/* ---------- tokens ---------- */
/* Dark is the base theme. Light applies when the system prefers it and the
   viewer has not picked dark, or when the viewer picks light. */
:root {
  --bg: #04050a;
  --bg-rgb: 4, 5, 10;
  --bg-2: #090b13;
  --fg-rgb: 255, 255, 255;   /* hairlines, washes and glass tints */
  --panel: rgba(12, 14, 24, 0.72);
  --panel-solid: #0b0d16;
  --panel-hover: rgba(16, 19, 31, 0.8);
  --glass: rgba(14, 17, 28, 0.55);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --ink: #eef0f6;
  --ink-2: #a9afc1;
  --ink-3: #6e7589;
  --accent: #ff7a3d;       /* berserker ember */
  --accent-rgb: 255, 122, 61;
  --accent-soft: rgba(255, 122, 61, 0.14);
  --on-accent: #1a0a02;
  --cool: #7cc7ff;
  --spur: #ff3d6e;         /* spurious centroid, reserved */
  --neutral-mark: #4d5466; /* non-highlighted chart marks */
  --ts-mark: #8b93a8;
  --stage-1: #0b0e18;      /* figure and comparison canvases */
  --stage-2: #05060b;
  --code-bg: #070910;
  --tooltip-bg: rgba(10, 12, 20, 0.95);
  --shadow: rgba(0, 0, 0, 0.9);
  --syn-str: #9be29b;
  --syn-fn: #e7c37b;
  --icon-sun: block;
  --icon-moon: none;
  --radius: 16px;
  --radius-sm: 10px;
  --gutter: clamp(16px, 4vw, 48px);
  --maxw: 1180px;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Geist", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --scene-dim: 0;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f5f1;
    --bg-rgb: 246, 245, 241;
    --bg-2: #efeee9;
    --fg-rgb: 15, 17, 26;
    --panel: rgba(255, 255, 255, 0.8);
    --panel-solid: #ffffff;
    --panel-hover: rgba(255, 255, 255, 0.96);
    --glass: rgba(255, 255, 255, 0.62);
    --line: rgba(15, 17, 26, 0.09);
    --line-2: rgba(15, 17, 26, 0.16);
    --ink: #0f1119;
    --ink-2: #4a5062;
    --ink-3: #6a7082;
    --accent: #c2470f;
    --accent-rgb: 194, 71, 15;
    --accent-soft: rgba(194, 71, 15, 0.1);
    --on-accent: #ffffff;
    --cool: #1f6fb2;
    --spur: #d92d3a;
    --neutral-mark: #c3c6cf;
    --ts-mark: #8a90a0;
    --stage-1: #ffffff;
    --stage-2: #f2f1ec;
    --code-bg: #ffffff;
    --tooltip-bg: rgba(255, 255, 255, 0.97);
    --shadow: rgba(20, 22, 30, 0.16);
    --syn-str: #2f7d32;
    --syn-fn: #8a5a00;
    --icon-sun: none;
    --icon-moon: block;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f5f1;
  --bg-rgb: 246, 245, 241;
  --bg-2: #efeee9;
  --fg-rgb: 15, 17, 26;
  --panel: rgba(255, 255, 255, 0.8);
  --panel-solid: #ffffff;
  --panel-hover: rgba(255, 255, 255, 0.96);
  --glass: rgba(255, 255, 255, 0.62);
  --line: rgba(15, 17, 26, 0.09);
  --line-2: rgba(15, 17, 26, 0.16);
  --ink: #0f1119;
  --ink-2: #4a5062;
  --ink-3: #6a7082;
  --accent: #c2470f;
  --accent-rgb: 194, 71, 15;
  --accent-soft: rgba(194, 71, 15, 0.1);
  --on-accent: #ffffff;
  --cool: #1f6fb2;
  --spur: #d92d3a;
  --neutral-mark: #c3c6cf;
  --ts-mark: #8a90a0;
  --stage-1: #ffffff;
  --stage-2: #f2f1ec;
  --code-bg: #ffffff;
  --tooltip-bg: rgba(255, 255, 255, 0.97);
  --shadow: rgba(20, 22, 30, 0.16);
  --syn-str: #2f7d32;
  --syn-fn: #8a5a00;
  --icon-sun: none;
  --icon-moon: block;
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: var(--on-accent); }

a { color: inherit; text-decoration: none; }
em { font-family: var(--serif); font-style: italic; font-weight: 400; }
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.02em; }
p { margin: 0; }
code, pre, kbd { font-family: var(--mono); }

/* ---------- 3D canvas ---------- */
#universe {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
  transition: opacity 0.8s ease, filter 0.8s ease;
  opacity: calc(1 - var(--scene-dim) * 0.62);
  filter: saturate(calc(1 - var(--scene-dim) * 0.35));
}
.vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(var(--bg-rgb), 0.85) 100%),
    linear-gradient(180deg, rgba(var(--bg-rgb), 0.55) 0%, transparent 18%, transparent 80%, rgba(var(--bg-rgb), 0.5) 100%);
}
main, .footer { position: relative; z-index: 2; }

/* ---------- nav ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px var(--gutter);
  background: linear-gradient(180deg, rgba(var(--bg-rgb), 0.8), rgba(var(--bg-rgb), 0));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.nav.scrolled { background: rgba(var(--bg-rgb), 0.85); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  font-family: var(--serif); font-style: italic; font-size: 20px; line-height: 1;
  padding-bottom: 3px;
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.35), inset 0 0 10px rgba(var(--accent-rgb), 0.2);
}
.brand-word { font-weight: 500; letter-spacing: -0.01em; font-size: 17px; }
.nav-links { display: flex; gap: 4px; margin-left: 12px; }
.nav-links a {
  padding: 6px 11px; border-radius: 999px;
  font-size: 14px; color: var(--ink-2);
  transition: color 0.2s, background 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--ink); background: rgba(var(--fg-rgb), 0.06); }
.nav-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.search-pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 8px 0 12px;
  background: rgba(var(--fg-rgb), 0.04);
  border: 1px solid var(--line-2); border-radius: 999px;
  color: var(--ink-3); font: 13px var(--sans); cursor: pointer;
}
.search-pill svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.search-pill kbd {
  font-size: 11px; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--line-2); color: var(--ink-3);
}
.theme-toggle {
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border-radius: 50%; border: 1px solid var(--line-2);
  background: rgba(var(--fg-rgb), 0.04); color: var(--ink-2); cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.theme-toggle:hover { color: var(--ink); background: rgba(var(--fg-rgb), 0.09); }
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.theme-toggle .sun { display: var(--icon-sun); }
.theme-toggle .moon { display: var(--icon-moon); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  border-radius: 999px; border: 1px solid transparent;
  font: 500 14px var(--sans); color: var(--ink);
  cursor: pointer; white-space: nowrap;
  transition: transform 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.4), 0 10px 40px -10px rgba(var(--accent-rgb), 0.8);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 0 0 1px rgba(var(--accent-rgb), 0.6), 0 14px 50px -10px rgba(var(--accent-rgb), 0.95); }
.btn-ghost { background: rgba(var(--fg-rgb), 0.04); border-color: var(--line-2); }
.btn-ghost:hover { background: rgba(var(--fg-rgb), 0.09); border-color: rgba(var(--fg-rgb), 0.25); }
.btn-ghost[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.btn-link { color: var(--ink-2); padding: 0 6px; }
.btn-link:hover { color: var(--ink); }
.nav .btn { height: 34px; padding: 0 14px; font-size: 13px; }

/* ---------- shared type ---------- */
.kicker, .eyebrow, .step-num, .thm-id, .fam-code, .doc-kind, .stat-label, .chart-sub {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.kicker { color: var(--accent); margin-bottom: 18px; }
.muted { color: var(--ink-3); }
.footnote { color: var(--ink-3); font-size: 13px; margin-top: 18px; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }

.section-head { max-width: 760px; margin-bottom: 48px; }
.section-head h2, .play-panel h2, .cite h2 {
  font-size: clamp(34px, 5vw, 60px);
  line-height: 1.02;
  letter-spacing: -0.035em;
}
.section-head h2 em, .play-panel h2 em, .cite h2 em { color: var(--accent); letter-spacing: -0.01em; }
.section-lede { margin-top: 20px; color: var(--ink-2); font-size: 18px; max-width: 640px; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex; align-items: flex-end;
  padding: 120px var(--gutter) 9vh;
}
/* a soft scrim keeps the copy legible where the dust drifts behind it */
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(var(--bg-rgb), 0.72) 0%, rgba(var(--bg-rgb), 0.5) 34%, rgba(var(--bg-rgb), 0) 58%);
}
.hero-copy { position: relative; max-width: 640px; }
.eyebrow { display: inline-flex; align-items: center; gap: 10px; color: var(--ink-2); margin-bottom: 26px; }
.eyebrow .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.display {
  font-size: clamp(44px, 7.4vw, 100px);
  line-height: 0.96;
  letter-spacing: -0.045em;
  font-weight: 500;
}
.display em { color: var(--accent); letter-spacing: -0.02em; padding-right: 0.04em; }
.lede { margin-top: 28px; font-size: clamp(17px, 1.5vw, 20px); color: var(--ink-2); max-width: 540px; line-height: 1.55; }
.theta { font-family: var(--serif); font-style: italic; font-size: 1.2em; color: var(--ink); }
.k { font-family: var(--serif); font-style: italic; font-size: 1.15em; color: var(--ink); }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
.hero-facts { display: flex; gap: 36px; margin: 46px 0 0; padding-top: 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.hero-facts div { display: flex; flex-direction: column-reverse; gap: 4px; }
.hero-facts dt { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.hero-facts dd { margin: 0; font-size: 22px; font-weight: 500; letter-spacing: -0.02em; }
.hero-facts .unit { font-family: var(--serif); font-style: italic; color: var(--accent); }
.stream-tag {
  position: absolute; right: var(--gutter); bottom: 9vh;
  display: flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3);
}
.stream-tag b { color: var(--accent); font-weight: 500; font-variant-numeric: tabular-nums; }
.live { width: 7px; height: 7px; border-radius: 50%; background: #48e08b; box-shadow: 0 0 10px #48e08b; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------- how (scrollytelling) ---------- */
.how { position: relative; padding: 18vh var(--gutter) 10vh; }
.how > .section-head { max-width: var(--maxw); margin: 0 auto 10vh; }
.how > .section-head h2, .how > .section-head .section-lede { max-width: 640px; }
.how-grid {
  max-width: var(--maxw); margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: clamp(28px, 4vw, 64px);
}
.steps { grid-column: 1; }
.step {
  min-height: 86vh;
  display: flex; flex-direction: column; justify-content: center;
  gap: 16px;
  opacity: 0.28;
  transition: opacity 0.6s ease;
}
.step.active { opacity: 1; }
.step > * { max-width: 400px; }
.step h3 { font-size: 30px; line-height: 1.1; letter-spacing: -0.03em; }
.step p { color: var(--ink-2); }
.step .muted { color: var(--ink-3); font-size: 15px; }
.step-num { display: flex; gap: 12px; align-items: baseline; color: var(--accent); }
.step-num span { color: var(--ink-3); }
.spur { color: var(--spur); font-weight: 500; }
.rule {
  margin: 4px 0;
  padding: 16px 18px;
  font-size: 12.5px; line-height: 1.7;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--ink-2);
  overflow-x: auto;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.kw { color: var(--accent); }
.c { color: var(--ink-3); }
.s { color: var(--syn-str); }
.n { color: var(--cool); }
.fn { color: var(--syn-fn); }

/* the figure: one real run, a short loop per step */
.fig { grid-column: 2; position: relative; }
.fig-card {
  position: sticky; top: max(76px, calc(50vh - 350px));
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 40px 120px -40px var(--shadow), 0 0 0 1px rgba(var(--accent-rgb), 0.04);
}
.fig-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.fig-steps button {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 11px 0 5px;
  border: 1px solid transparent; border-radius: 999px; background: none;
  font: 500 12.5px var(--sans); color: var(--ink-3); cursor: pointer;
  transition: color 0.25s, background 0.25s, border-color 0.25s;
}
.fig-steps button span {
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  font: 500 11px var(--mono); border: 1px solid var(--line-2);
}
.fig-steps button:hover { color: var(--ink-2); }
.fig-steps button[aria-current="step"] { color: var(--ink); background: var(--accent-soft); border-color: rgba(var(--accent-rgb), 0.3); }
.fig-steps button[aria-current="step"] span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.fig-stage {
  position: relative;
  height: min(44vh, 420px); min-height: 220px;
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line);
  background: radial-gradient(120% 100% at 50% 40%, var(--stage-1) 0%, var(--stage-2) 100%);
}
.fig-stage canvas { display: block; width: 100%; height: 100%; }
.fig-caption { font-size: 16.5px; line-height: 1.45; color: var(--ink); min-height: 2.9em; }
.fig-stats { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.04em; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.fig-algo { padding-top: 12px; border-top: 1px solid var(--line); }
.fig-algo .algo-lines li:not(.on) { display: none; }
.fig-algo.full .algo-lines { max-height: 26vh; overflow-y: auto; }
.fig-algo.full .algo-lines li { display: flex; }
.fig-more {
  margin-top: 8px; padding: 0; border: 0; background: none; cursor: pointer;
  font: 12px var(--mono); color: var(--ink-3);
}
.fig-more:hover { color: var(--ink); }
.algo-title { font-size: 13px; color: var(--ink-2); margin-bottom: 8px; display: flex; gap: 10px; align-items: baseline; }
.algo-title span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.algo-lines { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 12.5px; }
.algo-lines li {
  position: relative;
  display: flex; gap: 8px; align-items: baseline;
  padding: 2.5px 8px 2.5px 30px;
  border-radius: 6px;
  color: var(--ink-3);
  transition: color 0.35s, background 0.35s;
}
.algo-lines li::before {
  content: attr(data-l);
  position: absolute; left: 6px;
  width: 18px; text-align: right;
  font-size: 10.5px; color: rgba(var(--fg-rgb), 0.22);
}
.algo-lines li i { margin-left: auto; padding-left: 10px; font-style: normal; font-size: 10.5px; color: rgba(var(--fg-rgb), 0.22); white-space: nowrap; }
.algo-lines li b { font-weight: 500; }
.algo-lines li.on { color: var(--ink); background: var(--accent-soft); }
.algo-lines li.on::before { color: var(--accent); }
.algo-lines li.on i { color: var(--accent); }

/* ---------- generic panel sections ---------- */
.panel-section { padding: 16vh 0; position: relative; }
.panel-section::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(var(--bg-rgb), 0) 0%, rgba(var(--bg-rgb), 0.62) 12%, rgba(var(--bg-rgb), 0.62) 88%, rgba(var(--bg-rgb), 0) 100%);
  pointer-events: none;
  z-index: -1;
}

/* ---------- ordering duel ---------- */
.duel { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; perspective: 1400px; }
.duel-panel {
  margin: 0;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transform: rotateY(6deg) rotateX(4deg);
  transform-style: preserve-3d;
  transition: transform 0.7s cubic-bezier(.2, .7, .2, 1), border-color 0.4s;
}
.duel-panel.is-tb { transform: rotateY(-6deg) rotateX(4deg); border-color: rgba(var(--accent-rgb), 0.35); box-shadow: 0 30px 80px -40px rgba(var(--accent-rgb), 0.45); }
.duel:hover .duel-panel { transform: none; }
.duel-panel figcaption { display: flex; align-items: center; gap: 10px; font-size: 15px; margin-bottom: 14px; }
.duel-panel .sub { margin-left: auto; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.tag {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  padding: 3px 8px; border-radius: 6px;
  background: rgba(var(--fg-rgb), 0.08); color: var(--ink-2);
}
.is-tb .tag { background: var(--accent); color: var(--on-accent); }
.duel-canvas { aspect-ratio: 1 / 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--stage-2); border: 1px solid var(--line); }
.duel-canvas canvas { width: 100%; height: 100%; display: block; }
.duel-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 0; }
.duel-stats div { display: flex; flex-direction: column-reverse; gap: 2px; }
.duel-stats dt { font-size: 12px; color: var(--ink-3); line-height: 1.3; }
.duel-stats dd { margin: 0; font-size: 22px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.duel-stats dd span { color: var(--ink-3); font-size: 14px; font-weight: 400; }
.duel-bar { display: flex; align-items: center; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.duel-legend { color: var(--ink-3); font-size: 13px; margin-left: 8px; }
.duel-legend b { color: var(--ink-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 6px 0 0; vertical-align: -1px; }
.lg-off { border: 2px solid var(--spur); }

/* ---------- playground ---------- */
.playground {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr minmax(320px, 440px);
  gap: 24px;
  padding: 14vh var(--gutter);
}
.play-map {
  align-self: center;
  margin: 0; padding: 14px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 40px 120px -40px var(--shadow);
}
.play-map-canvas {
  aspect-ratio: 8 / 5; max-height: 72vh; /* the map's own shape, so nothing is letterboxed */
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line);
  background: radial-gradient(120% 100% at 50% 40%, var(--stage-1) 0%, var(--stage-2) 100%);
}
.play-map canvas { display: block; width: 100%; height: 100%; }
.play-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 12.5px; color: var(--ink-3); }
.play-legend span { display: inline-flex; align-items: center; gap: 7px; }
.play-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.lg-dot { background: var(--ink-2); }
.lg-ring { border: 1px dashed var(--ink-2); width: 14px !important; height: 14px !important; }
.lg-hollow { border: 1.5px solid var(--ink-3); }
.play-note { margin-top: 8px; min-height: 1.4em; font-size: 13px; color: var(--ink-3); }
.play-panel {
  align-self: center;
  padding: 30px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.play-panel > p:not(.kicker):not(.footnote) { color: var(--ink-2); margin-top: 16px; font-size: 15px; }
.play-panel h2 em { font-size: 1.1em; }
.control { margin-top: 26px; }
.control label { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--serif); font-style: italic; font-size: 24px; }
.control output { font-family: var(--mono); font-style: normal; font-size: 20px; color: var(--accent); font-variant-numeric: tabular-nums; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 28px; margin: 6px 0 0;
  background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 30%), rgba(var(--fg-rgb), 0.12) var(--fill, 30%));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(var(--fg-rgb), 0.12); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px; margin-top: -8px; border-radius: 50%;
  background: var(--ink); border: 4px solid var(--accent);
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.7);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--ink); border: 4px solid var(--accent);
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; margin-top: 18px; padding: 4px; border-radius: 12px; background: rgba(var(--fg-rgb), 0.04); border: 1px solid var(--line); }
.seg button {
  height: 34px; border: 0; border-radius: 9px;
  background: transparent; color: var(--ink-3);
  font: 500 13px var(--sans); cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.seg button[aria-checked="true"] { background: rgba(var(--fg-rgb), 0.1); color: var(--ink); }
.seg button[data-method="tb"][aria-checked="true"] { background: var(--accent); color: var(--on-accent); }

.readout { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 20px 0 0; }
.readout div { padding: 10px 10px 8px; border-radius: 10px; background: rgba(var(--fg-rgb), 0.03); border: 1px solid var(--line); display: flex; flex-direction: column-reverse; gap: 2px; }
.readout dt { font-size: 11px; color: var(--ink-3); line-height: 1.25; }
.readout dd { margin: 0; font-size: 20px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.readout dd b { font-weight: 500; color: var(--accent); }

.sweep { margin-top: 20px; }
.sweep-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--ink-2); gap: 10px; flex-wrap: wrap; }
.sweep-legend { color: var(--ink-3); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 2px; border-radius: 2px; margin-left: 6px; }
.sw-tb { background: var(--accent); }
.sw-ts { background: var(--ts-mark); }
.sw-true { background: repeating-linear-gradient(90deg, var(--ink-2) 0 3px, transparent 3px 6px); }
.sweep-chart { position: relative; height: 150px; margin-top: 8px; }
.sweep-wait { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-3); font-size: 13px; font-family: var(--mono); }
.play-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* ---------- theorems ---------- */
.theorems { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.thm {
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color 0.3s, transform 0.3s;
}
.thm:hover { border-color: rgba(var(--accent-rgb), 0.35); transform: translateY(-2px); }
.thm-id { color: var(--accent); }
.thm h3 { font-size: 21px; letter-spacing: -0.02em; }
.thm p:not(.thm-id):not(.math) { color: var(--ink-2); font-size: 15px; }
.math {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px dashed var(--line-2);
  font-family: var(--serif); font-size: 20px; color: var(--ink);
}
.thm-wide { grid-column: span 2; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.thm-wide > div:first-child { display: flex; flex-direction: column; gap: 10px; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--mono); font-size: 11px; fill: var(--ink-3); }
.chart .val { fill: var(--ink-2); font-size: 12px; }
.chart .lbl { fill: var(--ink-2); font-family: var(--sans); font-size: 13px; }
.chart .lbl.hi, .chart .val.hi { fill: var(--ink); font-weight: 500; }
.chart .grid { stroke: rgba(var(--fg-rgb), 0.06); stroke-width: 1; }
.chart .axis { stroke: rgba(var(--fg-rgb), 0.16); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: default; }
.chart .bar { transition: opacity 0.2s; }
.chart:hover .bar { opacity: 0.55; }
.chart .bar.hover { opacity: 1; }
.perf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chart-card {
  margin: 0; padding: 22px 24px 18px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.chart-card figcaption { margin-bottom: 14px; }
.chart-title { font-size: 16px; font-weight: 500; }
.chart-sub { margin-top: 4px; font-size: 11px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 16px; }
.stat { padding: 22px 22px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.stat-value { margin-top: 12px; font-size: 30px; letter-spacing: -0.03em; font-weight: 400; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.stat-value b { color: var(--ink); font-weight: 500; }
.stat-value .arrow { color: var(--accent); font-size: 22px; }
.stat-value .vs { font-size: 16px; color: var(--ink-3); }
.stat-note { margin-top: 8px; color: var(--ink-3); font-size: 13px; line-height: 1.45; }

.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  padding: 8px 10px; border-radius: 8px;
  background: var(--tooltip-bg); border: 1px solid var(--line-2);
  font-size: 12px; color: var(--ink-2); line-height: 1.45;
  opacity: 0; transform: translateY(4px);
  transition: opacity 0.12s, transform 0.12s;
  white-space: nowrap;
}
.tooltip.show { opacity: 1; transform: none; }
.tooltip b { color: var(--ink); font-weight: 500; }

/* ---------- family ---------- */
.family { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.fam {
  padding: 22px 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 10px;
}
.fam h3 { font-size: 18px; }
.fam p:last-child { color: var(--ink-2); font-size: 14px; }
.fam-code { font-size: 13px; color: var(--ink-2); }
.fam-main { border-color: rgba(var(--accent-rgb), 0.5); background: linear-gradient(180deg, rgba(var(--accent-rgb), 0.12), var(--panel)); box-shadow: 0 30px 70px -40px rgba(var(--accent-rgb), 0.6); }
.fam-main .fam-code { color: var(--accent); }

/* ---------- code ---------- */
.quick { display: grid; grid-template-columns: 1fr 1.1fr; gap: 40px; align-items: center; }
.quick .section-head { margin-bottom: 0; }
.code-card { background: var(--code-bg); border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; box-shadow: 0 40px 100px -50px var(--shadow); }
.tabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.tabs button[role="tab"], .tab-static {
  background: none; border: 0; padding: 8px 12px 10px;
  font: 500 13px var(--sans); color: var(--ink-3); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"], .tab-static { color: var(--ink); border-bottom-color: var(--accent); }
.copy {
  margin-left: auto; margin-bottom: 6px;
  background: rgba(var(--fg-rgb), 0.05); border: 1px solid var(--line-2); color: var(--ink-2);
  font: 12px var(--mono); padding: 4px 10px; border-radius: 7px; cursor: pointer;
}
.copy:hover { color: var(--ink); }
.code-card pre { margin: 0; padding: 22px 24px 24px; font-size: 13.5px; line-height: 1.75; overflow-x: auto; color: var(--ink); }

/* ---------- docs ---------- */
.docs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.doc {
  position: relative;
  padding: 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color 0.3s, transform 0.3s, background 0.3s;
}
.doc:hover { border-color: rgba(var(--fg-rgb), 0.22); transform: translateY(-3px); background: var(--panel-hover); }
.doc h3 { font-size: 20px; }
.doc p { color: var(--ink-2); font-size: 14.5px; }
.doc-kind { color: var(--accent); }
.soon {
  position: absolute; top: 22px; right: 22px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ink-3);
}

/* ---------- cite / footer ---------- */
.cite { display: grid; grid-template-columns: 1fr 1.2fr; gap: 40px; align-items: center; }
.authors { margin-top: 20px; font-size: 17px; }
.cite .muted { margin-top: 6px; font-size: 14px; }
.footer { border-top: 1px solid var(--line); background: rgba(var(--bg-rgb), 0.92); padding: 36px 0; }
.footer-inner { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.footer-inner p { color: var(--ink-3); font-size: 14px; }
.footer-inner nav { margin-left: auto; display: flex; gap: 18px; font-size: 14px; color: var(--ink-2); }
.footer-inner nav a:hover { color: var(--ink); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 70;
  transform: translate(-50%, 20px);
  padding: 10px 16px; border-radius: 999px;
  background: var(--tooltip-bg); border: 1px solid var(--line-2);
  font-size: 14px; color: var(--ink-2);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.9s cubic-bezier(.2, .7, .2, 1), transform 0.9s cubic-bezier(.2, .7, .2, 1); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .family { grid-template-columns: repeat(3, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .nav-links { display: none; }
}
@media (max-width: 900px) {
  .theorems { grid-template-columns: 1fr 1fr; }
  .thm-wide { grid-column: span 2; }
  .perf-grid, .quick, .cite { grid-template-columns: 1fr; }
  .playground { grid-template-columns: 1fr; }
  .docs { grid-template-columns: 1fr 1fr; }
  .search-pill span, .search-pill kbd { display: none; }
  /* the figure pins to the top and the steps scroll up beneath it */
  .how-grid { display: flex; flex-direction: column; gap: 0; }
  .fig { order: -1; position: sticky; top: 58px; z-index: 4; margin: 0 calc(-1 * var(--gutter)); padding: 8px var(--gutter) 0; background: var(--bg); }
  .fig-card { position: static; padding: 10px; gap: 8px; }
  .fig-stage { height: 30vh; min-height: 190px; }
  .fig-caption { font-size: 14.5px; min-height: 4.4em; }
  .fig-algo, .fig-stats { display: none; }
  .fig-steps button { padding: 0 8px 0 4px; font-size: 0; gap: 0; }
  .fig-steps button span { font-size: 11px; }
  .fig-steps button[aria-current="step"] { font-size: 12px; gap: 6px; }
  .step { min-height: 0; padding: 22px; margin: 40vh 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
  .step > * { max-width: none; }
}
@media (max-width: 680px) {
  .duel { grid-template-columns: 1fr; }
  .duel-panel, .duel-panel.is-tb { transform: none; }
  .theorems, .docs, .family, .stats { grid-template-columns: 1fr; }
  .thm-wide { grid-column: auto; grid-template-columns: 1fr; }
  .readout { grid-template-columns: repeat(2, 1fr); }
  .hero { padding-top: 46vh; padding-bottom: 150px; }
  .hero::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(0deg, rgba(var(--bg-rgb), 0.92) 0%, rgba(var(--bg-rgb), 0.82) 52%, rgba(var(--bg-rgb), 0) 78%);
  }
  .hero-copy { position: relative; }
  .hero-facts { gap: 22px; }
  .stream-tag { display: none; }
  .nav .btn-ghost { display: none; }
  .duel-bar { gap: 8px; }
  .duel-legend { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .duel-panel, .duel-panel.is-tb { transform: none; }
  .live { animation: none; }
}
