/* Palette shared with the paper figures and the promo video:
   target blue, confusable red, accept green, amber only for the eyebrow and expand/cutoff. */
:root {
  --bg: #0A0C11;
  --panel: #141821;
  --panel-hi: #1B2130;
  --line: #2A3142;
  --text: #F3F5F9;
  --dim: #A0A9BB;
  --target: #4C8DFF;
  --conf: #FF5A5F;
  --ok: #2FD08A;
  --warn: #F5B942;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --max: 1080px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--target); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
b { font-weight: 600; }
:where(a, button, select):focus-visible { outline: 2px solid var(--text); outline-offset: 4px; }

/* ---------------------------------------------------------------- hero */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  text-align: center;
}
.hero-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(0.72) brightness(0.9);
}
.hero-shade {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 65% 65% at 50% 46%, rgba(10, 12, 17, 0.86) 0%, rgba(10, 12, 17, 0.68) 52%, rgba(10, 12, 17, 0.26) 100%),
    linear-gradient(to bottom, rgba(10, 12, 17, 0.18), transparent 25%, rgba(10, 12, 17, 0.2) 65%, var(--bg) 100%);
}
.hero-content { position: relative; z-index: 1; width: 100%; max-width: 1040px; padding: 88px 24px 108px; }
.eyebrow {
  font: 600 12px/1.6 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--warn);
  margin: 0 0 22px;
}
.hero h1 {
  font-size: clamp(52px, 10vw, 132px);
  font-weight: 700;
  letter-spacing: -0.055em;
  line-height: 1;
  margin: 0;
  text-shadow: 0 4px 32px rgba(0, 0, 0, 0.35);
}
.hero h1 sup { position: relative; top: -1.15em; vertical-align: baseline; font-size: 0.42em; margin-left: 0.025em; }
.subtitle {
  font-size: clamp(20px, 2.3vw, 28px);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: -0.02em;
  margin: 22px 0 32px;
  color: #DCE1EA;
  text-wrap: balance;
}
.tagline { max-width: 880px; margin: -14px auto 30px; font-size: 17px; line-height: 1.6; color: #C5CBD6; text-wrap: balance; }
.nowrap { white-space: nowrap; }
.authors { max-width: 850px; margin: 0 auto; font-size: 16px; line-height: 1.8; color: #C5CBD6; text-wrap: balance; }
.author { display: inline-block; }
.authors a { color: var(--text); border-bottom: 1px solid rgba(243, 245, 249, 0.35); }
.authors a:hover { text-decoration: none; border-color: var(--text); }
.affils { color: var(--dim); font-size: 14px; line-height: 1.8; margin: 10px 0 28px; }
.affils .author { margin: 0 6px; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 22px;
  border-radius: 10px;
  background: rgba(20, 24, 33, 0.8);
  border: 1px solid rgba(243, 245, 249, 0.2);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  backdrop-filter: blur(12px);
}
.btn:hover { background: rgba(27, 33, 48, 0.95); border-color: rgba(243, 245, 249, 0.5); text-decoration: none; }
.btn-primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-primary:hover { background: #fff; border-color: #fff; }
.btn.disabled { color: #929AAA; background: rgba(20, 24, 33, 0.55); border-color: rgba(243, 245, 249, 0.1); cursor: default; }
.scroll-cue {
  position: absolute;
  z-index: 2;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--dim);
  font: 500 11px/1.4 var(--sans);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.scroll-cue span:last-child { font-size: 20px; }
.scroll-cue:hover { color: var(--text); text-decoration: none; }

/* ---------------------------------------------------------------- nav */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: rgba(10, 12, 17, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav a { color: var(--dim); font-size: 14px; font-weight: 500; padding: 4px 10px; border-radius: 6px; }
.nav a:hover, .nav a.on { color: var(--text); background: var(--panel); text-decoration: none; }

/* ---------------------------------------------------------------- layout */
main { max-width: var(--max); margin: 0 auto; padding: 0 20px 80px; }
main > section { padding: 80px 0 32px; }
main > section + section { border-top: 1px solid rgba(160, 169, 187, 0.12); }
h2 {
  font-size: clamp(30px, 3.4vw, 42px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.035em;
  margin: 0 0 24px;
  text-wrap: balance;
}
/* Signature: a target/confusable frame pair marks every chapter. */
main > section > h2::before {
  content: "";
  display: block;
  width: 24px;
  height: 15px;
  margin-bottom: 20px;
  border: 1px solid var(--target);
  box-shadow: 7px 5px 0 -1px var(--bg), 7px 5px 0 0 var(--conf);
}
h3 { font-size: 20px; font-weight: 600; line-height: 1.35; letter-spacing: -0.015em; margin: 6px 0 8px; }
p { color: #D5DAE3; }
main > section > p { max-width: 78ch; line-height: 1.7; }
.lead { max-width: 72ch; font-size: 20px; line-height: 1.65; }
.note { font-size: 14px; color: var(--dim); }
main > section > p.note { max-width: none; }

figure { margin: 32px 0; padding: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
figure img { width: 100%; border-radius: 6px; background: #fff; }
figure a { display: block; }
figure.narrow { max-width: 680px; margin-inline: auto; }
figcaption { margin: 12px 0 2px; padding-inline: 4px; color: var(--dim); font-size: 13px; line-height: 1.6; text-align: left; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid2 figure, .grid4 figure { margin: 8px 0; }
.grid4 figcaption { text-align: center; }
#diagnosis .grid2 figure img { height: 360px; object-fit: contain; }

.video-frame { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
.video-frame video { width: 100%; display: block; background: #000; }

.cards { display: grid; gap: 16px; margin: 28px 0; }
.cards.three { grid-template-columns: repeat(3, 1fr); }
.cards.two { grid-template-columns: repeat(2, 1fr); }
.card { background: var(--panel); border: 1px solid rgba(160, 169, 187, 0.16); border-radius: 12px; padding: 24px; }
.card p { margin: 0; font-size: 15px; line-height: 1.65; color: #C3C9D4; }
.tag { font: 600 12px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.big-number b { display: block; font-size: 34px; font-weight: 700; color: var(--text); margin-bottom: 8px; letter-spacing: -0.02em; }
.steps .step {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--panel-hi);
  border: 1px solid var(--line);
  font: 600 14px var(--mono);
  color: var(--dim);
}

.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; padding: 20px 0; margin: 28px 0; border-block: 1px solid var(--line); }
.stats div { padding: 8px 12px; text-align: center; }
.stats div + div { border-left: 1px solid var(--line); }
.stats b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stats span { font-size: 13px; color: var(--dim); }
table, .stats b, .big-number b { font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; margin: 24px 0 12px; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 13px 14px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--dim); font-weight: 600; font-size: 12px; line-height: 1.4; background: var(--panel); }
td:first-child, th:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(243, 245, 249, 0.045); }
tr.ours td { background: rgba(243, 245, 249, 0.035); }
tr.ours td:first-child { box-shadow: inset 3px 0 #9DA7B8; }
td.yes { color: var(--ok); }
td.no { color: #8D97AA; }

pre {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  overflow-x: auto;
  font: 14px/1.6 var(--mono);
  color: #DCE1EA;
}
.viewer { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 18px; }
.viewer iframe { display: block; width: 100%; height: 560px; border: 0; background: #fff; }
.bib { position: relative; }
.bib button {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--panel-hi);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  font: 600 13px var(--sans);
  cursor: pointer;
}

/* ---------------------------------------------------------------- trace explorer */
.ex-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin: 20px 0 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  background: var(--panel);
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font: 500 14px var(--sans);
  cursor: pointer;
}
.chips button.on { color: var(--text); border-color: #697387; background: #252D3B; }
.ex-legend { margin: 0 0 16px; }
.select { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 14px; }
.select select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font: 14px var(--sans);
  max-width: 70vw;
}
.ex { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; }
.ex-loading { color: var(--dim); }
.ex-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 20px; }
.ex-head h3 { margin: 0; font-size: 24px; line-height: 1.3; letter-spacing: -0.025em; }
.ex-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.badge {
  display: inline-flex;
  align-items: center;
  font: 600 11px/1.25 var(--mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 8px;
  border-radius: 5px;
  border: 1px solid;
}
.badge.accept, .badge.gold { color: var(--ok); border-color: rgba(47, 208, 138, 0.5); background: rgba(47, 208, 138, 0.08); }
.badge.expand, .badge.expanded { color: var(--warn); border-color: rgba(245, 185, 66, 0.5); background: rgba(245, 185, 66, 0.08); }
.badge.reject, .badge.miss { color: var(--conf); border-color: rgba(255, 90, 95, 0.5); background: rgba(255, 90, 95, 0.08); }
.badge.select, .badge.neutral { color: var(--dim); border-color: var(--line); background: transparent; }
.meta { color: var(--dim); font-size: 14px; }

.queries { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.q {
  text-align: left;
  cursor: pointer;
  background: var(--panel-hi);
  color: var(--text);
  border: 1px solid var(--line);
  border-left: 4px solid;
  border-radius: 10px;
  padding: 12px 14px;
  font: 15px/1.5 var(--sans);
}
.q.target { --query-accent: var(--target); border-left-color: var(--target); }
.q.confusable { --query-accent: var(--conf); border-left-color: var(--conf); }
.q.on { outline: 2px solid var(--query-accent); outline-offset: 2px; }
.q .role { display: block; font: 600 11px/1.5 var(--mono); letter-spacing: 0.055em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.q.on .role { color: var(--query-accent); }
.q .outcome-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.q .gtthumbs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.q .gtthumbs img { width: 100%; aspect-ratio: 2.39 / 1; object-fit: cover; border-radius: 6px; background: #000; }

.evidence-enter { animation: evidence-in 140ms ease-out; }
@keyframes evidence-in { from { opacity: 0.35; } to { opacity: 1; } }

.timeline { position: relative; height: 82px; margin: 18px 0 8px; }
.timeline .track { position: absolute; left: 0; right: 0; top: 28px; height: 6px; border-radius: 3px; background: #222939; }
.timeline .seg { position: absolute; top: 22px; height: 18px; border-radius: 4px; }
.timeline .seg.gt-t { background: var(--target); }
.timeline .seg.gt-c { background: var(--conf); }
.timeline .seg.cand { top: 48px; height: 10px; border: 1px dashed #6B7488; background: rgba(160, 169, 187, 0.08); }
.timeline .seg.final { top: 18px; height: 26px; border: 2px solid var(--ok); background: transparent; }
.timeline .seg.final.miss { border-color: var(--warn); }
.timeline .lbl { position: absolute; top: 0; font: 12px var(--mono); color: var(--dim); transform: translateX(-50%); white-space: nowrap; }
.timeline .ends { position: absolute; top: 64px; font: 12px var(--mono); color: var(--dim); }
.tl-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 12px; color: var(--dim); margin-bottom: 18px; }
.tl-legend i { display: inline-block; width: 14px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }

.subq { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 20px; padding: 0; list-style: none; }
.subq li { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; font-size: 14px; }
.subq li b { font-family: var(--mono); color: var(--dim); margin-right: 6px; }

.step-card { border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 18px; background: var(--bg); }
.step-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.step-top .meta b { color: var(--text); font-family: var(--mono); }
.look { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 16px; }
.look-top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.thumbs-cap { font: 11px var(--mono); color: var(--dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 720px; margin-bottom: 18px; }
.thumbs figure { margin: 0; padding: 0; background: none; border: 0; border-radius: 0; }
.thumbs img { aspect-ratio: 2.39 / 1; object-fit: cover; width: 100%; border-radius: 6px; background: #000; }
.thumbs figcaption { margin: 4px 0 0; padding: 0; font: 11px var(--mono); text-align: left; }
.verdicts { list-style: none; padding: 0; margin: 0; }
.verdicts li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; padding: 8px 0; font-size: 15px; line-height: 1.5; }
.verdicts .mark { font-weight: 700; text-align: center; }
.verdicts .true { color: var(--ok); }
.verdicts .false { color: var(--conf); }
.verdicts .cutoff { color: var(--warn); }
.verdicts .stmt { color: var(--text); }
.verdicts .note { display: block; margin-top: 3px; color: var(--dim); font-size: 14px; line-height: 1.55; }
.reason { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--line); font-size: 14px; line-height: 1.6; color: var(--dim); }
.outcome { margin-top: 16px; padding: 14px 16px; border-radius: 10px; background: var(--panel-hi); font-size: 15px; }
.outcome .ok { color: var(--ok); font-weight: 600; }
.outcome .bad { color: var(--warn); font-weight: 600; }

/* ---------------------------------------------------------------- interaction */
.btn, .q, .chips button, .nav a { transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease; }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  a.btn:hover { transform: translateY(-2px); }
  .q:hover { background: #242C3D; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .cards.three, .cards.two, .grid2, .queries { grid-template-columns: 1fr; }
  .grid4 { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); row-gap: 12px; }
  .stats div:nth-child(3n + 1) { border-left: 0; }
  main > section { padding: 56px 0 28px; }
  #diagnosis .grid2 figure img { height: auto; }
}
@media (max-width: 520px) {
  body { font-size: 16px; }
  .hero-content { padding: 72px 20px 96px; }
  .hero h1 { font-size: clamp(40px, 12.8vw, 64px); }
  .subtitle { margin: 18px 0 24px; }
  .tagline { font-size: 15px; margin: -10px auto 24px; }
  .authors { font-size: 14px; line-height: 1.85; }
  .affils { font-size: 12px; }
  .buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 340px; margin-inline: auto; }

  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats div:nth-child(n) { border-left: 0; }
  .stats div:nth-child(even) { border-left: 1px solid var(--line); }

  .nav { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; gap: 2px; padding: 6px 12px; }
  .nav a { flex: 0 0 auto; display: inline-flex; align-items: center; min-height: 44px; white-space: nowrap; }

  .ex { padding: 14px; }
  .ex-head h3 { font-size: 21px; }
  .ex-controls > .select { width: 100%; }
  .select select { flex: 1; min-width: 0; max-width: none; min-height: 44px; }
  .chips { gap: 6px; }
  .chips button { min-height: 44px; padding: 8px 12px; }
  .step-card { padding: 14px; }
  .thumbs { display: flex; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 6px; }
  .thumbs figure { flex: 0 0 72%; scroll-snap-align: start; }
}
/* touch: hero settles onto the video section (desktop wheel snap is in main.js) */
@media (pointer: coarse) {
  html { scroll-snap-type: y proximity; }
  .hero, #video { scroll-snap-align: start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; scroll-snap-type: none; }
  .btn, .q, .chips button, .nav a { transition: none; }
  .evidence-enter { animation: none; }
}
