:root {
  --bg: #fbfbfa;
  --bg-elevated: #ffffff;
  --bg-hover: #f5f5f4;
  --bg-header: rgba(251, 251, 250, 0.9);
  --text: #191919;
  --text-secondary: #6b6b6b;
  --text-muted: #9b9b9b;
  --border: #e8e8e6;
  --border-strong: #d4d4d2;
  --btn-primary-hover: #333333;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --radius: 8px;
  --radius-lg: 12px;
  --max-width: 1000px;
  --nav-height: 52px;
  --space-section: clamp(3rem, 8vw, 5.5rem);
  --container-padding: clamp(1rem, 4vw, 1.5rem);
}

[data-theme="dark"] {
  --bg: #232326;
  --bg-elevated: #2e2e31;
  --bg-hover: #38383c;
  --bg-header: rgba(35, 35, 38, 0.92);
  --text: #ededee;
  --text-secondary: #b0b0b5;
  --text-muted: #88888f;
  --border: #3f3f44;
  --border-strong: #52525a;
  --btn-primary-hover: #d4d4d4;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.18);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.22);
}

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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body.nav-open {
  overflow: hidden;
}

body {
  overflow-x: hidden;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: max(var(--container-padding), env(safe-area-inset-left, 0px));
  padding-right: max(var(--container-padding), env(safe-area-inset-right, 0px));
}

.section {
  padding: var(--space-section) 0;
  scroll-margin-top: calc(var(--nav-height) + 0.75rem);
}

#about {
  padding-top: clamp(2.5rem, 8vw, 4rem);
  padding-bottom: clamp(1.25rem, 3.5vw, 2rem);
}

#publications {
  padding-top: clamp(1.25rem, 3.5vw, 2rem);
  padding-bottom: clamp(1.25rem, 3.5vw, 2rem);
}

#contact {
  padding-top: clamp(1.25rem, 3.5vw, 2rem);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.section-intro {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  max-width: 42ch;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(8px);
  transition: background-color 0.2s ease;
}

.navbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--nav-height);
}

.brand {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  transition: color 0.2s ease;
}

.brand:hover {
  color: var(--text-secondary);
}

.nav-start {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 1.75rem;
}

.nav-links a {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  width: 1.125rem;
  height: 1.5px;
  background: var(--text);
  border-radius: 1px;
  transition: opacity 0.2s ease;
}

.page-header {
  margin-bottom: 2rem;
}

.subsection {
  margin-top: 2.5rem;
}

.subsection-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.page-heading {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 0.75rem;
  overflow-wrap: break-word;
}

.page-intro {
  font-size: clamp(0.9375rem, 2vw + 0.5rem, 1.0625rem);
  color: var(--text-secondary);
  max-width: 65ch;
  line-height: 1.75;
}

.intro-link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.intro-link:hover {
  color: var(--text-secondary);
  text-decoration-color: var(--text);
}

.about-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.news-feed {
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.news-feed::-webkit-scrollbar {
  width: 6px;
}

.news-feed::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

.news-item {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.news-item:last-child {
  border-bottom: none;
}

.news-date {
  flex-shrink: 0;
  width: 4.75rem;
  padding-top: 0.125rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.4;
}

.news-content {
  flex: 1;
  min-width: 0;
}

.news-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 0.35rem;
}

.news-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.eyebrow {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.btn-primary {
  background: var(--text);
  color: var(--bg-elevated);
  border: 1px solid var(--text);
}

.btn-primary:hover {
  background: var(--btn-primary-hover);
  border-color: var(--btn-primary-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.card,
.contact-link,
.btn,
.site-header {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

/* Theme switch — next to brand */
.theme-switch {
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.theme-switch-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 3.5rem;
  height: 1.75rem;
  padding: 2px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.theme-switch:hover .theme-switch-track {
  border-color: var(--border-strong);
}

.theme-switch-icon {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.theme-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(50% - 3px);
  height: calc(100% - 4px);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: left 0.25s ease, background-color 0.2s ease, border-color 0.2s ease;
  pointer-events: none;
}

[data-theme="dark"] .theme-switch-thumb {
  left: calc(50% + 1px);
}

[data-theme="light"] .theme-switch-sun,
:root:not([data-theme="dark"]) .theme-switch-sun {
  color: var(--text);
}

[data-theme="dark"] .theme-switch-moon {
  color: var(--text);
}

/* About */
.about-layout {
  display: flex;
  align-items: flex-start;
  gap: clamp(1.5rem, 4vw, 2.5rem);
}

.about-photo {
  flex-shrink: 0;
  margin: 0;
}

.about-photo-img {
  display: block;
  width: clamp(7.5rem, 22vw, 11.25rem);
  height: clamp(7.5rem, 22vw, 11.25rem);
  border-radius: 30px;
  object-fit: cover;
  object-position: center top;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.about-body {
  flex: 1;
  min-width: 0;
}

.about-body .page-header {
  margin-bottom: 0;
}

.about-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.about-content p {
  color: var(--text-secondary);
  font-size: clamp(0.9375rem, 2vw + 0.5rem, 1.0625rem);
  max-width: 52ch;
}

/* Publications */
.publication-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 100%;
}

.publication-item {
  padding: 1.25rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.publication-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.publication-content {
  min-width: 0;
}

.pub-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.pub-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  background: var(--bg-hover);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  cursor: default;
  user-select: none;
}

.pub-type {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.publication-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
  margin-bottom: 0.5rem;
}

.publication-authors {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 0.4rem;
}

.publication-details {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pub-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: default;
  user-select: none;
}

.card {
  padding: 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.card h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.card p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 1rem;
}

.card-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  transition: text-decoration-color 0.2s ease;
}

.card-link:hover {
  text-decoration-color: var(--text);
}

/* Contact */
.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 32rem;
  width: 100%;
}

.contact-link {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  font-size: clamp(0.875rem, 2vw + 0.25rem, 0.9375rem);
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.contact-link:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.contact-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.contact-link:hover .contact-icon {
  color: var(--text);
}

.contact-text {
  flex: 1;
  min-width: 0;
}

/* Footer */
.site-footer {
  padding: 1rem 0 1.5rem;
  border-top: 1px solid var(--border);
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  text-align: center;
}

.site-footer p {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

.footer-link:hover {
  color: var(--text);
  text-decoration-color: var(--text);
}

/* Responsive — tablet */
@media (max-width: 768px) {
  :root {
    --nav-height: 48px;
  }

  .menu-toggle {
    display: flex;
    flex-shrink: 0;
  }

  .nav-links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: 0.5rem var(--container-padding) 1rem;
    background: var(--bg-header);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
  }

  .nav-links.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .nav-links li {
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
  }

  .nav-links li:last-child {
    border-bottom: none;
  }

  .nav-links a {
    display: block;
    padding: 0.125rem 0;
  }

  .page-heading {
    max-width: none;
  }

  .about-layout {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .about-body {
    width: 100%;
  }

  .about-body .page-header,
  .about-content p,
  .page-intro,
  .about-actions,
  .subsection {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
  }

  .about-actions,
  .tag-list {
    justify-content: center;
  }

  .news-item {
    flex-direction: column;
    gap: 0.35rem;
    text-align: left;
  }

  .news-date {
    width: auto;
  }

  .section-intro {
    margin-bottom: 1.5rem;
  }
}

/* Responsive — mobile */
@media (max-width: 480px) {
  :root {
    --nav-height: 44px;
  }

  .brand {
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .card {
    padding: 1.125rem;
  }

  .site-footer {
    padding: 1.5rem 0 2rem;
  }

  .site-footer p {
    font-size: 0.75rem;
  }
}

/* Responsive — very small screens */
@media (max-width: 320px) {
  .theme-switch-track {
    width: 3.125rem;
    height: 1.625rem;
  }
}

/* Medium screens — prevent nav cramping */
@media (min-width: 769px) and (max-width: 900px) {
  .nav-links {
    gap: 1.25rem;
  }

  .nav-links a {
    font-size: 0.8125rem;
  }
}
