/* Ezra v10 design tokens.
 *
 * Dark is the default (it matches the EZPZ admin layout, the v9 :root tokens).
 * Light applies on any ancestor with data-theme="light" (the templates and
 * ezra-chat only ever set "light" or "dark"). Chart colours are read from these
 * variables at render time (lib/theme.js), so both themes stay in one place.
 *
 * Colour tokens follow Radix Colors step semantics (comments name the step):
 *   1-2  app / subtle backgrounds      (--bg, --bg2)
 *   3-5  component backgrounds         (--bg3 normal, --bg4 hover / pressed, --card / --card-2)
 *   6-8  borders and focus             (--border subtle, --border2 normal, --ring focus)
 *   9-10 solid fills                   (--p, --p-h hover; --bull, --bear, --amber fills)
 *   11   low-contrast text >= 4.5:1    (--muted, --faint, --p-text, --*-text)
 *   12   high-contrast text            (--text, --bright)
 * Contrast (WCAG, checked against --bg / --card / --card-2 in both themes):
 *   --text >= 12.6, --muted >= 6.4 (dark) / 7.2 (light), --faint >= 4.9 / 5.1,
 *   --amber-text >= 8.0 / 6.6, --p-text >= 8.2 / 6.4, --ring >= 6.4 / 5.8 (non-text, needs 3).
 *
 * Categorical palette: validated with the dataviz skill's validate_palette.js
 *   dark  (surface #161622): #7c6ff0,#d95926,#199e70,#c98500,#d55181,#3987e5 -> all checks pass
 *   light (surface #ffffff): #5b4dc9,#eb6834,#1baf7a,#eda100,#e87ba4,#2a78d6 -> pass, contrast WARN
 *   on slots 3-5 (relief: legend + direct labels + view-as-table on every chart).
 *
 * Bull / bear and the price-level colours (--level-*, one per LEVEL_STYLE token in
 * lib/theme.js) match the EZPZ website on dark: GEX/call #4cd68f, GEX/put #e24e4c,
 * price line yellow, max pain O/P/V purple / cyan / green. Light steps the same
 * hues darker so every line clears 3:1 on the white card (spot #b58100 = 3.44:1;
 * every other light level >= 4.1:1). Validated all-pairs with validate_palette.js:
 *   gamma set (call, put, flip, spot, max pain): dark PASS (CVD 9.5, normal 19.4);
 *     light CVD 6.3 floor (the red/green pair itself), normal 18.3 PASS
 *   S/R set (+ support, resistance): dark PASS (8.7 / 18.5); light 6.3 floor / 18.3
 *   plan set (entry, stop, target, spot): dark PASS; light 6.3 floor / 18.3
 * Floor-band pairs are legal only with secondary encoding: every level line carries
 * its label (axis chip + line title), dashes differ by kind, and rows print the kind.
 * Text never wears a level colour (labels use --text / --muted; chips use the
 * on-colour from theme.js onColor(), >= 4.5:1). Amber text uses --amber-text, never --amber.
 *
 * Scales (Tailwind-style; use the token, not a raw value):
 *   type     --fs-11 12 13 14 15 17 20 28 (16px stays literal on inputs: iOS zooms below it)
 *   weight   400 / 500 / 600 / 700 only
 *   leading  --lh-tight 1.2, --lh-snug 1.4, --lh-normal 1.6, --lh-prose 1.7
 *   control  --ctl-h-sm 28, --ctl-h 32, --ctl-h-lg 40 (heights); --track-caps .06em (uppercase labels)
 *   space    4px grid: --sp-1 4, --sp-2 8, --sp-3 12, --sp-4 16, --sp-5 20, --sp-6 24, --sp-8 32
 *            (2 / 6 / 10 / 14 half steps allowed; 1px only for hairlines and optical offsets)
 *   radius   --r-xs 6, --r-sm 8, --r 12 (cards, overlays), --r-lg 16 (sheets), --r-full (chips)
 *   motion   --dur-fast 120ms, --dur 180ms, --dur-slow 240ms, --ease, --ease-out
 *   z        --z-local-1..3, --z-shell 40, --z-drawer 50, --z-popover 2000, --z-modal 2050,
 *            --z-menu 2100, --z-sheet-toast 2900, --z-toast 3000
 */
.ezra-root {
  color-scheme: dark;
  /* brand: step 9-10 solid, step 11 text, washes for steps 3-5 */
  --p:        #6759d1;   /* 9 */
  --p-h:      #5548c1;   /* 10 */
  --p-text:   #b3a9ff;   /* 11 */
  --on-p:     #ffffff;   /* text / icons on --p fills: 5.4:1 on #6759d1 (both themes share --p) */
  --p1:       rgba(103, 89, 209, .08);   /* 3 */
  --p2:       rgba(103, 89, 209, .16);   /* 4 */
  --p3:       rgba(103, 89, 209, .28);   /* 6 */
  /* surfaces: steps 1-5 */
  --bg:       #111118;   /* 1 app */
  --bg2:      #161622;   /* 2 subtle */
  --bg3:      #1a1a26;   /* 3 component */
  --bg4:      #222232;   /* 4 component hover */
  --card:     #161622;   /* 2 raised */
  --card-2:   #1a1a26;   /* 3 overlay */
  --overlay:  rgba(10, 10, 16, .72);
  /* borders + focus: steps 6-8 */
  --border:   rgba(255, 255, 255, .07);   /* 6 */
  --border2:  rgba(255, 255, 255, .12);   /* 7 */
  --ring:     #9d92f5;                    /* 8 focus, 6.4:1+ */
  /* ink: steps 11-12 */
  --text:     #dcdce8;                    /* 12 */
  --bright:   #f0f0f8;                    /* 12 */
  --muted:    rgba(180, 175, 215, .86);   /* 11, >= 5.9:1 on --bg .. --bg4 */
  --faint:    rgba(180, 175, 215, .72);   /* 11 low, >= 4.5:1 on --bg .. --bg4 */
  /* semantic: fills (9) and text (11) */
  --green:    #10b981;
  --green2:   #34d399;
  --red:      #ef4444;
  --red2:     #f87171;
  --amber:    #f59e0b;   /* fills, dots, borders */
  --amber-text: #f59e0b; /* 8.0:1 on --card-2 */
  --cyan:     #38bdf8;
  --purple:   #a78bfa;
  --bull:     #4cd68f;   /* website GEX positive / calls */
  --bear:     #e24e4c;   /* website GEX negative / puts */
  --bull-text: #4cd68f;  /* 9.7:1 on --card */
  --bear-text: #f07472;  /* 6.3:1 on --card */
  --bull-wash: rgba(76, 214, 143, .12);
  --bear-wash: rgba(226, 78, 76, .12);
  --amber-wash: rgba(245, 158, 11, .12);
  --live:     #10b981;
  --stale:    #f59e0b;
  --closed:   #7c7c94;
  /* chart chrome */
  --grid:     rgba(255, 255, 255, .055);
  --axis:     rgba(255, 255, 255, .14);
  --axis-text: rgba(180, 175, 215, .62);
  --skeleton: rgba(255, 255, 255, .045);
  --skeleton-hi: rgba(255, 255, 255, .085);
  --div-mid:  #2e2e3e;     /* diverging midpoint (neutral) */
  /* price levels (LEVEL_STYLE tokens, lib/theme.js) */
  --level-call:       var(--bull);
  --level-put:        var(--bear);
  --level-target:     var(--bull);
  --level-stop:       var(--bear);
  --level-entry:      #3987e5;
  --level-spot:       #facc15;   /* the site's yellow price line, softened for dark UI */
  --level-flip:       #e2e8f0;
  --level-maxpain:    #a78bfa;   /* O-Max Pain (open interest) */
  --level-maxpain-p:  #67e8f9;   /* P-Max Pain (premium) */
  --level-maxpain-v:  #4ade80;   /* V-Max Pain (volume) */
  --level-support:    #38bdf8;
  --level-resistance: #d946ef;
  --level-darkpool:   #fb923c;
  --level-vwap:       #2dd4bf;
  --level-em:         #f59e0b;
  --level-custom:     #8a889c;
  /* categorical slots (fixed order, never cycled) */
  --s1: #7c6ff0; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #3987e5;
  /* sequential (violet, light->dark on light; dark->light on dark surfaces) */
  --seq-0: #252340; --seq-1: #3a3473; --seq-2: #5246a8; --seq-3: #7c6ff0; --seq-4: #b3a9ff;

  /* type */
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --fs-11: 11px;
  --fs-12: 12px;
  --fs-13: 13px;
  --fs-14: 14px;
  --fs-15: 15px;
  --fs-16: 16px;
  --fs-17: 17px;
  --fs-20: 20px;
  --fs-28: 28px;
  --fs-hero:    var(--fs-28);
  --fs-metric:  var(--fs-20);
  --fs-body:    var(--fs-15);
  --fs-prose:   var(--fs-16);   /* answer text: the 16px reading size of ChatGPT / Claude answers */
  --fs-title:   var(--fs-14);
  --fs-label:   var(--fs-12);
  --fs-caption: var(--fs-11);
  --lh-tight:  1.2;
  --lh-snug:   1.4;
  --lh-normal: 1.6;
  --lh-prose:  1.7;
  /* space (4px grid) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
  /* control heights (css/ezra-ui.css: buttons, inputs, selects, segments) + caps tracking; both themes */
  --ctl-h-sm: 28px;
  --ctl-h:    32px;
  --ctl-h-lg: 40px;
  --track-caps: .06em;
  /* shape */
  --r-xs:   6px;
  --r-sm:   8px;
  --r:      12px;
  --r-lg:   16px;
  --r-full: 999px;
  /* elevation */
  --shadow-1: 0 1px 0 rgba(255,255,255,.03) inset, 0 8px 24px rgba(0,0,0,.28);   /* cards */
  --shadow-2: 0 1px 2px rgba(0,0,0,.25);                                          /* selected segment */
  --shadow-pop: 0 12px 40px rgba(0,0,0,.5);                                       /* popovers, menus, sheets */
  --shadow: var(--shadow-1);
  --focus-halo: 0 0 0 3px var(--p2);
  /* scrollbars + native-control chrome (ezra.css) */
  --scroll-thumb:       rgba(220, 220, 232, .16);
  --scroll-thumb-hover: rgba(220, 220, 232, .30);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b4afd7' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  /* motion */
  --dur-fast: 120ms;
  --dur:      180ms;
  --dur-slow: 240ms;
  --ease:     cubic-bezier(.2, .7, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  /* stacking */
  --z-local-1: 1;
  --z-local-2: 2;
  --z-local-3: 3;
  --z-shell:   40;
  --z-drawer:  50;
  --z-popover: 2000;
  --z-modal:   2050;
  --z-menu:    2100;
  --z-sheet-toast: 2900;   /* the save card (bottom sheet on phones) */
  --z-toast:   3000;       /* generic toast: above the save card. A showModal() <dialog> sits in the top layer above any z-index. */
}

.ezra-root[data-theme="light"] {
  color-scheme: light;
  --p-text:   #5546c4;
  --bg:       #f6f6fa;
  --bg2:      #ffffff;
  --bg3:      #f3f3f8;
  --bg4:      #ebebf3;
  --card:     #ffffff;
  --card-2:   #f7f7fb;
  --overlay:  rgba(246, 246, 250, .8);
  --border:   rgba(20, 20, 40, .08);
  --border2:  rgba(20, 20, 40, .14);
  --ring:     #5b4dc9;
  --text:     #23232f;
  --bright:   #0e0e16;
  --muted:    #525066;   /* >= 6.5:1 on --bg .. --bg4 */
  --faint:    #68667a;   /* >= 4.7:1 on --bg .. --bg4 */
  --amber-text: #92400e; /* >= 6.0:1 on --bg .. --bg4 and on --amber-wash */
  --bull:     #14864f;   /* website green, stepped for white (4.6:1) */
  --bear:     #b91c1c;   /* website red, stepped for white (6.5:1) */
  --bull-text: #047857;
  --bear-text: #b91c1c;
  --bull-wash: rgba(20, 134, 79, .10);
  --bear-wash: rgba(185, 28, 28, .08);
  --amber-wash: rgba(245, 158, 11, .12);
  --closed:   #8a889c;
  --grid:     rgba(20, 20, 40, .06);
  --axis:     rgba(20, 20, 40, .16);
  --axis-text: #6f6d82;  /* >= 4.6:1 on --bg .. --card */
  --skeleton: rgba(20, 20, 40, .05);
  --skeleton-hi: rgba(20, 20, 40, .09);
  --div-mid:  #ececf2;
  --level-entry:      #1e68c4;
  --level-spot:       #b58100;
  --level-flip:       #334155;
  --level-maxpain:    #7c3aed;
  --level-maxpain-p:  #0284c7;
  --level-maxpain-v:  #15803d;
  --level-support:    #0284c7;
  --level-resistance: #9333ea;
  --level-darkpool:   #c2410c;
  --level-vwap:       #0f766e;
  --level-em:         #b45309;
  --level-custom:     #646276;
  --s1: #5b4dc9; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #2a78d6;
  --seq-0: #ecebfb; --seq-1: #c9c3f5; --seq-2: #9a8fea; --seq-3: #6a5bd8; --seq-4: #3d2f9e;
  --shadow-1: 0 1px 2px rgba(20,20,40,.05), 0 6px 20px rgba(20,20,40,.06);
  --shadow-2: 0 1px 2px rgba(20,20,40,.12);
  --shadow-pop: 0 12px 36px rgba(20,20,40,.16);
  --focus-halo: 0 0 0 3px rgba(91, 77, 201, .18);
  --scroll-thumb:       rgba(35, 35, 47, .16);
  --scroll-thumb-hover: rgba(35, 35, 47, .30);
  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23525066' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

@media (forced-colors: active) {
  .ezra-root { --border: CanvasText; --border2: CanvasText; --ring: Highlight; --scroll-thumb: CanvasText; --scroll-thumb-hover: Highlight; }
}
