/* The Desk: a trader's desk where you watch Claude's mind at work.
   One screen from 1280px up (panels scroll inside themselves); it stacks on a phone.
   Warm graphite. Amber is Claude's voice: the thought stream, the plan, its chips and its marks on the chart.
   Green and red only for P&L and direction. Numbers in a monospace with tabular figures. An 8px grid. */

:root {
  --bg: #101214;
  --panel: #16191c;
  --raised: #1c2024;
  --line: #22262a;
  --line-2: #2c3136;
  --text: #e6e4e0;
  --muted: #8b8f93;
  --faint: #5f6468;
  --amber: #e8a33d;
  --amber-soft: rgba(232, 163, 61, .12);
  --amber-line: rgba(232, 163, 61, .35);
  --up: #5fb58a;
  --up-soft: rgba(95, 181, 138, .12);
  --down: #d9695f;
  --down-soft: rgba(217, 105, 95, .12);
  --caution: #d9a13d;
  --vwap: #9f8be0;
  --range: #5aa7b8;
  --prior: #8d98a4;
  --bench: #8b8f93;
  /* names the shared chart code reads */
  --thought: #e8a33d;
  --thought-soft: rgba(232, 163, 61, .12);
  --line-soft: #22262a;
  --warn: #d9a13d;
  --sans: -apple-system, BlinkMacSystemFont, Inter, system-ui, "Segoe UI", Roboto, sans-serif;  /* the chart reads --sans */
  --ui: -apple-system, BlinkMacSystemFont, Inter, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f2f1ef;
  --panel: #fbfaf8;
  --raised: #f0eeeb;
  --line: #e1ded9;
  --line-2: #d3cfc9;
  --text: #1c1b19;
  --muted: #65625d;
  --faint: #97938d;
  --amber: #a8680f;
  --amber-soft: rgba(168, 104, 15, .1);
  --amber-line: rgba(168, 104, 15, .35);
  --up: #2f8a5e;
  --up-soft: rgba(47, 138, 94, .1);
  --down: #b9463c;
  --down-soft: rgba(185, 70, 60, .09);
  --caution: #a8740f;
  --vwap: #6c55c2;
  --range: #2f7f90;
  --prior: #6a7580;
  --bench: #8a867f;
  --thought: #a8680f;
  --thought-soft: rgba(168, 104, 15, .1);
  --line-soft: #e1ded9;
  --warn: #a8740f;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13px/1.5 var(--ui); font-variant-numeric: tabular-nums;
       -webkit-font-smoothing: antialiased; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; }
h1, h2, h3, h4 { margin: 0; font-size: 13px; font-weight: 600; }
p { margin: 0; }
.hidden { display: none !important; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.up { color: var(--up); }
.down { color: var(--down); }
.label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
:focus-visible { outline: 1px solid var(--amber); outline-offset: 2px; }
code { font-family: var(--mono); font-size: 12px; }

button { font: inherit; font-weight: 600; color: var(--text); background: var(--raised); border: 1px solid var(--line-2);
         border-radius: 4px; padding: 3px 10px; cursor: pointer; line-height: 18px; }
button:hover { border-color: var(--faint); }
button.danger { color: var(--down); }
button.danger.solid { background: var(--down); border-color: var(--down); color: #fff; }
button.key { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--muted); background: transparent; padding: 1px 6px; }
kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 3px;
      padding: 0 5px; color: var(--text); background: var(--raised); }

/* each region keeps its row even when the banners are empty (display: none takes an item out of the grid) */
.statusbar { grid-row: 1; } .banners { grid-row: 2; } .desk { grid-row: 3; } .drawer { grid-row: 4; }

/* ---------- status line ---------- */
.statusbar { display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 12px; background: var(--panel);
             border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12px; white-space: nowrap; min-width: 0; }
.switch { display: inline-flex; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; font-family: var(--ui); flex: none; }
.sw { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 2px 10px; font-size: 12px; }
.sw + .sw { border-left: 1px solid var(--line-2); }
.sw.active { background: var(--raised); color: var(--text); }
.sw .mini { margin-left: 6px; font-family: var(--mono); font-weight: 500; font-size: 11px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--up); flex: none; }
.st-state { font-weight: 700; letter-spacing: .04em; flex: none; }
.st-line { color: var(--muted); overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.st-right { display: flex; align-items: center; gap: 8px; flex: none; }
.st-eq { display: flex; gap: 8px; align-items: baseline; }
#equity { color: var(--text); font-weight: 600; }
.statusbar.st-ok .st-state { color: var(--up); }
.statusbar.st-think .dot { background: var(--amber); animation: pulse 1.4s ease-in-out infinite; }
.statusbar.st-think .st-state { color: var(--amber); }
.statusbar.st-warn .dot { background: var(--caution); }
.statusbar.st-warn .st-state, .statusbar.st-warn .st-line { color: var(--caution); }
.statusbar.st-bad .dot { background: var(--down); }
.statusbar.st-bad .st-state, .statusbar.st-bad .st-line { color: var(--down); }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px var(--amber-soft); } }
.flash-up { animation: flash-up .4s ease-out; }
.flash-down { animation: flash-down .4s ease-out; }
@keyframes flash-up { from { background: var(--up-soft); } }
@keyframes flash-down { from { background: var(--down-soft); } }

.banners:empty { display: none; }
.banner { padding: 6px 12px; font-weight: 600; border-bottom: 1px solid var(--line); }
.banner.bad { background: var(--down-soft); color: var(--down); }
.banner.warn { background: var(--amber-soft); color: var(--caution); }

/* ---------- the desk ---------- */
.desk { display: grid; grid-template-columns: minmax(0, 22fr) minmax(0, 48fr) minmax(0, 30fr); min-height: 0; }
.col { min-height: 0; overflow-y: auto; border-right: 1px solid var(--line); padding: 8px 12px 16px; }
.col:last-child { border-right: 0; }
.col-head { display: flex; align-items: center; gap: 8px; min-height: 28px; margin-bottom: 4px; flex-wrap: wrap; }
.col-head .label { margin-right: auto; }
.blk { padding: 8px 0 12px; border-bottom: 1px solid var(--line); }
.blk:last-child { border-bottom: 0; }
.blk > .label { display: block; margin-bottom: 8px; }
.empty { color: var(--muted); padding: 4px 0; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 4px; overflow: hidden; }
.seg-btn { border: 0; border-radius: 0; background: transparent; color: var(--muted); font-size: 11px; padding: 1px 8px; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line-2); }
.seg-btn.active { background: var(--raised); color: var(--text); }

/* book */
.watch { display: grid; }
.w-row { display: grid; grid-template-columns: minmax(0, 1fr) 56px auto 58px; gap: 8px; align-items: center; padding: 3px 4px;
         border: 0; border-radius: 3px; background: transparent; text-align: left; font-weight: 500; width: 100%; }
button.w-row:hover { background: var(--raised); }
.w-row.active { background: var(--raised); box-shadow: inset 2px 0 0 var(--text); }
.w-row .sym { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-row .num { text-align: right; font-size: 12px; }
.w-row .spark { height: 16px; }
.w-row.static { cursor: default; }
.pos-blk { padding: 4px 0 8px; }
.pos-top { display: flex; justify-content: space-between; gap: 8px; }
.pos-side { font-weight: 700; }
.pos-side.long { color: var(--up); } .pos-side.short { color: var(--down); }
.pos-track { position: relative; height: 4px; border-radius: 2px; margin: 8px 0 4px;
             background: linear-gradient(90deg, var(--down-soft), var(--raised) 50%, var(--up-soft)); }
.pos-track > i { position: absolute; top: -3px; width: 2px; height: 10px; background: var(--text); }
.pos-ends { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.risk-row { margin-bottom: 8px; }
.risk-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.risk-top .num { color: var(--muted); }
.bar { height: 3px; background: var(--raised); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.bar > span { display: block; height: 100%; background: var(--faint); }
.bar.caution > span { background: var(--caution); }
.bar.danger > span { background: var(--down); }
.bar.good > span { background: var(--up); }
.kv-line { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-top: 4px; }
.spark { width: 100%; display: block; }
.spark path.line { fill: none; stroke-width: 1.4; }
.spark path.area { stroke: none; opacity: .12; }
.spark.up .line { stroke: var(--up); } .spark.up .area { fill: var(--up); }
.spark.down .line { stroke: var(--down); } .spark.down .area { fill: var(--down); }
#equity-spark .spark { height: 40px; }
.l-0 { left: 0; } .l-5 { left: 5%; } .l-10 { left: 10%; } .l-15 { left: 15%; } .l-20 { left: 20%; } .l-25 { left: 25%; }
.l-30 { left: 30%; } .l-35 { left: 35%; } .l-40 { left: 40%; } .l-45 { left: 45%; } .l-50 { left: 50%; }
.l-55 { left: 55%; } .l-60 { left: 60%; } .l-65 { left: 65%; } .l-70 { left: 70%; } .l-75 { left: 75%; }
.l-80 { left: 80%; } .l-85 { left: 85%; } .l-90 { left: 90%; } .l-95 { left: 95%; } .l-100 { left: calc(100% - 2px); }
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; }
.w-25 { width: 25%; } .w-30 { width: 30%; } .w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; }
.w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; } .w-70 { width: 70%; }
.w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; }
.w-100 { width: 100%; }

/* chart */
.chart { display: flex; flex-direction: column; }
.price-chart { position: relative; flex: 1; min-height: 320px; }
.price-chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; }
.gym-day { position: relative; flex: 1; min-height: 320px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: var(--muted); padding: 16px; }
.chart-tip { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 3; max-width: 320px; font-size: 12px;
             background: var(--panel); border: 1px solid var(--line-2); border-radius: 4px; padding: 8px;
             box-shadow: 0 8px 24px -12px rgba(0, 0, 0, .6); }
.chart-tip .tip-title { font-family: var(--mono); font-weight: 600; }
.chart-tip .tip-thought { margin-top: 4px; color: var(--amber); }
.regime { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 8px; border-top: 1px solid var(--line);
          white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 26px; }
.legend { display: flex; flex-wrap: wrap; gap: 2px; }
.legend button { font-size: 11px; font-weight: 500; padding: 0 6px; border: 0; background: transparent; color: var(--muted);
                 display: inline-flex; align-items: center; gap: 4px; }
.legend button.off { opacity: .35; }
.legend .swatch { width: 10px; border-top: 2px solid currentColor; }
.legend .swatch.dash { border-top-style: dashed; }
.legend .swatch.dot { width: 6px; height: 6px; border: 0; border-radius: 50%; background: currentColor; }
.sw-vwap { color: var(--vwap) !important; } .sw-range { color: var(--range) !important; } .sw-prior { color: var(--prior) !important; }
.sw-round { color: var(--faint) !important; } .sw-thought { color: var(--amber) !important; } .sw-pos { color: var(--text) !important; }
select { font: inherit; font-size: 12px; color: var(--text); background: var(--raised); border: 1px solid var(--line-2); border-radius: 4px; padding: 1px 6px; }

/* mind */
.mind { display: flex; flex-direction: column; }
.plan-card { border: 1px solid var(--amber-line); border-radius: 4px; padding: 8px 10px; margin-bottom: 8px; background: var(--amber-soft); }
.plan-card .label { color: var(--amber); }
.plan-bias { display: flex; gap: 8px; align-items: baseline; font-family: var(--mono); font-size: 12px; }
.plan-bias strong { text-transform: uppercase; letter-spacing: .04em; }
.plan-sc { display: grid; grid-template-columns: 12px 14px minmax(0, 1fr); gap: 6px; margin-top: 6px; font-size: 12px; align-items: start; }
.plan-sc .sc-label { font-family: var(--mono); font-weight: 700; color: var(--amber); }
.sc-dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--amber); margin-top: 5px; }
.sc-dot.hit { background: var(--amber); }
.sc-dot.none { border-color: var(--faint); }
.sc-state { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.sc-state.hit { color: var(--amber); }
.plan-extra { font-size: 12px; color: var(--muted); margin-top: 6px; }
.attempts { display: inline-flex; gap: 3px; align-items: center; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.attempts span { width: 12px; height: 3px; border-radius: 2px; background: var(--line-2); }
.attempts span.used { background: var(--amber); }
.attempts span.over { background: var(--down); }
.grade { font-size: 12px; color: var(--muted); margin-top: 6px; border-left: 2px solid var(--amber-line); padding-left: 8px; }
.news { border: 1px solid var(--line); border-radius: 4px; padding: 4px 10px; margin-bottom: 8px; font-size: 12px; }
.news > summary { cursor: pointer; color: var(--muted); font-family: var(--mono); list-style: none; }
.news > summary::-webkit-details-marker { display: none; }
.news[open] > summary { margin-bottom: 4px; }
.research-row { padding: 3px 0; border-top: 1px solid var(--line); }
.research-row:first-child { border-top: 0; }
.research-head { cursor: pointer; font-family: var(--mono); }
.research-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.research-detail { padding: 4px 0 2px 8px; overflow-wrap: anywhere; }
.research-src { margin-right: 6px; }
.research-cancel { font-size: 11px; padding: 0 6px; margin-left: 4px; }
.bias-bullish { color: var(--up); } .bias-bearish { color: var(--down); } .bias-neutral { color: var(--muted); }
.stream-head { position: sticky; top: -8px; background: var(--bg); z-index: 1; padding-top: 4px; }
.stream { font-family: var(--mono); font-size: 12px; line-height: 1.55; }
.th { padding: 8px 0 10px 12px; border-left: 2px solid var(--line-2); margin-left: 2px; }
.th + .th { border-top: 1px dashed var(--line); }
.th.acted { border-left-color: var(--amber); }
.th.rejected { border-left-color: var(--caution); }
.th.error { border-left-color: var(--down); }
.th.system { border-left-color: var(--line); color: var(--muted); }
.th.focus { background: var(--amber-soft); }
.th.enter { animation: enter .45s cubic-bezier(.2, .7, .2, 1); }
@keyframes enter { from { opacity: 0; transform: translateY(-8px); } }
.th-meta { display: flex; gap: 8px; color: var(--faint); flex-wrap: wrap; }
.th-meta time { color: var(--muted); }
.th-reason { color: var(--amber); margin: 4px 0; cursor: pointer; font-family: var(--mono); }
:root[data-theme="light"] .th-reason { color: #6e4608; }
.th-chips { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip { display: inline-flex; align-items: center; padding: 0 6px; border-radius: 3px; font-family: var(--mono); font-size: 11px;
        line-height: 18px; background: var(--raised); color: var(--muted); white-space: nowrap; border: 1px solid var(--line-2); }
.chip.act { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }
.chip.warn { color: var(--caution); border-color: var(--amber-line); }
.chip.bad { color: var(--down); border-color: var(--down-soft); }
.chip.tag { color: var(--caution); }
.th-note { color: var(--faint); font-size: 11px; }
.th-more { background: transparent; border: 0; padding: 0; color: var(--faint); font-weight: 500; font-size: 11px; margin-top: 4px; }
.th-more:hover { color: var(--amber); }
.snapshot { display: grid; gap: 4px; margin-top: 6px; font-family: var(--ui); }
.snapshot-title { color: var(--faint); font-size: 11px; }
.snap-sec { border: 1px solid var(--line); border-radius: 3px; }
.snap-sec > summary { padding: 2px 8px; cursor: pointer; font-weight: 600; font-size: 12px; list-style: none; display: flex; justify-content: space-between; }
.snap-sec > summary::-webkit-details-marker { display: none; }
.snap-sec > summary::after { content: "+"; color: var(--faint); }
.snap-sec[open] > summary::after { content: "–"; }
.snap-body { padding: 0 8px 8px; font-size: 12px; overflow-x: auto; }
.snap-body p { white-space: pre-wrap; }
.snap-body h4 { margin: 8px 0 4px; font-size: 11px; color: var(--muted); }
.snap-body ul { margin: 4px 0; padding-left: 16px; }
.snap-body .data { color: var(--muted); white-space: pre; margin: 0; font-family: var(--mono); font-size: 11px; }

/* ---------- drawer ---------- */
.drawer { border-top: 1px solid var(--line-2); background: var(--panel); display: grid; grid-template-rows: 32px minmax(0, 1fr); min-height: 0; }
.drawer.closed { grid-template-rows: 32px; }
.drawer.closed .drawer-body { display: none; }
.dh-15 { height: 15vh; } .dh-20 { height: 20vh; } .dh-25 { height: 25vh; } .dh-30 { height: 30vh; } .dh-35 { height: 35vh; }
.dh-40 { height: 40vh; } .dh-45 { height: 45vh; } .dh-50 { height: 50vh; } .dh-55 { height: 55vh; } .dh-60 { height: 60vh; }
.dh-65 { height: 65vh; } .dh-70 { height: 70vh; } .dh-75 { height: 75vh; }
.drawer.closed { height: auto; }
.drawer-bar { position: relative; display: flex; align-items: stretch; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.grip { touch-action: none; position: absolute; left: 50%; top: -4px; width: 48px; height: 8px; margin-left: -24px; cursor: ns-resize; border-radius: 4px; }
.grip::after { content: ""; position: absolute; left: 12px; right: 12px; top: 3px; height: 2px; border-radius: 1px; background: var(--line-2); }
.grip:hover::after, .grip:focus-visible::after { background: var(--amber); }
.dtabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.dtabs::-webkit-scrollbar { display: none; }
.dtab { background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted);
        font-size: 12px; padding: 0 8px; white-space: nowrap; }
.dtab.active { color: var(--text); border-bottom-color: var(--text); }
.drawer.closed .dtab.active { border-bottom-color: transparent; }
.drawer-toggle { align-self: center; }
.drawer-body { overflow-y: auto; padding: 12px; min-height: 0; }
.pane-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 3px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
td { font-family: var(--mono); }
td.num, th.num { text-align: right; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--raised); }
.rbar { display: inline-grid; grid-template-columns: 36px 36px; align-items: center; height: 8px; vertical-align: middle; }
.rbar .neg, .rbar .pos { height: 6px; display: flex; }
.rbar .neg { justify-content: flex-end; border-right: 1px solid var(--faint); }
.rbar .neg > span { background: var(--down); height: 100%; }
.rbar .pos > span { background: var(--up); height: 100%; }

/* learning: the playbook as a living document */
.learn-grid { display: grid; gap: 24px; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.learn-grid .label { display: block; margin: 0 0 8px; }
.learn-grid .label + div + .label { margin-top: 16px; }
.stat-row { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 12px; font-family: var(--mono); }
.stat .label { display: block; }
.stat .value { font-size: 15px; font-weight: 600; }
.stat .sub { color: var(--faint); font-size: 11px; }
.rule { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 0 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.rule .evidence { grid-column: 2; color: var(--faint); font-size: 11px; font-family: var(--mono); }
.pill { font-family: var(--mono); font-size: 11px; font-weight: 600; }
.pill.confirmed { color: var(--up); } .pill.testing { color: var(--amber); } .pill.retired { color: var(--faint); }
.version { padding: 6px 0 8px; border-bottom: 1px solid var(--line); }
.version-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-family: var(--mono); font-size: 11px; color: var(--faint); }
.version-head strong { color: var(--text); font-size: 12px; }
.version-sum { margin: 4px 0; font-size: 12px; }
.diff { display: grid; gap: 2px; font-size: 12px; }
.diff div { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px; }
.diff .k { font-family: var(--mono); font-size: 11px; }
.diff .added .k, .diff .confirmed .k, .diff .reinstated .k { color: var(--up); }
.diff .added .t { color: var(--up); }
.diff .removed .k, .diff .retired .k, .diff .demoted .k { color: var(--down); }
.diff .revised .k { color: var(--amber); }
.diff .retired .t, .diff .removed .t { text-decoration: line-through; color: var(--muted); }
.diff .before { display: block; color: var(--faint); text-decoration: line-through; }
.mistake { padding: 4px 0 6px; border-bottom: 1px solid var(--line); }
.lesson { color: var(--muted); font-size: 12px; }
.heat { display: grid; gap: 2px; font-size: 11px; overflow-x: auto; margin: 8px 0; font-family: var(--mono); }
.heat-row { display: grid; grid-template-columns: 140px repeat(var(--days, 1), 12px) auto; gap: 2px; align-items: center; }
.heat-cell { width: 12px; height: 12px; border-radius: 2px; background: var(--raised); }
.heat-cell.n1 { background: color-mix(in srgb, var(--caution) 40%, var(--raised)); }
.heat-cell.n2 { background: color-mix(in srgb, var(--caution) 70%, var(--raised)); }
.heat-cell.n3 { background: var(--caution); }
.heat-tag { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.heat-sum { color: var(--muted); padding-left: 6px; white-space: nowrap; }
.days-1 { --days: 1; } .days-2 { --days: 2; } .days-3 { --days: 3; } .days-4 { --days: 4; } .days-5 { --days: 5; }
.days-6 { --days: 6; } .days-7 { --days: 7; } .days-8 { --days: 8; } .days-9 { --days: 9; } .days-10 { --days: 10; }
.days-11 { --days: 11; } .days-12 { --days: 12; } .days-13 { --days: 13; } .days-14 { --days: 14; }
.plan-item { display: grid; grid-template-columns: 88px 64px minmax(0, 1fr); gap: 8px; padding: 3px 0; font-size: 12px; border-bottom: 1px solid var(--line); }
.plan-item > :first-child { font-family: var(--mono); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

/* gym, letters, controls */
.gym-top { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; font-size: 12px; }
.gym-top .grow { flex: 1; }
.gym-proc { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; font-size: 12px; }
.gym-proc #gym-proc-state { flex: 1 1 240px; min-width: 0; }
.kv-inline { color: var(--muted); }
.kv-inline strong { color: var(--text); margin-left: 4px; }
.gym-grid { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.chart-box { position: relative; height: 200px; }
.gym-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.gym-form label { display: grid; gap: 2px; font-size: 11px; color: var(--muted); }
.gym-form input, .gym-form select { font: inherit; font-family: var(--mono); background: var(--raised); color: var(--text); border: 1px solid var(--line-2);
                                    border-radius: 4px; padding: 2px 6px; min-width: 0; }
.badge { display: inline-block; padding: 0 6px; border-radius: 3px; font-family: var(--mono); font-size: 11px; font-weight: 600; line-height: 18px;
         background: var(--raised); color: var(--muted); }
.state-ok { color: var(--up); } .state-warn { color: var(--caution); } .state-bad { color: #fff; background: var(--down); } .state-think { color: var(--amber); }
.letters { display: grid; gap: 16px; grid-template-columns: 220px minmax(0, 1fr); }
.letters-list { display: grid; gap: 4px; align-content: start; }
.letter-link { display: grid; text-align: left; font-weight: 400; border-color: var(--line); }
.letter-link.active { border-color: var(--amber); }
.letter-week { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.letter { max-width: 72ch; line-height: 1.6; }
.letter-title { font-size: 15px; margin-bottom: 4px; }
.letter h3 { margin: 16px 0 6px; } .letter h4 { margin: 16px 0 6px; font-size: 12px; }
.letter p { margin: 8px 0; } .letter ul, .letter ol { margin: 8px 0; padding-left: 22px; }
.letter pre { background: var(--raised); border: 1px solid var(--line); border-radius: 4px; padding: 8px; overflow-x: auto; }
.letter .meta { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.controls-grid { display: grid; gap: 24px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; }
.controls-grid .label { display: block; margin: 0 0 8px; }
.controls-grid .label ~ .label { margin-top: 16px; }
.controls-grid p { margin-top: 8px; font-size: 12px; }
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; color: var(--down); font-weight: 600; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.field-label { display: flex; justify-content: space-between; margin-top: 12px; color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--amber); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; font-size: 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-family: var(--mono); }
.credit { color: var(--faint); font-size: 11px; margin-top: 24px; }
.credit strong { color: var(--muted); font-weight: 600; }

/* dialogs */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 6px; padding: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .55); }
.palette { width: min(560px, calc(100vw - 16px)); margin-top: 12vh; }
.palette input { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text);
                 font: 14px var(--ui); padding: 12px 16px; outline: none; }
.palette-list { list-style: none; margin: 0; padding: 4px; max-height: 50vh; overflow-y: auto; }
.palette-list li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 12px; border-radius: 4px; cursor: pointer; }
.palette-list li.sel { background: var(--raised); }
.palette-list li .hint { color: var(--faint); font-family: var(--mono); font-size: 11px; }
.palette-list li.danger-cmd { color: var(--down); }
.help { width: min(420px, calc(100vw - 16px)); padding: 16px; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 12px 0; }
.keys dd { margin: 0; color: var(--muted); }
.replay { width: min(1100px, calc(100vw - 16px)); max-height: calc(100vh - 32px); }
.replay-head { display: flex; gap: 16px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line);
               position: sticky; top: 0; background: var(--panel); z-index: 2; }
.replay-head > div:first-child { flex: 1; min-width: 0; }
.replay-head h2 { font-size: 15px; }
.replay-result { text-align: right; font-family: var(--mono); }
.replay-result .r { font-size: 18px; font-weight: 600; }
.replay-chart { height: 320px; flex: none; margin: 12px 16px 0; }
.replay-body { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 16px 16px; }
.replay-body .full { grid-column: 1 / -1; }
.replay-body h3 { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-bottom: 4px; }
.why { border-left: 2px solid var(--amber); padding-left: 10px; }
.why .quote { color: var(--amber); font-family: var(--mono); font-size: 12px; margin: 4px 0; }
.during { display: grid; gap: 4px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.during time { color: var(--text); margin-right: 8px; }
.ep-chart { height: 220px; margin: 12px 16px 0; }
.lab-source { color: var(--amber); text-decoration: underline; }
.lab-src { font-size: 11px; padding: 0 8px 6px; }
.ep-session { border-top: 1px solid var(--line); padding: 6px 0; }
.ep-session summary { cursor: pointer; font-size: 12px; }
.ep-thought { border-left: 2px solid var(--amber); padding-left: 10px; margin: 8px 0 0; }
.ep-thought .quote { color: var(--amber); font-family: var(--mono); font-size: 12px; margin: 4px 0; white-space: pre-wrap; }
.act { font-family: var(--mono); font-size: 12px; font-weight: 600; }
.act.open-long, .act.buy { color: var(--up); } .act.open-short, .act.sell { color: var(--down); }
.act.rejected { color: var(--caution); } .act.failed { color: var(--down); }
.act .fillnote { color: var(--muted); font-weight: 400; }

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

/* below 1280px the desk stacks and the page scrolls */
@media (max-width: 1279px) {
  html, body { height: auto; }
  body { display: block; }
  .statusbar { position: sticky; top: 0; z-index: 10; }
  .desk { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .col { overflow: visible; border-bottom: 1px solid var(--line); }
  .chart { grid-column: 1 / -1; order: -1; }
  .price-chart, .gym-day { min-height: 380px; }
  .drawer, .drawer[class*="dh-"] { height: auto; }
  .drawer-body { max-height: none; overflow: visible; }
  .grip { display: none; }
  .learn-grid, .gym-grid, .controls-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .statusbar { flex-wrap: wrap; height: auto; padding: 6px 8px; gap: 6px 10px; }
  .st-line { flex-basis: 100%; order: 5; white-space: normal; }
  .st-right { margin-left: auto; }
  .desk { grid-template-columns: minmax(0, 1fr); }
  .col { border-right: 0; padding: 8px; }
  .chart { order: -2; }
  .mind { order: -1; }
  .price-chart, .gym-day { min-height: 300px; }
  .letters { grid-template-columns: minmax(0, 1fr); }
  .replay-body { grid-template-columns: minmax(0, 1fr); padding: 8px; }
  .replay-chart { height: 240px; margin: 8px; }
  .replay-head { flex-wrap: wrap; padding: 8px; }
  #palette-open { display: none; }
}
#gym-panels > .label { display: block; margin: 16px 0 8px; }
#gym-panels > .label:first-child { margin-top: 0; }
#gym-state > div + div, #gym-curve > div + div { margin-top: 2px; }
.th-meta span:last-child:not(:first-of-type) { margin-left: auto; }

/* the shared learning renderer writes its own h3 headings: give them the desk's label style */
.learn h3 { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.learn h3 ~ h3 { margin-top: 16px; }
.small-meta { font-family: var(--mono); font-size: 11px; margin-bottom: 4px; }
.plan-extra { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.letters-list:empty { display: none; }
.letters:has(.letters-list:empty) { grid-template-columns: minmax(0, 1fr); }
/* the drawer never grows wider than the screen: wide tables scroll inside their own wrapper */
.drawer { grid-template-columns: minmax(0, 1fr); min-width: 0; }
.drawer-bar, .drawer-body, .dpane { min-width: 0; }

@media (max-width: 1279px) { .stream-head { position: static; } }  /* the sticky status bar sits on top here */

/* ---------- the lab ---------- */
.lab-grid { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: start; }
.lab-item { display: grid; gap: 2px; width: 100%; text-align: left; font-weight: 400; background: transparent;
            border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 6px 4px; }
.lab-item.active { background: var(--raised); box-shadow: inset 2px 0 0 var(--amber); }
.lab-top { display: flex; gap: 8px; align-items: center; }
.lab-text { font-size: 12px; }
.lab-item .faint { font-family: var(--mono); font-size: 11px; }
.lab-form { display: grid; gap: 6px; margin-top: 16px; }
.lab-form textarea, .lab-form input { font: 12px var(--ui); color: var(--text); background: var(--raised); border: 1px solid var(--line-2);
                                      border-radius: 4px; padding: 6px 8px; resize: vertical; min-width: 0; }
.lab-form p { font-size: 11px; }
.lab-title { font-weight: 600; margin-bottom: 2px; }
.lab-verdict { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin: 8px 0; font-family: var(--mono); font-size: 12px; }
.lab-legend { display: flex; gap: 12px; font-size: 11px; font-family: var(--mono); }
.lab-legend .key-a::before, .lab-legend .key-b::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 4px; }
.lab-legend .key-a::before { background: var(--prior); }
.lab-legend .key-b::before { background: var(--amber); }
.lab-bars { overflow-x: auto; margin: 4px 0 8px; }
.paired { height: 140px; min-width: 240px; display: block; }
.paired .zero, .ci .zero { stroke: var(--faint); stroke-width: 1; }
.paired .arm-a { fill: var(--prior); }
.paired .arm-b { fill: var(--amber); }
.lab-ci { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-family: var(--mono); font-size: 12px; margin-bottom: 4px; }
.ci { width: 200px; height: 24px; }
.ci .range { stroke: var(--amber); stroke-width: 3; stroke-linecap: round; }
.ci .mid { fill: var(--text); }
@media (max-width: 1279px) { .lab-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- replay the day: a time-lapse of one session ---------- */
.replay-btn { font-size: 11px; padding: 1px 10px; color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }
.replay-btn:hover { border-color: var(--amber); }
.mini-replay { font-size: 10px; line-height: 14px; padding: 1px 6px; color: var(--amber); background: transparent; border-color: var(--line-2); }
.mini-replay:hover { border-color: var(--amber); background: var(--amber-soft); }
.version-head .mini-replay { margin-left: auto; }
.plan-item:has(.mini-replay) { grid-template-columns: 88px 64px minmax(0, 1fr) auto; }

.movie { width: calc(100vw - 32px); max-width: 1680px; height: calc(100vh - 32px); max-height: none; overflow: hidden; }
.movie[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.mv-head { display: flex; align-items: center; gap: 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.mv-title { flex: 1; min-width: 0; }
.mv-title h2 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv-title .faint { font-family: var(--mono); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv-head select { font: inherit; color: var(--text); background: var(--raised); border: 1px solid var(--line-2); border-radius: 4px; padding: 2px 6px; }
.mv-clock { font-family: var(--mono); color: var(--amber); white-space: nowrap; }
.mv-clock .num { font-size: 22px; font-weight: 600; letter-spacing: .02em; }
.mv-pnl { display: flex; align-items: baseline; gap: 8px; font-family: var(--mono); white-space: nowrap; }
.mv-pnl .num { font-size: 15px; font-weight: 600; min-width: 8ch; text-align: right; }
.mv-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 32%); min-height: 0; }
.mv-chart { position: relative; min-height: 0; border-right: 1px solid var(--line); }
.mv-chart canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.mv-note { position: absolute; left: 16px; top: 22px; right: 96px; color: var(--muted); font-size: 12px; pointer-events: none; }
.mv-stream { display: flex; flex-direction: column; min-height: 0; padding: 8px 12px 0; }
.mv-stream .col-head .label { margin-right: auto; }
.mv-stream .stream { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 12px; }
.mv-stream .th.now { background: var(--amber-soft); border-left-color: var(--amber); }
.mv-transport { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); min-width: 0; }
.mv-btn { font-family: var(--mono); padding: 3px 9px; }
.mv-play { min-width: 120px; color: var(--bg); background: var(--amber); border-color: var(--amber); }
.mv-play:hover { border-color: var(--text); }
.mv-scrub { position: relative; flex: 1; min-width: 120px; display: grid; }
.mv-scrub canvas { width: 100%; height: 14px; display: block; }
.mv-scrub input { width: 100%; margin: 2px 0 0; accent-color: var(--amber); cursor: pointer; }
.mv-time { white-space: nowrap; font-size: 12px; }
.mv-summary { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 32px));
              background: var(--panel); border: 1px solid var(--amber-line); border-radius: 6px; padding: 16px 20px;
              box-shadow: 0 12px 40px rgba(0, 0, 0, .45); display: grid; gap: 12px; animation: rise .35s cubic-bezier(.2, .7, .2, 1); }
.mv-sum-head { display: flex; align-items: baseline; gap: 12px; }
.mv-sum-head h3 { font-size: 15px; color: var(--amber); }
.mv-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.mv-stat .label { display: block; }
.mv-stat .value { font-family: var(--mono); font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mv-stat .grade-text { font-family: var(--ui); font-size: 13px; white-space: normal; color: var(--text); }
.mv-sum-row { display: grid; gap: 6px; }
.mv-tags { display: flex; flex-wrap: wrap; gap: 4px; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); } }
@media (max-width: 1100px) {
  .mv-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(260px, 55%) minmax(0, 1fr); }
  .mv-chart { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 700px) {
  .movie { width: 100vw; height: 100vh; max-width: 100vw; border-radius: 0; margin: 0; }
  .mv-head { flex-wrap: wrap; gap: 6px 12px; padding: 8px; }
  .mv-title { flex-basis: 100%; }
  .mv-transport { flex-wrap: wrap; padding: 8px; }
  .mv-scrub { flex-basis: 100%; order: 5; }
  .mv-play { min-width: 0; flex: 1 1 96px; white-space: nowrap; }
  .mv-time { display: none; }
  .mv-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Login page (dashboard.auth) ---- */
body.login-page { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; padding: 24px;
              background: var(--raised); border: 1px solid var(--line-2); border-radius: 6px; }
.login-card h1 { font-size: 16px; }
.login-card button { padding: 8px 12px; }
.login-name { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.login-name input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line-2);
                    border-radius: 4px; padding: 6px 8px; }

/* the controls block: state, the buttons that apply, recent actions, and the confirm dialog */
.control-state p { margin: 4px 0; }
.control-headline { font-weight: 600; }
.state-chip { display: inline-block; padding: 1px 8px; border-radius: 4px; border: 1px solid var(--line-2); }
.control-actions { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.control-action { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.control-action button { min-height: 44px; min-width: 9rem; }
.control-action p { margin: 0; flex: 1 1 14rem; }
.control-warning { color: var(--caution); font-weight: 600; }
.control-log { margin: 6px 0 0; padding-left: 1.2rem; font-size: 12px; color: var(--muted); max-height: 12rem; overflow: auto; }
.control-log-box summary { cursor: pointer; }
.control-dialog { width: min(32rem, calc(100vw - 32px)); padding: 16px; }
.control-dialog .row { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }
.control-dialog button { min-height: 44px; }
.control-positions { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
.control-positions th, .control-positions td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
