/* CityPedia project page.
   Layout: a full-height hero over a mosaic of real camera frames, which the page slides over; then the lab bar,
   TL;DR, abstract, method, demos, results and BibTeX. Text sits in a 1000px column, the demos in a 1120px one.
   A section index stays at the right edge. Spacing sits on a 4px grid.
   Color: one warm paper ramp for every surface below the hero, harbor blue as the single accent (paper theme f-city-light). */
:root {
  /* One warm paper ramp. --bg is the page, --surface the sheets that lie on it (cards, map land, tables). */
  --bg: #faf7ef;
  --bg-2: #f3efe4;
  --surface: #fffdf8;
  --raised: #ece7da;
  --raised-2: #e3ddcd;
  --ink: #1d1b16;
  --ink-2: #57534a;
  --ink-3: #7b766a;
  --line: rgba(29, 27, 22, 0.1);
  --line-2: rgba(29, 27, 22, 0.2);
  --shadow: rgba(29, 27, 22, 0.08);
  --accent: #1d74ae;
  --accent-ink: #15598a;
  --accent-1: #d4ebff;
  --accent-2: #95c3e9;
  --orange: #df6a2e;
  --arxiv: #b31b1b;
  --good: #15803d;
  --bad: #b45309;
  --r-s: 6px;
  --r-m: 8px;
  --r-l: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: "Noto Sans", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --mono: "Noto Sans Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent-ink); text-underline-offset: 2px; }
b, strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font: inherit; color: inherit; }

.wrap {
  max-width: 1120px; margin: 0 auto;
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
}
.wrap.text { max-width: 1000px; }
section { padding-block: 32px; }
section.tight { padding-block: 16px; }
section.lead { padding-top: 56px; }   /* the summary box keeps clear of the hero above it */

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.2; text-wrap: balance; }
h2 { font-size: 36px; margin-bottom: 16px; text-align: center; }
h2:not(:first-child) { margin-top: 40px; }
.kicker + h2 { margin-top: 0; }
h3 { font-size: 16px; }
/* A part of the section above it: a smaller heading and less space than a new section. */
h3.subhead { font-size: 24px; margin-bottom: 12px; text-align: center; }
section.part { padding-top: 8px; }
.prose { margin: 0 0 16px; color: var(--ink-2); text-align: justify; hyphens: auto; }
.intro { max-width: 72ch; color: var(--ink-2); margin: 0 auto 24px; text-align: center; text-wrap: pretty; }
.note { font-size: 14px; line-height: 20px; color: var(--ink-2); margin: 16px 0 0; max-width: 100ch; }
.muted { color: var(--ink-2); font-size: 14px; line-height: 20px; margin: 0; }

/* Signature: cells of the 16 x 16 patch grid mark each demo. The accent cell moves one place
   clockwise from one demo to the next (classes c1 to c4). */
.kicker { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 8px; font: 500 13px/20px var(--mono); color: var(--ink-3); }
.patch {
  --c1: var(--line-2); --c2: var(--line-2); --c3: var(--line-2); --c4: var(--line-2);
  width: 12px; height: 12px; flex: none;
  background:
    linear-gradient(var(--c1), var(--c1)) 0 0 / 5px 5px no-repeat,
    linear-gradient(var(--c2), var(--c2)) 7px 0 / 5px 5px no-repeat,
    linear-gradient(var(--c3), var(--c3)) 7px 7px / 5px 5px no-repeat,
    linear-gradient(var(--c4), var(--c4)) 0 7px / 5px 5px no-repeat;
}
.patch.c1 { --c1: var(--accent); }
.patch.c2 { --c2: var(--accent); }
.patch.c3 { --c3: var(--accent); }
.patch.c4 { --c4: var(--accent); }

/* ── Section index ──
   A rail of ticks at the right edge. Only the ticks take the pointer while the names are hidden,
   so the rail never blocks the content under it. */
.index {
  --tick: var(--line-2);
  position: fixed; z-index: 15; top: 50%; right: env(safe-area-inset-right, 0px); transform: translateY(-50%);
  padding: 8px 4px 8px 12px; border-radius: var(--r-m) 0 0 var(--r-m);
  pointer-events: none;
  transition: background-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.index ol { list-style: none; margin: 0; padding: 0; }
.index a {
  display: flex; align-items: center; justify-content: flex-end; height: 28px;
  color: var(--ink-2); text-decoration: none; font-size: 13px; line-height: 20px; white-space: nowrap;
}
.index a::after {
  content: ""; flex: none; width: 24px; height: 100%; pointer-events: auto;
  background: linear-gradient(var(--tick), var(--tick)) right center / 12px 2px no-repeat;
  transition: background-size 150ms var(--ease);
}
.index .sub span { font-size: 0.92em; color: var(--ink-3); }
.index .sub a[aria-current] span { color: inherit; }
.index a:hover { --tick: var(--ink-3); }
.index a:hover::after { background-size: 16px 2px; }
.index a[aria-current] { --tick: var(--accent); color: var(--ink); font-weight: 500; }
.index a[aria-current]::after { background-size: 20px 2px; }
.index a:focus-visible { outline: none; }
.index a:focus-visible span { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.index span { padding-right: 8px; opacity: 0; transform: translateX(4px); transition: opacity 150ms var(--ease), transform 150ms var(--ease); }
.index.open, .index:focus-within { pointer-events: auto; background: var(--surface); box-shadow: 0 0 0 1px var(--line), 0 8px 24px var(--shadow); }
.index.open span, .index:focus-within span { opacity: 1; transform: none; }
@media (hover: hover) {
  .index:hover { pointer-events: auto; background: var(--surface); box-shadow: 0 0 0 1px var(--line), 0 8px 24px var(--shadow); }
  .index:hover span { opacity: 1; transform: none; }
}
/* With room beside the content column the names stay in view. */
@media (min-width: 1480px) {
  .index, .index:hover, .index.open, .index:focus-within { pointer-events: auto; background: none; box-shadow: none; }
  .index span { opacity: 1; transform: none; }
}
/* Over the hero the rail turns light, and its card dark. */
.index.light { --tick: rgba(255, 255, 255, 0.5); }
.index.light a { color: rgba(255, 255, 255, 0.82); }
.index.light a:hover { --tick: rgba(255, 255, 255, 0.8); }
.index.light a[aria-current] { --tick: #ffffff; color: #ffffff; }
.index.light.open, .index.light:focus-within { background: rgba(16, 14, 10, 0.72); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14); }
@media (hover: hover) { .index.light:hover { background: rgba(16, 14, 10, 0.72); box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14); } }
@media (min-width: 1480px) { .index.light, .index.light:hover, .index.light.open, .index.light:focus-within { background: none; box-shadow: none; } }
@media print { .index { display: none; } }

/* ── Blocks rise into place as they scroll into view (set by page.js, so no script means no hiding) ── */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity 600ms var(--ease), transform 600ms var(--ease); }
.reveal.in { opacity: 1; transform: none; }

/* ── Title block ── */
/* The hero is one fixed dark look in both themes: white type on a shaded mosaic of camera frames.
   --lift (0 to 1, set by page.js) is how far the page has slid over it. */
.hero {
  --lift: 0; --hero-ground: #12100c; --hero-ink: #ffffff; --hero-ink-2: rgba(255, 255, 255, 0.8);
  position: relative; display: grid; place-items: center; overflow: hidden;
  min-height: 100vh; min-height: 100svh; padding-block: 64px;
  text-align: center; background: var(--hero-ground); color: var(--hero-ink);
}
/* On a screen tall enough to hold the title block, the hero stays put and the page covers it. */
@media (min-height: 640px) and (min-width: 700px) {
  .hero { position: sticky; top: 0; height: 100vh; height: 100svh; }
}
main, footer { position: relative; z-index: 1; }
main { background: var(--bg); }
.hero-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-shade {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 70% 60% at center, rgba(16, 14, 10, 0.84) 0%, rgba(16, 14, 10, 0.66) 60%, rgba(16, 14, 10, 0.46) 100%);
}
.hero-body { position: relative; opacity: calc(1 - var(--lift) * 1.6); transform: translateY(calc(var(--lift) * -32px)); }
/* Title in three lines: the mark beside the name, then the two halves of the subtitle. */
.hero h1 { margin: 0 auto; font-weight: 600; text-shadow: 0 1px 12px rgba(16, 14, 10, 0.6); }
.hero h1 .name { display: flex; align-items: center; justify-content: center; gap: 0.22em; font-size: clamp(44px, 7.2vw, 80px); line-height: 1.1; margin-bottom: 12px; }
.hero h1 .mark { width: 1.15em; height: 1.15em; flex: none; }
.hero h1 .sub { display: block; font-size: clamp(22px, 3.5vw, 40px); line-height: 1.25; font-weight: 500; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.venue { margin: 20px 0 16px; font-size: 20px; color: var(--hero-ink-2); }
.authors { margin: 0; font-size: 18px; line-height: 28px; }
.authors { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 24px; }
.authors span { white-space: nowrap; }
.mail { width: 0.72em; height: 0.54em; margin-left: 3px; position: relative; top: -0.55em; }
.affil .mail { margin: 0 2px 0 0; top: -0.1em; }
.affil .corr { display: block; margin-top: 4px; font-size: 14px; }
.authors a { color: inherit; text-decoration: none; }
.authors a:hover { text-decoration: underline; }
.affil { margin: 8px 0 24px; font-size: 18px; color: var(--hero-ink-2); }
.hero-clock {
  position: absolute; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 12px; border-radius: 14px; white-space: nowrap;
  background: rgba(16, 14, 10, 0.62); color: var(--hero-ink-2); font: 400 13px/20px var(--mono); font-variant-numeric: tabular-nums;
  opacity: calc(1 - var(--lift) * 1.6);
}
.hero-clock .sep { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: 0.6; }
#hero-time { color: var(--hero-ink); }
.hero .btn:not(.arxiv) { background: #fffdf8; color: #1d1b16; }
.hero .btn:not(.arxiv):hover { background: #ece7da; }
.actions { display: flex; flex-wrap: wrap; gap: 12px 16px; justify-content: center; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 24px; border-radius: 22px;
  background: var(--ink); color: #fff; text-decoration: none; font-weight: 500; font-size: 15px;
  transition: background-color 150ms var(--ease), transform 150ms var(--ease);
}
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:hover { background: #38342c; }
.btn.arxiv { background: var(--arxiv); }
.btn.arxiv:hover { background: #8f1616; }
.btn:active { transform: scale(0.98); }
.btn.ghost { background: var(--bg); color: var(--ink); border: 1px solid var(--line-2); }
.btn.ghost:hover { background: var(--raised); }
.soon { font-size: 14px; color: var(--ink-3); }
.tldr {
  margin: 0 auto; padding: 12px 24px; font-size: 18px; line-height: 28px; color: var(--ink-2); text-align: center; text-wrap: balance;
  background: linear-gradient(90deg, #dcebf9 0%, #f3ecd2 100%); border-radius: var(--r-l);
  box-shadow: 0 1px 2px var(--shadow), 0 4px 12px var(--shadow);
}
.tldr b { color: var(--ink); }

/* ── Figures and method ── */
.paperfig { margin: 24px 0; }
.paperfig img { width: 100%; border: 1px solid var(--line); border-radius: var(--r-m); background: #fff; }
.paperfig.narrow { max-width: 720px; margin-inline: auto; }
/* An event sequence: four frames in one row, a label under each, as in the supplementary figures. */
.eventfig { margin: 24px 0; }
.eventrow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.eventframe img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r-s, 4px); }
.eventframe span { display: block; margin-top: 4px; font: 400 12px/16px var(--mono); color: var(--ink-3); text-align: center; }
@media (max-width: 600px) { .eventrow { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
figcaption { font-size: 14px; line-height: 20px; color: var(--ink-2); margin-top: 8px; }
/* How it works: three step buttons and the panel of the chosen step. */
.steps { margin: 32px 0 24px; }
.steptabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 24px; }
/* Each step has one shade of the accent, lighter to darker in the order of the procedure.
   The button carries the shade, and the open panel a light wash of it. */
#step-tab-1, #step-1 { --step: #d4ebff; }
#step-tab-2, #step-2 { --step: #a9d0f0; }
#step-tab-3, #step-3 { --step: #7bb2de; }
.steptab {
  cursor: pointer; min-height: 48px; padding: 8px 20px; border-radius: 10px; border: 0;
  background: var(--step); color: var(--ink); font-size: 15px; font-weight: 500; opacity: 0.72;
  transition: opacity 150ms var(--ease), box-shadow 150ms var(--ease), transform 150ms var(--ease);
}
.steptab:hover { opacity: 1; }
.steptab[aria-selected="true"] { opacity: 1; box-shadow: 0 0 0 2px var(--ink); }
.steptab:active { transform: scale(0.98); }
.steppanel {
  border: 1px solid color-mix(in srgb, var(--step) 70%, var(--line-2)); border-radius: var(--r-l);
  background: color-mix(in srgb, var(--step) 16%, var(--surface)); padding: 24px;
}
.steppanel + .steppanel { margin-top: 16px; }
.steptext p { margin: 0 0 12px; color: var(--ink-2); font-size: 16px; line-height: 26px; }
.steptext b { color: var(--ink); }
.steptext > :last-child { margin-bottom: 0; }
.tex { color: var(--ink); }
.tex.block { margin: -4px 0 8px; text-align: center; overflow-x: auto; overflow-y: hidden; padding-block: 2px; }
.tex.block .katex-display { margin: 0; }
.tex .katex { font-size: 1.08em; }
.tex.block .katex { font-size: 1.16em; }
/* A step figure: a toolbar, a canvas that draws the figure, and a readout under it. */
/* The figure has no frame of its own: it shares the panel of its step with the text. */
.stage { margin-top: 12px; padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--step) 70%, var(--line-2)); }
.stage canvas { display: block; width: 100%; touch-action: pan-y; }
.stagewrap { position: relative; }
.stage canvas.deep { position: absolute; width: auto; pointer-events: none; }
.stagebar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 4px; }
.stagehint { margin-left: auto; font-size: 13px; line-height: 20px; color: var(--ink-3); }
.stagectl { display: flex; gap: 4px; align-items: center; }
.stagectl .chip { background: var(--bg-2); border-color: var(--line); }
.stagectl .chip:hover { border-color: var(--line-2); }
.stagectl.slider { gap: 12px; font-size: 13px; font-weight: 500; color: var(--ink); }
.stagectl output { min-width: 4ch; font: 500 13px/20px var(--mono); color: var(--ink-2); }
.stagectl.slider input { width: 220px; accent-color: var(--accent); }
.stageread { margin: 8px 0 0; min-height: 20px; text-align: center; font-size: 14px; line-height: 20px; color: var(--ink-2); text-wrap: balance; }
.stageread b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.stagenote .key { display: inline-block; width: 12px; height: 12px; margin: 0 4px 0 12px; vertical-align: -1px; border-radius: 2px; }
.stagenote .key:first-child { margin-left: 0; }
.stagenote .key.mask { border: 2px solid #DF6A2E; }
.stagenote .key.share { background: rgba(223,106,46,.5); }
.stagenote .key.frame { background: var(--raised-2); border-radius: 0; }
.stagenote .key.kept { border: 2px solid var(--ink); }
.stagenote .key.added { border: 2px solid #1E9C6D; }
.stagenote .key.base { background: rgba(29,116,174,.62); }
.stagenote .key.gain { background: rgba(30,156,109,.8); }
.stagenote .key.unseen { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.stagenote .key.marked { background: rgba(29,116,174,.62); }
.stagenote { margin: 4px 0 0; font-size: 13px; line-height: 20px; color: var(--ink-3); text-align: center; }

/* ── Segmented controls and cards ── */
.controls { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 0 0 16px; align-items: center; }
/* The borough switch is the quieter control: plain buttons with no tray. */
#map-boroughs { background: none; padding: 0; }
#map-boroughs [aria-selected="true"], #map-boroughs [aria-pressed="true"] { background: var(--raised); border-color: transparent; box-shadow: none; }
#ground-body > .tabs, #ground-body > .layerbar { margin-bottom: 16px; }
.tabs, .layerbar { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--raised); border-radius: 10px; justify-self: start; }
.tab, .chip {
  cursor: pointer; border: 1px solid transparent; background: transparent; color: var(--ink-2);
  height: 36px; padding: 0 12px; border-radius: var(--r-s); font-size: 14px; font-weight: 500;
  transition: color 150ms var(--ease), background-color 150ms var(--ease), border-color 150ms var(--ease);
}
.chip { height: 32px; font-size: 13px; }
.tab:hover, .chip:hover { color: var(--ink); }
.tab[aria-selected="true"], .chip[aria-pressed="true"] {
  background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: 0 1px 2px var(--shadow);
}
.tab small { font-weight: 400; color: var(--ink-3); margin-left: 4px; font-size: 13px; }
.card { border: 1px solid var(--line); border-radius: var(--r-l); background: var(--surface); padding: 16px; display: grid; gap: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 14px; line-height: 20px; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 500; }
.card p { margin: 0; }
.tag { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--ink); }
.tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.tag.warn::before { background: var(--bad); }
.tag.ok::before { background: var(--good); }

/* ── Map ── */
.mapgrid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
.mapbox { position: relative; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--bg-2); overflow: hidden; }
#map { display: block; width: 100%; height: 620px; cursor: grab; touch-action: none; }
#map.drag { cursor: grabbing; }
.mapctl { position: absolute; top: 12px; right: 12px; display: grid; gap: 4px; justify-items: end; }
.mapctl button {
  width: 32px; height: 32px; border: 1px solid var(--line-2); background: var(--surface); border-radius: var(--r-m);
  font-size: 16px; line-height: 1; cursor: pointer; transition: background-color 150ms var(--ease);
}
.mapctl button.wide { width: auto; padding: 0 12px; font-size: 13px; font-weight: 500; }
.mapctl button:hover { background: var(--raised); }
.maplegend {
  position: absolute; left: 12px; top: 12px; background: color-mix(in srgb, var(--surface) 95%, transparent);
  border: 1px solid var(--line); border-radius: var(--r-m); padding: 8px 12px; font-size: 12px; line-height: 16px; max-width: 256px;
}
.maplegend b { font-weight: 500; }
.maplegend .row { display: flex; align-items: center; gap: 8px; margin-top: 4px; color: var(--ink-2); }
.maplegend .ramp { height: 8px; width: 120px; border-radius: 2px; }
.maplegend .sw { width: 24px; height: 12px; display: inline-grid; place-items: center; flex: none; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; line-height: 16px;
  padding: 4px 8px; border-radius: var(--r-s); white-space: nowrap; transform: translate(12px, 12px); z-index: 5;
}
.side { display: grid; gap: 16px; }
.side h3 { margin-bottom: 4px; }
.side p { margin: 4px 0; font-size: 14px; line-height: 20px; color: var(--ink-2); }
.side .card p { margin: 0; }
.big { display: flex; gap: 24px; margin: 12px 0 4px; flex-wrap: wrap; }
.big div { font-size: 13px; line-height: 16px; color: var(--ink-2); max-width: 152px; }
.big b { display: block; font-size: 28px; line-height: 32px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; margin-bottom: 4px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart svg text { font-family: var(--mono); }
.chart .legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); }
.chart .legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 4px; }
/* Top frames of the selected camera: one frame fills the row, two share it, three give one large and two small. */
#map-camera h4 { font-size: 14px; line-height: 20px; font-weight: 600; margin: 16px 0 8px; }
.shots { margin-bottom: 8px; }
.shot { margin: 0; position: relative; border-radius: var(--r-s); overflow: hidden; background: var(--raised); }
.shot.open { cursor: pointer; }
.shot.open:hover, .shot.open:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.shot .pic { aspect-ratio: 352 / 240; background-repeat: no-repeat; }
.shot figcaption { position: absolute; left: 0; bottom: 0; right: 0; font: 400 11px/16px var(--mono); color: #fff; background: rgba(16, 14, 10, 0.62); padding: 0 4px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 8px; }
.thumbs.scroll { max-height: 328px; overflow-y: auto; padding-right: 4px; }
.thumbs.four { grid-template-columns: repeat(4, 1fr); }
/* A frame thumbnail. The ring is drawn over the picture, so selecting one moves nothing. */
.thumb { position: relative; padding: 0; border: 0; border-radius: var(--r-s); overflow: hidden; cursor: pointer; background: var(--raised); line-height: 0; }
.thumb img { width: 100%; aspect-ratio: 352 / 240; object-fit: cover; }
.thumb::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--line-2); transition: box-shadow 150ms var(--ease); }
.thumb:hover::after { box-shadow: inset 0 0 0 2px var(--ink-3); }
.thumb[aria-pressed="true"]::after { box-shadow: inset 0 0 0 3px var(--accent); }
.thumb .cap { position: absolute; left: 0; bottom: 0; right: 0; font: 400 11px/16px var(--mono); color: #fff; background: rgba(16, 14, 10, 0.62); padding: 0 4px; text-align: left; }

/* ── Viewer ── */
.demo { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 24px; align-items: start; }
.demo > div { display: grid; gap: 16px; align-content: start; }
.viewer { position: relative; border-radius: var(--r-l); overflow: hidden; border: 1px solid var(--line); background: var(--raised); line-height: 0; }
.viewer img { width: 100%; }
.viewer canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.legendline { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 13px; line-height: 20px; color: var(--ink-2); }
.legendline span { display: inline-flex; align-items: center; gap: 8px; }
.legendline i, .classchip i { width: 12px; height: 12px; border-radius: 2px; display: inline-block; border: 1px solid var(--line-2); }
.classchip {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer; background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--r-s); height: 28px; padding: 0 8px; font-size: 13px;
  transition: border-color 150ms var(--ease), color 150ms var(--ease);
}
.classchip:hover { border-color: var(--line-2); }
.classchip[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); font-weight: 500; }
.ranks { display: grid; gap: 12px; }
.rank-row h4 { margin: 0 0 8px; font-size: 14px; line-height: 20px; font-weight: 500; }
.rank-row h4 .muted { font-weight: 400; }
.rank-row .cells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.rank { position: relative; padding: 0; border: 0; border-radius: var(--r-s); overflow: hidden; cursor: pointer; background: var(--raised); line-height: 0; }
.rank img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; }
.rank::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px var(--line-2); transition: box-shadow 150ms var(--ease); }
.rank.wrong::after { box-shadow: inset 0 0 0 3px var(--orange); }
.rank[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.rank .badge { position: absolute; left: 4px; top: 4px; background: rgba(16, 14, 10, 0.72); color: #fff; font: 400 11px/16px var(--mono); padding: 0 4px; border-radius: 4px; }
.stack { display: grid; gap: 16px; }
.stack > * { min-width: 0; justify-self: stretch; }
.stack > .layerbar { justify-self: start; }

/* ── Tables ── */
.tablebox { margin: 24px 0; }
.tabcap { font-size: 14px; line-height: 20px; color: var(--ink-2); margin-bottom: 8px; }
.tscroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); }
.tscroll.plain { border: 0; }
table.res { border-collapse: collapse; width: 100%; font-size: 13px; font-variant-numeric: tabular-nums; }
table.res th, table.res td { padding: 8px 6px; text-align: center; white-space: nowrap; }
table.res th:first-child, table.res td:first-child { text-align: left; padding-left: 12px; }
table.res thead th { font-weight: 500; color: var(--ink-2); }
table.res thead tr:last-child th { border-bottom: 1px solid var(--ink); }
table.res tr.rule td { border-top: 1px solid var(--line); }
table.res tr.group td { background: var(--bg-2); text-align: left; }
table.res td.best { background: var(--accent-2); font-weight: 500; }
table.res td.second { background: var(--accent-1); }
table.res td b { font-weight: 600; }
/* Composite overview: a radar of AP per query next to the list of the same queries. */
.overgrid { display: grid; grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 16px 32px; align-items: center; margin-top: 8px; }
.radar svg { display: block; width: 100%; height: auto; overflow: visible; }
.radar .ring, .radar .spoke { fill: none; stroke: var(--line); stroke-width: 1; }
.radar .spoke.on { stroke: var(--ink-2); }
.radar .arc { fill: none; stroke: var(--line-2); stroke-width: 2; stroke-linecap: round; }
.radar text { font: 400 11px var(--sans); fill: var(--ink-3); text-anchor: middle; dominant-baseline: central; }
.radar .tick { font-family: var(--mono); font-size: 10px; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.radar .set { fill: var(--ink-2); font-size: 12px; }
.radar .num { font-family: var(--mono); }
.radar .num.on { fill: var(--ink); font-weight: 600; }
.radar .shape { stroke-width: 2; stroke-linejoin: round; }
.radar .shape.zs { fill: rgba(123, 118, 106, 0.10); stroke: var(--ink-3); stroke-width: 1.5; }
.radar .shape.ours { fill: rgba(29, 116, 174, 0.10); stroke: var(--accent); stroke-width: 1.5; }
.radar .gain { stroke: var(--accent); stroke-width: 5; stroke-linecap: round; }
.radar .gain.down { stroke: var(--ink-3); }
.radar .gain.on { stroke-width: 7; }
.radar-key { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-size: 12px; line-height: 16px; color: var(--ink-2); }
.radar-key li { display: flex; align-items: center; gap: 6px; }
.radar-key .sw { width: 10px; height: 10px; border-radius: 50%; }
.radar-key .sw.zs { background: var(--ink-3); }
.radar-key .sw.ours { background: var(--accent); }
.radar-key .seg { width: 18px; height: 5px; border-radius: 3px; background: var(--accent); }
.radar-key .seg.down { background: var(--ink-3); }
.radar .dot { stroke: var(--surface); stroke-width: 2; }
.radar .dot.zs { fill: var(--ink-3); }
.radar .dot.ours { fill: var(--accent); }
.radar .dot.on { r: 6px; }
.qlist { list-style: none; margin: 0; padding: 0; font-size: 14px; line-height: 20px; font-variant-numeric: tabular-nums; }
.qlist li { display: grid; grid-template-columns: 20px minmax(0, 1fr) 72px 72px 64px; gap: 8px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); border-radius: var(--r-s); }
.qlist li.on { background: var(--bg-2); }
.qlist li:focus-visible { outline-offset: -2px; }
.qlist .head { color: var(--ink-2); font-size: 13px; }
.qlist .n { font: 400 12px/20px var(--mono); color: var(--ink-3); }
.qlist .q b { font-weight: 500; }
.qlist .q small { display: block; font-size: 12px; line-height: 16px; color: var(--ink-3); }
.qlist .v, .qlist .d { text-align: right; }
.qlist .v.zs { color: var(--ink-2); }
.qlist .d { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.qlist .d.down { color: var(--ink-3); }
.qlist .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; }
.qlist .sw.zs { background: var(--ink-3); }
.qlist .sw.ours { background: var(--accent); }
.qlist .total { border-bottom: 0; }
@media (max-width: 760px) {
  .overgrid { grid-template-columns: minmax(0, 1fr); }
  .radar { max-width: 340px; margin: 0 auto; width: 100%; }
  .qlist li { grid-template-columns: 20px minmax(0, 1fr) 48px 48px 56px; gap: 4px; padding-inline: 0; }
  .qlist .head .v { font-size: 0; } .qlist .head .sw { margin: 0; }
}
.ck { display: inline-block; width: 6px; height: 11px; border: solid var(--ink); border-width: 0 2px 2px 0; transform: rotate(40deg); margin-bottom: 1px; }

/* ── BibTeX and footer ── */
.bibbox { position: relative; }
.bib { margin: 0; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; overflow-x: auto; font: 400 13px/20px var(--mono); }
.copy {
  position: absolute; top: 8px; right: 8px; height: 28px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--r-s);
  background: var(--surface); font-size: 13px; cursor: pointer; transition: background-color 150ms var(--ease);
}
.copy:hover { background: var(--raised); }
footer { border-top: 1px solid var(--line); background: var(--bg-2); padding-block: 24px 40px; font-size: 13px; line-height: 20px; color: var(--ink-2); }
footer p { margin: 0 0 8px; }

.demo > *, .mapgrid > * { min-width: 0; }

@media (max-width: 900px) {
  .mapgrid, .demo { grid-template-columns: 1fr; }
  #map { height: 460px; }
  .maplegend { position: static; max-width: none; border: 0; border-top: 1px solid var(--line); border-radius: 0; box-shadow: none; }
}
@media (max-width: 480px) {
  .stagehint { margin-left: 0; }
  .stagectl.slider input { width: 160px; }
  .steptab { width: 100%; padding: 8px 16px; }
  .steppanel { padding: 16px; }
  h2 { font-size: 28px; }
  .hero h1 .sub { white-space: normal; text-wrap: balance; }
  .hero-clock { font-size: 11px; gap: 6px; }
  .hero-clock #hero-date { display: none; }
  .hero-clock .sep:nth-of-type(2) { display: none; }
  .prose { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
