:root {
  --bg: #030605;
  --bg-2: #07100c;
  --panel: rgba(5, 14, 11, 0.92);
  --panel-2: rgba(7, 19, 15, 0.97);
  --well: #010403;
  --line: #1dff8a;
  --line-dim: #0f3324;
  --up: #3dff9a;
  --down: #ff4d6d;
  --amber: #ffc14a;
  --cyan: #4de6ff;
  --text: #d4ffe6;
  --muted: #5f8a73;
  --danger: #ff6b6b;
  --ink: #02120a;
  --edge: color-mix(in srgb, var(--line) 30%, var(--line-dim));
  --tint: color-mix(in srgb, var(--line) 7%, transparent);
  --tint-2: color-mix(in srgb, var(--line) 14%, transparent);
  --glow: color-mix(in srgb, var(--line) 55%, transparent);
  --shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 10px 30px rgba(0, 0, 0, 0.45);
  --grid: rgba(29, 255, 138, 0.045);
  --scan: 0.35;
  --vignette: 0.55;
  --gap: 8px;
  --font: "JetBrains Mono", "IBM Plex Mono", ui-monospace, "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

[data-theme="amber"] {
  --line: #ffb020;
  --line-dim: #3d2a08;
  --up: #ffd36a;
  --down: #ff5a3c;
  --text: #ffe7b0;
  --muted: #9a7a44;
  --panel: rgba(18, 11, 4, 0.92);
  --panel-2: rgba(26, 16, 6, 0.97);
  --well: #050301;
  --bg: #070502;
  --bg-2: #100a04;
  --ink: #140c02;
  --grid: rgba(255, 176, 32, 0.05);
}

[data-theme="ice"] {
  --line: #4de6ff;
  --line-dim: #0b2f38;
  --up: #7dfff1;
  --down: #ff6b9d;
  --text: #d9fbff;
  --muted: #5f8c98;
  --panel: rgba(4, 12, 18, 0.92);
  --panel-2: rgba(6, 17, 25, 0.97);
  --well: #010305;
  --bg: #02060a;
  --bg-2: #050d14;
  --ink: #021016;
  --grid: rgba(77, 230, 255, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, color-mix(in srgb, var(--line) 12%, transparent), transparent 70%),
    linear-gradient(var(--bg), var(--bg-2) 70%, var(--bg));
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
  opacity: var(--scan);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 81;
  box-shadow: inset 0 0 160px rgba(0, 0, 0, var(--vignette));
}

::selection { background: var(--line); color: var(--ink); }

button, input, select {
  font-family: inherit;
  color: inherit;
  border-radius: 0;
}

button { cursor: pointer; -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 2px;
}

* { scrollbar-width: thin; scrollbar-color: var(--line-dim) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: var(--line-dim); }
::-webkit-scrollbar-track { background: transparent; }

.desk {
  max-width: 1480px;
  margin: 0 auto;
  padding: 10px 12px 18px;
  position: relative;
}

/* ── tape ─────────────────────────────────────────── */

.tape-wrap {
  position: relative;
  overflow: hidden;
  border-top: 1px solid var(--edge);
  border-bottom: 1px solid var(--edge);
  background: var(--well);
  margin-bottom: var(--gap);
  height: 28px;
  display: flex;
  align-items: center;
  font-size: 12px;
}

.tape-wrap::before,
.tape-wrap::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 48px;
  z-index: 1;
  pointer-events: none;
}
.tape-wrap::before { left: 0; background: linear-gradient(90deg, var(--well), transparent); }
.tape-wrap::after { right: 0; background: linear-gradient(-90deg, var(--well), transparent); }

body.is-paused .tape { animation-play-state: paused; }
body.is-paused .live i { animation: none; opacity: 0.35; }

.tape {
  display: flex;
  gap: 28px;
  white-space: nowrap;
  animation: tape 40s linear infinite;
  padding: 0 16px;
  min-width: 200%;
  will-change: transform;
}

.tape > span { color: var(--muted); }
.tape .up { color: var(--up); }
.tape .down { color: var(--down); }
.tape b { color: var(--text); margin-right: 6px; font-weight: 600; }

@keyframes tape {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* ── top bar ──────────────────────────────────────── */

.topbar {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  margin-bottom: var(--gap);
}

.mast {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px 16px;
  flex-wrap: wrap;
  border: 1px solid var(--edge);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 10px 14px;
}

.brand {
  min-width: 260px;
  flex: 1 1 300px;
}

.brand h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.24em;
  color: var(--line);
  text-shadow: 0 0 14px var(--glow);
  margin: 2px 0;
}

.brand h1::after {
  content: "_";
  margin-left: 0.1em;
  animation: blink 1.05s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.brand .sub {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.14em;
}

.brand .bar { max-width: 420px; }

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--up);
  font-size: 10px;
  letter-spacing: 0.18em;
}

.live i {
  width: 6px;
  height: 6px;
  background: var(--up);
  box-shadow: 0 0 8px var(--up);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 520px;
}

.seg { display: flex; }
.seg > * + * { margin-left: -1px; }

.controls button, .chip, .ticket button, .qty-row button, .order-row button {
  position: relative;
  background: transparent;
  border: 1px solid var(--edge);
  color: var(--line);
  padding: 0 11px;
  letter-spacing: 0.1em;
  font-size: 11px;
  font-weight: 700;
  min-height: 32px;
  transition: background 0.12s, color 0.12s, border-color 0.12s, box-shadow 0.12s;
}

@media (hover: hover) {
  .controls button:hover, .chip:hover, .ticket button:hover:not(:disabled) {
    border-color: var(--line);
    background: var(--tint);
    z-index: 1;
  }
}

.controls button.active, .chip.active {
  background: var(--line);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: 0 0 12px var(--glow);
  z-index: 2;
}

.controls button:active, .ticket button:active:not(:disabled) { transform: translateY(1px); }

.crt-ctl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  border: 1px solid var(--edge);
  padding: 0 10px;
  min-height: 32px;
}
.crt-ctl input {
  width: 64px;
  accent-color: var(--line);
}

/* ── stats ────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  background: var(--edge);
  border: 1px solid var(--edge);
}

.stat {
  background: var(--panel-2);
  padding: 8px 12px;
  min-width: 0;
}

.stat label {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.16em;
  margin-bottom: 2px;
}

.stat b {
  display: block;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat[data-regime="BULL"] b { color: var(--up); }
.stat[data-regime="BEAR"] b, .stat[data-regime="CRASH"] b { color: var(--down); }
.stat[data-regime="EARNINGS"] b { color: var(--amber); }

/* ── panels ───────────────────────────────────────── */

.workspace {
  display: grid;
  grid-template-columns: minmax(250px, 0.85fr) minmax(440px, 1.75fr) minmax(280px, 0.95fr);
  gap: var(--gap);
  margin-bottom: var(--gap);
  align-items: stretch;
}

.panel {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line-dim);
  box-shadow: var(--shadow);
  min-width: 0;
}

/* corner brackets: sharp HUD frame without heavy borders */
.panel::before, .mast::before {
  content: "";
  position: absolute;
  inset: -1px;
  pointer-events: none;
  --c: var(--line);
  --s: 9px;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--s) 1px,
    linear-gradient(var(--c), var(--c)) top left / 1px var(--s),
    linear-gradient(var(--c), var(--c)) top right / var(--s) 1px,
    linear-gradient(var(--c), var(--c)) top right / 1px var(--s),
    linear-gradient(var(--c), var(--c)) bottom left / var(--s) 1px,
    linear-gradient(var(--c), var(--c)) bottom left / 1px var(--s),
    linear-gradient(var(--c), var(--c)) bottom right / var(--s) 1px,
    linear-gradient(var(--c), var(--c)) bottom right / 1px var(--s);
  background-repeat: no-repeat;
  opacity: 0.85;
}

.panel h2 {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-dim);
  background: linear-gradient(90deg, var(--tint), transparent 60%);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel h2::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--line);
  box-shadow: 0 0 6px var(--glow);
  flex: none;
}

.panel h2 span {
  margin-left: auto;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.14em;
}

#ticket h2:not(:first-child) { border-top: 1px solid var(--line-dim); }

/* ── watch ────────────────────────────────────────── */

.watch {
  max-height: 600px;
  overflow: auto;
}

.watch-row {
  position: relative;
  display: grid;
  grid-template-columns: 58px 1fr 76px 58px;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--line-dim) 55%, transparent);
  cursor: pointer;
  transition: background 0.15s;
}

@media (hover: hover) { .watch-row:hover { background: var(--tint); } }
.watch-row.selected { background: var(--tint-2); box-shadow: inset 2px 0 0 var(--line); }
.watch-row.locked { opacity: 0.38; cursor: not-allowed; }
.watch-row .sym { font-weight: 700; letter-spacing: 0.04em; }
.watch-row .meta { color: var(--muted); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }
.watch-row .px { text-align: right; }
.watch-row .chg { text-align: right; font-size: 11px; }
.watch-row.flash-up .px { animation: pxUp 0.6s ease-out; }
.watch-row.flash-down .px { animation: pxDown 0.6s ease-out; }

@keyframes pxUp {
  from { color: var(--up); text-shadow: 0 0 10px var(--up); }
  to { color: var(--text); text-shadow: none; }
}
@keyframes pxDown {
  from { color: var(--down); text-shadow: 0 0 10px var(--down); }
  to { color: var(--text); text-shadow: none; }
}

.spark { width: 56px; height: 22px; display: block; }

/* ── chart ────────────────────────────────────────── */

.chart-col { display: flex; flex-direction: column; }

.quote {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 8px;
  flex-wrap: wrap;
}

.quote .hint { letter-spacing: 0.08em; }

.quote .big {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
  text-shadow: 0 0 18px color-mix(in srgb, var(--line) 40%, transparent);
}

.quote .big.tick-up { animation: pxUp 0.7s ease-out; }
.quote .big.tick-down { animation: pxDown 0.7s ease-out; }

.quote .chg { font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; }
.toolbar .chip + .chip { margin-left: -1px; }
.chip { min-height: 26px; padding: 0 10px; font-size: 10px; }

#chart-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 340px;
  margin: 0 8px 8px;
  border: 1px solid var(--line-dim);
  overflow: hidden;
  touch-action: pan-y;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--line) 8%, transparent), transparent 60%),
    var(--well);
  background-size: 32px 32px, 32px 32px, auto, auto;
}

#chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.chart-legend {
  position: absolute;
  top: 6px;
  left: 8px;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  max-width: calc(100% - 90px);
  padding: 3px 6px;
  font-size: 10px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: color-mix(in srgb, var(--well) 78%, transparent);
  pointer-events: none;
}
.chart-legend b { color: var(--text); font-weight: 600; margin-left: 3px; }
.chart-legend .ema b { color: var(--cyan); }

.last-dot {
  position: absolute;
  left: 0;
  top: 0;
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  background: var(--dot, var(--up));
  border-radius: 50%;
  pointer-events: none;
  display: none;
  box-shadow: 0 0 10px var(--dot, var(--up));
  will-change: transform;
}

.last-dot::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1px solid var(--dot, var(--up));
  animation: ping 1.6s ease-out infinite;
}

@keyframes ping {
  from { transform: scale(1); opacity: 0.9; }
  to { transform: scale(4.2); opacity: 0; }
}

body.is-paused .last-dot::after { animation: none; opacity: 0; }

.crosshair {
  position: absolute;
  pointer-events: none;
  color: var(--ink);
  background: var(--cyan);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  transform: translateY(-50%);
  display: none;
}

.movers {
  display: flex;
  gap: 1px;
  margin: 0 8px 8px;
  overflow: auto;
  background: var(--line-dim);
  border: 1px solid var(--line-dim);
}

.mover {
  flex: 1 1 0;
  background: var(--panel-2);
  padding: 5px 8px;
  min-width: 84px;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

/* ── ticket ───────────────────────────────────────── */

.ticket { padding: 10px; display: flex; flex-direction: column; gap: 8px; }

.ticket select, .ticket input {
  width: 100%;
  min-height: 34px;
  background: var(--well);
  border: 1px solid var(--line-dim);
  padding: 6px 8px;
  font-size: 13px;
  transition: border-color 0.12s;
}

.ticket select:focus, .ticket input:focus { border-color: var(--line); outline: none; }
.ticket input:disabled { color: var(--muted); }

.side-row, .type-row { display: flex; gap: 6px; }
.type-row > * { flex: 1 1 50%; }
.qty-row { display: grid; grid-template-columns: repeat(6, 1fr) ; gap: 0; }
.qty-row input { grid-column: 1 / -1; margin-bottom: 6px; }
.qty-row button { padding: 0 4px; }
.qty-row button + button { margin-left: -1px; }
.trade-bar { display: flex; flex-direction: column; gap: 6px; }
.bar-meta { display: none; }
.side-row > button { flex: 1 1 40%; min-height: 40px; font-size: 12px; letter-spacing: 0.16em; }

.buy-btn, .cover-btn { border-color: color-mix(in srgb, var(--up) 60%, transparent) !important; color: var(--up) !important; }
.sell-btn, .short-btn { border-color: color-mix(in srgb, var(--down) 60%, transparent) !important; color: var(--down) !important; }
.buy-btn { background: color-mix(in srgb, var(--up) 10%, transparent) !important; }
.sell-btn { background: color-mix(in srgb, var(--down) 10%, transparent) !important; }
@media (hover: hover) {
  .buy-btn:hover:not(:disabled), .cover-btn:hover:not(:disabled) { background: var(--up) !important; color: var(--ink) !important; box-shadow: 0 0 16px color-mix(in srgb, var(--up) 45%, transparent); }
  .sell-btn:hover:not(:disabled), .short-btn:hover:not(:disabled) { background: var(--down) !important; color: #140308 !important; box-shadow: 0 0 16px color-mix(in srgb, var(--down) 45%, transparent); }
}
.buy-btn:active:not(:disabled), .cover-btn:active:not(:disabled) { background: var(--up) !important; color: var(--ink) !important; box-shadow: 0 0 16px color-mix(in srgb, var(--up) 45%, transparent); }
.sell-btn:active:not(:disabled), .short-btn:active:not(:disabled) { background: var(--down) !important; color: #140308 !important; box-shadow: 0 0 16px color-mix(in srgb, var(--down) 45%, transparent); }
button:disabled { opacity: 0.35; cursor: not-allowed; }

.hint { color: var(--muted); font-size: 11px; }
#maxBuy { font-size: 10px; letter-spacing: 0.04em; }

.positions { max-height: 180px; overflow: auto; }
.pos {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 6px;
  padding: 7px 10px;
  border-top: 1px solid color-mix(in srgb, var(--line-dim) 55%, transparent);
  font-size: 11px;
}
.pos:first-child { border-top: 0; }
.pos.hint { display: block; }

.pos.short { box-shadow: inset 2px 0 0 var(--down); }
.pos.short b::after {
  content: " SHORT";
  display: block;
  color: var(--down);
  font-size: 8px;
  letter-spacing: 0.12em;
}

.orders { font-size: 11px; }
.order-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-top: 1px solid color-mix(in srgb, var(--line-dim) 55%, transparent);
}
.order-row:first-child { border-top: 0; }
.order-row button { min-height: 24px; padding: 0 8px; color: var(--down); border-color: color-mix(in srgb, var(--down) 50%, transparent); }

/* ── session P&L card ─────────────────────────────── */

.pnl-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-bottom: 12px;
  background: var(--line-dim);
  border: 1px solid var(--line-dim);
}
.pnl-card div {
  background: var(--panel-2);
  padding: 9px 12px;
}
.pnl-card label {
  display: block;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.14em;
  margin-bottom: 2px;
}
.pnl-card b { font-size: 17px; font-weight: 600; }

/* ── bottom ───────────────────────────────────────── */

.bottom {
  display: grid;
  grid-template-columns: 1.1fr 0.8fr 1.1fr;
  gap: var(--gap);
}

.panel.news {
  min-height: 92px;
  padding: 12px 12px 12px 30px;
  border-color: color-mix(in srgb, var(--amber) 40%, var(--line-dim));
  color: var(--amber);
  line-height: 1.5;
}
.panel.news::before { --c: var(--amber); }
.panel.news::after {
  content: "»";
  position: absolute;
  left: 12px;
  top: 11px;
  color: var(--amber);
  animation: blink 1.05s steps(1) infinite;
}

.panel.news.hot {
  animation: newsflash 0.9s ease;
  box-shadow: var(--shadow), 0 0 22px rgba(255, 193, 74, 0.2);
}

@keyframes newsflash {
  0% { background: rgba(255, 193, 74, 0.16); }
  100% { background: var(--panel); }
}

.missions { padding: 8px 10px; }
.mission { margin-bottom: 9px; }
.mission:last-child { margin-bottom: 0; }
.bar {
  height: 4px;
  background: var(--well);
  border: 1px solid var(--line-dim);
  margin-top: 4px;
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--line);
  box-shadow: 0 0 8px var(--glow);
  width: 0;
  transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#log {
  height: 150px;
  overflow: auto;
  padding: 8px 10px;
  font-size: 11px;
}

.log-entry { margin-bottom: 2px; color: var(--muted); }
.log-entry.buy { color: var(--up); }
.log-entry.sell { color: var(--down); }
.log-entry.news, .log-entry.warn { color: var(--amber); }
.log-entry.win, .log-entry.rank, .log-entry.mission { color: var(--cyan); }

/* ── overlays ─────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: blur(3px);
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay.show { display: flex; }
.overlay.show .modal { animation: modalin 0.18s ease-out; }

@keyframes modalin {
  from { transform: translateY(6px) scale(0.99); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.modal {
  position: relative;
  width: min(520px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: 0 0 40px color-mix(in srgb, var(--line) 18%, transparent), var(--shadow);
  padding: 18px;
}

.modal h3 {
  letter-spacing: 0.2em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-dim);
  color: var(--line);
}
.modal p { color: var(--muted); margin-bottom: 10px; }
.modal ol { padding-left: 18px; color: var(--text); margin-bottom: 12px; }
.modal ol li { margin-bottom: 4px; }
.modal > button { width: 100%; min-height: 40px; border: 1px solid; font-weight: 700; letter-spacing: 0.16em; }
.scores { list-style: none; margin-bottom: 12px; padding-left: 0 !important; }
.scores li { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--line-dim); }

#boot {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 90;
  color: var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  letter-spacing: 0.14em;
  text-shadow: 0 0 10px var(--glow);
}

#bootText::after { content: "█"; margin-left: 4px; animation: blink 0.8s steps(1) infinite; }

#boot.hide { opacity: 0; pointer-events: none; transition: opacity 0.5s ease; }

.toast-wrap {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 45;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.toast {
  background: var(--panel-2);
  border: 1px solid var(--edge);
  border-left: 2px solid var(--line);
  padding: 8px 12px;
  min-width: 180px;
  font-size: 11px;
  letter-spacing: 0.08em;
  box-shadow: var(--shadow);
  animation: toastin 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes toastin {
  from { transform: translateX(12px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

.positive { color: var(--up); }
.negative { color: var(--down); }

.kb {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-align: center;
  margin-top: 10px;
}

/* ── responsive ───────────────────────────────────── */

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .workspace { grid-template-columns: minmax(230px, 0.8fr) minmax(0, 1.6fr); }
  #ticket { grid-column: 1 / -1; }
}

@media (max-width: 980px) {
  .workspace, .bottom { grid-template-columns: 1fr; }
  .chart-col { order: -2; }
  #ticket { order: -1; }
  #chart-wrap { min-height: 280px; }
  .watch { max-height: 320px; }
}

@media (max-width: 640px) {
  :root { --gap: 6px; }
  html, body { font-size: 12px; }
  .desk { padding: 6px max(8px, env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  .tape-wrap { height: 26px; font-size: 11px; margin-left: -8px; margin-right: -8px; border-left: 0; border-right: 0; }

  .mast { padding: 10px; gap: 10px; }
  .brand { min-width: 0; flex: 1 1 100%; }
  .brand h1 { font-size: 17px; letter-spacing: 0.18em; }
  .brand .sub { font-size: 9px; letter-spacing: 0.08em; }
  .brand .bar { max-width: none; }

  /* one swipeable strip instead of three wrapped rows */
  .controls {
    flex: 1 1 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    margin: 0 -10px;
    padding: 0 10px 2px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 10px, #000 calc(100% - 24px), transparent);
            mask-image: linear-gradient(90deg, transparent 0, #000 10px, #000 calc(100% - 24px), transparent);
  }
  .controls::-webkit-scrollbar { display: none; }
  .controls > * { flex: none; }
  .controls button { min-height: 34px; padding: 0 10px; }

  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat { padding: 6px 8px; }
  .stat label { font-size: 8px; letter-spacing: 0.1em; }
  .stat b { font-size: 13px; }

  .quote { padding: 8px 8px 6px; }
  .quote .big { font-size: 26px; }
  #chart-wrap { min-height: 0; height: 240px; flex: none; margin: 0 6px 6px; }
  .movers { margin: 0 6px 6px; }
  .mover { min-width: 76px; }

  .ticket { padding: 8px; }
  /* every mobile broker pins the trade actions; all four stay, shorting is the game */
  .desk { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .trade-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    background: var(--panel-2);
    border-top: 1px solid var(--edge);
    box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(6px);
            backdrop-filter: blur(6px);
  }
  .trade-bar .side-row { display: contents; }
  .trade-bar .side-row > button { min-height: 46px; padding: 0; font-size: 11px; letter-spacing: 0.1em; }
  .bar-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    grid-column: 1 / -1;
    font-size: 10px;
    letter-spacing: 0.08em;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
  }
  .bar-meta b { color: var(--text); font-weight: 600; }
  .chart-legend { font-size: 9px; gap: 0 8px; }
  /* 16px stops iOS from zooming into the inputs */
  .ticket select, .ticket input { font-size: 16px; min-height: 40px; }
  .qty-row button { min-height: 38px; }
  .side-row > button { min-height: 46px; }

  .watch-row { grid-template-columns: 52px 1fr 72px 54px; padding: 8px 10px; }
  .watch { max-height: 300px; }

  .panel.news { min-height: 0; }
  #log { height: 120px; }
  .kb { display: none; }

  .toast-wrap {
    left: 50%;
    right: auto;
    top: calc(36px + env(safe-area-inset-top));
    bottom: auto;
    transform: translateX(-50%);
    align-items: center;
  }
  .toast { min-width: 0; animation-name: toastdrop; }
  .modal { padding: 14px; }
}

@keyframes toastdrop {
  from { transform: translateY(-8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .tape { animation: tape 120s linear infinite !important; }
}

/* Fill markers tooltip (glyphs themselves are on the canvas) */
.fill-tip {
  position: absolute;
  display: none;
  transform: translateX(-50%);
  pointer-events: none;
  padding: 2px 6px;
  font: 700 10px var(--font);
  letter-spacing: 0.04em;
  white-space: nowrap;
  background: var(--bg);
  border: 1px solid currentColor;
  z-index: 3;
}
.fill-tip.up { color: var(--up); }
.fill-tip.down { color: var(--down); }
