/* Palette from docs/viz/DESIGN.md */
:root {
  --bg: #14171b; --line: #2a313a; --text: #e8ecf1; --muted: #8b96a5;
  --say: #3ddc97; --say-only: #f0b429; --do-only: #a78bfa; --none: #3a4350;
  --shop1: #60a5fa; --shop2: #f472b6; --panel: #1a1e23;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
code { color: var(--muted); }
.top { padding: 16px 20px 4px; }
h1 { margin: 0; font-size: 20px; letter-spacing: .02em; }
h1 .sub { color: var(--muted); font-weight: 400; font-size: 14px; margin-left: 6px; }
h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.takeaway { margin: 6px 0 0; color: var(--text); }
.banner { margin: 8px 20px 0; padding: 8px 12px; border: 1px solid var(--say-only); color: var(--say-only); font-weight: 700; letter-spacing: .12em; text-align: center; border-radius: 4px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.layout { display: grid; gap: 14px; padding: 14px 20px; grid-template-columns: minmax(250px, 1fr) minmax(340px, 1.6fr) minmax(250px, 1fr); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px; min-width: 0; }
.panel.wide { align-self: start; }
.panel.wide:nth-of-type(4) { grid-column: 1 / 2; }
.panel.wide:nth-of-type(5) { grid-column: 2 / 4; }
.empty { color: var(--muted); padding: 30px 10px; text-align: center; }

/* grid */
.grid-table { display: grid; gap: 3px; align-items: center; }
.grid-label { color: var(--text); font-size: 13px; white-space: nowrap; padding-right: 6px; }
.grid-head { color: var(--muted); font-size: 10px; text-align: center; white-space: nowrap; position: relative; }
.grid-head .fam { position: absolute; left: 0; bottom: 14px; }
.px { width: 100%; aspect-ratio: 1; min-width: 12px; border: 0; border-radius: 2px; cursor: pointer; padding: 0; outline: 2px solid transparent; outline-offset: 1px; }
.px:focus-visible { outline-color: var(--muted); }
.px.sel { outline-color: #ffffff; }
.o-say_do { background: var(--say); } .o-say_only { background: var(--say-only); }
.o-do_only { background: var(--do-only); } .o-neither { background: var(--none); }
.grid-wrap { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-start; }
.legend { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text); }
.legend-title { font-weight: 600; margin-bottom: 2px; }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: 8px; vertical-align: -2px; background: var(--c); }
.excluded { margin: 10px 0 0; padding: 8px 12px; border: 1px solid #f87171; border-left-width: 4px; border-radius: 4px; color: var(--text); background: rgba(248, 113, 113, .08); }
.excluded p { margin: 0; }
.excluded b { color: #fca5a5; }

/* replay */
.scene svg { width: 100%; height: auto; display: block; }
.controls { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.controls button { background: var(--line); color: var(--text); border: 1px solid var(--muted); border-radius: 4px; padding: 5px 12px; cursor: pointer; font: inherit; }
.slider-wrap { position: relative; flex: 1; height: 24px; }
.slider-wrap input { position: absolute; inset: 0; width: 100%; margin: 0; background: transparent; accent-color: var(--say-only); }
.track-marks { position: absolute; left: 8px; right: 8px; top: 9px; height: 6px; pointer-events: none; }
.track-marks .win { position: absolute; top: -3px; height: 12px; background: rgba(240, 180, 41, .18); border-radius: 2px; }
.track-marks .mark { position: absolute; top: -5px; width: 2px; height: 16px; background: var(--say-only); }
.round-label { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 86px; text-align: right; }
.mole { transition: transform .45s cubic-bezier(.2, 1.4, .4, 1); }
.ray { stroke-dasharray: 6 5; animation: dash 1s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -22; } }

/* inspector */
.headline { font-size: 16px; margin: 0 0 10px; }
.chips { display: flex; gap: 8px; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
.chip.yes { border-color: var(--say); color: var(--say); }
.chip.no { color: var(--muted); }
.kv { margin: 0 0 10px; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 2px 0 8px; }
.offer { background: var(--bg); border-left: 3px solid var(--say-only); padding: 6px 10px; border-radius: 0 4px 4px 0; }
.defs { color: var(--text); font-size: 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 6px 10px; margin-bottom: 12px; }
.defs p { margin: 4px 0; }
.defs b { color: var(--say); }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; cursor: pointer; text-align: left; color: inherit; font: inherit; }
.card:hover, .card:focus-visible { border-color: var(--muted); }
.card .name { font-weight: 600; margin-bottom: 6px; }
.card .row { display: flex; justify-content: space-between; align-items: baseline; }
.card .big { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .lbl { color: var(--muted); font-size: 11px; }
.ci { position: relative; height: 8px; background: var(--line); border-radius: 4px; margin: 3px 0 8px; }
.ci .seg { position: absolute; top: 0; height: 8px; border-radius: 4px; opacity: .45; }
.ci .dot { position: absolute; top: -2px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; border: 2px solid var(--bg); }
.strip { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 4px; }
.strip i { width: 9px; height: 9px; border-radius: 1px; display: inline-block; }
.card .n { color: var(--muted); font-size: 11px; margin-top: 4px; }

/* chart */
.chart { min-height: 220px; }
.chart svg { width: 100%; height: auto; display: block; }
.tooltip { position: fixed; pointer-events: none; background: #0d0f12; border: 1px solid var(--line); color: var(--text); padding: 5px 8px; border-radius: 4px; font-size: 12px; z-index: 10; }
.foot { color: var(--muted); font-size: 12px; padding: 4px 20px 20px; }

@media (max-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding: 12px 16px; }
  .panel.wide:nth-of-type(4), .panel.wide:nth-of-type(5) { grid-column: auto; }
  .banner { margin: 8px 16px 0; }
}
@media (prefers-reduced-motion: reduce) {
  .mole, .ray { transition: none; animation: none; }
}

/* ===== story mode (default view of index.html) and full mode (#full) ===== */
body.mode-story .full-only { display: none !important; }
body.mode-full .story-only { display: none !important; }
.story-back { margin-left: 10px; font: inherit; font-size: 13px; background: var(--line); color: var(--text); border: 1px solid var(--muted); border-radius: 4px; padding: 3px 10px; cursor: pointer; vertical-align: middle; }
.story { max-width: 1100px; margin: 0 auto; padding: 8px 20px 4px; font-size: 18px; }
.story-headline { font-size: 24px; line-height: 1.35; font-weight: 600; margin: 6px 0 12px; }
.story-stage { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.story-scene svg { width: 100%; height: auto; display: block; max-height: 52vh; }
.story-caption { font-size: 20px; line-height: 1.4; margin: 8px 2px 4px; min-height: 3.2em; }
.story-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.story-controls button { font: inherit; cursor: pointer; border-radius: 6px; }
.story-play { font-size: 20px; font-weight: 700; padding: 10px 22px; background: var(--say); color: #0b0d10; border: 0; }
.story-nav { font-size: 20px; padding: 8px 14px; background: var(--line); color: var(--text); border: 1px solid var(--muted); }
.story-explore { margin-left: auto; font-size: 16px; padding: 9px 16px; background: transparent; color: var(--text); border: 1px solid var(--muted); }
.story-step { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 8em; }
.story-keys { color: var(--muted); font-size: 13px; margin: 8px 2px 0; }
.story-compare { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px 18px; }
.story-compare-title { font-size: 16px; color: var(--muted); margin: 0 0 10px; }
.story-bars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.scond h3 { margin: 0 0 10px; font-size: 20px; }
.snote { color: var(--muted); font-size: 15px; margin: 0 0 12px; min-height: 2.4em; }
.sbar { display: grid; grid-template-columns: 1fr; gap: 4px; margin-bottom: 12px; }
.sbar-label { font-size: 15px; }
.sbar-track { display: block; height: 22px; background: var(--line); border-radius: 4px; overflow: hidden; }
.sbar-fill { display: block; height: 100%; border-radius: 4px; transition: width .6s ease; }
.sbar-val { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.story-lesson { font-size: 20px; font-weight: 600; margin: 8px 0 0; }
.excluded details summary { cursor: pointer; }
@media (max-width: 700px) {
  .story { padding: 6px 14px 4px; font-size: 16px; }
  .story-headline { font-size: 18px; }
  .story-caption { font-size: 16px; min-height: 4.5em; }
  .story-bars { grid-template-columns: 1fr; }
  .story-explore { margin-left: 0; }
  .story-play { font-size: 18px; padding: 9px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .sbar-fill { transition: none; }
}
@media (max-height: 820px) and (min-width: 701px) {
  .story-headline { font-size: 20px; margin: 4px 0 8px; }
  .story-scene svg { max-height: 36vh; }
  .story-caption { font-size: 18px; min-height: 2.8em; }
  .story-controls { margin-top: 8px; }
}
