/* The site's ONLY colour literals. Every page, template and chart script uses
   these names; a hex or rgb() anywhere else fails
   tests/surfaces/web/test_theme_tokens.py. Light is the first block, dark the
   second — `js/theme.js` sets <html data-theme> (system setting by default,
   🌓 overrides) before first paint. Need a tint? Derive it:
   `color-mix(in srgb, var(--up) 12%, var(--bg))`. Need a genuinely new
   colour? Add it here, in BOTH blocks. */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #fff;            /* page */
  --bg-soft: #fafafa;    /* sidebar, table stripes, quiet panels */
  --bg-elev: #fff;       /* cards, popovers, dialogs, inputs */
  --bg-sunk: #f4f5f6;    /* wells, code, disabled */
  --bg-hover: #f1f1f1;
  --sel-bg: #e9eaec;     /* selected control */
  --sel-border: #c7cace;

  /* Text */
  --text-strong: #111;
  --text: #222;
  --text-2: #555;        /* secondary copy */
  --muted: #888;
  --faint: #bbb;         /* placeholders, disabled, dividers-as-text */
  --on-fill: #fff;       /* text on a solid up/down/accent/info fill */

  /* Lines */
  --border: #e5e5e5;
  --border-strong: #ccc;

  /* Meaning */
  --accent: #4a7;
  --up: #16a34a;
  --up-strong: #15803d;  /* green text on a tinted green background */
  --down: #dc2626;
  --down-strong: #b91c1c;
  --warn: #d97706;
  --warn-strong: #b45309;
  --info: #2563eb;
  --info-strong: #1d4ed8;
  --violet: #7c3aed;
  --violet-strong: #5b21b6;
  /* Percentile-band fills: g1 = extreme decile, g2 = next band. /m/finance's
     SIGNALS + figures table and Fridays' OCEAN. */
  --g1-bg:   color-mix(in srgb, var(--violet) 50%, var(--violet-strong));
  --g1-text: var(--bg);
  --g2-bg:   color-mix(in srgb, var(--violet) 25%, var(--bg));
  --g2-text: color-mix(in srgb, var(--violet-strong) 60%, var(--text-strong));
  --hilite: #ffd479;     /* search-match / attention marker */
  --gold: #e0b000;       /* stars, ratings */
  --shadow: rgba(0, 0, 0, 0.14);
  --backdrop: rgba(0, 0, 0, 0.4);
  --scrim: rgba(0, 0, 0, 0.85);   /* lightbox / image zoom */
  --term-bg: #1c1f24;    /* log / console panels: dark in both themes */
  --term-text: #e6e6e6;

  /* Charts */
  --chart-bg: #fff;
  --chart-grid: #eef0f2;
  --chart-text: #888;
  --chart-border: #d0d4d8;
  --chart-guide: #c8ccd4;   /* dashed reference lines (RSI 30/70, zero) */
  --bb: #d97706;            /* band-width line; the bands themselves below */
  --bb-upper: #d97706;
  --bb-lower: #d97706;
  --bb-mid: #d97706;
  --macd: #2563eb;
  --signal: #d97706;
  --sma: #2563eb;           /* EMA 50 */
  --ema20: #7c3aed;
  --ema9: #eab308;
  /* Fridays chart lines in IBKR's scheme (2026-10-14): both bands one blue,
     SMA(20) green, SMA(9) magenta, SMA(50) a quiet slate behind them. */
  --ma-band: #1e5fd8;
  --ma20: #23893b;
  --ma9: #c026d3;
  --ma50: #94a3b8;
  --ma200: #b45309;          /* the menu's extra lines (chart-ind.js) */
  --ema9: #f97316;
  --ema21: #0891b2;
  --vwap: #7c3aed;
  --ich-t: #0891b2;           /* Ichimoku conversion / base / cloud spans */
  --ich-k: #be123c;
  --ich-a: #16a34a;
  --ich-b: #dc2626;
  --kc: #0d9488;              /* Keltner channel */
  --dc: #6366f1;              /* Donchian channel */
  /* EXT candles (pre/post-market): a muted up/down beside the session's. */
  --squeeze-bg: #f3ecfd;     /* 4h/1d chart background in a BB squeeze */
  --squeeze-grid: #d9d4e2;   /* its grid lines — the plain --chart-grid vanishes on it */
  --up-ext: #8fcfa3;
  --down-ext: #f0a8a8;
  --rsi: #7c3aed;
  /* OCEAN IV vs RV chart */
  --ivrv-iv: #7c3aed; --ivrv-rv20: #ea580c; --ivrv-rv10: #f59e0b; --ivrv-rv60: #64748b; --ivrv-iv30: #0891b2;
  --bbw: #d97706;           /* BB Width bars: widening */
  --bbw-dim: #d9770659;     /* …narrowing (a squeeze = a run of these) */
  --hist-up: rgba(22, 163, 74, 0.55);
  --hist-down: rgba(220, 38, 38, 0.55);

  /* Fridays bar: three families of switch, each its own grey (see fridays.css) */
  --tg-cool-bg: #f3f5f9; --tg-cool-border: #d3d9e3; --tg-cool-sel: #dde3ee; --tg-cool-sel-border: #aeb9cb;
  --tg-warm-bg: #f8f6f2; --tg-warm-border: #e0dad0; --tg-warm-sel: #eae4d9; --tg-warm-sel-border: #c4b8a5;

  /* Annotator ink — burned into saved JPEGs, so the SAME in both themes. */
  --ink-red: #dc2626; --ink-green: #16a34a; --ink-blue: #2563eb; --ink-amber: #d97706;
  --ink-dark: #111; --ink-light: #fff;
}

/* Dark — TradingView-style navy: teal up, red down, blue basis. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #131722;
  --bg-soft: #171b26;
  --bg-elev: #1e222d;
  --bg-sunk: #0f121a;
  --bg-hover: #242936;
  --sel-bg: #2a2e39;
  --sel-border: #434651;

  --text-strong: #eceff4;
  --text: #d1d4dc;
  --text-2: #a3a8b4;
  --muted: #787b86;
  --faint: #4a4e5a;
  --on-fill: #fff;

  --border: #2a2e39;
  --border-strong: #3a3f4c;

  --accent: #26a69a;
  --up: #26a69a;
  --up-strong: #4fc3b5;
  --down: #ef5350;
  --down-strong: #ff7a77;
  --warn: #f0a030;
  --warn-strong: #f5b95a;
  --info: #5b8def;
  --info-strong: #8aaef5;
  --violet: #a78bfa;
  --violet-strong: #c4b5fd;
  /* A solid lavender slab glares on navy: a deep and a faint violet instead. */
  --g1-bg:   color-mix(in srgb, var(--violet) 45%, var(--bg));
  --g1-text: var(--text-strong);
  --g2-bg:   color-mix(in srgb, var(--violet) 20%, var(--bg));
  --g2-text: var(--violet-strong);
  --hilite: #8a6d1f;
  --gold: #f0c419;
  --shadow: rgba(0, 0, 0, 0.5);
  --backdrop: rgba(0, 0, 0, 0.6);
  --scrim: rgba(0, 0, 0, 0.88);
  --term-bg: #0f121a;
  --term-text: #d1d4dc;

  --chart-bg: #131722;
  --chart-grid: #1f2433;
  --chart-text: #8a8f9c;
  --chart-border: #2a2e39;
  --chart-guide: #3a3f4c;
  --bb: #f0a030;
  --bb-upper: #ef5350;
  --bb-lower: #26a69a;
  --bb-mid: #2962ff;
  --macd: #2962ff;
  --signal: #ff9800;
  --sma: #5b8def;
  --ema20: #b388ff;
  --ema9: #fdd835;
  --ma-band: #5b8def;
  --ma20: #4caf50;
  --ma9: #e040fb;
  --ma50: #78909c;
  --ma200: #f59e0b;
  --ema9: #fb923c;
  --ema21: #22d3ee;
  --vwap: #a78bfa;
  --ich-t: #22d3ee;
  --ich-k: #fb7185;
  --ich-a: #4ade80;
  --ich-b: #f87171;
  --kc: #2dd4bf;
  --dc: #818cf8;
  --squeeze-bg: #2a2142;
  --squeeze-grid: #3d3458;
  --up-ext: #2f6b55;
  --down-ext: #7d3d3d;
  --rsi: #b388ff;
  /* OCEAN IV vs RV chart */
  --ivrv-iv: #b388ff; --ivrv-rv20: #fb923c; --ivrv-rv10: #fcd34d; --ivrv-rv60: #94a3b8; --ivrv-iv30: #22d3ee;
  --bbw: #f0a54a;
  --bbw-dim: #f0a54a59;
  --hist-up: rgba(38, 166, 154, 0.55);
  --hist-down: rgba(239, 83, 80, 0.55);

  --tg-cool-bg: #1c2230; --tg-cool-border: #2c3446; --tg-cool-sel: #2a3450; --tg-cool-sel-border: #45547a;
  --tg-warm-bg: #221f1c; --tg-warm-border: #37322b; --tg-warm-sel: #352f27; --tg-warm-sel-border: #5c5040;

  /* Annotator ink — burned into saved JPEGs, so the SAME in both themes. */
  --ink-red: #dc2626; --ink-green: #16a34a; --ink-blue: #2563eb; --ink-amber: #d97706;
  --ink-dark: #111; --ink-light: #fff;
}

/* The 🌓 switch. Any element with [data-theme-toggle] is one; theme.js sets
   its glyph and title. */
.theme-toggle { background: none; border: 1px solid var(--border); color: var(--text-2);
  border-radius: 6px; font: 14px/1 system-ui, sans-serif; padding: 4px 7px; cursor: pointer; }
.theme-toggle:hover { background: var(--bg-hover); color: var(--text); }
