/* ======================================================================
   Virtual Trading Platform — follows the lying project's color system
   (Modern Scientific Dashboard). Light theme by default with a
   [data-theme="dark"] override; [data-theme="auto"] tracks
   prefers-color-scheme. Domain aliases (--fv, --bubble, --volume,
   --bid, --ask, --hold) point at the base palette so every theme
   toggle flows through the existing rules automatically.
   ====================================================================== */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg-0: #fafbfc; --bg-1: #ffffff; --bg-2: #f4f5f7; --bg-3: #e8eaed;
  --fg-0: #1a1d23; --fg-1: #3d4250; --fg-2: #6b7080; --fg-3: #9aa0ad;
  --border: #dfe1e6;
  --accent: #2563eb; --accent-light: #dbeafe; --accent-dark: #1d4ed8;
  --red: #dc2626; --red-bg: #fef2f2;
  --green: #16a34a; --green-bg: #f0fdf4;
  --amber: #d97706; --amber-bg: #fffbeb;
  --blue: #2563eb; --blue-bg: #eff6ff;
  --purple: #7c3aed; --purple-bg: #f5f3ff;
  --teal: #0d9488; --teal-bg: #f0fdfa;
  --pink: #db2777; --pink-bg: #fdf2f8;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.07);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.09);
  --radius: 10px; --radius-sm: 6px; --radius-lg: 14px;
  --ease: cubic-bezier(.4,0,.2,1);
  /* One font stack for the entire UI. Tabular numerics are enabled
     per-rule via font-variant-numeric so columns stay aligned without
     needing a monospace fallback. */
  --font-ui: 'Helvetica Neue', Helvetica, Arial, sans-serif;

  /* Domain aliases — every rule in the rest of the file reads these,
     so a theme switch only needs to change the base tokens above. */
  --fv:      var(--amber);
  --bubble:  var(--red);
  --volume:  var(--green);
  --bid:     var(--green);
  --ask:     var(--red);
  --hold:    var(--fg-3);

  /* Chart scrims — read by the canvas renderers via getComputedStyle
     so gridlines / alternate-row stripes / period bands adapt to the
     active theme. Keep these as baseline-on-transparent rgba values. */
  --chart-grid:   rgba(0,0,0,0.06);
  --chart-stripe: rgba(0,0,0,0.025);
  --chart-band:   rgba(0,0,0,0.022);
  --chart-frame:  #c6cad1;
}
[data-theme="dark"] {
  --bg-0: #0d1117; --bg-1: #161b22; --bg-2: #1c2129; --bg-3: #272d38;
  --fg-0: #e6edf3; --fg-1: #c9d1d9; --fg-2: #8b949e; --fg-3: #6e7681;
  --border: #30363d;
  --accent-light: #1e3a5f;
  --red-bg: #2d1b1b; --green-bg: #1a2e1a; --amber-bg: #2d2614;
  --blue-bg: #1a2540; --purple-bg: #231a35; --teal-bg: #142925;
  --pink-bg: #2b1524;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 14px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.4);
  --chart-grid:   rgba(255,255,255,0.06);
  --chart-stripe: rgba(255,255,255,0.025);
  --chart-band:   rgba(255,255,255,0.022);
  --chart-frame:  #2a3344;
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --bg-0: #0d1117; --bg-1: #161b22; --bg-2: #1c2129; --bg-3: #272d38;
    --fg-0: #e6edf3; --fg-1: #c9d1d9; --fg-2: #8b949e; --fg-3: #6e7681;
    --border: #30363d;
    --accent-light: #1e3a5f;
    --red-bg: #2d1b1b; --green-bg: #1a2e1a; --amber-bg: #2d2614;
    --blue-bg: #1a2540; --purple-bg: #231a35; --teal-bg: #142925;
    --pink-bg: #2b1524;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 14px rgba(0,0,0,.35);
    --shadow-lg: 0 8px 28px rgba(0,0,0,.4);
    --chart-grid:   rgba(255,255,255,0.06);
    --chart-stripe: rgba(255,255,255,0.025);
    --chart-band:   rgba(255,255,255,0.022);
    --chart-frame:  #2a3344;
  }
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--fg-0);
  font-family: var(--font-ui);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; }

h1, h2, h3 { margin: 0; font-weight: 600; }
.muted { color: var(--fg-2); }

/* ---------- Math (native MathML) ----------
   Every mathematical symbol in the UI flows through js/mathml.js and
   renders as a <math> element so the browser's native MathML engine
   handles sub/sup layout, script sizing, and math-font glyph
   selection. Defining a single math { ... } rule here guarantees the
   same symbol looks identical on the agent cards, in the notes, in
   the figure equation strips, in the table, and anywhere else a
   Sym.* lookup is embedded. Context-specific rules elsewhere only
   adjust the font-size; never the sub/sup geometry. */
math {
  font-family: "STIX Two Math", "Latin Modern Math", "Cambria Math",
               "TeX Gyre Termes Math", "XITS Math", "STIX",
               "Iowan Old Style", "Palatino Linotype", Palatino,
               "Georgia", "Times New Roman", serif;
  font-size: 1em;
  font-style: normal;
  color: inherit;
  vertical-align: baseline;
}
math[display="inline"] { white-space: nowrap; }

/* ---------- Header ---------- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.title h1   {
  font-size: 18px;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--accent), var(--red));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.title .subtitle {
  display: block;
  color: var(--fg-2);
  font-size: 11px;
  margin-top: 2px;
}

/*
 * Nav tabs — top-level view selector sitting between .title and the
 * paradigm switch. Modelled on the lying project's .nav-tab pattern:
 * text-only buttons that turn accent-coloured when active, with a
 * 2px bottom border used as the active indicator. The non-active
 * bottom border is transparent but reserved so tab activation does
 * not shift the header baseline. main.js toggles .active on click
 * and on .tab-pane at the same time.
 */
.nav-tabs {
  display: flex;
  gap: 4px;
}
.nav-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 12px 7px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-2);
  cursor: pointer;
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.nav-tab:hover { color: var(--fg-0); }
.nav-tab.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom-color: var(--accent);
}
.nav-tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
  border-radius: 2px;
}

/* Tab panes — only the .active pane is rendered. Each pane is a
   top-level section below the header and owns its own layout. */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/*
 * Paradigm switch — segmented two-button control between .title and
 * .controls. Adopts the visual language of the lying project's
 * Math / AI Agent toggle: a rounded bg-2 rail with 2px inner padding,
 * transparent inactive buttons in fg-3, and an elevated active
 * button using bg-1 + a subtle shadow. Clicking swaps between the
 * DLM 2005 (E-heavy) and Lopez-Lira 2025 (U-heavy) population
 * presets; main.js keeps the .active class in sync with App.paradigm.
 */
.paradigm-switch {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}
.paradigm-btn {
  appearance: none;
  background: transparent;
  color: var(--fg-3);
  border: 0;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 999px;
  transition: background 0.18s var(--ease),
              color 0.18s var(--ease),
              box-shadow 0.18s var(--ease);
}
.paradigm-btn:hover {
  color: var(--fg-0);
}
.paradigm-btn.active {
  background: var(--bg-1);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.paradigm-btn.active:hover { color: var(--accent); }
.paradigm-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
}

.controls { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.controls label {
  color: var(--fg-2);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.controls select,
.controls input[type=number],
.controls input[type=range] {
  background: var(--bg-2);
  color: var(--fg-0);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12px;
  min-width: 80px;
}
.controls input[type=range] { padding: 0 4px; min-width: 130px; }
.controls button {
  background: var(--bg-2);
  color: var(--fg-0);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, transform 0.05s;
}
.controls button:hover { background: var(--bg-3); border-color: var(--accent); }
.controls button:active { transform: translateY(1px); }
.controls button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.controls button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.controls .theme-btn {
  width: 32px; height: 32px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: min-content;
  gap: 14px;
  padding: 16px 20px 40px;
  max-width: 1600px;
  margin: 0 auto;
}

.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: var(--shadow-md);
  min-width: 0;
  overflow: hidden;
}
.panel h2 {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-2);
  margin-bottom: 10px;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
}
.panel h2 .math {
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg-3);
}
.panel h2 .math em { font-style: italic; color: var(--fg-2); }
.panel h3 {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-2);
  margin: 10px 0 6px;
}

/* =============================================================
   Figure cards — academic-paper layout for every chart panel.

   Layout contract (top → bottom, all fixed vertical rhythm so
   figures sitting in the same grid row align at every block):

     .fig-head       numbered title, 40px tall, bottom hairline
     .fig-eq         display equation, 44px tall, left-rule block
     canvas          the chart, height driven by .chart-* rules
     .fig-caption    prose caption, grows to fill remaining space
       .fig-note     "Note" header + dl glossary pinned to card bottom

   Math typography is delegated to the browser's native MathML engine
   (see js/mathml.js); the figure-level CSS only sizes the <math> glyphs.
   ============================================================= */
.panel.figure {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 18px;
}
.panel.figure > h2 { display: none; } /* legacy h2 suppressed */

.panel.figure .fig-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  min-height: 22px;
}
.panel.figure .fig-num {
  font-size: 10px;
  font-style: italic;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  flex-shrink: 0;
}
.panel.figure .fig-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fg-0);
  line-height: 1.35;
  margin: 0;
  text-transform: none;
  display: block;
}

/* --- Display equation block --- */
.panel.figure .fig-eq {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Cambria",
               "Georgia", "Times New Roman", serif;
  font-style: italic;
  font-size: 14px;
  color: var(--fg-0);
  background: var(--bg-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
  padding: 10px 14px;
  line-height: 1.5;
  min-height: 44px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  overflow-x: auto;
}
/* The equation strip itself is just a flex row; all math typography
   (including sub/sup layout and glyph selection) is delegated to the
   browser's native MathML engine via the <math> tags generated from
   js/mathml.js. Only the descriptive <em> caption next to the eq is
   styled here. */
.panel.figure .fig-eq em {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-style: normal;
  color: var(--fg-3);
  font-size: 10.5px;
  letter-spacing: 0.01em;
}
.panel.figure .fig-eq math {
  font-size: 15px;
}

.panel.figure canvas { margin: 0; }

/* --- Legend row (optional, between canvas and caption) --- */
.panel.figure .legend {
  margin-top: 4px;
  margin-bottom: 0;
}

/* --- Figure caption: flex grows to pin symbols to the card bottom --- */
.panel.figure .fig-caption {
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--fg-2);
  margin: 0;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 0 auto;
}
.panel.figure .fig-caption p { margin: 0; }
.panel.figure .fig-caption strong {
  color: var(--fg-1);
  font-weight: 600;
}
.panel.figure .fig-caption em {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Georgia",
               serif;
  font-style: italic;
  color: var(--fg-1);
}

/* --- Note block pinned to figure bottom --- *
 * Single "NOTE" header + dl glossary sitting inside a soft bg-2 card.
 * Shares typographic rules with .panel-agents .agent-notes-list so a
 * symbol reads the same on an agent card as in a figure caption.
 * ------------------------------------------------------------------ */
.panel.figure .fig-note {
  margin: 0;
  margin-top: auto; /* stick to the bottom of the flex figcaption */
  padding: 10px 14px 12px;
  background: var(--bg-2);
  border-radius: 4px;
  border-left: 2px solid var(--border);
}
.panel.figure .fig-note-title {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.panel.figure .fig-note-list {
  display: grid;
  grid-template-columns: minmax(56px, max-content) 1fr;
  gap: 6px 16px;
  margin: 0;
  font-size: 11px;
  line-height: 1.55;
  color: var(--fg-3);
}
.panel.figure .fig-note-list dt {
  color: var(--fg-1);
  white-space: nowrap;
  text-align: right;
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
}
.panel.figure .fig-note-list dd {
  margin: 0;
  color: var(--fg-3);
}
.panel.figure .fig-note-list dd em {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Georgia",
               serif;
  font-style: italic;
  color: var(--fg-1);
}

/* ---------- Column spans ---------- */
.panel-params   { grid-column: span 12; }
.panel-stats    { grid-column: span 12; display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.chart-price    { grid-column: span 8; }
.panel-book     { grid-column: span 4; }
.chart-bubble   { grid-column: span 4; }
.chart-volume   { grid-column: span 4; }
.chart-heatmap  { grid-column: span 4; }
.chart-timeline { grid-column: span 12; }
.panel-agents   { grid-column: span 8; }
.panel-feed     { grid-column: span 4; }
.panel-replay   { grid-column: span 12; }

/* Extended panels (utility experiment mode) */
.chart-valuation { grid-column: span 8; }
.panel-metrics   { grid-column: span 4; }
.chart-utility   { grid-column: span 6; }
.chart-ownership { grid-column: span 6; }
.chart-messages  { grid-column: span 8; }
.chart-trust     { grid-column: span 4; }

/* Hide the extended cluster unless body.extended is set by main.js */
body:not(.extended) .ext-only { display: none !important; }
/* Hide the Experience preferences block unless mix.E > 0. Mirrors the
   .ext-only gate so the U slot and the E slot each control their own
   preference panel and neither becomes visible noise when its slot is
   empty. */
body:not(.has-experienced) .exp-only { display: none !important; }
/* Hide the AIPE AI endpoint psec unless the AIPE paradigm is
   active. Mirrors the .ext-only / .exp-only gates — the AI-config
   fields are meaningless for DLM and Lopez-Lira, so they only
   render when body.wang-mode is set by _setParadigm('wang'). */
body:not(.wang-mode) .wang-only { display: none !important; }

/* ---------- Parameters panel ---------- */
/*
 * Foldable container for every tunable. The header strip toggles
 * .collapsed on the whole panel. Each .psec is a <details> card with
 * a hover-reveal tooltip on its rows (data-tip). Range inputs are
 * fully restyled for Chromium/Firefox parity and draw their filled
 * portion from the --pct custom property that main.js keeps in sync
 * with each slider's value on every input event.
 */
.panel-params { padding-bottom: 18px; }

.panel-params .panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  padding: 4px 2px 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  transition: border-color 0.18s var(--ease);
}
.panel-params .panel-header:hover { border-bottom-color: var(--accent); }
.panel-params .panel-header h2 {
  margin: 0;
  color: var(--fg-0);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.panel-params .panel-header .chevron {
  color: var(--fg-3);
  font-size: 14px;
  line-height: 1;
  transition: transform 0.25s var(--ease), color 0.18s var(--ease);
}
.panel-params .panel-header:hover .chevron { color: var(--accent); }
.panel-params.collapsed .panel-header {
  margin-bottom: 0;
  border-bottom-color: transparent;
  padding-bottom: 4px;
}
.panel-params.collapsed .params-body { display: none; }
.panel-params.collapsed .panel-header .chevron { transform: rotate(-90deg); }

.panel-params .params-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (max-width: 1100px) {
  .panel-params .params-body { grid-template-columns: 1fr; }
}

/* Each section of sliders is its own card. Open sections lift via a
   subtle shadow; focus-within adds an accent ring while the user is
   actively dragging a slider inside. */
.psec {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px 14px;
  transition:
    background 0.18s var(--ease),
    border-color 0.18s var(--ease),
    box-shadow 0.22s var(--ease);
}
.psec:hover { border-color: var(--bg-3); }
.psec[open] {
  background: var(--bg-1);
  border-color: var(--bg-3);
  box-shadow: var(--shadow-sm);
}
.psec:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.psec summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-1);
  transition: color 0.18s var(--ease);
}
.psec:hover summary { color: var(--fg-0); }
.psec summary::marker { display: none; }
.psec summary::-webkit-details-marker { display: none; }
/* Chevron built from a rotated border-square so it renders crisply
   on HiDPI at any font-size without depending on a glyph font. */
.psec summary::before {
  content: '';
  width: 7px;
  height: 7px;
  flex-shrink: 0;
  border-right: 1.5px solid var(--fg-3);
  border-bottom: 1.5px solid var(--fg-3);
  transform: rotate(-45deg) translate(-1px, -1px);
  transition: transform 0.22s var(--ease), border-color 0.18s var(--ease);
}
.psec[open] summary::before {
  transform: rotate(45deg) translate(-1px, -1px);
  border-color: var(--accent);
}
.psec summary .muted {
  margin-left: auto;
  color: var(--fg-3);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}
.psec .psec-body {
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
/* Native <details> collapse: the UA default hides non-summary children
   on :not([open]), but our .psec .psec-body rule above sets display:flex
   with higher specificity and wins — so without this explicit override
   the body stays visible and clicking the summary only toggles the
   chevron. Force display: none when the section is closed. */
.psec:not([open]) > .psec-body { display: none; }

.param-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.param-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.param-head label {
  color: var(--fg-1);
  font-size: 11px;
  font-weight: 500;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.18s var(--ease);
}
.param-row:hover .param-head label,
.param-row:focus-within .param-head label { color: var(--fg-0); }

.param-head .pval {
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 999px;
  min-width: 52px;
  text-align: center;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.param-row:focus-within .param-head .pval {
  background: var(--accent);
  color: #fff;
}

/* Custom range input. --pct is owned by main.js: it reads min/max/value
   and writes a percentage string on every input event so the filled
   portion of the track follows the thumb. Both Chromium and Firefox
   get their own pseudo-elements. */
.param-row input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  outline: none;
  cursor: pointer;
  --pct: 50%;
}
.param-row input[type=range]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--pct),
    var(--bg-3)   var(--pct),
    var(--bg-3)   100%
  );
}
.param-row input[type=range]::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: var(--bg-3);
}
.param-row input[type=range]::-moz-range-progress {
  height: 5px;
  border-radius: 999px;
  background: var(--accent);
}
.param-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg-1);
  border: 2px solid var(--accent);
  margin-top: -5.5px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s var(--ease), box-shadow 0.18s var(--ease);
}
.param-row input[type=range]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg-1);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s var(--ease), box-shadow 0.18s var(--ease);
}
.param-row input[type=range]:hover::-webkit-slider-thumb,
.param-row input[type=range]:focus::-webkit-slider-thumb {
  transform: scale(1.12);
  box-shadow: 0 0 0 6px var(--accent-light);
}
.param-row input[type=range]:hover::-moz-range-thumb,
.param-row input[type=range]:focus::-moz-range-thumb {
  transform: scale(1.12);
  box-shadow: 0 0 0 6px var(--accent-light);
}
.param-row input[type=range]:active::-webkit-slider-thumb {
  transform: scale(1.16);
  box-shadow: 0 0 0 8px var(--accent-light);
}
.param-row input[type=range]:active::-moz-range-thumb {
  transform: scale(1.16);
  box-shadow: 0 0 0 8px var(--accent-light);
}

.param-row .checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--fg-0);
  cursor: pointer;
}
.param-row .checkbox input { accent-color: var(--accent); }

/* Risk-preference composition bar — the three linked sliders push
   their percentages into this segmented bar so the overall risk mix
   is visible at a glance even when the sliders are below the fold. */
.comp-bar {
  display: flex;
  height: 26px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-1);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}
.comp-bar .seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  transition: flex 0.28s var(--ease);
}
.comp-bar .seg span {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.comp-bar .seg-loving  { background: var(--red); }
.comp-bar .seg-neutral { background: var(--fg-3); }
.comp-bar .seg-averse  { background: var(--accent); }
.comp-bar .seg-neutral span { color: var(--fg-0); text-shadow: none; }
/* Experience preferences: same red→grey→blue gradient as risk
   preferences. The bubble-fueling end (naive) reuses --red, the
   bubble-suppressing end (veteran) reuses --accent, and the
   intermediate sits on the neutral grey. */
.comp-bar .seg-naive   { background: var(--red); }
.comp-bar .seg-once    { background: var(--fg-3); }
.comp-bar .seg-veteran { background: var(--accent); }
.comp-bar .seg-once span { color: var(--fg-0); text-shadow: none; }

/*
 * Per-row hover tooltip (pure CSS). The entire .param-row is the hover
 * zone so moving the mouse onto the slider itself is enough to reveal
 * the explanation. The tip floats above the row by default; first-
 * child rows flip below so they don't collide with the section header.
 */
.param-row[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  width: 320px;
  max-width: min(420px, 90vw);
  padding: 12px 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-1);
  font: 11px/1.6 var(--font-ui);
  letter-spacing: normal;
  text-transform: none;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.18s var(--ease), transform 0.18s var(--ease);
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
.param-row[data-tip]:hover::after,
.param-row[data-tip]:focus-within::after {
  opacity: 1;
  transform: translateY(0);
}
.psec-body > .param-row[data-tip]:first-child::after {
  bottom: auto;
  top: calc(100% + 8px);
  transform: translateY(-4px);
}
.psec-body > .param-row[data-tip]:first-child:hover::after,
.psec-body > .param-row[data-tip]:first-child:focus-within::after {
  transform: translateY(0);
}

/* ---------- AI endpoint (AIPE) ---------- */
/*
 * Three-input form inside the .wang-only psec: API key, endpoint
 * override, and model name. Nothing is persisted — main.js reads
 * the fields on every run start and forwards them to AI.call()
 * only when App.paradigm === 'wang' and the key is non-empty.
 * Styling matches the rest of the parameter panel (no range track
 * here, just text inputs that sit in a subtle rail) so the
 * Wang-only block does not break the visual rhythm of the other
 * psec cards. The accent colour is pink to pair with the pink
 * ai.js node in the Architecture diagram.
 */
.ai-config { gap: 10px; }
.ai-config .ai-config-note {
  margin: 0 0 4px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--fg-2);
}
.ai-config .param-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ai-config .param-head label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-2);
}
.ai-config .input-text {
  appearance: none;
  width: 100%;
  background: var(--bg-1);
  color: var(--fg-0);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  font-family: var(--font-ui);
  font-size: 12px;
  transition: border-color 0.18s var(--ease),
              box-shadow 0.18s var(--ease);
}
.ai-config select.input-text {
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-2) 50%),
                    linear-gradient(135deg, var(--fg-2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%,
                       calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 26px;
}
.ai-config .input-text::placeholder { color: var(--fg-3); }
.ai-config .ai-status {
  min-height: 14px;
  font-size: 11px;
  font-style: italic;
  color: var(--pink);
}
.ai-config .ai-status:empty { display: none; }
.ai-config .input-text:hover { border-color: var(--bg-3); }
.ai-config .input-text:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pink) 22%, transparent);
}
.wang-only[open] {
  border-color: var(--pink);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--pink) 28%, transparent),
              var(--shadow-sm);
}
.wang-only summary {
  color: var(--pink);
}
.wang-only summary .muted {
  color: color-mix(in srgb, var(--pink) 70%, var(--fg-3));
}

/* ---------- Constant cards (Paper + Hidden) ---------- */
/*
 * Two read-only psec sections nested inside Experiment settings,
 * sharing the same card layout but distinguished by accent colour:
 *
 *   .const-paper  — design constants pinned by Dufwenberg, Lindqvist
 *                   & Moore (2005) §I (asset life, dividend shape,
 *                   expected dividend, FV formula). Accent: blue.
 *   .const-sim    — discretization + Utility-agent calibration
 *                   constants pinned by this simulator's
 *                   implementation (ticksPerPeriod, N(F/T/R) slots,
 *                   belief weights …). Accent: amber. Default folded.
 *
 * Both render inside a <details class="psec"> so the open/close
 * affordance is handled natively by the existing psec chrome. The
 * shared .const-* class set keeps the layout in one place; the two
 * sections only override the left-border and val colour so the
 * "paper vs implementation" boundary is visually legible.
 */
/* Both constant sections span the full width of the 2-col params-body
   grid — their dense card lists need the width to breathe. */
.panel-params .params-body > .const-paper,
.panel-params .params-body > .const-sim { grid-column: 1 / -1; }
.const-paper .psec-body,
.const-sim   .psec-body { gap: 0; }
.const-paper summary .const-cite,
.const-sim   summary .const-cite {
  margin-left: auto;
  font-size: 10px;
  color: var(--fg-3);
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
}
.const-paper .const-list,
.const-sim   .const-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin: 0;
}
.const-paper .const-item,
.const-sim   .const-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 4px;
  min-width: 0;
}
.const-sim .const-item {
  border-left-color: var(--amber);
}
.const-paper .const-item dt,
.const-sim   .const-item dt {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  color: var(--fg-0);
  font-size: 13px;
  font-weight: 500;
}
.const-paper .const-item dt math,
.const-sim   .const-item dt math {
  font-size: 13px;
}
.const-paper .const-val {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.const-sim .const-val {
  color: var(--amber);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.const-paper .const-label,
.const-sim   .const-label {
  margin: 0;
  font-size: 10px;
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.const-paper .const-note,
.const-sim   .const-note {
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--fg-1);
  font-style: italic;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}
.const-paper .const-src,
.const-sim   .const-src {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  font-style: normal;
  color: var(--fg-3);
  letter-spacing: 0.04em;
}

/* ---------- Stats cells ---------- */
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 0;
}
.stat .label {
  color: var(--fg-2);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.stat .value {
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.stat .value.price  { color: var(--accent); }
.stat .value.fv     { color: var(--fv); }
.stat .value.bubble { color: var(--bubble); }
.stat .value.vol    { color: var(--volume); }

/* ---------- Charts ---------- */
.panel-chart canvas { display: block; width: 100%; height: 240px; }
.chart-bubble canvas,
.chart-volume canvas,
.chart-heatmap canvas { height: 160px; }
.chart-timeline canvas { height: 190px; }
.chart-valuation canvas { height: 220px; }
.chart-utility canvas,
.chart-ownership canvas { height: 200px; }
.chart-messages canvas { height: 200px; }
.chart-trust canvas    { height: 220px; }

/* ---------- Order book ------------------------------------------
 * Mirrors the .panel-feed treatment: the panel is a flex column so
 * the list body can grow to fill whatever height the grid row
 * assigns it (pinned to the sibling .chart-price figure). Bids and
 * asks are two side-by-side lists that each overflow independently,
 * with a dynamic row count computed in renderBook from the measured
 * clientHeight.
 * ---------------------------------------------------------------- */
.panel-book {
  display: flex;
  flex-direction: column;
}
.panel-book > h2 { flex: 0 0 auto; }

.book-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  flex: 1 1 auto;
  min-height: 0;
}
.book-side {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.side-label {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.12em;
  font-weight: 700;
  padding-bottom: 5px;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border);
}
.side-label.bids { color: var(--bid); }
.side-label.asks { color: var(--ask); }

.book-head {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(48px, 1fr) 36px minmax(0, 1.4fr);
  gap: 6px;
  padding: 4px 6px;
  font-size: 10px;
  color: var(--fg-2);
  font-weight: 500;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border);
}

.book-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.book-list li {
  display: grid;
  grid-template-columns: minmax(48px, 1fr) 36px minmax(0, 1.4fr);
  gap: 6px;
  padding: 3px 6px;
  align-items: center;
}
.book-list li:nth-child(odd) { background: var(--bg-2); }
.book-list li .price { font-weight: 600; }
.book-list.bids li .price { color: var(--bid); }
.book-list.asks li .price { color: var(--ask); }
.book-list li .agent {
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.book-list li.empty {
  display: block;
  padding: 8px 6px;
  color: var(--fg-3);
  font-style: italic;
  text-align: center;
}

/* ---------- Agents ---------- */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.agent-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.agent-card .agent-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.agent-card .agent-head-left  { min-width: 0; }
.agent-card .agent-head-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  flex: none;
}
.agent-card .agent-name { font-weight: 600; font-size: 13px; letter-spacing: 0.02em; }
.agent-card .agent-type {
  font-size: 10px;
  color: var(--fg-2);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}
.agent-card .metrics {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  row-gap: 2px;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.agent-card .metric {
  color: var(--fg-2);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 5px;
}
.agent-card .metric-val { color: var(--fg-0); font-weight: 600; text-align: right; }
/* Paper-symbol wrapper. Real math typography (font selection,
   sub/sup sizing, baseline shift) is delegated to the browser's
   native MathML engine — this rule only paints the wrapper a muted
   colour and pins the baseline so the symbol sits next to its
   English label without stretching the row height. */
.agent-card .sym {
  color: var(--fg-3);
  white-space: nowrap;
  display: inline-flex;
  align-items: baseline;
}
.agent-card .sym math { font-size: 11px; }
.agent-card .action-sym { }
.agent-card .action-sym math { font-size: 10px; }
.agent-card .last-action {
  font-size: 9px;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.agent-card .last-action.bid  { color: var(--green); background: var(--green-bg); }
.agent-card .last-action.ask  { color: var(--red);   background: var(--red-bg); }
.agent-card .last-action.hold { color: var(--fg-2);  background: var(--bg-2); }
.agent-card.fundamentalist { border-left: 2px solid var(--accent); }
.agent-card.trend          { border-left: 2px solid var(--bubble); }
.agent-card.random         { border-left: 2px solid var(--fg-2); }
.agent-card.experienced    { border-left: 2px solid var(--volume); }

/* Agents-panel header: title + Resample button inline, stage label
   under the title. In preview mode the panel picks up an outline to
   signal that the endowment fields are editable. */
.panel-agents .agents-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.panel-agents .agents-header h2 {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.panel-agents .stage-label {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: none;
  color: var(--amber);
  font-weight: 500;
  padding: 2px 6px;
  border: 1px solid var(--amber);
  border-radius: 10px;
  background: var(--amber-bg);
}
.panel-agents .stage-label.live {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-bg);
}
.panel-agents.preview {
  outline: 1px dashed var(--amber);
  outline-offset: -1px;
}

/* Inline editable endowment fields — shown only in the pre-run
   preview, right-aligned to match the read-only metric-val layout. */
.agent-card .endow-input {
  width: 64px;
  background: var(--bg-1);
  color: var(--fg-0);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: inherit;
  font-size: 11px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.agent-card .endow-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-2);
}
.agent-card .endow-input::-webkit-outer-spin-button,
.agent-card .endow-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ---------- Agent-panel explanatory notes ---------- *
 * Single "Note" block (title + dl glossary). Each <dt> carries the
 * exact term name that appears on the agent card ("Cash", "P&L", …)
 * in the same UI font as the card, so symbol/term typography stays
 * consistent across card and note. <dd> holds the prose explanation.
 * ------------------------------------------------------------------ */
.panel-agents .agent-notes {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  line-height: 1.65;
  color: var(--fg-3);
}
.panel-agents .agent-notes-title {
  color: var(--accent);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 10px;
}
.panel-agents .agent-notes-list {
  display: grid;
  grid-template-columns: minmax(96px, max-content) 1fr;
  gap: 8px 16px;
  margin: 0;
}
.panel-agents .agent-notes-list dt {
  color: var(--fg-1);
  font-weight: 500;
  white-space: nowrap;
  text-align: right;
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 4px;
}
.panel-agents .agent-notes-list dt .sym,
.panel-agents .agent-notes-list dt [data-sym] {
  color: var(--fg-3);
}
.panel-agents .agent-notes-list dd {
  margin: 0;
  color: var(--fg-3);
}
.panel-agents .agent-notes-list dd em {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Georgia",
               "Times New Roman", serif;
  font-style: italic;
  color: var(--fg-1);
}

/* ---------- Feed ---------- *
 * The panel is a flex column so the <ul> fills whatever row height the
 * shared grid cell ends up at. The row is sized by min-content of the
 * taller sibling (.panel-agents), so we need #trade-feed to contribute
 * *nothing* to panel-feed's own intrinsic height — otherwise a long
 * trade list would inflate the row past the Agents panel and stretch
 * Agents along with it. `flex-basis: 0` is what makes that work: with
 * basis 0 the UL's content size does not propagate into the flex
 * container's min-content calculation, so panel-feed's min-content
 * stays at ~h2 height and the grid row tracks Agents exactly. The list
 * still flex-grows to fill the row, and its own `overflow-y: auto`
 * kicks in for anything that would spill past the Agents-height cap.
 * ------------------------------------------------------------------ */
.panel-feed {
  display: flex;
  flex-direction: column;
}
.panel-feed > h2 { flex: 0 0 auto; }
#trade-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
#trade-feed li {
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
  display: grid;
  grid-template-columns: 40px 70px 1fr;
  gap: 8px;
  align-items: center;
}
#trade-feed .t-tick { color: var(--fg-2); }
#trade-feed .t-price { color: var(--accent); font-weight: 700; }
#trade-feed .t-agents { color: var(--fg-2); }
#trade-feed li.feed-dividend {
  background: var(--amber-bg);
  border-left: 2px solid var(--amber);
  padding-left: 6px;
}
#trade-feed li.feed-dividend .t-price { color: var(--fv); }
#trade-feed li.feed-dividend .t-agents { color: var(--fv); }

/* ---------- Replay ---------- */
.panel-replay .replay-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.panel-replay .replay-controls button {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--fg-0);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
}
.panel-replay .replay-controls button:hover { background: var(--bg-3); }
.panel-replay .replay-controls .primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}
.panel-replay .replay-pos {
  margin-left: auto;
  color: var(--fg-2);
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}
.panel-replay input[type=range] { width: 100%; margin-bottom: 6px; }

.trace-inspector {
  margin-top: 10px;
  max-height: 260px;
  overflow-y: auto;
}
#trace-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}
.trace-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 11px;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
}
.trace-card .trace-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: var(--fg-0);
  margin-bottom: 5px;
}
.trace-card .trace-kind {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}
.trace-card .trace-kind.bid  { color: var(--green); background: var(--green-bg); }
.trace-card .trace-kind.ask  { color: var(--red);   background: var(--red-bg); }
.trace-card .trace-kind.hold { color: var(--fg-2);  background: var(--bg-2); }
.trace-card .trace-row { color: var(--fg-2); margin: 1px 0; line-height: 1.35; }
.trace-card .trace-row strong { color: var(--fg-0); font-weight: 600; }

/* ---------- Timeline legend ---------- */
.legend {
  display: flex;
  gap: 14px;
  font-size: 10px;
  color: var(--fg-2);
  margin-top: 8px;
  flex-wrap: wrap;
}
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
.legend i.bid   { background: var(--bid); }
.legend i.ask   { background: var(--ask); }
.legend i.hold  { background: var(--hold); }
.legend i.trade { background: var(--accent); border-radius: 50%; }
.legend i.lie   { background: transparent; border: 1.5px solid var(--bubble); border-radius: 50%; }

/* ---------- Extended-mode controls ---------- */
.ext-controls {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 6px 10px;
  background: var(--bg-2);
  border: 1px dashed var(--border);
  border-radius: 5px;
}
.ext-controls .checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-transform: none;
  font-size: 11px;
  color: var(--fg-2);
  letter-spacing: 0;
  cursor: pointer;
}
.ext-controls input[type=checkbox] {
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

/* ---------- Metrics panel ---------- */
#metrics-body {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 10px;
  column-gap: 14px;
  font-family: var(--font-ui);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  padding-top: 4px;
}
#metrics-body .metric-row { display: contents; }
#metrics-body .metric-row span   { color: var(--fg-2); display: flex; flex-wrap: wrap; align-items: baseline; gap: 0; }
#metrics-body .metric-row span em {
  font-style: normal;
  font-family: "SF Mono", SFMono-Regular, ui-monospace, Menlo, Consolas, monospace;
  font-size: 10px;
  color: var(--fg-3);
  margin-left: 4px;
}
#metrics-body .metric-row span em math {
  font-size: 12px;
}
#metrics-body .metric-row strong { color: var(--fg-0); text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
#metrics-body .metric-group-label {
  grid-column: 1 / -1;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-3);
  padding-top: 4px;
  border-top: 1px solid var(--bg-3);
  margin-top: 2px;
}
#metrics-body .metric-group-label:first-child {
  border-top: none;
  padding-top: 0;
  margin-top: 0;
}

/* ---------- EU candidate table in trace cards ---------- */
.trace-card .trace-eu {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.trace-card .eu-row {
  display: flex;
  justify-content: space-between;
  color: var(--fg-2);
  font-size: 10px;
  gap: 10px;
}
.trace-card .eu-row.chosen {
  color: var(--bid);
  font-weight: 700;
}
.trace-card .eu-lbl { flex: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(6, 1fr); }
  .panel-stats { grid-template-columns: repeat(3, 1fr); }
  .chart-price, .chart-timeline, .panel-agents { grid-column: span 6; }
  .panel-book, .chart-bubble, .chart-volume, .chart-heatmap, .panel-feed { grid-column: span 6; }
  .chart-valuation, .panel-metrics, .chart-utility,
  .chart-ownership, .chart-messages, .chart-trust { grid-column: span 6; }
  .agents-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .panel-stats { grid-template-columns: repeat(2, 1fr); }
  .agents-grid { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .chart-price, .chart-timeline, .panel-agents, .panel-book,
  .chart-bubble, .chart-volume, .chart-heatmap, .panel-feed, .panel-replay,
  .chart-valuation, .panel-metrics, .chart-utility,
  .chart-ownership, .chart-messages, .chart-trust { grid-column: span 1; }
}

/* ---------- Architecture tab (math-focused) ---------- */
/*
 * Snapshot of the three paradigms' equation pipeline. The SVG nodes
 * carry inline equations (no KaTeX; KaTeX lives in .arch-def-card
 * .formula blocks below). Every node class has a CSS custom-property
 * pair (--nc = accent/stroke, --nb = soft fill) so the theme-swap is
 * free. The "Edit in draw.io" button opens architecture.drawio in the
 * public app.diagrams.net editor — href is filled in at runtime by
 * main.js so the URL always reflects the live GitHub Pages path.
 */
.arch-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 28px 60px;
}
.arch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.arch-title-block { display: flex; flex-direction: column; gap: 4px; }
.arch-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--fg-0);
}
.arch-desc {
  margin: 0;
  font-size: 12px;
  color: var(--fg-2);
  font-style: italic;
}
.btn-drawio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-1);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.btn-drawio:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-drawio svg { width: 16px; height: 16px; display: block; }
.arch-svg-container {
  width: 100%;
  padding: 8px 0 28px;
  overflow-x: auto;
}
.arch-svg-container svg {
  width: 100%;
  max-width: 980px;
  height: auto;
  display: block;
  margin: 0 auto;
  color: var(--fg-3);
}

/* Node colour keys — each .n-* class binds --nc (accent/stroke) and
   --nb (soft background). Add a new category by defining both vars
   and then the shared .n rect / .n text.t rules below do the work. */
.arch-diagram .n-paper  { --nc: var(--blue);   --nb: var(--blue-bg); }
.arch-diagram .n-fund   { --nc: var(--green);  --nb: var(--green-bg); }
.arch-diagram .n-trend  { --nc: var(--green);  --nb: var(--green-bg); }
.arch-diagram .n-zi     { --nc: var(--green);  --nb: var(--green-bg); }
.arch-diagram .n-exp    { --nc: var(--teal);   --nb: var(--teal-bg); }
.arch-diagram .n-util   { --nc: var(--amber);  --nb: var(--amber-bg); }
.arch-diagram .n-eu     { --nc: var(--amber);  --nb: var(--amber-bg); }
.arch-diagram .n-msg    { --nc: var(--amber);  --nb: var(--amber-bg); }
.arch-diagram .n-trust  { --nc: var(--amber);  --nb: var(--amber-bg); }
.arch-diagram .n-wang   { --nc: var(--pink);   --nb: var(--pink-bg); }
.arch-diagram .n-book   { --nc: var(--purple); --nb: var(--purple-bg); }
.arch-diagram .n-metric { --nc: var(--red);    --nb: var(--red-bg); }

.arch-diagram .n rect {
  fill: var(--nb);
  stroke: var(--nc);
  stroke-width: 1.6;
}
.arch-diagram .n text {
  text-anchor: middle;
  dominant-baseline: middle;
}
.arch-diagram .n text.t {
  fill: var(--nc);
  font: 600 12px var(--font-ui);
  letter-spacing: 0.01em;
}
.arch-diagram .n text.s {
  fill: var(--fg-2);
  font: 10px var(--font-ui);
}
/* Equation nodes — slightly tighter, mono-ish */
.arch-diagram .n-eq text.t {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, var(--font-ui);
  font-size: 11px;
}
.arch-diagram .n-eq text.s {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, var(--font-ui);
  font-size: 10px;
}

/* Paradigm group frames — soft rectangles behind each cluster of nodes.
   Paper constants (blue) / strategies (green) / Wang overlay (pink, dashed)
   / market (amber). The Wang overlay is dashed to signal "optional". */
.arch-diagram .arch-group rect {
  fill: none;
  stroke-width: 1.2;
  stroke-dasharray: 0;
  opacity: 0.85;
}
.arch-diagram .arch-group.g-paper  rect { stroke: var(--blue);  fill: color-mix(in srgb, var(--blue-bg)  45%, transparent); }
.arch-diagram .arch-group.g-strat  rect { stroke: var(--green); fill: color-mix(in srgb, var(--green-bg) 30%, transparent); }
.arch-diagram .arch-group.g-wang   rect { stroke: var(--pink);  fill: color-mix(in srgb, var(--pink-bg)  45%, transparent); stroke-dasharray: 5 4; }
.arch-diagram .arch-group.g-market rect { stroke: var(--amber); fill: color-mix(in srgb, var(--amber-bg) 35%, transparent); }
.arch-diagram .arch-group .g-label {
  text-anchor: middle;
  font: 700 10px var(--font-ui);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}
.arch-diagram .arch-group.g-paper  .g-label { fill: var(--blue); }
.arch-diagram .arch-group.g-strat  .g-label { fill: var(--green); }
.arch-diagram .arch-group.g-wang   .g-label { fill: var(--pink); }
.arch-diagram .arch-group.g-market .g-label { fill: var(--amber); }

/* Core dataflow connectors. color is inherited from the svg element
   (var(--fg-3)) so light / dark switches sweep the whole diagram in
   a single variable resolution. */
.arch-diagram .link {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  marker-end: url(#arch-arrow);
}
/* AIPE overlay connector (ai.js → Utility prior). Dashed + pink to
   signal that it only fires when paradigm === 'wang' and an API key is
   provided, and that it overrides the deterministic prior block. */
.arch-diagram .link-wang {
  stroke: var(--pink);
  stroke-dasharray: 4 3;
  stroke-width: 1.5;
}

/* Definition cards below the diagram. Responsive 3-col grid that
   collapses at the 1100 / 700 breakpoints. Each card reuses the
   node colour key so the colour-encoded module group is consistent
   between the SVG and the card stack. */
.arch-defs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.arch-def-card {
  padding: 14px 16px 16px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-left: 2px solid var(--fg-3);
  border-radius: 8px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.arch-def-card:hover {
  box-shadow: var(--shadow-sm);
}
.arch-def-card h4 {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--fg-0);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.arch-def-card .role {
  margin: 0 0 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  font-weight: 600;
}
.arch-def-card .body {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--fg-1);
}
.arch-def-card .body code {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  font: 11px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--fg-0);
}
/* KaTeX formula block. One per card by default; a card can stack two
   formula blocks (e.g. the EU scoring card) and they'll space evenly. */
.arch-def-card .formula {
  margin: 6px 0 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--fg-0);
}
.arch-def-card .formula + .formula { margin-top: -2px; }
.arch-def-card .formula .katex { font-size: 1.02em; }
.arch-def-card .formula .katex-display {
  margin: 0;
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.arch-def-card.card-paper  { border-left-color: var(--blue); }
.arch-def-card.card-paper  h4 { color: var(--blue); }
.arch-def-card.card-strat  { border-left-color: var(--green); }
.arch-def-card.card-strat  h4 { color: var(--green); }
.arch-def-card.card-ll     { border-left-color: var(--amber); }
.arch-def-card.card-ll     h4 { color: var(--amber); }
.arch-def-card.card-wang   { border-left-color: var(--pink); }
.arch-def-card.card-wang   h4 { color: var(--pink); }
.arch-def-card.card-metric { border-left-color: var(--red); }
.arch-def-card.card-metric h4 { color: var(--red); }

/* ---------- Glossary tab ---------- */
/*
 * Reference section for every abbreviation, symbol, figure, and source
 * paper used in the simulator. Four gloss-sections stacked vertically;
 * each section has a heading + a full-width table (or a flex list for
 * the figure descriptions). KaTeX renders the math cells via main.js
 * ._renderMath(), triggered on tab switch.
 */
.glossary-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 28px 60px;
}
.glossary-wrap > h2 {
  margin: 0 0 26px;
  padding-bottom: 14px;
  font-size: 18px;
  font-weight: 700;
  color: var(--fg-0);
  border-bottom: 1px solid var(--border);
}
.gloss-section {
  margin-bottom: 34px;
}
.gloss-section > h3 {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-2);
}
.gloss-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.55;
}
.gloss-table thead th {
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-2);
}
.gloss-table tbody td {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  color: var(--fg-1);
  vertical-align: top;
}
.gloss-table tbody tr:first-child td { border-top: 0; }
.gloss-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--bg-2) 55%, transparent); }
.gloss-table td.term {
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  color: var(--fg-0);
  min-width: 90px;
}
.gloss-table td.term.math {
  font-family: var(--font-ui);
  font-weight: 500;
}

/* Figure-description rows — each is a flex card with a coloured number
   circle and a two-line title/body block. */
.plot-desc {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.plot-desc:last-child { margin-bottom: 0; }
.plot-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 13px var(--font-ui);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.plot-info { flex: 1 1 auto; }
.plot-info h4 {
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-0);
}
.plot-info p {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--fg-1);
}

/* ---------- Slides tab ---------- */
/*
 * Presentation mode. Responsive flex viewport (no fixed aspect ratio)
 * — one active .slide at a time, navigated with prev/next buttons or
 * keyboard arrows. Fullscreen mode fixes the viewport to the whole
 * window; reading mode unhides every slide and stacks them for
 * scrolling or printing. Page size is intentionally NOT hard-coded
 * to 16:9 so the slides adapt to the host window rather than showing
 * black bars.
 */
.slides-wrap {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 60px;
}
.slides-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.slides-counter {
  font: 600 12px var(--font-ui);
  color: var(--fg-2);
  letter-spacing: 0.05em;
}
.slides-counter #slide-cur { color: var(--fg-0); }
.slides-nav {
  display: flex;
  gap: 6px;
}
.slides-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg-1);
  font: 600 14px var(--font-ui);
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.slides-btn:hover:not(:disabled) {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.slides-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.slides-btn.active {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.slides-viewport {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  min-height: 560px;
  padding: 40px 48px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}
.slide {
  display: none;
  flex: 1 1 auto;
  width: 100%;
  animation: slide-fade 0.24s var(--ease);
}
.slide.active { display: flex; }
@keyframes slide-fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.slide-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
}
.slide-body.slide-center {
  align-items: center;
  justify-content: center;
  text-align: center;
}
.slide-title {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--fg-0);
}
.slide-subtitle {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  color: var(--fg-2);
  font-style: italic;
}
.slide-heading {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: var(--fg-0);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.slide-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: var(--fg-1);
  max-width: 900px;
}
.slide-center .slide-text { margin: 0 auto; }
.slide-note-sm {
  margin: 0;
  font-size: 11px;
  color: var(--fg-3);
  font-style: italic;
  letter-spacing: 0.02em;
}
.slide-sm {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--fg-2);
  line-height: 1.5;
}
.slide-big {
  font-size: 22px;
  font-weight: 600;
  color: var(--fg-0);
  line-height: 1.5;
  max-width: 900px;
  margin: 0 auto;
}

/* Formula blocks — .slide-formula is inline / compact,
   .slide-formula-card is a bordered block for display equations. */
.slide-formula {
  font: 500 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--fg-0);
  background: var(--bg-2);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: inline-block;
}
.slide-formula-card {
  padding: 18px 22px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 14px;
  overflow-x: auto;
}
.slide-formula-card .katex-display { margin: 0; }
.slide-formula .katex { font-size: 1em; }

/* Card layouts inside slides. slide-card is a soft bordered block; the
   *-col grids lay multiple cards side-by-side; slide-highlight adds a
   coloured left-border accent. */
.slide-card {
  padding: 14px 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.slide-card h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--fg-0);
}
.slide-card .slide-formula { display: block; margin-top: 4px; }
.slide-highlight { border-left: 3px solid var(--accent); }
.slide-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.slide-three-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.slide-class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

/* Paradigm env badges — pill labels used on the title / closing slides. */
.slide-env-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.slide-env-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  font: 600 11px var(--font-ui);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  background: color-mix(in srgb, currentColor 10%, transparent);
}
.slide-env-badge.slide-dlm  { color: var(--blue);  }
.slide-env-badge.slide-ll   { color: var(--amber); }
.slide-env-badge.slide-wang { color: var(--pink);  }

/* Fullscreen mode — lifts the viewport out of the normal flow and
   fills the window. z-index above everything else. The toolbar stays
   in its normal spot; main.js adds a subtle overlay so the underlying
   page doesn't distract. */
.slides-viewport.fullscreen {
  position: fixed;
  inset: 32px;
  z-index: 1000;
  padding: 60px 80px;
  min-height: unset;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}
.slides-fs-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 999;
  backdrop-filter: blur(3px);
}

/* Reading mode — unhides every slide and stacks them vertically with
   generous spacing. The viewport becomes a long scroll column; print
   reuses this mode via @media print below. */
.slides-viewport.reading-mode {
  display: block;
  min-height: unset;
  padding: 32px 48px;
}
.slides-viewport.reading-mode .slide {
  display: flex;
  margin-bottom: 48px;
  padding-bottom: 32px;
  border-bottom: 1px dashed var(--border);
  animation: none;
  page-break-after: always;
}
.slides-viewport.reading-mode .slide:last-child {
  margin-bottom: 0;
  border-bottom: 0;
}

/* Print — force reading mode, full bleed, one slide per page. */
@media print {
  .app-header, .paradigm-switch, .nav-tabs, .controls { display: none !important; }
  .tab-pane { display: none !important; }
  #tab-slides { display: block !important; }
  .slides-toolbar { display: none !important; }
  .slides-viewport {
    display: block;
    border: 0;
    box-shadow: none;
    padding: 0;
    min-height: unset;
    background: transparent;
  }
  .slide {
    display: flex !important;
    page-break-after: always;
    padding: 24px;
    animation: none;
  }
  .slide:last-child { page-break-after: auto; }
}
@page { size: A4 landscape; margin: 1cm; }

/* Responsive breakpoints — below 900px the three/two-col grids collapse
   and the slide title scales down. */
@media (max-width: 900px) {
  .slide-three-col { grid-template-columns: 1fr; }
  .slide-two-col   { grid-template-columns: 1fr; }
  .slide-title     { font-size: 24px; }
  .slide-heading   { font-size: 18px; }
  .slides-viewport { padding: 24px 20px; min-height: 420px; }
}

/* ---------- Scrollbars ---------- */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
*::-webkit-scrollbar-thumb:hover { background: var(--bg-3); }
