/* ---------- Tokens ---------- */
:root {
  --bg: #f7f5f0;
  --surface: #fffdf8;
  --ink: #17201f;
  --muted: #5b6664;
  --line: #dedad0;
  --accent: #0f6b5c;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe9;
  --warm: #b4542a;
  --warm-soft: #f6e6dc;
  --gold: #8a6a12;
  --gold-soft: #f3ecd4;
  --shadow: 0 1px 2px rgba(23, 32, 31, .05), 0 8px 24px rgba(23, 32, 31, .05);

  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Consolas, monospace;

  --wrap: 1120px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1413;
    --surface: #151d1b;
    --ink: #e8ece9;
    --muted: #9aa7a3;
    --line: #27322f;
    --accent: #5fd0b5;
    --accent-ink: #06231d;
    --accent-soft: #16302a;
    --warm: #eb9a6c;
    --warm-soft: #3a2418;
    --gold: #d9bb5c;
    --gold-soft: #33290f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1413;
  --surface: #151d1b;
  --ink: #e8ece9;
  --muted: #9aa7a3;
  --line: #27322f;
  --accent: #5fd0b5;
  --accent-ink: #06231d;
  --accent-soft: #16302a;
  --warm: #eb9a6c;
  --warm-soft: #3a2418;
  --gold: #d9bb5c;
  --gold-soft: #33290f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
abbr { text-decoration: none; }
em { font-style: italic; }
.nowrap { white-space: nowrap; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--gutter); }

.skip {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 8px 14px; border-radius: 8px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; min-width: 0; }
.brand-mark {
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em;
  background: var(--accent); color: var(--accent-ink);
  padding: 5px 7px; border-radius: 6px;
}
.brand-name { font-family: var(--serif); font-weight: 500; font-size: 17px; white-space: nowrap; }
.brand:hover { color: var(--ink); }

.nav { display: flex; gap: 4px; }
.nav a {
  font-size: 14px; color: var(--muted); text-decoration: none;
  padding: 6px 10px; border-radius: 8px;
  transition: color .15s, background-color .15s;
}
.nav a:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.nav a.is-current { color: var(--accent); }

.theme-toggle {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: border-color .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ---------- Hero ---------- */
.hero { padding: clamp(48px, 9vw, 104px) 0 clamp(40px, 6vw, 72px); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); gap: clamp(32px, 6vw, 80px); align-items: center; }

.eyebrow, .section-num, .tag, .when, .doi {
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .04em;
}
.eyebrow { color: var(--accent); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 22px; }

h1 {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(44px, 8.2vw, 92px); line-height: .98; letter-spacing: -.025em;
  font-variation-settings: "opsz" 144;
  text-wrap: balance;
}
.lede { margin-top: 28px; font-size: clamp(18px, 2vw, 21px); line-height: 1.55; color: var(--muted); max-width: 34em; }
.lede em { color: var(--ink); }
.lede abbr { color: var(--ink); font-weight: 500; }

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 20px; border-radius: 999px;
  font-size: 15px; font-weight: 500; text-decoration: none;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: transform .15s, border-color .15s, background-color .15s, color .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { color: var(--accent-ink); background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }

.hero-links { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 26px; font-size: 15px; color: var(--muted); }
.hero-links a { text-decoration: none; }
.hero-links a:hover { text-decoration: underline; }

/* Alignment motif */
.alignment {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px 18px 20px; box-shadow: var(--shadow);
}
.alignment figcaption {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 12px;
}
.alignment figcaption span:last-child { color: var(--warm); }
.alignment-grid {
  display: grid; grid-template-columns: repeat(var(--cols, 18), minmax(0, 1fr)); gap: 3px;
  font-family: var(--mono); font-size: clamp(9px, 1.05vw, 12px); line-height: 1;
}
.alignment-grid span {
  display: grid; place-items: center; aspect-ratio: 1;
  border-radius: 4px; color: color-mix(in srgb, var(--muted) 70%, transparent);
  background: color-mix(in srgb, var(--ink) 3.5%, transparent);
}
.alignment-grid .ref { color: var(--ink); background: color-mix(in srgb, var(--ink) 9%, transparent); font-weight: 500; }
.alignment-grid .var { color: var(--warm); background: var(--warm-soft); font-weight: 500; }
.alignment-grid .hit { color: var(--accent); background: var(--accent-soft); }

/* Facts */
.facts {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: clamp(40px, 7vw, 80px);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.facts > div { padding: 22px 20px 22px 0; display: flex; flex-direction: column-reverse; gap: 4px; }
.facts > div + div { padding-left: 20px; border-left: 1px solid var(--line); }
.facts dt { font-size: 14px; color: var(--muted); line-height: 1.35; }
.facts dd { font-family: var(--serif); font-size: clamp(32px, 4.4vw, 46px); line-height: 1; font-weight: 500; font-variant-numeric: lining-nums; }

/* ---------- Sections ---------- */
.section { padding: clamp(56px, 8vw, 104px) 0; border-top: 1px solid var(--line); }
.hero + .section { border-top: 0; }
.two-col { display: grid; grid-template-columns: minmax(0, 250px) minmax(0, 1fr); gap: clamp(24px, 5vw, 72px); align-items: start; }
.section-head { position: sticky; top: 96px; }
.section-num { color: var(--accent); margin-bottom: 10px; }
h2 { font-family: var(--serif); font-weight: 500; font-size: clamp(28px, 3.4vw, 38px); line-height: 1.1; letter-spacing: -.015em; text-wrap: balance; }

.prose p { max-width: 62ch; }
.prose p + p { margin-top: 1.1em; }
.subhead {
  font-family: var(--mono); font-weight: 500; font-size: 12.5px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px;
}
.subhead-spaced { margin-top: 56px; }
.when { color: var(--muted); white-space: nowrap; text-align: right; line-height: 1.5; flex: none; }
.when span { opacity: .85; }
.tag { color: var(--accent); text-transform: uppercase; letter-spacing: .08em; font-size: 11.5px; margin-bottom: 6px; }

/* Education */
.edu { margin-top: 44px; }
.edu-list li {
  display: flex; justify-content: space-between; gap: 20px; align-items: baseline;
  padding: 16px 0; border-top: 1px solid var(--line);
}
.edu-list li:last-child { border-bottom: 1px solid var(--line); }
.edu-degree { font-weight: 500; }
.edu-school { color: var(--muted); font-size: 15.5px; }

/* Roles */
.role + .role { margin-top: 56px; padding-top: 56px; border-top: 1px solid var(--line); }
.role-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 22px; }
.role-head h3, .entry-head h3 { font-family: var(--serif); font-weight: 500; font-size: 24px; line-height: 1.2; letter-spacing: -.01em; }
.role-org { margin-top: 4px; font-weight: 500; font-size: 15.5px; }
.role-pi { color: var(--muted); font-size: 15px; }

.projects { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.projects:has(.project:only-child) { grid-template-columns: 1fr; }
.project {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 22px 22px;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.project:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); transform: translateY(-2px); box-shadow: var(--shadow); }
.project h4 { font-size: 16.5px; font-weight: 600; line-height: 1.35; margin-bottom: 8px; }
.project p:not(.tag) { font-size: 15.5px; color: var(--muted); line-height: 1.55; }

/* Publications */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.filter {
  font: inherit; font-size: 14px; cursor: pointer;
  padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  transition: color .15s, border-color .15s, background-color .15s;
}
.filter span { font-family: var(--mono); font-size: 12px; margin-left: 4px; opacity: .75; }
.filter:hover { color: var(--ink); border-color: var(--muted); }
.filter.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.pubs { counter-reset: pub; border-top: 1px solid var(--line); }
.pub {
  counter-increment: pub; position: relative;
  padding: 22px 0 22px 52px; border-bottom: 1px solid var(--line);
}
.pub::before {
  content: counter(pub, decimal-leading-zero);
  position: absolute; left: 0; top: 25px;
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
}
.pub[hidden] { display: none; }
.pub-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.badge {
  font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px; line-height: 1.5;
}
.badge-pub { background: var(--accent-soft); color: var(--accent); }
.badge-review { background: var(--gold-soft); color: var(--gold); }
.badge-prep { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--muted); }
.badge-first { background: var(--warm-soft); color: var(--warm); }
.pub h3 { font-family: var(--serif); font-weight: 500; font-size: 20px; line-height: 1.32; letter-spacing: -.005em; max-width: 46em; }
.pub h3 a { text-decoration: none; background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat; transition: background-size .25s; }
.pub h3 a:hover { background-size: 100% 1px; }
.pub-authors { margin-top: 8px; font-size: 15px; color: var(--muted); max-width: 60em; }
.pub-authors strong, .talk-detail strong { color: var(--ink); font-weight: 600; }
.pub-venue { margin-top: 4px; font-size: 15px; }
.doi { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

.talks li { padding: 18px 0; border-top: 1px solid var(--line); }
.talks li:last-child { border-bottom: 1px solid var(--line); }
.talk-title { font-weight: 500; font-size: 17px; line-height: 1.4; }
.talk-detail { margin-top: 4px; font-size: 15px; color: var(--muted); }

/* Skills */
.skills-grid { display: grid; gap: 18px; }
.skill-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 26px 28px 12px; }
.skill-card h3 { font-family: var(--serif); font-weight: 500; font-size: 22px; margin-bottom: 14px; }
.skill-list > div {
  display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 16px; align-items: baseline;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.skill-list dt { font-size: 14.5px; color: var(--muted); }
.skill-list dd { display: flex; flex-wrap: wrap; gap: 6px; }
.skill-list dd span {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.4;
  padding: 4px 9px; border-radius: 7px;
  background: color-mix(in srgb, var(--ink) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 7%, transparent);
}

/* Entries */
.entries li { padding: 24px 0; border-top: 1px solid var(--line); }
.entries li:first-child { padding-top: 0; border-top: 0; }
.entry-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 10px; }
.entry-head h3 { font-size: 21px; }
.entries li > p { color: var(--muted); font-size: 16px; max-width: 64ch; }

/* Contact */
.contact { text-align: left; }
.contact h2 { font-size: clamp(36px, 6vw, 68px); letter-spacing: -.025em; max-width: 14em; }
.contact-lede { margin-top: 20px; color: var(--muted); font-size: 19px; max-width: 36em; }
.contact-mail {
  display: inline-block; margin-top: 34px;
  font-family: var(--serif); font-size: clamp(24px, 4.6vw, 44px); line-height: 1.2;
  color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 6px; overflow-wrap: anywhere;
}
.contact-links { display: flex; flex-wrap: wrap; gap: 10px 26px; margin-top: 30px; color: var(--muted); font-size: 16px; }
.contact-links a { text-decoration: none; }
.contact-links a:hover { text-decoration: underline; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 26px 0 34px; font-size: 14px; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer a { text-decoration: none; }

/* Reveal */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-in { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .nav { display: none; }
  .two-col { grid-template-columns: 1fr; gap: 28px; }
  .section-head { position: static; }
  .hero-grid { grid-template-columns: 1fr; }
  .alignment { max-width: 520px; }
}
@media (max-width: 680px) {
  body { font-size: 16px; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts > div { padding: 18px 12px 18px 0; }
  .facts > div + div { padding-left: 0; border-left: 0; }
  .facts > div:nth-child(even) { padding-left: 16px; border-left: 1px solid var(--line); }
  .facts > div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .projects { grid-template-columns: 1fr; }
  .role-head, .entry-head, .edu-list li { flex-direction: column; gap: 6px; }
  .when { text-align: left; }
  .when br { display: none; }
  .when span::before { content: " · "; }
  .skill-list > div { grid-template-columns: 1fr; gap: 8px; }
  .skill-card { padding: 22px 18px 8px; }
  .pub { padding-left: 0; }
  .pub::before { position: static; display: block; margin-bottom: 8px; }
  .pub h3 { font-size: 18.5px; }
  .brand-name { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  * { transition-duration: 0s !important; }
}

@media print {
  .site-header, .theme-toggle, .filters, .alignment, .hero-actions { display: none; }
  .section { padding: 24px 0; }
  .reveal { opacity: 1; transform: none; }
}
