/* BriefExchange — styles. Tokens per the shared build spec; chart colours per the dataviz palette. */

/* ------------------------------------------------------------------ tokens */

:root {
  color-scheme: light;

  --bg: #fafafa;
  --surface: #ffffff;
  /* #f7f8fa, not darker: muted text (#6b7280) must clear 4.5:1 on it (4.55). */
  --surface-2: #f7f8fa;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e5e7eb;

  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-ink: #ffffff;
  --accent-wash: #eff4ff;

  /* categorical series (dataviz palette, validated on #ffffff) */
  --series-1: #2563eb;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;

  /* ordinal ramp — one hue, light to dark (validated on #ffffff) */
  --ord-1: #86b6ef;
  --ord-2: #5598e7;
  --ord-3: #2a78d6;
  --ord-4: #1c5cab;
  --ord-5: #0d366b;

  /* meter track: a lighter step of the same ramp */
  --meter-track: #dbe7fa;

  --grid: #e9eaee;
  --axis: #cdd0d8;

  --good: #0ca30c;
  --good-ink: #0a6b12;
  --good-wash: #e8f6ea;
  --warn-ink: #8a5a00;
  --warn-wash: #fdf3dd;
  --crit-ink: #a52d2d;
  --crit-wash: #fbecec;

  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .07);
  --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);

  --r-card: 8px;
  --r-ctl: 6px;

  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;
  --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #111318;
  --surface: #1b1e26;
  --surface-2: #232733;
  --text: #e8eaf0;
  --muted: #9aa1ad;
  --border: #2a2f3a;

  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-ink: #10131a;
  --accent-wash: #1c2942;

  /* categorical series stepped for the dark surface (validated on #1b1e26) */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;

  /* ordinal ramp for the dark surface */
  --ord-1: #b7d3f6;
  --ord-2: #86b6ef;
  --ord-3: #5598e7;
  --ord-4: #2a78d6;
  --ord-5: #184f95;

  --meter-track: #26374f;

  --grid: #262b36;
  --axis: #39404e;

  --good: #0ca30c;
  --good-ink: #57d05a;
  --good-wash: #16301c;
  --warn-ink: #e5b45a;
  --warn-wash: #33291a;
  --crit-ink: #f09393;
  --crit-wash: #35211f;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
}

/* ------------------------------------------------------------------ base */

* { box-sizing: border-box; }

/* Author-level so it beats component rules that set display (.slideover, .response-detail). */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  overflow-x: clip;
}

h1, h2, h3 { line-height: 1.25; margin: 0; font-weight: 640; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0; }

a { color: var(--accent-strong); }
[data-theme="dark"] a { color: var(--accent); }

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: var(--r-ctl);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 60;
  background: var(--surface); color: var(--text);
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-ctl);
}
.skip-link:focus { top: 8px; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 var(--sp-5); }

/* ------------------------------------------------------------------ header */

.app-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px; margin: 0 auto; padding: var(--sp-3) var(--sp-5);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.brand-mark { color: var(--accent); display: flex; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.wordmark { font-size: 1.125rem; font-weight: 700; color: var(--accent); letter-spacing: -.02em; }
.tagline { font-size: .8125rem; color: var(--muted); }

.header-controls { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }

.segmented {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-ctl);
}
.seg-btn {
  font: inherit; font-size: .875rem; font-weight: 560;
  min-height: 40px; padding: 0 var(--sp-3);
  border: 0; border-radius: 4px; background: transparent; color: var(--muted);
  cursor: pointer; white-space: nowrap;
  transition: background 160ms ease, color 160ms ease;
}
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] {
  background: var(--accent); color: var(--accent-ink);
}

.icon-btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font: inherit; font-size: .875rem; font-weight: 560;
  min-height: 44px; padding: 0 var(--sp-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}
.icon-btn:hover { background: var(--surface-2); }
.theme-icon { display: flex; color: var(--muted); }
.i-moon { display: none; }
[data-theme="dark"] .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: block; }

/* tabs */

.tabs-wrap {
  max-width: 1200px; margin: 0 auto; padding: 0 var(--sp-5);
  overflow-x: auto; scrollbar-width: thin;
}
.tabs { display: flex; gap: var(--sp-1); }
.tab {
  font: inherit; font-size: .9375rem; font-weight: 560;
  min-height: 44px; padding: 0 var(--sp-3);
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); cursor: pointer; white-space: nowrap;
  transition: color 160ms ease, border-color 160ms ease;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--accent-strong); border-bottom-color: var(--accent); }
[data-theme="dark"] .tab[aria-selected="true"] { color: var(--accent); }

/* ------------------------------------------------------------------ panels */

.panel { padding: var(--sp-6) 0 var(--sp-7); }
.panel:focus { outline: none; }
.panel-head { margin-bottom: var(--sp-5); max-width: 78ch; }
.lede { color: var(--muted); margin-top: var(--sp-2); }
.section-title { margin: var(--sp-6) 0 var(--sp-3); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--sp-5);
}

.banner {
  display: flex; flex-direction: column; gap: var(--sp-1);
  background: var(--accent-wash);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--r-card);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-5);
}
.banner strong { font-size: .9375rem; }
.banner span { font-size: .875rem; color: var(--muted); }

/* ------------------------------------------------------------------ stat tiles */

.stat-row {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: var(--sp-5);
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); padding: var(--sp-4);
}
.stat-label { font-size: .8125rem; color: var(--muted); }
.stat-value { font-size: 1.75rem; font-weight: 660; margin-top: 2px; letter-spacing: -.02em; }
.stat-note { font-size: .8125rem; color: var(--muted); margin-top: 2px; }
.stat-note.up { color: var(--good-ink); }

/* ------------------------------------------------------------------ filters */

.filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.field { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.field.grow { flex: 1 1 220px; }
.field.block { display: flex; }
.field label, .switch-text { font-size: .8125rem; font-weight: 560; color: var(--muted); }

select, input[type="text"], input[type="search"], textarea {
  font: inherit; font-size: .9375rem;
  min-height: 40px; padding: var(--sp-2) var(--sp-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  width: 100%;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
select { cursor: pointer; }

.reset-link, .linkish {
  font: inherit; font-size: .875rem; font-weight: 560;
  background: none; border: 0; color: var(--accent-strong);
  cursor: pointer; padding: var(--sp-2) var(--sp-1); min-height: 40px;
  text-decoration: underline; text-underline-offset: 3px;
}
[data-theme="dark"] .reset-link, [data-theme="dark"] .linkish { color: var(--accent); }

/* ------------------------------------------------------------------ tables */

.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); overflow-x: auto;
}
.table-wrap.tight { margin-top: var(--sp-3); }

.data-table {
  width: 100%; border-collapse: collapse; font-size: .9375rem;
  font-variant-numeric: tabular-nums; min-width: 720px;
}
.data-table th, .data-table td {
  text-align: left; padding: var(--sp-3); border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  padding: 0; white-space: nowrap;
}
.data-table thead th button {
  font: inherit; font-size: .8125rem; font-weight: 620; color: var(--muted);
  background: none; border: 0; cursor: pointer;
  width: 100%; text-align: left; padding: var(--sp-3);
  min-height: 40px; display: flex; align-items: center; gap: var(--sp-1);
}
.data-table thead th.col-num button { justify-content: flex-end; }
.data-table thead th button:hover { color: var(--text); }
.data-table thead th[aria-sort] button { color: var(--accent-strong); }
[data-theme="dark"] .data-table thead th[aria-sort] button { color: var(--accent); }
.sort-arrow { font-size: .75rem; }

.data-table tbody tr { cursor: default; }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: var(--surface-2); }
.data-table tbody tr.clickable:focus-within { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tfoot td {
  font-weight: 620; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0;
}
.col-num, td.col-num { text-align: right; }
.col-wide { min-width: 240px; }
.cell-strong { font-weight: 560; }
.cell-sub { display: block; font-size: .8125rem; color: var(--muted); margin-top: 2px; }
.cell-nowrap { white-space: nowrap; }

.row-btn {
  font: inherit; background: none; border: 0; padding: 0; color: inherit;
  cursor: pointer; text-align: left; font-weight: 560;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--border);
}
.row-btn:hover { text-decoration-color: var(--accent); }

.empty-state {
  padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--muted);
}

/* meter (match score) */

.meter { display: flex; align-items: center; gap: var(--sp-2); justify-content: flex-end; }
.meter-track {
  width: 76px; height: 8px; border-radius: 4px; background: var(--meter-track); overflow: hidden; flex: none;
}
.meter-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.meter-value { font-weight: 620; min-width: 2.2em; }

/* badges */

.badge {
  display: inline-block; font-size: .75rem; font-weight: 620;
  padding: 2px var(--sp-2); border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
  white-space: nowrap;
}
.badge.ok { background: var(--accent-wash); color: var(--accent-strong); border-color: transparent; }
[data-theme="dark"] .badge.ok { color: var(--accent); }
.badge.warn { background: var(--warn-wash); color: var(--warn-ink); border-color: transparent; }
.badge.crit { background: var(--crit-wash); color: var(--crit-ink); border-color: transparent; }
.badge.good { background: var(--good-wash); color: var(--good-ink); border-color: transparent; }

/* ------------------------------------------------------------------ charts */

.chart-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
}
.chart-card { margin: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.chart-card figcaption { display: flex; flex-direction: column; gap: var(--sp-1); }
.chart-sub { font-size: .8125rem; color: var(--muted); }
/* Charts keep a floor width and scroll inside their own card on narrow screens,
   so SVG text never shrinks below legibility and the page body never scrolls sideways. */
.chart-host { width: 100%; overflow-x: auto; }
.chart-host svg { display: block; width: 100%; min-width: 460px; height: auto; }

.ax-line { stroke: var(--axis); stroke-width: 1; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.ax-text { fill: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.ax-title { fill: var(--muted); font-size: 12px; font-weight: 620; }
.mark-label { fill: var(--text); font-size: 14px; font-weight: 620; font-variant-numeric: tabular-nums; }
.mark-sub { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.fn-1 { fill: var(--ord-1); }
.fn-2 { fill: var(--ord-2); }
.fn-3 { fill: var(--ord-3); }
.fn-4 { fill: var(--ord-4); }
.fn-5 { fill: var(--ord-5); }
.fn-bar { transition: opacity 160ms ease; }
.fn-hit { fill: transparent; cursor: pointer; }
/* box-shadow does not paint on SVG elements, so focus gets a real outline here. */
.fn-hit:focus-visible { box-shadow: none; outline: 2px solid var(--accent); outline-offset: -3px; }
.fn-row:hover .fn-bar, .fn-row:focus-within .fn-bar { opacity: .78; }

.sr-1 { stroke: var(--series-1); }
.sr-2 { stroke: var(--series-2); }
.sr-3 { stroke: var(--series-3); }
.sr-4 { stroke: var(--series-4); }
.sr-5 { stroke: var(--series-5); }
.dot-1 { fill: var(--series-1); }
.dot-2 { fill: var(--series-2); }
.dot-3 { fill: var(--series-3); }
.dot-4 { fill: var(--series-4); }
.dot-5 { fill: var(--series-5); }

.line-mark { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dot-ring { stroke: var(--surface); stroke-width: 2; }
.crosshair { stroke: var(--axis); stroke-width: 1; }
.week-hit { fill: transparent; }

.legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); }
.legend-item { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: .8125rem; color: var(--muted); }
.legend-key { width: 14px; height: 3px; border-radius: 2px; flex: none; }
.legend-total { font-weight: 620; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-actions { display: flex; }

/* ------------------------------------------------------------------ slide-over */

.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(12, 15, 22, .45);
}

.slideover {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51;
  width: min(560px, 100%);
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  animation: slide-in 180ms ease;
}
@keyframes slide-in { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.slideover-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border);
}
.slideover-eyebrow { font-size: .75rem; font-weight: 620; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.close-btn { min-width: 40px; justify-content: center; padding: 0 var(--sp-2); }
.slideover-body { padding: var(--sp-5); overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-5); }

.so-section > h3 { font-size: .8125rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: var(--sp-2); }
.so-text { font-size: .9375rem; }
.so-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }
.so-meta div { display: flex; flex-direction: column; gap: 2px; }
.so-meta dt, .so-meta .k { font-size: .75rem; color: var(--muted); }
.so-meta .v { font-weight: 560; font-size: .9375rem; }

.cred-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.cred {
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  padding: var(--sp-3); background: var(--surface-2);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
.cred-id { font-size: .75rem; font-weight: 620; color: var(--muted); font-variant-numeric: tabular-nums; }
.cred-title { font-size: .875rem; }
.cred-tags { display: flex; flex-wrap: wrap; gap: var(--sp-1); }

.so-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.btn {
  font: inherit; font-size: .9375rem; font-weight: 560;
  min-height: 40px; padding: 0 var(--sp-4);
  border-radius: var(--r-ctl); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  transition: background 160ms ease, border-color 160ms ease;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-ghost { background: transparent; }

.back-link {
  font: inherit; font-size: .875rem; font-weight: 560; background: none; border: 0;
  color: var(--accent-strong); cursor: pointer; padding: var(--sp-2) 0; min-height: 40px;
  display: inline-flex; align-items: center; gap: var(--sp-1);
}
[data-theme="dark"] .back-link { color: var(--accent); }

.doc {
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  background: var(--surface-2); padding: var(--sp-4);
  display: flex; flex-direction: column; gap: var(--sp-4);
}
.doc-kicker { font-size: .75rem; font-weight: 620; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-strong); }
[data-theme="dark"] .doc-kicker { color: var(--accent); }
.doc h4 { margin: 0; font-size: .9375rem; font-weight: 640; }
.doc-block { display: flex; flex-direction: column; gap: var(--sp-2); }
.doc-block ul { margin: 0; padding-left: 1.15rem; display: flex; flex-direction: column; gap: var(--sp-1); }
.doc-block li { font-size: .875rem; }
.doc-note { font-size: .8125rem; color: var(--muted); font-style: italic; }

/* ------------------------------------------------------------------ forms */

.two-col { display: grid; gap: var(--sp-4); grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.form-card { display: flex; flex-direction: column; gap: var(--sp-4); }
.field-row { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.field-error { font-size: .8125rem; color: var(--crit-ink); font-weight: 560; }
.form-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.switch-row { display: flex; flex-direction: column; gap: var(--sp-1); }
.switch { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; min-height: 40px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  width: 40px; height: 22px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); display: inline-flex; align-items: center; padding: 2px; flex: none;
  transition: background 160ms ease, border-color 160ms ease;
}
.switch-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(18px); background: var(--accent-ink); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }
.hint { font-size: .8125rem; color: var(--muted); }

.side-card { display: flex; flex-direction: column; gap: var(--sp-3); }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.steps li { display: flex; gap: var(--sp-3); font-size: .875rem; }
.steps span {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-wash); color: var(--accent-strong);
  font-size: .75rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
[data-theme="dark"] .steps span { color: var(--accent); }
.footnote { font-size: .8125rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: var(--sp-3); }

/* ------------------------------------------------------------------ responses */

.brief-header { display: flex; flex-direction: column; gap: var(--sp-3); }
.brief-header .brief-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }

.response-list { display: flex; flex-direction: column; gap: var(--sp-3); }
.response {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card);
}
.response.top { border-color: var(--accent); }
.response-summary {
  width: 100%; font: inherit; text-align: left; background: none; border: 0; cursor: pointer;
  padding: var(--sp-4); display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap;
  color: inherit;
}
.response-summary:hover { background: var(--surface-2); border-radius: var(--r-card); }
.response-rank { font-size: .8125rem; font-weight: 700; color: var(--muted); flex: none; width: 1.6em; }
.response-firm { font-weight: 620; flex: 1 1 180px; min-width: 0; }
.response-fig { font-variant-numeric: tabular-nums; font-size: .9375rem; }
.response-fig .k { display: block; font-size: .75rem; color: var(--muted); font-variant-numeric: normal; }
.chev { flex: none; color: var(--muted); transition: transform 160ms ease; }
.response-summary[aria-expanded="true"] .chev { transform: rotate(180deg); }
.response-detail {
  padding: 0 var(--sp-4) var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3);
  border-top: 1px solid var(--border); padding-top: var(--sp-4);
}
.cite-list { margin: 0; padding-left: 1.15rem; display: flex; flex-direction: column; gap: var(--sp-2); }
.cite-list li { font-size: .875rem; }

/* ------------------------------------------------------------------ prose / about */

.prose { display: flex; flex-direction: column; gap: var(--sp-3); max-width: 78ch; }
.prose h2 { font-size: 1rem; margin-top: var(--sp-3); }
.prose h2:first-child { margin-top: 0; }
.prose p { color: var(--text); }

.play-map { margin-top: var(--sp-4); max-width: 78ch; }
.roll-up { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.roll-up li { display: flex; gap: var(--sp-3); align-items: flex-start; }
.roll-tag {
  flex: none; width: 108px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--accent-strong); padding-top: 3px;
}
[data-theme="dark"] .roll-tag { color: var(--accent); }
.roll-tag.second { color: var(--muted); }
.roll-body { font-size: .9375rem; }
.roll-body em { color: var(--muted); font-style: normal; font-size: .8125rem; display: block; margin-top: 2px; }

/* ------------------------------------------------------------------ tooltip / toast */

.tooltip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-ctl);
  box-shadow: var(--shadow);
  padding: var(--sp-2) var(--sp-3); font-size: .8125rem; max-width: 260px;
  font-variant-numeric: tabular-nums;
}
.tooltip .tt-title { font-weight: 620; margin-bottom: 2px; }
.tooltip .tt-row { display: flex; align-items: center; gap: var(--sp-2); justify-content: space-between; }
.tooltip .tt-key { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.tooltip .tt-swatch { width: 10px; height: 3px; border-radius: 2px; flex: none; }
.tooltip .tt-val { font-weight: 620; }

.toast-stack {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 60; display: flex; flex-direction: column; gap: var(--sp-2); width: min(420px, calc(100vw - 32px));
}
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--good);
  border-radius: var(--r-card); box-shadow: var(--shadow);
  padding: var(--sp-3) var(--sp-4); font-size: .875rem;
  animation: toast-in 180ms ease;
}
.toast strong { display: block; }
.toast span { color: var(--muted); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------------ footer */

.app-footer { border-top: 1px solid var(--border); background: var(--surface); }
.footer-inner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  flex-wrap: wrap; padding-top: var(--sp-4); padding-bottom: var(--sp-4);
  font-size: .875rem; color: var(--muted);
}

/* ------------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .two-col { grid-template-columns: minmax(0, 1fr); }
  .chart-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .container, .header-inner, .tabs-wrap { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .header-inner { padding-top: var(--sp-2); padding-bottom: var(--sp-2); gap: var(--sp-2); }
  .header-controls { width: 100%; justify-content: space-between; }
  .segmented { flex: 1 1 auto; }
  .seg-btn { flex: 1 1 auto; font-size: .8125rem; padding: 0 var(--sp-2); }
  .tagline { display: none; }
  h1 { font-size: 1.3125rem; }
  .panel { padding-top: var(--sp-5); }
  .stat-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .stat-value { font-size: 1.5rem; }
  .slideover { width: 100%; border-left: 0; }
  .roll-up li { flex-direction: column; gap: var(--sp-1); }
  .roll-tag { width: auto; }
  .response-summary { gap: var(--sp-3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .app-header, .app-footer, .filter-bar, .chart-actions { display: none; }
}
