:root {
  --bg:#0e1116; --panel:#161b22; --panel2:#1f2630; --line:#262d36; --text:#e6edf3; --muted:#8b949e;
  --up:#a374ff; --down:#7cc4ff; --accent:#4c8dff;
  /* conventional red/green, darker: PnL, sides */
  --pos:#3fa556; --neg:#e5534b; --long:#238636; --short:#b62324;
  /* the warning amber (the leverage warning, a stop too close, …) as a token */
  --warn:#f2cc60;
  /* wide screens: the left column's share of the panel under the chart (50% → 40/60 is this one value) */
  --bottom-split:50%;
}
* { box-sizing:border-box; }
html, body { height:100%; margin:0; background:var(--bg); color:var(--text);
  font:14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior:none; }
body { display:flex; flex-direction:column; height:100dvh; overflow:hidden;
  padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  -webkit-user-select:none; user-select:none; -webkit-tap-highlight-color:transparent; }
button, select, input { font:inherit; color:inherit; }
button { cursor:pointer; }
.num { font-variant-numeric:tabular-nums; }
.muted { color:var(--muted); }
.pos { color:var(--pos); } .neg { color:var(--neg); }
[hidden] { display:none !important; }

/* ---- top bar */
header#top { position:relative; padding:6px 10px 4px; border-bottom:1px solid var(--line); z-index:20; }
header .row { display:flex; align-items:center; gap:8px; min-width:0; }
header .row.sub { position:relative; gap:12px; font-size:12px; color:var(--muted); margin-top:2px; white-space:nowrap; overflow:hidden; min-height:20px; }
header .row.sub b { color:var(--text); font-weight:500; }
header .row.sub b.neg { color:var(--neg); } header .row.sub b.pos { color:var(--pos); }
#account-line, #round-line { display:flex; align-items:center; gap:12px; min-width:0; }
#round-line { gap:10px; margin-left:auto; }
#round-line .who b { font-weight:600; }
#round-line small { font-size:11px; }
.textbtn { border:0; background:none; padding:0; color:var(--text); font-weight:500; font-size:12px; }
.narrow-only { display:none; }
@media (min-width:561px) { .menu .narrow-item { display:none; } }
#round-chip.on { background:#122a4a; border-color:var(--accent); color:#cfe0ff; font-variant-numeric:tabular-nums; }
#review-btn[aria-pressed="true"] { background:var(--accent); border-color:var(--accent); color:#fff; }

/* ---- toasts: a stack at the top right of the chart, just under the top bar, newest on top.
   Over the sheets (a refusal there stays readable), under the open ⋯ menu. */
.toasts { position:absolute; top:6px; right:8px; z-index:42; display:flex; flex-direction:column; align-items:flex-end; gap:6px;
  width:min(340px, calc(100% - 16px)); pointer-events:none; }
.toast { display:flex; gap:7px; align-items:baseline; max-width:100%; padding:7px 10px; border:1px solid var(--line); border-radius:9px;
  background:var(--panel2); color:var(--text); font-size:13px; line-height:1.3; white-space:normal; overflow-wrap:anywhere;
  box-shadow:0 6px 18px rgba(0,0,0,.45); pointer-events:auto; cursor:pointer; }
.toast::before { content:""; flex:none; width:7px; height:7px; border-radius:50%; background:var(--accent); transform:translateY(-1px); }
.toast.err { border-color:rgba(229,83,75,.55); color:#ff9b94; } .toast.err::before { background:var(--neg); }
.toast.sticky { cursor:default; border-color:#d29922; background:#3a2a10; color:#f2cc60; }
.toast.sticky::before { background:#d29922; }
header#top:has(#menu:not([hidden])) { z-index:46; }

/* ---- compact menu (phone) */
.menu { position:absolute; right:8px; top:calc(100% - 2px); z-index:45; min-width:200px; background:var(--panel2);
  border:1px solid var(--line); border-radius:10px; padding:4px; box-shadow:0 8px 24px rgba(0,0,0,.45); }
.menu button { display:flex; justify-content:space-between; gap:12px; width:100%; text-align:left; background:none; border:0;
  border-radius:7px; padding:10px 12px; font-size:14px; }
.menu button:hover, .menu button:focus-visible { background:var(--panel); }
.spacer { flex:1; }
.symbol { position:relative; display:flex; align-items:center; gap:4px; font-weight:600; font-size:15px; min-height:36px; }
.symbol select, .size select { position:absolute; inset:0; opacity:0; width:100%; height:100%; cursor:pointer; }
.caret { color:var(--muted); font-size:11px; }
.quote { font-weight:500; color:var(--muted); margin-left:-4px; }
/* the exchange switcher: "WEEX ▾"; a borrowed-prices profile reads "Phoenix · WEEX prices ▾", on narrower screens "Phoenix* ▾" */
.exchip { display:flex; align-items:center; gap:3px; flex:none; min-height:34px; padding:0 8px; border:1px solid var(--line);
  background:var(--panel); border-radius:8px; font-size:13px; white-space:nowrap; }
.exchip b { font-weight:600; }
.exchip .caret { margin-left:2px; }
.ex-src { color:var(--muted); font-weight:400; font-size:12px; }
.ex-mark { color:#f2cc60; font-weight:700; margin-left:-1px; }
@media (max-width:899px) { .ex-src { display:none; } }
@media (min-width:900px) { .ex-mark { display:none; } }
#price { font-size:18px; font-weight:600; }
.live { width:7px; height:7px; border-radius:50%; background:var(--muted); flex:none; }
.live.on { background:var(--pos); }
.chip { border:1px solid var(--line); background:var(--panel); border-radius:8px; min-height:34px; padding:0 10px; font-size:13px; white-space:nowrap; }
.chip.icon { width:34px; padding:0; color:var(--muted); }
.chip.primary { background:var(--accent); border-color:var(--accent); color:#fff; }
.chip.small { min-height:26px; font-size:11px; padding:0 8px; }
.chip[aria-pressed="true"] { background:#3a2a10; border-color:#d29922; color:#f2cc60; }

/* ---- chart */
#chart-wrap { flex:1; min-height:0; position:relative; }
#chart { position:absolute; inset:0; width:100%; height:100%; display:block; touch-action:none; }

/* ---- quick reasons: a quiet chip row over the bottom of the chart (the oscillator pane), so
   nothing moves when it slides in; only the chips take taps, the chart around them stays live */
.reasons { position:absolute; left:0; right:0; bottom:0; z-index:6; display:flex; flex-direction:column; gap:6px;
  padding:14px 8px 6px; pointer-events:none;
  background:linear-gradient(to top, rgba(14,17,22,.94), rgba(14,17,22,.86) 62%, rgba(14,17,22,0));
  opacity:0; transform:translateY(12px); visibility:hidden;
  transition:opacity .18s ease-out, transform .18s ease-out, visibility 0s linear .18s; }
.reasons.open { opacity:1; transform:none; visibility:visible; transition:opacity .18s ease-out, transform .18s ease-out; }
.rs-chips { display:flex; flex-wrap:wrap; gap:6px 5px; }
.rchip { pointer-events:auto; flex:none; min-height:36px; padding:0 9px; border-radius:18px; font-size:12px;
  border:1px solid rgba(139,148,158,.22); background:rgba(22,27,34,.78); color:#9aa4ae; touch-action:manipulation;
  transition:background .12s, border-color .12s, color .12s; }
.rchip:active { background:var(--panel2); }
.rchip[aria-pressed="true"] { background:#17305a; border-color:#4c8dff; color:#e3ecff; }
.rchip.flag { border-style:dashed; border-color:rgba(210,153,34,.35); color:#a99a7a; }
.rchip.first-flag { margin-left:8px; }
.rchip.flag[aria-pressed="true"] { border-style:solid; background:#3a2a10; border-color:#d29922; color:#f2cc60; }
.rchip.add, .rchip.shut { min-width:36px; padding:0; font-size:16px; line-height:1; }
.rchip.shut { min-width:30px; }
.rchip.add.has { color:#cfe0ff; border-color:rgba(76,141,255,.55); font-size:14px; }
.rchip.shut { border-color:transparent; background:transparent; color:var(--muted); }
.rs-note { display:flex; gap:6px; align-items:center; }
.rs-note input { pointer-events:auto; flex:1; min-width:0; min-height:36px; padding:0 12px; border-radius:18px;
  border:1px solid var(--accent); background:var(--bg); color:var(--text); font-size:16px; -webkit-user-select:text; user-select:text; }
.rs-note input::placeholder { color:var(--muted); font-size:13px; }
body.reviewing #reasons { display:none; }
@media (min-width:900px) { .reasons { padding-left:16px; padding-right:72px; } .rs-chips, .rs-note { max-width:720px; } }

/* the "why?" tag: on the position line, or with only an order open, in the readout */
.why { flex:none; white-space:normal; text-align:left;
  border:1px dashed rgba(139,148,158,.45); background:none; color:var(--muted); border-radius:11px;
  padding:0 8px; min-height:26px; font-size:11.5px; font-variant-numeric:normal; }
.why.set { border-style:solid; border-color:rgba(76,141,255,.45); color:#c9d7f0; }
#ord-why { max-width:96px; min-height:24px; margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
/* the account's leverage is above this market's maximum: its orders are refused */
#lev-chip.warn, #menu-lev-val.warn { border-color:#d29922; color:#f2cc60; }
#lev-mini.warn { color:#f2cc60; }
#lev-fix { min-height:24px; margin-bottom:2px; border-color:#d29922; color:#f2cc60; background:#3a2a10; }
#ro-mid { display:flex; flex-direction:column; align-items:center; justify-content:flex-end; min-width:0; }
#ro-mid > span:empty { display:none; }
/* the one-tap fix cannot work with a position open: a short explanation in its place */
.lev-hint { color:#f2cc60; white-space:normal; max-width:150px; line-height:1.25; }

/* ---- bottom panel (under the chart). Narrow: one column, order bar first (the thumb's reach),
   then the strip, then the positions. Wide (≥ 900 px): the positions on the left (scrolling when
   they are many), the strip over the order bar on the right, split by --bottom-split. */
#bottom { flex:none; display:flex; flex-direction:column; min-width:0; }
.b-right { display:contents; }
#orderbar { order:1; } #strip { order:2; } .b-left { order:3; }
/* narrow: the positions are one list of a fixed height, always there and scrolling inside, so
   the chart, the order bar and the strip never move when positions open, close or multiply.
   --pos-h fits the shown market's whole position line (its rows, wrapped at 390 px). */
.b-left { --pos-h:104px; display:block; height:var(--pos-h); flex:none; min-width:0; overflow-y:auto; overscroll-behavior:contain;
  border-top:1px solid var(--line); }
.b-left > #position { border-top:0; }
.b-left > #position[hidden] + #pos-others { border-top:0; }
#pos-none { display:none; margin:0; padding:8px 16px; font-size:12.5px; }
#positions:not(:has(> :is(#position, #pos-others):not([hidden]))) > #pos-none { display:block; }
/* positions on other markets: one compact line each; a tap shows that market */
#pos-others { border-top:1px solid var(--line); font-size:12.5px; }
.pos-row { display:flex; align-items:center; gap:8px; min-height:44px; padding:0 10px; white-space:nowrap; cursor:pointer; }
.pos-row + .pos-row { border-top:1px solid var(--line); }
.pos-row:hover { background:var(--panel); }
.pos-row > span { flex:none; }
.pos-row { gap:7px; }
.pos-row .pr-value { margin-right:auto; }
.pos-row .pr-pnl, .pos-row .pr-real { font-weight:600; }
.pos-row .side { font-weight:700; } .pos-row .side.long { color:var(--pos); } .pos-row .side.short { color:var(--neg); }
/* Close: a 36 px tall target, rows 44 px apart with a line between them */
.pos-row button { border:1px solid var(--line); background:var(--panel2); border-radius:8px; min-height:36px; padding:0 14px; font-size:12.5px; flex:none; }
.pos-sym { font-weight:700; }
body.reviewing #bottom { display:none !important; }

/* ---- position line: first what matters across markets (market, side, value, unrealised and
   realised P&L), wrapping to a second row when the first is full; then a smaller row with size,
   entry, liquidation, exits and why; Close at the right */
#position { display:grid; grid-template-columns:minmax(0, 1fr) auto; column-gap:8px; align-items:center;
  padding:4px 10px; border-top:1px solid var(--line); font-size:13px; white-space:nowrap; }
.pos-main { display:flex; flex-wrap:wrap; align-items:baseline; gap:1px 12px; min-width:0; }
.pos-a, .pos-p { display:flex; align-items:baseline; gap:8px; flex:none; }
.pos-b { grid-column:1 / -1; display:flex; flex-wrap:wrap; align-items:center; gap:1px 10px; min-width:0; margin-top:1px; font-size:12px; }
.pos-b > span { flex:none; }
.pos-b .why { min-height:24px; }
#pos-close { grid-column:2; grid-row:1; align-self:center; }
/* "uP&L" / "real.": small labels so the two numbers cannot be confused */
.pl-k { font-size:11px; font-weight:400; color:var(--muted); }
#pos-pnl, #pos-real { font-weight:600; }
#position .warn, .pos-row .warn { color:var(--warn); }
/* layer "Break-even and distances": its parts flow on in the smaller row */
#pos-dist { display:contents; font-size:11.5px; }
#pos-dist > span { flex:none; }
#pos-dist > span:empty { display:none; }
#pos-dist .warn { color:#f2cc60; }
#pos-exits { font-size:12px; }
#pos-exits > span + span { margin-left:7px; }
#position .side { font-weight:700; }
#position .side.long { color:var(--pos); } #position .side.short { color:var(--neg); }
#pos-close { border:1px solid var(--line); background:var(--panel2); border-radius:8px; min-height:36px; padding:0 14px; }

/* ---- order bar */
#orderbar { border-top:1px solid var(--line); padding:4px 8px 8px; }
.readout { display:grid; grid-template-columns:1fr auto 1fr; gap:6px; font-size:11px; color:var(--muted); min-height:30px; align-items:end; }
.readout span { white-space:pre-line; line-height:1.25; }
#ro-mid { text-align:center; } #ro-long { text-align:right; }
.readout b { color:var(--text); font-weight:500; }
.buttons { display:grid; grid-template-columns:minmax(0, 1fr) auto minmax(0, 1fr); gap:8px; margin-top:4px; }
.trade { position:relative; overflow:hidden; display:flex; flex-direction:column; align-items:center; justify-content:center;
  border:0; border-radius:10px; min-height:50px; color:#fff; -webkit-touch-callout:none; touch-action:manipulation; }
.trade b { font-size:16px; letter-spacing:.04em; }
.trade small { font-size:11px; opacity:.85; font-variant-numeric:tabular-nums; }
.trade.long { background:var(--long); } .trade.short { background:var(--short); }
.trade:disabled { opacity:.4; }
.trade::after { content:""; position:absolute; inset:0; background:rgba(255,255,255,.18); transform:scaleX(0); transform-origin:left; }
/* holding a trade button fills it from the left; when full (LONG_PRESS_MS) a market order goes */
.trade.holding::after { transform:scaleX(1); transition:transform var(--hold-ms, .45s) linear; }
.trade.fired::after { transform:scaleX(1); background:rgba(255,255,255,.32); }
.trade:focus { outline:none; }
.trade:focus-visible { outline:2px solid #cfe0ff; outline-offset:2px; }
/* size and Limit | Market side by side, so the row is as tall as the trade buttons and no taller */
.mid { display:flex; flex-direction:row; gap:4px; align-items:stretch; }
.ord-type { align-self:stretch; }
#ord-type button { min-height:0; padding:0 8px; font-size:12px; font-weight:600; }
/* a phone has no width to spare beside the trade buttons: Limit over Market */
@media (max-width:560px) {
  .ord-type { flex-direction:column; }
  #ord-type button { flex:1; padding:0 7px; }
  #ord-type button + button { border-left:0; border-top:1px solid var(--line); }
}
.size { position:relative; display:flex; flex-direction:column; align-items:center; justify-content:center;
  background:var(--panel); border:1px solid var(--line); border-radius:8px; min-height:30px; min-width:64px; flex:1; padding:1px 6px; }
#size-pct { font-weight:600; font-size:13px; } #size-base { font-size:11px; color:var(--muted); }


/* ---- sheets */
#sheet-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:40; }
.sheet { position:fixed; left:0; right:0; bottom:0; margin:0 auto; max-width:480px; z-index:41; background:var(--panel);
  border:1px solid var(--line); border-radius:14px 14px 0 0; padding:14px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet h2 { margin:0 0 10px; font-size:16px; }
.sheet.tall { display:flex; flex-direction:column; max-height:min(80dvh, 640px); }
.sheet-title { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; }
.sheet-title h2 { margin:0; }
.sheet-actions.wrap { flex-wrap:wrap; }
.sheet-actions .spacer { flex:1; }
.chip.danger { border-color:var(--short); color:#ffb3ad; }
.chip:disabled { opacity:.45; }
.presets .chip[aria-pressed="true"] { background:#122a4a; border-color:var(--accent); color:#cfe0ff; }

/* segmented toggle */
.seg { display:inline-flex; border:1px solid var(--line); border-radius:8px; overflow:hidden; flex:none; }
.seg button { border:0; background:var(--panel); padding:0 10px; min-height:30px; font-size:12px; color:var(--muted); }
.seg button + button { border-left:1px solid var(--line); }
.seg button[aria-pressed="true"] { background:var(--accent); color:#fff; }

/* ---- review: session list */
.ss-list { overflow:auto; min-height:80px; margin:0 -6px; }
.ss-row { display:block; width:100%; text-align:left; background:none; border:0; border-bottom:1px solid var(--line); padding:9px 6px; }
.ss-row:hover { background:var(--panel2); }
.ss-l1 { display:flex; align-items:center; gap:8px; }
.ss-l1 .spacer { flex:1; }
.ss-l2 { font-size:12px; margin-top:2px; }
.tag { font-size:11px; border:1px solid var(--line); border-radius:5px; padding:0 5px; color:var(--muted); }
.tag.run { border-color:var(--accent); color:#cfe0ff; }
.ss-row.current { background:rgba(76,141,255,.06); }

/* ---- new session sheet */
.ns-mode { display:flex; flex-direction:column; gap:6px; }
.ns-opt { display:flex; align-items:center; gap:10px; min-height:46px; padding:6px 12px; border:1px solid var(--line); border-radius:10px; cursor:pointer; }
.ns-opt:has(input:checked) { border-color:var(--accent); background:#122a4a; }
.ns-opt input[type=radio] { accent-color:var(--accent); margin:0; }
.ns-opt b { font-weight:500; }
.ns-opt > span { margin-left:auto; }
#ns-bal { width:110px; background:var(--bg); border:1px solid var(--line); border-radius:8px; min-height:34px; padding:0 8px; text-align:right; }
#ns-bal-row.off { opacity:.55; }
#ns-note.warn { color:#f2cc60; }

/* ---- review: playback bar (under the chart) */
#rv-bar { display:flex; align-items:center; gap:8px; padding:5px 10px; border-top:1px solid var(--line); font-size:12px; }
#rv-bar .chip.icon { width:38px; min-height:32px; color:var(--text); font-size:14px; }
#rv-scrub { flex:1; min-width:60px; accent-color:var(--accent); }
#rv-time { min-width:54px; text-align:right; }

/* ---- review: trade detail (in the order bar's place) */
#rv-detail { border-top:1px solid var(--line); padding:6px 10px 8px; font-size:12px; }
.td-hint { margin:6px 0; text-align:center; }
.td-head { display:flex; align-items:center; gap:8px; min-width:0; font-size:13px; }
.td-head .nav { flex:none; width:34px; min-height:30px; padding:0; }
.td-head .what { flex:1; min-width:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.td-head .net { flex:none; font-weight:700; }
.side.long { color:var(--pos); font-weight:700; } .side.short { color:var(--neg); font-weight:700; }
.td-line { margin-top:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; color:var(--muted); }
.td-line b { color:var(--text); font-weight:500; }
.td-note { color:var(--text); font-style:italic; }
.ctx-head { margin-top:5px; color:var(--muted); }
.ctx-head b { font-weight:600; }
.ctx-grid { display:grid; gap:1px 3px; margin-top:4px; font-size:11px; text-align:center; }
.ctx-grid small { font-size:8px; margin-right:1px; vertical-align:1px; }
.ctx-grid > span { white-space:nowrap; overflow:hidden; }
.ctx-grid .rl { text-align:left; color:var(--muted); padding-right:4px; }
.ctx-grid .th { color:var(--muted); font-weight:600; }
.ob { color:#ff4fd8; } .os { color:#2dd4bf; } .bull { color:#2dd4bf; } .bear { color:#ff4fd8; }

/* ---- review: panel (summary, equity, trades) */
#rv-panel { display:flex; flex-direction:column; min-height:0; border-top:1px solid var(--line); background:var(--panel); }
#rv-head { display:flex; align-items:center; gap:8px; width:100%; background:none; border:0; padding:8px 12px; min-height:40px; text-align:left; }
#rv-title { font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
#rv-headline { margin-left:auto; font-size:12px; white-space:nowrap; }
#rv-head .caret { transition:transform .15s; }
#rv-panel.collapsed #rv-head .caret { transform:rotate(180deg); }
#rv-body { overflow:auto; padding:0 12px 12px; min-height:0; }
#rv-panel.collapsed #rv-body { display:none; }
.rv-summary { display:grid; grid-template-columns:repeat(3, 1fr); gap:6px 10px; font-size:12px; }
.stat { display:flex; flex-direction:column; min-width:0; }
.stat span { color:var(--muted); font-size:11px; }
.stat b { font-weight:600; white-space:nowrap; }
.rv-equity-wrap { position:relative; height:64px; margin:10px 0 6px; }
#rv-equity { position:absolute; inset:0; width:100%; height:100%; }
.rv-trades { display:flex; flex-direction:column; }
.tr-row { display:block; width:100%; text-align:left; background:none; border:0; border-top:1px solid var(--line); padding:7px 4px; font-size:12px; }
.tr-row:hover { background:var(--panel2); }
.tr-row.sel { background:#122a4a; }
.tr-row.future { opacity:.35; }
.tr-l1 { display:flex; align-items:center; gap:8px; }
.tr-l1 .spacer { flex:1; }
.tr-l2 { margin-top:1px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tr-tags { display:flex; flex-wrap:wrap; gap:4px; margin-top:3px; }
.ttag { display:inline-block; font-size:11px; line-height:16px; padding:0 6px; border-radius:8px; background:#17233a; color:#c9d7f0; white-space:nowrap; }
.ttag.flag { background:#33260f; color:#f2cc60; }
.td-why .ttag + .ttag { margin-left:4px; }
/* by reason */
.rv-bytag { margin-top:10px; }
.bytag { width:100%; border-collapse:collapse; font-size:12px; }
.bytag th, .bytag td { padding:4px 4px; border-bottom:1px solid var(--line); text-align:right; white-space:nowrap; }
.bytag th:first-child, .bytag td:first-child { text-align:left; }
.bytag thead th { color:var(--muted); font-weight:600; font-size:11px; }
.bytag td:last-child { font-weight:600; }

/* review mode swaps the live controls out; the strip describes now, so it goes too */
body.reviewing #position, body.reviewing #orderbar, body.reviewing #strip { display:none !important; }

/* ---- agreement strip (layer): a column per timeframe, symbols only; legend in the Layers sheet */
#strip { display:grid; grid-template-columns:auto minmax(0, 1fr); gap:4px; padding:2px 8px 3px; border-top:1px solid var(--line);
  font-size:11px; line-height:14px; }
.st-lab, .st-col { display:flex; flex-direction:column; }
.st-lab > span, .st-col > span { height:14px; white-space:nowrap; }
.st-lab { color:var(--muted); font-size:11px; text-align:right; }
.st-ens { font-weight:600; font-size:11px; }
.st-ens b { margin-left:2px; }
.st-cols { display:grid; grid-template-columns:repeat(var(--cols, 9), minmax(0, 1fr)); gap:2px; }
.st-col { align-items:center; min-width:0; border:0; background:none; padding:0; border-radius:5px; color:var(--text); }
.st-col > span { align-self:stretch; text-align:center; overflow:hidden; }
.st-col .st-tf { color:var(--muted); font-size:11px; font-weight:600; }
.st-col.cur { background:var(--panel2); box-shadow:inset 0 0 0 1px #34425a; }
.st-col.cur .st-tf { color:var(--text); }
.ly-legend small { font-size:8px; color:var(--muted); margin-left:1px; vertical-align:1px; }
.st-col small { font-size:11px; color:var(--muted); margin-left:1px; }
.st-col > .z-ob, .st-col > .z-os { align-self:center; padding:0 5px; }
.z-ob { background:rgba(255,79,216,.24); border-radius:4px; } .z-os { background:rgba(45,212,191,.22); border-radius:4px; }
.st-col .old { opacity:.45; }
@media (min-width:900px) { #strip { grid-template-columns:auto minmax(0, 640px); justify-content:center; padding:3px 16px 4px; } }

/* ---- the Layers sheet */
.ly-body { overflow:auto; min-height:0; margin:0 -4px; padding:0 4px; }
.ly-group { margin:10px 0 2px; font-size:11px; font-weight:600; color:var(--muted); text-transform:uppercase; letter-spacing:.05em; }
.ly-group:first-child { margin-top:0; }
.ly-row { position:relative; display:flex; align-items:center; gap:12px; padding:7px 0; border-bottom:1px solid var(--line); cursor:pointer; }
.ly-text { flex:1; min-width:0; display:flex; flex-direction:column; }
.ly-text b { font-weight:500; font-size:14px; }
.ly-text small { font-size:11.5px; line-height:1.3; }
.ly-row input { position:absolute; opacity:0; width:1px; height:1px; }
.switch { flex:none; position:relative; width:40px; height:24px; border-radius:12px; background:var(--panel2); border:1px solid var(--line); transition:background .15s; }
.switch::after { content:""; position:absolute; top:2px; left:2px; width:18px; height:18px; border-radius:50%; background:var(--muted); transition:transform .15s, background .15s; }
.ly-row input:checked + .switch { background:var(--accent); border-color:var(--accent); }
.ly-row input:checked + .switch::after { transform:translateX(16px); background:#fff; }
.ly-row input:focus-visible + .switch { outline:2px solid var(--accent); outline-offset:2px; }
.ly-legend { display:grid; grid-template-columns:auto 1fr; gap:4px 12px; margin:4px 0 0; font-size:12px; align-items:center; }
.ly-legend dt { text-align:center; white-space:nowrap; }
.ly-legend dd { margin:0; color:var(--muted); }

/* ---- the exchange sheet: one card per profile */
.ex-intro { margin:-4px 0 8px; }
.ex-intro.warn, .ex-note.warn { color:#f2cc60; }
.ex-note:empty { display:none; }
.ex-list { overflow:auto; min-height:0; display:flex; flex-direction:column; gap:8px; margin:0 -4px; padding:0 4px; }
.ex-card { display:block; width:100%; text-align:left; background:var(--bg); border:1px solid var(--line); border-radius:10px; padding:9px 12px; }
.ex-card:hover { background:var(--panel2); }
.ex-card.current { border-color:var(--accent); background:#10213b; }
.ex-card:disabled { opacity:.6; cursor:progress; }
.ex-head { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.ex-head .spacer { flex:1; }
.ex-title { font-size:15px; }
.ex-max { font-size:12px; font-weight:600; }
.tag.ex-borrowed { border-color:rgba(210,153,34,.5); color:#f2cc60; }
.ex-figs { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:3px 10px; margin:5px 0 0; font-size:12px; }
.ex-fig { min-width:0; }
.ex-fig dt { color:var(--muted); font-size:10.5px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ex-fig dd { margin:0; white-space:nowrap; }
/* the round trip and the per-market leverage: a whole row each, label inline */
.ex-fig.line { grid-column:1 / -1; display:flex; gap:6px; align-items:baseline; flex-wrap:wrap; }
.ex-fig.line dd { white-space:normal; }
.ex-notes { display:block; margin-top:6px; font-size:10.5px; line-height:1.3; color:var(--muted); }
.tag.ex { color:var(--text); }

/* ---- rounds */
.rd-clock { font-size:30px; font-weight:700; margin:2px 0 8px; }
.min-input { display:inline-flex; align-items:center; gap:4px; color:var(--muted); font-size:13px; }
.min-input input, #rd-bal { width:80px; background:var(--bg); border:1px solid var(--line); border-radius:8px; min-height:34px; padding:0 8px; }
#rd-bal { width:110px; margin-left:0; }
#round-sheet .reset-row { margin-top:12px; }
.rd-ex-row { display:flex; align-items:center; gap:8px; margin-top:12px; flex-wrap:wrap; }
.rd-live-ex { font-size:15px; font-weight:500; }
.rl-ex { color:var(--text); font-weight:600; }
.cmp { width:100%; border-collapse:collapse; font-size:13px; font-variant-numeric:tabular-nums; }
.cmp th, .cmp td { padding:6px 4px; border-bottom:1px solid var(--line); text-align:right; }
.cmp th:first-child, .cmp td:first-child { text-align:left; color:var(--muted); font-weight:400; }
.cmp thead th { color:var(--muted); font-weight:600; }
.cmp .win { color:var(--text); font-weight:700; }
.sheet hr { border:0; border-top:1px solid var(--line); margin:14px 0; }
.lev-value { font-size:28px; font-weight:700; }
.lev-value input { width:84px; background:transparent; border:0; border-bottom:1px solid var(--line); font-size:28px; font-weight:700; }
#lev-range { width:100%; margin:10px 0; accent-color:var(--accent); }
.presets { display:flex; flex-wrap:wrap; gap:6px; }
.sheet-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:12px; }
.reset-row { display:flex; align-items:center; gap:8px; }
.reset-row input { width:100px; background:var(--bg); border:1px solid var(--line); border-radius:8px; min-height:34px; padding:0 8px; margin-left:auto; }
.keys { display:grid; grid-template-columns:auto 1fr; gap:6px 14px; margin:0; font-size:13px; }
.keys dt { font-family:ui-monospace, SFMono-Regular, Menlo, monospace; color:var(--accent); }
.keys dd { margin:0; }
.sheet p { font-size:12px; }

/* ---- signing in: the whole screen at start-up; over the page when a session ended while it was open */
.signin { position:fixed; inset:0; z-index:100; display:flex; align-items:center; justify-content:center; overflow:auto;
  padding:calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); background:var(--bg); }
.signin.over { background:rgba(14,17,22,.78); -webkit-backdrop-filter:blur(3px); backdrop-filter:blur(3px); }
.si-card { width:100%; max-width:340px; margin-bottom:8dvh; padding:22px 20px 18px; background:var(--panel);
  border:1px solid var(--line); border-radius:14px; }
.signin.over .si-card { box-shadow:0 12px 40px rgba(0,0,0,.55); }
.si-head { display:flex; align-items:center; gap:10px; margin-bottom:16px; }
.si-head img { flex:none; border-radius:8px; }
.si-head h1 { margin:0; font-size:18px; font-weight:600; letter-spacing:.01em; }
.si-lead { margin:-6px 0 14px; color:var(--muted); font-size:13px; }
.si-lead:empty { display:none; }
.si-form { display:flex; flex-direction:column; gap:10px; }
#si-password { min-height:44px; padding:0 12px; border-radius:10px; border:1px solid var(--line); background:var(--bg);
  color:var(--text); font-size:16px; -webkit-user-select:text; user-select:text; }
#si-password::placeholder { color:var(--muted); }
#si-password:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px rgba(76,141,255,.22); }
.si-btn { min-height:44px; border:0; border-radius:10px; background:var(--accent); color:#fff; font-weight:600; font-size:15px; }
.si-btn:disabled { opacity:.45; cursor:default; }
.si-btn:focus-visible { outline:2px solid #cfe0ff; outline-offset:2px; }
.si-msg { margin:12px 0 0; min-height:18px; font-size:13px; color:var(--muted); }
.si-msg.err { color:#ff9b94; }
.si-msg:empty { min-height:0; margin:0; }
/* there for password managers and screen readers, not for the eye */
.vh { position:absolute !important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }
.menu .menu-signout { border-top:1px solid var(--line); border-radius:0 0 7px 7px; margin-top:4px; padding-top:11px; color:var(--muted); }

@media (max-width:420px) { #position { font-size:12.5px; } .pos-a, .pos-p { gap:7px; } .pos-b { gap:1px 8px; font-size:11.5px; } #pos-dist { font-size:11px; } }

/* phone: secondary controls go to the ⋯ menu; leverage stays visible in the account line */
@media (max-width:560px) {
  .wide-only { display:none !important; }
  .narrow-only { display:inline-block; }
  header#top { padding:4px 8px 3px; }
  header .row { gap:6px; }
  header .row.sub { gap:8px; font-size:11.5px; }
  #account-line { gap:8px; }
  .textbtn { font-size:11.5px; }
  #rl-stop { min-height:20px; padding:0 8px; }
  .td-line { white-space:normal; }
  .chip { padding:0 9px; }
  #price { font-size:17px; }
  .symbol { font-size:14px; }
  .quote { display:none; }
  /* the top row is the tight spot: exchange, symbol, price, Round, Review and ⋯ in 374 px */
  header .row:first-child { gap:3px; }
  header .row:first-child > .symbol { margin-left:3px; }
  header .row:first-child > #price { font-size:16px; margin-left:1px; }
  .exchip { padding:0 6px; font-size:12.5px; flex:0 1 auto; min-width:44px; }
  .exchip b { min-width:0; overflow:hidden; text-overflow:ellipsis; }
  .exchip .caret { display:none; }
  #price { flex:none; }
  #round-chip, #review-btn { padding:0 7px; }
  body.round-on #account-line { display:none; }
  body.round-on #round-line { margin-left:0; width:100%; }
  body.round-on #round-line #rl-stop { margin-left:auto; }
  /* review on a phone: the panel is a sheet over the lower part; the trade detail shows once it is collapsed */
  #rv-panel { border-radius:14px 14px 0 0; border:1px solid var(--line); border-bottom:0; max-height:52dvh; box-shadow:0 -6px 18px rgba(0,0,0,.35); }
  body.reviewing:not(.rv-collapsed) #rv-detail { display:none; }
  #rv-head .caret { display:inline-block; }
  .rv-summary { grid-template-columns:repeat(4, minmax(0, 1fr)); gap:5px 8px; }
  .stat span { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .rv-equity-wrap { height:54px; margin:8px 0 4px; }
  .ctx-grid { font-size:10.5px; gap:1px 2px; }
  #rv-speed button { padding:0 8px; }
}
@media (min-width:900px) {
  #orderbar, #position { padding-left:16px; padding-right:16px; }
  .pos-row { padding:0 16px; }
  /* two columns, always: the positions left, the strip over the order bar right. The left column
     takes the right one's height and scrolls inside it, so the buttons never move. */
  #bottom { display:grid; grid-template-columns:var(--bottom-split) minmax(0, 1fr); border-top:1px solid var(--line); }
  .b-left { order:0; height:0; min-height:100%; border-top:0; }
  .b-right { display:flex; flex-direction:column; justify-content:flex-end; min-width:0; border-left:1px solid var(--line); }
  .b-right > #strip { border-top:0; order:1; }
  .b-right > #orderbar { order:2; }
  #orderbar { padding-top:4px; padding-bottom:6px; min-width:0; }
  .trade { min-height:46px; border-radius:9px; }
  .trade b { font-size:15px; }

  /* review on a desktop: the panel is a column on the right */
  body.reviewing { display:grid; grid-template-columns:minmax(0, 1fr) 380px; grid-template-rows:auto minmax(0, 1fr) auto auto; }
  body.reviewing > header { grid-column:1 / -1; }
  body.reviewing > #chart-wrap { grid-column:1; grid-row:2; }
  body.reviewing > #rv-bar { grid-column:1; grid-row:3; }
  body.reviewing > #rv-detail { grid-column:1; grid-row:4; }
  body.reviewing > #rv-panel { grid-column:2; grid-row:2 / 5; border-top:0; border-left:1px solid var(--line); }
  body.reviewing #rv-head { cursor:default; }
  #rv-detail { padding-left:16px; padding-right:16px; }
  .buttons, .readout { width:100%; max-width:720px; margin-left:auto; margin-right:auto; }
}
