/* The whole site as a trading terminal: IBM Plex, monospace figures, thin rules instead of cards,
   amber for the bot's own marks, green and red only for gains and losses, cyan for protective
   orders. Dark by default; the owner can switch the site to light in Settings → Display, which
   sets data-theme="light" on <html> (every colour is a token, redefined there). No inline styles
   anywhere: the content security policy forbids them, so every size, colour and chart stroke is a
   class here. */

/* ==== Tokens ============================================================================== */
:root {
    color-scheme: dark;
    --bg: #090c10;
    --panel: #0e1318;
    --panel-2: #121921;
    --raise: #161e27;
    --line: #1d2630;
    --line-soft: #141b23;
    --ink: #d4dce6;
    --ink-2: #a3afbd;
    --mut: #6c7a8b;
    --amber: #f2a93b;
    --amber-soft: rgb(242 169 59 / 0.12);
    --pos: #3cc47c;
    --neg: #f0585b;
    --cyan: #5fb7da;
    --spy: #4f5d70;           /* the benchmark line */
    --spy-label: #8796a8;
    --on-amber: #120d04;      /* text on an amber button */
    --on-neg: #ffffff;        /* ...and on a red one */
    --amber-hover: #ffbb55;
    --shadow: rgb(0 0 0 / 0.5);
    --scrim: rgb(3 5 8 / 0.72);
    --code-ink: 95 110 128;   /* the home page's 3D code (js/hero-3d.js reads these three): the streams... */
    --code-head: 242 169 59;  /* ...their leading characters... */
    --code-bg: 9 12 16;       /* ...and the page behind them, as r g b */
    --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    --cond: "IBM Plex Sans Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
    --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* The light terminal: paper instead of night, the same roles. */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f3f4f6;
    --panel: #ffffff;
    --panel-2: #f7f8fa;
    --raise: #eef1f4;
    --line: #dde2e8;
    --line-soft: #edf0f3;
    --ink: #12171d;
    --ink-2: #3c4754;
    --mut: #6a7584;
    --amber: #b86a00;
    --amber-soft: rgb(184 106 0 / 0.1);
    --pos: #137a4b;
    --neg: #c4313a;
    --cyan: #1c7aa3;
    --spy: #9aa5b3;
    --spy-label: #6a7584;
    --on-amber: #ffffff;
    --amber-hover: #9c5a00;
    --shadow: rgb(16 24 40 / 0.16);
    --scrim: rgb(16 24 40 / 0.45);
    --code-ink: 128 140 156;
    --code-head: 184 106 0;
    --code-bg: 243 244 246;
}

/* ==== Base ================================================================================ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.term { margin: 0; background: var(--bg); color: var(--ink); font: 13px/1.45 var(--mono); font-variant-numeric: tabular-nums; }
h1, h2, h3, p { margin: 0; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
code { font-family: var(--mono); color: var(--amber); }
button, input, select, textarea { font: inherit; color: inherit; }
.container { padding: 0 0 40px; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.amb { color: var(--amber); }
.cyan { color: var(--cyan); }
.mut, .muted, .faint { color: var(--mut); }
.small { font-size: 11px; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sym { color: var(--ink); font-weight: 600; letter-spacing: 0.02em; }
.inline { display: inline; margin: 0; }
.spacer { flex: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.empty { color: var(--mut); padding: 10px 0; }

/* ==== Top bar ============================================================================= */
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 18px; height: 44px; padding: 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; margin-right: auto; } /* clocks and menu sit on the right, the clocks shown or not */
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 24px; height: 24px; border: 1px solid var(--amber); color: var(--amber); font: 600 11px var(--cond); letter-spacing: 0.06em; }
.brand-name { font: 600 13px var(--cond); letter-spacing: 0.16em; text-transform: uppercase; }
.clocks { display: flex; gap: 14px; color: var(--mut); font-size: 12px; }
.menu-wrap { position: relative; margin-left: 4px; }
.menu-btn { display: flex; align-items: center; gap: 6px; padding: 3px 6px 3px 3px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); cursor: pointer; }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { border-color: var(--amber); color: var(--amber); }
.menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 170px; padding: 4px 0; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 12px 32px var(--shadow); }
.menu form { margin: 0; }
.menu [role="menuitem"] { display: block; width: 100%; padding: 8px 14px; border: 0; background: none; color: var(--ink); text-align: left; cursor: pointer; font: 500 12px var(--cond); letter-spacing: 0.1em; text-transform: uppercase; }
.menu [role="menuitem"]:hover, .menu [role="menuitem"]:focus-visible { background: var(--raise); color: var(--amber); outline: none; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.clocks i { font: 500 10.5px var(--cond); letter-spacing: 0.1em; text-transform: uppercase; font-style: normal; margin-right: 6px; }
.clocks b { color: var(--ink); font-weight: 500; }
.avatar { width: 24px; height: 24px; border-radius: 2px; display: grid; place-items: center; background: var(--raise); color: var(--ink-2); font: 600 11px var(--cond); object-fit: cover; }
.icon-btn { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid var(--line); background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { color: var(--amber); border-color: var(--amber); }

/* ==== Buttons, tags, dots, switch ============================================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px; border: 1px solid var(--line); background: var(--raise); color: var(--ink); font: 500 12px var(--cond); letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--ink-2); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn--sm { height: 26px; padding: 0 10px; font-size: 11px; }
.btn--lg { height: 38px; padding: 0 18px; }
.btn--primary { background: var(--amber); border-color: var(--amber); color: var(--on-amber); }
.btn--primary:hover { background: var(--amber-hover); border-color: var(--amber-hover); }
.btn--danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 45%, transparent); background: transparent; }
.btn--danger:hover { border-color: var(--neg); }
.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--kill { color: var(--neg); border-color: var(--neg); background: transparent; font-weight: 600; letter-spacing: 0.18em; }
/* The bot's one switch, next to the panic kill: a status light and its state. */
.btn--bot { gap: 9px; color: var(--mut); background: transparent; font-weight: 600; letter-spacing: 0.16em; }
.btn--bot .led { width: 8px; height: 8px; border-radius: 50%; background: var(--mut); }
.btn--bot.is-on { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 55%, transparent); }
.btn--bot.is-on .led { background: var(--pos); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pos) 22%, transparent); animation: led 2.4s ease-in-out infinite; }
.btn--bot.is-on:hover { border-color: var(--pos); }
@keyframes led { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--pos) 8%, transparent); } }
.btn--danger-solid { background: var(--neg); border-color: var(--neg); color: var(--on-neg); font-weight: 600; }
.btn--danger-solid:hover { filter: brightness(1.1); border-color: var(--neg); }
.btn--kill:hover:not(:disabled) { background: var(--neg); color: var(--bg); }
.btn.is-busy { opacity: 0.6; }

.badge, .tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 7px; border: 1px solid var(--line); font: 500 11px var(--mono); letter-spacing: 0.04em; color: var(--ink-2); }
.badge--blue, .tag--paper { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 45%, transparent); }
.badge--pos { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 45%, transparent); }
.badge--neg, .tag--live { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 55%, transparent); }
.badge--warn { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 50%, transparent); }
.badge--outline { color: var(--ink-2); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--mut); flex: none; }
.dot--on, .dot--pos { background: var(--pos); }
.dot--warn { background: var(--amber); }
.dot--neg { background: var(--neg); }


/* ==== Tradebot: header, tape, grid, panels ======================================================= */
.term-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 9px 14px; background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0; }
.kv { display: inline-flex; align-items: baseline; gap: 7px; }
.term-head .kv i, .ph-sub i, .risk i { font: 500 10.5px var(--cond); letter-spacing: 0.1em; text-transform: uppercase; color: var(--mut); font-style: normal; }
.term-head .kv b { font-weight: 500; }
.head-actions { display: flex; gap: 8px; margin-left: auto; }
.head-actions form { margin: 0; }

.tape { display: flex; overflow: hidden; background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
/* The ticker: two copies of the items slide left by one copy's width, in a loop; paused under the pointer. */
.tape-track { display: flex; width: max-content; animation: tape 40s linear infinite; }
.tape-view:hover .tape-track { animation-play-state: paused; }
@keyframes tape { to { transform: translateX(-50%); } }
.tick { display: flex; align-items: center; gap: 9px; padding: 7px 14px; border-right: 1px solid var(--line); white-space: nowrap; }
.tick b { font-weight: 600; }
.tick--note { flex: none; color: var(--mut); font-size: 11px; background: var(--panel); } /* fixed at the left of the ticker */
.tape-view { flex: 1; min-width: 0; overflow: hidden; }
.spark { fill: none; stroke: var(--cyan); stroke-width: 1.3; vector-effect: non-scaling-stroke; }

.term-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.term-col { display: flex; flex-direction: column; gap: 1px; background: var(--line); min-width: 0; }
.term-col > :last-child { flex: 1; } /* the last panel fills the column, so no empty strip shows under it */
.panel { background: var(--panel); padding: 10px 14px 14px; min-width: 0; }
.ph { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.ph h2 { font: 600 11.5px var(--cond); letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber); }
.ph h2 span { color: var(--mut); font-weight: 500; letter-spacing: 0.08em; margin-left: 8px; }
.ph-sub { display: flex; flex-wrap: wrap; gap: 6px 22px; margin-bottom: 10px; font-size: 12px; }
.ph-sub span { display: inline-flex; gap: 8px; align-items: baseline; }
.ph-sub b { font-weight: 500; }
.ph-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; font-size: 11px; }

.table-wrap { position: relative; overflow-x: auto; } /* positioned: hidden labels inside stay inside */
.grid-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.grid-table th, .grid-table td { padding: 6px 8px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line-soft); }
.grid-table thead th { font: 500 10.5px var(--cond); letter-spacing: 0.08em; text-transform: uppercase; color: var(--mut); border-bottom: 1px solid var(--line); padding-top: 4px; }
.grid-table th:first-child, .grid-table td:first-child { text-align: left; padding-left: 0; }
.grid-table tbody th { font-weight: 400; }
.grid-table tbody tr:hover td, .grid-table tbody tr:hover th { background: var(--panel-2); }
.grid-table.compact th, .grid-table.compact td { padding: 4px 6px; }
.room { vertical-align: middle; margin-left: 6px; }
.room-bg { fill: var(--raise); }
.room-fg { fill: var(--cyan); }
/* The shares table (Private/_Universe) and the owner's picks. */
.panel--wide { border-bottom: 1px solid var(--line); }
.universe tbody tr { height: 35px; } /* the same with or without a Pick button */
.universe .left { text-align: left; }
.universe .name { display: inline-block; max-width: 200px; margin-left: 6px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; color: var(--mut); font-size: 11px; }
.universe .btn--sm { height: 22px; }
.grid-table .sort { color: inherit; text-decoration: none; }
.grid-table .sort:hover, .grid-table .sort.is-on { color: var(--ink); }
.grid-table .sort .arrow { display: inline-block; width: 10px; margin-left: 3px; font-size: 8px; color: var(--amber); }
#shares { scroll-margin-top: 60px; }
.u-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; margin-bottom: 10px; }
.u-set { position: relative; width: max-content; max-width: 100%; } /* holds its hidden radio buttons */
.seg.seg--3 { grid-template-columns: repeat(3, auto); }
.u-set label { display: contents; }
.u-set input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.u-set span { display: grid; place-items: center; padding: 0 12px; white-space: nowrap; height: 28px; background: var(--panel-2); color: var(--mut); cursor: pointer; font: 500 11px var(--cond); letter-spacing: 0.1em; text-transform: uppercase; }
.u-set span:hover { color: var(--ink); }
.u-set input:checked + span { background: var(--raise); color: var(--amber); }
.u-set input:focus-visible + span { outline: 1px solid var(--amber); outline-offset: -2px; }
.u-tools input[type="search"], .u-tools select { height: 30px; padding: 0 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: 12px var(--mono); }
.u-tools input[type="search"] { flex: 1 1 180px; max-width: 300px; }
/* The dropdowns, on the line after the search, with their own arrow a little in from the edge. */
.u-select { position: relative; display: flex; flex: 0 1 200px; min-width: 0; }
.u-tools:not(.is-any) .u-market, .u-tools.is-any .u-industry { display: none; } /* the market for the other markets; the industries are the US lists' */
.u-select select { width: 100%; padding-right: 30px; appearance: none; -webkit-appearance: none; cursor: pointer; }
.u-select::after { content: ""; position: absolute; top: 50%; right: 14px; width: 6px; height: 6px; border-right: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.u-tools input:focus-visible, .u-tools select:focus-visible { outline: 1px solid var(--amber); outline-offset: -1px; }
.u-pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 10px; font-size: 11px; } /* pages in the middle, the count on the right */
.u-pager .pages, .u-pager .sizes { display: flex; align-items: center; gap: 4px; }
.u-pager .sizes .mut { margin-right: 4px; }
.u-pager .info { justify-self: end; white-space: nowrap; }
.u-pager a, .u-pager .cur, .u-pager .off { display: inline-grid; place-items: center; min-width: 28px; height: 26px; padding: 0 6px; border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-family: var(--mono); }
.u-pager a:hover { color: var(--ink); border-color: var(--ink-2); }
.u-pager .cur { color: var(--amber); border-color: var(--amber); }
.u-pager .off { opacity: 0.3; }
.u-pager .gap { color: var(--mut); padding: 0 2px; }
.universe tr.is-picked th, .universe tr.is-picked td { background: var(--amber-soft); }
.chip { display: inline-block; margin-right: 6px; padding: 0 5px; border: 1px solid var(--line); font: 500 10px/16px var(--cond); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.chip--blue { color: var(--cyan); border-color: color-mix(in srgb, var(--cyan) 45%, transparent); }
.chip--amb { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 55%, transparent); }
.chip--neg { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 50%, transparent); }
/* A buy waiting for the open, under the holdings (Private/_Today). */
.grid-table tr.is-pending th, .grid-table tr.is-pending td { background: color-mix(in srgb, var(--cyan) 5%, transparent); }
.btn--picked { color: var(--amber); border-color: var(--amber); background: var(--amber-soft); }
.pick-mark { color: var(--amber); margin-left: 4px; }
.chip.news { margin: 0 0 0 6px; cursor: help; }
.flag { color: var(--amber); font-size: 11.5px; }
.log .is-amb .kind, .log .is-amb .detail { color: var(--amber); }

/* The equity chart, drawn like a trading platform's (Private/_Equity): it fills the panel's height. */
.panel--fill { display: flex; flex-direction: column; }
.panel--fill > [data-refresh] { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tchart { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 78px; grid-template-rows: minmax(200px, 1fr) 20px; }
.tchart-plot { position: relative; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: crosshair; }
.tchart-svg { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: visible; }
.tchart-svg * { vector-effect: non-scaling-stroke; }
.tchart .grid { stroke: var(--line-soft); stroke-width: 1; }
.tchart .zero { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 3; }
.tchart .fill { fill: url(#eq-fill); }
.tchart .fill--sim { fill: url(#sim-fill); }
.tchart--fixed { flex: none; grid-template-rows: 190px 20px; } /* in the settings window: its own height */
.tchart .g0 { stop-color: var(--amber); stop-opacity: 0.24; }
.tchart .g1 { stop-color: var(--amber); stop-opacity: 0; }
.tchart .bot { fill: none; stroke: var(--amber); stroke-width: 2; stroke-linejoin: round; }
.tchart .spy { fill: none; stroke: var(--spy); stroke-width: 1.2; stroke-dasharray: 4 3; }
.tchart .price { stroke-width: 1; stroke-dasharray: 2 3; }
.tchart .price.is-pos { stroke: var(--pos); }
.tchart .price.is-neg { stroke: var(--neg); }
.tchart .dot { fill: none; stroke: var(--amber); stroke-width: 7; stroke-linecap: round; }
.tchart .halo { fill: none; stroke: var(--amber); stroke-width: 18; stroke-linecap: round; opacity: 0.25; animation: blink 1.8s ease-in-out infinite; }
.tchart-axis, .tchart-time { display: block; width: 100%; height: 100%; overflow: visible; }
.tchart .ax { fill: var(--mut); font: 10.5px var(--mono); }
.tchart .tag text { fill: var(--bg); font: 600 10.5px var(--mono); }
.tchart .tag.is-pos rect { fill: var(--pos); }
.tchart .tag.is-neg rect { fill: var(--neg); }
.tchart-cross { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px dashed var(--ink-2); pointer-events: none; }
.tchart-cross .cdot { position: absolute; left: -4.5px; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 2px var(--panel); }
.tchart-cross .tip { position: absolute; top: 6px; left: 8px; padding: 3px 7px; border: 1px solid var(--line); background: var(--raise); color: var(--ink); font: 11px var(--mono); white-space: nowrap; }
.tchart-cross .tip.is-left { left: auto; right: 8px; }
.panel--fill .legend { margin: 8px 0 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 6px 0 10px; font-size: 12px; }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 2px; margin-right: 7px; vertical-align: middle; background: currentColor; }
.legend .lg-swing { color: var(--amber); }
.legend .lg-spy { color: var(--spy-label); }
.legend .mut::before { display: none; }

.risk { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); }
.risk .cell { background: var(--panel); padding: 10px 14px; display: grid; gap: 3px; align-content: start; min-width: 0; }
.risk b { font-size: 17px; font-weight: 500; }
.risk small { color: var(--mut); font-size: 11px; overflow-wrap: anywhere; }
/* Each box's status icon, in its top right corner (Private/_Overview). */
.risk .cell { position: relative; }
.risk .cell > i { padding-right: 22px; }
.ind { position: absolute; top: 10px; right: 12px; width: 16px; height: 16px; overflow: visible; color: var(--mut); fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ind--pos { color: var(--pos); }
.ind--neg { color: var(--neg); }
.ind--amb { color: var(--amber); }
.ind--cyan { color: var(--cyan); }
.ind .fill { fill: currentColor; }
.ind .ring-bg { stroke: var(--raise); }
.ind .halo { fill: currentColor; stroke: none; transform-box: fill-box; transform-origin: center; animation: halo 2s ease-out infinite; }
.ind--blink { animation: blink 1.4s ease-in-out infinite; }
@keyframes halo { 0% { transform: scale(0.5); opacity: 0.55; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes blink { 50% { opacity: 0.3; } }

/* ==== Blotter / logs =========================================================================== */
.log { list-style: none; margin: 0; padding: 0; font-size: 11.5px; } /* no box of its own to scroll: the page scrolls */
.log li { display: grid; grid-template-columns: 76px 48px minmax(0, 1fr); gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--line-soft); align-items: baseline; }
.log time { color: var(--mut); white-space: nowrap; }
.log .kind { font: 500 10px var(--cond); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.log .detail { overflow-wrap: anywhere; color: var(--ink); }
.log .is-blue .kind { color: var(--cyan); }
.log .is-neg .kind { color: var(--neg); }
.log .is-pos .kind { color: var(--pos); }
.log .is-faint .detail { color: var(--ink-2); }
.log .is-news .kind { color: var(--ink); }
/* A news line opens a drawer under it: Claude's plain explanation and its view (Private/_Explain). */
.log li[data-explain] { cursor: pointer; }
.log li[data-explain]:hover .detail, .log li[data-explain][aria-expanded="true"] .detail { color: var(--ink); }
.log li[data-explain]:focus-visible { outline: 1px solid var(--amber); outline-offset: -1px; }
.log li[data-explain] .detail::after { content: " ▾"; color: var(--mut); }
.log li[data-explain][aria-expanded="true"] .detail::after { content: " ▴"; }
.drawer { grid-column: 1 / -1; margin: 6px 0 2px; padding: 10px 12px; background: var(--panel-2); border-left: 2px solid var(--amber); font: 12.5px/1.55 var(--sans); color: var(--ink-2); cursor: auto; }
.drawer p + p { margin-top: 8px; }
.drawer .view { color: var(--ink); }
.drawer .view b { color: var(--amber); }
.drawer-actions { margin: 10px 0 2px; }
/* The News panel while Claude reads the news: a bar sliding across, and the words. */
.news-loading { display: grid; gap: 6px; margin-bottom: 8px; font: 12px var(--mono); color: var(--amber); }
.news-bar { position: relative; display: block; height: 2px; overflow: hidden; background: var(--raise); }
.news-bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 35%; background: var(--amber); animation: newsbar 1.4s ease-in-out infinite; }
@keyframes newsbar { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
/* A scheduled sale on a position: an hourglass and the day, in front of the stop (Private/_Today). */
.sched { display: inline-flex; align-items: center; gap: 4px; height: 15px; vertical-align: middle; color: var(--amber); cursor: help; }
.positions .sched-col { width: 1%; padding-right: 0; text-align: left; } /* the hourglasses line up, just in front of the protection */
.positions .sym-col, .positions tbody th[scope="row"] { text-align: left; }
.sched-none { display: inline-flex; align-items: center; gap: 4px; height: 15px; vertical-align: middle; color: var(--amber); cursor: help; } /* no scheduled sale: the hourglass and an infinity sign in place of the day */
/* The owner's manual buys, under the bot's positions (Private/_Today). */
.manual { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--line); }
.universe .u-actions { display: flex; gap: 6px; justify-content: flex-end; }
/* Other markets: what IBKR finds, in the shares table's place (Private/_Search). */
.m-results .left { text-align: left; }
.u-found { margin: 18px 0 6px; font: 500 11px var(--cond); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.u-found .mut { text-transform: none; letter-spacing: 0; }
.m-results .name-cell { white-space: normal; color: var(--ink-2); }
/* Working orders: the bot's, then the owner's manual ones under a divider (Private/_Orders). */
.grid-table tr.group th { padding-top: 8px; text-align: left; font: 500 10px var(--cond); letter-spacing: 0.1em; text-transform: uppercase; color: var(--amber); border-bottom: 1px solid var(--line); }
.grid-table .group-manual tr.group th { padding-top: 12px; border-top: 1px dashed var(--line); }
.term-col > .panel--fill { flex: 1; }
.term-col > .panel--news { flex: none; } /* the equity chart takes the height left */
/* The blotter's window: 6 rows (js/dash.js measures them), no scrollbar; an arrow above and one under it. */
.scroll-view { max-height: 158px; overflow-y: auto; scrollbar-width: none; }
.scroll-view::-webkit-scrollbar { display: none; }
.scroll-view .log li:last-child { border-bottom: 0; }
.scroll-arrow { display: flex; justify-content: center; align-items: center; width: 100%; height: 24px; padding: 0; border: 0; background: none; color: var(--ink-2); cursor: pointer; }
.scroll-arrow:hover { color: var(--amber); }
.scroll-arrow:focus-visible { outline: 1px solid var(--amber); outline-offset: -1px; }
.scroll-arrow[aria-disabled="true"] { color: var(--line); cursor: default; }
.scroll-arrow svg { overflow: visible; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: square; }
.scroll-arrow--up svg { transform: scaleY(-1); } /* the same arrow, dripping upwards */
.scroll-arrow .drip { stroke-width: 1.5; animation: drip 1.6s ease-in infinite; }
.scroll-arrow .stack { animation: stack 1.6s ease-in-out infinite; }
.scroll-arrow[aria-disabled="true"] .drip { visibility: hidden; animation: none; }
.scroll-arrow[aria-disabled="true"] .stack { animation: none; }
@keyframes drip { 0% { opacity: 0; transform: translateY(-4px); } 35% { opacity: 1; } 100% { opacity: 0; transform: translateY(5px); } }
@keyframes stack { 0%, 100% { opacity: 1; } 55% { opacity: 0.55; } }

/* ==== Messages ================================================================================= */
.alert { padding: 9px 12px; border: 1px solid var(--line); background: var(--panel-2); font-size: 12px; }
.alert--info { border-color: color-mix(in srgb, var(--cyan) 35%, transparent); color: var(--ink); }
.alert--pos { border-color: color-mix(in srgb, var(--pos) 45%, transparent); color: var(--pos); }
.alert--neg { border-color: color-mix(in srgb, var(--neg) 50%, transparent); color: var(--neg); }
.alert--warn { border-color: color-mix(in srgb, var(--amber) 50%, transparent); color: var(--amber); }
.toast { position: fixed; top: calc(56px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 50; max-width: min(560px, calc(100vw - 32px)); background: var(--raise); box-shadow: 0 12px 32px var(--shadow); transition: opacity 0.3s, transform 0.3s; }
.toast.is-gone { opacity: 0; transform: translate(-50%, -8px); pointer-events: none; }
.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--amber); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==== Settings window =========================================================================== */
.modal { width: min(660px, calc(100vw - 32px)); max-height: min(88vh, 800px); padding: 0; overflow: hidden; border: 1px solid var(--line); background: var(--panel); color: var(--ink); box-shadow: 0 24px 64px var(--shadow); }
.modal[open] { display: flex; flex-direction: column; }
.modal--wide { width: min(900px, calc(100vw - 32px)); }
/* Settings: one size for every tab (the tallest, Strategy, fits without scrolling on a desktop screen). */
.modal--settings { width: min(1080px, calc(100vw - 32px)); height: min(680px, calc(100vh - 32px)); max-height: none; }
.modal--settings .tab-panel { flex: 1; }
.modal--settings .tab-panel:not([hidden]) { display: flex; flex-direction: column; }
/* A tab's content sits in the middle of the window when it is smaller than it; forms keep a readable width. */
.modal--settings .tab-body { margin: auto; width: 100%; max-width: 680px; }
.modal--settings .tab-body--wide { max-width: none; }
.strategy-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 32px; }
.cols-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }
.cols-2 > div > .field:first-child, .cols-2 > div > form:first-child .field { margin-top: 0; }
.strategy-grid .plain { gap: 10px; }
.strategy-grid .muted { margin-bottom: 8px; }
.strategy-grid .ph-foot { margin-top: 6px; }
.modal--confirm { width: min(460px, calc(100vw - 32px)); }
.modal--confirm .tab-panel p { color: var(--ink); }
.modal--confirm.is-danger { border-color: var(--neg); }
.modal--confirm.is-danger h2 { color: var(--neg); }
.modal-head h2 .mut { letter-spacing: 0.06em; margin-left: 6px; font-weight: 500; }
.modal:focus { outline: none; } /* the window itself takes focus when it opens; its controls show it */
.modal::backdrop { background: var(--scrim); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font: 600 12px var(--cond); letter-spacing: 0.16em; text-transform: uppercase; color: var(--amber); }
.tabs { display: flex; gap: 0; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs [role="tab"] { padding: 10px 12px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer; white-space: nowrap; font: 500 11.5px var(--cond); letter-spacing: 0.12em; text-transform: uppercase; color: var(--mut); }
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"]:focus-visible { outline: 1px solid var(--amber); outline-offset: -5px; }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--amber); }
.tab-panel { padding: 16px 16px 20px; overflow-y: auto; font: 13px/1.55 var(--sans); }
.tab-panel h3 { font: 600 12px var(--cond); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink); padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tab-panel .plain li { color: var(--ink-2); }
.tab-panel .plain strong { color: var(--ink); font-weight: 600; }
.status-line { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; }
.field { display: grid; gap: 5px; margin-top: 12px; }
.field > span { font: 500 10.5px var(--cond); letter-spacing: 0.1em; text-transform: uppercase; color: var(--mut); }
.field .help { text-transform: none; letter-spacing: 0; font: 11.5px var(--sans); color: var(--mut); margin-left: 6px; }
input, select, textarea { width: 100%; padding: 7px 9px; background: var(--bg); border: 1px solid var(--line); color: var(--ink); font-family: var(--mono); font-size: 12.5px; border-radius: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--amber); }
textarea { resize: vertical; line-height: 1.5; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; align-items: end; } /* inputs line up even when a label wraps */
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.seg--2 { grid-template-columns: 1fr 1fr; }
.seg form { display: contents; }
.seg-btn { padding: 8px 10px; border: 0; background: var(--panel-2); color: var(--mut); cursor: pointer; font: 500 11.5px var(--cond); letter-spacing: 0.1em; text-transform: uppercase; }
.seg-btn:hover:not(:disabled) { color: var(--ink); }
.seg-btn.is-on { background: var(--raise); color: var(--amber); }
.seg-btn:disabled { cursor: default; }
dl.kv { display: grid; gap: 0; margin: 12px 0 0; }
dl.kv > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
dl.kv dt { color: var(--mut); font: 500 10.5px var(--cond); letter-spacing: 0.08em; text-transform: uppercase; padding-top: 2px; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
.test-log { display: block; margin-top: 12px; font-family: var(--mono); font-size: 12px; }
.test-log[hidden] { display: none; }

/* ==== Notes (the notes window) ================================================================== */
.notes { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.note { padding: 12px 0; border-bottom: 1px solid var(--line-soft); display: grid; gap: 8px; }
.note-body { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--sans); }
.note-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--mut); }
.note-meta time { white-space: nowrap; }
.note-meta .spacer { flex: 1; }
.note-form { display: none; margin: 0; }
.note-form .actions { margin-top: 8px; }
.note.is-editing .note-form { display: block; }
.note.is-editing .note-body, .note.is-editing .note-meta { display: none; }

/* ==== Public pages: the 3D code (js/hero-3d.js) with at most one panel on top ===================== */
body.public { margin: 0; overflow: hidden; height: 100vh; background: var(--bg); color: var(--ink); font: 13px/1.5 var(--mono); user-select: none; -webkit-tap-highlight-color: transparent; }
.backdrop { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
/* A vignette in the page's own colour, so the panel always reads on top of the code. */
body.public::after { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 50%, color-mix(in srgb, var(--bg) 88%, transparent) 100%); }
.stage { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(400px, 100%); padding: 22px 22px 18px; background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line); box-shadow: 0 24px 64px var(--shadow); user-select: text; }
.auth-card .brand { margin-bottom: 20px; }
.auth-card h1 { font: 600 12px var(--cond); letter-spacing: 0.16em; text-transform: uppercase; color: var(--amber); margin-bottom: 6px; }
.auth-card .lead { color: var(--ink-2); margin-bottom: 20px; font-family: var(--sans); }
.auth-card .btn { width: 100%; }
.auth-card .foot { margin-top: 16px; display: flex; justify-content: center; font-size: 12px; }
.auth-card .alert { margin-bottom: 14px; }
.progress { height: 2px; background: var(--raise); overflow: hidden; margin: 18px 0 8px; }
.progress span { display: block; height: 100%; width: 0; background: var(--amber); animation: fill 2.2s ease-out forwards; }
@keyframes fill { to { width: 100%; } }

/* ==== Narrow screens ============================================================================== */
@media (max-width: 1000px) {
    .strategy-grid, .cols-2 { grid-template-columns: minmax(0, 1fr); gap: 20px; }
    .term-grid { grid-template-columns: minmax(0, 1fr); }
    .clocks { display: none; }
}
@media (max-width: 640px) {
    .hide-sm { display: none !important; } /* over any display a component sets */
    .sim-table th:nth-child(2), .sim-table td:nth-child(2), .sim-table th:nth-child(5), .sim-table td:nth-child(5) { display: none; }
    .tabs [role="tab"] { padding: 10px 9px; }
    .u-set span { padding: 0 8px; letter-spacing: 0.05em; }
    /* Positions on a phone: symbol, P&L %, the hourglass, protection, the button. */
    .positions th:nth-child(n+2):nth-child(-n+5), .positions td:nth-child(n+2):nth-child(-n+5),
    .positions:not(.manual-table) th:nth-child(n+9):nth-child(-n+11), .positions:not(.manual-table) td:nth-child(n+9):nth-child(-n+11), .positions tbody th .mut.small { display: none; }
    .positions td:nth-child(8) { white-space: normal; }
    /* Shares: the search on its row, both dropdowns on the next; the pager's pages under its other two parts. */
    .u-tools input[type="search"] { flex-basis: 100%; max-width: none; }
    .u-select { flex: 1 1 calc(50% - 4px); }
    .u-pager { grid-template-columns: 1fr auto; }
    .u-pager .pages { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
    .universe .status { white-space: normal; }
    .head-actions { width: 100%; } /* both buttons on one row, the same size */
    .head-actions form { flex: 1; }
    .head-actions .btn { width: 100%; }
    .topbar-inner { gap: 10px; padding: 0 10px; }
    .brand-name { display: none; }
    .term-head { gap: 8px 14px; padding: 8px 10px; }
    .panel { padding: 10px; }
    .form-grid { grid-template-columns: 1fr; }
    .log li { grid-template-columns: 88px minmax(0, 1fr); }
    .log .kind { display: none; }
    .modal { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; }
    .modal--settings { height: 100dvh; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
    .scroll-arrow .drip, .scroll-arrow .stack, .ind .halo, .ind--blink, .tchart .halo, .tape-track, .news-bar::after { animation: none; }
    .tape-view { overflow-x: auto; scrollbar-width: none; } /* no ticker: swiped instead */
    .scroll-arrow .drip { visibility: hidden; }
}
