:root {
  --bg: #FAF9F6;
  --bg-elevated: #F2F0EA;
  --fg: #141413;
  --fg-secondary: #52514E;
  --fg-muted: #787772;
  --border: #E2E0D8;
  --border-strong: #141413;
  --accent: #141413;
  --selection-bg: #141413;
  --selection-fg: #FAF9F6;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --max-width: 780px;
  --space-xs: 0.375rem;
  --space-sm: 0.75rem;
  --space-md: 1.25rem;
  --space-lg: 2.25rem;
  --space-xl: 3.75rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E0E0D;
    --bg-elevated: #181816;
    --fg: #EDEDEB;
    --fg-secondary: #B5B4AE;
    --fg-muted: #7E7D78;
    --border: #262624;
    --border-strong: #EDEDEB;
    --accent: #EDEDEB;
    --selection-bg: #EDEDEB;
    --selection-fg: #0E0E0D;
  }
}

:root[data-theme="dark"] {
  --bg: #0E0E0D;
  --bg-elevated: #181816;
  --fg: #EDEDEB;
  --fg-secondary: #B5B4AE;
  --fg-muted: #7E7D78;
  --border: #262624;
  --border-strong: #EDEDEB;
  --accent: #EDEDEB;
  --selection-bg: #EDEDEB;
  --selection-fg: #0E0E0D;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

::selection {
  background-color: var(--selection-bg);
  color: var(--selection-fg);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: 1.7;
  letter-spacing: 0.01em;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Language visibility control */
html[data-lang="ja"] [data-i18n="en"] {
  display: none !important;
}

html[data-lang="en"] [data-i18n="ja"] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

a:hover {
  opacity: 0.68;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Top Bar */
.site-header {
  padding: 2rem 0 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-secondary);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  padding: 0.25rem 0.55rem;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lang-btn:hover {
  color: var(--fg);
}

.lang-btn.is-active {
  background-color: var(--fg);
  color: var(--bg);
  font-weight: 500;
}

.theme-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--fg-secondary);
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.theme-btn:hover {
  border-color: var(--fg-muted);
  color: var(--fg);
}

.theme-btn svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* Hero Section */
.hero {
  padding: 3.5rem 0 3rem;
  border-bottom: 1px solid var(--border);
}

.hero-name {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 0.35rem;
}

.hero-name-sub {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--fg-muted);
  letter-spacing: 0.02em;
  margin-bottom: 1.5rem;
}

.hero-affiliations {
  list-style: none;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.hero-affiliations li {
  font-size: 0.9375rem;
  color: var(--fg);
  font-weight: 500;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}

.role-badge {
  color: var(--fg-secondary);
  font-weight: 400;
}

.hero-bio {
  font-size: 0.9375rem;
  color: var(--fg-secondary);
  margin-bottom: 1.75rem;
}

.keyword-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  margin-bottom: 1.75rem;
}

.keyword-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-secondary);
  background-color: var(--bg-elevated);
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.1rem;
}

.hero-link:hover {
  border-bottom-color: var(--fg);
  opacity: 1;
}

.arrow-up-right {
  font-size: 0.75em;
  color: var(--fg-muted);
}

.email-copy-btn {
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.1rem;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: border-color 0.15s ease;
}

.email-copy-btn:hover {
  border-bottom-color: var(--fg);
}

.copy-feedback {
  font-size: 0.7rem;
  color: var(--fg-muted);
}

/* Main Sections */
.section {
  padding: 2.75rem 0;
  border-bottom: 1px solid var(--border);
}

.section:last-of-type {
  border-bottom: none;
}

.section-header {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  margin-bottom: 1.75rem;
}

.section-index {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
  letter-spacing: 0.05em;
}

.section-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg);
}

/* Swiss Timeline Grid (Experience, Education, Design, Grants) */
.timeline-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.timeline-item {
  display: grid;
  grid-template-columns: 155px 1fr;
  gap: 1.25rem;
  align-items: baseline;
}

.timeline-period {
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  color: var(--fg-muted);
  letter-spacing: 0.01em;
  line-height: 1.5;
}

.timeline-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.timeline-org {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--fg);
  line-height: 1.5;
}

.timeline-role {
  font-size: 0.875rem;
  color: var(--fg-secondary);
  line-height: 1.5;
}

.timeline-meta {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
  margin-top: 0.15rem;
}

/* Subsections inside Publications */
.subsection {
  margin-bottom: 2.25rem;
}

.subsection:last-child {
  margin-bottom: 0;
}

.subsection-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  margin-bottom: 1rem;
}

.pub-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.pub-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 1rem;
  align-items: baseline;
}

.pub-year {
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  color: var(--fg-muted);
}

.pub-citation {
  font-size: 0.9rem;
  color: var(--fg-secondary);
  line-height: 1.65;
}

.pub-citation strong {
  color: var(--fg);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
}

.pub-title {
  color: var(--fg);
  font-weight: 500;
}

.pub-journal {
  font-style: italic;
}

/* Societies List */
.society-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  font-size: 0.9rem;
  color: var(--fg-secondary);
}

.society-list li {
  position: relative;
}

/* Footer */
.site-footer {
  padding: 2.5rem 0 3.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--fg-muted);
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .site-header {
    padding: 1.5rem 0 1rem;
  }

  .hero {
    padding: 2.5rem 0 2.25rem;
  }

  .section {
    padding: 2.25rem 0;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 0.2rem;
  }

  .pub-item {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
}

/* Technical Notes & Appendix Pages */
.container--wide {
  max-width: 920px;
}

.back-nav {
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  color: var(--fg-muted);
}

.back-nav a {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.1rem;
}

.back-nav a:hover {
  border-bottom-color: var(--fg);
  color: var(--fg);
  opacity: 1;
}

.note-meta {
  font-family: var(--font-mono);
  font-size: 0.78125rem;
  color: var(--fg-muted);
  margin-bottom: 0.5rem;
}

.note-title {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
  margin-bottom: 1rem;
}

.note-lead {
  font-size: 0.9375rem;
  color: var(--fg-secondary);
  line-height: 1.75;
  margin-bottom: 1.25rem;
}

.note-prose p {
  font-size: 0.925rem;
  color: var(--fg-secondary);
  line-height: 1.75;
  margin-bottom: 1rem;
}

.note-prose ul,
.note-prose ol {
  padding-left: 1.25rem;
  margin-bottom: 1.25rem;
  font-size: 0.925rem;
  color: var(--fg-secondary);
  line-height: 1.75;
}

.note-prose li {
  margin-bottom: 0.4rem;
}

.note-prose strong {
  color: var(--fg);
  font-weight: 600;
}

.note-prose code {
  font-family: var(--font-mono);
  font-size: 0.8125em;
  background-color: var(--bg-elevated);
  padding: 0.12rem 0.35rem;
  border-radius: 2px;
  color: var(--fg);
}

.note-figure {
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: #ffffff;
}

.note-figure img {
  display: block;
  width: 100%;
  height: auto;
}

.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 1.25rem 0 1.75rem;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
  line-height: 1.5;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fg);
  background-color: var(--bg-elevated);
  white-space: nowrap;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table td code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background-color: var(--bg-elevated);
  padding: 0.1rem 0.3rem;
  border-radius: 2px;
}

