/* TradeFloor v2 "Survey". See DESIGN.md. Dark-first; light via [data-theme] or OS setting. */
:root {
  --ground: #070B14; --panel: rgba(13, 20, 36, .82); --panel-solid: #0D1424; --line: #1C2A44; --ink: #E6ECF7; --ink-2: #8E9BB5; --ink-3: #5D6A85;
  --gain: #5A8FD8; --loss: #D86F33; --warn: #D9A23A;
  --gain-wash: rgba(90, 143, 216, .16); --loss-wash: rgba(216, 111, 51, .16); --warn-wash: rgba(217, 162, 58, .16);
  --hover: rgba(230, 236, 247, .05); --scrim: rgba(7, 11, 20, .58);
  --display: "Bricolage Grotesque", "Hanken Grotesk", system-ui, sans-serif;
  --body: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --d1: 120ms; --d2: 200ms; --d3: 320ms;
  --out: cubic-bezier(0, 0, .4, 1); --inout: cubic-bezier(.45, 0, .4, 1);
  --r: 6px; --rail: 76px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ground: #EEF2F3; --panel: #F9FBFB; --line: #D3DCE0; --ink: #13212A; --ink-2: #4F6472; --ink-3: #7D909C;
    --gain: #2563A8; --loss: #C2561A; --warn: #A8730A;
    --gain-wash: rgba(37, 99, 168, .12); --loss-wash: rgba(194, 86, 26, .12); --warn-wash: rgba(168, 115, 10, .12);
    --hover: rgba(19, 33, 42, .04); --panel-solid: #F9FBFB; --scrim: transparent;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --panel-solid: #F9FBFB; --scrim: transparent;
  --ground: #EEF2F3; --panel: #F9FBFB; --line: #D3DCE0; --ink: #13212A; --ink-2: #4F6472; --ink-3: #7D909C;
  --gain: #2563A8; --loss: #C2561A; --warn: #A8730A;
  --gain-wash: rgba(37, 99, 168, .12); --loss-wash: rgba(194, 86, 26, .12); --warn-wash: rgba(168, 115, 10, .12);
  --hover: rgba(19, 33, 42, .04);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 400 14px/1.5 var(--body); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; }
h1 { font: 700 25px/1.1 var(--display); font-variation-settings: "wdth" 85; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 700; }
.display { font-family: var(--display); font-variation-settings: "wdth" 85; font-weight: 700; font-size: 25px; }
code { font-size: .9em; background: var(--hover); padding: 1px 5px; border-radius: 3px; }
:focus-visible { outline: 2px solid var(--gain); outline-offset: 2px; }
.sub { color: var(--ink-2); margin: 2px 0 0; max-width: 70ch; }
.pos { color: var(--gain); } .neg { color: var(--loss); } .muted { color: var(--ink-2); } .faint { color: var(--ink-3); }

/* ---------------------------------------------------------------- shell */
.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100%; }
.rail { position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: max(14px, env(safe-area-inset-top, 0px)) 0 14px max(0px, env(safe-area-inset-left, 0px)); background: var(--panel); border-right: 1px solid var(--line); z-index: 6; }
.mark { color: var(--ink); padding: 4px 0 14px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; width: 100%; padding: 0 8px; }
.nav button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 7px; width: 100%;
  font: 500 11px/1.1 var(--body); color: var(--ink-2); background: none; border: 0; border-radius: var(--r); cursor: pointer; }
.nav button svg { width: 20px; height: 20px; }
.nav button:hover { color: var(--ink); background: var(--hover); }
.nav button[aria-current="page"] { color: var(--ink); }
.nav button[aria-current="page"]::before { content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--ink); view-transition-name: nav-indicator; }
.nav .badge { position: absolute; top: 4px; right: 10px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--ink); color: var(--ground); font-size: 10px; font-weight: 700; line-height: 16px; }
.rail-btn { width: 40px; height: 40px; display: grid; place-items: center; background: none; border: 0; color: var(--ink-2); border-radius: var(--r); cursor: pointer; }
.rail-btn:hover { color: var(--ink); background: var(--hover); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
  padding: 14px max(24px, env(safe-area-inset-right, 0px)) 14px 24px; background: var(--ground); border-bottom: 1px solid var(--line); }
.title-block { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.conn[data-state="live"] i { background: var(--gain); animation: breathe 2.4s var(--inout) infinite; }
.conn[data-state="stale"] i, .conn[data-state="connecting"] i { background: var(--warn); }
.conn[data-state="down"] i { background: var(--loss); }
.conn[data-state="demo"] i { background: var(--warn); }
@keyframes breathe { 50% { opacity: .35; } }
.mode { font-size: 12px; color: var(--warn); white-space: nowrap; }
.vitals { display: flex; gap: 28px; margin: 0 0 0 auto; }
.vitals div { display: flex; flex-direction: column; min-width: 0; }
.vitals dt { font-size: 11.5px; color: var(--ink-2); }
.vitals dd { margin: 0; font-size: 17px; font-weight: 600; white-space: nowrap; }
.vitals .v-eq dd { font: 700 21px/1.25 var(--display); font-variation-settings: "wdth" 85; }
.actions { display: flex; gap: 8px; align-items: center; }

/* ---------------------------------------------------------------- controls */
.btn { position: relative; overflow: hidden; font: 600 13px/1 var(--body); cursor: pointer; border-radius: var(--r); padding: 9px 14px;
  border: 1px solid var(--ink); background: var(--ink); color: var(--ground); white-space: nowrap; transition: transform var(--d1) var(--out), opacity var(--d1); }
.btn:hover { opacity: .9; } .btn:active { transform: scale(.98); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink-2); opacity: 1; }
.btn.danger { background: transparent; color: var(--loss); border-color: var(--loss); }
.btn.danger.armed { background: var(--loss); color: #fff; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.auto { background: transparent; color: var(--ink-2); border-color: var(--line); display: inline-flex; gap: 7px; align-items: center; }
.btn.auto::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.btn.auto[aria-pressed="true"] { color: var(--gain); border-color: var(--gain); }
.btn.auto[aria-pressed="true"]::before { background: var(--gain); }
/* press-and-hold: a fill sweeps across the button while held */
.btn.hold .ring { position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--p, 0)); background: currentColor; opacity: .22; pointer-events: none; }
.btn.hold.holding .ring { transition: transform var(--hold-ms, 1200ms) linear; }
.btn.hold .lbl { position: relative; }
.link { font: 500 12.5px var(--body); color: var(--ink-2); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); }
.link:hover { color: var(--ink); text-decoration-color: var(--ink-2); }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; background: none; border: 1px solid transparent; color: var(--ink); border-radius: var(--r); cursor: pointer; }
.icon-btn:hover { border-color: var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { font: 500 12px var(--body); padding: 5px 10px; background: none; border: 0; color: var(--ink-2); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--ink-2); margin: 8px 0; cursor: pointer; }
input:not([type="checkbox"]) { font: 500 14px var(--body); color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; width: 100%; }
input:focus { border-color: var(--ink-2); outline: none; }
.switch { position: relative; width: 40px; height: 22px; flex: none; display: inline-block; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 11px; background: var(--line); transition: background var(--d2) var(--out); pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink); transition: transform var(--d2) var(--out); }
.switch input:checked + span { background: var(--gain); }
.switch input:checked + span::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--gain); outline-offset: 2px; }

.banner { padding: 10px 24px; background: var(--loss); color: #fff; font-weight: 600; }
.banner.warn { background: var(--warn); color: #1b1305; }

/* ---------------------------------------------------------------- views */
#views { padding: 20px max(24px, env(safe-area-inset-right, 0px)) 48px 24px; flex: 1; min-width: 0; }
.view { animation: viewIn var(--d3) var(--out); }
.view[hidden] { display: none !important; }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } }
.blk-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.blk-head.spaced { margin-top: 32px; }
.blk-head .sub { flex-basis: 100%; margin-top: -2px; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: var(--d2); }

/* overview */
.v-overview { display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "terrain side" "charts charts"; gap: 20px 28px; }
.terrain-wrap { grid-area: terrain; position: relative; height: clamp(380px, 58vh, 620px); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--ground); }
.terrain-wrap canvas { display: block; }
.terrain-overlay { position: absolute; left: 0; bottom: 0; padding: 18px 20px; pointer-events: none; z-index: 2; }
.ov-label { display: block; font-size: 12px; color: var(--ink-2); }
.ov-big { display: block; font: 800 44px/1.05 var(--display); font-variation-settings: "wdth" 80, "opsz" 96; letter-spacing: -.02em; }
.ov-sub { display: block; font-size: 13.5px; margin-top: 2px; }
.terrain-key { position: absolute; right: 14px; bottom: 12px; display: flex; gap: 14px; font-size: 11.5px; color: var(--ink-2); z-index: 2; pointer-events: none; }
.k { display: inline-block; width: 8px; height: 8px; margin-right: 5px; vertical-align: 0; border-radius: 1px; }
.k.ink { background: var(--ink); } .k.gain { background: var(--gain); } .k.loss { background: var(--loss); }
.terrain-tip { position: absolute; z-index: 3; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; font-size: 12.5px; min-width: 150px; transform: translate(12px, -50%); }
.terrain-tip b { font-size: 13.5px; }
.t-label { pointer-events: none; font: 600 11.5px var(--body); color: var(--ink); white-space: nowrap; text-shadow: 0 1px 2px var(--ground), 0 0 6px var(--ground); }
.t-label b { font-weight: 700; margin-right: 6px; }
.t-label small { font-weight: 500; color: var(--ink-2); margin-left: 6px; }
.t-label small.pos { color: var(--gain); } .t-label small.neg { color: var(--loss); }
.t-label.closed { color: var(--ink-3); }
.t-district { pointer-events: none; font: 700 13px var(--display); font-variation-settings: "wdth" 85; color: var(--ink-2); white-space: nowrap; text-shadow: 0 0 6px var(--ground); }
.t-beacon { pointer-events: auto; cursor: pointer; text-align: center; font: 600 11px var(--body); color: var(--ink); white-space: nowrap; text-shadow: 0 0 6px var(--ground), 0 1px 2px var(--ground); }
.t-beacon small { display: block; font-weight: 500; color: var(--ink-2); font-size: 10.5px; }
.t-beacon.paused { color: var(--warn); } .t-beacon.error, .t-beacon.stopped { color: var(--loss); }
.terrain-fallback { display: grid; place-items: center; height: 100%; padding: 24px; color: var(--ink-2); text-align: center; }

.ov-side { grid-area: side; display: flex; flex-direction: column; gap: 22px; min-width: 0; max-height: clamp(380px, 58vh, 620px); }
.side-block { min-height: 0; display: flex; flex-direction: column; }
.side-block:first-child { flex: 1; }
.ov-charts { grid-area: charts; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 28px; align-items: start; }

/* feed */
.feed { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; border-top: 1px solid var(--line); }
.feed li { display: grid; grid-template-columns: 54px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; line-height: 1.45; }
.feed.compact { flex: 1; }
.feed time { color: var(--ink-3); font-size: 11.5px; white-space: nowrap; padding-top: 1px; }
.feed .who { font-weight: 700; margin-right: 6px; }
.feed .tone-gain .who { color: var(--gain); } .feed .tone-loss .who { color: var(--loss); } .feed .tone-warn .who { color: var(--warn); }
.feed li.fresh { animation: slideIn var(--d3) var(--out); }
@keyframes slideIn { from { transform: translateY(-6px); background: var(--hover); } }
.empty { color: var(--ink-2); padding: 14px 0; font-size: 13px; }

/* mini positions */
.mini-pos { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.mini-pos:first-child { border-top: 1px solid var(--line); }
.mini-pos b { font-weight: 700; }
.mini-pos .bar { grid-column: 1 / -1; }

/* stop-to-target track */
.track { position: relative; height: 6px; background: var(--line); border-radius: 3px; min-width: 120px; }
.track .fill { position: absolute; top: 0; bottom: 0; border-radius: 3px; transition: left var(--d3) var(--out), width var(--d3) var(--out); }
.track .now { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--ink); transition: left var(--d3) var(--out); }
.track .entry { position: absolute; top: -2px; width: 1px; height: 10px; background: var(--ink-2); }

/* charts */
.chart { position: relative; height: 210px; }
.chart.small { height: 86px; margin-top: 6px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart .axis { fill: var(--ink-3); font: 500 10.5px var(--body); }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw 900ms var(--out) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.chart .area-dd { fill: var(--loss-wash); stroke: var(--loss); stroke-width: 1.25; }
.chart .base { stroke: var(--ink-3); stroke-dasharray: 3 3; }
.chart .hair { stroke: var(--ink-3); }
.chart .tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 9px; font-size: 12px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); z-index: 2; }
.chart .empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 0 20px; }

/* stats strip */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--line); }
.stat { padding: 12px 0 10px; border-bottom: 1px solid var(--line); }
.stat dt { font-size: 11.5px; color: var(--ink-2); }
.stat dd { margin: 2px 0 0; font-size: 18px; font-weight: 700; }
.stat dd small { font-size: 11.5px; font-weight: 500; color: var(--ink-3); margin-left: 4px; }
.stats-note { grid-column: 1 / -1; font-size: 12px; color: var(--ink-3); padding-top: 8px; }

/* tables */
.table-wrap { overflow-x: auto; }
.table-wrap.tall { max-height: 520px; overflow-y: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th { text-align: left; font-weight: 500; font-size: 11.5px; color: var(--ink-2); padding: 8px 14px 8px 0; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; background: var(--ground); z-index: 1; }
.grid td { padding: 0 14px 0 0; height: 40px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid tbody tr { transition: background var(--d1); }
.grid tbody tr:hover { background: var(--hover); }
.grid tbody tr[aria-selected="true"] { background: var(--hover); box-shadow: inset 2px 0 0 var(--ink); }
.grid .num { text-align: right; }
.grid .sym { font-weight: 700; }
.grid caption { text-align: left; color: var(--ink-2); padding: 16px 0; caption-side: bottom; }
.grid tr.clickable { cursor: pointer; }
.chg { display: inline-flex; align-items: center; gap: 3px; }
.chg svg { width: 9px; height: 9px; }
[data-flash] { transition: background 300ms var(--out); border-radius: 3px; }
[data-flash="up"] { background: var(--gain-wash); } [data-flash="down"] { background: var(--loss-wash); }
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px; border: 1px solid var(--line); color: var(--ink-2); }
.pill.held { border-color: var(--gain); color: var(--gain); }
.pill.closed { color: var(--ink-3); }

/* crypto / nasdaq views */
.v-market { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  grid-template-areas: "head head" "terrain detail" "pos pos" "table trades"; gap: 24px 32px; }
.mk-head { grid-area: head; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 28px; align-items: end; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.mk-head h2 { font: 700 31px/1.05 var(--display); font-variation-settings: "wdth" 82; }
.mk-head .venue { color: var(--ink-2); font-size: 13px; margin-top: 4px; }
.mk-head dl { display: flex; gap: 28px; margin: 0; flex-wrap: wrap; }
.mk-head dl div { display: flex; flex-direction: column; }
.mk-head dt { font-size: 11.5px; color: var(--ink-2); }
.mk-head dd { margin: 0; font-size: 19px; font-weight: 700; white-space: nowrap; }
.mk-head .acct-eq dd { font: 800 27px/1.1 var(--display); font-variation-settings: "wdth" 82; }
.mk-head .hours { font-size: 12.5px; margin: 0; color: var(--ink-2); display: flex; gap: 8px; align-items: center; }
.mk-head .hours i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.mk-head .hours.open i { background: var(--gain); }
.terrain-slot { grid-area: terrain; min-height: 380px; }
.terrain-slot .terrain-wrap { height: 100%; min-height: 380px; }
.mk-detail { grid-area: detail; min-width: 0; }
.mk-positions { grid-area: pos; min-width: 0; }
.mk-table { grid-area: table; min-width: 0; }
.mk-trades { grid-area: trades; min-width: 0; }
.head-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.mk-detail .big { font: 800 34px/1.1 var(--display); font-variation-settings: "wdth" 82; }
.candles { height: clamp(260px, 40vh, 440px); margin-top: 10px; }
.candles svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* positions view */
.v-positions .blk-head:first-child { margin-bottom: 4px; }

/* calendar */
.v-calendar { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav h2 { min-width: 9ch; text-align: center; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin-top: 8px; }
.cal .dow { font-size: 11.5px; color: var(--ink-3); padding: 0 0 4px 6px; }
.cal .day { position: relative; font: inherit; text-align: left; min-height: 92px; padding: 8px; border: 0; border-radius: 4px; background: var(--panel);
  color: var(--ink); cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; transition: box-shadow var(--d1); animation: cellIn var(--d3) var(--out) backwards; animation-delay: calc(var(--i) * 12ms); }
@keyframes cellIn { from { opacity: 0; transform: scale(.97); } }
.cal .day:hover { box-shadow: inset 0 0 0 1px var(--ink-3); }
.cal .day .d { font-size: 12px; color: var(--ink-2); }
.cal .day .p { font: 700 17px/1.1 var(--display); font-variation-settings: "wdth" 85; }
.cal .day .n { font-size: 11px; color: var(--ink-2); }
.cal .day.out { visibility: hidden; animation: none; }
.cal .day.today { box-shadow: inset 0 0 0 2px var(--ink); }
.cal .day[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--gain); }
.cal .day.ink-light .d, .cal .day.ink-light .n, .cal .day.ink-light .p { color: #fff; }
.cal-side { border-left: 1px solid var(--line); padding-left: 24px; }
.cal-side .big { font: 800 34px/1.1 var(--display); font-variation-settings: "wdth" 82; margin: 6px 0 4px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; margin-top: 14px; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; text-align: right; font-weight: 600; }
.day-trades { list-style: none; padding: 0; margin: 16px 0 0; border-top: 1px solid var(--line); }
.day-trades li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; }

/* agents view */
.v-agents { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.pipeline svg { width: 100%; height: auto; display: block; overflow: visible; }
.pipeline .edge { fill: none; stroke: var(--line); stroke-width: 1.5; }
.pipeline .edge.lit { stroke: var(--ink-2); stroke-dasharray: 5 6; animation: flow 900ms linear; }
.pipeline .edge.lit.gain { stroke: var(--gain); } .pipeline .edge.lit.loss { stroke: var(--loss); }
@keyframes flow { from { stroke-dashoffset: 44; } to { stroke-dashoffset: 0; } }
.pipeline .node rect { fill: var(--panel); stroke: var(--line); stroke-width: 1; transition: stroke var(--d2); }
.pipeline .node:hover rect, .pipeline .node.sel rect { stroke: var(--ink-2); }
.pipeline .node.pulse rect { animation: nodePulse 600ms var(--out); }
@keyframes nodePulse { 30% { stroke: var(--ink); } }
.pipeline .node text { fill: var(--ink); font: 700 13px var(--body); }
.pipeline .node .count { fill: var(--ink-2); font: 500 11.5px var(--body); }
.pipeline .node .act { fill: var(--ink-3); font: 500 10.5px var(--body); }
.pipeline .node .st { font: 600 10.5px var(--body); }
.pipeline .node { cursor: pointer; outline: none; }
.pipeline .node:focus-visible rect { stroke: var(--gain); stroke-width: 2; }
.pipeline .edge-label { fill: var(--ink-3); font: 500 10.5px var(--body); }
.agent-detail { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; min-height: 120px; }
.agent-detail .btns { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.feed-wrap { display: flex; flex-direction: column; min-width: 0; }
.feed-wrap .feed { max-height: calc(100vh - 230px); }

/* risk view */
.auto-hero { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 18px 24px; align-items: center; padding: 20px 0 22px; border-bottom: 1px solid var(--line); margin-bottom: 26px; }
.auto-hero h2 { font: 700 25px/1.1 var(--display); font-variation-settings: "wdth" 85; }
.auto-hero p { margin: 4px 0 0; color: var(--ink-2); max-width: 64ch; }
.auto-gauge { text-align: right; }
.auto-gauge .big { font: 800 40px/1 var(--display); font-variation-settings: "wdth" 80; }
.auto-gauge small { display: block; color: var(--ink-2); font-size: 12px; margin-top: 4px; }
.auto-why { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.auto-why span { font-size: 12px; color: var(--ink-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px 9px; }
.risk-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; }
.strat { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.strat:first-of-type { border-top: 1px solid var(--line); margin-top: 12px; }
.strat h3 { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.strat h3 small { font-weight: 500; font-size: 12px; color: var(--warn); }
.strat p { margin: 2px 0 8px; color: var(--ink-2); font-size: 13px; }
.strat .stats-row { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.strat .stats-row b { color: var(--ink); font-weight: 600; margin-left: 4px; }
.risk-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.risk-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); }
.risk-form label.row { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; }
.risk-form fieldset { display: contents; }
.risk-form fieldset:disabled input { opacity: .55; cursor: not-allowed; }
.risk-form .locked { grid-column: 1 / -1; font-size: 12.5px; color: var(--ink-2); margin: 0; }
.risk-form .full { grid-column: 1 / -1; }
.breakers { display: grid; gap: 14px; }
.breaker { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: 13px; }
.meter { grid-column: 1 / -1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.meter b { display: block; height: 100%; background: var(--ink-2); border-radius: 3px; transition: width var(--d3) var(--out); }
.meter.hot b { background: var(--loss); }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.inline-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); width: 200px; }

/* lab */
#btResult { margin-top: 24px; }
.bt-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; margin-top: 14px; }
.verdict { font-size: 16px; font-weight: 600; max-width: 70ch; margin: 0; padding-left: 12px; border-left: 3px solid var(--ink); }
.loading { color: var(--ink-2); display: flex; gap: 10px; align-items: center; }
.loading::before { content: ""; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* rolling digits */
.roll { display: inline-block; height: 1.15em; overflow: hidden; vertical-align: top; position: relative; }
.roll .strip { display: flex; flex-direction: column; transition: transform 240ms var(--out); }
.roll .strip span { height: 1.15em; line-height: 1.15em; text-align: center; }

/* toast, dialogs */
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--ground); padding: 10px 16px; font-size: 13.5px; font-weight: 500; border-radius: var(--r); z-index: 30; max-width: calc(100% - 32px); animation: toastIn var(--d3) var(--out); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }
dialog { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 26px; max-width: 440px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(5, 10, 14, .6); }
dialog form { display: grid; gap: 12px; }
.palette { padding: 0; max-width: 560px; margin-top: 12vh; }
.palette input { border: 0; border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; padding: 16px 18px; font-size: 16px; background: transparent; }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-radius: var(--r); cursor: pointer; font-size: 14px; }
.palette li small { color: var(--ink-3); }
.palette li[aria-selected="true"] { background: var(--hover); box-shadow: inset 2px 0 0 var(--ink); }
.palette-hint { margin: 0; padding: 8px 18px 12px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--line); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1280px) {
  .vitals { gap: 20px; }
  .v-nas { display: none !important; }
}
@media (max-width: 1100px) {
  .v-overview { grid-template-columns: minmax(0, 1fr); grid-template-areas: "terrain" "side" "charts"; }
  .ov-side { max-height: none; }
  .side-block:first-child .feed { max-height: 300px; }
  .ov-charts, .v-market, .v-agents, .risk-cols, .bt-grid { grid-template-columns: minmax(0, 1fr); }
  .v-market { grid-template-areas: "head" "terrain" "detail" "pos" "table" "trades"; }
  .mk-head { grid-template-columns: minmax(0, 1fr); }
  .v-calendar { grid-template-columns: minmax(0, 1fr); }
  .cal-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 16px; }
  .vitals { margin-left: 0; order: 3; flex-basis: 100%; }
}
@media (max-width: 760px) {
  :root { --rail: 0px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 4px max(8px, env(safe-area-inset-right, 0px)) max(4px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
    border-right: 0; border-top: 1px solid var(--line); overflow-x: auto; }
  .mark, #paletteBtn { display: none; }
  .nav { flex-direction: row; padding: 0; gap: 0; }
  .nav button { min-width: 56px; padding: 7px 4px 6px; }
  .nav button[aria-current="page"]::before { left: 10px; right: 10px; top: -4px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .top { padding: max(10px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); gap: 10px; position: static; }
  .title-block { flex-basis: 100%; }
  .vitals { gap: 16px; flex-wrap: wrap; }
  .vitals dd { font-size: 15px; }
  .actions { flex-wrap: wrap; }
  .actions .btn { padding: 8px 10px; font-size: 12.5px; }
  #views { padding: 16px max(16px, env(safe-area-inset-right, 0px)) 96px max(16px, env(safe-area-inset-left, 0px)); }
  .terrain-wrap { height: 340px; }
  .ov-big { font-size: 34px; }
  .terrain-key { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal .day { min-height: 58px; padding: 5px; }
  .cal .day .p { font-size: 12px; }
  .cal .day .n { display: none; }
  .risk-form { grid-template-columns: 1fr; }
  .auto-hero { grid-template-columns: auto minmax(0, 1fr); }
  .auto-gauge { grid-column: 1 / -1; text-align: left; }
  .auto-why { grid-column: 1 / -1; }
  .inline-form label { width: 100%; }
  .feed-wrap .feed { max-height: 420px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* backing plates so overlay text never fights the terrain behind it */
.ov-money { background: color-mix(in srgb, var(--ground) 84%, transparent); padding: 10px 14px 12px; border-radius: var(--r); }
.terrain-key { background: color-mix(in srgb, var(--ground) 84%, transparent); padding: 5px 9px; border-radius: var(--r); }
@media (max-width: 640px) {
  .t-beacon, .t-label small { display: none; }
  .t-label { font-size: 10px; }
  .t-district { font-size: 11px; }
  .terrain-overlay { padding: 10px; }
}

/* real-data-only states */
.terrain-empty { position: absolute; inset: 0; display: grid; place-items: center; z-index: 2; pointer-events: none; padding: 24px; }
.terrain-empty p { max-width: 42ch; text-align: center; color: var(--ink-2); background: color-mix(in srgb, var(--ground) 88%, transparent); padding: 14px 18px; border-radius: var(--r); }
.terrain-empty b { color: var(--ink); display: block; margin-bottom: 4px; }
.offline { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: var(--ground); padding: 24px; }
.offline > div { max-width: 520px; display: grid; gap: 10px; }
.setup { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.setup:first-child { border-top: 1px solid var(--line); }
.setup .why { grid-column: 1 / -1; color: var(--ink-2); font-size: 12px; }
.pill.approved { border-color: var(--gain); color: var(--gain); }
.pill.waiting { border-color: var(--warn); color: var(--warn); }
.side-block:first-child { flex: 1 1 auto; }
.side-block .feed.compact { max-height: 260px; }

[hidden] { display: none !important; }

/* robot crew */
/* the fleet: always a window into space, whatever the dashboard theme */
.crew { position: relative; height: clamp(440px, 66vh, 700px); border: 1px solid #1a2440; border-radius: 10px; overflow: hidden;
  background: radial-gradient(120% 90% at 30% 20%, #0c1430 0%, #03060d 60%); box-shadow: inset 0 0 0 1px rgba(120,150,255,.06), 0 18px 50px -20px rgba(20,30,80,.6); }
.crew canvas { display: block; }
.crew::after { content: "Drag to look around · scroll to zoom · click a ship"; position: absolute; left: 14px; bottom: 12px; font: 500 11px var(--body);
  color: rgba(190,205,240,.55); letter-spacing: .02em; pointer-events: none; }
.crew-tag { text-align: center; white-space: nowrap; pointer-events: none; text-shadow: 0 1px 8px rgba(0,0,0,.9), 0 0 2px #000; }
.crew-tag b { display: block; font: 700 12.5px var(--body); color: #eef3ff; letter-spacing: .01em; }
.crew-tag i { display: block; font: 600 9.5px var(--body); font-style: normal; letter-spacing: .14em; text-transform: uppercase; color: var(--accent, #9fb4ff); opacity: .9; }
.crew-tag small { display: block; font: 500 10.5px var(--body); color: #9fb0cf; max-width: 170px; overflow: hidden; text-overflow: ellipsis; margin: 1px auto 0; }
.crew-tag.off small { color: #ffc857; }
.crew-tag.sel b { color: var(--accent, #fff); text-shadow: 0 0 12px var(--accent, #fff), 0 1px 6px #000; }
.crew-bubble { max-width: 240px; background: rgba(10, 16, 34, .82); color: #e8eeff; border: 1px solid rgba(140,170,255,.22); border-left: 3px solid var(--accent, #9fb4ff);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border-radius: 8px; padding: 7px 10px; font: 500 12px/1.4 var(--body);
  box-shadow: 0 8px 26px rgba(0,0,0,.5), 0 0 18px -6px var(--accent, transparent); pointer-events: none; animation: bubbleIn 220ms var(--out); white-space: normal; }
.crew-bubble.gain { border-left-color: #5a8fd8; } .crew-bubble.loss { border-left-color: #e0743a; } .crew-bubble.warn { border-left-color: #ffc857; }
@media (prefers-reduced-motion: reduce) { .crew-bubble { animation: none; } }
@keyframes bubbleIn { from { opacity: 0; } }  /* opacity only: CSS2D owns the transform */

/* review */
.review { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 32px; margin-top: 8px; }
.rv-market h2 { font: 700 25px/1.1 var(--display); font-variation-settings: "wdth" 85; }
.rv-head { font-size: 15px; margin: 6px 0 4px; max-width: 64ch; }
.rv-kpis { display: flex; flex-wrap: wrap; gap: 22px; margin: 14px 0 18px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.rv-kpis div { display: flex; flex-direction: column; } .rv-kpis dt { font-size: 11.5px; color: var(--ink-2); } .rv-kpis dd { margin: 0; font-size: 18px; font-weight: 700; }
.rv-list { margin: 6px 0 18px; padding: 0; list-style: none; display: grid; gap: 8px; }
.rv-list li { padding-left: 14px; border-left: 3px solid var(--line); font-size: 13.5px; max-width: 70ch; }
.rv-list.wrong li { border-left-color: var(--loss); } .rv-list.right li { border-left-color: var(--gain); } .rv-list.change li { border-left-color: var(--warn); }
.rv-sub { margin: 18px 0 6px; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.mk-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.strat .mkt-toggles { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; }
.strat .mkt-toggles label { display: inline-flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.strat .mkt-toggles .switch { width: 34px; height: 19px; } .strat .mkt-toggles .switch span::after { width: 13px; height: 13px; }
.strat .mkt-toggles .switch input:checked + span::after { transform: translateX(15px); }
.strat .mkt-toggles .auto { color: var(--warn); }

.mk-head #mkHours { grid-column: 1; }
.mk-head .mk-actions { grid-column: 2; justify-self: end; }
@media (max-width: 1100px) { .mk-head .mk-actions { grid-column: 1; justify-self: start; } }
.v-review > .sub { margin: -4px 0 6px; }

.feed li.empty { display: block; grid-template-columns: none; }

/* Inspector: health check panel (Agents) and problem banner (Overview) */
.health { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.health .blk-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hlist { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.hf { border: 1px solid var(--line); border-left: 3px solid var(--ink-3); border-radius: var(--r); padding: 10px 12px; background: var(--panel); }
.hf.error { border-left-color: var(--loss); background: linear-gradient(90deg, var(--loss-wash), transparent 60%), var(--panel); }
.hf.warn { border-left-color: var(--warn); }
.hf.ok { border-left-color: var(--gain); padding: 7px 12px; color: var(--ink-2); }
.hf-top { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.hf-lvl { font: 700 10.5px var(--body); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); }
.hf.error .hf-lvl { color: var(--loss); } .hf.warn .hf-lvl { color: var(--warn); } .hf.ok .hf-lvl { color: var(--gain); }
.hf p { margin: 6px 0 0; color: var(--ink-2); font-size: 13.5px; }
.hf details { margin-top: 6px; font-size: 12.5px; } .hf summary { cursor: pointer; color: var(--ink-3); }
.hf details p { overflow-wrap: anywhere; }
.hf-clear { display: flex; align-items: center; gap: 10px; margin: 10px 0 0; color: var(--ink-2); }
.hf-clear .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gain); box-shadow: 0 0 0 4px var(--gain-wash); flex: none; }
.hf-meta { margin-top: 10px; font-size: 12.5px; }
.health-banner { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 2px; width: 100%; padding: 10px 14px; margin-bottom: 14px;
  border: 1px solid var(--loss); border-radius: var(--r); background: var(--loss-wash); color: var(--ink); font: 500 13.5px/1.4 var(--body); }
.health-banner b { color: var(--loss); } .health-banner .go { color: var(--ink-2); font-size: 12.5px; }
.health-banner:hover { background: color-mix(in srgb, var(--loss-wash), var(--loss) 8%); }
.health-banner:focus-visible { outline: 2px solid var(--gain); outline-offset: 2px; }

/* Signal Desk panel (Agents) */
.sigdesk { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.sigdesk .blk-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sd-setup { display: grid; gap: 6px; margin: 12px 0 4px; }
.sd-setup label { font: 600 12.5px var(--body); color: var(--ink); margin-top: 6px; }
.sd-copy { display: flex; gap: 8px; align-items: stretch; min-width: 0; }
.sd-copy code { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 500 12px/1.45 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; user-select: all; }
.sd-h { font: 700 13px var(--body); margin: 16px 0 6px; }
.sd-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sd-table th { text-align: left; font: 600 11px var(--body); color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
.sd-table td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.sd-tag { font: 600 11px var(--body); color: var(--gain); } .sd-tag.off { color: var(--warn); }
.sd-recent { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.sd-recent li { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
@media (max-width: 640px) { .sd-table th:nth-child(5), .sd-table td:nth-child(5) { display: none; } }

/* Robinhood (read-only mirror) */
.rh-intro { max-width: 760px; margin: 0 0 16px; }
.rh-card { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 18px 20px; max-width: 820px; }
.rh-card h2 { margin: 0 0 10px; font-size: 17px; }
.rh-steps { margin: 0 0 10px; padding-left: 20px; display: grid; gap: 10px; color: var(--ink); }
.rh-steps code { font: 500 12px/1.5 ui-monospace, Menlo, Consolas, monospace; background: var(--ground); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; overflow-wrap: anywhere; }
.rh-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.rh-stats > div { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 12px 14px; display: grid; gap: 2px; }
.rh-stats b { font: 800 24px/1.15 var(--display); font-variant-numeric: tabular-nums; }
.rh-stats small { font-size: 12px; }
.rh-cols { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.rh-ready ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.rh-ready li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: baseline; font-size: 13.5px; }
.rh-ready .tick { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font: 700 11px var(--body); color: var(--ground); }
.rh-ready li.ok .tick { background: var(--gain); border-color: var(--gain); }
@media (max-width: 860px) { .rh-cols { grid-template-columns: minmax(0, 1fr); } .rh-stats { grid-template-columns: minmax(0, 1fr); } }
.rh-why { margin: 0 0 14px; padding: 10px 12px; border-left: 3px solid var(--warn); background: var(--warn-wash); border-radius: 4px; }

/* Robinhood live control */
.rh-live-ctl { margin: 0 0 18px; }
.rh-ctl-row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.btn.rh-start { --rh: #00c805; background: var(--rh); border-color: var(--rh); color: #04210a; font-weight: 800; padding: 12px 20px; font-size: 15px; letter-spacing: .01em; }
.btn.rh-start:hover:not(:disabled) { background: #00b004; border-color: #00b004; }
.btn.rh-start .ring { background: #04210a; opacity: .18; }
.btn.rh-start:disabled { background: var(--line); border-color: var(--line); color: var(--ink-2); cursor: default; }
.rh-budget { display: inline-flex; align-items: center; gap: 6px; font: 600 13px var(--body); color: var(--ink-2); }
.rh-budget input { width: 92px; font: 600 14px var(--body); color: var(--ink); background: var(--ground); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; }
.rh-ctl-txt { flex: 1 1 320px; font-size: 13.5px; color: var(--ink-2); min-width: 0; }
.rh-ctl-txt b { color: var(--ink); }
.rh-ctl-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.warn-txt { color: var(--warn); }
.rh-live { margin-bottom: 22px; }
.rh-pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 14px; }
.rh-pos { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 12px 14px; min-width: 0; }
.rh-pos header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rh-pos header b { font: 800 18px var(--display); }
.rh-pnl { font: 800 18px var(--display); font-variant-numeric: tabular-nums; }
.rh-pos-sub { margin: 4px 0 8px; font-size: 12.5px; }
.rh-candles { height: 210px; }
.rh-hist { margin-top: 14px; }

/* following trades in real time (Robinhood page) */
.rh-chart { height: 150px; margin-top: 8px; }
.rh-pos header { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rh-pos header b { font: 800 17px var(--display); }
.rh-pos .rh-pnl { margin-left: auto; font: 800 17px var(--display); font-variant-numeric: tabular-nums; }
.rh-kind { font: 700 10px var(--body); letter-spacing: .08em; padding: 3px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }
.rh-kind.live { background: #00c805; border-color: #00c805; color: #04210a; }
.rh-pos.live { border-color: color-mix(in srgb, #00c805 45%, var(--line)); }
.live-dot { animation: liveDot 1.6s ease-in-out infinite; }
@keyframes liveDot { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* Robinhood agentic (MCP) stock account */
.rhs { max-width: none; margin-bottom: 20px; }
.rhs h2 .pos { font-size: 13px; margin-left: 6px; }
.rhs-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.rhs-input { flex: 1 1 360px; min-width: 0; font: 500 13px ui-monospace, Menlo, Consolas, monospace; color: var(--ink); background: var(--ground); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.rhs-read { border: 1px solid var(--line); border-radius: var(--r); padding: 8px 12px; margin-top: 8px; background: var(--ground); }
.rhs-read summary { cursor: pointer; }
.rhs-read pre { margin: 8px 0 0; max-height: 280px; overflow: auto; font: 500 12px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.rhs-tools { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; font-size: 12.5px; }
.rhs-tools li { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.rhs-tag { font: 700 10px var(--body); letter-spacing: .06em; text-transform: uppercase; color: var(--gain); }
.rhs-tag.w { color: var(--warn); }
.rh-sec { font: 800 18px var(--display); margin: 26px 0 12px; }

/* ---- v3 "Mission Control": the shared space backdrop and viewport panels (DESIGN.md) ---- */
.backdrop { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 0; pointer-events: none; image-rendering: auto; }
.backdrop[hidden] { display: none !important; }
.app { position: relative; z-index: 1; }
.main { background: var(--scrim); }
.top { background: color-mix(in srgb, var(--ground) 72%, transparent); -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2); }
.rail { background: color-mix(in srgb, var(--panel-solid) 78%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
input, select, textarea { background-color: var(--panel-solid); }
.view.enter > * { animation: viewRise 340ms var(--out) both; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes viewRise { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .view.enter > * { animation: none; } }
/* ship icons: each agent speaks as its own ship */
.ship-ico { display: none; }
.has-ships .ship-ico { display: inline-block; width: 26px; height: 26px; margin: -6px 6px -8px -3px; vertical-align: middle; background-position: center; background-size: contain; background-repeat: no-repeat; flex: none; }
.has-ships .ship-ico.ico-you { display: none; }
.has-ships .feed .who[class*="who-"] { color: var(--who, inherit); }
:root[data-theme="light"] .has-ships .feed .who[class*="who-"], :root[data-theme="light"].has-ships .feed .who[class*="who-"] { filter: brightness(.62) saturate(1.3); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]).has-ships .feed .who[class*="who-"] { filter: brightness(.62) saturate(1.3); } }
.feed .tone-gain .who, .feed .tone-loss .who, .feed .tone-warn .who { color: inherit; }
.feed .tone-gain { --tone: var(--gain); } .feed .tone-loss { --tone: var(--loss); } .feed .tone-warn { --tone: var(--warn); }
.feed li > div[class*="tone-"] { box-shadow: inset 2px 0 0 var(--tone, transparent); padding-left: 8px; }
.terrain-wrap { background: var(--terrain-bg, var(--ground)); }
:root { --terrain-bg: rgba(7, 11, 20, .32); }
:root[data-theme="light"] { --terrain-bg: var(--ground); }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --terrain-bg: var(--ground); } }
.has-ships .ship-ico.big { width: 44px; height: 44px; margin: -10px 10px -12px -4px; }
.ad-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.has-ships .ad-name { color: var(--who, inherit); }
.candles { position: relative; }
.candles .lwc { position: absolute; inset: 0; }
.candles .lwc a[href*="tradingview"] { opacity: .55; }

/* Live: follow the positions (Robinhood-Legend-style workspace) */
.live-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.live-list, .live-main, .live-side { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.live-list ol, .live-side ol { list-style: none; margin: 10px 0 0; padding: 0; }
.live-list li + li { margin-top: 6px; }
.live-item { all: unset; box-sizing: border-box; display: grid; gap: 3px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.live-item:hover { background: var(--hover); }
.live-item[aria-pressed="true"] { border-color: var(--ink-2); background: var(--hover); }
.live-item.real { border-left: 3px solid #00c805; }
.live-item:focus-visible { outline: 2px solid var(--gain); outline-offset: 2px; }
.li-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.li-pnl { font-weight: 700; font-variant-numeric: tabular-nums; }
.li-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; color: var(--ink-2); flex-wrap: wrap; }
.live-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.live-sym { font: 800 26px/1.1 var(--display); font-variation-settings: "wdth" 85; }
.live-nums { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.live-nums b { display: block; font: 700 18px var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-nums small { font-size: 12px; font-weight: 600; }
.live-chart { position: relative; height: clamp(320px, 56vh, 620px); margin-top: 14px; }
.live-chart .lwc { position: absolute; inset: 0; }
.live-note { margin: 10px 0 0; font-size: 12px; }
.live-side .feed { max-height: calc(100vh - 220px); overflow: auto; }
@media (max-width: 1180px) { .live-grid { grid-template-columns: 220px minmax(0, 1fr); } .live-side { grid-column: 1 / -1; } }
@media (max-width: 760px) { .live-grid { grid-template-columns: minmax(0, 1fr); } .live-nums { grid-template-columns: repeat(2, minmax(0, 1fr)); } .live-list ol { display: flex; gap: 8px; overflow-x: auto; } .live-list li + li { margin-top: 0; } .live-item { min-width: 170px; } }

/* notification bell */
.btn.icon-only { padding: 7px 9px; display: inline-grid; place-items: center; }
.btn.icon-only[aria-pressed="true"] { color: var(--gain); border-color: var(--gain); }

/* goal tracker (Overview) */
.goal { padding: 0 0 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line); }
.ov-right { min-width: 0; display: grid; gap: 6px; align-content: start; }
.goal .blk-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.goal-row { display: flex; gap: 22px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.goal-ring { --p: 0; width: 78px; height: 78px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: radial-gradient(closest-side, var(--panel-solid) 76%, transparent 77%), conic-gradient(var(--gain) calc(var(--p) * 360deg), var(--line) 0); }
.goal-ring b { font: 800 17px var(--display); }
.goal-kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 28px; margin: 0; flex: 1 1 380px; min-width: 0; }
.goal-kv dt { font-size: 11.5px; color: var(--ink-2); }
.goal-kv dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.goal-edit { font: inherit; font-weight: 700; color: var(--ink); text-decoration: underline dotted; text-underline-offset: 3px; }
.goal-note { margin: 10px 0 0; font-size: 12.5px; }
@media (max-width: 640px) { .goal-kv { grid-template-columns: minmax(0, 1fr); } }

/* trade journal (Positions page) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.jr-study { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 22px; align-items: center; padding: 12px 14px; margin: 4px 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.jr-study dl { display: flex; gap: 20px; margin: 0; }
.jr-study dt { font-size: 11.5px; color: var(--ink-3); }
.jr-study dd { margin: 2px 0 0; font: 800 20px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.jr-study p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.jr-study p b { font-weight: 700; }
@media (max-width: 900px) { .jr-study { grid-template-columns: 1fr; } }
.jr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: 12px; }
.jr-card { position: relative; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 11px 13px 10px; min-width: 0;
  display: flex; flex-direction: column; gap: 5px; }
.jr-card::before { content: ""; position: absolute; left: -1px; top: 12px; bottom: 12px; width: 2px; border-radius: 2px; background: var(--loss); }
.jr-card.win::before { background: var(--gain); }
.jr-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.jr-id { display: flex; flex-direction: column; min-width: 0; }
.jr-id b { font: 800 17px/1.15 var(--display); font-variation-settings: "wdth" 85; }
.jr-id span { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.jr-pnl { font: 800 17px/1.15 var(--display); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.jr-pnl small { display: block; font: 600 11.5px var(--body); color: var(--ink-2); }
.jr-chart { display: block; width: 100%; height: auto; aspect-ratio: 320 / 96; }
.jr-nochart { display: grid; place-items: center; aspect-ratio: 320 / 96; font-size: 12px; color: var(--ink-3); border: 1px dashed var(--line); border-radius: 8px; padding: 0 12px; text-align: center; }
.jr-line { margin: 0; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.jr-note { margin: 0; font-size: 13px; color: var(--ink); }
.jr-why { margin: 0; font-size: 12px; color: var(--ink-3); }
.jr-card time { font-size: 11px; }
.jr-more { display: flex; justify-content: center; margin-top: 14px; }
#tradeSub { margin: -4px 0 10px; }

/* Robinhood real-money section of the daily review */
.rv-rh { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 22px; }
.rv-rh .rv-list, .rv-rh .rv-head { max-width: 860px; }
.rv-rh h2 { display: flex; align-items: center; gap: 10px; }
.rv-rh h2 small { font: 500 13px var(--body); }
.rh-dot { width: 10px; height: 10px; border-radius: 50%; background: #00c805; flex: none; }

/* alerts panel under the bell */
.bell-wrap { position: relative; display: inline-flex; }
.pop { position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: min(380px, calc(100vw - 24px)); max-height: calc(100vh - 90px); overflow: auto;
  background: var(--panel-solid); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 12px; box-shadow: 0 18px 48px rgba(0, 0, 0, .45);
  text-align: left; color: var(--ink); font-size: 13px; }
.pop h3 { margin: 0 0 6px; font: 700 15px var(--display); }
.al-row { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.al-row:first-of-type { border-top: 0; }
.al-row p { margin: 2px 0 0; color: var(--ink-2); font-size: 12.5px; line-height: 1.4; }
.al-row a { color: var(--gain); }
.al-steps { margin: 4px 0 10px; padding-left: 20px; color: var(--ink-2); line-height: 1.5; }
.al-steps b { color: var(--ink); }
.al-topic { display: flex; gap: 8px; align-items: center; margin: 4px 0 2px; }
.al-topic code { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 600 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--ink);
  background: var(--hover); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; user-select: all; }
.al-kinds { border: 0; margin: 0 0 10px; padding: 0; display: grid; gap: 5px; }
.al-kinds legend { font-weight: 600; margin-bottom: 4px; padding: 0; }
.al-kinds label { display: flex; gap: 8px; align-items: center; color: var(--ink-2); }
.al-btns { display: flex; gap: 8px; }
.al-status { margin: 10px 0 0; font-size: 11.5px; line-height: 1.4; }
@media (max-width: 700px) { .pop { position: fixed; top: 64px; right: 12px; left: 12px; width: auto; } }
.goal-pace > span { display: block; white-space: nowrap; }
/* overview side column: activity and Up next share the height and scroll inside; positions keep their size */
.ov-side > .side-block { flex: none; }
.ov-side > .side-block:has(#ovFeed) { flex: 1 1 140px; }
.ov-side > .side-block:has(#ovSetups) { flex: 0 1 auto; min-height: 120px; }
#ovSetups { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.jr-timing { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 12px 14px; margin: -4px 0 14px; }
.jt-head h3 { margin: 0; font: 700 14px var(--display); }
.jt-head p { margin: 2px 0 10px; font-size: 12.5px; color: var(--ink-2); }
.jt-bars { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.jt-col { flex: 1 0 44px; max-width: 72px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }
.jt-bar { position: relative; width: 100%; height: 56px; }
.jt-bar span { position: absolute; left: 22%; right: 22%; border-radius: 3px 3px 0 0; }
.jt-bar span.up { bottom: 50%; height: calc(var(--h) / 2); background: var(--gain); }
.jt-bar span.down { top: 50%; height: calc(var(--h) / 2); background: var(--loss); border-radius: 0 0 3px 3px; }
.jt-bar::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed var(--line); }
.jt-col b { font-size: 11.5px; } .jt-col small { font-size: 10.5px; color: var(--ink-3); }
.marks .mark { stroke: var(--ground); stroke-width: 1.5; }
.marks .mark.win { fill: var(--gain); } .marks .mark.loss { fill: var(--loss); }
/* fleet bubbles: never squeezed into a thin column, at most 3 lines; smaller on phones */
.crew-bubble { width: max-content; max-width: min(240px, 58vw); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.crew-bubble[hidden] { display: none; }
@media (max-width: 640px) { .crew-bubble { font-size: 11px; padding: 5px 8px; max-width: min(190px, 52vw); } .crew-tag small { display: none; } }
