/* /how: a seven-step guided walkthrough of one question through ChatFPV.
   Same OpenDrone identity tokens as the chat app (gold accent, paper/ink
   neutrals); follows prefers-color-scheme. Layout: one full-screen stage per
   step. The 3D map fills the screen; each step's visual (a board, a passage,
   the answer) floats over it, with a small caption card for the one-line
   explanation, optional "How this works" reading, and Back/Next. */
:root {
  color-scheme: dark;
  --bg: #0d0d10;
  --panel: #141418;
  --elev: #1f1f24;
  --elev2: #26262c;
  --text: #ececee;
  --muted: #a3a3a9;
  --border: #313138;
  --gold: #ffb700;
  --gold-soft: color-mix(in srgb, #ffb700 16%, transparent);
  --on-gold: #1a1a1e;
  --link: var(--gold);
  --danger: #ff8a80;
  --danger-soft: color-mix(in srgb, #ff8a80 14%, transparent);
  --good: #35d488;
  --good-soft: color-mix(in srgb, #35d488 14%, transparent);
  --meaning: #5cc8ff;
  --keyword: #ffb700;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --overlay: color-mix(in srgb, var(--bg) 78%, transparent);
  --panel-w: 460px;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f7f6f3;
    --panel: #fbfaf7;
    --elev: #efeee9;
    --elev2: #e7e5de;
    --text: #1a1a1e;
    --muted: #55534f;
    --border: #d3d1c7;
    --gold-soft: color-mix(in srgb, #ffb700 22%, transparent);
    --link: #1a1a1e;
    --danger: #b42318;
    --danger-soft: color-mix(in srgb, #b42318 10%, transparent);
    --good: #1c7a4d;
    --good-soft: color-mix(in srgb, #1c7a4d 10%, transparent);
    --meaning: #0b6fa4;
    --keyword: #8a5a00;
    --shadow: 0 8px 28px rgba(26, 26, 30, 0.14);
    --overlay: color-mix(in srgb, var(--bg) 84%, transparent);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  overflow-x: hidden;
}
a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
:focus { outline: none; }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible, #map-canvas:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 2px;
}
button { font: inherit; color: inherit; }
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--gold); color: var(--on-gold);
  padding: 8px 14px; z-index: 200; border-radius: 0 0 6px 0;
}
.skip:focus { left: 0; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
noscript.how-noscript {
  display: block; margin: 24px auto; max-width: 640px; padding: 14px 18px; text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; color: var(--muted);
}


/* ---- map ---- */

.map-hero { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.map-hero #map-live-group { position: absolute; inset: 0; }
.map-canvas-wrap {
  position: relative; width: 100%; height: 100%;
  background: radial-gradient(ellipse at 50% 45%, var(--elev) 0%, var(--bg) 100%);
}
#map-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#map-canvas:active { cursor: grabbing; }
#map-status {
  position: absolute; right: 10px; top: 10px; z-index: 1; margin: 0;
  font-size: 12px; color: var(--muted); background: var(--overlay); padding: 3px 8px; border-radius: 999px;
}
.map-caption {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3; margin: 0;
  max-width: min(92%, 560px); padding: 6px 12px; border-radius: 999px; text-align: center;
  font-size: 13px; font-weight: 600; color: var(--text); background: var(--overlay);
  border: 1px solid var(--border); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  pointer-events: none; transition: opacity 0.25s ease;
}
.map-caption:empty { opacity: 0; }
#map-legend {
  position: absolute; left: 10px; top: 10px; z-index: 1;
  max-width: min(70%, 520px); margin: 0; font-size: 11px; color: var(--muted);
}
.map-legend-chips {
  display: flex; flex-wrap: wrap; gap: 3px 10px; margin: 0; padding: 6px 8px;
  background: var(--overlay); border-radius: 8px;
}
.map-legend-item { display: inline-flex; align-items: center; gap: 4px; }
.map-legend-swatch { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.map-legend-toggle {
  display: none; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--overlay); color: var(--text); font-size: 11px; cursor: pointer;
}
.map-legend-toggle { display: inline-block; }
.map-legend-chips { display: none; }
#map-legend[data-expanded='1'] .map-legend-toggle { display: none; }
#map-legend[data-expanded='1'] .map-legend-chips { display: flex; max-width: min(calc(100vw - 24px), 520px); }
#map-cluster-labels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.map-cluster-label {
  position: absolute; top: 0; left: 0; transform: translate(-9999px, -9999px);
  padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600;
  color: var(--text); background: color-mix(in srgb, var(--bg) 72%, transparent);
  border: 1px solid var(--border); white-space: nowrap; transition: opacity 0.2s ease;
}
body:not([data-level='1']) #map-cluster-labels { opacity: 0.35; }
.map-cluster-list-wrap {
  position: absolute; left: 10px; bottom: 10px; z-index: 2; margin: 0; font-size: 12px; color: var(--muted);
  background: var(--overlay); border-radius: 8px; padding: 2px 8px; max-width: min(50%, 300px);
}
.map-cluster-list-wrap summary { cursor: pointer; color: var(--muted); }
.map-cluster-list-wrap ul { margin: 6px 0 4px; padding-left: 18px; max-height: 30vh; overflow: auto; }
@media (max-width: 859px) { .map-cluster-list-wrap, #map-status { display: none; } }
#map-tooltip {
  position: absolute; top: 0; left: 0; max-width: 260px; z-index: 5;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  font-size: 12px; box-shadow: var(--shadow); pointer-events: none;
}
#map-tooltip .map-tooltip-source { color: var(--link); font-weight: 600; margin-bottom: 4px; }
#map-tooltip .map-tooltip-text { color: var(--text); margin-bottom: 6px; line-height: 1.4; }
#map-tooltip a { pointer-events: auto; }
.map-fallback-note {
  position: absolute; left: 10px; bottom: 44px; z-index: 1; max-width: 300px;
  margin: 0; padding: 8px 10px; font-size: 12px; color: var(--muted);
  background: var(--elev); border: 1px solid var(--border); border-radius: 8px;
}


/* ---- stage ---------------------------------------------------------------- */
#stage { position: relative; height: 100vh; height: 100svh; overflow: hidden; }
.veil {
  position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 50%, color-mix(in srgb, var(--bg) 55%, transparent) 0%, color-mix(in srgb, var(--bg) 88%, transparent) 70%);
  transition: opacity 0.6s ease;
}
body[data-step='1'] .veil { opacity: 1; }
body[data-step='4'] .veil, body[data-step='5'] .veil, body[data-step='6'] .veil, body[data-step='7'] .veil { opacity: 0.85; }

.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6; display: flex; align-items: center; gap: 14px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
/* chatfpv polish-beta-ui: BETA label, same recipe as style.css .ai-badge. */
.beta-badge {
  display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  padding: 1px 6px; border-radius: 999px; background: var(--gold); color: var(--on-gold); line-height: 1.3;
}
.dots { list-style: none; display: flex; gap: 6px; margin: 0 auto; padding: 6px 10px; border-radius: 999px; background: var(--overlay); }
.dots li { width: 8px; height: 8px; border-radius: 999px; background: var(--border); transition: width 0.35s ease, background 0.35s ease; }
.dots li.done { background: var(--good); }
.dots li.on { width: 24px; background: var(--gold); }
body[data-step='1'] .dots { visibility: hidden; }
.chip-btn {
  min-height: 36px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--overlay);
  color: var(--text); cursor: pointer; font-size: 14px; line-height: 1.2; text-align: left;
}
.chip-btn:hover { border-color: var(--gold); }
.chip-btn[aria-pressed='true'] { border-color: var(--gold); background: var(--gold-soft); }
.chip-btn:disabled { opacity: 0.5; cursor: default; }

/* map chrome moves out of the way of the topbar */
#map-legend { top: 56px; }
#map-status { top: 60px; }
#stage .map-cluster-list-wrap { top: 94px; bottom: auto; }
body:not([data-step='1']) #map-status { display: none; }
body[data-step='1'] #map-legend, body[data-step='1'] .map-cluster-list-wrap { opacity: 0; pointer-events: none; }

/* ---- scenes ------------------------------------------------------------------ */
.scene {
  position: absolute; z-index: 3; pointer-events: none;
  /* sequenced, never a crossfade: the old scene fades out first, the new one fades in after it */
  transition: opacity 0.5s ease 0.3s, transform 0.5s ease-out 0.3s;
}
.scene.leave { transition-duration: 0.4s; transition-delay: 0s; }
.scene > * { pointer-events: auto; }
.scene.enter { opacity: 0; transform: translateY(8px); }
.scene.enter.back { transform: translateY(8px); }
.scene.leave { opacity: 0; transform: none; }
.scene.leave.back { transform: none; }

.scene-ask {
  left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(620px, calc(100vw - 32px));
  text-align: center;
}
.scene-ask.enter, .scene-ask.leave { opacity: 0; transform: translate(-50%, -48.5%); }
.scene-ask h1 { font-size: clamp(28px, 5vw, 44px); line-height: 1.1; margin: 0 0 10px; letter-spacing: -0.02em; }
.lede { color: var(--muted); font-size: 17px; margin: 0 0 20px; }
#ask-form { display: flex; gap: 8px; margin: 0 0 12px; }
#ask-q {
  flex: 1 1 auto; min-width: 0; min-height: 52px; padding: 12px 16px; border-radius: 14px; font: inherit; font-size: 17px;
  border: 1.5px solid var(--border); background: var(--panel); color: var(--text); box-shadow: var(--shadow);
}
#ask-q:focus-visible { border-color: var(--gold); outline: none; }
.example-qs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
#ask-turnstile { display: flex; justify-content: center; margin-top: 10px; }
.status { min-height: 1.5em; margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.status[data-state='error'] { color: var(--danger); }
.status[data-state='busy']::before, .verdict[data-state='busy']::before, .answer .busy::before {
  content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid var(--gold); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.counts { margin: 18px 0 0; font-size: 13px; color: var(--muted); }

/* boards float right of the caption on a desktop, over the top of the screen on a phone */
.scene-board {
  right: 24px; top: 64px; bottom: 24px; width: min(620px, calc(100vw - 500px));
  display: flex; flex-direction: column; justify-content: center; gap: 10px; overflow-y: auto;
  padding: 4px; scrollbar-width: thin;
}
.scene-top { left: 50%; top: 64px; transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); }
.scene-top.enter, .scene-top.leave { opacity: 0; transform: translate(-50%, -12px); }

.card {
  background: color-mix(in srgb, var(--panel) 94%, transparent); border: 1px solid var(--border); border-radius: 14px;
  padding: 12px 14px; box-shadow: var(--shadow); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.card-k { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); }

/* ---- caption card ------------------------------------------------------------ */
.caption {
  position: absolute; z-index: 5; left: 24px; bottom: 24px; width: min(440px, calc(100vw - 32px));
  max-height: calc(100svh - 110px); display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--panel) 95%, transparent); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.caption.swap { opacity: 0.2; transform: translateY(6px); }
.cap-ghost { position: absolute; inset: 0; overflow: hidden; pointer-events: none; opacity: 1; transition: opacity 0.35s ease; }
.cap-ghost.out { opacity: 0; }
.cap.in { animation: capin 0.45s ease 0.25s backwards; }
.caption.appear { animation: capin 0.45s ease backwards; }
#rank-cards { transition: opacity 0.25s ease; }
#rank-cards.fading { opacity: 0; }
@keyframes capin { from { opacity: 0; } }
.cap { padding: 14px 16px 4px; overflow-y: auto; min-height: 0; }
.cap h2 { font-size: 20px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.01em; }
.cap > p { margin: 0 0 10px; color: var(--muted); font-size: 15px; }
.capnav { display: flex; align-items: center; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.capnav .count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-right: auto; }
.primary, .ghost { min-height: 44px; padding: 10px 18px; border-radius: 12px; cursor: pointer; font-weight: 700; }
.primary { background: var(--gold); color: var(--on-gold); border: 0; transition: background-color 0.35s ease, color 0.35s ease; }
.primary:disabled { background: var(--elev2); color: var(--muted); cursor: default; }
.primary.small { min-height: 38px; padding: 8px 14px; }
.ghost { background: transparent; border: 1px solid var(--border); font-weight: 600; }
.ghost:hover { border-color: var(--gold); }
#next-btn { min-width: 150px; }
#next-btn.act { box-shadow: 0 0 0 0 var(--gold); animation: ring 1.8s ease-out 2; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--gold) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 12px transparent; } }
.loop .live { display: block; margin-top: 4px; color: var(--text); font-weight: 700; }
#next-btn:not(:disabled) { animation: nudge 1.6s ease-in-out 0.6s 2; }
@keyframes nudge { 0%, 100% { transform: none; } 50% { transform: translateY(-2px); box-shadow: 0 4px 16px var(--gold-soft); } }
.more { margin: 4px 0 8px; font-size: 14px; }
.more summary { cursor: pointer; color: var(--link); font-weight: 600; list-style: none; padding: 4px 0; }
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: '+ '; }
.more[open] summary::before { content: '− '; }
.more-body { color: var(--muted); padding: 2px 0 6px; }
.more-body p { margin: 0 0 8px; }
.more-body b { color: var(--text); }
.more-body table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 4px 0 8px; }
.more-body td { padding: 3px 4px; border-top: 1px solid var(--border); vertical-align: top; }
.more-body td.n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.verdict { margin: 0 0 10px; font-size: 14.5px; }
.verdict:empty { display: none; }
.verdict[data-state='good'] { color: var(--good); }
.verdict[data-state='bad'] { color: var(--danger); }
.verdict strong { color: var(--text); }
.verdict .why { display: block; margin-top: 3px; color: var(--muted); }
.verdict .bad-token { background: var(--danger-soft); color: var(--danger); border-radius: 3px; padding: 0 3px; font-weight: 700; }

/* step 2: meaning */
.vec-card { padding: 10px 12px; }
.vec { display: grid; grid-template-columns: repeat(32, 1fr); gap: 2px; }
.vec i { display: block; aspect-ratio: 1; border-radius: 2px; background: var(--keyword); }
.vec i.neg { background: var(--meaning); }
.vec { animation: fadein 0.5s ease-out; }
.try { margin: 0 0 6px; display: none; }
.cap.trying .try { display: block; }
@media (max-width: 859px) { .cap.trying .explain { display: none; } body.trying[data-step='2'] .vec-card { display: none; } }
.try-k { margin: 0 0 6px; font-size: 13px; font-weight: 700; color: var(--text); }
.phrases { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.phrases .chip-btn { font-size: 13px; min-height: 32px; padding: 5px 10px; }
.phrases .chip-btn i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }
#phrase-form { display: flex; gap: 6px; margin-bottom: 8px; }
#phrase-q { flex: 1 1 auto; min-width: 0; min-height: 36px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; font-size: 14px; }

/* map overlay drawn by map.js */
.map-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; overflow: visible; }
.ov-line { stroke: var(--gold); stroke-width: 1.2; stroke-opacity: 0.55; }
.ov-line.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 0.6s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.map-overlay text, .map-overlay circle { animation: fadein 0.4s ease-out backwards; }
@keyframes fadein { from { opacity: 0; } }
#map-cluster-labels { transition: opacity 0.3s ease; }
#map-cluster-labels.moving { opacity: 0; }
.ov-line.phrase { stroke-dasharray: 3 3; }
.ov-query { fill: var(--gold); stroke: var(--bg); stroke-width: 2; }
.ov-query-halo { fill: var(--gold); fill-opacity: 0.16; animation: halo 1.6s ease-in-out 1; }
@keyframes halo { 50% { fill-opacity: 0.32; } }
.ov-dot { stroke: var(--bg); stroke-width: 2; fill: var(--meaning); }
.ov-dot.p0 { fill: #5cc8ff; } .ov-dot.p1 { fill: #35d488; } .ov-dot.p2 { fill: #c792ff; } .ov-dot.p3 { fill: #ff8a80; } .ov-dot.p4 { fill: var(--text); }
.ov-label { font: 700 12px system-ui, sans-serif; fill: var(--text); paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.ov-query-label { fill: var(--gold); }
.phrases i.p0 { background: #5cc8ff; } .phrases i.p1 { background: #35d488; } .phrases i.p2 { background: #c792ff; } .phrases i.p3 { background: #ff8a80; } .phrases i.p4 { background: var(--text); }

/* step 3: lanes */
.lanes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lane[data-lane='meaning'] { border-top: 3px solid var(--meaning); }
.lane[data-lane='keyword'] { border-top: 3px solid var(--keyword); }
.lane-n { color: var(--text); margin-left: 4px; }
.lane-hits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; min-height: 40px; }
.lane-hits li {
  font-size: 13px; line-height: 1.3; padding: 6px 8px; border-radius: 8px; background: var(--elev);
  opacity: 0; transform: translateY(6px); animation: rise 0.35s ease forwards; overflow-wrap: anywhere;
}
.lane-hits li.both { box-shadow: inset 0 0 0 1.5px var(--good); }
.lane-hits li.more { background: none; color: var(--muted); padding: 2px 8px; }
.lane-hits li.wait { background: none; color: var(--muted); animation: none; opacity: 1; transform: none; }
.lane-hits mark, .card mark { background: var(--gold-soft); color: inherit; border-radius: 3px; padding: 0 1px; }
.tag-both { display: inline-block; margin-left: 4px; font-size: 10px; font-weight: 700; color: var(--good); text-transform: uppercase; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* step 4: rank cards */
.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rank-card {
  width: 100%; text-align: left; display: block; padding: 11px 13px; border-radius: 14px; cursor: pointer; color: var(--text);
  border: 1.5px solid var(--border); background: color-mix(in srgb, var(--panel) 95%, transparent); box-shadow: var(--shadow);
  transition: border-color 0.2s ease;
}
.rank-card:hover:not(:disabled) { border-color: var(--gold); }
.rank-card:disabled { cursor: default; }
.rank-card .src { display: block; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.rank-card .sec, .passage .sec { display: block; font-size: 14px; font-weight: 700; margin-top: 2px; }
.rank-card .snip { display: block; font-size: 14px; line-height: 1.4; margin-top: 3px; color: var(--muted); }
.rank-card .meter { display: none; margin-top: 8px; height: 6px; border-radius: 3px; background: var(--elev2); overflow: hidden; }
.rank-card .meter i { display: block; height: 100%; width: 0; background: var(--muted); border-radius: 3px; transition: width 0.7s ease; }
.rank-card .rank-note { display: none; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.cards[data-revealed='1'] .meter, .cards[data-revealed='1'] .rank-note { display: block; }
.rank-card[data-top='1'] { border-color: var(--good); }
.rank-card[data-top='1'] .meter i { background: var(--good); }
.rank-card[data-picked='1'] { box-shadow: 0 0 0 2px var(--gold), var(--shadow); animation: picked 0.45s ease; }
@keyframes picked { 40% { transform: scale(1.025); } }
.rank-card[data-picked='1'] .rank-note { color: var(--text); font-weight: 600; }

/* step 5: quote */
.passage .src { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }
.passage .sec { margin: 2px 0 8px; }
.sent {
  display: block; width: 100%; text-align: left; font-size: 15px; line-height: 1.45; padding: 7px 9px; margin: 2px 0; color: var(--text);
  border-radius: 9px; border: 1px solid transparent; background: transparent; cursor: pointer;
}
.sent:hover:not(:disabled) { background: var(--gold-soft); }
.sent:disabled { cursor: default; color: var(--muted); }
.sent[data-picked='1'] { border-color: var(--good); background: var(--good-soft); color: var(--text); animation: picked 0.45s ease; }
.tamper { display: flex; flex-direction: column; gap: 8px; }
.tamper label { font-weight: 700; font-size: 14.5px; }
.tamper textarea {
  resize: vertical; font: inherit; font-size: 14.5px; line-height: 1.4; min-height: 44px; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.tamper .primary { align-self: flex-start; }
.tamper:not([hidden]) { animation: fadein 0.45s ease-out; }

/* step 6: answer */

.answer { font-size: 15px; line-height: 1.55; min-height: 120px; }
.answer p { margin: 0 0 8px; }
.answer ul, .answer ol { margin: 0 0 8px; padding-left: 20px; }
.answer li.sub { margin-left: 16px; list-style: circle; }
.answer pre { margin: 0 0 8px; padding: 8px; background: var(--elev2); border-radius: 6px; overflow-x: auto; font-size: 12.5px; }
.answer pre code { background: none; padding: 0; }
.answer code { font-size: 13px; background: var(--elev2); padding: 1px 4px; border-radius: 4px; }
.answer .busy { color: var(--muted); margin: 0; }
.answer .srcs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; }
.answer .srcs span {
  font-size: 12px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--elev);
  animation: slidein 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}
@keyframes slidein { from { opacity: 0; transform: translateX(-60px); } }
.cite {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; margin: 0 1px;
  border-radius: 6px; border: 0; background: var(--gold); color: var(--on-gold); font-size: 12px; font-weight: 800;
  vertical-align: 1px; cursor: pointer; line-height: 1;
}
.cite[aria-pressed='true'] { outline: 2px solid var(--text); }
.cite-detail { border-color: var(--gold); font-size: 14px; }
.cite-detail .src { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.cite-detail p { margin: 4px 0 0; }

/* step 7: loop */
.loop { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.loop li {
  display: flex; flex-direction: column; gap: 4px; padding: 14px; border-radius: 14px; border: 1.5px solid var(--border);
  background: color-mix(in srgb, var(--panel) 95%, transparent); box-shadow: var(--shadow); font-size: 14.5px;
  transition: border-color 0.35s ease, background 0.35s ease, transform 0.35s ease;
}
.loop li b { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.loop li[data-lit='1'] { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 14%, var(--panel)); transform: translateY(-3px); }
.loop li[data-lit='1'] b { color: var(--text); }
.summary ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; font-size: 14.5px; }
.summary .ok { color: var(--good); font-weight: 700; }
.summary .no { color: var(--muted); font-weight: 700; }
.summary .ctas { display: flex; flex-wrap: wrap; gap: 8px; }
.summary .ctas a.primary { text-decoration: none; display: inline-grid; place-items: center; }

/* ---- phone ------------------------------------------------------------------------ */
@media (max-width: 859px) {
  .topbar { padding: max(8px, env(safe-area-inset-top)) 12px 6px; gap: 8px; }
  .dots { padding: 5px 8px; gap: 5px; }
  .dots li.on { width: 18px; }
  #map-legend, #map-status, .map-cluster-list-wrap { display: none; }
  .lede { font-size: 15px; }
  .scene-board { left: 10px; right: 10px; width: auto; top: 52px; bottom: var(--cap-h, 240px); justify-content: flex-start; padding: 4px 2px 12px; }
  .scene-top { top: 52px; }
  .caption { left: 0; right: 0; bottom: 0; width: auto; border-radius: 16px 16px 0 0; max-height: 58svh; }
  .cap { padding: 12px 14px 2px; }
  .cap h2 { font-size: 18px; }
  .cap > p { font-size: 14px; margin-bottom: 8px; }
  .lanes { grid-template-columns: 1fr; }
  .loop { grid-template-columns: 1fr; gap: 6px; }
  .loop li { padding: 10px 12px; }
  #next-btn { min-width: 0; flex: 1 1 auto; }
  /* small screen: fade only, no slide, so text never travels across the frame */
  .scene.enter, .scene.enter.back { transform: none; }
  .scene-top.enter, .scene-top.leave { transform: translateX(-50%); }
  .rank-card .meter i { transition-duration: 0.9s; }
  .answer .srcs span { animation-name: fadein; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .lane-hits li { opacity: 1; transform: none; }
  .ov-line.draw { stroke-dashoffset: 0; }
  /* instant cuts, softened with a short fade: no movement */
  .scene { transition: opacity 0.2s linear !important; }
  .scene.enter, .scene.leave, .scene-ask.enter, .scene-ask.leave, .scene-top.enter, .scene-top.leave { transform: none; }
  .scene-ask.enter, .scene-ask.leave { transform: translate(-50%, -50%); }
  .scene-top.enter, .scene-top.leave { transform: translateX(-50%); }
}

/* map labels (hierarchical) */
/* #map-cluster-labels itself stays pointer-events:none (existing rule above);
   only the label pills and the hover/tap card opt back into pointer events,
   so the labels never block dragging/zooming the canvas underneath them. */
.map-cluster-label { pointer-events: auto; cursor: pointer; }
.map-cluster-label-l0 { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.map-cluster-label-l1 { font-size: 11.5px; }
.map-cluster-label-l2 { font-size: 11px; font-weight: 500; }
#map-cluster-card {
  position: absolute; top: 0; left: 0; z-index: 6; max-width: 220px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 11.5px; box-shadow: var(--shadow); pointer-events: auto;
}
.map-cluster-card-title { font-weight: 700; color: var(--text); margin-bottom: 2px; }
.map-cluster-card-count { color: var(--muted); margin-bottom: 6px; }
.map-cluster-card-example {
  color: var(--text); opacity: 0.85; line-height: 1.35; margin-top: 3px;
  padding-top: 3px; border-top: 1px solid var(--border);
}
@media (max-width: 480px) {
  .map-cluster-label-l0, .map-cluster-label-l1 { font-size: 11px; }
  #map-cluster-card { max-width: 180px; font-size: 11px; }
}
