:root {
  --background: #ffffff;
  --surface: #f4f4f3;
  --text: #202124;
  --muted: #666a70;
  --line: #d9dadd;
  --accent: #c8102e;
  --accent-dark: #9f0d25;
  --header-bg: rgba(255, 255, 255, 0.96);
  --shell: min(1040px, calc(100vw - 48px));
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

/* Dark theme: applied automatically when the visitor's system prefers dark,
   unless they have explicitly chosen light; the header toggle can force either. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #15161a;
    --surface: #1d1f24;
    --text: #e7e8ec;
    --muted: #9a9ea7;
    --line: #32353c;
    --accent: #ff5d6c;
    --accent-dark: #ff8591;
    --header-bg: rgba(21, 22, 26, 0.92);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --background: #15161a;
  --surface: #1d1f24;
  --text: #e7e8ec;
  --muted: #9a9ea7;
  --line: #32353c;
  --accent: #ff5d6c;
  --accent-dark: #ff8591;
  --header-bg: rgba(21, 22, 26, 0.92);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: 4px;
  z-index: 60;
  background: var(--accent);
}
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
img { display: block; max-width: 100%; }
button { font: inherit; }
.shell { width: var(--shell); margin-inline: auto; }

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--text);
  color: white;
  transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--header-bg);
  border-bottom: 1px solid transparent;
  backdrop-filter: blur(12px);
}
.site-header.scrolled { border-bottom-color: var(--line); }
.header-inner {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}
.brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.site-nav { display: flex; align-items: center; gap: 26px; }
.site-nav a,
.menu-button { color: var(--muted); font-size: 14px; }
.site-nav a:hover,
.site-nav a:focus-visible,
.site-nav a[aria-current="page"] { color: var(--text); }
.site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 7px; text-decoration-thickness: 2px; }
.menu-button { display: none; padding: 8px 0; border: 0; background: transparent; }

.intro-section {
  padding: 78px 0 84px;
  border-bottom: 1px solid var(--line);
}
.intro-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: clamp(56px, 10vw, 112px);
  align-items: center;
}
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; }
h1 {
  margin-bottom: 22px;
  font-size: clamp(42px, 5vw, 58px);
  line-height: 1.08;
  letter-spacing: -0.03em;
}
.position {
  max-width: 690px;
  margin-bottom: 14px;
  font-size: 18px;
  line-height: 1.52;
}
.summary {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
}
.profile-links,
.inline-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 28px;
}
.profile-links a,
.inline-links a,
.section-heading > a,
.text-link {
  padding-bottom: 1px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.profile-links a:hover,
.inline-links a:hover,
.section-heading > a:hover,
.text-link:hover { border-bottom-color: currentColor; }
.portrait { margin: 0; }
.portrait img {
  width: 210px;
  height: 210px;
  object-fit: cover;
  border-radius: 2px;
}

.content-section {
  padding: 76px 0;
  border-bottom: 1px solid var(--line);
}
.section-layout {
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr);
  gap: clamp(50px, 8vw, 96px);
}
.section-heading h2 {
  margin-bottom: 18px;
  font-size: 29px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.section-heading > a { color: var(--muted); line-height: 1.35; }
.section-note { margin: 0; color: var(--muted); font-size: 14px; }

.work-list { border-top: 1px solid var(--line); }
.work-item,
.publication-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 176px;
  gap: 32px;
  align-items: start;
  padding: 24px 0 26px;
  border-bottom: 1px solid var(--line);
}
.work-item h3,
.publication-item h2,
.publication-item h3 {
  margin-bottom: 6px;
  font-size: 22px;
  line-height: 1.28;
  letter-spacing: -0.015em;
}
.work-item p,
.publication-item p { margin-bottom: 0; color: var(--muted); font-size: 15px; }
.work-item > span,
.publication-meta {
  padding-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: right;
}
.publication-authors { margin-bottom: 8px !important; color: var(--text) !important; }
.publication-summary { max-width: 720px; }
.year-heading {
  margin: 48px 0 12px;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.year-heading:first-child { margin-top: 0; }

.data-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 38px; }
.data-grid article, .dataset {
  padding-top: 18px;
  border-top: 2px solid var(--accent);
}
.data-grid h3, .dataset h2 { margin-bottom: 10px; font-size: 21px; line-height: 1.3; letter-spacing: -0.01em; }
.data-grid p, .dataset p { margin-bottom: 0; color: var(--muted); font-size: 15px; }
.dataset + .dataset { margin-top: 50px; }
.dataset .dataset-meta { margin-bottom: 10px; color: var(--text); font-size: 14px; }
.dataset .inline-links { margin-top: 20px; }

.about-section { background: var(--surface); }
.about-copy { max-width: 720px; }
.about-copy > p { margin-bottom: 20px; font-size: 17px; }
.affiliations {
  margin: 34px 0 0;
  padding: 22px 0 0;
  border-top: 1px solid var(--line);
  list-style: none;
}
.affiliations li { margin: 0 0 10px; }
.affiliations a { border-bottom: 1px solid var(--line); }
.details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin: 38px 0 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.details dt { margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.details dd { margin: 0; font-size: 14px; }
.details a { border-bottom: 1px solid var(--line); }

.page-header { padding: 70px 0 54px; border-bottom: 1px solid var(--line); }
.page-header-inner { max-width: 780px; }
.page-header h1 { margin-bottom: 14px; font-size: clamp(38px, 4.8vw, 52px); }
.page-header p { max-width: 720px; margin-bottom: 0; color: var(--muted); font-size: 17px; }
.page-content { padding: 64px 0 90px; }
.page-content-narrow { max-width: 780px; }
.page-section + .page-section { margin-top: 72px; }
.page-section > h2 {
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  font-size: 28px;
  line-height: 1.25;
}
.paper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 32px;
  padding: 25px 0 28px;
  border-bottom: 1px solid var(--line);
}
.paper:first-of-type { border-top: 1px solid var(--line); }
.paper h2, .paper h3 { margin-bottom: 7px; font-size: 23px; line-height: 1.3; letter-spacing: -0.015em; }
.paper .authors { margin-bottom: 9px; color: var(--text); font-size: 15px; }
.paper .abstract { margin-bottom: 0; color: var(--muted); font-size: 15px; }
.paper .status { padding-top: 3px; color: var(--muted); font-size: 13px; text-align: right; }

.cv-panel {
  max-width: 760px;
  padding: 32px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
}
.cv-panel h2 { margin-bottom: 12px; font-size: 28px; }
.cv-panel p { color: var(--muted); }
.download-link {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  padding: 11px 16px;
  border: 1px solid var(--text);
  font-size: 14px;
  font-weight: 650;
}
.download-link:hover { border-color: var(--accent); }

.not-found { min-height: calc(100vh - 170px); display: grid; place-items: center; padding: 80px 0; }
.not-found-inner { max-width: 650px; }
.not-found .code { margin-bottom: 12px; color: var(--accent); font-size: 14px; font-weight: 700; letter-spacing: .08em; }
.not-found h1 { margin-bottom: 14px; }
.not-found p { color: var(--muted); font-size: 17px; }

.site-footer { padding: 25px 0 34px; }
.footer-inner { display: flex; justify-content: space-between; gap: 24px; color: var(--muted); font-size: 13px; }
.footer-inner a { border-bottom: 1px solid var(--line); }

.external::after { content: " ↗"; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* Theme toggle (injected into the nav by script.js) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  border: 0;
  padding: 8px 0;
  background: transparent;
  color: var(--muted);
  line-height: 0;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--text); }

/* Clickable-card affordance: title turns accent with a trailing arrow on hover */
.work-item h3 { transition: color 0.15s ease; }
.work-item:hover h3,
.work-item:focus-visible h3 { color: var(--accent); }
.work-item:hover h3::after,
.work-item:focus-visible h3::after { content: "\00a0→"; }

/* Status pills for working papers */
.status-pill {
  display: inline-block;
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.status-pill--active { border-color: var(--accent); color: var(--accent); }

/* Publications: group-by toggle + per-item PDF/appendix links */
.pub-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }
.pub-controls-label { color: var(--muted); font-size: 13px; }
.pub-controls button {
  padding: 5px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.pub-controls button:hover { color: var(--text); }
.pub-controls button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.publication-item .inline-links { margin-top: 12px; gap: 16px; }

/* News list */
.news-list { border-top: 1px solid var(--line); }
.news-item {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 28px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.news-date { color: var(--accent); font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.news-item p { margin: 0; font-size: 15px; }

/* Coauthor links inside author lines — subtle, discoverable on hover */
.authors a,
.publication-authors a { border-bottom: 1px solid var(--line); }
.authors a:hover,
.publication-authors a:hover { border-bottom-color: currentColor; }

/* Social links row */
.social-links { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 20px; }
.social-links a {
  padding-bottom: 1px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.social-links a:hover { border-bottom-color: currentColor; }

@media (max-width: 820px) {
  :root { --shell: min(100% - 36px, 700px); }
  .menu-button { display: block; }
  .site-nav {
    position: absolute;
    inset: 70px 18px auto;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 18px;
    background: var(--background);
    border: 1px solid var(--line);
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: 13px 0; border-bottom: 1px solid var(--line); }
  .site-nav a:last-child { border-bottom: 0; }
  .site-nav a[aria-current="page"] { text-decoration: none; color: var(--accent); }
  .site-nav .theme-toggle { padding: 13px 0; text-align: left; }
  .intro-layout { grid-template-columns: 1fr 170px; gap: 42px; }
  .portrait img { width: 170px; height: 170px; }
  .section-layout { grid-template-columns: 1fr; gap: 32px; }
  .section-heading { display: flex; justify-content: space-between; gap: 24px; align-items: baseline; }
  .section-heading h2 { margin-bottom: 0; }
}

@media (max-width: 600px) {
  :root { --shell: calc(100vw - 28px); }
  .intro-section { padding: 52px 0 62px; }
  .intro-layout { grid-template-columns: 1fr; gap: 30px; }
  h1 { font-size: 42px; }
  .position, .summary { font-size: 17px; }
  .portrait { order: -1; }
  .portrait img { width: 128px; height: 128px; }
  .content-section { padding: 58px 0; }
  .section-heading { display: block; }
  .section-heading h2 { margin-bottom: 11px; font-size: 27px; }
  .work-item, .publication-item, .paper { grid-template-columns: 1fr; gap: 10px; }
  .work-item h3, .publication-item h2, .publication-item h3, .paper h2, .paper h3 { font-size: 21px; }
  .work-item > span, .publication-meta, .paper .status { padding-top: 0; text-align: left; }
  .data-grid, .details { grid-template-columns: 1fr; gap: 28px; }
  .news-item { grid-template-columns: 1fr; gap: 4px; }
  .page-header { padding: 50px 0 42px; }
  .page-content { padding: 48px 0 70px; }
  .cv-panel { padding: 24px; }
  .footer-inner { flex-direction: column; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
