/* Fonts (owner choice, 24 Nov 2026): Instrument Sans (UI + headings) and Geist Mono (figures), self-hosted.
   SIL OFL 1.1: licenses in assets/fonts/OFL-InstrumentSans.txt and OFL-GeistMono.txt. */
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/instrument-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Instrument Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/assets/fonts/instrument-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Geist Mono"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/assets/fonts/geist-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Geist Mono"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/assets/fonts/geist-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
/*
  Met Flipper "Range Atlas" operator skin, phase 1: tokens + global styling (DESIGN-app.md, 23 Nov 2026).
  Loaded right after the inline <style> in index.html. It only remaps the existing CSS variables and re-skins
  existing classes (colour, border, radius, weight, font family). It never changes layout, sizes of hit targets,
  the mobile 16px input rule or sticky footers.

  Feature flag: everything is scoped to html:root. Setting
  document.documentElement.dataset.skin = "legacy" (or removing the <link>) restores the previous look.

  Roles (night | day):
    page #111116 | #F4F1F7      shell #1B1726 | #EDE7F3      panel #17161D | #FFFFFF
    inset/instrument #0F1015 | #F8F6FA                       overlay (dialogs, menus) #24212D | #FFFFFF
    strong / body / muted text  #F7F4FB #DED8E6 #BCAFC9 | #211C29 #38303F #62546F
    separator / control / focus #38333F #897B9C #FFCA9D | #D8D0DF #7D6C87 #854000
    selection / selected fill   #D9CCFF #2A2334 | #594284 #EDE6F7   (active route, selected PK, enabled segment)
    primary action / NOW        #FF985B ink #22140C | #91420B ink #FFFFFF (Review costs, deliberate save; never Close/Stop)
    gain / loss                 #82DFB4 #FF989D | #146042 #A42F45
    warn / warn ground          #F5CC82 #252119 | #744B00 #FFF2D9
    SOL / token                 #49AEDA #AA8AEF | #096D91 #654098   (inventory, never performance)
*/

html:root {
  /* shared, theme independent */
  /* type: Instrument Sans for UI and headings, Geist Mono (tabular) for numbers, addresses and labels (owner's choice). */
  --font-display: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-text:    "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono:    "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --display-weight: 600; --display-tracking: -0.025em;
  --num-tracking: -0.01em;                     /* mono figures: tabular, slightly tightened */
  --r-sm: 4px; --r-md: 5px; --r-lg: 6px; --r-btn: 4px;   /* 4px controls, 5px panels */
  --dur: 90ms;                                 /* hover/focus: colour only, 80-100 ms */
  --dur-disclose: 120ms;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --lit: 0 0 0 1px var(--line);                /* panels: one crisp 1px rule, no elevation (box-shadow: no layout change) */
  --lift: 0 18px 48px rgb(0 0 0 / .45), 0 0 0 1px var(--line-strong);   /* only overlays lift */
}

/* ── night (reference) ── */
html:root[data-theme="dark"] {
  color-scheme: dark;
  --p-bg: #111116; --p-surface: #1B1726; --p-ink: #F7F4FB; --p-muted: #BCAFC9;
  --p-accent: #D9CCFF; --p-accent-ink: #1B1726; --p-action: #D9CCFF; --p-action-ink: #1B1726;
  --p-inv-bg: #F7F4FB; --p-inv-surface: #EDE7F3; --p-inv-ink: #1B1726; --p-inv-muted: #62546F;
  --p-inv-accent: #594284; --p-inv-accent-ink: #FFFFFF; --p-inv-action: #594284; --p-inv-action-ink: #FFFFFF;
  --bg: var(--p-bg); --ink: var(--p-ink); --muted: #BCAFC9; --accent: #D9CCFF; --action: #D9CCFF; --action-ink: #1B1726;
  --shell: #1B1726; --inset: #0F1015; --instrument: #0F1015; --overlay: #24212D;
  --tone-1: #17161D; --tone-2: #1E1B26; --tone-hover: #1C1A24;
  --dim: #DED8E6; --faint: #A99CB8;
  --line: #38333F; --line-strong: #4E4659; --control: #897B9C;
  --focus: #FFCA9D;
  --sel: #D9CCFF; --sel-fill: #2A2334; --sel-line: #847296; --sel-ink: #1B1726;
  --cta: #FF985B; --cta-ink: #22140C; --cta-hover: #FFAB79; --now: #FF985B;
  --gain: #82DFB4; --loss: #FF989D; --next-ink: #FF989D;
  --warn: #F5CC82; --warn-bg: #252119; --warn-line: #74603D;
  --live-bg: #2E1A21; --run-bg: #1B2A24;
  --sol: #49AEDA; --sol-bin: #49AEDA; --token: #AA8AEF; --tok-bin: #AA8AEF; --ask-hatch: #EEB088;
  --danger-fill: #FF989D; --danger-ink: #1B1726;
  /* chart + indicator palette (phase 3 wires termChartTheme()/termIndColors() to these) */
  --chart-grid: rgb(255 255 255 / .05); --chart-vol: rgb(188 175 201 / .22);
  --ind-ema-fast: #D9CCFF; --ind-ema-slow: #49AEDA; --ind-sma: #AA8AEF; --ind-vwap: #E9A4C7;
  --ind-bb: #49AEDA; --ind-rsi: #D9CCFF; --ind-macd: #49AEDA; --ind-macd-sig: #F5CC82;
  --ind-srsi-k: #49AEDA; --ind-srsi-d: #F5CC82; --ind-vpvr: rgb(170 138 239 / .22); --ind-poc: #D9CCFF;
  --bub-entry: #49AEDA; --bub-flip: #D9CCFF; --bub-ink: #111116;
  --scroll-thumb: #4A4356; --scroll-thumb-hover: #6A5F79;
  --backdrop: rgb(8 7 12 / .68);
}

/* ── day: violet-tinted paper, not an inversion ── */
html:root[data-theme="light"] {
  color-scheme: light;
  --p-bg: #F4F1F7; --p-surface: #EDE7F3; --p-ink: #211C29; --p-muted: #62546F;
  --p-accent: #594284; --p-accent-ink: #FFFFFF; --p-action: #594284; --p-action-ink: #FFFFFF;
  --p-inv-bg: #1B1726; --p-inv-surface: #24212D; --p-inv-ink: #F7F4FB; --p-inv-muted: #BCAFC9;
  --p-inv-accent: #D9CCFF; --p-inv-accent-ink: #1B1726; --p-inv-action: #D9CCFF; --p-inv-action-ink: #1B1726;
  --bg: var(--p-bg); --ink: var(--p-ink); --muted: #62546F; --accent: #594284; --action: #594284; --action-ink: #FFFFFF;
  --shell: #EDE7F3; --inset: #F8F6FA; --instrument: #F8F6FA; --overlay: #FFFFFF;
  --tone-1: #FFFFFF; --tone-2: #F6F3F9; --tone-hover: #FBFAFC;
  --dim: #38303F; --faint: #6A5C77;
  --line: #D8D0DF; --line-strong: #C3B8CD; --control: #7D6C87;
  --focus: #854000;
  --sel: #594284; --sel-fill: #EDE6F7; --sel-line: #9A86B5; --sel-ink: #FFFFFF;
  --cta: #91420B; --cta-ink: #FFFFFF; --cta-hover: #7A3708; --now: #91420B;
  --gain: #146042; --loss: #A42F45; --next-ink: #A42F45;
  --warn: #744B00; --warn-bg: #FFF2D9; --warn-line: #D9B36A;
  --live-bg: #FBE9EC; --run-bg: #E4F2EB;
  --sol: #096D91; --sol-bin: #096D91; --token: #654098; --tok-bin: #654098; --ask-hatch: #92512C;
  --danger-fill: #A42F45; --danger-ink: #FFFFFF;
  --chart-grid: rgb(33 28 41 / .06); --chart-vol: rgb(98 84 111 / .18);
  --ind-ema-fast: #594284; --ind-ema-slow: #096D91; --ind-sma: #654098; --ind-vwap: #A3466F;
  --ind-bb: #096D91; --ind-rsi: #594284; --ind-macd: #096D91; --ind-macd-sig: #744B00;
  --ind-srsi-k: #096D91; --ind-srsi-d: #744B00; --ind-vpvr: rgb(101 64 152 / .16); --ind-poc: #594284;
  --bub-entry: #096D91; --bub-flip: #594284; --bub-ink: #FFFFFF;
  --scroll-thumb: #C9BED3; --scroll-thumb-hover: #A595B4;
  --backdrop: rgb(33 28 41 / .42);
}

html:root {
  scrollbar-color: var(--scroll-thumb) transparent;

  & ::selection { background: var(--sel); color: var(--sel-ink); }
  & ::-webkit-scrollbar { width: 10px; height: 10px; }
  & ::-webkit-scrollbar-track { background: transparent; }
  & ::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
  & ::-webkit-scrollbar-thumb:hover { background-color: var(--scroll-thumb-hover); }
  & ::-webkit-scrollbar-corner { background: transparent; }

  /* ── type ── */
  & body { background: var(--p-bg); color: var(--p-ink); font-family: var(--font-text); font-variant-numeric: tabular-nums lining-nums; }
  & :is(h1, h2, h3, h4) { font-family: var(--font-display); }
  & .mono, & code { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
  /* figures: Geist Mono, tabular + lining, slightly tight (sizes stay as they are: no reflow) */
  & :is(.kpi dd:not(.kpi__floor), .pnl, .pc__pnl, .facts dd, .pc__facts dd, .tok__stats dd, .tkv dd, .thead__kv dd,
        .tside__pnl, .trow__v, .hist__tot dd, .pt td.num, .htbl td:not(:first-child):not(.tx):not(.pair), .bulk__t .num,
        .ttbl td.num, .split, .edge, .bins-axis, .range__legend, .pcal__tot dd, .dtab__n, .ev__time, .status-pill__age) {
    font-family: var(--font-mono); font-variant-numeric: tabular-nums lining-nums; letter-spacing: var(--num-tracking);
  }
  & :is(.kpi dd:not(.kpi__floor), .pnl, .pc__pnl, .tside__pnl) { font-weight: 500; }
  & .mono, & code, & :is(.pos__pk, .pc__pk, .pt__pk, .ev__detail, .ev__tx, .brow, .tbook, .oq__rows td:last-child) { }
  & :is(.pnl, .pc__pnl, .tside__pnl) small { font-family: var(--font-mono); letter-spacing: 0; }
  /* compact labels (KPI keys, column headings): mono caps, muted */
  & :is(.kpi dt, .facts dt, .pc__facts dt, .tok__stats dt, .hist__tot dt, .pt th, .htbl th, .bulk__t thead th, .ttbl th,
        .tpane__h h2, .tside__h, .attn__k, .gm__h, .tok__src, .tind__h, .dfg legend, .pcal__wd) {
    font-family: var(--font-mono); font-weight: 500; letter-spacing: .06em; color: var(--muted);
  }
  & :is(.pt th, .htbl th, .bulk__t thead th, .ttbl th) { letter-spacing: .02em; }
  & :is(.pt td.num, .htbl td, .ttbl td.num, .bulk__t .num) { letter-spacing: -0.03em; }
  & .pt td.num { font-size: 12px; }
  & :is(.pt th, .htbl th, .bulk__t thead th) { font-size: 11px; letter-spacing: .02em; }   /* spec: row numbers 12-13px; keeps the table inside its frame with the mono face */
  & .tkv dt, & .thead__kv dt, & .sig dt { color: var(--muted); }
  & :is(.pos__pk, .pc__pk, .pt__pk, .trow__n small, .thead__id small) { color: var(--faint); font-family: var(--font-mono); }
  /* headings: semibold, tight tracking, no serif anywhere */
  & h1.brand { font-family: var(--font-display); font-weight: 750; letter-spacing: -0.035em; }
  & :is(.panel-h h2, .dtab, .pnlpage__t) { font-family: var(--font-display); font-weight: 650; letter-spacing: -0.025em; }
  & :is(.pos__name, .pc__name, .pt__pair, .sig__pair, .thead__id b, .trow__n b, .htbl td.pair) { font-family: var(--font-display); font-weight: 650; letter-spacing: -0.01em; }
  & dialog h3 { font-family: var(--font-display); font-weight: 650; letter-spacing: -0.02em; }
  & legend, & .pcal__title { font-family: var(--font-display); font-weight: 650; }
  /* the KPI keys carry the Range Atlas "folio" tick: a short tangerine rule (desktop; phones keep the room) */
  @media (min-width: 701px) { & .kpis:not(.kpis--sub) .kpi dt::before { content: ""; display: inline-block; width: 10px; height: 2px; margin: 0 7px 0 0; vertical-align: .3em; background: var(--now); } }
  & legend { font-weight: 600; }

  /* ── links and focus ── */
  & :is(a, button, select, summary, [tabindex], input, textarea):focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  & :is(.fld input, .fld select, .ptools__q input, .tsearch input, .tind__p input):focus-visible,
  & .tsearch input:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
  & :is(.dff__in):focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
  & .pt__row:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
  & :is(.tok__lnk, .linkbtn, .setup-nudge a) { text-underline-offset: 2px; }

  /* ── header bar and page nav ── */
  & .bar { border-bottom-color: var(--line); }
  & .pagenav { border-color: transparent; border-radius: 0; gap: 4px; padding: 3px; }
  & .pagenav a { border-radius: 0; background: none; box-shadow: none; color: var(--muted); font-weight: 600;
    box-shadow: inset 0 -2px 0 transparent; transition: color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
  & .pagenav a:hover { color: var(--p-ink); box-shadow: inset 0 -2px 0 var(--line-strong); }
  & .pagenav a[aria-current="page"] { background: none; color: var(--sel); box-shadow: inset 0 -2px 0 var(--sel); }
  /* mode / run status: square instrument tags, words carry the state (never a colour dot alone) */
  & .mode { border-radius: 3px; border-color: var(--sel-line); background: var(--sel-fill); color: var(--sel);
    font-family: var(--font-mono); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 11px; }
  & .mode::before { background: var(--sel); width: 6px; height: 6px; }
  & .mode[data-mode="live"] { background: var(--live-bg); border-color: color-mix(in oklab, var(--loss) 55%, transparent); color: var(--loss); }
  & .mode[data-mode="live"]::before { background: var(--loss); }
  & .status-pill { border-radius: 3px; border-color: var(--line-strong); background: var(--tone-1); font-family: var(--font-mono); font-size: 11px; font-weight: 450; letter-spacing: 0; }
  & .status-pill__dot { width: 6px; height: 6px; }
  & .run { border-radius: 3px; }
  & #wallet { font-family: var(--font-mono); color: var(--muted); }
  /* one compact masthead row at >=1100px (4 nav items no longer push status/actions onto a second line);
     the status text ellipsizes instead of wrapping. Narrower widths keep the existing wrap. */
  @media (min-width: 1100px) {
    & .bar { flex-wrap: nowrap; gap: var(--s-4); }
    & .bar__left { flex-wrap: nowrap; flex: none; gap: var(--s-5); }
    & .bar__right { flex-wrap: nowrap; flex: 1 1 auto; justify-content: flex-end; gap: var(--s-2); }
    & .bar__right > * { flex: none; }
    & .bar__right > .status-pill { flex: 0 1 auto; min-width: 48px; overflow: hidden; }
    & .bar__right { min-width: 0; }
    & h1.brand { font-size: 22px; gap: var(--s-2); }
    & .brand__logo { width: 34px; height: 34px; }
  }
  @media (min-width: 1100px) and (max-width: 1439px) { & .status-pill__age { display: none; } }
  @media (min-width: 1100px) and (max-width: 1279px) {
    & #wallet { display: none; }
    & .bar__left { gap: var(--s-4); }
    & .pagenav a { padding-left: 10px; padding-right: 10px; }
  }
  & .update { border-radius: var(--r-sm); border: 1px solid color-mix(in oklab, var(--warn) 45%, transparent); background: var(--warn-bg); color: var(--warn); }
  & .setup-nudge { border-radius: var(--r-sm); border: 1px solid color-mix(in oklab, var(--loss) 45%, transparent); background: var(--live-bg); color: var(--loss); }

  /* ── buttons ── */
  & .btn { border-radius: var(--r-btn); font-weight: 600; letter-spacing: 0;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease); }
  /* primary = selection lilac (confirm, copy, open…) */
  & .btn--primary { background: var(--action); color: var(--action-ink); border-color: var(--action); }
  & .btn--primary:hover:not(:disabled) { background: color-mix(in oklab, var(--action) 86%, var(--p-ink)); border-color: color-mix(in oklab, var(--action) 86%, var(--p-ink)); }
  & .btn--secondary { background: transparent; color: var(--dim); border-color: var(--control); }
  & .btn--secondary:hover:not(:disabled) { background: var(--sel-fill); color: var(--p-ink); border-color: var(--sel-line); }
  & .btn--ghost { background: transparent; color: var(--muted); border-color: var(--line-strong); border-radius: var(--r-btn); }
  & .btn--ghost:hover:not(:disabled) { color: var(--p-ink); border-color: var(--control); background: var(--sel-fill); }
  & .btn:disabled, & .btn[aria-disabled="true"] { background: color-mix(in oklab, var(--tone-2) 80%, transparent); color: var(--faint); border-color: var(--line-strong); opacity: 1; cursor: not-allowed; filter: none; }
  /* tangerine = the deliberate action: review costs, open after review, save settings */
  & :is(#openGo, .tticket__go, #setupForm button[type="submit"].btn--primary, #settingsForm button[type="submit"].btn--primary) {
    background: var(--cta); border-color: var(--cta); color: var(--cta-ink);
  }
  & :is(#openGo, .tticket__go, #setupForm button[type="submit"].btn--primary, #settingsForm button[type="submit"].btn--primary):hover:not(:disabled) { background: var(--cta-hover); border-color: var(--cta-hover); }
  & :is(#openGo, .tticket__go, #setupForm button[type="submit"].btn--primary, #settingsForm button[type="submit"].btn--primary):disabled {
    background: color-mix(in oklab, var(--tone-2) 80%, transparent); color: var(--faint); border-color: var(--line-strong); filter: none; opacity: 1;
  }
  /* phones: system.css turns a .btn-row secondary into an underlined text link; keep it a quiet bordered button instead */
  @media (max-width: 639px) { & .btn-row > .btn--secondary { text-decoration: none; } }
  /* Stop bot: quiet, never orange; it opens a confirmation */
  & #pauseBtn { background: transparent; color: var(--dim); border-color: var(--control); }
  & #pauseBtn:hover:not(:disabled) { background: var(--sel-fill); color: var(--p-ink); border-color: var(--sel-line); }
  /* destructive confirmations borrow loss, always with an explicit verb in the label */
  & :is(#closeYes, #bulkYes, #liveYes) { background: var(--danger-fill); border-color: var(--danger-fill); color: var(--danger-ink); }
  & :is(#closeYes, #bulkYes, #liveYes):hover:not(:disabled) { background: color-mix(in oklab, var(--danger-fill) 86%, var(--p-ink)); border-color: color-mix(in oklab, var(--danger-fill) 86%, var(--p-ink)); }
  & :is(#closeYes, #bulkYes, #liveYes):disabled { background: color-mix(in oklab, var(--tone-2) 80%, transparent); color: var(--faint); border-color: var(--line-strong); }
  /* Stop managing leaves the position open: not destructive, not orange */
  & #ignoreYes { background: transparent; color: var(--p-ink); border-color: var(--control); }
  & #ignoreYes:hover:not(:disabled) { background: var(--sel-fill); border-color: var(--sel-line); }
  & .bell-btn[aria-pressed="true"] { color: var(--sel); border-color: var(--sel-line); background: var(--sel-fill); }
  & .pos__fold { border-radius: var(--r-sm); }
  & .pos__fold:hover { background: var(--sel-fill); }
  & .linkbtn { color: var(--sel); }

  /* segmented controls / toggles: the enabled segment is the selection */
  & .seg { border-color: var(--control); border-radius: var(--r-btn); }
  & .seg button { background: transparent; color: var(--dim); }
  & .seg button:hover:not(:disabled):not([aria-pressed="true"]) { background: var(--tone-2); color: var(--p-ink); }
  & .seg button[aria-pressed="true"] { background: var(--sel-fill); color: var(--sel); box-shadow: inset 0 0 0 1px var(--sel-line); }
  & .seg button.live[aria-pressed="true"] { background: var(--live-bg); color: var(--loss); box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--loss) 55%, transparent); }
  & :is(.evf, .ttf) { border-color: var(--line-strong); border-radius: var(--r-btn); }
  & :is(.evf button, .ttf button, .tsr__tab) { border-radius: 3px; }
  & :is(.evf button, .ttf button, .tind__btn, .tbub-toggle):hover:not(:disabled) { color: var(--p-ink); }
  & :is(.evf button, .ttf button, .tsr__tab)[aria-pressed="true"],
  & .tsr__tab[aria-selected="true"],
  & .tind__btn[aria-expanded="true"] { background: var(--sel-fill); color: var(--sel); box-shadow: inset 0 0 0 1px var(--sel-line); border-color: transparent; }
  & .tpane__h .evf--xs button[aria-pressed="true"] { background: var(--sel-fill); }
  & .ttabs button[aria-selected="true"] { color: var(--sel); box-shadow: inset 0 -2px 0 var(--sel); }
  & .ttabs button:hover { color: var(--p-ink); }
  & .tind__btn.is-on::after { background: var(--sel); }
  & .evsim { border-radius: var(--r-btn); border-color: var(--line-strong); }
  & .evsim[aria-pressed="true"] { background: var(--sel-fill); color: var(--sel); box-shadow: inset 0 0 0 1px var(--sel-line); }
  & .evsim[aria-pressed="true"]::before { box-shadow: inset 0 0 0 1.5px var(--sel-fill); }

  /* dashboard list tabs: underline, lilac when selected */
  & .dtabs { border-bottom-color: var(--line); }
  & .dtab { color: var(--muted); }
  & .dtab:hover { color: var(--p-ink); }
  & .dtab[aria-selected="true"] { color: var(--p-ink); border-bottom-color: var(--sel); }
  & .dtab__n { border-radius: 3px; background: var(--tone-2); color: var(--muted); font-weight: 500; }

  /* ── chips / pills: square tags ── */
  & :is(.chip, .tchip, .dfchip, .sigsort__pill, .attn__c, .ptools__att, .ev__tx, .ev__rep, .ev__simtag, .ev__more,
        .hold-pill, .tfbtn, .oq-chip, .htbl .hx, .spike--hot, .tsr__open) { border-radius: 3px; }
  & .ptools__att button { border-radius: 3px; }
  & .chip { border-color: var(--line-strong); color: var(--dim); }
  & .chip--link:hover, & .oq-chip:hover:not(:disabled) { color: var(--p-ink); border-color: var(--control); }
  & .chip--bad { color: var(--loss); border-color: color-mix(in oklab, var(--loss) 50%, transparent); }
  & .chip--warn { color: var(--warn); border-color: var(--warn-line); }
  & .chip--ok { color: var(--gain); border-color: color-mix(in oklab, var(--gain) 45%, transparent); }
  & .dfchip { border-color: var(--line-strong); background: transparent; color: var(--dim); }
  & .dfchip:hover { border-color: var(--control); color: var(--p-ink); }
  & .dfchip[aria-pressed="true"] { background: var(--sel-fill); border-color: var(--sel-line); color: var(--sel); }
  & .dfchip small { color: var(--faint); }
  & .tfbtn { background: transparent; border-color: var(--line-strong); }
  & .tfbtn.is-on { border-color: var(--sel-line); color: var(--sel); }
  & .tfbtn__n:not(:empty) { border-radius: 3px; background: var(--sel); color: var(--sel-ink); }
  & .tsr__open { background: var(--action); color: var(--action-ink); }
  & .tchip { border-radius: 2px; font-family: var(--font-mono); font-weight: 500; letter-spacing: .04em; }
  & .ev__simtag { font-family: var(--font-mono); border-color: var(--line-strong); }
  & .ev__tx { font-family: var(--font-mono); border-color: var(--line-strong); }
  & .ev__tx:hover { border-color: var(--control); }
  & .spike--hot { color: var(--p-bg); }

  /* needs-attention strip: a narrow actionable warning, chips are filters (not trade actions) */
  & .attn__c { background: transparent; border-color: var(--line-strong); }
  & .attn__c--warn { border-color: var(--warn-line); color: color-mix(in oklab, var(--warn) 80%, var(--p-ink)); }
  & .attn__c--bad { border-color: color-mix(in oklab, var(--loss) 50%, transparent); }
  & .attn__c--good { border-color: color-mix(in oklab, var(--gain) 45%, transparent); }
  & .attn__c[aria-pressed="true"] { background: var(--sel-fill); box-shadow: inset 0 0 0 1px var(--sel-line); }
  & .attn__c:hover { background: var(--tone-2); }
  & .hold-pill { font-family: var(--font-mono); }

  /* ── inputs and selects: inset ground, control-colour boundary (3:1), 4px corners ── */
  & :is(.fld input, .fld select, .fld textarea, .dff__in, .dff--inline > input, .dfp__preset select, .dfp__name input,
        .share__row select, .share__row input, .scope-pick select, .ptools__q input, .tsearch input, .tticket__in input,
        .tticket select, .tind__p input, .sigsort__pill, .pcal__month, #liveDialog input, dialog input[type="text"], dialog input[type="number"], dialog select) {
    background: var(--inset); border-color: var(--control); border-radius: var(--r-sm); color: var(--p-ink);
  }
  & .sigsort__pill select { color: var(--p-ink); }
  & .sigsort__pill select option, & select option { background: var(--overlay); color: var(--p-ink); }
  & :is(input, textarea)::placeholder { color: var(--faint); opacity: 1; }
  & :is(.check input, .dff--chk input, .tind__on input, .pt__ck input, .pbulk__all input, input[type="checkbox"], input[type="radio"]) { accent-color: var(--sel); }
  & .tsearch__k { border-color: var(--line-strong); color: var(--faint); border-radius: 3px; }

  /* ── panels / cards: worksheet ground, 1px rule (via --lit), 5-6px corners, no nested elevation ── */
  & :is(.kpi, .pos, .sig, .settings, .ev, .dfg, .hist__tot > div, .hist__chart, .hist__tbl, .ptwrap, .term .tp, .tpane,
        .sd__panel, .tticket, .pcal__grid) { box-shadow: var(--lit); }
  & .kpi { border-radius: var(--r-md); }
  & .kpis--sub .kpi { background: color-mix(in oklab, var(--tone-1) 55%, var(--p-bg)); }
  & .kpi__pct { opacity: 1; color: inherit; font-family: var(--font-text); letter-spacing: 0; font-weight: 600; }
  & .kpi dd.kpi__floor, & .kpi__floor { color: var(--muted); }
  & .pos { border-radius: var(--r-lg); }
  & .pt__x .pos { box-shadow: var(--lit); }
  & .term .tp, & .tpane { border-radius: var(--r-md); }
  & .tp--left { box-shadow: none !important; }
  & .tpane__h { background: var(--tone-2); box-shadow: inset 0 -1px 0 var(--line); }
  & .tbar { background: var(--shell); box-shadow: inset 0 1px 0 var(--line); border-radius: var(--r-md) var(--r-md) 0 0; }
  & .tok__row, & .sd, & .ex, & .track { border-radius: var(--r-sm); }
  & .empty { border-color: var(--line-strong); border-radius: var(--r-md); }
  & .oor { border-radius: var(--r-sm); border: 1px solid color-mix(in oklab, var(--warn) 45%, transparent); }
  & .tok__icon, & .trow__ic { box-shadow: 0 0 0 1px var(--line-strong); background: var(--sel-fill); color: var(--sel); }

  /* activity rows: rules, not floating cards */
  & .ev { border-radius: var(--r-sm); }
  & .ev--real { background: var(--tone-2); }
  & .ev--sim { box-shadow: none; }
  & .ev__detail { color: var(--muted); }
  & .ev__rep { background: var(--sel-fill); color: var(--sel); }

  /* ── tables ── */
  & .ptwrap, & .hist__tbl { border-radius: var(--r-md); }
  & .pt th, & .bulk__t thead th { background: var(--inset); }
  & .htbl th, & .htbl td:first-child, & .htbl th:first-child { background: var(--tone-1); }
  & .htbl th { background: var(--inset); }
  & .htbl th:first-child { background: var(--inset); }
  & .htbl th button:hover, & .htbl th[aria-sort] button { color: var(--sel); }
  & :is(.pt td, .htbl td, .ttbl td, .bulk__t td) { border-color: color-mix(in oklab, var(--line) 85%, transparent); }
  & .pt__row.is-open { background: var(--sel-fill); }
  & .pt__row.is-open { outline: 1px solid var(--sel-line); outline-offset: -1px; }
  & .pt__row[aria-expanded="true"] { background: var(--sel-fill); }
  & .pt__x > td { background: color-mix(in oklab, var(--sel-fill) 45%, var(--tone-1)); }
  & .pt__g td, & .pgroup__h { background: var(--tone-2); }
  & .htbl tbody tr:hover td, & .htbl tbody tr:hover td:first-child { background: var(--tone-hover); }
  & .htbl td.tx a { color: var(--muted); }
  & .htbl td.tx a:hover { color: var(--p-ink); }
  & .ttbl th { background: var(--tone-1); }
  & .ttbl tr[aria-selected="true"] td { background: var(--sel-fill); }
  & .tev--mine td { background: color-mix(in oklab, var(--sel-fill) 45%, transparent); }
  & .trow[aria-selected="true"] { background: var(--sel-fill); border-color: var(--sel-line); }
  & .tsr[aria-selected="true"], & .tsr:hover { background: var(--sel-fill); }
  & .brow--mid { background: var(--tone-2); }

  /* ── dialogs and overlays: the only things that lift ── */
  & dialog { background: var(--overlay); color: var(--p-ink); border-color: var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--lift); }
  & dialog::backdrop { background: var(--backdrop); }
  & .bulk__t thead th, & .bulk__t tfoot th, & .bulk__t tfoot td { background: var(--overlay); }
  & .bulk__t thead th { background: var(--inset); }
  & .bulk__list { border-color: var(--line); border-radius: var(--r-sm); }
  & .bulk__mode, & .sd { border-radius: var(--r-sm); }
  & .bulk__mode--shadow { background: var(--warn-bg); border-color: var(--warn); }
  & .bulk__mode--live { background: var(--live-bg); border-color: var(--loss); }
  & .share__preview canvas { border-radius: var(--r-md); box-shadow: 0 0 0 1px var(--line); }
  & :is(.dfp--pop, .tsearch__res, .tind__menu) { background: var(--overlay); border-radius: var(--r-md); box-shadow: var(--lift); }
  & .dfp--pop { border-color: var(--line-strong); }
  & .dfp--pop .dfp__top { background: var(--overlay); }
  & .dfp--pop .dfg { background: var(--tone-2); box-shadow: none; }
  & .dfp__bottom { background: var(--p-bg); }
  & .pcal-day { background: var(--overlay); }
  & .toast { background: var(--p-ink); color: var(--p-bg); border-radius: var(--r-sm); box-shadow: var(--lift); }


  /* ── PnL page ── */
  & .pnlpage__t { font-weight: 600; letter-spacing: -0.03em; }
  & .pnl-link a { color: var(--sel); }
  & .kpi--link .kpi__link { color: inherit; }
  & .kpi--link:hover { background: color-mix(in oklab, var(--sel-fill) 55%, var(--tone-1)); }
  & .kpi--link:hover .kpi__link { color: var(--sel); }

  /* ── PnL calendar ── */
  & .pcal__grid { background: var(--tone-1); border-radius: var(--r-md); }
  & .pcal__d, & .pcal__w { border-radius: 3px; }
  & .pcal__d { background: var(--tone-2); }
  & .pcal__d.is-today { box-shadow: inset 0 0 0 2px var(--sel); }
  & .pcal__d.is-today .pcal__n { color: var(--sel); }
  & .pcal__d[aria-selected="true"] { box-shadow: inset 0 0 0 2px var(--p-ink); }
  & .pcal__n { font-family: var(--font-mono); font-weight: 500; }
  & .pcal__arrow { font-family: var(--font-text); }

  /* ── range / bins / sell-style demo ── */
  & .track__sol { background: color-mix(in oklab, var(--sol-bin) 38%, var(--tone-2)); }
  & .track__tok { background: color-mix(in oklab, var(--tok-bin) 42%, var(--tone-2)); }
  & .mark--next, & .bmark--next { border-left-color: var(--warn); }
  & .mark--next span, & .bmark--next span, & .bmark--oor span { color: var(--warn); }
  & .brow--ask span:first-child { color: color-mix(in oklab, var(--tok-bin) 70%, var(--p-ink)); }
  & .ex__now { box-shadow: 0 0 0 2px var(--tone-2); }
  & .pc__mark--out { background: var(--warn); }
  & .bin i { transition: none; }   /* no animation on live ticks */

  /* ── Terminal chart bubbles: E blue entry, F lilac flips, S outlined exit ── */
  & .tbub--entry { --c: var(--bub-entry); }
  & .tbub--flip { --c: var(--bub-flip); }
  & :is(.tbub--entry, .tbub--flip) .tbub__pill { color: var(--bub-ink); }
  & .tbub--close .tbub__pill { background: var(--tone-1); color: var(--c); box-shadow: inset 0 0 0 1.5px var(--c); }
  & .tbub--close:not(.tbub--gain):not(.tbub--loss) { --c: var(--dim); }
  & .tbub.is-open .tbub__pill { background: var(--overlay); color: var(--p-ink); border: 1px solid var(--c); box-shadow: var(--lift); }
  & .tbub__pill { font-family: var(--font-mono); font-weight: 600; }
  & .tbub__dot { box-shadow: 0 0 0 2px var(--tone-1); }
  & .tind-li { background: color-mix(in oklab, var(--tone-1) 78%, transparent); }

  /* ── motion ── */
  & .pagenav a, & .dtab, & .attn__c, & .pt__row, & .dfchip, & .tfbtn, & .evsim, & .seg button, & .evf button { transition-duration: var(--dur); }
}

@media (prefers-reduced-motion: reduce) {
  html:root *, html:root *::before, html:root *::after {
    transition-duration: 0s !important; transition-delay: 0s !important;
    animation-duration: 0s !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important;
  }
}

@media (forced-colors: active) {
  html:root :is(.btn, .seg, .chip, .dfchip, .attn__c, .mode, .status-pill, dialog, .kpi, .pos, .ptwrap) { border: 1px solid CanvasText; }
  html:root :is(.pagenav a[aria-current="page"], .dtab[aria-selected="true"], .seg button[aria-pressed="true"]) { outline: 2px solid Highlight; }
  html:root :focus-visible { outline: 2px solid Highlight !important; }
}
