/* ---------- tokens ---------- */
:root {
  --bg:        #fbfaf7;
  --bg-soft:   #f3f1ea;
  --surface:   #ffffff;
  --text:      #17191a;
  --muted:     #585f5c;
  --faint:     #858a87;
  --line:      #e4e1d8;
  --accent:    #0e6a5c;
  --accent-soft:#e2efeb;
  --on-accent: #fbfaf7;
  --shadow:    0 1px 2px rgba(20,24,22,.05), 0 10px 28px -18px rgba(20,24,22,.28);
  --radius:    12px;
  --maxw:      880px;
  --serif:     "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans:      "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --nav-h:     56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0f1211;
    --bg-soft:   #171b1a;
    --surface:   #151918;
    --text:      #ebe9e3;
    --muted:     #a3a9a6;
    --faint:     #7c827f;
    --line:      #262c2a;
    --accent:    #5fd4bf;
    --accent-soft:#12302b;
    --on-accent: #0b0f0e;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 10px 28px -18px rgba(0,0,0,.8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:        #0f1211;
  --bg-soft:   #171b1a;
  --surface:   #151918;
  --text:      #ebe9e3;
  --muted:     #a3a9a6;
  --faint:     #7c827f;
  --line:      #262c2a;
  --accent:    #5fd4bf;
  --accent-soft:#12302b;
  --on-accent: #0b0f0e;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 10px 28px -18px rgba(0,0,0,.8);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 20px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

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

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 16px; min-height: var(--nav-h); }
.nav-name { font-family: var(--serif); font-size: 18px; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--text); }
.nav-links { display: flex; gap: 2px; margin-left: auto; overflow-x: auto; scrollbar-width: none; order: 2; }
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  display: block; padding: 6px 9px; border-radius: 6px; white-space: nowrap;
  font-size: 13.5px; color: var(--muted); text-decoration: none;
}
.nav-links a:hover { color: var(--text); background: var(--bg-soft); }
.nav-links a[aria-current] { color: var(--accent); background: var(--accent-soft); }
.theme-btn {
  flex: none; order: 3; width: 32px; height: 32px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--muted); cursor: pointer; padding: 0;
}
.theme-btn:hover { color: var(--text); }
.theme-btn svg { width: 15px; height: 15px; }
.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; }
}

/* small screens: name + toggle on top, links scroll sideways underneath */
@media (max-width: 760px) {
  :root { --nav-h: 96px; }
  .nav-inner { flex-wrap: wrap; gap: 0 12px; padding-top: 8px; }
  .nav-name { flex: 1; }
  .theme-btn { order: 2; }
  .nav-links {
    order: 3; flex-basis: calc(100% + 40px); margin: 6px -20px 0; padding: 0 14px 8px;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 24px), transparent);
            mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 24px), transparent);
  }
}

/* ---------- hero ---------- */
.hero { padding: 72px 20px 48px; }
.hero-top { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 36px; }
.hero-top > div { grid-row: 1; }
.portrait {
  grid-column: 2; width: 184px; height: 184px; border-radius: 50%; object-fit: cover;
  border: 4px solid var(--surface); box-shadow: 0 0 0 1px var(--line), var(--shadow);
}
@media (max-width: 680px) {
  .hero-top { grid-template-columns: 1fr; gap: 20px; }
  .hero-top > div { grid-row: auto; }
  .portrait { grid-column: 1; width: 104px; height: 104px; }
}
.hero h1 {
  font-size: clamp(20px, 3vw, 22px); font-family: var(--sans); font-weight: 600; letter-spacing: 0;
  margin: 0 0 10px; color: var(--accent);
}
.tagline {
  font-family: var(--serif); font-weight: 500; letter-spacing: -.02em; line-height: 1.08;
  font-size: clamp(38px, 7.4vw, 64px); margin: 0 0 20px; max-width: 16ch; text-wrap: balance;
}
.tagline em { font-style: italic; color: var(--accent); }
.hero .roles { margin: 0; color: var(--muted); font-size: 16.5px; }
.hero .roles strong { color: var(--text); font-weight: 600; }
.hero .roles span { color: var(--faint); }
.meta { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 14.5px; }
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.meta svg { width: 14px; height: 14px; flex: none; opacity: .75; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 8px; font-size: 14.5px; font-weight: 500;
  text-decoration: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  transition: transform .12s ease, border-color .12s ease;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.06); }

/* stat strip */
.highlights {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin: 40px 0 0;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
@media (max-width: 680px) { .highlights { grid-template-columns: repeat(2, 1fr); } }
.highlight { background: var(--surface); padding: 14px 16px; }
.highlight dt { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); margin: 0 0 4px; font-weight: 600; }
.highlight dd { margin: 0; font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: lining-nums; }
.highlight dd small { display: block; font-family: var(--sans); font-size: 12.5px; font-weight: 400; color: var(--muted); margin-top: 3px; }

/* ---------- sections ---------- */
section { padding: 48px 0; border-top: 1px solid var(--line); }
.sec-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 22px; }
.sec-head h2 { font-size: 27px; margin: 0; }
.sec-head .count { font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; }
.sec-head-sub { margin-top: 40px; }

.prose p { margin: 0 0 16px; max-width: 68ch; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 600; }

/* ---------- news ---------- */
.news { list-style: none; margin: 0; padding: 0; }
.news li { display: grid; grid-template-columns: 84px 1fr; gap: 16px; padding: 9px 0; }
.news-when { font-size: 13px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; padding-top: 2px; }
.news li:first-child .news-when { color: var(--accent); }
.news p { margin: 0; }
@media (max-width: 540px) { .news li { grid-template-columns: 1fr; gap: 0; } }

/* ---------- timeline ---------- */
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: grid; grid-template-columns: 1fr auto; gap: 2px 20px; padding: 14px 0; border-bottom: 1px dashed var(--line); }
.entry:last-child { border-bottom: none; }
.entry:first-child { padding-top: 0; }
.entry .role { font-weight: 600; font-size: 16px; }
.entry .org { grid-column: 1; color: var(--muted); font-size: 14.5px; }
.entry .org em { font-style: normal; color: var(--faint); }
.entry .when { grid-row: 1; grid-column: 2; color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 2px; }
.entry .when.now { color: var(--accent); font-weight: 500; }
@media (max-width: 540px) {
  .entry { grid-template-columns: 1fr; }
  .entry .when { grid-row: auto; grid-column: 1; }
}

/* ---------- research themes ---------- */
.themes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .themes { grid-template-columns: 1fr; } }
.theme {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; box-shadow: var(--shadow);
}
.theme:first-child { border-top: 3px solid var(--accent); }
.theme-num { margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--accent); }
.theme h3 { font-size: 20px; margin: 0 0 8px; }
.theme > p { margin: 0 0 12px; font-size: 14.5px; color: var(--muted); line-height: 1.6; }
.theme .theme-foot { margin: auto 0 0; font-size: 13px; font-weight: 600; color: var(--accent); }
.theme-papers { list-style: none; margin: auto 0 0; padding: 12px 0 0; border-top: 1px solid var(--line); font-size: 13.5px; display: grid; gap: 7px; }
.theme-papers li { line-height: 1.4; }
.theme-papers a { text-decoration: none; color: var(--text); font-weight: 500; }
.theme-papers a:hover { color: var(--accent); text-decoration: underline; }
.theme-papers span { color: var(--faint); white-space: nowrap; font-size: 12.5px; }
.theme-papers + .theme-foot { margin-top: 12px; }

/* ---------- publications ---------- */
.pub-featured { display: grid; gap: 12px; }
.pub-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 20px; box-shadow: var(--shadow);
  border-left: 3px solid var(--accent);
}
.pub-card .title { font-family: var(--serif); font-size: 19px; font-weight: 600; margin: 8px 0 6px; line-height: 1.3; }
.authors { color: var(--muted); font-size: 14px; line-height: 1.55; margin: 0; }
.authors .me { color: var(--text); font-weight: 600; }
.venue-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.chip.alt { background: var(--bg-soft); color: var(--muted); border-color: var(--line); }

.links { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.links a {
  font-size: 12.5px; font-weight: 500; text-decoration: none;
  padding: 2px 9px; border-radius: 6px;
  border: 1px solid var(--line); color: var(--muted); background: var(--bg-soft);
}
.links a:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.links a::after { content: " ↗"; font-size: 11px; opacity: .7; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 22px; }
.filter {
  font: inherit; font-size: 13.5px; padding: 5px 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px;
}
.filter:hover { color: var(--text); }
.filter[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 500; }

.pub-year { display: grid; grid-template-columns: 72px 1fr; gap: 0 20px; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.pub-year:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.pub-year[hidden] { display: none; }
.pub-year h3 {
  margin: 0; font-size: 22px; color: var(--faint); font-variant-numeric: lining-nums;
  position: sticky; top: calc(var(--nav-h) + 12px); align-self: start;
}
.pub-year ul { list-style: none; margin: 0; padding: 0; }
.pub-year li { padding: 0 0 18px; }
.pub-year li:last-child { padding-bottom: 6px; }
.pub-year li[hidden] { display: none !important; }
.pub-list .title { font-size: 15.5px; font-weight: 600; margin: 0 0 3px; line-height: 1.4; }
.pub-list .venue { font-size: 13.5px; color: var(--faint); margin: 3px 0 0; }
.pub-list .venue b { color: var(--muted); font-weight: 600; }
.star { color: var(--accent); margin-right: 5px; font-size: .9em; }
@media (max-width: 540px) {
  .pub-year { grid-template-columns: 1fr; }
  .pub-year h3 { position: static; font-size: 19px; margin-bottom: 10px; }
}
.note { font-size: 13px; color: var(--faint); margin-top: 20px; }

/* ---------- talks / bullets ---------- */
.talks { list-style: none; margin: 0; padding: 0; }
.talks > li { padding: 13px 0; border-bottom: 1px dashed var(--line); }
.talks > li:first-child { padding-top: 0; }
.talks > li:last-child { border-bottom: none; }
.talks .title { font-weight: 600; font-size: 15.5px; margin: 0 0 3px; }
.talks .where { color: var(--muted); font-size: 14px; }
.talks .host { color: var(--faint); font-size: 13.5px; }
.venues { margin: 4px 0 0; padding-left: 1.1em; }
.venues li { margin-bottom: 3px; }
.venues li::marker { color: var(--faint); }

.bullets { margin: 0; padding-left: 1.1em; }
.bullets li { margin-bottom: 8px; }
.bullets li:last-child { margin-bottom: 0; }
.bullets li::marker { color: var(--accent); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; gap: 26px; } }
.sub-h { font-family: var(--sans); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); margin: 0 0 12px; }

.skills { margin-top: 34px; }
.skills dl { margin: 0; display: grid; gap: 12px; }
.skills dt { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); }
.skills dd { margin: 4px 0 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 13px; padding: 3px 9px; border-radius: 6px; background: var(--bg-soft); border: 1px solid var(--line); color: var(--muted); }

/* ---------- blog ---------- */
.post { max-width: 720px; padding-top: 44px; padding-bottom: 56px; }
.post-back { margin: 0 0 26px; font-size: 14px; }
.post-back a { text-decoration: none; }
.post-back-end { margin: 44px 0 0; }
.post-head { margin-bottom: 30px; }
.post-head h1 { font-size: clamp(32px, 5.6vw, 44px); line-height: 1.12; letter-spacing: -.02em; margin: 6px 0 14px; text-wrap: balance; }
.post-meta { margin: 0; font-size: 13.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.post-dek { margin: 0; font-size: 18.5px; line-height: 1.55; color: var(--muted); }

.post-body { font-size: 17.5px; line-height: 1.75; }
.post-body > p, .post-body > ul, .post-body > ol { margin: 0 0 20px; }
.post-body h2 { font-size: 25px; margin: 40px 0 12px; }
.post-body ul, .post-body ol { padding-left: 1.3em; }
.post-body li { margin-bottom: 8px; }
.post-body li::marker { color: var(--accent); font-weight: 600; }
.post-body strong { font-weight: 600; }

.post-fig { margin: 30px 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.post-fig svg, .post-fig img { display: block; width: 100%; height: auto; }

.post-fig figcaption { margin-top: 14px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.fig-label text { font: 600 14px var(--sans); fill: var(--text); }
.fig-label .fig-small { font-weight: 500; font-size: 12.5px; fill: var(--faint); }
.fig-axis { stroke: var(--line); stroke-width: 1.5; }
.bar { fill: color-mix(in srgb, var(--muted) 30%, var(--surface)); }
.bar-warn { fill: #c2703d; }
.bar-good { fill: var(--accent); }
.fig-val text { font: 500 13px var(--sans); fill: var(--muted); }
.fig-letter text { font: 700 15px var(--sans); fill: var(--text); }
.fig-note text { font: 500 12px var(--sans); }
.fig-pct text { font: 500 14px var(--sans); fill: var(--muted); font-variant-numeric: tabular-nums; }
.post-fig .strong { font-weight: 700; fill: var(--text); }
.post-fig .warn { fill: #b4602c; }
.post-fig .good { fill: var(--accent); }
:root[data-theme="dark"] .bar-warn { fill: #e0925c; }
:root[data-theme="dark"] .post-fig .warn { fill: #eaa06c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .bar-warn { fill: #e0925c; }
  :root:not([data-theme="light"]) .post-fig .warn { fill: #eaa06c; }
}

@media (max-width: 540px) {
  /* the SVG shrinks to fit, so enlarge its text to stay readable */
  .post-fig { padding: 14px; margin-inline: -6px; }
  .fig-label text { font-size: 17px; }
  .fig-label .fig-small { font-size: 13.5px; }
  .fig-val text { font-size: 16px; }
  .fig-letter text { font-size: 18px; }
  .fig-note text { font-size: 15px; }
  .fig-pct text { font-size: 17px; }
}
.post-cite { margin-top: 40px; padding: 18px 20px; border-left: 3px solid var(--accent); background: var(--bg-soft); border-radius: 0 var(--radius) var(--radius) 0; font-size: 15px; line-height: 1.55; }
.post-cite p { margin: 0; }
.post-cite .title { font-family: var(--serif); font-size: 18px; font-weight: 600; margin: 0 0 4px; }
.post-cite .venue { font-size: 13.5px; color: var(--faint); margin-top: 3px; }
.post-cite .venue b { color: var(--muted); }

.post-list { list-style: none; margin: 0; padding: 0; }
.post-list li { padding: 22px 0; border-top: 1px solid var(--line); }
.post-list h2 { font-size: 23px; margin: 6px 0 6px; line-height: 1.25; }
.post-list h2 a { color: var(--text); text-decoration: none; }
.post-list h2 a:hover { color: var(--accent); }
.post-list li > p:last-child { margin: 0; color: var(--muted); }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--line); padding: 28px 0 44px; color: var(--muted); font-size: 14px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; }
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; }

/* ---------- print ---------- */
@media print {
  .nav, .actions, .filters, .theme-btn, footer, .links { display: none !important; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  section { border-top: 1px solid #ccc; padding: 14px 0; }
  .pub-year[hidden], .pub-year li[hidden] { display: block !important; }
  .pub-year h3 { position: static; }
  .theme, .pub-card { box-shadow: none; break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}
