/* ==========================================================================
   Base layout + components. All color/type decisions are CSS variables that
   themes.css defines per style, so the three looks share one structure.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { animation: none !important; transition: none !important; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 var(--body-size, 17px)/1.62 var(--font-body);
  text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased;
  transition: background-color .4s, color .4s;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
::selection { background: var(--accent); color: var(--bg); }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--bg); padding: 8px 14px; z-index: 100; }
.skip:focus { left: 12px; top: 12px; }

:root { --gutter: clamp(18px, 4vw, 56px); --max: 1240px; }
main > section, .foot { padding-inline: var(--gutter); }

/* ---------- type primitives ---------- */
h1, h2, h3 { font-family: var(--font-display); font-weight: var(--display-weight, 600); letter-spacing: var(--display-track, -0.01em); line-height: 1.08; margin: 0; }
h2 em, h1 em { font-style: var(--em-style, italic); color: var(--em-color, inherit); }
.eyebrow { font: 500 12px/1.4 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 14px; }
.note { font-family: var(--font-note); color: var(--note-color, var(--accent)); font-size: var(--note-size, 1.15rem); line-height: 1.3; }
.fig-cap { font-size: 13.5px; color: var(--ink-2); margin: 12px 0 0; line-height: 1.5; }
.fig-no { font: 600 11px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin-right: 6px; }
.sub-head { font: 600 12px/1.3 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.link-arrow { color: var(--accent); text-decoration: none; font-weight: 600; border-bottom: 1px solid currentColor; }
.link-arrow::after { content: " →"; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px;
  background: var(--btn-bg, var(--ink)); color: var(--btn-ink, var(--bg));
  border: 1px solid var(--btn-bg, var(--ink)); border-radius: var(--radius-btn, 999px);
  font: 600 14px/1 var(--font-ui, var(--font-body)); letter-spacing: .01em; text-decoration: none;
  transition: transform .2s, background .2s, color .2s, box-shadow .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--btn-shadow, 0 6px 18px rgba(0,0,0,.12)); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong, var(--ink)); }
.btn-small { padding: 9px 16px; font-size: 13px; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 16px; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 24px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) var(--gutter) 14px;
  transition: background .3s, box-shadow .3s, backdrop-filter .3s;
}
.nav.scrolled { background: var(--nav-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 1px 0 var(--line); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--font-display); font-weight: 600; font-size: 18px; }
.mono-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1.5px solid var(--ink); border-radius: var(--mark-radius, 50%); font: 600 12px/1 var(--font-mono); letter-spacing: .04em; }
.nav-links { display: flex; align-items: center; gap: 2px; margin-left: auto; padding: 4px 6px 4px 14px; }
.nav-hint { display: inline-flex; align-items: center; gap: 6px; font: 600 10.5px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-right: 6px; white-space: nowrap; }
.nav-hint::after { content: "↓"; font-size: 13px; letter-spacing: 0; animation: nudge 2.4s ease-in-out infinite; }
@keyframes nudge { 0%, 100% { transform: translateY(-1px); } 50% { transform: translateY(2px); } }
.nav-links a { position: relative; text-decoration: none; font: 500 13.5px/1 var(--font-ui, var(--font-body)); padding: 8px 10px; color: var(--ink-2); transition: color .2s; white-space: nowrap; }
.nav-links a::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 2px; height: 2px; border-radius: 2px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .3s; }
.nav-links a:hover { color: var(--ink); }
.nav-links a:hover::after { transform: scaleX(.35); }
.nav-links a.active::after { transform: scaleX(1); }
.nav-resume span { font-size: 12px; }
main > section[id], #publications, #talks { scroll-margin-top: 64px; }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; }
.progress span { display: block; height: 100%; background: var(--accent); transform-origin: 0 50%; transform: scaleX(0); }


/* ---------- hero ---------- */
.hero {
  max-width: var(--max); margin: 0 auto; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: clamp(24px, 4vw, 64px); align-items: center;
  padding-block: 36px 24px; position: relative;
}
.hero-name { font-size: var(--h1-size, clamp(56px, 9vw, 124px)); line-height: .92; margin: 0 0 26px; letter-spacing: var(--h1-track, -0.03em); }
.hero-name em { display: var(--h1-em-display, inline); }
.hero-roles { font: var(--roles-font, 600 clamp(22px, 2.3vw, 30px)/1.15 var(--font-display)); margin: 0 0 6px; color: var(--ink); letter-spacing: -0.01em; }
.hero-sub { font-size: clamp(15px, 1.25vw, 17px); color: var(--ink-2); margin: 0 0 18px; font-style: italic; }
.hero-lede { font-size: clamp(16.5px, 1.35vw, 18.5px); max-width: 34em; margin: 0 0 18px; color: var(--ink); }
.htag { color: var(--c); cursor: default; transition: opacity .2s; white-space: nowrap; }
.hero-note:hover .htag:not(:hover) { opacity: .45; }
.hsep { color: var(--ink-2); opacity: .6; }
.hl { background: var(--hl-bg, none); padding: 0 .1em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.hero-note { margin: 0 0 28px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.hero-map { margin: 0; position: relative; }
/* Title sits in the map's empty top-left corner. */
.map-head { position: absolute; top: calc(var(--map-pad, 0px) + 2px); left: calc(var(--map-pad, 0px) + 4px); z-index: 1; pointer-events: none; margin: 0; }
.map-frame { container-type: inline-size; }
.map-head { max-width: 38cqw; }
.map-title { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: clamp(14px, 4.4cqw, 26px); line-height: 1.1; color: var(--accent); letter-spacing: -0.01em; }
.map-sub { margin: 3px 0 0; font-size: clamp(10.5px, 2.3cqw, 13.5px); line-height: 1.3; color: var(--ink-2); }
.map-frame { position: relative; background: var(--map-bg, transparent); border: var(--map-border, 0); border-radius: var(--radius); padding: var(--map-pad, 0); }
#map { width: 100%; height: auto; display: block; overflow: visible; }
/* The portrait sits inside the text column, so the tags stay beside the map in every theme. */
.hero-portrait { float: right; width: clamp(118px, 13vw, 190px); aspect-ratio: 4 / 5; object-fit: cover; object-position: 72% 30%; margin: 4px 0 12px 22px; border-radius: var(--radius-img, var(--radius)); box-shadow: var(--portrait-shadow, none); }
.hero-note { clear: both; }
@media (max-width: 900px) { .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; } }

/* map drawing */
#map .edge { fill: none; stroke: var(--c); stroke-width: 1.2; opacity: var(--edge-op, .35); transition: opacity .25s, stroke-width .25s; }
#map .pnode { cursor: pointer; }
#map .pnode .dot { fill: var(--pnode-fill, var(--bg)); stroke: var(--c); stroke-width: 2; transition: r .2s, fill .2s; }
#map .pnode .halo { fill: var(--c); opacity: 0; transition: opacity .2s; }
#map .pnode:hover .dot, #map .pnode.on .dot { fill: var(--c); }
#map .pnode.on .halo { opacity: .18; }
#map .dnode { cursor: pointer; }
#map .dnode .ring { fill: var(--dnode-ring-fill, transparent); stroke: var(--c); stroke-width: 1.5; stroke-dasharray: var(--ring-dash, none); }
#map .dnode .core { fill: var(--c); }
#map .dnode text { font: var(--map-label-font, 600 15px var(--font-display)); fill: var(--ink); paint-order: stroke; stroke: var(--bg); stroke-width: 5px; stroke-linejoin: round; }
#map.focus .edge { opacity: .06; }
#map.focus .pnode:not(.on), #map.focus .dnode:not(.on) { opacity: .28; }
#map.focus .edge.on { opacity: .95; stroke-width: 2.2; }
#map .pnode, #map .dnode { transition: opacity .25s; }
.map-tip {
  position: absolute; transform: translate(-50%, calc(-100% - 12px)); pointer-events: none; z-index: 5;
  background: var(--ink); color: var(--bg); padding: 9px 13px; border-radius: 10px; width: max-content; max-width: 240px;
  font-size: 13px; line-height: 1.35; box-shadow: 0 10px 30px rgba(0,0,0,.2);
}
.map-tip b { display: block; font-weight: 600; }
.map-tip span { opacity: .75; font-size: 12px; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
#map .dnode .core { transform-box: fill-box; transform-origin: center; animation: pulse 3.2s ease-in-out infinite; }

/* ---------- stats ---------- */
.stats { padding-block: 10px 30px; }
.stats-row { max-width: var(--max); margin: 0 auto; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 16px 18px 16px 0; display: flex; flex-direction: column; gap: 6px; }
.stat + .stat { padding-left: 18px; border-left: 1px solid var(--line); }
.stat-big { font: var(--stat-font, 600 28px/1 var(--font-display)); color: var(--stat-color, var(--ink)); letter-spacing: -0.01em; }
.stat-small { font-size: 13px; line-height: 1.4; color: var(--ink-2); }
@media (max-width: 1000px) { .stats-row { grid-template-columns: repeat(3, 1fr); } .stat:nth-child(4) { border-left: 0; padding-left: 0; } .stat:nth-child(n+4) { border-top: 1px solid var(--line); } }
@media (max-width: 560px) { .stats-row { grid-template-columns: repeat(2, 1fr); } .stat:nth-child(odd) { border-left: 0; padding-left: 0; } .stat:nth-child(4) { padding-left: 18px; border-left: 1px solid var(--line); } .stat:nth-child(n+3) { border-top: 1px solid var(--line); } }

/* ---------- sections ---------- */
.section { max-width: var(--max); margin: 0 auto; padding-block: 64px 0; position: relative; }
.sec-head { max-width: 860px; margin-bottom: 26px; position: relative; opacity: 0; transform: translateY(16px); transition: opacity .7s, transform .7s; }
.sec-head.in { opacity: 1; transform: none; }
.sec-head h2 { font-size: var(--h2-size, clamp(34px, 4.6vw, 60px)); }
.sec-no { font: var(--secno-font, 500 12px/1 var(--font-mono)); color: var(--secno-color, var(--accent)); display: var(--secno-display, block); margin-bottom: 14px; }
.sec-lede { font-size: 16.5px; color: var(--ink-2); max-width: 46em; margin: 14px 0 0; }
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s calc(var(--i, 0) * 40ms), transform .6s calc(var(--i, 0) * 40ms); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- pattern ---------- */
.thread-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 26px; }
.thread-tabs button, .chip {
  padding: 9px 16px; border-radius: var(--radius-btn, 999px); border: 1px solid var(--line-strong, var(--line));
  font: 500 14px/1.2 var(--font-ui, var(--font-body)); color: var(--ink-2); background: var(--surface); transition: all .2s;
}
.thread-tabs button:hover, .chip:hover { color: var(--ink); border-color: var(--ink-2); }
.thread-tabs button[aria-selected="true"], .chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--step-gap, 0); counter-reset: s; position: relative; }
.step { position: relative; padding: 20px 20px 22px; background: var(--step-bg, var(--surface)); border: 1px solid var(--line); margin-left: -1px; }
.step:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.step:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.step::after { content: "→"; position: absolute; right: -13px; top: 32px; width: 24px; height: 24px; display: grid; place-items: center; background: var(--bg); color: var(--accent); border-radius: 50%; border: 1px solid var(--line); font-size: 13px; z-index: 2; }
.step:last-child::after { display: none; }
.step-no { font: 500 12px/1 var(--font-mono); color: var(--accent); display: block; margin-bottom: 10px; }
.step-k { font: var(--step-k-font, 600 30px/1 var(--font-display)); display: block; margin-bottom: 6px; }
.step-t { font-size: 13.5px; color: var(--ink-2); display: block; margin-bottom: 12px; }
.step-cell { margin: 0; font-size: 15px; line-height: 1.55; padding-top: 12px; border-top: 1px dashed var(--line-strong, var(--line)); }
.steps.swap .step-cell { animation: cellIn .5s both; animation-delay: calc(var(--i) * 90ms); }
@keyframes cellIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.pattern-foot { margin-top: 22px; }
@media (max-width: 900px) {
  .steps { grid-template-columns: 1fr 1fr; }
  .step, .step:first-child, .step:last-child { border-radius: 0; margin: -1px 0 0 -1px; }
  .step::after { display: none; }
}
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } .step { min-height: 0; } }

/* ---------- work cards ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--card-gap, 24px 16px); }
.card { background: var(--card-bg, var(--surface)); border: var(--card-border, 1px solid var(--line)); border-radius: var(--radius); overflow: hidden; box-shadow: var(--card-shadow, none); transition: transform .25s, box-shadow .25s, border-color .25s; }
.card:hover { transform: translateY(-4px); box-shadow: var(--card-shadow-hover, 0 14px 34px rgba(0,0,0,.1)); border-color: var(--accent); }
.card-btn { display: flex; flex-direction: column; width: 100%; height: 100%; text-align: left; }
.card-img { aspect-ratio: 16 / 10 !important; overflow: hidden; background: var(--img-bg, var(--bg-2)); position: relative; width: 100%; }
.card-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s; filter: var(--img-filter, none); }
.card:hover .card-img img { transform: scale(1.04); }
.card-type { display: flex; flex-direction: column; justify-content: flex-end; padding: 16px; background: var(--type-bg, var(--bg-2)); }
.card-type .type-big { max-width: 100%; white-space: nowrap; overflow: hidden; font: var(--type-big-font, 600 40px/1.05 var(--font-display)); color: var(--type-color, var(--accent)); letter-spacing: -0.01em; }
.card-type .type-small { font-size: 13px; color: var(--ink-2); margin-top: 8px; }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-when { font: 500 11.5px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin: 0; }
.card-title { font-size: 17px; line-height: 1.2; }
.card-line { font-size: 13.5px; color: var(--ink-2); margin: 2px 0 6px; line-height: 1.45; flex: 1; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.tag { font: 500 10px/1 var(--font-mono); letter-spacing: .04em; padding: 4px 7px 4px 16px; border-radius: 999px; position: relative; background: var(--chip-bg); color: var(--ink-2); }
.tag::before { content: ""; position: absolute; left: 6px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--c); }
.tag-vol { padding-left: 7px; background: none; border: 1px dashed var(--d-lead); color: var(--d-lead); }
.tag-vol::before { content: none; }

/* ---------- research ---------- */
.spotlight { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: clamp(28px, 4vw, 60px); align-items: start; }
.paper-kicker { font: 500 12px/1.3 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin: 0 0 12px; }
.paper-title { font-size: clamp(22px, 2.2vw, 28px); line-height: 1.22; margin-bottom: 14px; }
.paper-authors { font-size: 14px; color: var(--ink-2); margin: 0 0 22px; }
.findings { list-style: none; padding: 0; margin: 0 0 26px; display: grid; gap: 12px; }
.findings li { padding-left: 118px; position: relative; font-size: 15.5px; line-height: 1.5; min-height: 26px; }
.findings li span { position: absolute; left: 0; top: 1px; width: 104px; font: 600 11px/1.9 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); border: 1px solid var(--line-strong, var(--line)); border-radius: var(--radius-btn, 999px); text-align: center; }
.spot-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.fig-stage button { display: block; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: zoom-in; aspect-ratio: 2410 / 3000; max-height: 62vh; }
.fig-stage img { width: 100%; height: 100%; object-fit: contain; }
.fig-strip { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; padding-bottom: 4px; }
.fig-strip button { flex: 0 0 auto; width: 62px; height: 62px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; position: relative; background: #fff; opacity: .6; transition: opacity .2s, border-color .2s; }
.fig-strip button[aria-selected="true"] { border-color: var(--accent); opacity: 1; }
.fig-strip button:hover { opacity: 1; }
.fig-strip img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.fig-strip span { position: absolute; right: 3px; bottom: 3px; font: 600 10px/1 var(--font-mono); background: #111; color: #fff; padding: 3px 4px; border-radius: 3px; }
.pubs { display: grid; grid-template-columns: 1.3fr 1fr; gap: clamp(28px, 4vw, 60px); padding-top: 44px; }
.pub-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 22px; }
.pub-list li { display: grid; gap: 4px; }
.pub-tag { font: 600 10.5px/1 var(--font-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.pub-title { font-family: var(--font-display); font-size: 18.5px; line-height: 1.3; text-decoration: none; }
.pub-title:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.pub-auth { font-size: 13.5px; color: var(--ink-2); }
.pub-venue { font-size: 13.5px; }
.pres-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.pres-list li { display: grid; grid-template-columns: 64px 1fr; gap: 12px; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.pres-list b { display: block; color: var(--ink); font-weight: 600; }
.pres-y { font: 500 12px/1.6 var(--font-mono); color: var(--accent); }
@media (max-width: 900px) { .spotlight, .pubs { grid-template-columns: minmax(0, 1fr); } }

/* ---------- timeline ---------- */
.tl-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.tl-scroll { overflow-x: auto; padding-bottom: 12px; scrollbar-width: thin; cursor: grab; user-select: none; -webkit-user-select: none; }
.tl-scroll.dragging, .tl-scroll.dragging .tl-bar { cursor: grabbing; }
.tl-scroll.dragging .tl-bar { pointer-events: none; }
.tl { padding: 16px 20px 10px 8px; position: relative; width: max-content; }
.tl-labels { display: flex; flex-direction: column; padding: 16px 0 10px 18px; border-right: 1px solid var(--line); width: 138px; }
.tl-years-pad { height: 32px; flex: 0 0 auto; }
.tl-label { display: block; flex: 0 0 auto; font: 600 11px/1.25 var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); padding: 18px 10px 0 0; border-bottom: 1px dashed var(--line); }
.tl-years { position: relative; height: 26px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.tl-years span { position: absolute; top: 0; font: 500 11.5px/1 var(--font-mono); color: var(--ink-2); padding-left: 6px; border-left: 1px solid var(--line); height: 100%; }
.tl-lane { position: relative; border-bottom: 1px dashed var(--line); background-image: linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 92px 100%; }
@media (max-width: 600px) { .tl-labels { width: 92px; padding-left: 10px; } .tl-label { font-size: 9.5px; } }
.tl-bar {
  position: absolute; height: 30px; border-radius: var(--radius-btn, 999px); padding: 0 12px; text-align: left;
  background: color-mix(in srgb, var(--c) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
  font: 500 12.5px/28px var(--font-ui, var(--font-body)); color: var(--ink); transition: transform .2s, background .2s;
}
.tl-bar span { display: inline-block; vertical-align: top; position: sticky; left: 8px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-bar:hover { background: var(--c); color: var(--bg); transform: translateY(-2px); z-index: 3; }
/* Short spans: the colored bar covers only the real dates; the label sits beside it. */
.tl-bar.out, .tl-bar.out:hover { background: none !important; border-color: transparent !important; box-shadow: none !important; color: var(--ink) !important; padding: 0; }
.tl-bar.out::before { content: ""; position: absolute; top: 0; bottom: 0; left: var(--bx); width: var(--bw); border-radius: inherit; background: color-mix(in srgb, var(--c) 30%, var(--surface)); border: 1px solid var(--c); transition: background .2s; }
.tl-bar.out:hover::before { background: var(--c); }
.tl-bar.out span { position: static; display: block; max-width: none; overflow: visible; }
.tl-bar.out-right span { padding-left: calc(var(--bx) + var(--bw) + 8px); }
.tl-bar.out-left { text-align: right; }
.tl-bar.out-left span { padding-right: calc(var(--bw) + 8px); }

/* ---------- letter ---------- */
.letter-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: clamp(28px, 5vw, 80px); align-items: start; }
.letter { font-family: var(--font-letter, var(--font-body)); font-size: var(--letter-size, 18.5px); line-height: 1.72; position: relative; background: var(--letter-bg, transparent); padding: var(--letter-pad, 0); border-radius: var(--radius); border: var(--letter-border, 0); box-shadow: var(--letter-shadow, none); }
.letter p { margin: 0 0 1.05em; }
.letter p.first::first-letter { font-family: var(--font-display); float: left; font-size: 4.1em; line-height: .82; padding: .06em .1em 0 0; color: var(--accent); font-weight: 600; }
.letter .sig { font-family: var(--font-note); font-size: 1.8em; color: var(--accent); margin-top: .4em; }
.letter[data-collapsed="true"] p:nth-child(n+4) { display: none; }
.letter[data-collapsed="true"] p:nth-child(3) { -webkit-mask-image: linear-gradient(#000 20%, transparent); mask-image: linear-gradient(#000 20%, transparent); }
.letter-more { margin-top: 6px; }
.letter-side { position: sticky; top: 100px; display: grid; gap: 24px; }
.pull { margin: 0; font-family: var(--font-display); font-size: clamp(22px, 2.2vw, 28px); line-height: 1.3; font-style: var(--pull-style, italic); border-left: 3px solid var(--accent); padding-left: 20px; }
.seek { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.seek li { padding: 8px 14px; border: 1px solid var(--line-strong, var(--line)); border-radius: var(--radius-btn, 999px); font-size: 14px; background: var(--surface); }
.seek .seek-h { flex-basis: 100%; border: 0; background: none; padding: 10px 0 0; font: 500 11.5px/1.4 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.seek .seek-h:first-child { padding-top: 0; }
.seek .seek-open { border-style: dashed; color: var(--accent); font-style: italic; }
@media (max-width: 900px) { .letter-grid { grid-template-columns: minmax(0, 1fr); } .letter-side { position: static; } }

/* ---------- credentials ---------- */
.creds { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 5vw, 80px); }
.edu, .awards { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 18px; }
.edu li { display: grid; gap: 2px; position: relative; padding-left: 20px; border-left: 2px solid var(--line); }
.edu li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent); }
.edu b { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.edu span { font-size: 14.5px; }
.edu em { font-size: 13.5px; color: var(--ink-2); font-style: normal; }
.work-wrap { margin-top: clamp(20px, 3vw, 36px); }
.edu.work { align-items: start; grid-template-columns: 1fr 1fr; column-gap: clamp(28px, 5vw, 80px); }
.work li { align-content: start; }
.work b { font-size: 16px; }
@media (max-width: 760px) { .edu.work { grid-template-columns: 1fr; } }
.edu-y { font: 500 11.5px/1.4 var(--font-mono) !important; color: var(--accent); letter-spacing: .06em; }
.awards { gap: 10px; }
.awards li { font-size: 14.5px; padding-left: 20px; position: relative; line-height: 1.45; }
.awards li::before { content: "✦"; position: absolute; left: 0; color: var(--accent); font-size: 11px; top: 3px; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.tools span { font: 500 12px/1 var(--font-mono); padding: 7px 10px; border-radius: 6px; background: var(--chip-bg); color: var(--ink-2); }
@media (max-width: 900px) { .creds { grid-template-columns: minmax(0, 1fr); } }

/* ---------- archive ---------- */
.masonry { columns: 6 160px; column-gap: 12px; }
.tile { break-inside: avoid; margin: 0 0 12px; position: relative; border-radius: var(--radius-img, var(--radius)); overflow: hidden; background: var(--img-bg, var(--bg-2)); border: var(--tile-border, 0); padding: var(--tile-pad, 0); box-shadow: var(--tile-shadow, none); }
.tile button { display: block; width: 100%; cursor: zoom-in; overflow: hidden; border-radius: calc(var(--radius-img, var(--radius)) - 2px); }
.tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; filter: var(--img-filter, none); }
.tile:hover img { transform: scale(1.03); }
.tile figcaption { font-size: 12.5px; line-height: 1.4; padding: var(--tile-cap-pad, 10px 4px 2px); color: var(--ink-2); font-family: var(--tile-cap-font, var(--font-body)); }

/* ---------- contact + footer ---------- */
.contact { text-align: center; padding-bottom: 60px; }
.contact h2 { font-size: var(--h2-size, clamp(34px, 4.6vw, 60px)); max-width: 18em; margin: 0 auto; }
.contact .sec-lede { margin-inline: auto; }
.contact-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 34px; }
.email-text { font: 500 15px/1 var(--font-mono); color: var(--accent); min-height: 1em; margin-top: 18px; }
.foot { max-width: var(--max); margin: 0 auto; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; border-top: 1px solid var(--line); padding-block: 26px calc(26px + env(safe-area-inset-bottom, 0px)); font-size: 13px; color: var(--ink-2); }
.foot .note { font-size: 1rem; }

/* ---------- theme picker (in the top bar) ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.theme-pick { position: relative; display: flex; align-items: center; gap: 2px; margin-left: auto; padding: 3px; border: 1px solid var(--line-strong, var(--line)); border-radius: var(--radius-btn, 999px); background: var(--surface); }
.theme-label { font: 600 10px/1 var(--font-mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); padding: 0 6px 0 8px; }
.theme-pick button { display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px; border-radius: calc(var(--radius-btn, 999px) - 2px); font: 500 12.5px/1 var(--font-ui, var(--font-body)); color: var(--ink-2); white-space: nowrap; transition: background .2s, color .2s; }
.theme-pick button:hover { color: var(--ink); }
.theme-pick button[aria-checked="true"] { background: var(--ink); color: var(--bg); }
.t-ic { font-size: 12px; line-height: 1; }
.nav-links { margin-left: 8px; }
@media (max-width: 1280px) {
  .nav { flex-wrap: wrap; row-gap: 10px; }
  .nav-resume { margin-left: 0; }
  .nav-links { order: 3; flex: 1 0 100%; margin: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .nav-links::-webkit-scrollbar { display: none; }
}
/* Phones: show only the current theme; it opens a small menu with the other two. */
@media (max-width: 640px) {
  .theme-label { display: none; }
  .brand-name { display: none; }
  .nav { gap: 12px; }
  .theme-pick { padding: 2px; }
  .theme-pick button:not([aria-checked="true"]) { display: none; }
  .theme-pick button[aria-checked="true"]::after { content: "▾"; font-size: 10px; margin-left: 2px; }
  .theme-pick.open button:not([aria-checked="true"]) {
    display: inline-flex; position: absolute; left: -1px; right: -1px; z-index: 50; top: calc(100% + 4px + var(--k, 0) * 33px);
    background: var(--bg); border: 1px solid var(--line-strong, var(--line)); box-shadow: 0 10px 24px rgba(0,0,0,.2);
  }
}

/* ---------- drawer ---------- */
dialog { padding: 0; border: 0; color: var(--ink); }
.drawer { margin: 0 0 0 auto; height: 100dvh; max-height: none; width: min(760px, 100vw); background: var(--bg); box-shadow: -20px 0 60px rgba(0,0,0,.25); }
.drawer[open] { animation: slideIn .38s cubic-bezier(.2,.8,.2,1); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer::backdrop { background: rgba(10, 12, 18, .45); backdrop-filter: blur(3px); }
.drawer-inner { height: 100%; overflow-y: auto; padding: calc(28px + env(safe-area-inset-top, 0px)) clamp(20px, 5vw, 52px) calc(40px + env(safe-area-inset-bottom, 0px)); overscroll-behavior: contain; }
.drawer-close { position: sticky; top: 0; margin-left: auto; z-index: 3; }
.dr-cover { display: block; width: 100%; max-height: 460px; border-radius: var(--radius); overflow: hidden; margin: 12px 0 26px; background: var(--bg-2); cursor: zoom-in; }
.dr-cover img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
/* Posters and figures: always the whole image, letterboxed on white. */
.contain { background: #fff !important; }
.contain img { object-fit: contain !important; object-position: center !important; }
.dr-title { font-size: clamp(30px, 4vw, 44px); margin-bottom: 14px; }
.dr-lede { font-size: 19px; line-height: 1.5; color: var(--ink); font-family: var(--font-display); margin: 18px 0 22px; }
#drawer-body > p:not([class]) { font-size: 16.5px; margin: 0 0 1em; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 26px 0; }
.facts div { background: var(--surface); padding: 16px; }
.facts dt { white-space: nowrap; overflow: hidden; font: var(--stat-font, 600 26px/1 var(--font-display)); color: var(--accent); margin-bottom: 6px; }
.facts dd { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.dr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 26px 0; }
.dr-grid button { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg-2); cursor: zoom-in; }
.dr-grid img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.dr-grid button:hover img { transform: scale(1.06); }
.dr-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0; }
.dr-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.dr-nav button { font-size: 13.5px; color: var(--ink-2); text-align: left; max-width: 48%; }
.dr-nav button:last-child { text-align: right; }
.dr-nav button:hover { color: var(--accent); }
.writing { list-style: none; padding: 0; margin: 22px 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.writing li { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 15.5px; }
.writing a { color: var(--ink); text-decoration-color: var(--accent); font-weight: 500; }
.writing em { font-style: normal; font-size: 13px; color: var(--ink-2); text-align: right; }
.flow-title { margin: 26px 0 -12px; }
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 22px 0 10px; }
.flow-node { flex: 1 1 110px; padding: 12px; border: 1px solid var(--line-strong, var(--line)); border-radius: 10px; background: var(--surface); font-size: 13.5px; line-height: 1.35; }
.flow-node span { display: block; font: 600 10.5px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.flow-node.wip { border-style: dashed; }
.flow-arrow { align-self: center; color: var(--accent); }
.roadmap { list-style: none; margin: 22px 0 10px; padding: 0; position: relative; }
.roadmap::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; border-left: 2px solid var(--line-strong, var(--line)); }
.rm-step { position: relative; padding: 0 0 16px 30px; }
.rm-step::before { content: ""; position: absolute; left: 0; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid var(--accent); }
.rm-step.next::before { background: var(--bg); }
.rm-step.planned::before { background: var(--bg); border-style: dashed; border-color: var(--ink-2); }
.rm-k { display: block; font: 600 10.5px/1.2 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 3px; }
.rm-step.planned .rm-k { color: var(--ink-2); }
.rm-t { font-size: 14.5px; line-height: 1.4; }
.rm-code { margin: 8px 0 0; padding: 10px 12px; font: 12.5px/1.5 var(--font-mono); background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; white-space: pre; color: var(--ink); font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.rm-legend { display: flex; flex-wrap: wrap; gap: 14px; font: 11px/1 var(--font-mono); color: var(--ink-2); margin: 0 0 4px; }
.rm-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--accent); margin-right: 5px; vertical-align: -1px; }
.rm-legend .d i { background: var(--accent); } .rm-legend .p i { border-style: dashed; border-color: var(--ink-2); }
.stack { display: grid; gap: 6px; margin: 22px 0 10px; }
.stack-layer { padding: 12px 16px; border: 1px solid var(--line-strong, var(--line)); border-radius: 10px; background: var(--surface); font-size: 14.5px; display: grid; grid-template-columns: 120px 1fr; align-items: center; }
.stack-layer span { font: 600 11px/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.stack-layer:nth-child(2) { margin-inline: 12px; } .stack-layer:nth-child(3) { margin-inline: 24px; } .stack-layer:nth-child(4) { margin-inline: 36px; }

/* ---------- lightbox ---------- */
.lightbox { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; background: #08090c; color: #eee; display: none; }
.lightbox[open] { display: grid; grid-template-rows: 1fr auto; animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
.lightbox::backdrop { background: transparent; }
.lb-stage { overflow: auto; display: grid; place-items: center; padding: calc(20px + env(safe-area-inset-top, 0px)) 20px 10px; min-height: 0; }
.lb-stage img { max-width: 100%; max-height: calc(100dvh - 120px); object-fit: contain; cursor: zoom-in; border-radius: 4px; }
.lightbox.zoomed .lb-stage { place-items: start center; }
.lightbox.zoomed .lb-stage { display: block; }
.lightbox.zoomed .lb-stage img { max-width: none; max-height: none; height: auto; cursor: zoom-out; margin: 0 auto; }
.lb-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 20px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid rgba(255,255,255,.1); flex-wrap: wrap; }
.lb-cap { margin: 0; font-size: 14px; max-width: 70ch; color: #ddd; font-family: "Inter Tight", system-ui, sans-serif; }
.lb-cap .link-arrow { color: #fff; margin-left: 8px; font-size: 13px; }
.lb-ctrls { display: flex; align-items: center; gap: 8px; font: 500 12px/1 "JetBrains Mono", monospace; color: #999; }
.lightbox .icon-btn { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.15); color: #fff; }
.lightbox .icon-btn[hidden] { display: none; }

/* ---------- folds: long blocks show a slice, then unfold in place ---------- */
.fold { position: relative; overflow: hidden; transition: max-height .6s cubic-bezier(.2,.8,.2,1); }
.fold.folded::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 150px; pointer-events: none; background: linear-gradient(to bottom, transparent, var(--bg) 88%); }
.fold-bar { display: flex; align-items: center; gap: 18px; margin-top: 14px; }
.fold-bar[hidden] { display: none; }
.fold-bar::before, .fold-bar::after { content: ""; flex: 1; height: 1px; background: var(--line-strong, var(--line)); }
.fold-btn { display: inline-flex; align-items: center; gap: 10px; white-space: nowrap; transition: transform .2s, background .2s, box-shadow .2s; }
.fold-icon { width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-3px); transition: transform .3s; }
.fold-bar.is-open .fold-icon { transform: rotate(-135deg) translateY(-2px); }
@media (max-width: 560px) { .fold-bar { gap: 8px; } .fold-btn { white-space: normal; text-align: center; } }

/* ---------- video players (click to load) ---------- */
.videos { margin: 12px 0 24px; }
.videos-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.video { margin: 0; }
.video-btn, .video-frame { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: var(--radius); overflow: hidden; background: #000; position: relative; }
.video-btn img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s, opacity .3s; opacity: .9; }
.video-btn:hover img { transform: scale(1.03); opacity: 1; }
.video-play { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px 0 0 -32px; border-radius: 50%; background: rgba(0,0,0,.62); box-shadow: 0 0 0 2px rgba(255,255,255,.85); transition: transform .2s, background .2s; }
.video-play::after { content: ""; position: absolute; left: 26px; top: 20px; border-left: 18px solid #fff; border-top: 12px solid transparent; border-bottom: 12px solid transparent; }
.video-btn:hover .video-play { transform: scale(1.08); background: var(--accent); }
.videos-grid .video-play { width: 48px; height: 48px; margin: -24px 0 0 -24px; }
.videos-grid .video-play::after { left: 19px; top: 14px; border-left-width: 14px; border-top-width: 10px; border-bottom-width: 10px; }
.video figcaption { font-size: 13px; color: var(--ink-2); margin-top: 8px; line-height: 1.4; }
.video figcaption a { color: var(--accent); white-space: nowrap; margin-left: 4px; }
.dr-grid button.contain { background: #fff; }
.dr-grid button.contain img { object-fit: contain; padding: 4px; }

/* Archive tiles that are video thumbnails get a play badge; the caption links to YouTube. */
.tile .is-video { position: relative; }
.tile .is-video::after { content: "▶"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; padding-left: 3px; font-size: 18px; color: #fff; background: rgba(0, 0, 0, .6); pointer-events: none; }
.yt-link { white-space: nowrap; }
