/* PipRake dashboard. The design system lives in docs/brand-guidelines.md; this file implements it.
 * Phone first (375 px, no sideways page scroll, 44 px tap targets). Dark whatever the device says;
 * <html data-theme="light"> switches to light and data-theme="auto" follows prefers-color-scheme (the
 * server writes the attribute from the `theme` cookie). No inline styles (CSP 'self'): every colour
 * comes from a token and a class.
 * Palette "Ledger": blue-black and slate layers, ledger navy for the brand, white (navy in light) for
 * actions; colour only for meaning (profit, loss, warning, modes). Flat: no shadows on the page, pill
 * buttons, 12 px cards. */

/* ==== 0. Fonts ================================================================================== */

/* Self-hosted (CSP font-src 'self'), latin subset, from Fontsource; SIL Open Font Licence in static/fonts.
   swap: the device's font shows at once and the brand face replaces it when loaded. */
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/hanken-grotesk-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/static/fonts/hanken-grotesk-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/hanken-grotesk-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/hanken-grotesk-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/source-serif-4-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/source-serif-4-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/static/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }

/* ==== 1. Tokens ================================================================================== */

:root {
  color-scheme: dark;

  /* brand, fixed in both themes: ledger navy is a ground (app icon, public page), paper the mark and type
     on it, brass for the public page only (never in the app, where it would read as amber) */
  --navy: #0c1b2e;
  --paper: #f4f6f9;
  --paper-2: #aeb8c6;
  --paper-3: #8e9aab;
  --paper-line: rgba(244, 246, 249, 0.12);
  --brass: #b08d57;

  /* neutrals (ledger): blue-black page, slate layers */
  --bg: #070b12;
  --surface: #0f1724;
  --surface-2: #18222f;
  --surface-3: #222e3d;
  --line: #18222f;
  --line-strong: #33404f;
  --highlight: transparent;
  --bar-bg: rgba(7, 11, 18, 0.84);

  /* text */
  --text: #eef1f5;
  --text-2: #c3cad4;
  --muted: #8d96a4;

  /* brand: white for actions and for the view; no hue in the brand at all */
  --primary: #eef1f5;
  --on-primary: #070b12;
  --primary-hover: #ffffff;
  --primary-tint: rgba(255, 255, 255, 0.22);
  --link: #eef1f5;
  --focus: #eef1f5;
  --accent: #ffffff;

  /* meaning */
  --profit: #30d158;
  --profit-bg: rgba(48, 209, 88, 0.14);
  --loss: #ff7a73;
  --loss-bg: rgba(255, 122, 115, 0.13);
  --loss-line: rgba(255, 122, 115, 0.5);
  --warn: #f5b53d;
  --warn-bg: #2a2213;
  --warn-line: rgba(245, 181, 61, 0.45);
  --halted: #b3141c;
  --on-halted: #ffffff;
  --kill: #c8161f;
  --kill-hover: #dd2a33;
  --kill-line: rgba(200, 22, 31, 0.5);
  --kill-glow: rgba(200, 22, 31, 0.35);
  --info: #7db4ff;
  --info-bg: rgba(125, 180, 255, 0.12);

  /* modes */
  --mode-live-bg: #1e7d36;
  --mode-live-text: #ffffff;

  /* charts: real and shadow are the validated data-viz slots 1-2; the baseline is a dashed neutral */
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #aeaeb2;
  /* Mode race (Low, Medium, Higher, Gambling): validated all-pairs colour-blind safe, each with its own dash */
  --m1: #3987e5;
  --m2: #644fb1;
  --m3: #d95926;
  --m4: #c952a8;
  --m5: #308e63;
  --grid: #141e2b;
  --axis: #33404f;
  --candle-up: #3fae6b;
  --candle-down: #e0605c;
  --lvl-support: #5aa2ff;
  --lvl-resist: #f08a4b;
  --lvl-both: #e07ab0;

  /* type: Hanken Grotesk for the interface, Source Serif 4 for public headlines, IBM Plex Mono for
     tickers and code; self-hosted (section 0), the device's own faces as fallbacks */
  --display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI Variable Text", "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  /* four sizes (plus 11 px for chart axes and tab labels): small, body, title, hero */
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-xl: 22px;
  --fs-hero: 40px;

  /* space, shape, depth */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --r-sm: 8px;
  --r-md: 10px;
  --r-lg: 12px;
  --r-pill: 999px;
  --tap: 44px;
  /* flat: no shadow on anything that sits on the page; floating layers (menus, tooltips) only */
  --shadow-1: none;
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 16px 40px rgba(0, 0, 0, 0.6);
  --blur: saturate(180%) blur(20px);
  --tabbar-h: 62px;
}

/* Light: chosen in the theme menu, or "Auto" on a device set to light. The two blocks must stay equal. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --surface-3: #e3e7ec;
  --line: #e3e7ec;
  --line-strong: #c3cad3;
  --highlight: transparent;
  --bar-bg: rgba(243, 244, 246, 0.86);
  --text: #0d1726;
  --text-2: #3b4656;
  --muted: #5b6676;
  --primary: #0c1b2e;
  --on-primary: #ffffff;
  --primary-hover: #060e19;
  --primary-tint: rgba(0, 0, 0, 0.14);
  --link: #0c1b2e;
  --focus: #0c1b2e;
  --accent: #0c1b2e;
  --profit: #1d7a36;
  --profit-bg: #e5f4e8;
  --loss: #c2282b;
  --loss-bg: #fbe9e9;
  --loss-line: #e9a3a3;
  --warn: #8f5300;
  --warn-bg: #fff2d6;
  --warn-line: #e3b866;
  --kill-hover: #a8121a;
  --kill-glow: rgba(200, 22, 31, 0.25);
  --info: #1f5fc4;
  --info-bg: #e8effc;
  --mode-live-bg: #1d7a36;
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #6e6e73;
  --m1: #2a78d6;
  --m2: #5b3bb3;
  --m3: #eb6834;
  --m4: #b8327a;
  --m5: #106f4c;
  --grid: #e9ecf0;
  --axis: #c3cad3;
  --candle-up: #2c9a57;
  --candle-down: #d4504c;
  --lvl-support: #2a6fd6;
  --lvl-resist: #c2560f;
  --lvl-both: #b8327a;
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-3: 0 16px 40px rgba(0, 0, 0, 0.14);
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --surface-2: #f5f6f8;
    --surface-3: #e3e7ec;
    --line: #e3e7ec;
    --line-strong: #c3cad3;
    --highlight: transparent;
    --bar-bg: rgba(243, 244, 246, 0.86);
    --text: #0d1726;
    --text-2: #3b4656;
    --muted: #5b6676;
    --primary: #0c1b2e;
    --on-primary: #ffffff;
    --primary-hover: #060e19;
    --primary-tint: rgba(0, 0, 0, 0.14);
    --link: #0c1b2e;
    --focus: #0c1b2e;
    --accent: #0c1b2e;
    --profit: #1d7a36;
    --profit-bg: #e5f4e8;
    --loss: #c2282b;
    --loss-bg: #fbe9e9;
    --loss-line: #e9a3a3;
    --warn: #8f5300;
    --warn-bg: #fff2d6;
    --warn-line: #e3b866;
    --kill-hover: #a8121a;
    --kill-glow: rgba(200, 22, 31, 0.25);
    --info: #1f5fc4;
    --info-bg: #e8effc;
    --mode-live-bg: #1d7a36;
    --s1: #2a78d6;
    --s2: #eb6834;
    --s3: #6e6e73;
    --m1: #2a78d6;
    --m2: #5b3bb3;
    --m3: #eb6834;
    --m4: #b8327a;
    --m5: #106f4c;
    --grid: #e9ecf0;
    --axis: #c3cad3;
    --candle-up: #2c9a57;
    --candle-down: #d4504c;
    --lvl-support: #2a6fd6;
    --lvl-resist: #c2560f;
    --lvl-both: #b8327a;
    --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-3: 0 16px 40px rgba(0, 0, 0, 0.14);
  }
}

/* ==== 2. Base ==================================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-4));
  overflow-x: hidden;
}
h1, h2, h3, p, ul, ol, dl, figure { margin: 0; }
h1 { font-size: var(--fs-xl); line-height: 1.2; font-weight: 600; letter-spacing: -0.025em; }
h2 { font-size: var(--fs-md); line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: var(--fs-md); line-height: 1.35; font-weight: 600; }
a { color: var(--link); text-decoration-color: var(--muted); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
pre {
  font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.5; margin: var(--sp-2) 0 0;
  padding: var(--sp-3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: auto; max-height: 420px; white-space: pre-wrap; word-break: break-word;
}
strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--primary-tint); }
.icon { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
/* instrument badges (the six markets) beside the name: web/icons.py instrument_icon */
.inst-icon { display: inline-block; flex: none; margin-right: 0.4em; border-radius: 50%; }
.inst-14 { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.inst-16 { width: 16px; height: 16px; vertical-align: -3px; margin-right: 6px; }
.inst-20 { width: 20px; height: 20px; vertical-align: -4px; margin-right: 8px; }
.inst-24 { width: 24px; height: 24px; vertical-align: -5px; margin-right: 8px; }
.inst-chip { white-space: nowrap; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--primary); color: var(--on-primary); padding: 8px 12px; border-radius: var(--r-sm); }
.skip-link:focus { left: 8px; }

/* text helpers */
.muted { color: var(--muted); }
.small, .help, .meta-line, .card-foot { font-size: var(--fs-sm); }
.help { color: var(--muted); margin-top: var(--sp-2); }
.meta-line { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--profit); }
.neg { color: var(--loss); }
.flat { color: var(--text); }
.ok-text { color: var(--profit); }
.warn-text { color: var(--warn); }

/* ==== 3. Shell: top bar, footer, bottom tabs ======================================================= */

.page { min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
  padding: env(safe-area-inset-top) 0 0;
}
.topbar-row {
  position: relative; display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-4); min-height: 56px;
}
.brand { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); min-height: var(--tap); }
/* The lockup (docs/brand-guidelines.md section 2; macro `lockup` in _macros.html): the bare mark and the
   word as one unit. The mark is 1.35 x the type size. The last tine ends at 26.4 of its 32 units
   (1.114em), so the word, pushed on 0.114em, starts 0.35em after it (about twice the tine spacing, so the
   P never reads as a fifth tine). The mark for the ground: paper on dark, navy on light. */
.lockup {
  display: inline-flex; align-items: center; gap: 0; margin: 0; color: inherit; white-space: nowrap;
  font-weight: 600; letter-spacing: -0.005em; line-height: 1;
}
.lockup-sm { font-size: 20px; }
.lockup-lg { font-size: var(--fs-xl); }
.lockup-mark { display: block; flex: none; width: 1.35em; height: 1.35em; }
.lockup-word { margin-left: 0.114em; }
.lockup-on-light { display: none; }
:root[data-theme="light"] .lockup-on-dark { display: none; }
:root[data-theme="light"] .lockup-on-light { display: block; }
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .lockup-on-dark { display: none; }
  :root[data-theme="auto"] .lockup-on-light { display: block; }
}
/* the mark's left air would push the lockup in from the content edge: pull it back in the top bar */
.brand .lockup { margin-left: -0.21em; }

/* account pill (DRY RUN / DEMO / LIVE): a small pill beside the Mode menu, on every page.
   Dry run grey, demo amber, live green with a pulsing dot and the page frame below. */
.mode-pill {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  min-height: 26px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; line-height: 1; text-transform: uppercase;
  white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line);
}
.mode-pill .mode-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.mode-pill.mode-demo { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.mode-pill.mode-live { background: var(--mode-live-bg); color: var(--mode-live-text); border-color: transparent; }
.mode-pill.mode-live .mode-dot { animation: pulse 1.4s ease-in-out infinite; }
.auth-page .topbar-end .mode-pill { margin-left: auto; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.35; transform: scale(0.8); } }
body.mode-live .topbar { border-top: 4px solid var(--mode-live-bg); border-bottom: 2px solid var(--mode-live-bg); }
body.mode-live::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 60;
  border: 3px solid var(--mode-live-bg); box-shadow: inset 0 0 0 1px var(--mode-live-text);
}

/* kill switch: one tap, always in the bar */
.kill { display: grid; gap: var(--sp-2); margin: 0; }
.kill-button {
  display: flex; align-items: center; justify-content: center; width: 100%;
  min-height: 52px; padding: 0 var(--sp-4);
  border: 1.5px solid var(--kill); border-radius: var(--r-pill); cursor: pointer;
  background: transparent; color: var(--loss);
  font: 600 var(--fs-md)/1.2 var(--font);
}
.kill-button:hover { background: var(--kill); color: var(--on-halted); }
.kill-button:active { transform: translateY(1px); }
.kill-note { font-size: var(--fs-sm); color: var(--muted); line-height: 1.45; text-align: center; }

/* live status banners (from /partials/status) */
.status-region { padding: 0 var(--sp-4); }
.status-region:empty { display: none; }
.status-region .alert:last-child { margin-bottom: var(--sp-3); }
.alert {
  position: relative; margin: 0 0 var(--sp-2); padding: 10px 12px 10px 40px;
  border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 600; line-height: 1.4;
}
.alert::before {
  content: ""; position: absolute; left: 12px; top: 10px; width: 18px; height: 18px;
  background: currentColor;
  -webkit-mask: url("icons/alert.svg") center / contain no-repeat; mask: url("icons/alert.svg") center / contain no-repeat;
}
.alert-red { background: var(--halted); color: var(--on-halted); }
.alert-amber { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }
.alert-info { background: var(--info-bg); color: var(--info); }
.alert-info::before { -webkit-mask-image: url("icons/info.svg"); mask-image: url("icons/info.svg"); }
.poll-failed { opacity: 0.6; }
/* two polls missed: the figures are old; dashed warning outline (the headline says since when) */
.poll-stale { outline: 2px dashed var(--warn-line); outline-offset: 4px; border-radius: var(--r-md); }

/* bottom tab bar (phone) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(6, 1fr);
  min-height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  background: var(--bar-bg); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--tabbar-h); padding: 6px 2px; color: var(--muted); text-decoration: none;
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em; cursor: pointer; list-style: none;
  border-radius: var(--r-md);
}
.tab::-webkit-details-marker { display: none; }
.tab .icon { width: 22px; height: 22px; }
.tab.active, .tab-more.active > .tab { color: var(--text); }
.tab.active .icon, .tab-more.active > .tab .icon { color: var(--primary); }
.tab-more { position: relative; }
.tab-more[open] > .tab { color: var(--text); }
.more-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px); min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
}
.more-menu .logout { margin: 0; border-top: 1px solid var(--line); padding-top: 4px; margin-top: 4px; }
.more-link {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: var(--tap);
  padding: 0 12px; border: 0; background: none; border-radius: var(--r-md);
  color: var(--text); text-decoration: none; font: 500 var(--fs-md) var(--font); cursor: pointer; text-align: left;
}
.more-link:hover, .more-link.active { background: var(--surface-2); }
.more-link.active .icon { color: var(--primary); }

/* page content */
.content { padding: var(--sp-4); max-width: 1180px; margin: 0 auto; }
.page-head { margin: var(--sp-1) 0 var(--sp-3); }
.page-head .sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; max-width: 70ch; }
.page-head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); }
.back {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); margin-left: -6px; padding-right: 8px;
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: var(--fs-sm);
}
.section { margin: var(--sp-4) 0; }
/* card and section titles: a quiet label (13, semibold, muted, sentence case), not a shouting heading */
.section-title, .card > h2, .card-head h2, .label {
  font-size: var(--fs-sm); font-weight: 600; letter-spacing: 0; color: var(--muted); line-height: 1.4;
}
.section-title { margin-bottom: var(--sp-2); }
.card > h2 { margin-bottom: var(--sp-2); }
.count { color: var(--text-2); font-weight: 600; margin-left: 2px; }
.caption { font-size: var(--fs-sm); color: var(--muted); }
.updated { color: var(--muted); font-size: var(--fs-sm); margin: var(--sp-3) 0 var(--sp-4); }

/* ==== 4. Components ============================================================================== */

/* card */
.card {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg);
  padding: var(--sp-4); margin-bottom: var(--sp-3); min-width: 0;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.card-head h2, .card-head h3 { font-size: var(--fs-md); font-weight: 600; }
.card-foot { color: var(--muted); margin-top: var(--sp-3); }
.card-danger { border-color: var(--kill-line); }
.card-warn { border-color: var(--warn-line); background: var(--warn-bg); }
.card-alert { border-color: var(--halted); }
.card-grid { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; }
.card-grid > .card { margin-bottom: 0; }
.home-grid { display: grid; gap: 0 var(--sp-4); grid-template-columns: 1fr; }
.link-more { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); font-weight: 600; font-size: var(--fs-sm); text-decoration: none; }
.link-more .icon { width: 16px; height: 16px; vertical-align: -3px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap); padding: 0 22px; border-radius: var(--r-pill); border: 1px solid transparent;
  font: 600 var(--fs-md)/1.1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: opacity 0.15s, background-color 0.15s;
}
.btn:active { opacity: 0.85; }
.btn .icon { width: 18px; height: 18px; vertical-align: 0; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-quiet { background: transparent; color: var(--text-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--kill); color: var(--on-halted); }
.btn-danger:hover { background: var(--kill-hover); }
.btn-block { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }

/* notices and errors */
.notice, .error {
  display: flex; align-items: flex-start; gap: var(--sp-2); padding: 10px 12px; border-radius: var(--r-md);
  margin: 0 0 var(--sp-4); font-size: var(--fs-sm); line-height: 1.45;
}
.notice { background: var(--info-bg); color: var(--text); }
.notice .icon { color: var(--info); width: 18px; height: 18px; vertical-align: 0; margin-top: 1px; }
.notice-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-line); }
.notice-warn .icon { color: var(--warn); }
.error { background: var(--loss-bg); color: var(--loss); font-weight: 600; }
.card .error:last-child, .card .notice:last-child { margin-bottom: 0; }

/* status pill (Home strip) */
.status-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); }
.pill {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: var(--sp-2);
  align-items: center; padding: 10px 12px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid transparent; min-width: 0;
}
.pill .icon { grid-row: 1 / span 2; width: 22px; height: 22px; padding: 0; }
.pill-label { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.pill-value { font-size: var(--fs-md); font-weight: 600; overflow-wrap: anywhere; line-height: 1.3; }
.pill-ok .icon { color: var(--profit); }
.pill-warn { border-color: var(--warn-line); }
.pill-warn .icon, .pill-warn .pill-value { color: var(--warn); }
.pill-bad { border-color: var(--loss-line); background: var(--loss-bg); }
.pill-bad .icon, .pill-bad .pill-value { color: var(--loss); }
.pill-neutral .icon { color: var(--muted); }

/* metric tile and hero figure */
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
.metric { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.metric-label { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.metric-value { font-size: var(--fs-xl); font-weight: 600; line-height: 1.25; font-variant-numeric: proportional-nums; overflow-wrap: anywhere; }
.metric-note { font-size: var(--fs-sm); color: var(--muted); }
.metric-note.pos { color: var(--profit); }
.metric-note.neg { color: var(--loss); }
.hero-figure { font-size: var(--fs-hero); font-weight: 600; line-height: 1.05; letter-spacing: -0.035em; font-variant-numeric: proportional-nums; }
.hero-sub { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--sp-1); }
/* the Scorecard's key figures: one card, figures in a grid (not a card each) */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4) var(--sp-3); }
.summary-row .metric {
  background: var(--surface); border: 1px solid transparent; border-radius: var(--r-lg); padding: var(--sp-3) var(--sp-4);
}
.range-form { margin-bottom: var(--sp-3); }
.range-form input { min-height: var(--tap); }
.summary-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2); margin-bottom: var(--sp-4); }
.summary-row .metric-value { font-size: var(--fs-md); }

/* key-value grid */
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2) var(--sp-3); }
.kv-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kv-wide { grid-template-columns: 1fr; }
.kv-wide > div { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv-wide > div:last-child { border-bottom: 0; }
.kv dt, .kv-label { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.kv-wide dd { text-align: right; }

/* chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 700; line-height: 1.6; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.chip-accepted, .chip-pass, .chip-taken { background: var(--profit-bg); color: var(--profit); }
.chip-failed { background: var(--loss-bg); color: var(--loss); }
.chip-skipped_cap, .chip-skipped, .chip-warn, .chip-high { background: var(--warn-bg); color: var(--warn); }
.chip-medium { background: var(--info-bg); color: var(--info); }
.chip-neutral { background: var(--surface-3); color: var(--text-2); }
.bias {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--r-pill);
  font-weight: 700; font-size: var(--fs-sm); background: var(--surface-3); color: var(--text);
  border: 1px solid var(--line-strong);
}
.bias::before { font-size: 10px; line-height: 1; }
.bias-long_only::before { content: "\25B2"; color: var(--profit); }
.bias-short_only::before { content: "\25BC"; color: var(--loss); }
.bias-both::before { content: "\25C6"; color: var(--info); }
.bias-flat::before { content: "\25A0"; color: var(--muted); }
.side {
  display: inline-flex; align-items: center; gap: 2px; margin-left: 4px; padding: 0 8px 0 4px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; vertical-align: 2px;
  background: var(--surface-3); color: var(--text-2);
}
.side .icon { width: 14px; height: 14px; vertical-align: 0; }
.side-long .icon { color: var(--profit); }
.side-short .icon { color: var(--loss); }
.level-chip {
  display: inline-flex; padding: 1px 8px; margin: 2px 4px 2px 0; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 600; background: var(--surface-2); border: 1px solid var(--line);
}
.level-chip::before { content: ""; width: 8px; height: 2px; margin: auto 6px auto 0; background: var(--muted); }
.level-chip.level-support::before { background: var(--lvl-support); }
.level-chip.level-resistance::before { background: var(--lvl-resist); }
.level-chip.level-both::before { background: var(--lvl-both); }
.levels-line { margin-top: var(--sp-3); line-height: 2; }
.levels-line .kv-label { margin-right: 6px; }

/* filter chips and switches */
.filters { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.filter-chip, .switch-item {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 16px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid transparent; color: var(--text-2);
  font-weight: 600; font-size: var(--fs-sm); text-decoration: none;
}
.filter-chip:hover, .switch-item:hover { color: var(--text); background: var(--surface-3); }
.filter-chip.current, .switch-item.current { background: var(--primary); color: var(--on-primary); border-color: transparent; }
.switch-sep { width: 1px; height: 24px; background: var(--line-strong); margin: 0 4px; }
.more-filters > summary, .disclosure > summary {
  display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--tap); cursor: pointer;
  font-weight: 600; font-size: var(--fs-sm); color: var(--text-2); list-style: none;
}
.more-filters > summary::-webkit-details-marker, .disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after {
  content: ""; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: url("icons/chevron.svg") center / contain no-repeat; mask: url("icons/chevron.svg") center / contain no-repeat;
  transition: transform 0.15s;
}
.disclosure[open] > summary::after { transform: rotate(90deg); }
.disclosure { margin-top: var(--sp-2); }
.filter-form { display: grid; gap: var(--sp-3); padding: var(--sp-3) 0; }
.filter-form.filter-inline { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3); padding: 0; }
.filter-inline .field { flex: 1 1 140px; }
.filter-inline .button-row { margin: 0; }

/* forms */
.stack { display: grid; gap: var(--sp-4); }
.field { display: grid; gap: 6px; min-width: 0; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong);
  font: 400 16px/1.4 var(--font); font-variant-numeric: tabular-nums;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: transparent; }
.form-title { font-size: var(--fs-md); margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--line); }

/* empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-4); color: var(--muted); font-size: var(--fs-sm);
}
.empty > .icon { display: none; } /* minimalist: words, not decoration */
.empty p { max-width: 36ch; }
.empty-small { padding: var(--sp-3) var(--sp-2); flex-direction: row; text-align: left; }
.empty-small > .icon { width: 32px; height: 32px; padding: 7px; }
.empty-inline { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--sp-3); }

/* tables */
.table-wrap { overflow-x: auto; margin: var(--sp-2) 0; border: 1px solid var(--line); border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child, th:nth-child(2):not(:last-child) { text-align: left; }
th { font-size: var(--fs-sm); font-weight: 700; color: var(--muted); background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.total td { font-weight: 700; background: var(--surface-2); }

/* ==== 5. Screens ================================================================================= */

/* Home */
.spark { margin-top: var(--sp-3); }
.spark-svg { display: block; overflow: visible; }
.spark-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-line.pos { stroke: var(--profit); }
.spark-line.neg { stroke: var(--loss); }
.spark-area { stroke: none; opacity: 0.12; }
.spark-area.pos { fill: var(--profit); }
.spark-area.neg { fill: var(--loss); }
.spark-dot { stroke: var(--surface); stroke-width: 2; }
.spark-dot.pos { fill: var(--profit); }
.spark-dot.neg { fill: var(--loss); }
.spark figcaption { font-size: var(--fs-sm); color: var(--muted); margin-top: var(--sp-1); }
.pl { font-size: var(--fs-md); font-weight: 700; text-align: right; line-height: 1.2; white-space: nowrap; }
.pl-r { display: block; font-size: var(--fs-sm); font-weight: 600; opacity: 0.9; }
.view-now .card-head h3 { font-size: var(--fs-md); }
.view-line { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.age { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); white-space: nowrap; }
.age .icon { width: 14px; height: 14px; vertical-align: 0; }
.reason { margin-top: var(--sp-3); color: var(--text-2); font-size: var(--fs-sm); font-style: italic; }
.stale { border-color: var(--warn-line); }
.age-stale { color: var(--warn); }
.stale-note {
  display: flex; gap: 6px; align-items: flex-start; margin-top: var(--sp-3); padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--warn-bg); color: var(--warn); font-size: var(--fs-sm); font-weight: 600;
}
.stale-note .icon { width: 16px; height: 16px; margin-top: 2px; vertical-align: 0; }
.countdown { font-size: var(--fs-xl); font-weight: 600; color: var(--accent); line-height: 1.2; }
.countdown-in { font-size: var(--fs-md); color: var(--muted); font-weight: 500; }
.countdown-what { margin-top: var(--sp-1); color: var(--text-2); font-size: var(--fs-sm); }
.feed { list-style: none; padding: 0; display: grid; gap: 2px; }
.feed-item { display: flex; gap: var(--sp-3); padding: 8px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); color: var(--text-2);
}
.feed-icon .icon { width: 16px; height: 16px; vertical-align: 0; }
.feed-entry .feed-icon { color: var(--info); }
.feed-exit .feed-icon { color: var(--profit); }
.feed-stop .feed-icon { color: var(--loss); }
.feed-skip { opacity: 0.75; }
.feed-body { min-width: 0; flex: 1; }
.feed-title { font-weight: 600; font-size: var(--fs-sm); }
.feed-detail { color: var(--muted); font-size: var(--fs-sm); }
.lock-list { list-style: none; padding: 0; display: grid; gap: var(--sp-2); }
.lock { display: flex; gap: var(--sp-2); align-items: center; font-weight: 600; color: var(--loss); }

/* Views */
.timeline { list-style: none; padding: 0 0 0 20px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 2px; background: var(--line); border-radius: 2px; }
.timeline-item { position: relative; }
.timeline-dot {
  position: absolute; left: -20px; top: 22px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--profit); box-shadow: 0 0 0 3px var(--bg);
}
.status-failed .timeline-dot { background: var(--loss); }
.status-skipped_cap .timeline-dot { background: var(--warn); }
.view-time { font-size: var(--fs-md); }
.view-card .meta-line { margin-top: calc(-1 * var(--sp-2)); }
.view-inst { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.view-inst-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-2); }
.view-inst-head h3 { font-size: var(--fs-md); margin-right: 4px; }
.view-inst .levels-line + .small, .view-inst .small { margin-top: var(--sp-2); }
.reasons { margin: var(--sp-3) 0 0; padding-left: 18px; color: var(--text-2); }
.reasons li + li { margin-top: 4px; }
.problems { padding-left: 0; list-style: none; }
.scores { list-style: none; padding: 0; margin-top: var(--sp-3); display: flex; flex-wrap: wrap; gap: 6px; }
.score {
  padding: 3px 10px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-strong);
}
.score-right { background: var(--profit-bg); color: var(--profit); border: 1px solid transparent; }
.score-wrong { background: var(--loss-bg); color: var(--loss); border: 1px solid transparent; }
.score-abstained { border-style: solid; color: var(--text-2); }
.pager { margin: var(--sp-4) 0; }

/* Trades */
.trade-list { list-style: none; padding: 0; display: grid; gap: var(--sp-3); }
.trade-list .card { margin: 0; }
.trade-title { font-size: var(--fs-md); }
.trade-setup { color: var(--text-2); font-size: var(--fs-sm); margin: calc(-1 * var(--sp-2)) 0 var(--sp-3); }
.trade .kv + .small { margin-top: var(--sp-2); }
.trade-skipped { background: transparent; border-style: dashed; border-color: var(--line-strong); color: var(--text-2); }
.trade-skipped .trade-title, .trade-skipped .kv dd { color: var(--text-2); font-weight: 500; }
.skip-reason { display: flex; gap: 6px; align-items: flex-start; margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--muted); }
.skip-reason .icon { width: 16px; height: 16px; margin-top: 2px; vertical-align: 0; }

/* Charts (shared) */
.chart-frame { position: relative; margin: var(--sp-2) 0; touch-action: pan-y; }
.chart, .viz-svg { display: block; overflow: visible; font-family: var(--font); }
.grid { stroke: var(--grid); stroke-width: 1; }
.axis, .tick { stroke: var(--axis); stroke-width: 1; }
.axis-label {
  fill: var(--muted); font-size: 11px; font-weight: 500;
  paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round;
}
.price-label { text-anchor: end; }
.time-label { text-anchor: middle; }
.time-label.edge-start { text-anchor: start; }
.time-label.edge-end { text-anchor: end; }
.y-label { text-anchor: start; }
.crosshair { stroke: var(--text-2); stroke-width: 1; opacity: 0; pointer-events: none; }
.chart-frame.hovering .crosshair { opacity: 0.6; }
.chart-tip {
  position: absolute; top: 0; left: 0; z-index: 5; display: none; pointer-events: none;
  max-width: 240px; padding: 8px 10px; border-radius: var(--r-sm);
  background: var(--surface-3); border: 1px solid var(--line-strong); box-shadow: var(--shadow-2);
  font-size: var(--fs-sm); font-weight: 600; color: var(--text); line-height: 1.45;
}
.chart-frame.hovering .chart-tip { display: block; }
.legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--text-2); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend-values { font-size: var(--fs-sm); margin: var(--sp-2) 0 0; }
.legend-values strong { color: var(--text); }
.key { display: inline-block; flex: none; }
.key-line { width: 16px; height: 0; border-top: 2px solid var(--muted); }
.key-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.key-line.level-support { border-color: var(--lvl-support); }
.key-line.level-resistance { border-color: var(--lvl-resist); }
.key-line.level-both { border-color: var(--lvl-both); }
.key-line.weak-key { border-top-style: dashed; border-color: var(--muted); }
.key-line.vlevel-key { border-top-style: dotted; border-top-width: 3px; border-color: var(--accent); }
.key-line.stop-key { border-top-style: dashed; border-color: var(--loss); }
.key-line.series-s1 { border-color: var(--s1); }
.key-line.series-s2 { border-color: var(--s2); }
.key-line.series-s3 { border-color: var(--s3); border-top-style: dashed; }
.key-dot.mark-entry { background: var(--text); }
.key-dot.mark-exit-win { background: var(--profit); }
.key-dot.mark-exit-loss { background: var(--loss); }
.viz { margin: var(--sp-4) 0 var(--sp-2); }
.viz-title { font-size: var(--fs-sm); font-weight: 600; }

/* Chart screen: candles and levels */
.chart-symbol { font-size: var(--fs-md); }
.chart-last { font-size: var(--fs-md); font-weight: 700; color: var(--accent); white-space: nowrap; }
.candle .wick { stroke-width: 1; }
.candle.up .wick { stroke: var(--candle-up); }
.candle.up .body { fill: var(--candle-up); }
.candle.down .wick { stroke: var(--candle-down); }
.candle.down .body { fill: var(--candle-down); }
.gap-mark { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.6; }
.level { stroke-width: 1; opacity: 0.85; }
.level-support { stroke: var(--lvl-support); }
.level-resistance { stroke: var(--lvl-resist); }
.level-both { stroke: var(--lvl-both); }
.level.weak { stroke-dasharray: 4 3; opacity: 0.6; }
.vlevel { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 1 3; stroke-linecap: round; }
.level-label {
  font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round;
}
text.level-support { fill: var(--lvl-support); }
text.level-resistance { fill: var(--lvl-resist); }
text.level-both { fill: var(--lvl-both); }
text.level-label.from-view { fill: var(--accent); }
.last-line { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 2; opacity: 0.8; }
.stop-line { stroke: var(--loss); stroke-width: 1.5; stroke-dasharray: 4 3; }
.trade-mark { stroke: var(--surface); stroke-width: 2; }
.mark-entry { fill: var(--text); }
.mark-exit-win { fill: var(--profit); }
.mark-exit-loss { fill: var(--loss); }
.mark-exit-flat { fill: var(--muted); }
.level-list { list-style: none; padding: 0; }
.level-row {
  display: grid; grid-template-columns: auto 1fr; column-gap: var(--sp-3); align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.level-row:last-child { border-bottom: 0; }
.level-row.off-chart { opacity: 0.7; }
.level-price { font-weight: 700; grid-row: 1 / span 2; min-width: 6.5ch; }
.level-price.level-support { color: var(--lvl-support); }
.level-price.level-resistance { color: var(--lvl-resist); }
.level-price.level-both { color: var(--lvl-both); }
.level-name { font-weight: 500; }
.level-meta { font-size: var(--fs-sm); color: var(--muted); grid-column: 2; }

/* Scorecard */
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.series-s1 { stroke: var(--s1); }
.series-s2 { stroke: var(--s2); }
.series-s3 { stroke: var(--s3); }
.series-line.series-s3 { stroke-dasharray: 6 4; }
.end-dot { stroke: var(--surface); stroke-width: 2; }
.flow-mark { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; } /* money in and out (0099) */
.flow-label { fill: var(--accent); font-weight: 600; }
.flow-label.edge-end { text-anchor: end; }
circle.series-s1 { fill: var(--s1); }
circle.series-s2 { fill: var(--s2); }
circle.series-s3 { fill: var(--s3); }
/* Mode race: five books, colour plus a dash pattern each (Low solid, Medium long dash, Higher solid, Gambling dotted, Lunatic dash-dot) */
.series-m1 { stroke: var(--m1); }
.series-m2 { stroke: var(--m2); }
.series-m3 { stroke: var(--m3); }
.series-m4 { stroke: var(--m4); }
.series-line.series-m2 { stroke-dasharray: 9 4; }
.series-m5 { stroke: var(--m5); }
.series-line.series-m4 { stroke-dasharray: 1 4; stroke-width: 2.5; }
.series-line.series-m5 { stroke-dasharray: 10 3 2 3; }
circle.series-m1 { fill: var(--m1); }
circle.series-m2 { fill: var(--m2); }
circle.series-m3 { fill: var(--m3); }
circle.series-m4 { fill: var(--m4); }
circle.series-m5 { fill: var(--m5); }
.key-line.series-m1 { border-color: var(--m1); }
.key-line.series-m2 { border-color: var(--m2); border-top-style: dashed; }
.key-line.series-m3 { border-color: var(--m3); }
.key-line.series-m4 { border-color: var(--m4); border-top-style: dotted; border-top-width: 3px; }
.key-line.series-m5 { border-color: var(--m5); border-top-style: double; border-top-width: 3px; }
.race-table .key-line { display: inline-block; width: 18px; margin-right: var(--sp-2); vertical-align: middle; }
.race-lock { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); }
.race-lock .icon { width: 16px; height: 16px; }
/* Past races and the real (demo) row: the real account is a neutral grey line, never a race colour */
.key-line.key-real { border-color: var(--text-2); border-top-style: dashed; }
.race-table .race-real td, .past-table .race-real td, .across-table .race-real td { border-top: 1px dashed var(--line); }
.past-table .key-line, .across-table .key-line { display: inline-block; width: 18px; margin-right: var(--sp-2); vertical-align: middle; }
.past-table .past-head th { text-align: left; font-weight: 700; padding-top: var(--sp-4); }
.past-table .past-race:first-of-type .past-head th { padding-top: var(--sp-2); }
.past-table .past-winner td:first-child { font-weight: 700; }
/* No-scalp twins (docs/decisions.md "No-scalp twins"): the mode's colour, short-dashed, thinner and muted,
   right after the mode it copies. After the m1..m5 rules so the twin's dash wins. */
.series-line.series-twin { stroke-dasharray: 3 3; stroke-width: 1.5; opacity: 0.6; }
circle.series-twin { opacity: 0.6; }
.key-line.series-twin { border-top-style: dashed; border-top-width: 2px; opacity: 0.6; }
.race-table .race-twin td, .past-table .race-twin td, .across-table .race-twin td { color: var(--text-2); }
.seg-nav .seg-label { align-self: center; padding: 0 var(--sp-2) 0 10px; font-size: var(--fs-sm); white-space: nowrap; }
.seg-nav .switch-item.switch-twin:not(.current) { color: var(--muted); }
.past-table .chip .icon { width: 14px; height: 14px; }
.past-races h3 { margin-top: var(--sp-5); }
.hit { fill: transparent; cursor: crosshair; }
.verdict { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); font-size: var(--fs-md); }
.verdict-icon { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; align-items: center; justify-content: center; flex: none; }
.verdict-icon .icon { width: 16px; height: 16px; vertical-align: 0; }
.verdict-pos .verdict-icon, .verdict.pos .verdict-icon { background: var(--profit-bg); color: var(--profit); }
.verdict-neg .verdict-icon, .verdict.neg .verdict-icon { background: var(--warn-bg); color: var(--warn); }
.verdict.pos, .verdict.neg { color: var(--text); }
.bars { list-style: none; padding: 0; display: grid; gap: var(--sp-3); margin-top: var(--sp-2); }
.bar-row { display: grid; grid-template-columns: 44px 1fr 48px; column-gap: var(--sp-3); align-items: center; }
.bar-label { font-weight: 700; font-size: var(--fs-sm); }
.bar-svg { display: block; overflow: visible; }
.bar-track { fill: var(--surface-3); }
.bar-fill { fill: var(--s1); }
.bar-ref { stroke: var(--text-2); stroke-width: 1; }
.bar-value { font-weight: 700; text-align: right; }
.bar-note { grid-column: 2 / span 2; font-size: var(--fs-sm); color: var(--muted); }
.bar-row:hover .bar-fill { opacity: 0.85; }
.checklist { list-style: none; padding: 0; margin-top: var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-md); }
.check-row { display: grid; grid-template-columns: auto 1fr auto; gap: var(--sp-3); align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.check-row:last-child { border-bottom: 0; }
.check-icon { display: inline-flex; width: 28px; height: 28px; border-radius: 50%; align-items: center; justify-content: center; }
.check-icon .icon { width: 16px; height: 16px; vertical-align: 0; }
.pass .check-icon { background: var(--profit-bg); color: var(--profit); }
.fail .check-icon { background: var(--warn-bg); color: var(--warn); }
.check-body { display: flex; flex-direction: column; min-width: 0; }
.check-detail { font-size: var(--fs-sm); color: var(--muted); }
.check-state { font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; }
.pass .check-state { color: var(--profit); }
.fail .check-state { color: var(--warn); }

/* Settings (docs/decisions/0083): Trading mode, Markets and History are folded cards; every settings
   section is a folded <details> in one "All settings" card, its summary one line (title, then a muted
   line with the count, the lead values and any flag); each setting is a <details> row: title on the
   left, the value right-aligned in one column, a chevron. An open row is a quiet tile holding the help,
   the control and "Review change"; the technical name and last change sit small at its foot. */
.settings-page { max-width: 880px; margin: 0 auto; } /* a readable column: titles near their values */
.card-fold { padding-top: 0; padding-bottom: 0; }
.card-fold, .set-group, .set-item { scroll-margin-top: 96px; } /* clear of the sticky top bar */
.fold-sum {
  display: flex; align-items: center; gap: var(--sp-3); min-height: 56px; padding: var(--sp-3) 0;
  cursor: pointer; list-style: none;
}
.fold-sum::-webkit-details-marker, .set-row::-webkit-details-marker { display: none; }
.fold-head { display: grid; gap: 2px; flex: 1; min-width: 0; }
.fold-title { font-size: var(--fs-md); font-weight: 600; color: var(--text); line-height: 1.3; }
.fold-meta { font-size: var(--fs-sm); color: var(--muted); line-height: 1.4; overflow-wrap: break-word; }
.fold-sum:hover .fold-title, .set-row:hover .set-title {
  text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong);
}
.flag { display: inline-flex; align-items: center; gap: 4px; margin-right: var(--sp-2); font-weight: 600; }
.flag .icon { width: 14px; height: 14px; vertical-align: 0; }
.flag-warn { color: var(--warn); }
.flag-error { color: var(--loss); }
.chev { display: flex; flex: none; color: var(--muted); }
.chev .icon { width: 16px; height: 16px; transition: transform 0.15s ease; }
details[open] > summary > .chev .icon { transform: rotate(180deg); }
.fold-body { padding-bottom: var(--sp-4); }
.fold-body > .help:first-child { margin-top: 0; }
.set-groups { padding-bottom: var(--sp-1); }
.set-groups > h2 { margin-bottom: 0; }
.set-group + .set-group { border-top: 1px solid var(--line); }
.set-note { padding-bottom: var(--sp-2); }
.set-note .help { margin-top: var(--sp-1); }
.set-list { padding-bottom: var(--sp-3); }
.set-item + .set-item { border-top: 1px solid var(--line); }
.set-item[open], .set-item[open] + .set-item { border-top-color: transparent; }
.set-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 16px; align-items: center; column-gap: var(--sp-3);
  min-height: var(--tap); padding: var(--sp-2) 0; cursor: pointer; list-style: none;
}
.set-title { color: var(--text-2); line-height: 1.35; overflow-wrap: break-word; }
.set-value {
  justify-self: end; max-width: 11em; text-align: right; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1.35; overflow-wrap: break-word;
}
.set-value .icon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.set-value-pending { color: var(--warn); }
.set-value-fixed { color: var(--text-2); }
.set-item[open] {
  background: var(--surface-2); border-radius: var(--r-sm); margin: 0 calc(-1 * var(--sp-2)); padding: 0 var(--sp-2);
}
.set-item[open] > .set-row .set-title { color: var(--text); font-weight: 600; }
.set-item[open] input, .set-item[open] select, .set-item[open] .btn-secondary { background: var(--surface); }
.set-item[open] .btn-secondary { border-color: var(--line-strong); }
.set-item[open] .btn-secondary:hover { background: var(--surface-3); }
.set-more { display: grid; gap: var(--sp-3); padding: var(--sp-1) 0 var(--sp-3); }
.set-more > * { margin: 0; }
.set-help, .set-now { font-size: var(--fs-sm); color: var(--text-2); line-height: 1.5; max-width: 65ch; }
.set-form { display: grid; gap: var(--sp-3); justify-items: start; }
.set-form .field { width: 100%; max-width: 360px; }
.set-form .caption { margin: 0; }
.unit-field { display: flex; align-items: center; gap: var(--sp-2); }
.unit-field input { flex: 1 1 auto; min-width: 0; max-width: 200px; }
.unit-field .unit { color: var(--text-2); white-space: nowrap; }
.set-meta { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.set-meta .key { font-size: 11px; color: var(--muted); }
.set-item.has-error { background: var(--loss-bg); border: 1px solid var(--loss-line); border-radius: var(--r-sm); }
.pending-list { list-style: none; padding: 0; margin: 0; }
.pending-row .row-head { color: var(--text); text-decoration: none; font-weight: 600; }
.pending-row .row-head:hover span:first-child { text-decoration: underline; text-underline-offset: 3px; }
@media (min-width: 720px) {
  .set-value { max-width: 18em; }
  .set-row { column-gap: var(--sp-4); }
}
.pending-row { padding: var(--sp-2) 0; }
.row-head { display: flex; justify-content: space-between; gap: var(--sp-3); align-items: baseline; }
.audit { list-style: none; padding: 0; }
.audit > li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.audit > li:last-child { border-bottom: 0; }
.audit-head { display: flex; justify-content: space-between; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--muted); }
.what { font-weight: 500; font-size: var(--fs-sm); overflow-wrap: anywhere; }

/* Week ahead */
.event-list { list-style: none; padding: 0; }
.event-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.event-row:last-child { border-bottom: 0; }
.switch-state { font-size: var(--fs-md); }
.playbook.skipped { opacity: 0.75; border-style: dashed; }
.buckets { list-style: none; padding: 0; margin-top: var(--sp-3); display: grid; gap: var(--sp-2); }
.bucket { padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.body-view { margin-top: var(--sp-2); }
dl.body { margin: 0; }
dl.body > div { padding: 6px 0; }
dl.body dt { font-weight: 700; font-size: var(--fs-sm); color: var(--muted); letter-spacing: 0.03em; }
dl.body dd { margin: 0 0 0 var(--sp-3); }
dl.body-0 > div { border-bottom: 1px solid var(--line); }
dl.body-0 > div:last-child { border-bottom: 0; }
.body-list { margin: 4px 0; padding-left: 18px; }

/* Confirm, login, setup */
.confirm-lines { display: grid; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.confirm-lead { margin-bottom: var(--sp-3); }
.confirm-change {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-2); margin-bottom: var(--sp-4);
  padding: var(--sp-3) var(--sp-4); background: var(--surface-2); border-radius: var(--r-md);
  font-size: var(--fs-xl); line-height: 1.2; font-weight: 600;
}
.confirm-old { color: var(--muted); font-weight: 400; }
.confirm-tech { margin-top: var(--sp-4); font-size: var(--fs-sm); color: var(--muted); }
.confirm { max-width: 560px; }
.auth-page { padding-bottom: 0; }
.auth-page .page { min-height: 100vh; display: flex; flex-direction: column; }
.auth-page .topbar { position: static; background: transparent; border: 0; }
.auth-page .topbar .brand { display: none; }
.auth-page .content { flex: 1; display: flex; align-items: flex-start; justify-content: center; width: 100%; padding-top: 6vh; }
.auth { width: 100%; max-width: 400px; padding: var(--sp-6); }
.auth-brand { text-align: center; margin-bottom: var(--sp-6); }
.auth-brand .lockup { margin-bottom: var(--sp-3); }
.auth-brand h1:not(.lockup) { font-size: var(--fs-xl); }
.tagline { color: var(--accent); font-weight: 500; font-size: var(--fs-sm); margin-top: 2px; }

/* Public home page on piprake.com (templates/landing.html): navy ground, lockup, a brass rule, a serif
   headline, one line, the markets in mono and "In private operation". Fixed colours: the page is always navy. */
.landing { padding: 0; background: var(--navy); color: var(--paper); }
.landing-main {
  min-height: 100vh; max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column;
  justify-content: space-between; gap: var(--sp-10);
  padding: var(--sp-6) max(var(--sp-5), env(safe-area-inset-right)) var(--sp-8) max(var(--sp-5), env(safe-area-inset-left));
}
/* the lockup as in the dashboard (.lockup): the mark at 1.35 x the 20 px type (27 px), the word pushed on
   0.114em so it starts 0.35em after the last tine (about twice the tine spacing). The mark's own left air
   (5 of its 32 units, 0.21em) is pulled back, as in the top bar, so its ink lines up with the rule, headline
   and markets below; the lockup's font size is the 20 px type, so that em is the word's. */
.landing-lockup {
  display: inline-flex; align-self: flex-start; align-items: center; gap: 0; font-size: 20px; margin-left: -0.21em;
}
.landing-mark { display: block; width: 27px; height: 27px; }
.landing-word { font-size: 20px; line-height: 1; font-weight: 600; letter-spacing: -0.005em; margin: 0 0 0 0.114em; }
.landing-hero { display: flex; flex-direction: column; gap: var(--sp-5); }
.landing-rule { width: 56px; height: 1px; background: var(--brass); }
.landing-head {
  font-family: var(--display); font-weight: 400; font-size: clamp(34px, 6vw, 56px); line-height: 1.08;
  letter-spacing: -0.015em; max-width: 15ch; margin: 0;
}
.landing-line { color: var(--paper-2); font-size: 17px; max-width: 52ch; margin: 0; }
.landing-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--sp-3) var(--sp-6);
  border-top: 1px solid var(--paper-line); padding-top: var(--sp-4);
}
.landing-markets { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-6); margin: 0; padding: 0; list-style: none;
  font-family: var(--mono); font-size: var(--fs-sm); color: var(--paper-3); }
.landing-soon { color: var(--brass); font-size: var(--fs-sm); font-weight: 600; margin: 0; }

/* Usability pass (docs/design/ux-review.md) */

/* Home: one sentence that answers "is it working?" (word + icon, never colour alone) */
.headline {
  display: flex; align-items: flex-start; gap: 6px; padding: 0 2px; margin: 0 0 var(--sp-3);
  border-radius: var(--r-pill); border: 1px solid transparent;
  font-weight: 600; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-2);
}
.headline .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.headline-warn, .headline-bad { padding: 6px 12px; border-radius: var(--r-md); }
.headline-ok .icon { color: var(--profit); }
.headline-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.headline-bad { background: var(--loss-bg); border-color: var(--loss-line); color: var(--loss); }

/* Home's top row: the headline, then the one arm / disarm switch */
.home-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-3); }
.home-head .headline { margin: 0; flex: 1 1 260px; }
.home-head .arm-control { flex: 0 1 auto; }
/* arm / disarm: two segments, the current state filled (Armed green, Disarmed grey) */
.arm-control { display: grid; gap: 4px; justify-items: start; }
.arm-toggle {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--line);
}
.arm-opt {
  display: inline-flex; align-items: center; justify-content: center; min-height: 38px; min-width: 96px;
  padding: 0 16px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600;
  color: var(--muted); text-decoration: none;
}
a.arm-opt:hover { color: var(--text); background: var(--surface-3); }
.arm-opt.current { color: var(--text); }
.arm-opt.arm-on { background: var(--mode-live-bg); color: var(--mode-live-text); }
.arm-opt.arm-off { background: var(--surface-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.arm-opt.arm-refused { opacity: 0.45; cursor: not-allowed; }
.arm-note { margin: 0; font-size: 11px; color: var(--muted); }
.arm-note .icon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.arm-locked .arm-note { color: var(--warn); }

/* the Trading pill is a link to arm / disarm (with its own confirmation) */
.pill-link { color: inherit; text-decoration: none; min-height: var(--tap); }
.pill-link:hover { border-color: var(--muted); }
.pill-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* swing / scalp: a word in a pill. Neutral for swing, info blue for scalp (not a state colour) */
.family {
  display: inline-flex; align-items: center; padding: 0 8px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 700; line-height: 1.6; letter-spacing: 0.02em; vertical-align: 2px;
  white-space: nowrap;
}
.family-swing { background: var(--surface-3); color: var(--text-2); border: 1px solid var(--line-strong); }
.family-scalp { background: var(--info-bg); color: var(--info); border: 1px solid transparent; }
.feed-title .family { margin-left: 2px; }
.family-split { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); }
.family-split li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--sp-2); font-size: var(--fs-sm); }
.family-split li .family { min-width: 52px; justify-content: center; }
.family-split-row { margin: calc(-1 * var(--sp-2)) 0 var(--sp-4); padding: var(--sp-3) var(--sp-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.family-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); margin-bottom: var(--sp-2); }
.family-card { display: grid; gap: 4px; align-content: start; padding: var(--sp-3); background: var(--surface-2); border-radius: var(--r-md); }

/* section heading with an action beside it (Home: "Ask Claude now") */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.section-head .section-title { margin-bottom: 0; }
.chip-note { flex-basis: 100%; font-size: var(--fs-sm); color: var(--muted); }
.control-state { margin-bottom: var(--sp-2); }

/* Trades table: one row per signal. Phone shows Time, Instrument, Side, Result, R; a tap opens the rest. */
.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-2); }
.toggle-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle {
  display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 0 14px; cursor: pointer;
  border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: 600;
}
.toggle::before { content: ""; width: 14px; height: 14px; border-radius: 4px; border: 2px solid var(--muted); flex: none; }
.toggle-input:checked + .toggle { color: var(--text); border-color: var(--muted); }
.toggle-input:checked + .toggle::before { background: var(--primary); border-color: var(--primary); }
.toggle-input:focus-visible + .toggle { outline: 2px solid var(--focus); outline-offset: 2px; }
.trades-wrap:has(.toggle-input:not(:checked)) .row-skipped { display: none; }
.trades-scroll {
  max-height: 75vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
}
.trades-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.trades-table th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2); text-align: left; padding: 0 8px;
  font-size: var(--fs-sm); font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
.trades-table td { padding: 6px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.trades-table .c-num { text-align: right; white-space: nowrap; }
.trades-table th.c-num { text-align: right; }
.th-sort {
  min-height: var(--tap); padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer;
}
.th-sort::after { content: ""; margin-left: 4px; }
th[aria-sort="ascending"] .th-sort::after { content: "\25B2"; font-size: 9px; }
th[aria-sort="descending"] .th-sort::after { content: "\25BC"; font-size: 9px; }
.row-main { cursor: pointer; }
.row-main:hover td { background: var(--surface-2); }
.row-toggle {
  min-height: 40px; padding: 0; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-align: left;
}
.trade-group.row-skipped td { color: var(--muted); }
.trade-group.row-skipped .side { opacity: 0.75; }
.cell-note { display: block; font-size: 11px; color: var(--muted); font-weight: 500; }
.trades-table .pos { color: var(--profit); font-weight: 600; }
.trades-table .neg { color: var(--loss); font-weight: 600; }
.row-detail td { background: var(--surface-2); border-top: 0; padding: 8px 12px 12px; }
.kv-detail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.js .row-detail { display: none; }
.js .trade-group.open .row-detail { display: table-row; }
.js .trade-group.open .row-main td { background: var(--surface-2); }
.trades-table .c-wide { display: none; }
.family-inline .family { margin-left: 2px; font-size: 11px; }
@media (min-width: 720px) {
  .trades-table .c-wide { display: table-cell; }
  .family-inline { display: none; }
  .row-detail { display: none; }
  .kv-detail { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Chart screen, calmer: soft grid, zones for close levels, labels kept apart at the right edge */
.chart .grid { opacity: 0.55; }
.chart .level { opacity: 0.7; }
.zone { opacity: 0.12; }
.zone-support { fill: var(--lvl-support); }
.zone-resistance { fill: var(--lvl-resist); }
.zone-both { fill: var(--lvl-both); }
.zone-view { fill: var(--accent); }
.chart .level-label { text-anchor: end; font-size: 11px; }
.key-band { width: 16px; height: 8px; border-radius: 2px; background: var(--muted); opacity: 0.4; }

/* the price ladder: levels above and below the last price */
.ladder { list-style: none; padding: 0; margin: 0 0 var(--sp-3); }
.ladder-row {
  display: grid; grid-template-columns: auto 1fr; column-gap: var(--sp-3); align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.ladder-price { font-weight: 700; min-width: 8ch; font-variant-numeric: tabular-nums; grid-row: 1 / span 2; }
.ladder-price.level-support { color: var(--lvl-support); }
.ladder-price.level-resistance { color: var(--lvl-resist); }
.ladder-price.level-both { color: var(--lvl-both); }
.ladder-price.level-view { color: var(--accent); }
.ladder-name { font-weight: 500; font-size: var(--fs-sm); }
.ladder-meta { grid-column: 2; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: var(--fs-sm); color: var(--muted); }
.ladder-weak .ladder-name { color: var(--text-2); }
.ladder-now { background: var(--surface-2); border-radius: var(--r-sm); padding: 8px; border: 1px solid var(--accent); margin: 4px 0; }
.ladder-now .ladder-price { color: var(--accent); }
.ladder-now .ladder-name { grid-row: 1 / span 2; align-self: center; font-weight: 700; }
.src-chip { padding: 0 6px; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); font-weight: 700; }
.src-chip.src-claude { color: var(--accent); }
.strength { display: inline-flex; gap: 2px; }
.strength .dot { width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--muted); }
.strength .dot.on { background: var(--text-2); border-color: var(--text-2); }
.ladder-dist { margin-left: auto; }

/* Scorecard: result by day, the account switch and the Analysis section */
.day-bar.pos { fill: var(--profit); }
.day-bar.neg { fill: var(--loss); }
.day-bar.flat { fill: var(--muted); }
.zero-line { stroke: var(--axis); stroke-width: 1; }
.filter-chip-off { opacity: 0.55; cursor: default; }
.kpis .metric-value .pos { color: var(--profit); }
.kpis .metric-value .neg { color: var(--loss); }
.analysis { margin-top: var(--sp-6); border-top: 1px solid var(--line); padding-top: var(--sp-4); }
.analysis > summary {
  display: grid; gap: 2px; min-height: var(--tap); cursor: pointer; padding: var(--sp-2) 0; margin-bottom: var(--sp-3); list-style: none;
}
.analysis > summary::-webkit-details-marker { display: none; }
.analysis-title { font-size: var(--fs-md); font-weight: 700; }
.analysis-title::after { content: " \25B8"; color: var(--muted); }
.analysis[open] .analysis-title::after { content: " \25BE"; }
.analysis-sub { font-size: var(--fs-sm); color: var(--muted); }
.why { color: var(--text-2); font-size: var(--fs-sm); margin-bottom: var(--sp-2); }

/* ==== 6. Wider screens =========================================================================== */

@media (max-width: 399px) {
  .menu-key { display: none; }
}

@media (min-width: 720px) {
  .content { padding: var(--sp-5) var(--sp-6); }
  .status-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: var(--sp-4); }
  .more-filters { flex-basis: 100%; }
  .filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: end; }
  .filter-form .button-row { grid-column: 1 / -1; }
  .trade-list { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

@media (min-width: 1024px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .topbar-row, .page-foot { max-width: 1240px; margin: 0 auto; }
  .topbar-row { padding: var(--sp-2) var(--sp-8); }
  .status-region { padding: 0 var(--sp-8); max-width: 1240px; margin: 0 auto; }
  .content { padding: var(--sp-5) var(--sp-8) var(--sp-8); }
  .card { padding: var(--sp-5); }
  .view-insts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--sp-6); }
  .chart-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--sp-4); align-items: start; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
}

@media (min-width: 1280px) {
  .trade-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Live prices (web/live.py, app.js part 6): a brief green or red flash on a change; older than 15 s the
   figure turns grey and says when it is from. The reduced-motion rule below switches the flash off. */
.live-value { font-variant-numeric: tabular-nums; border-radius: 4px; }
.live-value.live-stale { color: var(--muted); }
.live-value.live-stale::after { content: " as of " attr(data-asof); font-size: var(--fs-xs); font-weight: 400; }
.live-line { margin-bottom: var(--sp-3); }
.live-line .kv-label { margin-right: 6px; }
.flash-up { animation: live-flash-up 0.9s ease-out; }
.flash-down { animation: live-flash-down 0.9s ease-out; }
@keyframes live-flash-up { from { background: var(--profit-bg); } to { background: transparent; } }
@keyframes live-flash-down { from { background: var(--loss-bg); } to { background: transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (forced-colors: active) {
  .kill-button, .btn-danger { border: 2px solid ButtonText; }
  .mode-pill { border: 1px solid CanvasText; }
}

/* Trades: a compact summary line above the table */
.trade-summary {
  display: grid; gap: 2px; margin-bottom: var(--sp-3); padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.trade-summary .family-split { margin-top: var(--sp-2); }
.more-filters .chip-row { margin: var(--sp-2) 0; }
@media (max-width: 719px) {
  /* five columns that always fit 375 px: no sideways scroll */
  .trades-table { table-layout: fixed; font-size: var(--fs-sm); }
  .trades-table th, .trades-table td { padding-left: 6px; padding-right: 6px; }
  .trades-table th:nth-child(1) { width: 19%; }
  .trades-table th:nth-child(2) { width: 25%; }
  .trades-table th:nth-child(5) { width: 19%; }
  .trades-table th:nth-child(10) { width: 22%; }
  .trades-table th:nth-child(11) { width: 15%; }
  .trades-table .family-inline { display: block; }
  .trades-table .side { margin-left: 0; padding: 0 6px 0 2px; font-size: 11px; }
  .row-detail dd { overflow-wrap: anywhere; }
}
.trades-table td:nth-child(2) { text-align: left; }
.trades-table th, .trades-table td { text-align: left; white-space: normal; border-bottom: 0; }
.trades-table .c-num, .trades-table th.c-num { text-align: right; white-space: nowrap; }
.trades-table th { white-space: nowrap; }
/* entries as hollow rings, so a busy scalp day reads as outlines with the exits filled in */
.trade-mark.mark-entry { fill: var(--surface); stroke: var(--text-2); stroke-width: 1.5; }
.key-dot.mark-entry { background: transparent; border: 2px solid var(--text-2); }

/* Trading mode: the compact control on Home and the four cards on Settings (web/modes.py) */
.mode-bar { display: grid; gap: var(--sp-2) var(--sp-4); grid-template-columns: 1fr; align-items: center; }
.mode-bar-title { font-size: var(--fs-md); font-weight: 600; display: flex; align-items: baseline; gap: var(--sp-2); flex-wrap: wrap; }
.mode-bar-title .kv-label { text-transform: uppercase; letter-spacing: 0.08em; }
.mode-bar .help { margin-top: var(--sp-1); }
.mode-bar .help .icon { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.mode-bar-form { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.mode-bar-form select { flex: 1 1 140px; min-width: 0; }
.mode-cards { display: grid; gap: var(--sp-3); grid-template-columns: 1fr; margin-top: var(--sp-4); }
.mode-card {
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--sp-4);
  background: var(--surface-2); display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0;
}
.mode-card .card-head { margin-bottom: 0; }
.mode-card form { margin-top: auto; padding-top: var(--sp-2); }
.mode-card-current { border: 2px solid var(--primary); background: var(--surface); }
.mode-numbers { grid-template-columns: 1fr; gap: 0; }
.mode-numbers > div { display: flex; justify-content: space-between; gap: var(--sp-3); padding: 6px 0; border-bottom: 1px solid var(--line); }
.mode-numbers > div:last-child { border-bottom: 0; }
.mode-numbers dd { text-align: right; font-variant-numeric: tabular-nums; }
.chip-current { background: var(--primary); color: var(--on-primary); }
.chip-current .icon { width: 14px; height: 14px; }
/* Lunatic (docs/decisions.md "Lunatic mode"): a red-toned warning card */
.mode-card-lunatic { border-color: var(--loss-line); background: var(--loss-bg); }
.mode-card-lunatic.mode-card-current { border-color: var(--loss); }
.mode-card-lunatic h3, .mode-card-warning { color: var(--loss); }
.mode-card-warning { display: flex; gap: var(--sp-2); align-items: flex-start; font-weight: 600; font-size: var(--fs-sm); }
.mode-card-warning .icon { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.confirm-understand label { display: flex; gap: var(--sp-2); align-items: flex-start; color: var(--loss); }
.confirm-understand input { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.confirm-warning .icon { width: 18px; height: 18px; flex: none; }
@media (min-width: 720px) {
  .mode-bar { grid-template-columns: 1fr auto; }
  .mode-bar .link-more { grid-column: 1 / -1; }
  .mode-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .mode-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (min-width: 1440px) {
  .mode-cards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* ==== 7. Cleaner layout (docs/decisions.md "Cleaner layout") ===================================== */

/* small button: still a 44 px tap target, quieter text */
.btn-small { padding: 0 14px; font-size: var(--fs-sm); gap: 6px; }
.btn-small .icon { width: 16px; height: 16px; }

/* drop-down menus built on <details>: work without the script; app.js closes them on an outside tap */
.menu { position: static; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-button {
  display: inline-flex; align-items: center; gap: 4px; min-height: var(--tap); padding: 0 12px;
  border-radius: var(--r-pill); background: var(--surface-2); color: var(--text); cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; white-space: nowrap;
}
.menu-button:hover { background: var(--surface-3); }
.menu[open] > .menu-button { background: var(--surface-3); }
.menu-key { color: var(--muted); font-weight: 500; }
.menu-caret { width: 16px; height: 16px; vertical-align: 0; color: var(--muted); }
.menu-pending { width: 14px; height: 14px; vertical-align: 0; color: var(--warn); }
.menu-button.mode-gambling .mode-name, .menu-button.mode-lunatic .mode-name { color: var(--loss); }
.menu-item-lunatic .menu-item-label { color: var(--loss); }
.menu-panel {
  position: absolute; z-index: 40; top: calc(100% - 2px); left: var(--sp-4); right: var(--sp-4);
  display: grid; gap: 2px; padding: 6px; max-height: calc(100vh - 140px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
}
.menu-title { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); padding: 6px 10px 2px; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); min-height: var(--tap);
  padding: 8px 10px; border-radius: var(--r-md); color: var(--text); text-decoration: none;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.current { background: var(--surface-2); }
.menu-item .icon { color: var(--primary); width: 18px; height: 18px; }
.menu-item-text { display: grid; gap: 1px; min-width: 0; }
.menu-item-label { font-weight: 600; }
.menu-item-help { font-size: var(--fs-sm); color: var(--muted); line-height: 1.35; }
.menu-note { font-size: var(--fs-sm); color: var(--muted); padding: 6px 10px; }
.menu-note.warn-text { color: var(--warn); }
.menu-foot {
  display: flex; align-items: center; gap: 2px; min-height: var(--tap); padding: 0 10px; margin-top: 2px;
  border-top: 1px solid var(--line); font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
}
.menu-foot .icon { width: 16px; height: 16px; }

/* top bar: logo, account badge, the screens (desktop), then the mode menu and the theme button */
.top-tabs { display: none; align-items: center; gap: 2px; margin-left: var(--sp-3); }
@media (min-width: 1024px) { .top-tabs { display: flex; } }
.top-tab {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: var(--r-pill);
  color: var(--muted); text-decoration: none; font-size: var(--fs-sm); font-weight: 500;
}
.top-tab:hover { color: var(--text); }
.top-tab.active { color: var(--text); background: var(--surface-2); font-weight: 600; }
.topbar-end { display: flex; align-items: center; gap: var(--sp-1); margin-left: auto; }
.theme-toggle { margin: 0; }
.icon-button {
  display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap);
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-button:hover { background: var(--surface-2); color: var(--text); }
.icon-button .icon { width: 20px; height: 20px; vertical-align: 0; }
.icon-moon { display: none; }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: block; }
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] .icon-sun { display: none; }
  :root[data-theme="auto"] .icon-moon { display: block; }
}

/* the kill switch: at the foot of every screen, one tap, no confirmation */
.page-foot {
  display: grid; gap: var(--sp-3); padding: var(--sp-4) var(--sp-4) var(--sp-6); max-width: 640px; margin: 0 auto;
}
.page-foot .logout { justify-self: center; margin: 0; }
.page-foot .btn-quiet { color: var(--muted); }

/* Home layout (templates/_home_live.html): one grid, cards top-aligned so none stretches into a gap.
   Phone: one column in source order (Today, Open trades, Markets, locks, Recent trades, Next release and
   System). Desktop: row 1 Today | Open trades (the same height), row 2 Markets full width, locks full
   width when there are any, row 3 Recent trades | Next release and System stacked. */
.home-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); align-items: start; margin-bottom: var(--sp-3); }
.home-layout > .card, .home-layout > .stack-col { margin: 0; }
@media (min-width: 1024px) {
  .home-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .home-layout > .money { grid-column: 1; align-self: stretch; }
  .home-layout > .positions { grid-column: 2; align-self: stretch; }
  .home-layout > .markets, .home-layout > .home-locks { grid-column: 1 / -1; }
  .home-layout > .recent { grid-column: 1; }
  .home-layout > .home-side { grid-column: 2; }
}
.money-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: var(--sp-1) var(--sp-4); }
.money-cell { min-width: 0; }
.money-equity { text-align: right; }
.money .hero-figure { margin-top: 2px; }
.equity-figure { font-size: var(--fs-xl); font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; margin: 2px 0 4px; }
.money > .caption { margin-top: 2px; }
.money .family-split { margin-top: var(--sp-2); }
.spark { margin-top: var(--sp-2); }
.spark figcaption { font-size: 11px; }
@media (max-width: 399px) {
  .money .hero-figure { font-size: 36px; }
}
@media (max-width: 719px) {
  .fam-count, .spark figcaption, .wide-only { display: none; }
}
.markets .card-head, .positions .card-head { align-items: center; margin-bottom: var(--sp-1); }
.markets .card-head .link-more { min-height: 32px; }
.pos-list, .facts, .mkt-list { list-style: none; padding: 0; margin: 0; }

/* Home: the Markets table. One line per instrument (a <summary>); the row opens in place to Claude's
   reason, Tyler's view and the "Your view" control. Columns on a desktop: market, price, Claude, You,
   Bot, view age, chevron. A phone keeps market (price under the name), Claude, You and Bot. */
.mkt-grid {
  display: grid; align-items: center; column-gap: var(--sp-3);
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 76px 76px minmax(0, 1.3fr) 88px 16px;
  grid-template-areas: "name price claude you bot age chev";
}
.mkt-grid .mkt-name { grid-area: name; }
.mkt-grid .mkt-price { grid-area: price; }
.mkt-grid .mkt-claude { grid-area: claude; }
.mkt-grid .mkt-you { grid-area: you; }
.mkt-grid .mkt-bot { grid-area: bot; }
.mkt-grid .mkt-age { grid-area: age; }
.mkt-grid .mkt-chev { grid-area: chev; }
.mkt-head { padding-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 600; color: var(--muted); }
.mkt-head .mkt-price, .mkt-head .mkt-age { text-align: right; }
.mkt-item + .mkt-item { border-top: 1px solid var(--line); }
.mkt-row { min-height: var(--tap); padding: 6px 0; cursor: pointer; list-style: none; }
.mkt-row::-webkit-details-marker { display: none; }
.mkt-row:hover .mkt-label { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.mkt-name { display: flex; align-items: center; min-width: 0; font-weight: 600; }
.mkt-name .inst-20 { flex: none; }
.mkt-label { min-width: 0; overflow-wrap: anywhere; }
.mkt-name .tag-paper { flex: none; }
.mkt-price { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mkt-claude, .mkt-you { display: flex; align-items: center; min-width: 0; }
.lean-chip, .you-pill { min-height: 24px; padding: 0 8px; }
.you-pill {
  display: inline-flex; align-items: center; gap: 4px; border-radius: var(--r-pill); border: 1px solid var(--line-strong);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1; white-space: nowrap; color: var(--text-2);
}
.you-pill-up { color: var(--profit); }
.you-pill-down { color: var(--loss); }
.you-pill-sideways { color: var(--info); }
.mkt-add { display: inline-flex; align-items: center; min-height: 24px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap; }
.mkt-add:hover { color: var(--text); }
.mkt-bot { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); line-height: 1.3; }
.mkt-bot-lock { color: var(--warn); }
.mkt-age { justify-self: end; font-weight: 500; }
.mkt-chev { display: flex; justify-content: flex-end; color: var(--muted); }
.mkt-chev .icon { width: 16px; height: 16px; transition: transform 0.15s ease; }
.mkt-details[open] .mkt-chev .icon { transform: rotate(180deg); }
.mkt-more { display: grid; gap: 4px; padding: 0 0 var(--sp-3) 28px; }
.mkt-more > * { margin: 0; }
.mkt-reason { font-size: var(--fs-sm); color: var(--text-2); font-style: italic; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.mkt-more .stale-note { margin: 0; }
.mkt-more .owner-actions { margin-top: 4px; }
.mkt-more .mkt-views { justify-self: start; min-height: 32px; }
.mkt-foot { margin-top: var(--sp-2); font-size: 11px; }
.mkt-price .tag-narrow { display: none; }
@media (max-width: 719px) {
  /* 375 px: the name and price share the first column (the paper tag moves under the name, beside the
     price); Claude, You and Bot keep their own; the age and chevron go. */
  .mkt-grid {
    column-gap: 6px;
    grid-template-columns: minmax(0, 1fr) 58px 60px minmax(0, 72px);
    grid-template-areas: "name claude you bot" "price claude you bot";
  }
  .mkt-grid .mkt-age, .mkt-grid .mkt-chev, .mkt-head .mkt-price, .mkt-name .tag-wide, .wide-text { display: none; }
  .mkt-row { padding: 8px 0; }
  .mkt-name { font-size: var(--fs-sm); }
  .mkt-name .inst-20 { width: 16px; height: 16px; margin-right: 6px; }
  .mkt-label { overflow-wrap: normal; }
  .mkt-row .mkt-price {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; padding-left: 22px;
    white-space: normal; text-align: left; font-size: 12px; color: var(--muted);
  }
  .mkt-price .tag-narrow { display: inline-block; flex: none; margin-left: 0; padding: 0 5px; font-size: 10px; }
  .lean-chip, .you-pill { padding: 0 6px; }
  .mkt-bot { font-size: 12px; }
  .mkt-more { padding-left: 0; }
}
.position-card {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--sp-3); align-items: center;
  padding: var(--sp-2) 0; border-top: 1px solid var(--line);
}
.position-card:first-child { border-top: 0; padding-top: 0; }
.pos-title { font-weight: 600; }
.pos-title .side { margin-left: 2px; }
.pos-sub { font-size: var(--fs-sm); color: var(--muted); }
.pos-levels { grid-column: 1 / -1; font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.pos-levels .num { color: var(--text-2); }
.pos-costs { grid-column: 1 / -1; font-size: var(--fs-sm); margin-top: 2px; }
.pl-r { display: block; font-size: var(--fs-sm); font-weight: 600; opacity: 0.9; }
.feed-item { align-items: center; }
.feed-value { font-size: var(--fs-sm); font-weight: 600; text-align: right; white-space: nowrap; }
.stack-col { display: grid; gap: var(--sp-3); align-content: start; margin-bottom: var(--sp-3); }
.stack-col > .card { margin: 0; }
.fact {
  display: flex; align-items: center; gap: var(--sp-2); min-height: 40px; border-top: 1px solid var(--line); font-size: var(--fs-sm);
}
.fact:first-child { border-top: 0; }
.fact > .icon { width: 18px; height: 18px; color: var(--muted); }
.fact-label { color: var(--muted); }
.fact .pill-value, .fact-link { margin-left: auto; font-size: var(--fs-sm); font-weight: 600; }
.fact-link { display: inline-flex; align-items: center; gap: 2px; min-height: var(--tap); color: var(--text); text-decoration: none; }
.fact-link .icon { width: 16px; height: 16px; color: var(--muted); }
.fact-ok > .icon { color: var(--profit); }
.fact-warn > .icon, .fact-warn .pill-value { color: var(--warn); }
.fact-bad > .icon, .fact-bad .pill-value { color: var(--loss); }
.system .caption { margin-top: var(--sp-1); }
.countdown { font-size: var(--fs-xl); }
.countdown-in { font-size: var(--fs-sm); }
.controls .button-row { margin-top: var(--sp-1); }
.controls .caption { margin-top: var(--sp-2); }
.empty-inline { margin-top: var(--sp-1); }
.chart-symbol, .view-time { color: var(--text); font-size: var(--fs-md); }

/* segmented switches (instrument, timeframe, account): one grey track, the chosen one lifted */
.seg-nav { display: inline-flex; flex-wrap: nowrap; gap: 2px; padding: 2px; border-radius: var(--r-pill); background: var(--surface-2); }
.seg-nav .switch-item {
  min-height: 40px; padding: 0 14px; border: 0; background: transparent; color: var(--text-2); font-size: var(--fs-sm);
}
.seg-nav .switch-item:hover { color: var(--text); }
.seg-nav .switch-item.current { background: var(--primary); color: var(--on-primary); }
/* Trades: the Book and Open/Closed switches; on a phone each scrolls sideways in its own row */
.trade-switches { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-3); min-width: 0; }
.seg-scroll { max-width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.seg-scroll::-webkit-scrollbar { display: none; }
.seg-scroll .switch-item { flex: none; white-space: nowrap; gap: 4px; }
.seg-count { font-variant-numeric: tabular-nums; opacity: 0.75; font-weight: 600; }
.seg-scroll .switch-item .tag-paper { margin-left: 2px; }
.seg-scroll .switch-item.current .tag-paper { background: var(--on-primary); color: var(--primary); }

@media (min-width: 720px) { .trade-switches { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: var(--sp-4); } }

/* Week ahead: expected outcome rows with a range bar, analysis, a calendar by day, the feed line */
.outcome-list, .risk-list, .change-list, .calendar, .cal-items { list-style: none; padding: 0; margin: 0; }
.outcome-row { padding: var(--sp-3) 0; border-top: 1px solid var(--line); }
.outcome-row:first-child { border-top: 0; padding-top: 0; }
.outcome-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.outcome-name { font-weight: 600; }
.outcome-price { margin-left: auto; font-weight: 600; }
.outcome-head .direction { font-size: var(--fs-sm); padding: 2px 12px; }
.direction-up { background: var(--profit-bg); color: var(--profit); }
.direction-down { background: var(--loss-bg); color: var(--loss); }
.direction-sideways { background: var(--info-bg); color: var(--info); }
.outcome-case { margin: var(--sp-1) 0 var(--sp-2); color: var(--text-2); font-size: var(--fs-sm); }
/* Labelled range bars (web/range_bar.py): start and end prices under the band, "Now" and wrong-if above */
.rbar { margin: var(--sp-2) 0 0; }
.rbar-cap { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.rbar-svg { display: block; overflow: visible; }
.rbar-track { fill: var(--surface-3); }
.rbar-band { fill: var(--s1); opacity: 0.55; }
.rbar-you .rbar-band { fill: transparent; stroke: var(--accent); stroke-width: 1.5; opacity: 1; }
.rbar-level { stroke: var(--muted); stroke-width: 1.5; }
.rbar-wrong { stroke: var(--loss); stroke-width: 2; stroke-dasharray: 3 2; }
.rbar-you .rbar-wrong { stroke: var(--accent); }
.rbar-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.rbar-dot.outside { fill: var(--warn); }
.rbar-text { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; fill: var(--text-2); }
.rbar-end { font-weight: 600; fill: var(--text); }
.rbar-now { fill: var(--text); }
.rbar-wrong-text { fill: var(--loss); }
.rbar-you .rbar-wrong-text { fill: var(--text-2); }
.wk-next { margin: 0 0 var(--sp-4); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--r-lg); }
.wk-next .label { margin-bottom: 2px; }
.wk-next-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--sp-2); }
.wk-next-when { color: var(--text-2); font-size: var(--fs-sm); }
.wk-legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); font-size: 11px; color: var(--muted); margin: 0 0 var(--sp-3); }
.wk-key { display: inline-block; width: 14px; height: 8px; border-radius: 4px; }
.wk-key-range { background: var(--s1); opacity: 0.55; }
.wk-key-dot { width: 8px; border-radius: 50%; background: var(--accent); }
.wk-key-wrong { width: 0; height: 12px; border-radius: 0; border-left: 2px dashed var(--loss); }
.wk-calls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-3); margin: var(--sp-1) 0 0; font-size: 11px; color: var(--muted); }
.wk-call { display: inline-flex; align-items: center; gap: 6px; }
.wk-call .direction { font-size: var(--fs-sm); padding: 2px 10px; }
.wk-differ { display: inline-flex; align-items: center; gap: 4px; color: var(--warn); font-size: var(--fs-sm); }
.wk-differ .icon { width: 14px; height: 14px; }
.wk-verdict { font-size: var(--fs-sm); color: var(--text-2); margin: 2px 0 0; }
.wk-you-meta { font-size: var(--fs-sm); color: var(--text-2); margin: 2px 0 0; }
.wk-you-why { display: block; font-size: var(--fs-sm); color: var(--text-2); margin: 2px 0 0; }
.wk-more { margin-top: var(--sp-2); }
.wk-more > summary { font-size: var(--fs-sm); min-height: 36px; }
.wk-more-body { display: grid; gap: var(--sp-3); padding-bottom: var(--sp-2); }
.wk-sub { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.wk-level { font-size: var(--fs-sm); font-weight: 600; padding: 2px 8px; border-radius: var(--r-sm); background: var(--surface-2); }
.levels-line .wk-level { margin: 0 6px 4px 0; display: inline-block; }
.wk-written { margin-top: var(--sp-3); }
.wk-intro { margin: 2px 0 var(--sp-2); }
.wk-views { list-style: none; padding: 0; margin: 0 0 var(--sp-2); display: grid; gap: var(--sp-2); }
.wk-views li { font-size: var(--fs-sm); }
.wk-views .help { display: block; margin-left: 0; }
.wk-views .inst-icon, .wk-views svg { vertical-align: -3px; margin-right: 6px; }
.wk-earlier { margin-bottom: var(--sp-2); }
.wk-impact-key { vertical-align: 1px; }
.wk-impact-key .dot.on { background: var(--warn); }
.wk-skip { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: var(--sp-1) 0 var(--sp-2); }
.wk-plan { list-style: none; padding: 0; margin: var(--sp-2) 0; display: grid; gap: var(--sp-2); }
.wk-bucket { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--line); border-radius: var(--r-sm); font-size: var(--fs-sm); }
.wk-bucket.middle { background: var(--surface-2); }
.wk-bucket-head { margin-bottom: 2px; }
.wk-bucket-lines { list-style: none; padding: 0; margin: 0; color: var(--text-2); }
.wk-releases > .disclosure > summary { font-weight: 500; }
.wk-switch { margin: var(--sp-2) 0; }
@media (min-width: 1024px) {
  .wk-markets { display: grid; grid-template-columns: 1fr 1fr; column-gap: var(--sp-8); }
  .wk-markets .outcome-row:nth-child(2) { border-top: 0; padding-top: 0; }
  .wk-more-body { grid-template-columns: 1fr 1fr; }
}
.risk-list li { font-size: var(--fs-sm); color: var(--text-2); padding-left: 14px; position: relative; }
.risk-list li::before { content: ""; position: absolute; left: 2px; top: 0.6em; width: 5px; height: 5px; border-radius: 50%; background: var(--warn); }
.change-row { padding: var(--sp-2) 0; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.calendar { display: grid; gap: var(--sp-2); }
.cal-day { padding: var(--sp-2) 0; border-top: 1px solid var(--line); }
.cal-day:first-child { border-top: 0; }
.cal-day.past { opacity: 0.6; }
.cal-day.today .cal-date { color: var(--text); }
.cal-date { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); margin-bottom: 4px; display: flex; gap: var(--sp-2); align-items: center; }
.cal-item { padding: 4px 0; }
.cal-item.past .cal-line, .cal-item.past .cal-meta, .cal-item.past .disclosure { opacity: 0.6; }
.cal-line { display: flex; align-items: center; gap: var(--sp-2); }
.cal-time { color: var(--text-2); min-width: 3.2em; font-size: var(--fs-sm); }
.cal-name { font-weight: 600; font-size: var(--fs-sm); }
.impact { display: inline-flex; gap: 2px; }
.impact .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--surface-3); }
.impact .dot.on { background: var(--muted); }
.impact-high .impact .dot.on { background: var(--warn); }
.cal-meta { font-size: 11px; color: var(--muted); margin-left: calc(3.2em + var(--sp-2)); }
.cal-item .disclosure { margin: 0 0 0 calc(3.2em + var(--sp-2)); }
.cal-figure { font-size: var(--fs-sm); color: var(--text-2); margin: 2px 0 0 calc(3.2em + var(--sp-2)); }
.cal-figure strong { color: var(--text); }
.cal-source, .cal-missing { color: var(--muted); font-size: 11px; }
.cal-item .stale-note { margin-left: calc(3.2em + var(--sp-2)); }
.cal-item .disclosure > summary { min-height: 32px; font-size: var(--fs-sm); }
.cal-empty { font-size: var(--fs-sm); color: var(--muted); }
.feed-foot { margin: 0 0 var(--sp-3); padding: 0 var(--sp-1); }
.feed-foot .disclosure > summary { color: var(--muted); font-weight: 500; }
@media (min-width: 1024px) {
  .calendar { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); }
  .cal-day { border-top: 0; border-left: 1px solid var(--line); padding: 0 var(--sp-3); }
  .cal-day:first-child { border-left: 0; padding-left: 0; }
  .cal-meta, .cal-item .disclosure, .cal-figure, .cal-item .stale-note { margin-left: 0; }
  .cal-line { flex-wrap: wrap; }
}

/* Views: one block per instrument (the view, what changes it, levels), then the history table */
.view-blocks { display: grid; gap: 0 var(--sp-3); }
.view-block-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--sp-3); margin-bottom: var(--sp-2); }
.view-block-name { font-size: var(--fs-md); color: var(--text); }
.view-block-price { font-weight: 600; }
.view-block-head .caption { margin-left: auto; }
.direction {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 14px; border-radius: var(--r-pill);
  font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.01em; background: var(--surface-2);
}
.direction::before { font-size: 12px; }
/* Claude's lean shown with the permission (Views, Home, Chart side panel; docs/decisions.md "Lean shown
   with the permission"): a small direction pill (26 px, 13 px text, an arrow), the confidence beside it,
   what the bot may do as one muted line, then "You:" and the combined line. */
.lean-pill {
  display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.lean-arrow { font-size: var(--fs-sm); line-height: 1; }
.lean-pill-up { background: var(--profit-bg); color: var(--profit); }
.lean-pill-down { background: var(--loss-bg); color: var(--loss); }
.lean-pill-none { background: var(--info-bg); color: var(--info); }
.lean-call { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-2); }
.lean-conf { font-size: var(--fs-sm); }
.lean-conf strong { font-size: var(--fs-md); font-weight: 600; }
.lean-permission { margin-top: 2px; font-size: var(--fs-sm); color: var(--muted); }
.lean-you { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }
.lean-combined { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-2); }
.view-facts-row {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; margin-top: var(--sp-2);
  font-size: var(--fs-sm); color: var(--muted);
}
.setups-disclosure { display: inline-block; }
.setups-disclosure > summary {
  display: inline; cursor: pointer; color: var(--text-2); text-decoration: underline;
  text-decoration-color: var(--line-strong); text-underline-offset: 2px; list-style: none;
}
.setups-disclosure > summary::-webkit-details-marker { display: none; }
.setup-list { margin: 4px 0 0; padding-left: 18px; color: var(--text-2); }
.view-block h3.label { margin: var(--sp-3) 0 var(--sp-1); }
.view-block h3.view-block-title { margin-top: 0; }
.view-changes { margin: 0; padding-left: 18px; font-size: var(--fs-sm); color: var(--text-2); line-height: 1.4; }
.view-changes li + li { margin-top: 2px; }
.view-block .levels-line { margin-top: 0; }
.view-history td { vertical-align: top; text-align: left; white-space: normal; }
.view-history th { text-align: left; }
.view-mini { display: inline-flex; align-items: center; gap: 4px; margin: 0 8px 4px 0; white-space: nowrap; }
.view-mini .bias { padding: 0 8px; font-size: var(--fs-sm); font-weight: 600; }
.view-history .scored .cell-note { white-space: normal; }
@media (min-width: 1024px) {
  .view-blocks { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

/* Chart: a toolbar, the Lightweight Charts chart (static/chart.js), a side panel. SVG: the no-script view. */
.chart-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.tools-menu { display: none; position: relative; }
.js-chart .tools-menu { display: block; }
.tools-panel { left: auto; right: auto; width: min(320px, calc(100vw - 32px)); top: calc(100% + 6px); }
.tool {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-height: 40px; padding: 4px 10px;
  border-radius: var(--r-md); font-size: var(--fs-sm); font-weight: 500; color: var(--text); cursor: pointer;
}
.tool:hover { background: var(--surface-2); }
.tool input { width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; accent-color: var(--primary); }
.tool-help { flex-basis: 100%; margin-left: 28px; font-size: 11px; color: var(--muted); }
.chart-readout {
  display: none; flex: 1 1 100%; flex-wrap: wrap; gap: 2px 12px; min-height: 20px;
  font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums;
}
.ohlc-time { color: var(--muted); }
.ohlc-key { color: var(--muted); font-weight: 600; }
.ohlc-note { flex-basis: 100%; color: var(--muted); }
.chart-last { font-size: var(--fs-xl); font-weight: 600; color: var(--accent); letter-spacing: -0.02em; }
.lw { display: none; position: relative; height: 280px; touch-action: pan-y; }
/* TradingView's attribution logo: the library injects these rules as a <style> element, which the CSP
   (style-src 'self') blocks, so they are copied here unchanged. */
a#tv-attr-logo {
  --fill: #131722; --stroke: #fff; position: absolute; left: 10px; bottom: 10px; height: 19px; width: 35px;
  margin: 0; padding: 0; border: 0; z-index: 3;
}
a#tv-attr-logo[data-dark] { --fill: #D1D4DC; --stroke: #131722; }
.chart-credit { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.js-only { display: none; }
.js-chart .chart-readout { display: flex; }
.js-chart .lw { display: block; }
.js-chart .svg-fallback { display: none; }
.js-chart .js-only { display: inline; }
.chart-failed .lw { display: none; }
.chart-failed .svg-fallback { display: block; }
.chart-card { padding: var(--sp-2) var(--sp-2) var(--sp-3); }
.window-links { margin: var(--sp-2); }
.chart-note { margin: var(--sp-2) var(--sp-2) 0; font-size: 11px; }
.chart-side { display: grid; gap: var(--sp-4); }
.side-head .chart-symbol { color: var(--muted); font-size: var(--fs-sm); font-weight: 600; }
.side-section { border-top: 1px solid var(--line); padding-top: var(--sp-3); }
.side-section > .label { margin-bottom: var(--sp-2); }
.side-section .ladder { margin-bottom: var(--sp-1); }
.side-section .lean-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); min-height: 0; }
.sizeup-list { list-style: none; padding: 0; margin: var(--sp-2) 0; font-size: var(--fs-sm); color: var(--text-2); }
.sizeup { display: grid; grid-template-columns: auto 1fr; column-gap: var(--sp-3); padding: 4px 0; }
.sizeup-price { font-weight: 700; color: var(--warn); min-width: 8ch; }
.sizeup.unused { color: var(--muted); }
.sizeup.unused .sizeup-price { color: var(--muted); text-decoration: line-through; }
.sizeup-reason { display: block; font-size: 11px; color: var(--muted); }
.ind-s1 .ohlc-key { color: var(--s1); }
.ind-s2 .ohlc-key { color: var(--s2); }

/* Levels strip under the chart (templates/_strip.html, static/strip.js): a price axis, the price in the
   middle, levels below it on the left and above it on the right. Tick height and weight are strength. */
.levels-strip { margin: var(--sp-3) var(--sp-2) 0; padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.levels-strip > .label { margin-bottom: var(--sp-1); }
.strip { position: relative; }
.strip-scroll { overflow-x: auto; overflow-y: hidden; max-width: 100%; -webkit-overflow-scrolling: touch; }
.strip-svg { display: block; min-width: 560px; overflow: visible; }
.strip-svg text { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.strip-side { font-weight: 600; }
.strip-svg .strip-side-end { text-anchor: end; }
.strip-axis { stroke: var(--axis); stroke-width: 1; }
.strip-grid { stroke: var(--axis); }
.strip-svg .strip-tick { text-anchor: middle; }
.strip-now line { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 2; }
.strip-svg .strip-now text {
  text-anchor: middle; font-weight: 700; fill: var(--accent); paint-order: stroke;
  stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round;
}
.strip-mark { cursor: pointer; outline: none; }
.strip-hit { stroke: transparent; stroke-width: 16; }
.strip-tick-mark { stroke: var(--lvl-support); stroke-linecap: butt; }
.strip-tick-mark.s1 { stroke-width: 1.5; }
.strip-tick-mark.s2 { stroke-width: 2.5; }
.strip-tick-mark.s3 { stroke-width: 3.5; }
.strip-leader { stroke: var(--line-strong); stroke-width: 1; }
.strip-svg .strip-label { text-anchor: middle; fill: var(--text-2); }
.strip-svg .strip-label.anchor-start { text-anchor: start; }
.strip-svg .strip-label.anchor-end { text-anchor: end; }
.lvl-resistance .strip-tick-mark { stroke: var(--lvl-resist); }
.lvl-both .strip-tick-mark { stroke: var(--lvl-both); }
.lvl-view .strip-tick-mark { stroke: var(--accent); }
.lvl-sizeup .strip-tick-mark { stroke: var(--warn); }
.strip-mark.weak .strip-tick-mark { stroke-dasharray: 3 2; opacity: 0.7; }
.strip-mark.broken .strip-tick-mark { stroke-dasharray: 2 2; }
.strip-svg .strip-mark.broken .strip-label { fill: var(--muted); text-decoration: line-through; }
.strip-svg .strip-mark:hover .strip-label, .strip-svg .strip-mark:focus .strip-label { fill: var(--text); font-weight: 600; }
.strip-mark:focus-visible .strip-leader { stroke: var(--focus); stroke-width: 2; }
.strip-tip {
  position: absolute; top: 2px; z-index: 5; display: grid; gap: 2px; max-width: min(320px, 100%);
  padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-3); color: var(--text);
  font-size: var(--fs-sm); box-shadow: var(--shadow-3); pointer-events: none;
}
.strip-tip[hidden] { display: none; }
.strip-tip-dist { font-weight: 600; font-variant-numeric: tabular-nums; }
.all-levels { margin-top: var(--sp-2); }
.broken-tag {
  margin-left: 4px; padding: 0 6px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600;
  color: var(--warn); background: var(--warn-bg);
}
@media (min-width: 720px) {
  .chart-readout { flex: 1 1 auto; justify-content: flex-end; }
}
@media (min-width: 1024px) {
  .lw { height: 400px; }
  .chart-layout { grid-template-columns: minmax(0, 1fr) 340px; gap: var(--sp-3); }
}

@media (min-width: 720px) {
  .money-row { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: end; }
  .menu.mode-menu { position: relative; }
  .mode-menu .menu-panel { left: 0; right: auto; width: 340px; top: calc(100% + 6px); }
}

/* Six instruments: the Markets card (Settings), the paper tag and the Exposure line (Home) */
.tag-paper {
  margin-left: 6px; padding: 1px 7px; border-radius: var(--r-pill); font-size: 11px; font-weight: 700;
  background: var(--surface-3); color: var(--text-2); vertical-align: 1px;
}
.exposure-line { margin: 0 0 var(--sp-2); }
.exposure-item { color: var(--text-2); font-weight: 600; }
.exposure-item.warn-text { color: var(--warn); }
.verdict {
  display: inline-flex; align-items: center; padding: 2px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 700; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.verdict-cheap { background: var(--profit-bg); color: var(--profit); }
.verdict-expensive { background: var(--warn-bg); color: var(--warn); }
.markets-table td:first-child { white-space: nowrap; }
.market-switch { display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2); }
.market-state { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.market-state.ok-text { color: var(--profit); }
.chart-toolbar .seg-nav { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.chart-toolbar .seg-nav .switch-item { flex: none; }

/* ---- Mixed mode: the mix editor, the Home line, the sleeves table (docs/decisions.md "Mixed mode") ---- */
.mix-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.mix-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mix-name { display: grid; gap: 2px; min-width: 0; flex: 1 1 200px; }
.mix-name label { display: inline-flex; align-items: center; gap: 8px; }
.mix-name .help { margin: 0; }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper input[type="number"] { width: 5.5ch; text-align: right; font-variant-numeric: tabular-nums; }
.stepper .step { min-width: 44px; min-height: 44px; padding: 0; font-size: var(--fs-xl); line-height: 1; }
.stepper .unit { color: var(--text-2); }
.mix-total { margin: 0; font-variant-numeric: tabular-nums; }
.mix-summary { margin: 0; padding-left: 18px; display: grid; gap: 4px; color: var(--text-2); font-size: var(--fs-sm); }
.mix-summary:empty { display: none; }
.mix-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin: 0 0 12px; font-size: var(--fs-sm); }
.mix-line-head { font-weight: 600; }
.mix-sleeve { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mix-sleeve .key { align-self: center; }
.sleeve-chip { margin-left: 4px; }

/* Trades: a taken trade's fills, oldest first (templates/_trade_parts.html). */
.fills-kv { grid-column: 1 / -1; }
.fill-timeline { margin: 0; padding-left: 1.2em; }
.fill-timeline li { margin: 2px 0; }
.pos-sub .cell-note, .pos-levels .cell-note { display: inline; }

/* Scorecard: "What's working" (templates/_working.html). Bleeders first; on a phone four columns fit
   375 px (name, trades, win rate, net R) and the rest sit on a muted line under the name. */
.family-position, .family-event { background: var(--surface-3); color: var(--text-2); border: 1px dashed var(--line-strong); }
.working-total { margin: var(--sp-3) 0 var(--sp-1); font-variant-numeric: tabular-nums; }
.working-by { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); margin: var(--sp-2) 0; }
.working-by label { flex: 1 1 100%; font-size: var(--fs-sm); color: var(--text-2); }
.working-by select { flex: 1 1 200px; min-width: 0; max-width: 100%; }
/* RSI: "What we measure" (templates/rsi.html). */
.rsi-measures td:first-child { white-space: nowrap; }
.rsi-measures td { vertical-align: top; }
.working-lines { list-style: none; margin: 0 0 var(--sp-2); padding: 0; display: grid; gap: 4px; font-size: var(--fs-sm); }
.working-table td:first-child { white-space: normal; }
.working-table .wk-small { display: block; font-size: 12px; }
.working-table .wk-line { display: none; font-size: 12px; font-variant-numeric: tabular-nums; }
@media (max-width: 719px) {
  .working-table { table-layout: fixed; }
  .working-table th, .working-table td { padding-left: 6px; padding-right: 6px; }
  .working-table .wk-wide { display: none; }
  .working-table .wk-line { display: block; }
  .working-table th { white-space: normal; }
  .working-table th:nth-child(1) { width: 40%; }
  .working-table th:nth-child(2) { width: 15%; }
  .working-table th:nth-child(3) { width: 18%; }
  .working-table th:nth-child(6) { width: 27%; }
}

/* Replay (templates/replay.html, _replay.html): four columns (figure, before, now, change) fit 375 px;
   a second figure (drawdown in money, a setup's trade count) sits on a muted line under the first. */
.replay-form { display: grid; gap: var(--sp-2); max-width: 22rem; }
.replay-form input[type="number"] { max-width: 8rem; }
.replay-progress { width: 100%; height: 8px; margin-top: var(--sp-2); accent-color: var(--primary); }
.replay-facts { list-style: none; margin: 0 0 var(--sp-2); padding: 0; display: grid; gap: 4px; font-size: var(--fs-sm); }
.replay-facts .muted { display: inline-block; min-width: 7.5em; }
.replay-notes { margin: 0; padding-left: 1.2em; display: grid; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }
.replay-mode { margin-top: var(--sp-5); }
.replay-mode h3 { display: flex; align-items: center; gap: var(--sp-2); margin: 0 0 var(--sp-1); }
.replay-changed { margin-top: 0; }
.replay-table { table-layout: fixed; font-variant-numeric: tabular-nums; }
.replay-table th, .replay-table td { white-space: normal; overflow-wrap: anywhere; padding-left: 6px; padding-right: 6px; }
.replay-table th[scope="row"] { text-align: left; font-weight: 600; color: var(--text); background: none; }
.replay-table thead th:first-child { width: 34%; }
.replay-table .replay-sub { display: block; font-size: 12px; }
.replay-table-ns thead th:first-child { width: 24%; } /* five columns: the no-scalp twin beside now */
.replay-setups summary { min-height: var(--tap); display: flex; align-items: center; }

/* Carry book (templates/carry.html, _carry_table.html): three columns (figure, rules, always held) and the
   events table (when, what, amount) wrap inside 375 px; the venue and the reason sit on a muted line. */
.carry-verdict { font-weight: 600; margin: var(--sp-1) 0; }
.carry-forward { font-weight: 600; margin: var(--sp-1) 0 0; }
.carry-state { font-size: var(--fs-sm); color: var(--text-2); overflow-wrap: anywhere; }
.carry-table, .carry-events { table-layout: fixed; width: 100%; font-variant-numeric: tabular-nums; }
.carry-table th, .carry-table td, .carry-events th, .carry-events td {
  white-space: normal; overflow-wrap: anywhere; padding-left: 6px; padding-right: 6px;
}
.carry-table th[scope="row"] { text-align: left; font-weight: 600; color: var(--text); background: none; }
.carry-table thead th:first-child { width: 36%; }
.carry-events thead th:first-child { width: 30%; }
.carry-events thead th:last-child { width: 28%; }
.carry-events td:nth-child(2) { text-align: left; }
.carry-sub { display: block; font-size: 12px; }
.carry-notes { margin: 0; padding-left: 1.2em; display: grid; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text-2); }
/* Reviews (web/reviews.py): the daily log, the weekly proposals and the register. */
.review-week + .review-week { margin-top: var(--sp-5); padding-top: var(--sp-4); border-top: 1px solid var(--line); }
.review-week h3 { margin: 0 0 var(--sp-2); }
.review-summary { overflow-wrap: anywhere; }
.review-proposal { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--line); display: grid; gap: var(--sp-2); }
.review-proposal p { margin: 0; }
.review-proposal-head { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }
.review-proposal .button-row form { margin: 0; }
.review-evidence, .review-findings { margin: 0; padding-left: 1.2em; display: grid; gap: var(--sp-3); overflow-wrap: anywhere; }
.review-findings { list-style: none; padding-left: 0; }
.review-findings p { margin: 0 0 4px; }
.review-day summary { min-height: var(--tap); display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }

/* RSI page (docs/decisions/0084-rsi-page.md): status strip, decisions, pattern tracker, log, effects */
.rsi-strip .facts { margin: 0; }
.rsi-strip .fact .pill-value { text-align: right; overflow-wrap: anywhere; }
.rsi-decision h3.label, .review-day h3.label, .rsi-effect h3.label, #implemented h3.label { margin: var(--sp-2) 0 0; }
.rsi-expired { opacity: 0.85; }
.rsi-evidence { display: block; margin-top: 2px; }
.rsi-patterns, .rsi-outcomes, .rsi-notes { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--sp-3); }
.rsi-notes { gap: 4px; font-size: var(--fs-sm); color: var(--text-2); overflow-wrap: anywhere; }
.rsi-outcomes { gap: var(--sp-2); overflow-wrap: anywhere; }
.rsi-pattern { padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.rsi-pattern:first-child { padding-top: 0; border-top: 0; }
.rsi-pattern p { margin: 0 0 4px; overflow-wrap: anywhere; }
.rsi-pattern-head { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-2); align-items: center; }
.rsi-strip-days { display: flex; flex-wrap: wrap; gap: 3px; margin: var(--sp-1) 0; padding: 0; list-style: none; }
.rsi-cell { display: inline-block; width: 16px; height: 16px; border-radius: 2px; border: 1px solid var(--line-strong); vertical-align: -3px; }
.rsi-cell-bad { background: var(--loss); border-color: var(--loss); }
.rsi-cell-good { background: var(--profit); border-color: var(--profit); }
.rsi-cell-none { background: var(--surface-3); }
.rsi-cell-missing { background: transparent; border-style: dashed; }
.rsi-key { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--sp-2); }
.rsi-day-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px var(--sp-2); }
.rsi-sub { font-size: var(--fs-sm); }
.rsi-gate .rsi-window-head th { text-align: left; white-space: normal; color: var(--text); overflow-wrap: anywhere; }
.rsi-verdict { margin: var(--sp-1) 0; overflow-wrap: anywhere; }
.rsi-held .disclosure { margin-top: var(--sp-1); }
.rsi-day { flex: 1 1 0; min-width: 0; display: grid; gap: 2px; }
.rsi-headline { font-size: var(--fs-sm); font-weight: 400; color: var(--text-2); }
.recap-losses { margin: var(--sp-2) 0; overflow-wrap: anywhere; }
.recap-markets td, .recap-sessions td { vertical-align: top; }
.recap-markets th, .recap-markets td, .recap-sessions th, .recap-sessions td { padding: 8px; }
.recap-day th { white-space: normal; }
.recap-day td:first-child { white-space: normal; min-width: 7em; overflow-wrap: anywhere; }
.rsi-effect + .rsi-effect { margin-top: var(--sp-4); padding-top: var(--sp-3); border-top: 1px solid var(--line); }
.rsi-effect p { margin: 0 0 var(--sp-1); }
@media (min-width: 1024px) and (max-width: 1279px) { .top-tab { padding: 0 8px; } }
/* Sniper (docs/decisions.md "Sniper mode (Tyler 2026-11-18)"): the sixth race series, an electric violet
   (validated six series all-pairs with the data-viz validator; see docs/brand-guidelines.md), a long
   dash-dot-dot line; its mode card and menu entry are red-toned like Lunatic's (no account limits). */
:root {
  --m6: #9000f8;
}
:root[data-theme="light"] {
  --m6: #d810f8;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    --m6: #d810f8;
  }
}
.series-m6 { stroke: var(--m6); }
.series-line.series-m6 { stroke-dasharray: 14 3 2 3 2 3; }
circle.series-m6 { fill: var(--m6); }
.key-line.series-m6 { border-color: var(--m6); border-top-style: dashed; border-top-width: 3px; }
.series-line.series-m6.series-twin { stroke-dasharray: 3 3; }
.mode-card-sniper { border-color: var(--loss-line); background: var(--loss-bg); }
.mode-card-sniper.mode-card-current { border-color: var(--loss); }
.mode-card-sniper h3 { color: var(--loss); }
.menu-button.mode-sniper .mode-name, .menu-item-sniper .menu-item-label { color: var(--loss); }
/* Six mode cards: two rows of three on a wide screen too. */
@media (min-width: 1440px) {
  .mode-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---- Mixed mode: the allocation inputs show 0 to 100 in full (UX review U1). The +/- buttons step the
   value, so the browser's own spinner is hidden; the width holds three digits plus the padding. ---- */
.stepper input[type="number"] {
  flex: none; width: calc(3ch + 28px); min-width: calc(3ch + 28px); padding-left: 6px; padding-right: 6px;
  text-align: center; -moz-appearance: textfield; appearance: textfield;
}
.stepper input[type="number"]::-webkit-inner-spin-button,
.stepper input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* ---- Lunatic / Sniper confirmation: Current -> Selected from the presets, the rest folded ---- */
.mode-compare { margin: 0 0 var(--sp-4); }
.compare-table caption { text-align: left; font-weight: 600; color: var(--text-2); padding: 0 0 var(--sp-2); }
.compare-table th, .compare-table td { white-space: normal; text-align: left; vertical-align: top; padding: 8px 10px; }
.compare-table tbody th { background: transparent; color: var(--text-2); font-weight: 600; }
.compare-table tr.compare-changed td:last-child { color: var(--loss); font-weight: 600; }
.compare-detail { margin-top: var(--sp-3); }
.compare-detail summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.compare-detail p { margin: 0 0 var(--sp-2); color: var(--text-2); font-size: var(--fs-sm); }
/* Page lengths and phone targets (docs/decisions/0090). A standalone link gets the 44 px tap height
   (.tap-link); a link inside a line of text or a row keeps its line and gets an invisible 44 px hit
   area instead (.tap-pad), so data rows do not grow. */
.tap-link { display: inline-flex; align-items: center; min-height: var(--tap); }
.tap-pad { position: relative; }
.tap-pad::after { content: ""; position: absolute; left: -6px; right: -6px; top: 50%; height: var(--tap); transform: translateY(-50%); }
.owner-edit > summary, .setups-disclosure > summary { min-height: var(--tap); }
.setups-disclosure > summary { display: inline-flex; align-items: center; }
/* Views: Claude's call now, one row per market; each row jumps to the market's block. */
.now-grid {
  display: grid; align-items: center; column-gap: var(--sp-3);
  grid-template-columns: minmax(0, 1.4fr) 84px 84px minmax(0, 1.4fr) 96px;
}
.now-head { padding-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 11px; font-weight: 600; color: var(--muted); }
.now-head .now-age, .now-row .now-age { text-align: right; }
.now-list { list-style: none; padding: 0; margin: 0; }
.now-list li + li { border-top: 1px solid var(--line); }
.now-row { min-height: var(--tap); padding: 6px 0; color: var(--text); text-decoration: none; }
.now-row:hover .now-name { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line-strong); }
.now-name { display: flex; align-items: center; gap: 6px; min-width: 0; font-weight: 600; }
.now-name .icon, .now-name svg { flex: none; }
.now-claude, .now-you { display: flex; align-items: center; min-width: 0; }
.now-bot { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); line-height: 1.3; }
.views-now .caption { margin: var(--sp-2) 0 0; }
.view-more { margin-top: 0; }
.view-more > summary { color: var(--text); }
@media (max-width: 719px) {
  .now-grid { column-gap: 6px; grid-template-columns: minmax(0, 1fr) 58px 60px minmax(0, 76px); }
  .now-grid .now-age { display: none; }
  .now-name { font-size: var(--fs-sm); }
  .now-bot { font-size: 12px; }
  .now-row { padding: 8px 0; }
}
/* A card that opens on demand: its title is the <summary> (Past races, What's working). */
.fold > .fold-summary {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px var(--sp-2); min-height: var(--tap);
  cursor: pointer; list-style: none;
}
.fold > .fold-summary::-webkit-details-marker { display: none; }
.fold > .fold-summary h2 { margin: 0; }
.fold > .fold-summary .muted { font-size: var(--fs-sm); }
.fold > .fold-summary::after {
  content: ""; width: 16px; height: 16px; margin-left: auto; background: var(--muted);
  -webkit-mask: url("icons/chevron.svg") center / contain no-repeat; mask: url("icons/chevron.svg") center / contain no-repeat;
  transition: transform 0.15s;
}
.fold[open] > .fold-summary::after { transform: rotate(90deg); }
.fold[open] > .fold-summary { margin-bottom: var(--sp-2); }
.diag-title { margin: var(--sp-6) 0 var(--sp-1); }
.kpi-note { margin: calc(-1 * var(--sp-2)) 0 var(--sp-4); }
.view-block .owner-actions { margin-top: var(--sp-1); }
.carry-link .help { margin: 0; }
/* Trades: kind, market, taken/skipped, setup and dates under one "Filters" disclosure with a count. */
.trade-filters { margin-bottom: var(--sp-3); }
.trade-filters > summary {
  display: flex; align-items: center; gap: var(--sp-2); min-height: var(--tap); cursor: pointer; list-style: none;
  font-weight: 600; font-size: var(--fs-sm); color: var(--text-2);
}
.trade-filters > summary::-webkit-details-marker { display: none; }
.trade-filters > summary::after {
  content: ""; flex: none; width: 16px; height: 16px; background: currentColor;
  -webkit-mask: url("icons/chevron.svg") center / contain no-repeat; mask: url("icons/chevron.svg") center / contain no-repeat;
  transition: transform 0.15s;
}
.trade-filters[open] > summary::after { transform: rotate(90deg); }
.filter-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-pill); background: var(--primary); color: var(--on-primary); font-size: 12px; font-weight: 700;
}
.filter-words { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 500; }
.trade-filters .chip-row { margin: var(--sp-2) 0; }
/* RSI: a finding's readable title leads; its id stays small beside the details. */
.finding-id { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.unit-note { margin-top: 0; }
.views-now .now-age { margin: 0; }
/* Phone polish (docs/decisions/0090, "Follow-up"). */
/* Trades: the time is the day and the time in two spans; on a phone the day sits over the time, so an
   older row's "17 Nov 21:55" stays inside its column instead of running into the instrument. */
.row-toggle .t-day, .row-toggle .t-hm { white-space: nowrap; }
@media (max-width: 719px) {
  .row-toggle { white-space: normal; line-height: 1.25; }
  .row-toggle .t-day { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
}
/* Segmented switches and the arm switch: each segment keeps its look (40 px and 38 px inside the track's
   padding) and gets an invisible 44 px hit area that covers the track's padding, like .tap-pad. */
.seg-nav .switch-item, a.arm-opt { position: relative; }
.seg-nav .switch-item::after, a.arm-opt::after {
  content: ""; position: absolute; left: -1px; right: -1px; top: 50%; height: var(--tap); transform: translateY(-50%);
}
/* Two fields side by side: when one label wraps to two lines, the inputs still line up (Plays' new play,
   the "Your view" form on Home, Views and the Chart). */
.play-form .field-pair, .owner-form .field-pair { align-items: end; }
/* RSI: each colour square stays with its word when the key wraps. */
.rsi-key-item { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
/* Phone tables (docs/decisions/0090, "Follow-up 2"). */
/* An instrument's icon and name stay together; a long name wraps beside the icon, not under it. */
.inst-name { display: inline-flex; align-items: center; }
.inst-name > .inst-icon { flex: none; }
/* Stacked tables (the Scorecard's split, Plays' open plays): under 720 px each row is a small card, the
   name on the left and the money (.stack-key) on the right of its first line, the other figures under it
   with their column name (data-label) above each. The desktop table is unchanged. */
@media (max-width: 719px) {
  .table-wrap:has(> .stack-table) { overflow-x: visible; }
  .stack-table thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .stack-table tbody, .stack-table tr, .stack-table td { display: block; }
  .stack-table tr {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px var(--sp-2);
    padding: 10px 12px; border-bottom: 1px solid var(--line);
  }
  .stack-table tbody tr:last-child { border-bottom: 0; }
  .stack-table td { padding: 0; border: 0; text-align: left; white-space: normal; min-width: 0; }
  .stack-table td:first-child { grid-column: 1 / 3; grid-row: 1; align-self: center; font-weight: 600; }
  .stack-table td.stack-key { grid-column: 3; grid-row: 1; align-self: center; text-align: right; font-weight: 700; }
  .stack-table .live-value { white-space: nowrap; }
  /* a stale live figure's "as of" time goes under it, not beside it */
  .stack-table .live-value.live-stale::after { display: block; white-space: nowrap; }
  .stack-table td[data-label]::before {
    content: attr(data-label); display: block; font-size: 11px; font-weight: 600; color: var(--muted);
  }
  .stack-table td[data-label] { font-variant-numeric: tabular-nums; }
  .stack-table tr.total td { background: none; }
  .stack-table tr.total { background: var(--surface-2); }
  .stack-table td.stack-action { grid-column: 1 / -1; }
  .stack-table td.stack-action .btn { width: 100%; }
  .plays-open-table td:first-child { grid-column: 1 / 3; font-weight: 400; }
  .plays-open-table td:first-child .muted { font-size: var(--fs-sm); }
  /* Trades: the instrument cell takes a little more of the row so "EUR/USD" fits beside its icon. */
  .trades-table th:nth-child(1) { width: 15%; }
  .trades-table th:nth-child(2) { width: 28%; }
  .trades-table th:nth-child(5) { width: 19%; }
  .trades-table th:nth-child(10) { width: 22%; }
  .trades-table th:nth-child(11) { width: 16%; }
  .trades-table .inst-name { display: flex; align-items: flex-start; }
  .trades-table .inst-name > .inst-icon { margin-top: 2px; }
}
/* Levels strip: room at both ends so a label at the strip's edge is not cut, and on a phone a fade on the
   side that has more to scroll to (strip.js sets .more-start / .more-end). */
.strip-scroll { padding: 0 var(--sp-3); }
.strip-scroll.more-start { mask-image: linear-gradient(to right, transparent, var(--text) 40px); }
.strip-scroll.more-end { mask-image: linear-gradient(to left, transparent, var(--text) 40px); }
.strip-scroll.more-start.more-end {
  mask-image: linear-gradient(to right, transparent, var(--text) 40px, var(--text) calc(100% - 40px), transparent);
}
/* How sure? (docs/decisions/0094): the label as a chip whose words carry the meaning (colour and icon only
   repeat them), the count under it; the range and the rough count of trades still needed are the cell's
   tooltip on a desktop and a second line on a phone. The race table stacks under 720 px like the split. */
.sure .icon { width: 14px; height: 14px; }
.chip.sure-edge { background: var(--profit-bg); color: var(--profit); }
.chip.sure-leak { background: var(--loss-bg); color: var(--loss); }
.chip.sure-unclear, .chip.sure-early { background: var(--surface-3); color: var(--text-2); }
.sure-n { display: block; margin-top: 2px; font-size: var(--fs-sm); }
.sure-more {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.rsi-sure .chip { margin-right: var(--sp-2); }
@media (max-width: 719px) {
  .race-table td.sure-cell, .race-table td.state-cell { grid-column: span 2; }
  .race-table .sure-more {
    position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal;
    display: block; margin-top: 4px; font-size: var(--fs-sm); color: var(--muted);
  }
  .race-table tr.race-real { border-top: 1px dashed var(--line); }
  .race-table .race-real td { border-top: 0; }
}

/* Lot sizes (docs/decisions/0090, "Follow-up 3"): an open trade's size leads its sub-line on Home and the
   Chart side panel; Trades shows it beside the kind chip on a phone (the Size column on a desktop); Home's
   Recent trades and Plays put it first on their muted line. */
.pos-lots, .feed-lots, .play-lots { color: var(--text-2); font-weight: 600; }
.trade-lots {
  display: block; margin-top: 2px; font-size: 11px; color: var(--muted); font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Visual pass 2026-11-18 (docs/decisions/0090 follow-up). */
/* Position and Event chips beside Swing and Scalp: a word in a pill, not a state colour. */
.family-position { background: var(--primary-tint); color: var(--text); border: 1px solid transparent; }
.family-event { background: var(--warn-bg); color: var(--text); border: 1px solid var(--warn-line); }
/* The Lunatic/Sniper "Everything ... sets" fold gets the standard chevron. */
.compare-detail > summary { gap: var(--sp-2); list-style: none; }
.compare-detail > summary::-webkit-details-marker { display: none; }
.compare-detail > summary::after {
  content: ""; width: 16px; height: 16px; margin-left: auto; background: var(--muted);
  -webkit-mask: url("icons/chevron.svg") center / contain no-repeat; mask: url("icons/chevron.svg") center / contain no-repeat;
  transition: transform 0.15s;
}
.compare-detail[open] > summary::after { transform: rotate(90deg); }
/* A checkbox on the line of its label. */
.field-check label { display: flex; align-items: flex-start; gap: var(--sp-2); cursor: pointer; }
.field-check input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; flex: none; margin: 1px 0 0; padding: 0; }
/* Trades' filter groups: a small label before each chip row. */
.chip-group-label { flex-basis: 100%; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
/* Your own view switched off (owner_view.enabled, "machine led"): the Markets and Views rows drop the You
   column. Two classes, so these win over the phone layouts above. */
.mkt-grid.no-you {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 76px minmax(0, 1.3fr) 88px 16px;
  grid-template-areas: "name price claude bot age chev";
}
.now-grid.no-you { grid-template-columns: minmax(0, 1.4fr) 84px minmax(0, 1.4fr) 96px; }
@media (max-width: 719px) {
  .mkt-grid.no-you {
    grid-template-columns: minmax(0, 1fr) 58px minmax(0, 72px);
    grid-template-areas: "name claude bot" "price claude bot";
  }
  .now-grid.no-you { grid-template-columns: minmax(0, 1fr) 58px minmax(0, 76px); }
}
/* Settings: which books read a row (docs/decisions/0103), and the explainer under the mode cards. */
.set-name { display: grid; gap: 2px; justify-items: start; min-width: 0; }
.scope-badge {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; line-height: 1.4;
  padding: 0 var(--sp-2); border-radius: var(--r-sm); border: 1px solid var(--line-strong); color: var(--muted);
  white-space: nowrap; width: fit-content;
}
.scope-badge.scope-mode, .scope-badge.scope-real { color: var(--text-2); background: var(--surface-3); }
.mode-explainer { margin-top: var(--sp-4); padding: var(--sp-3) var(--sp-4); border: 1px solid var(--line-strong); border-radius: var(--r-lg); }
.mode-explainer h3 { font-size: var(--fs-md); margin-bottom: var(--sp-2); }
.mode-explainer ul { margin: 0 0 var(--sp-3); padding-left: var(--sp-5); color: var(--text-2); font-size: var(--fs-sm); }
.mode-explainer li { margin-bottom: var(--sp-1); }
/* Strategies: the recipe table, modes as columns; one mode at a time on a phone (?mode=). */
.recipe-modes { margin-bottom: var(--sp-3); flex-wrap: wrap; }
.recipe-count, .recipe-meta { font-size: 11px; font-weight: 600; color: var(--muted); }
.recipe-meta { display: block; }
.recipe-table th.rc { vertical-align: bottom; }
.recipe-table .recipe-group th { text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; padding-top: var(--sp-4); }
.recipe-table .recipe-key { text-align: left; font-weight: 500; color: var(--text-2); }
.recipe-cell { display: inline-block; color: var(--text); text-decoration: none; }
.recipe-cell:hover { text-decoration: underline; }
.recipe-cell.recipe-unused { color: var(--muted); font-style: italic; }
.recipe-edited { background: var(--primary-tint); }
.recipe-flag { display: inline-block; font-size: 11px; font-weight: 600; color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 var(--sp-1); }
.recipe-flag-warn { color: var(--warn); border-color: var(--warn-line); }
.recipe-flag .icon { width: 12px; height: 12px; }
.recipe-resets form { display: inline; }
.race-recipes ul { margin: 0 0 var(--sp-3); padding-left: var(--sp-5); }
.lab-table .lab-note { display: block; max-width: 36ch; }
.lab-table .lab-since { display: block; }
@media (max-width: 719px) {
  .recipe-table .rc { display: none; }
  .recipe-table.show-low .col-low, .recipe-table.show-medium .col-medium, .recipe-table.show-higher .col-higher,
  .recipe-table.show-gambling .col-gambling, .recipe-table.show-lunatic .col-lunatic,
  .recipe-table.show-sniper .col-sniper { display: table-cell; }
}

/* ==== Polish pass (docs/decisions/0090, follow-up 2026-11-19) =================================== */
.nowrap { white-space: nowrap; }
/* Strategies: the key column wraps so the mode's values stay in view on a phone; values sit on the
   key's line; row keys read as text, not header tiles; the phone's mode switch only on a phone. */
.recipe-table th, .recipe-table td { vertical-align: middle; }
.recipe-table thead th { vertical-align: bottom; white-space: normal; }
.recipe-table tbody th { background: none; }
.recipe-table .recipe-key { white-space: normal; min-width: 9em; }
.recipe-table .recipe-cell { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 4px; min-height: var(--tap); }
@media (min-width: 720px) { .recipe-modes { display: none; } }
/* Replay: with the no-scalp or trend-gate column the table scrolls in its own box on a phone instead
   of breaking figures mid-number; the facts are label and value columns. */
.replay-wrap { margin: var(--sp-1) 0 0; }
.replay-table-wide { table-layout: auto; }
.replay-table-wide th, .replay-table-wide td { overflow-wrap: normal; }
.replay-table-wide td, .replay-table-wide .replay-sub { white-space: nowrap; }
.replay-table-wide thead th { white-space: normal; min-width: 4.5em; }
.replay-facts li { display: grid; grid-template-columns: 7.5em minmax(0, 1fr); column-gap: var(--sp-2); }
.replay-facts .muted { min-width: 0; }
/* Views: a closed market in the row's small type, on one line; its caption spaced from the title. */
.now-closed { font-size: var(--fs-sm); line-height: 1.25; }
.view-closed { margin: 0 0 var(--sp-2); }
/* Home: the side pill a gap from the name and on its baseline; the money card hugs its content. */
.pos-title .side { margin-left: 6px; vertical-align: 1px; }
@media (min-width: 1024px) {
  .home-layout > .money, .home-layout > .positions { align-self: start; }
}
/* Chart: the indicator keys in the text colour with a swatch of the line's colour (contrast in light). */
.ind-s1 .ohlc-key, .ind-s2 .ohlc-key { color: var(--text-2); }
.ind-s1 .ohlc-key::before, .ind-s2 .ohlc-key::before {
  content: ""; display: inline-block; width: 10px; height: 0; margin-right: 4px; vertical-align: middle;
  border-top: 2px solid var(--s1);
}
.ind-s2 .ohlc-key::before { border-top-color: var(--s2); }
/* Date inputs fit their cells. */
.field input[type="date"] { min-width: 0; width: 100%; max-width: 100%; }
/* Trades: the row toggle a full tap target. */
.row-toggle { min-height: var(--tap); }
/* Scorecard: the no-scalp rows keep their profit and loss colours; the Analysis fold's chevron. */
.race-table .race-twin td.pos, .past-table .race-twin td.pos, .across-table .race-twin td.pos,
.race-table .race-twin .pos { color: var(--profit); }
.race-table .race-twin td.neg, .past-table .race-twin td.neg, .across-table .race-twin td.neg,
.race-table .race-twin .neg { color: var(--loss); }
.analysis-title::after, .analysis[open] .analysis-title::after {
  content: ""; display: inline-block; width: 16px; height: 16px; margin-left: var(--sp-2); vertical-align: -2px;
  background: var(--muted); transition: transform 0.15s;
  -webkit-mask: url("icons/chevron.svg") center / contain no-repeat; mask: url("icons/chevron.svg") center / contain no-repeat;
}
.analysis[open] .analysis-title::after { transform: rotate(90deg); }
.ruin-table .key-line { display: inline-block; margin-right: var(--sp-2); vertical-align: middle; }
/* Week ahead: the folds are full tap targets. */
.wk-more > summary, .playbook > summary { min-height: var(--tap); }
/* Carry: the caveats under the page head; no lone rule under the last row. */
.carry-caveats { margin: 0 0 var(--sp-3); }
.carry-caveats .carry-notes { margin-top: var(--sp-2); }
.carry-table tbody tr:last-child th, .carry-table tbody tr:last-child td,
.carry-events tbody tr:last-child td { border-bottom: 0; }
/* Plays: the proposal's title and its validity pill each stay on one line; the pill drops below. */
.play-head { flex-wrap: wrap; row-gap: var(--sp-1); }
.play-head strong, .play-head .chip { white-space: nowrap; }
/* Settings: an open row inside the list's edges; the page aligned with every other page. */
.set-item[open] { margin: 0; }
.settings-page { margin: 0; }
/* RSI: the legend spaced from the patterns under it. */
.rsi-key { gap: 4px var(--sp-4); margin-bottom: var(--sp-3); }

/* a dismissable status notice: the text and a small ✕ (44 px target) that hides it (POST /notices/dismiss) */
.alert-dismissable { display: flex; align-items: center; gap: var(--sp-2); padding-right: 4px; }
.alert-dismissable .alert-text { flex: 1; margin: 0; }
.notice-dismiss { margin: 0; flex: none; }
.notice-dismiss-btn {
  min-width: 44px; min-height: 44px; margin: -10px 0; padding: 0;
  background: none; border: 0; border-radius: var(--r-md); color: inherit;
  font: inherit; font-size: var(--fs-md); line-height: 1; cursor: pointer;
}
.notice-dismiss-btn:hover { opacity: 0.7; }
.notice-dismiss-btn:focus-visible { outline: 2px solid currentColor; outline-offset: -4px; }

/* Trades: the Book switch wraps on wide screens (it grew past one line with the twins and the lab books);
   a phone gets one grouped dropdown instead (the chips are hidden there). */
.seg-nav.book-wrap { display: flex; flex-wrap: wrap; max-width: 100%; border-radius: var(--r-lg); }
.seg-nav.book-wrap .switch-item { flex: none; white-space: nowrap; gap: 4px; }
.book-picker { display: none; align-items: center; gap: var(--sp-2); }
.book-picker label { color: var(--text-2); font-size: var(--fs-sm); }
.book-picker select { flex: 1 1 auto; min-width: 0; min-height: var(--tap); }
@media (max-width: 719px) {
  .seg-nav.book-wrap { display: none; }
  .book-picker { display: flex; }
}
/* Race and lab tables condensed (Tyler 2026-11-19): Mode · Balance · Total value · Costs · Return · Trades ·
   Win rate · Expectancy · How sure? · Max drawdown · State. Each secondary figure (banked, money in, open,
   share of gross, net, $ a trade, drawdown money) sits small under its main one; the cost parts are the
   cell's tooltip on a desktop and a line of their own on a phone. */
.race-table .cell-sub {
  display: block; margin-top: 2px; font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap;
}
.race-table .cell-sub.pos, .race-table .cell-sub .pos { color: var(--profit); }
.race-table .cell-sub.neg, .race-table .cell-sub .neg { color: var(--loss); }
.race-table .race-costs-parts {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.race-table .race-check { white-space: normal; max-width: 24ch; line-height: 1.3; }
@media (max-width: 719px) {
  .race-table .cell-sub { white-space: normal; }
  .race-table .race-costs-parts {
    position: static; width: auto; height: auto; overflow: visible; clip-path: none; white-space: normal;
    display: block; margin-top: 2px;
  }
}

/* ==== Lab layout pass (docs/decisions/0107 and 0090, follow-up 2026-11-19) ====================== */
/* Strategy lab: the book's idea is a full-width line under its figures (tr.lab-note-row), so a long
   hypothesis wraps across the table instead of running over the Balance column. The pair reads as one. */
.lab-table tr.lab-row td { border-bottom: 0; padding-bottom: 4px; }
.lab-table tr.lab-note-row td {
  padding-top: 0; text-align: left; white-space: normal; overflow-wrap: anywhere;
  font-size: var(--fs-sm); color: var(--text-2); line-height: 1.4;
}
.lab-table tbody tr.lab-note-row:last-child td { border-bottom: 0; }
.lab-table .lab-note { display: inline; max-width: none; }
.lab-table .lab-since { display: inline; white-space: normal; }
.lab-table .lab-same { display: block; margin-top: 2px; color: var(--warn); }
/* The regime gate A/B under the lab (docs/decisions/0116): a pair whose two books started apart says so. */
.gate-ab-table .cell-sub.warn-text { color: var(--warn); white-space: normal; }
@media (max-width: 719px) {
  .lab-table tr.lab-row { border-bottom: 0; padding-bottom: 4px; }
  .lab-table tr.lab-note-row { display: block; padding: 0 12px 10px; border-bottom: 1px solid var(--line); }
  .lab-table tr.lab-note-row td { display: block; padding: 0; font-weight: 400; }
  .lab-table tbody tr.lab-note-row:last-child { border-bottom: 0; }
}
/* Race and lab tables on a desktop: eleven columns fit 1440 px without scrolling. Tighter cell padding,
   headers and the name, How sure? and State cells wrap (a lock's or a blow-up's sentence was the widest
   cell); figures and their small lines stay on one line each. */
@media (min-width: 720px) {
  .race-table th, .race-table td { padding-left: 8px; padding-right: 8px; }
  .race-table th { white-space: normal; vertical-align: bottom; }
  .race-table td:first-child { white-space: normal; min-width: 14ch; max-width: 22ch; }
  .race-table td.state-cell { white-space: normal; min-width: 9ch; max-width: 18ch; text-align: left; }
  .race-table .race-lock { display: inline; }
  .race-table .race-lock .icon { vertical-align: -3px; margin-right: 4px; }
  .race-table td.sure-cell { white-space: normal; max-width: 20ch; }
  .race-table .sure-cell .chip { white-space: nowrap; }
}
/* A table wider than its card shows that it scrolls: a soft edge on the side with more to see (the
   covers move with the content, the edges stay; colours are the tokens). */
.table-wrap {
  background:
    linear-gradient(to right, var(--surface), var(--surface)) left center / 24px 100% no-repeat local,
    linear-gradient(to left, var(--surface), var(--surface)) right center / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--line-strong), transparent) left center / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--line-strong), transparent) right center / 12px 100% no-repeat scroll;
}
/* Replay's "Strategy lab recipes": the recipe's name is the row's header cell (a th); it reads like the
   other replay tables' names on a desktop and leads its card on a phone, wrapping inside it. */
.replay-lab-table th[scope="row"] { text-align: left; font-weight: 600; color: var(--text); background: none; white-space: normal; }
@media (max-width: 719px) {
  .replay-lab-table th[scope="row"] {
    display: block; grid-column: 1 / -1; grid-row: 1; padding: 0; border: 0; min-width: 0;
  }
  .race-table .race-check { max-width: 100%; }
}
/* Super Sniper (docs/decisions/0118): the seventh race series, a deep amber-brown in both themes (validated
   seven series all-pairs with the data-viz validator: dark passes every check, worst colour-blind ΔE 8.4,
   unchanged, the new colour's worst 10.6, contrast relief as --m2; light keeps the 7.5 warning already
   there, the new colour's worst 10.6), a long-short dash; its card and menu entry are red-toned like
   Sniper's (no account limits). */
:root {
  --m7: #904800;
}
.series-m7 { stroke: var(--m7); }
.series-line.series-m7 { stroke-dasharray: 16 4 4 4; }
circle.series-m7 { fill: var(--m7); }
.key-line.series-m7 { border-color: var(--m7); border-top-width: 4px; }
.series-line.series-m7.series-twin { stroke-dasharray: 3 3; }
.mode-card-super_sniper { border-color: var(--loss-line); background: var(--loss-bg); }
.mode-card-super_sniper.mode-card-current { border-color: var(--loss); }
.mode-card-super_sniper h3 { color: var(--loss); }
.menu-button.mode-super_sniper .mode-name, .menu-item-super_sniper .menu-item-label { color: var(--loss); }
@media (max-width: 719px) {
  .recipe-table.show-super_sniper .col-super_sniper { display: table-cell; }
}
