/* ==========================================================================
   forecast.agenticlearning.ai — site layer
   Loads AFTER the shared lab-tokens.css + lab-components.css.
   Holds only what the forecasting site adds: the two venue hues, the hero
   figure, the chart, the ledger extras, and the position card.
   Source of truth for the site layer (docs/site_redesign/build_mockup.py inlines it into the mockup).
   ========================================================================== */

/* venue identity — the venues' own brand hues (Mengye, 2026-09-06).
   Kalshi green sits near --good; chips are small labels and P&L figures
   are large, so they rarely compete at the same size. */
:root {
  /* light values sit a step darker than the brand hues so small text passes
     AA (4.5:1) on white, on cards and on its own chip ground: Kalshi 4.6:1,
     Polymarket 5.0:1 on the chip; the dark values below are unchanged. */
  --venue-kalshi: #0B7050;
  --venue-kalshi-soft: rgba(11, 112, 80, 0.14);
  --good: #157A4C;                 /* lab light #1E8E5A is 4.1:1 on white; 5.0:1 here. Dark keeps the lab value. */
  --accent-ink: #2258C4;           /* accent as running text (.delta.up): --accent #3C81F7 is 3.7:1 on white */
  --good-soft: rgba(30, 142, 90, 0.12); --bad-soft: rgba(179, 38, 30, 0.10); --warn-soft: rgba(183, 121, 31, 0.12);   /* badge grounds */
  --bg-archived: #fff8e6; --archived-text: #5a4510; --archived-border: #e0b050;   /* archived-scan card */
  --venue-polymarket: #2258C4;
  --venue-polymarket-soft: rgba(34, 88, 196, 0.12);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --venue-kalshi: #3FBF86; --venue-kalshi-soft: rgba(63, 191, 134, 0.18);
    --venue-polymarket: #5D97FF; --venue-polymarket-soft: rgba(93, 151, 255, 0.18);
    --accent-ink: var(--accent);
    --bg-archived: #2a2410; --archived-text: #d4b56a; --archived-border: #6b5520;
  }
}
:root[data-theme="dark"] {
  --venue-kalshi: #3FBF86; --venue-kalshi-soft: rgba(63, 191, 134, 0.18);
  --venue-polymarket: #5D97FF; --venue-polymarket-soft: rgba(93, 151, 255, 0.18);
  --accent-ink: var(--accent);
  --bg-archived: #2a2410; --archived-text: #d4b56a; --archived-border: #6b5520;
}
.venue { display: inline-block; font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 0.08rem 0.45rem; border-radius: 4px; }
.venue.kalshi { color: var(--venue-kalshi); background: var(--venue-kalshi-soft); }
.venue.polymarket { color: var(--venue-polymarket); background: var(--venue-polymarket-soft); }

/* density: the dashboard carries far more information per screen than the
   lab sites, so the site layer runs a smaller scale than the shared sheet's
   prose defaults (17px/1.75). Everything below is sized against this. */
body { font-size: 0.97rem; line-height: 1.6; display: flex; flex-direction: column; min-height: 100vh; }
main.wrap { flex: 1 0 auto; width: 100%; }
footer.lab { flex: none; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1rem; }
p.lede { font-size: 0.98rem; }
th, td { font-size: 0.78rem; }

/* header: eight nav items need a tighter measure than the lab sites' five */
.brand { gap: 0.6rem; font-size: 1.2rem; }
.brand svg { width: 60px; height: 51px; }
nav.lab { gap: 0.2rem; font-size: 0.9rem; }
#theme-toggle svg { width: 15px; height: 15px; }   /* the nav is 0.9rem here, so the glyph is a step smaller than the kit's 20px */
#theme-toggle-icon { display: inline-flex; align-items: center; }
#theme-toggle-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* the eight-item nav collapses to the hamburger earlier than the lab sites' five-item nav.
   Drawer follows agenticlearning.ai: fixed top-right, sized to content, card-bg with a faint
   left edge, links right-aligned at 15px; the button sits on the page's 5% inset (the content column's
   right edge), stays put and turns into an X. */
@media (max-width: 1180px) {
  /* header keeps the page's .wrap inset (brand aligned with the content); only the button is pinned 20px from the edge */
  header.lab { position: relative; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; position: absolute; right: 5%; top: 40px; width: 30px; height: 30px; margin: 0; padding: 0; z-index: 60; }
  header.lab.open .menu-btn { position: fixed; right: 5%; top: 40px; }
  .menu-btn svg { width: 24px; height: 24px; }
  .menu-btn .ico-x { display: none; }
  header.lab.open .menu-btn .ico-menu { display: none; }
  header.lab.open .menu-btn .ico-x { display: block; }
  nav.lab { display: flex; flex-direction: column; align-items: flex-end; justify-content: flex-start; gap: 0.5rem; position: fixed; top: 0; right: 0; bottom: auto; height: auto; max-height: calc(100vh - 20px); width: 0; padding: 100px 5% 60px 8px; overflow: hidden; opacity: 0; visibility: hidden; pointer-events: none; z-index: 50; background: var(--card-bg); color: var(--fg); border-top-left-radius: var(--radius-lg); border-bottom-left-radius: var(--radius-lg); border-left: 1px solid color-mix(in srgb, var(--border) 35%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); transition: width 0.3s ease, opacity 0.2s ease, visibility 0s 0.3s; }   /* visibility flips after the fade, so closed links leave the tab order */
  header.lab.open nav.lab { width: calc(140px + 5%); opacity: 1; visibility: visible; pointer-events: auto; transition: width 0.3s ease, opacity 0.2s ease, visibility 0s 0s; }
  nav.lab .header-links { font-size: 15px; padding: 6px 10px; white-space: nowrap; }
  nav.lab .theme-toggle { margin-top: 0.25rem; }
}

/* hero — a card with the lab's pastel wash and the thesis figure */
.hero.lab { margin: 0.5rem 0 1.25rem; padding: 2.5rem 2.75rem 2.25rem; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.9fr); gap: 2rem; align-items: end; }
.hero h1 { font-size: clamp(2.1rem, 4.2vw, 3.2rem); line-height: 1.1; max-width: 14ch; }
.hero p.lede { max-width: 54ch; font-size: 1rem; margin: 0.9rem 0 0; }
.live { display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--mono); font-size: 0.78rem; color: var(--fg); border-radius: 999px; padding: 0.25rem 0.75rem 0.25rem 0.55rem; margin-bottom: 1.25rem; }
.live .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(30, 142, 90, 0.18); }
.live .muted { color: var(--fg-muted); }
@media (max-width: 480px) {
  /* the pill can't hold "agent live · last scan <stamp> UTC" on one line: the stamp drops to its own line under the label, the pill squares off */
  .live { flex-wrap: wrap; row-gap: 0; border-radius: var(--radius-md); }
  .live .muted { flex-basis: 100%; padding-left: calc(8px + 0.5rem); }
  .live .sep { display: none; }
}
.figure { padding: 1.25rem 1.4rem 1.1rem; }
.figure .label { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted); display: flex; align-items: center; gap: 0.5rem; }
.figure .big { font-size: clamp(1.8rem, 3.2vw, 2.5rem); line-height: 1.1; margin: 0.25rem 0 0.15rem; }
.tile .value { font-weight: 400; font-size: 1.5rem; }
.tile .foot { font-size: 0.86rem; }
.figure .sub { font-family: var(--mono); font-size: 0.78rem; color: var(--fg-muted); }
.figure .spark { display: block; width: 100%; height: 56px; margin-top: 0.75rem; }
.figure .spark-cap { font-family: var(--mono); font-size: 0.68rem; color: var(--fg-muted); display: flex; justify-content: space-between; }

/* page hero: every page opens with a compact wash card, not a bare title under the site header */
.hero.lab.page { display: block; padding: 1.75rem 2.25rem 1.6rem; margin: 0.25rem 0 1.5rem; }
.hero.lab.page h1, .hero.lab.page h2 { font-family: var(--mono); font-weight: 400; font-size: clamp(1.5rem, 2.4vw, 2rem); line-height: 1.15; letter-spacing: -0.02em; margin: 0; max-width: 28ch; text-wrap: balance; }
.hero.lab.page h2::after { display: none; content: none; }
.hero.lab.page .lede { font-size: 0.98rem; max-width: 66ch; margin: 0.5rem 0 0; color: var(--fg); }
.hero.lab.page .meta { font-family: var(--mono); font-size: 0.8rem; color: var(--fg-muted); margin-top: 0.7rem; display: flex; gap: 0.35rem 0.7rem; flex-wrap: wrap; align-items: center; }
.hero.lab.page .meta a { color: var(--fg); }
.hero.lab.page .filters { margin-top: 1.1rem; display: flex; gap: 0.35rem; flex-wrap: wrap; }
.hero.lab.page .filters .chip:not(.active), .hero.lab.page .chip:not(.active) { background: color-mix(in srgb, var(--bg) 72%, transparent); }
.hero.lab.page .back { display: inline-block; margin-bottom: 0.9rem; font-family: var(--mono); font-size: 0.8rem; color: var(--fg-muted); text-decoration: none; }
.hero.lab.page .back:hover { color: var(--accent); }
.hero.lab.page.detail h1 { font-size: clamp(1.25rem, 1.9vw, 1.6rem); max-width: 48ch; line-height: 1.25; }
@media (max-width: 860px) { .hero.lab.page { padding: 1.5rem 1.25rem; } }

/* section heads */
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.sec-head h2, body[class*="page-"] .sec-head h2 { margin: 0; }  /* the page-layer h2 margin would double the gap below */
.sec-head .more { font-family: var(--mono); font-size: 0.85rem; color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--border); }
.sec-head .more:hover { color: var(--accent); border-color: var(--accent); }
section.lab { padding: 1.5rem 0; }

/* chart card */
.chart-card { background: var(--card-bg); border-radius: var(--radius-md); padding: 1.1rem 1.35rem 0.9rem; }
.chart-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.chart-card .legend { margin-top: 0; gap: 1.1rem; color: var(--fg); }
.chart-card .legend span { display: inline-flex; align-items: center; gap: 0.45rem; }
.chart-card .legend i { width: 14px; height: 3px; margin: 0; }
.chart-card .legend i.dashed { height: 0; background: none; border-top: 2px dashed; }
.chart-card .card-title { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted); margin-bottom: 0.6rem; }
.chart-card .legend .v { color: var(--fg-muted); }
.ranges { display: flex; gap: 0.25rem; }
.ranges .button:not(.filled) { background: var(--bg); }
.chart-wrap { position: relative; }
.chart-wrap svg { display: block; width: 100%; height: auto; font-family: var(--mono); }
.chart-wrap .tip { position: absolute; pointer-events: none; font-family: var(--mono); font-size: 0.74rem; line-height: 1.5; background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 0.4rem 0.6rem; min-width: 160px; box-shadow: 0 6px 18px rgba(0,0,0,0.08); }
.chart-wrap .tip[hidden] { display: none; }
.chart-wrap .tip b { font-weight: 400; color: var(--fg-muted); display: block; margin-bottom: 0.1rem; }
.chart-wrap .tip span { display: flex; justify-content: space-between; gap: 1rem; }
.chart-wrap .tip i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.4rem; }

/* ledger extras */
th, td { padding: 0.6rem 0.75rem; }
td.h { min-width: 30ch; max-width: 58ch; font-size: 0.94rem; line-height: 1.4; }
td.h a { text-decoration: none; }
td.h a:hover { text-decoration: underline; }
tr:hover td { background: var(--card-bg); }
.cat { color: var(--fg-muted); }
.delta { display: inline-flex; align-items: center; gap: 0.3rem; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--accent-ink); }
.delta.down { color: var(--fg); }
.conf { display: inline-flex; align-items: center; gap: 0.5rem; }
.conf i { display: inline-block; width: 56px; height: 4px; border-radius: 2px; background: var(--border-soft); position: relative; overflow: hidden; }
.conf i::after { content: ""; position: absolute; inset: 0; width: var(--w); background: var(--accent); border-radius: 2px; }

/* position cards */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.pcard { background: var(--card-bg); border-radius: var(--radius-md); padding: 1.25rem 1.4rem 1.2rem; display: flex; flex-direction: column; gap: 0.6rem; }
.pcard .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.35rem 0.5rem; font-family: var(--mono); font-size: 0.74rem; color: var(--fg-muted); }
.pcard .row > span:last-child { white-space: nowrap; }
.pcard .chips { display: inline-flex; gap: 0.4rem; align-items: center; }
.side { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; padding: 0.1rem 0.5rem; border-radius: 4px; border: 1.5px solid var(--fg); color: var(--fg); }
.side.no { background: var(--btn-bg); color: var(--btn-color); border-color: var(--btn-bg); }
.pcard h3 { font-family: var(--serif); font-weight: 600; font-size: 1.02rem; line-height: 1.35; letter-spacing: 0; margin: 0; min-height: 2.7em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .ticker { font-family: var(--mono); font-size: 0.72rem; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard .pl { display: flex; justify-content: space-between; align-items: end; gap: 1rem; border-top: 1px solid var(--border-soft); padding-top: 0.7rem; margin-top: 0.4rem; }
.pcard .pl .label { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted); }
.pcard .pl .v { font-family: var(--mono); font-weight: 400; font-size: 1.35rem; letter-spacing: -0.02em; line-height: 1.15; }
.pcard .pl .v.small { font-size: 1.05rem; font-weight: 400; }
.pcard .kv { display: flex; gap: 1rem; flex-wrap: wrap; font-family: var(--mono); font-size: 0.76rem; color: var(--fg-muted); }
.pcard .kv b { font-weight: 400; color: var(--fg); }
.pcard .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: auto; padding-top: 0.9rem; border-top: 1px solid var(--border-soft); }
.pcard .kv { margin-bottom: 0.8rem; }
.pcard .actions .button { flex: 1 1 auto; justify-content: center; font-size: 0.76rem; padding: 4px 10px; background: var(--bg); }
.pcard { min-width: 0; }

/* footer: outerloop's block verbatim (mark + Developed by + GitHub / X / site) */

@media (max-width: 960px) {
  .hero.lab { grid-template-columns: 1fr; padding: 2rem 1.5rem; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .cards { grid-template-columns: 1fr; }
}

/* wide tables scroll inside their wrapper at every width (the old rule only applied below 768px, so the
   closed-positions table on /trades widened the page at phone widths) */
.table-wrap, .tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table-wrap, .chart-wrap, .card-expand { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--fg) 35%, transparent) transparent; }
.table-wrap::-webkit-scrollbar, .card-expand::-webkit-scrollbar { height: 8px; width: 8px; }
.table-wrap::-webkit-scrollbar-track, .card-expand::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb, .card-expand::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--fg) 35%, transparent); border-radius: 4px; }
.table-wrap table { min-width: 0; }

/* inline code in running text wraps (long commands / URLs must not widen the page); block code keeps <pre> scrolling */
p code, li code, td code, .about-content code:not(pre code) { white-space: normal; overflow-wrap: anywhere; }

/* client-side pager (scans list) */
.pager { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin: 1.25rem 0; font-family: var(--mono); font-size: 0.8rem; color: var(--fg-muted); }
.pager .button[disabled] { opacity: 0.4; cursor: default; }


/* ===================================================================
   Per-page sections — moved out of the templates' <style> blocks in
   phase 4 (docs/site_redesign/README.md). Selectors are unchanged so
   every specificity relation is as it was; the only thing that moved
   is source order (these precede the page-layer rules at the end of this file instead of following
   it), so the few rules that used to beat an equal-specificity page-layer
   rule by order alone carry their page's body class (see comments).
   Each template sets body_class "page-<name>" (home sets none).
   =================================================================== */


/* ---- about — team cards (templates/about.html) ---- */
/* about: the pipeline figure (templates/_pipeline_diagram.html). One horizontal
   flow of six glyphs; every colour is a token so it follows the theme without JS. */
.pipeline-figure { margin: 2rem 0; padding: 1.5rem 1.25rem 1.25rem; background: var(--card-bg); border-radius: var(--radius-md); }
.pipeline-flow { display: flex; align-items: center; justify-content: space-between; max-width: 720px; margin: 0 auto; color: var(--fg-muted); }
.pf-stage { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.pf-stage svg { display: block; width: 100%; max-width: 92px; height: auto; }
.pf-label { font-family: var(--mono); font-size: 0.8rem; line-height: 1.2; color: var(--fg); }
.pf-arr { flex: 0 0 auto; width: 28px; height: 16px; margin-bottom: 1.35rem; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.pf-shape { fill: var(--bg); stroke: var(--border-soft); stroke-width: 1.25; }
.pf-soft { fill: var(--accent-soft); stroke: var(--border); stroke-width: 1; }
.pf-solid { fill: var(--accent); }
.pf-dot { fill: var(--fg-muted); }
.pf-line { fill: none; stroke: var(--border); stroke-width: 1.25; stroke-linecap: round; }
.pf-bar { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; }
.pf-tick { fill: none; stroke: var(--good); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.pf-chip text { font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.06em; text-transform: uppercase; }
.pf-chip.kalshi rect { fill: var(--venue-kalshi-soft); }         .pf-chip.kalshi text { fill: var(--venue-kalshi); }
.pf-chip.polymarket rect { fill: var(--venue-polymarket-soft); } .pf-chip.polymarket text { fill: var(--venue-polymarket); }
.pipeline-figure figcaption { max-width: 720px; margin: 1.1rem auto 0; font-family: var(--serif); font-size: 0.9rem; line-height: 1.55; color: var(--fg-muted); }
@media (max-width: 640px) {   /* two rows of three; the arrow that would open row two is dropped */
  .pipeline-flow { flex-wrap: wrap; row-gap: 1.1rem; }
  .pf-stage { flex: 0 0 26%; }
  .pf-arr { width: 11%; }
  .pf-arr-break { display: none; }
}

.team-section { margin-top: 3rem; padding-top: 2rem; border-top: 1px solid var(--border-soft); }
.team-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.25rem; }
@media (max-width: 640px) { .team-grid { grid-template-columns: 1fr; } }
/* the lab site's people card: soft surface, square headshot, name, italic role */
.team-card { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 1rem 0.75rem 0.85rem; background: var(--card-bg); border: 2px solid transparent; border-radius: var(--radius-md); text-decoration: none; color: var(--fg); }
.team-card:hover { border-color: var(--border); transform: none; box-shadow: none; }
.team-photo { width: 120px; height: 120px; overflow: hidden; border-radius: var(--radius-sm); background: var(--bg); }
.team-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.team-name { font-family: var(--mono); font-size: 0.95rem; color: var(--fg); text-align: center; }

/* ---- p&l — per-venue books, live dot (templates/pnl.html) ---- */
.platform-books { display: flex; gap: 1.5rem; flex-wrap: wrap; margin: -0.4rem 0 2rem; font-family: var(--mono); font-size: 0.78rem; color: var(--fg-muted); }
.platform-books .book { display: flex; align-items: center; gap: 0.45rem; }
.platform-books strong { font-weight: 400; color: var(--fg); }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); vertical-align: middle; margin-right: 0.35rem; animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* ---- metaculus detail (templates/metaculus_detail.html) ---- */
.mq-section { margin: 1.5rem 0; padding: 1.25rem 1.4rem; }
.mq-section h3 { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted); margin: 0 0 0.9rem; display: flex; justify-content: space-between; align-items: baseline; }
.mq-section h3 .badge { font-size: 0.65rem; }
.mq-meta { font-family: var(--mono); font-size: 0.74rem; color: var(--fg-muted); margin-top: 0.25rem; }
.mq-prose { font-size: 0.95rem; line-height: 1.6; color: var(--fg); white-space: pre-wrap; }
.mq-evidence-item { padding: 0.7rem 0.9rem; margin-bottom: 0.5rem; font-size: 0.92rem; line-height: 1.5; }
.mq-evidence-item .e-meta { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 0.35rem; }
/* scoped: ties with the page layer's `[class*="page-"] .badge` at (0,2,0); the page block used to win by source order */
body.page-metaculus .mq-evidence-item .badge { font-size: 0.6rem; padding: 0.1rem 0.4rem; }
.badge-up { background: var(--good-soft); color: var(--good); }
.badge-down { background: var(--bad-soft); color: var(--bad); }
.badge-neutral { background: var(--card-bg); color: var(--fg-muted); }
.mq-tool-row { display: grid; grid-template-columns: minmax(120px, max-content) minmax(60px, max-content) minmax(0, 1fr) minmax(50px, max-content); gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border-soft); font-size: 0.9rem; align-items: baseline; }
.mq-tool-row:last-child { border-bottom: none; }
.mq-tool-row .name { font-family: var(--mono); font-size: 0.76rem; }
.mq-sq-row { display: grid; grid-template-columns: 60px 1fr 80px; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border-soft); font-size: 0.95rem; align-items: baseline; }
.mq-sq-row .sq-id { font-family: var(--mono); color: var(--fg-muted); font-size: 0.76rem; }
.mq-sq-row .sq-weight { font-family: var(--mono); color: var(--fg-muted); font-size: 0.76rem; text-align: right; }
.mq-sq-row .sq-rationale { font-size: 0.85rem; color: var(--fg-muted); margin-top: 0.25rem; }
.mq-tool-row > *, .mq-sq-row > * { min-width: 0; overflow-wrap: anywhere; }   /* tool args and ids are unbroken strings */
@media (max-width: 640px) { .mq-tool-row, .mq-sq-row { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; } .mq-sq-row .sq-weight { text-align: left; } }
.mq-headline { font-family: var(--mono); font-size: 1.6rem; font-weight: 400; letter-spacing: -0.02em; color: var(--fg); font-variant-numeric: tabular-nums; }
.mq-headline-label { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); }
.mq-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin: 1rem 0; }
.mq-stat { background: var(--card-bg); border-radius: var(--radius-md); padding: 1rem 1.15rem; }
.mq-stat-value { font-family: var(--mono); font-size: 1.25rem; font-weight: 400; font-variant-numeric: tabular-nums; }
.mq-stat-label { font-family: var(--mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-muted); margin-top: 0.2rem; }
.mq-code { font-family: var(--mono); font-size: 0.78rem; background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; overflow-x: auto; white-space: pre-wrap; }

/* ---- pnl — per-venue books, performance strip, monthly bars, edge buckets (templates/pnl.html) ---- */
.chart-card.venue-books { margin-top: 0.75rem; }
.chart-card.venue-books .card-title { margin-bottom: 0; }
.chart-card .bars-wrap { position: relative; height: 260px; margin-top: 0.4rem; }
.chart-card > .legend { display: flex; flex-wrap: wrap; font-family: var(--mono); font-size: 0.78rem; }
.chart-card > .legend i { display: inline-block; border-radius: 1px; }
body.page-pnl .stats.perf { margin-bottom: 0; }
body.page-pnl .stat-foot { font-family: var(--serif); font-size: 0.8rem; color: var(--fg-muted); margin-top: 0.35rem; line-height: 1.35; }
body.page-pnl .edge-table th.num, body.page-pnl .edge-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
body.page-pnl .edge-table td:first-child { color: var(--fg); white-space: nowrap; }
body.page-pnl .edge-table tr.all td { color: var(--fg-muted); border-bottom: 1px solid var(--border-soft); }
body.page-pnl .edge-table tr.all td.positive { color: var(--good); }
body.page-pnl .edge-table tr.all td.negative { color: var(--bad); }
body.page-pnl .edge-table tr.empty td { color: var(--fg-muted); }
@media (max-width: 600px) {
  .chart-card .bars-wrap { height: 220px; }
  body.page-pnl .stats.perf { grid-template-columns: 1fr 1fr; }
}

/* ---- trades — card grid, expansion drawer, sortable headers (templates/trades.html) ---- */
.trade-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.trade-card { min-width: 0; }
.card-action-expand.is-open .card-action-icon { transform: rotate(90deg); }
.card-action-icon { display: inline-block; transition: transform 0.15s; margin-left: 0.3rem; transform-origin: 50% 50%; }
.open-sort-select { cursor: pointer; }
.show-all-btn { padding: 6px 14px; }
.card-expand { grid-column: 1 / -1; padding: 1.25rem 1.4rem; margin: -0.1rem 0 0.1rem; }
.card-expand-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.5rem; }
.card-expand-rationale .rationale-body { font-size: 0.95rem; line-height: 1.6; color: var(--fg); }
.card-expand-rationale .rationale-meta { margin-top: 0.85rem; padding-top: 0.65rem; border-top: 1px solid var(--border-soft); font-family: var(--mono); font-size: 0.74rem; color: var(--fg-muted); }
/* Grid children must be allowed to shrink below their content (the chart
   canvas otherwise forces its intrinsic width and the panel overflows). */
.card-expand-grid > *, .trade-expand-grid > *, .trade-expand-grid .panel { min-width: 0; }
.trade-expand-grid canvas { max-width: 100%; }
/* The drawer holds three columns (chart, book, rationale): collapse early. */
@media (max-width: 1250px) { .card-expand .trade-expand-grid { grid-template-columns: 1fr !important; } }
@media (max-width: 1000px) { .card-expand-grid { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .trade-expand-grid { grid-template-columns: 1fr !important; } }
/* When the closed-trades table is wider than the viewport it scrolls inside
   .table-wrap; the expansion cell spans the whole table, so pin its content
   to the visible region instead of letting it run under the scroll edge. */
.expand-row > td > div { position: sticky; left: 0; max-width: calc(100vw - 2.5rem); box-sizing: border-box; }
.sortable { cursor: pointer; user-select: none; position: relative; white-space: nowrap; }
.sortable:hover { color: var(--accent); }
.sortable::after { content: '⇅'; margin-left: 0.3rem; font-size: 0.7rem; opacity: 0.3; }
.sortable.active-sort::after { opacity: 1; }
.sortable.active-sort[data-dir="asc"]::after { content: '↑'; }
.sortable.active-sort[data-dir="desc"]::after { content: '↓'; }

/* ---- scans list — filters, conviction cards, ledger rows (templates/scans_v2_list.html) ---- */
/* Filter row */
.scan-filter-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.scan-search-input { flex: 0 1 300px; }
.scan-chips { display: flex; gap: 0.35rem; flex-wrap: wrap; }

/* Top-conviction grid */
.conviction-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 2rem; }
.conviction-card { display: block; text-decoration: none; color: inherit; padding: 1.1rem 1.25rem; }
.conviction-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; gap: 0.5rem; }
.conviction-card-edge { font-size: 1.15rem; }
.conviction-card-title { line-height: 1.35; margin-bottom: 0.55rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.conviction-card-meta { font-family: var(--mono); color: var(--fg); }

/* Scan list: a ledger of rows */
.scan-list { display: flex; flex-direction: column; margin-bottom: 1rem; border-top: 1px solid var(--border-soft); }
.scan-row { display: grid; grid-template-columns: minmax(180px, 1fr) auto auto auto; column-gap: 1.25rem; align-items: center; padding: 0.75rem 0.5rem; text-decoration: none; color: inherit; border-bottom: 1px solid var(--border-soft); }
.scan-row:hover { background: var(--card-bg); }
.scan-row-bar { display: none; }
.scan-row-main { min-width: 0; }
.scan-row-title { line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
.scan-row-sub { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.3rem; font-family: var(--mono); }
.scan-row-ticker { font-size: 0.7rem; }
.scan-row-prices { display: grid; grid-template-columns: auto auto; column-gap: 0.5rem; row-gap: 0.1rem; font-family: var(--mono); font-size: 0.78rem; text-align: right; min-width: 120px; font-variant-numeric: tabular-nums; }
.scan-row-prices-line { display: contents; }
.scan-row-pct { color: var(--fg); }
.scan-row-edge { text-align: right; min-width: 90px; }
.scan-row-edge-value { font-size: 1rem; line-height: 1.2; }
.scan-row-conf-bar { width: 56px; height: 4px; background: var(--border-soft); border-radius: 2px; margin: 0.35rem 0 0.15rem auto; overflow: hidden; }
.scan-row-conf-fill { height: 100%; background: var(--accent); }
.scan-row-conf-text { font-family: var(--mono); font-size: 0.66rem; }
.scan-row-date { font-family: var(--mono); font-size: 0.75rem; min-width: 80px; text-align: right; }

@media (max-width: 768px) {
    .conviction-grid { grid-template-columns: 1fr; }
    .scan-row { grid-template-columns: 1fr auto; grid-template-areas: "main edge" "prices date"; row-gap: 0.4rem; }
    .scan-row-main { grid-area: main; }
    .scan-row-prices { grid-area: prices; justify-self: start; text-align: left; }
    .scan-row-edge { grid-area: edge; }
    .scan-row-date { grid-area: date; justify-self: end; }
}

/* ---- data — endpoint table, chart blocks (templates/data.html; the generic selectors are scoped to body.page-data so they stay off the About page) ---- */
/* endpoint table: the description column is prose, so it reads in the serif */
body.page-data .about-content table td:nth-child(2) { font-family: var(--serif); font-size: 0.92rem; line-height: 1.5; }
body.page-data .about-content table td:nth-child(2) code { font-size: 0.78rem; }
body.page-data .about-content table td .tag { margin-left: 0.25rem; vertical-align: 1px; }
body.page-data .about-content h3 { margin-top: 2.25rem; }

.chart-block {
    margin: 1.75rem 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    padding: 1rem;
}
.chart-block img {
    width: 100%;
    height: auto;
    max-width: 720px;
    display: block;
    margin: 0 auto;
    cursor: pointer;
}
.chart-caption {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--fg);
    line-height: 1.55;
    text-align: left;
}
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.chart-tile {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
}
.chart-tile img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
}
.tile-caption {
    margin-top: 0.6rem;
    font-size: 0.8rem;
    color: var(--fg);
    line-height: 1.5;
}
body.page-data pre code {
    font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* ---- forecast evolution (templates/forecast_evolution.html; everything under #ft / .ft-) ---- */
/* former inline styles */
body.page-evolution .ft-intro { max-width: 760px; color: var(--fg); line-height: 1.7; margin: 0.9rem 0 1.1rem; }
body.page-evolution .ft-sum { cursor: pointer; color: var(--accent); font-size: .8rem; }
#ft { margin-top: 0; }
#ft .ft-loading { color: var(--fg-muted); font-family: var(--mono); font-size: .8rem; }
#ft .ft-sub { font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); margin-bottom: .5rem; }
/* pills in the hero */
#ft .ft-pills { display: flex; gap: .35rem; flex-wrap: wrap; }
#ft .ft-pill { font-family: var(--mono); font-size: .74rem; padding: 3px 10px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--bg) 72%, transparent); color: var(--fg); }
#ft .ft-pill.on { background: var(--btn-bg); color: var(--btn-color); }
#ft .ft-pill.warn { color: var(--bad); }
/* --- current pipeline + 3D --- */
#ft .ft-hero { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 1rem; margin: 0 0 1.5rem; }
@media (max-width: 900px) { #ft .ft-hero { grid-template-columns: 1fr; } }
#ft .ft-hero.ft-no3d { grid-template-columns: 1fr; max-width: 760px; }
#ft .ft-herocard { background: var(--card-bg); border-radius: var(--radius-md); padding: 1.25rem 1.4rem; }
#ft .ft-heroname { font-family: var(--serif); font-size: 1.2rem; font-weight: 600; color: var(--fg); line-height: 1.3; margin-bottom: .35rem; overflow-wrap: anywhere; }
#ft .ft-herostats { display: flex; gap: 1.6rem; margin: .8rem 0; }
#ft .ft-herostats .v { font-family: var(--mono); font-size: 1.35rem; color: var(--fg); font-variant-numeric: tabular-nums; }
#ft .ft-herostats .k { font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); margin-top: .1rem; }
#ft .ft-herowhy { font-size: .95rem; color: var(--fg); line-height: 1.55; margin-bottom: .8rem; }
#ft .ft-herobtns { display: flex; gap: .5rem; flex-wrap: wrap; }
#ft .ft-3dwrap { position: relative; border-radius: var(--radius-md); min-height: 250px; background: var(--card-bg); overflow: hidden; }
#ft .ft-3dwrap.ft-3d-off { display: none; }
#ft #ft-3d { width: 100%; height: 100%; display: block; position: absolute; inset: 0; }
#ft .ft-3dbar { position: absolute; left: .9rem; right: .9rem; bottom: .7rem; display: flex; align-items: center; gap: .6rem; }
#ft .ft-3dbar input[type=range] { flex: 1; accent-color: var(--accent); }
#ft .ft-gen { font-family: var(--mono); font-size: .72rem; color: var(--fg-muted); min-width: 44px; font-variant-numeric: tabular-nums; }
#ft .ft-btn-mini { padding: 2px 8px; font-size: .72rem; }
/* --- buttons: the kit's .button --- */
#ft .ft-btn { display: inline-flex; align-items: center; font-family: var(--mono); font-size: .82rem; padding: 4px 11px; border: 2px solid transparent; border-radius: var(--radius-sm); background: var(--bg); color: var(--fg); cursor: pointer; }
#ft .ft-btn:hover { border-color: var(--border); }
#ft .ft-btn-acc { background: var(--btn-bg); color: var(--btn-color); }
/* --- branch navigator --- */
#ft .ft-navhead { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
#ft .ft-bgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .75rem; }
#ft .ft-bcard { display: flex; flex-direction: column; align-items: flex-start; gap: .3rem; text-align: left; border: 2px solid transparent; border-radius: var(--radius-md); background: var(--card-bg); padding: .8rem .95rem; cursor: pointer; font-family: inherit; }
#ft .ft-bcard:hover { border-color: var(--border-soft); }
#ft .ft-bcard.on { border-color: var(--fg); }
#ft .ft-bcard.s-closed, #ft .ft-bcard.s-rolled_back { opacity: .7; }
#ft .ft-bstate { font-family: var(--mono); font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; padding: .1rem .5rem; border-radius: 4px; }
#ft .ft-bstate.s-main { background: var(--btn-bg); color: var(--btn-color); }
#ft .ft-bstate.s-kept { color: var(--fg); border: 1px solid var(--border); }
#ft .ft-bstate.s-open { color: var(--accent); border: 1px solid var(--accent); }
#ft .ft-bstate.s-closed { background: var(--bg); color: var(--fg-muted); }
#ft .ft-bstate.s-rolled_back { background: var(--bad-soft); color: var(--bad); }
#ft .ft-bname { font-family: var(--serif); font-size: .98rem; font-weight: 600; color: var(--fg); line-height: 1.35; overflow-wrap: anywhere; }
#ft .ft-bmeta { font-family: var(--mono); font-size: .72rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
#ft .ft-bdone { margin-top: .8rem; }
#ft .ft-bdone > summary { cursor: pointer; font-family: var(--mono); font-size: .78rem; color: var(--fg-muted); margin-bottom: .6rem; }
#ft .ft-bdone > summary:hover { color: var(--fg); }
.ft-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.ft-main { background: var(--fg); }
.ft-open { background: transparent; border: 2px solid var(--accent); }
.ft-x { color: var(--fg-muted); font-size: .95rem; line-height: 1; flex: none; }
.ft-rb { color: var(--bad); }
/* --- inspector + tabs --- */
#ft .ft-inspector { background: var(--card-bg); border-radius: var(--radius-md); padding: 1.25rem 1.4rem; min-height: 120px; margin-top: 1.25rem; }
#ft .ft-ihead { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
#ft .ft-iname { font-family: var(--serif); font-size: 1.15rem; font-weight: 600; color: var(--fg); flex: 1 1 60%; min-width: 0; overflow-wrap: anywhere; line-height: 1.35; }
#ft .ft-imeta { font-family: var(--mono); font-size: .76rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
#ft .ft-bc { font-family: var(--mono); font-size: .74rem; color: var(--fg-muted); margin: .35rem 0 .9rem; }
#ft .ft-tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--border-soft); margin-bottom: 1rem; flex-wrap: wrap; }
#ft .ft-tab { background: none; border: none; border-bottom: 2px solid transparent; padding: .45rem .85rem; font-family: var(--mono); font-size: .8rem; color: var(--fg-muted); cursor: pointer; }
#ft .ft-tab:hover { color: var(--fg); }
#ft .ft-tab.on { color: var(--fg); border-bottom-color: var(--accent); }
#ft .ft-pane { animation: ftfade .3s ease; }
@keyframes ftfade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#ft .ft-why { font-size: .95rem; color: var(--fg); line-height: 1.6; margin-bottom: 1rem; }
#ft .ft-diff { font-family: var(--mono); font-size: .76rem; line-height: 1.55; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); overflow: auto; background: var(--bg); }
#ft .ft-diff div { padding: .05rem .7rem; white-space: pre-wrap; }
#ft .ft-add { background: var(--good-soft); color: var(--good); }
#ft .ft-del { background: var(--bad-soft); color: var(--bad); }
#ft .ft-ctx { color: var(--fg-muted); }
#ft details.ft-prompt summary { cursor: pointer; color: var(--fg); font-family: var(--mono); font-size: .8rem; }
#ft pre.ft-pre, .ft-modal pre.ft-pre { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: .76rem; background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: .7rem .9rem; margin: .4rem 0; }
#ft .ft-scoreline { display: flex; align-items: center; gap: .85rem; margin-bottom: .4rem; }
#ft .ft-icbig { font-family: var(--mono); font-size: 1.1rem; color: var(--fg); font-variant-numeric: tabular-nums; }
#ft .ft-two { display: flex; gap: 1.2rem; flex-wrap: wrap; margin-bottom: .8rem; }
#ft .ft-two > div { flex: 1; min-width: 150px; }
#ft .ft-gate { background: var(--bg); border-radius: var(--radius-md); padding: .8rem .95rem; margin-bottom: 1rem; }
#ft .ft-gate .g-dec { font-family: var(--mono); font-size: .9rem; margin-bottom: .25rem; }
#ft .ft-gate .g-promoted { color: var(--good); }
#ft .ft-gate .g-closed { color: var(--fg-muted); }
#ft .ft-gate .g-rb { color: var(--bad); }
#ft .ft-ebar { height: 5px; border-radius: 3px; background: var(--border-soft); margin: .4rem 0 .3rem; overflow: hidden; }
#ft .ft-ebar > i { display: block; height: 100%; background: var(--accent); transition: width .6s ease; }
#ft .ft-gline { font-family: var(--mono); font-size: .76rem; color: var(--fg); font-variant-numeric: tabular-nums; margin-top: .2rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.ft-chk { color: var(--good); } .ft-no { color: var(--bad); }
#ft table.ft-cl { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: .78rem; margin: .3rem 0 1rem; }
#ft table.ft-cl th { text-align: left; color: var(--fg-muted); font-weight: 400; font-size: .74rem; text-transform: none; letter-spacing: 0; padding: .3rem .4rem; border-bottom: 1px solid var(--border-soft); }
#ft table.ft-cl td { padding: .3rem .4rem; border-bottom: 1px solid var(--border-soft); color: var(--fg); font-variant-numeric: tabular-nums; }
#ft .ft-prov { display: flex; flex-wrap: wrap; gap: .4rem .5rem; margin: .2rem 0 1rem; }
#ft .ft-prov span { font-family: var(--mono); font-size: .74rem; background: var(--bg); border-radius: var(--radius-sm); padding: .2rem .5rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
#ft .ft-prov b { color: var(--fg); font-weight: 400; }
#ft table.ft-fc { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: .8rem; }
#ft table.ft-fc th { text-align: left; font-weight: 400; color: var(--fg-muted); font-size: .76rem; text-transform: none; letter-spacing: 0; padding: .3rem .5rem; border-bottom: 1px solid var(--border-soft); }
#ft table.ft-fc td { padding: .45rem .5rem; border-bottom: 1px solid var(--border-soft); color: var(--fg); }
.ft-num { font-variant-numeric: tabular-nums; }
.ft-pos { color: var(--good); } .ft-neg { color: var(--bad); }
#ft .ft-badge { font-family: var(--mono); font-size: .68rem; padding: .1rem .5rem; border-radius: 4px; }
#ft .ft-by { background: var(--good-soft); color: var(--good); }
#ft .ft-bn { background: var(--bad-soft); color: var(--bad); }
#ft .ft-bo { background: var(--bg); color: var(--fg-muted); }
#ft .ft-qlink, #ft .ft-trbtn { font-family: var(--mono); font-size: .7rem; padding: 2px 8px; border: 2px solid transparent; border-radius: var(--radius-sm); background: var(--bg); color: var(--fg); text-decoration: none; white-space: nowrap; cursor: pointer; }
#ft .ft-qlink:hover, #ft .ft-trbtn:hover { border-color: var(--border); }
#ft .ft-trbtn { background: var(--btn-bg); color: var(--btn-color); }
/* --- folds --- */
#ft .ft-fold { margin-top: 1.5rem; background: var(--card-bg); border-radius: var(--radius-md); padding: 1rem 1.4rem; }
#ft .ft-fold > summary { cursor: pointer; font-family: var(--mono); font-size: .95rem; color: var(--fg); }
#ft .ft-fold[open] > summary { margin-bottom: .75rem; }
#ft .ft-method { position: relative; text-align: center; margin-top: .5rem; }
#ft .ft-method img { max-width: 100%; height: auto; border-radius: var(--radius-md); padding: 1rem; background: var(--bg); cursor: pointer; }
#ft .ft-full-btn { position: absolute; top: 1.25rem; right: 1.25rem; font-family: var(--mono); font-size: .78rem; background: var(--card-bg); border: 2px solid transparent; border-radius: var(--radius-sm); padding: 4px 10px; cursor: pointer; color: var(--fg); }
#ft .ft-full-btn:hover { border-color: var(--border); }
#ft-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 9999; justify-content: center; align-items: center; cursor: pointer; }
#ft-overlay img { max-width: 96%; max-height: 96%; object-fit: contain; background: #fff; border-radius: 8px; }
/* --- overview grid --- */
#ft-ov { display: grid; gap: .9rem; }
#ft-ov .ov-stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: .6rem; }
@media (max-width: 820px) { #ft-ov .ov-stats { grid-template-columns: repeat(3, 1fr); } }
#ft-ov .ov-stat { background: var(--bg); border-radius: var(--radius-md); padding: .7rem .85rem; }
#ft-ov .ov-stat .v { font-family: var(--mono); font-size: 1.2rem; color: var(--fg); font-variant-numeric: tabular-nums; }
#ft-ov .ov-stat .k { font-family: var(--mono); font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); margin-top: .15rem; }
#ft-ov .ov-cols { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
@media (max-width: 820px) { #ft-ov .ov-cols { grid-template-columns: 1fr; } }
#ft-ov .ov-card { background: var(--bg); border-radius: var(--radius-md); padding: .9rem 1.05rem; }
#ft-ov .ov-card h5 { margin: 0 0 .6rem; font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); font-weight: 400; }
#ft-ov .ov-kv { display: flex; flex-wrap: wrap; gap: .4rem .5rem; }
#ft-ov .ov-kv span { font-family: var(--mono); font-size: .76rem; background: var(--card-bg); border-radius: var(--radius-sm); padding: .2rem .5rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
#ft-ov .ov-kv span b { color: var(--fg); font-weight: 400; }
#ft-ov .ov-badges { display: flex; flex-direction: column; gap: .45rem; }
#ft-ov .ov-badge { font-size: .9rem; color: var(--fg); display: flex; align-items: center; gap: .5rem; }
#ft-ov .ov-badge .ok { color: var(--good); }
#ft-ov .ov-last { font-family: var(--mono); font-size: .72rem; color: var(--fg-muted); margin-top: .65rem; font-variant-numeric: tabular-nums; }
#ft-ov .ov-props { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
@media (max-width: 820px) { #ft-ov .ov-props { grid-template-columns: 1fr; } }
#ft-ov .ov-prop { font-size: .9rem; padding: .35rem .1rem; border-bottom: 1px solid var(--border-soft); color: var(--fg); }
#ft-ov .ov-prop .r { color: var(--fg-muted); font-size: .8rem; margin-top: .1rem; }
#ft-ov .ov-acc { color: var(--good); margin-right: .35rem; font-size: .72rem; }
#ft-ov .ov-rej { color: var(--bad); margin-right: .35rem; font-size: .72rem; }
/* --- modals --- */
.ft-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 9000; justify-content: center; align-items: flex-start; padding: 4vh 1rem; backdrop-filter: blur(6px); }
.ft-modal.on { display: flex; }
.ft-modal-panel { position: relative; background: var(--bg); border-radius: var(--radius-lg); padding: 1.5rem 1.7rem; max-height: 88vh; overflow-y: auto; animation: ftmodal .25s ease; }
@keyframes ftmodal { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.ft-help-panel { max-width: 620px; }
.ft-trace-panel { max-width: 900px; width: 100%; }
.ft-modal-x { position: absolute; top: .7rem; right: .85rem; background: none; border: none; font-size: 1.4rem; color: var(--fg-muted); cursor: pointer; line-height: 1; }
.ft-modal-x:hover { color: var(--fg); }
.ft-help-p { color: var(--fg); line-height: 1.65; font-size: .95rem; margin: .6rem 0; }
.ft-help-legend { display: grid; gap: .65rem; margin: 1rem 0; }
.ft-help-legend > div { display: flex; gap: .7rem; align-items: flex-start; font-size: .9rem; color: var(--fg); line-height: 1.5; }
.ft-help-legend i { margin-top: .3rem; }
/* --- trace viewer --- */
#ft-trace-body h3 { margin: 0 0 .2rem; font-family: var(--serif); font-size: 1.1rem; font-weight: 600; line-height: 1.4; }
.ft-tr-meta { display: flex; flex-wrap: wrap; gap: .4rem .5rem; margin: .6rem 0 1rem; }
.ft-tr-meta span { font-family: var(--mono); font-size: .72rem; background: var(--card-bg); border-radius: var(--radius-sm); padding: .2rem .55rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; }
.ft-tr-meta b { color: var(--fg); font-weight: 400; }
.ft-call { background: var(--card-bg); border-radius: var(--radius-md); margin-bottom: .7rem; overflow: hidden; }
.ft-call-h { display: flex; align-items: center; gap: .6rem; padding: .55rem .85rem; font-family: var(--mono); font-size: .8rem; color: var(--fg); }
.ft-call-kind { font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; padding: .12rem .5rem; border-radius: 4px; background: var(--bg); color: var(--fg); }
.ft-call-kind.tool { color: var(--warn); }
.ft-call-dur { margin-left: auto; font-size: .72rem; color: var(--fg-muted); font-variant-numeric: tabular-nums; flex: none; }
.ft-call-b { padding: .6rem .85rem .75rem; background: var(--bg); }
.ft-call-b details { margin: .25rem 0; }
.ft-call-b summary { cursor: pointer; font-family: var(--mono); font-size: .76rem; color: var(--fg); }
.ft-call-err { color: var(--bad); font-family: var(--mono); font-size: .76rem; margin-top: .3rem; }
.ft-msg-role { font-family: var(--mono); font-size: .64rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); margin: .5rem 0 .15rem; }
.ft-tr-rationale { border-left: 3px solid var(--accent); padding: .2rem 0 .2rem .9rem; margin: .6rem 0 1rem; color: var(--fg); font-size: .95rem; line-height: 1.65; white-space: pre-wrap; }
.ft-tr-warn { font-family: var(--mono); font-size: .76rem; color: var(--bad); margin: .4rem 0; }


/* ===== rules for the pages that still carry the pre-redesign markup =====
   Formerly static/site/legacy.css (the old inline <style> of base.html).
   Scope: every page except home sets body class page-<name>; `[class*="page-"] X`
   keeps the old `.legacy X` specificity (0,2,0) and `body[class*="page-"] X`
   the old `body.legacy X` (0,2,1), in the same order, so nothing shifts.
   Old alias tokens are resolved to the lab tokens they pointed at. Delete a
   block once no page-<name> section needs it. */
/* Layout: the old page container, [class*="page-"] now the lab's .wrap measure */
[class*="page-"] .container { max-width: 1200px; margin: 0 auto; padding: 0 5%; }
[class*="page-"] main.wrap > .container { max-width: none; padding: 0; }
/* Typography */
[class*="page-"] h2 {
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--fg);
    margin-bottom: 2rem;
    letter-spacing: -0.02em;
}
[class*="page-"] h4 {
    font-family: var(--mono);
    font-size: 1rem;
    font-weight: 400;
    color: var(--fg);
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}
/* Stat cards */
[class*="page-"] .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 2.5rem; }
[class*="page-"] .stat {
    padding: 1.25rem;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--bg);
}
[class*="page-"] .stat-value {
    font-family: var(--mono);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
[class*="page-"] .stat-label {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--fg-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
/* Tables */
[class*="page-"] thead th {
    text-align: left;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.75rem 0.75rem;
    border-bottom: 1px solid var(--border-soft);
}
[class*="page-"] tbody td {
    padding: 0.75rem 0.75rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: top;
}
[class*="page-"] tbody tr:hover { background-color: var(--card-bg); }
/* Colors */
[class*="page-"] .positive { color: var(--good); }
[class*="page-"] .negative { color: var(--bad); }
[class*="page-"] .muted { color: var(--fg-muted); font-size: 0.75rem; }
/* Badges */
[class*="page-"] .badge {
    display: inline-block;
    font-family: var(--mono);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.03em;
}
[class*="page-"] .badge-yes { background: var(--good-soft); color: var(--good); }
[class*="page-"] .badge-no { background: var(--bad-soft); color: var(--bad); }
[class*="page-"] .badge-won { background: var(--good-soft); color: var(--good); }
[class*="page-"] .badge-lost { background: var(--bad-soft); color: var(--bad); }
[class*="page-"] .badge-cat { background: var(--card-bg); color: var(--fg-muted); }
[class*="page-"] .badge-stoploss { background: var(--bad-soft); color: var(--bad); }
/* Confidence badges — scans whose forecaster drafts reported an
   ordinal label rather than a number are shown as that label, [class*="page-"] because
   the six values the old averaging produced are not a percentage and
   rendering them as one implies precision that was never measured.
   A "low-high" split keeps both words and takes the lower colour. */
[class*="page-"] .conf-low { background: var(--bad-soft); color: var(--bad); }
[class*="page-"] .conf-medium { background: var(--warn-soft); color: var(--warn); }
[class*="page-"] .conf-high { background: var(--good-soft); color: var(--good); }
[class*="page-"] .conf-badge {
    display: inline-block;
    font-family: var(--mono);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
/* Platform badges — the venue a question came from. Colors are the
   venues' own: Kalshi green, [class*="page-"] Polymarket blue (site.css --venue-*). */
[class*="page-"] .badge-platform {
    border: 1px solid transparent;
    font-variant-caps: all-small-caps;
    letter-spacing: 0.06em;
}
[class*="page-"] .badge-platform.kalshi {
    background: var(--venue-kalshi-soft);
    color: var(--venue-kalshi);
    border-color: var(--venue-kalshi-soft);
}
[class*="page-"] .badge-platform.polymarket {
    background: var(--venue-polymarket-soft);
    color: var(--venue-polymarket);
    border-color: var(--venue-polymarket-soft);
}
/* Edge bar */
[class*="page-"] .edge-bar {
    display: inline-block;
    height: 6px;
    border-radius: 3px;
    min-width: 4px;
}
[class*="page-"] .edge-bar.pos { background: var(--accent); }
[class*="page-"] .edge-bar.neg { background: var(--bad); }
/* Empty state */
[class*="page-"] .empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--fg-muted);
    font-size: 0.9rem;
}
[class*="page-"] .empty code {
    background: var(--card-bg);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}
/* Expandable rationale */
[class*="page-"] .rationale-toggle {
    display: inline;
    margin-top: 0.35rem;
}
[class*="page-"] .rationale-toggle summary {
    display: inline-block;
    cursor: pointer;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--accent);
    border-radius: 4px;
    margin-top: 0.35rem;
    user-select: none;
}
[class*="page-"] .rationale-toggle summary:hover {
    background: var(--accent);
    color: var(--bg);
}
[class*="page-"] .rationale-toggle[open] summary {
    margin-bottom: 0.5rem;
}
[class*="page-"] .rationale-full {
    font-size: 0.8rem;
    color: var(--fg);
    line-height: 1.65;
    padding: 0.75rem;
    background: var(--card-bg);
    border-radius: 6px;
    margin-top: 0.25rem;
}
/* Charts */
[class*="page-"] .chart-container {
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: var(--card-bg);
}
[class*="page-"] .chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
[class*="page-"] .chart-title {
    font-family: var(--mono);
    font-size: 0.85rem;
    color: var(--fg);
}
/* Time range toggle */
[class*="page-"] .time-toggle { display: flex; gap: 0.25rem; }
[class*="page-"] .time-toggle button {
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-family: var(--mono);
    color: var(--fg);
    cursor: pointer;
    transition: all 0.15s;
}
[class*="page-"] .time-toggle button:hover { border-color: var(--border); }
[class*="page-"] .time-toggle button.active { background: var(--btn-bg); color: var(--btn-color); }
/* Hero section (pre-redesign pages; .hero.lab is the new card) */
[class*="page-"] .hero:not(.lab) {
    text-align: center;
    padding: 2rem 0 3rem;
}
[class*="page-"] .hero:not(.lab) h1 {
    font-size: 2rem;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}
[class*="page-"] .hero:not(.lab) p {
    color: var(--fg-muted);
    font-size: 1rem;
    max-width: 500px;
    margin: 0 auto;
}
/* Section */
[class*="page-"] .section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}
[class*="page-"] .section-header h4 { margin: 0; }
[class*="page-"] .section-header a {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--fg);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
}
[class*="page-"] .section-header a:hover { color: var(--accent); border-color: var(--accent); }
/* About page */
[class*="page-"] .about-content { max-width: 700px; }
[class*="page-"] .about-content h3 {
    font-size: 1.1rem;
    margin: 2rem 0 0.75rem;
    color: var(--fg);
}
[class*="page-"] .about-content p {
    color: var(--fg);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.75;
}
/* Mobile responsive (pre-redesign pages) */
@media (max-width: 768px) {
    [class*="page-"] .hero:not(.lab) h1 { font-size: 1.4rem; }
    [class*="page-"] .hero:not(.lab) p { font-size: 0.85rem; }
    [class*="page-"] .stats { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
    [class*="page-"] .stat { padding: 1rem; }
    [class*="page-"] .stat-value { font-size: 1.2rem; }
    /* cells wrap now, so a table may shrink to the viewport; the expansion row inherits that width */
    [class*="page-"] .table-wrap table { min-width: 0; }
    [class*="page-"] .chart-container { padding: 1rem; }
    [class*="page-"] .chart-header { flex-direction: column; gap: 0.75rem; align-items: flex-start; }
    [class*="page-"] .section-header { flex-direction: column; gap: 0.5rem; }
    [class*="page-"] h2, [class*="page-"] main > h1 { font-size: 1.25rem; }
    [class*="page-"] .trade-expand-grid { grid-template-columns: 1fr !important; }
}
@media (max-width: 480px) {
[class*="page-"] .stats { grid-template-columns: 1fr 1fr; }
[class*="page-"] .time-toggle { flex-wrap: wrap; }
[class*="page-"] .hero:not(.lab) h1 { font-size: 1.4rem; }
[class*="page-"] .hero:not(.lab) p { font-size: 0.8rem; padding: 0 0.5rem; }
[class*="page-"] .scan-detail-cards { grid-template-columns: 1fr 1fr !important; }
}


/* -- Polish ---------------------------------------------------
   Applied on top of the rules above at body[class*="page-"] specificity:
   page titles, tiles, pills, inputs, cards, tables in the lab
   language, without touching each page's markup. */
body[class*="page-"] h2, body[class*="page-"] main > h1 { font-family: var(--mono); font-size: 1.5rem; font-weight: 400; letter-spacing: -0.02em; line-height: 1.2; margin: 0 0 1.25rem; }
body[class*="page-"] h2::after, body[class*="page-"] main > h1::after { content: ""; display: block; width: 52px; height: 5px; background: var(--accent); border-radius: 3px; margin-top: 0.6rem; }
body[class*="page-"] h2 + p.muted, body[class*="page-"] h2 + .muted { font-family: var(--serif); font-size: 0.95rem; color: var(--fg-muted); max-width: 66ch; }
body[class*="page-"] h3 { font-family: var(--mono); font-weight: 400; font-size: 1.05rem; }
body[class*="page-"] h4 { font-family: var(--mono); font-size: 1rem; font-weight: 400; margin: 1.75rem 0 0.6rem; }
body[class*="page-"] .section-header { margin-top: 2.25rem; margin-bottom: 1rem; }
body[class*="page-"] .section-header a { font-family: var(--mono); font-size: 0.85rem; color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--border); }
body[class*="page-"] .section-header a:hover { color: var(--accent); border-color: var(--accent); }
/* tiles */
    body[class*="page-"] .stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.85rem; margin-bottom: 1.5rem; }
body[class*="page-"] .stats.stats-4 { grid-template-columns: repeat(4, 1fr); margin-bottom: 0.85rem; }
body[class*="page-"] .stats.stats-4 + .stats.stats-4 { margin-bottom: 1.5rem; }
@media (max-width: 760px) {
body[class*="page-"] .stats.stats-4 { grid-template-columns: 1fr 1fr; }
}
body[class*="page-"] .stat { background: var(--card-bg); border: 0; border-radius: var(--radius-md); padding: 1.1rem 1.15rem 1rem; min-width: 0; overflow: hidden; }
body[class*="page-"] .stat-value { font-family: var(--mono); font-weight: 400; font-size: clamp(0.95rem, 0.5rem + 0.85vw, 1.4rem); letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
body[class*="page-"] .stat-label { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted); margin-top: 0.3rem; }
/* filter pills, body[class*="page-"] inputs, body[class*="page-"] selects, body[class*="page-"] buttons */
    body[class*="page-"] .chip, body[class*="page-"] a.chip, body[class*="page-"] button.chip { display: inline-flex; align-items: center; font-family: var(--mono); font-size: 0.8rem; padding: 4px 11px; border: 2px solid transparent; border-radius: var(--radius-sm); background: var(--card-bg); color: var(--fg); text-decoration: none; cursor: pointer; font-weight: 400; line-height: 1.5; transition: none; }
body[class*="page-"] .chip:hover { border-color: var(--border); color: var(--fg); background: var(--card-bg); }
body[class*="page-"] .chip.active { background: var(--btn-bg); color: var(--btn-color); border-color: transparent; }
body[class*="page-"] input[type="text"], body[class*="page-"] input[type="search"], body[class*="page-"] input[type="password"], body[class*="page-"] select, body[class*="page-"] .open-sort-select, body[class*="page-"] .scan-search-input {
        font-family: var(--mono); font-size: 0.82rem; color: var(--fg); background: var(--card-bg); border: 2px solid transparent; border-radius: var(--radius-sm); padding: 6px 12px; outline: none; }
body[class*="page-"] input[type="text"]:focus, body[class*="page-"] input[type="search"]:focus, body[class*="page-"] input[type="password"]:focus, body[class*="page-"] select:focus, body[class*="page-"] .scan-search-input:focus { border-color: var(--border); }
body[class*="page-"] input::placeholder { color: var(--fg-muted); }
body[class*="page-"] .show-all-btn, body[class*="page-"] .card-action-expand, body[class*="page-"] .time-toggle button, body[class*="page-"] button.chip {
        font-family: var(--mono); font-size: 0.8rem; font-weight: 400; border: 2px solid transparent; border-radius: var(--radius-sm); background: var(--card-bg); color: var(--fg); cursor: pointer; transition: none; }
body[class*="page-"] .show-all-btn:hover, body[class*="page-"] .card-action-expand:hover { border-color: var(--border); color: var(--fg); background: var(--card-bg); }
body[class*="page-"] .time-toggle button.active { background: var(--btn-bg); color: var(--btn-color); }
/* cards: soft, body[class*="page-"] no borders, body[class*="page-"] no color rails */
    body[class*="page-"] .conviction-card, body[class*="page-"] .trade-card, body[class*="page-"] .card-expand, body[class*="page-"] .mq-section, body[class*="page-"] .chart-block, body[class*="page-"] .chart-tile, body[class*="page-"] .team-card {
        background: var(--card-bg); border: 0; border-radius: var(--radius-md); box-shadow: none; }
body[class*="page-"] .conviction-card:hover, body[class*="page-"] .trade-card:hover, body[class*="page-"] .team-card:hover { border: 0; transform: none; box-shadow: 0 0 0 2px var(--border-soft) inset; }
body[class*="page-"] .trade-card { display: flex; flex-direction: column; }
body[class*="page-"] .mq-evidence-item { background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
body[class*="page-"] .chart-container { background: var(--card-bg); border: 0; border-radius: var(--radius-md); }
body[class*="page-"] .conviction-card-title, body[class*="page-"] .scan-row-title { font-family: var(--serif); font-size: 0.96rem; font-weight: 600; }
body[class*="page-"] .conviction-card-edge, body[class*="page-"] .scan-row-edge-value { font-family: var(--mono); font-weight: 400; font-variant-numeric: tabular-nums; }
/* tables: ledger language; wrapping stays on (these cells carry prose) */
    body[class*="page-"] thead th { font-family: var(--mono); font-size: 0.78rem; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--fg-muted); padding: 0.55rem 0.75rem; border-bottom: 1px solid var(--border-soft); white-space: nowrap; }
body[class*="page-"] tbody td { font-family: var(--mono); font-size: 0.78rem; padding: 0.55rem 0.7rem; white-space: normal; }
body[class*="page-"] td.h, body[class*="page-"] td.h a { font-family: var(--serif); font-size: 0.92rem; line-height: 1.4; color: var(--fg); text-decoration: none; }
body[class*="page-"] td.h a:hover { text-decoration: underline; }
body[class*="page-"] .badge, body[class*="page-"] .conf-badge { font-family: var(--mono); font-weight: 400; }
/* scan detail stages */
    body[class*="page-"] details > summary.stage { font-family: var(--mono); font-size: 0.98rem; color: var(--fg); cursor: pointer; padding: 0.85rem 0; border-bottom: 1px solid var(--border-soft); list-style: none; }
body[class*="page-"] details > summary.stage::before { content: "▸ "; color: var(--fg-muted); }
body[class*="page-"] details[open] > summary.stage::before { content: "▾ "; }
body[class*="page-"] .stage-body { padding: 1rem 0 1.25rem; font-size: 0.95rem; }
/* trace kit: each stage is a card; inside, body[class*="page-"] panels sit on --bg, body[class*="page-"] quotes carry a rule, body[class*="page-"] labels are mono */
    body[class*="page-"] details.stage-card { background: var(--card-bg); border-radius: var(--radius-md); padding: 0 1.4rem; margin-bottom: 0.75rem; }
body[class*="page-"] details.stage-card > summary.stage { border-bottom: 0; padding: 0.95rem 0; }
body[class*="page-"] details.stage-card[open] > summary.stage { border-bottom: 1px solid var(--border-soft); }
body[class*="page-"] .sub { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted); margin: 0 0 0.5rem; }
body[class*="page-"] .prose { font-family: var(--serif); font-size: 0.95rem; line-height: 1.65; color: var(--fg); }
body[class*="page-"] .quote { border-left: 3px solid var(--accent); padding: 0.15rem 0 0.15rem 1rem; margin: 0.5rem 0 1rem; }
body[class*="page-"] .quote .sub { margin-bottom: 0.3rem; }
body[class*="page-"] .panel { background: var(--bg); border-radius: var(--radius-md); padding: 0.9rem 1rem; margin-bottom: 0.75rem; }
body[class*="page-"] .panel.mini { text-align: center; padding: 0.75rem; margin: 0; }
body[class*="page-"] .panel.mono-block { font-family: var(--mono); font-size: 0.8rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--fg); }
body[class*="page-"] .mini-v { font-family: var(--mono); font-size: 1.3rem; color: var(--fg); font-variant-numeric: tabular-nums; }
body[class*="page-"] .headline { font-family: var(--mono); font-size: 1.6rem; color: var(--fg); margin-bottom: 0.75rem; font-variant-numeric: tabular-nums; }
body[class*="page-"] .more-link { cursor: pointer; font-family: var(--mono); font-size: 0.8rem; color: var(--fg); }
body[class*="page-"] .more-link:hover { color: var(--accent); }
body[class*="page-"] .stage-body table { font-size: 0.8rem; }
/* home-style position cards on these pages: keep the serif title despite the mono h3 rule above */
    body[class*="page-"] .pcard h3 { font-family: var(--serif); font-weight: 600; font-size: 1.02rem; line-height: 1.35; letter-spacing: 0; margin: 0; }
body[class*="page-"] .card { background: var(--card-bg); border: 0; border-radius: var(--radius-md); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
body[class*="page-"] .card > .card-title { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-muted); margin-bottom: 0.5rem; }
body[class*="page-"] .tag { margin-right: 0.3rem; }
body[class*="page-"] .back { font-family: var(--mono); font-size: 0.82rem; color: var(--fg-muted); text-decoration: none; }
body[class*="page-"] .back:hover { color: var(--accent); }


/* -- Inline-style replacements (phase 4) ------------------------------
   Classes standing in for the templates' former style="…" attributes
   that carried colors. Nested under body[class*="page-"] and placed last in the
   cascade so they keep the precedence those inline styles had. */
body[class*="page-"] .t-pos { color: var(--good); }
body[class*="page-"] .t-neg { color: var(--bad); }
body[class*="page-"] .t-warn { color: var(--warn); }
body[class*="page-"] .t-ink { color: var(--fg); }
body[class*="page-"] .t-muted2 { color: var(--fg); }
body[class*="page-"] .tone-low { color: var(--bad); }
body[class*="page-"] .tone-medium { color: var(--warn); }
body[class*="page-"] .tone-high { color: var(--good); }
body[class*="page-"] .tone-bg-low { background: var(--bad); }
body[class*="page-"] .tone-bg-medium { background: var(--warn); }
body[class*="page-"] .tone-bg-high { background: var(--good); }
body[class*="page-"] .cap { text-transform: capitalize; }
body[class*="page-"] .card.card-archived { background: var(--bg-archived); color: var(--archived-text); font-size: 0.9rem; }
body[class*="page-"] .conf-track { margin: 0.3rem 0; height: 4px; background: var(--border-soft); border-radius: 2px; overflow: hidden; }
body[class*="page-"] .conf-mini { width: 50px; height: 4px; background: var(--border-soft); border-radius: 2px; overflow: hidden; }
body[class*="page-"] .bar-track { flex: 1; height: 8px; background: var(--border-soft); border-radius: 4px; overflow: hidden; }
body[class*="page-"] .conf-track > .fill, body[class*="page-"] .conf-mini > .fill, body[class*="page-"] .bar-track > .fill { height: 100%; }
body[class*="page-"] .conf-pct { font-family: var(--mono); font-size: 0.8rem; }
body[class*="page-"] .bar-pct { font-weight: 600; font-size: 1rem; }
body[class*="page-"] td.cell-note { font-size: 0.85rem; color: var(--fg); max-width: 480px; }
body[class*="page-"] td.expand-cell { padding: 0; background: var(--card-bg); }
body[class*="page-"] .err-note { margin-top: 0.75rem; font-size: 0.85rem; color: var(--bad); }
body[class*="page-"] .cred { font-weight: 500; font-size: 0.85rem; }
body[class*="page-"] .dir { font-weight: 500; }
body[class*="page-"] .note-lg { font-size: 0.85rem; color: var(--fg); line-height: 1.8; }
body[class*="page-"] .note-pad { padding: 0.75rem 0; font-size: 0.85rem; color: var(--fg); line-height: 1.7; }
body[class*="page-"] .note-top { margin-top: 1rem; font-size: 0.9rem; color: var(--fg); }
body[class*="page-"] .note-sm { font-size: 0.9rem; color: var(--fg); }
body[class*="page-"] .strong-ink { font-weight: 500; color: var(--fg); }
body[class*="page-"] .prose-muted { color: var(--fg); line-height: 1.7; }
body[class*="page-"] .figure-v { font-family: var(--mono); font-size: 1.2rem; font-weight: 400; margin-top: 0.25rem; color: var(--fg); font-variant-numeric: tabular-nums; }
body[class*="page-"] .flag { font-size: 0.75rem; padding: 2px 8px; border-radius: 10px; margin-left: 0.5rem; }
body[class*="page-"] .flag-neg { background: var(--bad-soft); color: var(--bad); }
body[class*="page-"] .flag-pos { background: var(--good-soft); color: var(--good); }
body[class*="page-"] .load-error { color: var(--bad); text-align: center; padding: 1rem; }
body[class*="page-"] .edge-neg { border-color: var(--bad); }
body[class*="page-"] h4.sub-h { margin: 0 0 0.5rem; font-size: 0.8rem; color: var(--fg-muted); }
body[class*="page-"] h4.sub-h.gap { margin-top: 1.5rem; }
body[class*="page-"] h4.sub-h.gap-sm { margin-top: 1.25rem; }
body[class*="page-"] ul.sub-list { font-size: 0.8rem; padding-left: 1.25rem; color: var(--fg); }
body[class*="page-"] .link-accent { color: var(--accent); cursor: pointer; }
body[class*="page-"] .link-accent.strong { font-weight: 500; }
body[class*="page-"] a.link-quiet { color: var(--fg-muted); text-decoration: none; }
body[class*="page-"] p.muted-p { color: var(--fg); }
body[class*="page-"] ol.muted-list { color: var(--fg); line-height: 1.7; }
body[class*="page-"] p.fine-print { margin-top: 2rem; color: var(--fg-muted); font-size: 0.8rem; }
body[class*="page-"] input.input-bg { background: var(--bg); }
body[class*="page-"] .status-note { flex-basis: 100%; font-size: 0.82rem; color: var(--fg); }

/* ==========================================================================
   print: paper is white whatever the stored theme, so the dark stamp is
   overridden with the lab's light tokens (values from lab-tokens.css); the
   chrome, the hero wash and the theme toggle don't print.
   ========================================================================== */
@media print {
  :root, :root[data-theme="dark"], :root:not([data-theme="light"]) {
    color-scheme: light;
    --bg: #ffffff; --fg: #2c2c2c; --fg-muted: #6b7280; --ink-strong: #0d0d0d; --link: #0d0d0d;
    --card-bg: #f3f3f3; --border-soft: #e5e7eb; --border: rgb(75 85 99); --btn-bg: #0d0d0d; --btn-color: #fdfdfd;
    --accent: #3C81F7; --accent-soft: rgba(60, 129, 247, 0.12); --accent-ink: #2258C4;
    --good: #157A4C; --warn: #B7791F; --bad: #B3261E; --mark: #AEB6C2; --grid: rgba(44, 44, 44, 0.08);
    --venue-kalshi: #0B7050; --venue-kalshi-soft: rgba(11, 112, 80, 0.14);
    --venue-polymarket: #2258C4; --venue-polymarket-soft: rgba(34, 88, 196, 0.12);
    --bg-archived: #fff8e6; --archived-text: #5a4510; --archived-border: #e0b050;
  }
  html, body { background: #fff !important; color: #2c2c2c !important; }
  header.lab, footer.lab, nav.lab, .menu-btn, #theme-toggle, canvas.wash, .chart-wrap .tip, .pager, .ranges { display: none !important; }
  main.wrap { max-width: none; }
  .hero.lab, .chart-card, .tile, .pcard, .card { break-inside: avoid; box-shadow: none; }
  a { color: inherit; }
}
