/* ---------- Tokens ---------- */
:root {
  --bg: #fbfaf7;
  --text: #22252a;
  --muted: #5f636b;
  --faint: #8a8d94;
  --line: #e6e3dc;
  --accent: #3451b2;
  --accent-soft: #eef1fb;
  --surface: #ffffff;

  --serif: "Source Serif 4", "Source Serif Pro", Georgia, "Times New Roman", serif;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181b;
    --text: #e3e3e0;
    --muted: #a3a6ab;
    --faint: #7c7f86;
    --line: #2b2e33;
    --accent: #9fb3f5;
    --accent-soft: #1d2236;
    --surface: #1c1f23;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16181b;
  --text: #e3e3e0;
  --muted: #a3a6ab;
  --faint: #7c7f86;
  --line: #2b2e33;
  --accent: #9fb3f5;
  --accent-soft: #1d2236;
  --surface: #1c1f23;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17.5px/1.7 var(--serif);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 600; }
p { margin: 0 0 1em; }
em { font-style: italic; }

.page { max-width: 820px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 560px) { .page { padding: 0 16px; } body { font-size: 17px; } }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; background: var(--bg); padding: 6px 10px; }

/* ---------- Masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  border-bottom: 1px solid var(--line);
  font: 400 14px var(--sans);
}
.masthead__inner {
  max-width: 820px; margin: 0 auto; padding: 0 24px; height: 56px;
  display: flex; align-items: center; gap: 20px;
}
.brand { font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; color: var(--accent); }
.masthead nav { margin-left: auto; display: flex; gap: 2px; }
.masthead nav a { color: var(--muted); padding: 5px 10px; border-radius: 6px; transition: background .15s, color .15s; }
.masthead nav a:hover { color: var(--text); background: var(--accent-soft); text-decoration: none; }
.theme-toggle {
  width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--muted); cursor: pointer; display: grid; place-items: center;
  transition: color .15s, border-color .15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--faint); }
.theme-toggle svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.theme-toggle .i-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: block; }
}
@media (max-width: 640px) {
  .brand { display: none; }
  .masthead__inner { padding: 0 12px; gap: 8px; }
  .masthead nav { margin-left: 0; }
  .masthead nav a { padding: 5px 7px; font-size: 13.5px; }
  .theme-toggle { margin-left: auto; }
}

/* ---------- Intro ---------- */
.intro {
  display: flex; gap: 28px; align-items: center;
  padding: 72px 0 48px;
}
.portrait {
  width: 128px; height: 128px; flex: none;
  border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--line), 0 12px 28px -12px rgba(0,0,0,.35);
}
.intro h1 { font: 600 2rem/1.15 var(--sans); letter-spacing: -0.025em; margin-bottom: 8px; }
.intro .role { font-size: 1.1rem; margin: 0; }
.intro .meta { color: var(--muted); margin: 0 0 10px; }
.intro .links { font: 500 13px var(--sans); display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 0; }
.intro .links a {
  padding: 4px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
  background: var(--surface); transition: color .15s, border-color .15s;
}
.intro .links a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }
@media (max-width: 560px) {
  .intro { flex-direction: column; align-items: flex-start; gap: 20px; padding-top: 44px; }
  .portrait { width: 104px; height: 104px; }
  .intro h1 { font-size: 1.7rem; }
}

/* ---------- Sections ---------- */
main section:not(.intro) { padding-top: 52px; }
main h2 {
  display: flex; align-items: center; gap: 14px;
  font: 600 1.25rem var(--sans); letter-spacing: -0.015em; color: var(--text); margin-bottom: 22px;
}
main h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.interests { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 1.4em; }
.interests__label { font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin-right: 4px; }
.tag {
  font: 500 13px var(--sans); color: var(--accent); background: var(--accent-soft);
  padding: 4px 11px; border-radius: 999px;
}
.note { color: var(--muted); font-size: .95rem; }

/* Experience / Education entries */
.entries { list-style: none; margin: 0; padding: 0; }
.entries > li { display: grid; grid-template-columns: 150px 1fr; gap: 28px; position: relative; }
.entries > li > div:last-child { position: relative; padding: 0 0 26px 24px; border-left: 1px solid var(--line); }
.entries > li > div:last-child::before {
  content: ""; position: absolute; left: -5px; top: 9px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--faint);
}
.entries > li:first-child > div:last-child::before { border-color: var(--accent); background: var(--accent); }
.entries > li:last-child > div:last-child { padding-bottom: 4px; }
.entries .when { font: 500 13px/2.1 var(--sans); color: var(--faint); text-align: right; font-variant-numeric: tabular-nums; }
.entries h3 { font: 600 1.02rem/1.5 var(--sans); letter-spacing: -0.01em; }
.entries .where { color: var(--muted); font-style: italic; margin: 0 0 4px; }
.entries p:last-child { margin-bottom: 0; }
@media (max-width: 600px) { .entries > li { grid-template-columns: 1fr; gap: 0; } .entries .when { text-align: left; padding-left: 25px; border-left: 1px solid var(--line); } }

/* Publications */
.pub-group {
  font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--faint);
  margin: 30px 0 6px;
}
.pubs { list-style: none; margin: 0; padding: 0; }
.pub { display: grid; grid-template-columns: 48px 1fr; gap: 16px; padding: 12px 14px; margin: 0 -14px; border-radius: 10px; transition: background .15s; }
.pub:hover { background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.pub__year { font: 500 13px/2 var(--sans); color: var(--faint); font-variant-numeric: tabular-nums; }
.pub h3 { font-size: 1rem; font-weight: 400; line-height: 1.55; margin-bottom: 2px; }
.pub__venue { color: var(--muted); font-style: italic; font-size: .95rem; margin: 0; }
.pub__links { margin: 8px 0 0; display: flex; gap: 6px; font: 500 12px var(--sans); }
.pub__links a { padding: 2px 9px; border-radius: 6px; background: var(--accent-soft); }
.pub__links a:hover { text-decoration: none; filter: brightness(0.96); }
@media (max-width: 480px) { .pub { grid-template-columns: 1fr; gap: 0; } }

.plain { margin: 0; padding-left: 1.1em; }
.plain li + li { margin-top: 4px; }

/* Footer */
.footer {
  margin-top: 64px; padding: 20px 0 40px; border-top: 1px solid var(--line);
  font: 400 13px var(--sans); color: var(--faint);
}
.footer p { margin: 0; }

/* ---------- Print ---------- */
@media print {
  :root { --bg: #fff; --text: #000; --muted: #333; --faint: #555; --line: #bbb; --accent: #000; }
  body { font-size: 10.5pt; }
  .masthead, .skip, .portrait, .pub__links { display: none !important; }
  .tag { background: none; padding: 0; color: #000; }
  .pub:hover { background: none; box-shadow: none; }
  .intro { padding: 0 0 10pt; }
  main section:not(.intro) { padding-top: 14pt; }
  .entries > li, .pub { break-inside: avoid; }
}
