:root {
  --bg: #050507;
  --bg2: #08080c;
  --panel: #0c0c12;
  --panel2: #101018;
  --line: #1c1c28;
  --line2: #2a2a3a;
  --text: #eef2ff;
  --muted: #7d8599;
  --cyan: #00f3ff;
  --mag: #ff00aa;
  --up: #0ecb81;
  --down: #f6465d;
  --gold: #f0b90b;
  --warn: #ff8a3d;
  --font: "Segoe UI", Inter, ui-sans-serif, system-ui, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, ui-monospace, monospace;
  --tape-h: 28px;
  --top-h: 52px;
  --tool-h: 34px;
  --bot-h: 212px;
  --watch-w: 228px;
  --rail-w: 286px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; }
button, input, select { font-family: inherit; }
button { cursor: pointer; }
::selection { background: rgba(0, 243, 255, 0.28); }

.st-app {
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--tape-h) var(--top-h) minmax(0, 1fr);
  background:
    radial-gradient(900px 420px at 0% 0%, rgba(0, 243, 255, 0.05), transparent 55%),
    radial-gradient(700px 360px at 100% 0%, rgba(255, 0, 170, 0.05), transparent 50%),
    var(--bg);
}
.st-app.stream {
  --bot-h: 0px;
  --watch-w: 0px;
  --rail-w: 0px;
}

/* ticker tape */
.st-tape {
  display: flex; align-items: center; gap: 0;
  overflow: hidden; border-bottom: 1px solid var(--line);
  background: #05050a; font-family: var(--mono); font-size: 11px;
  white-space: nowrap;
}
.st-tape-inner { display: flex; gap: 22px; padding: 0 14px; animation: st-marquee 80s linear infinite; }
.st-tape:hover .st-tape-inner { animation-play-state: paused; }
@keyframes st-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.st-tick { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); }
.st-tick b { color: var(--text); font-weight: 700; letter-spacing: 0.04em; }
.st-tick .up { color: var(--up); }
.st-tick .down { color: var(--down); }

/* top bar */
.st-top {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px; align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 8, 12, 0.94);
}
.st-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 168px; }
.st-mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 900; font-size: 13px;
  background: linear-gradient(135deg, #091820, #1a0820);
  color: var(--cyan); border: 1px solid rgba(0, 243, 255, 0.4);
  box-shadow: 0 0 18px rgba(0, 243, 255, 0.18);
}
.st-brand strong { display: block; font-size: 12px; letter-spacing: 0.16em; }
.st-brand span { display: block; font-size: 10px; color: var(--muted); letter-spacing: 0.12em; }
.st-pairbar { display: flex; align-items: center; gap: 14px; min-width: 0; overflow: hidden; }
.st-pairbtn {
  background: var(--panel2); border: 1px solid var(--line2); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-weight: 800; letter-spacing: 0.04em;
}
.st-pairbtn:hover { border-color: var(--cyan); }
.st-last { font-family: var(--mono); font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.st-last.up { color: var(--up); }
.st-last.down { color: var(--down); }
.st-chg { font-family: var(--mono); font-weight: 700; font-size: 13px; }
.st-chg.up { color: var(--up); }
.st-chg.down { color: var(--down); }
.st-meta { display: flex; gap: 14px; color: var(--muted); font-size: 11px; flex-wrap: wrap; }
.st-meta b { color: var(--text); font-family: var(--mono); font-weight: 650; margin-left: 4px; }
.st-actions { display: flex; gap: 6px; align-items: center; }
.st-btn {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: 6px 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
.st-btn:hover { color: var(--text); border-color: var(--cyan); }
.st-btn.on, .st-btn.active { color: var(--cyan); border-color: rgba(0, 243, 255, 0.45); background: rgba(0, 243, 255, 0.06); }
.st-btn.hot { color: var(--mag); border-color: rgba(255, 0, 170, 0.4); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 0 rgba(14, 203, 129, 0.6); animation: pulse 1.4s infinite; display: inline-block; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(14,203,129,.55);} 100% { box-shadow: 0 0 0 10px transparent;} }

/* body */
.st-body {
  display: grid;
  grid-template-columns: var(--watch-w) minmax(0, 1fr) var(--rail-w);
  min-height: 0;
}
.st-app.stream .st-watch, .st-app.stream .st-rail, .st-app.stream .st-bot { display: none; }
.st-app.stream .st-body { grid-template-columns: minmax(0, 1fr); }

.st-watch, .st-rail, .st-center {
  min-height: 0; min-width: 0;
  border-right: 1px solid var(--line);
}
.st-rail { border-right: 0; border-left: 1px solid var(--line); display: grid; grid-template-rows: 1fr 1fr; }
.st-watch { display: flex; flex-direction: column; background: var(--bg2); }
.st-whead { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); }
.st-search {
  flex: 1; background: #08080e; border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 6px 8px; font-size: 12px;
}
.st-wtabs { display: flex; gap: 4px; padding: 6px 8px; }
.st-wtab, .st-tab {
  flex: 1; background: transparent; border: 1px solid transparent; color: var(--muted);
  border-radius: 6px; padding: 5px 4px; font-size: 10px; font-weight: 800; letter-spacing: 0.06em;
}
.st-wtab.on, .st-tab.on { color: var(--cyan); background: rgba(0, 243, 255, 0.06); border-color: var(--line); }
.st-list { overflow: auto; flex: 1; }
.st-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
  padding: 7px 10px; cursor: pointer; border-bottom: 1px solid rgba(28,28,40,0.6);
  font-size: 12px;
}
.st-row:hover { background: rgba(0, 243, 255, 0.04); }
.st-row.on { background: rgba(0, 243, 255, 0.08); }
.st-row .sym { font-weight: 800; letter-spacing: 0.03em; }
.st-row .px { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.st-row .chg { grid-column: 1 / -1; font-size: 11px; font-family: var(--mono); }
.up { color: var(--up); } .down { color: var(--down); }

.st-center { display: grid; grid-template-rows: var(--tool-h) minmax(220px, 1fr) auto var(--bot-h); }
.st-app.stream .st-center { grid-template-rows: var(--tool-h) minmax(0, 1fr) auto; }

.st-toolbar {
  display: flex; align-items: center; gap: 6px; padding: 0 8px;
  border-bottom: 1px solid var(--line); background: #09090f; overflow-x: auto;
}
.st-tf, .st-ico {
  background: transparent; border: 1px solid transparent; color: var(--muted);
  border-radius: 6px; padding: 3px 7px; font-size: 11px; font-weight: 700;
}
.st-tf.on, .st-ico.on { color: var(--cyan); border-color: var(--line2); background: #101018; }
.st-sep { width: 1px; height: 16px; background: var(--line); margin: 0 4px; flex: 0 0 1px; }
.st-select {
  background: #0c0c12; color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 6px; font-size: 11px;
}

.st-chartbox { position: relative; min-height: 0; background: #07070b; }
#chart, #pane-macd, #pane-rsi, #pane-wt, #pane-cvd { width: 100%; height: 100%; }
#drawLayer, #vpLayer {
  position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none;
}
#drawLayer.armed { pointer-events: auto; cursor: crosshair; }
.st-ohlc {
  position: absolute; top: 6px; left: 10px; z-index: 4;
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  pointer-events: none; text-shadow: 0 1px 2px #000;
}
.st-ohlc b { color: var(--text); margin-right: 8px; }
.st-edge {
  position: absolute; top: 6px; right: 62px; z-index: 4;
  display: flex; gap: 8px; align-items: center;
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
  padding: 4px 8px; border-radius: 7px; border: 1px solid var(--line); background: rgba(8,8,12,0.82);
}
.st-edge.long { color: var(--up); border-color: rgba(14,203,129,0.35); }
.st-edge.short { color: var(--down); border-color: rgba(246,70,93,0.35); }
.st-edge.flat { color: var(--muted); }

.st-panes { display: flex; flex-direction: column; background: #07070b; border-top: 1px solid var(--line); }
.st-pane { height: 92px; border-top: 1px solid var(--line); position: relative; }
.st-pane[hidden] { display: none; }
.st-plabel {
  position: absolute; top: 4px; left: 8px; z-index: 3;
  font-size: 10px; letter-spacing: 0.1em; color: var(--muted); pointer-events: none;
}

.st-bot { display: grid; grid-template-columns: 340px minmax(0, 1fr); border-top: 1px solid var(--line); min-height: 0; }
.st-ticket { padding: 10px 12px; border-right: 1px solid var(--line); background: #0a0a10; overflow: auto; }
.st-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.side-buy, .side-sell {
  border-radius: 8px; padding: 8px; font-weight: 800; letter-spacing: 0.08em; border: 1px solid var(--line);
}
.side-buy { background: rgba(14,203,129,0.08); color: var(--up); }
.side-sell { background: rgba(246,70,93,0.08); color: var(--down); }
.side-buy.on { background: var(--up); color: #04140d; border-color: var(--up); }
.side-sell.on { background: var(--down); color: #1a0408; border-color: var(--down); }
.st-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 7px; font-size: 11px; color: var(--muted); }
.st-field input, .st-field select {
  background: #08080e; border: 1px solid var(--line); color: var(--text);
  border-radius: 7px; padding: 7px 8px; font-family: var(--mono);
}
.st-lev { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.st-lev input { flex: 1; }
.st-submit {
  width: 100%; border: 0; border-radius: 8px; padding: 10px; font-weight: 800; letter-spacing: 0.08em; margin-top: 4px;
}
.st-submit.buy { background: var(--up); color: #04140d; }
.st-submit.sell { background: var(--down); color: #1a0408; }
.st-bal { font-size: 11px; color: var(--muted); margin: 6px 0 0; font-family: var(--mono); }

.st-bookkeep { display: flex; flex-direction: column; min-width: 0; background: #09090f; }
.st-tabs { display: flex; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.st-tablewrap { overflow: auto; flex: 1; }
table.st-table { width: 100%; border-collapse: collapse; font-size: 11px; font-family: var(--mono); }
.st-table th, .st-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(28,28,40,0.7); }
.st-table th { color: var(--muted); font-weight: 700; position: sticky; top: 0; background: #09090f; }

/* book + tape */
.st-book, .st-tape2 { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.st-book { border-bottom: 1px solid var(--line); }
.st-rh { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; font-size: 11px; color: var(--muted); }
.st-cols, .st-lvl, .st-tr {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px;
  font-family: var(--mono); font-size: 11px; padding: 1px 10px;
}
.st-cols { color: var(--muted); font-size: 10px; letter-spacing: 0.06em; }
.st-lvls { overflow: hidden; flex: 1; }
.st-lvl { position: relative; font-variant-numeric: tabular-nums; }
.st-lvl .bar { position: absolute; inset: 0; opacity: 0.18; }
.st-lvl.bid { color: var(--up); }
.st-lvl.ask { color: var(--down); }
.st-lvl.bid .bar { background: var(--up); right: auto; }
.st-lvl.ask .bar { background: var(--down); left: auto; }
.st-spread { text-align: center; padding: 5px; font-family: var(--mono); font-weight: 800; color: var(--gold); font-size: 12px; }
.st-trs { overflow: auto; flex: 1; }
.st-tr { font-variant-numeric: tabular-nums; }
.st-tr.buy { color: var(--up); }
.st-tr.sell { color: var(--down); }

/* modal / palette */
.st-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 40;
  display: none; place-items: start center; padding: 10vh 16px 16px;
}
.st-modal.show { display: grid; }
.st-card {
  width: min(720px, 100%); background: #0c0c14; border: 1px solid var(--line2);
  border-radius: 14px; padding: 12px; box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.st-card h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: 0.1em; color: var(--muted); }
.st-inds { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; max-height: 60vh; overflow: auto; }
.st-ind {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; background: #0a0a10;
}
.st-cmd input {
  width: 100%; background: #08080e; border: 1px solid var(--line2); color: var(--text);
  border-radius: 10px; padding: 12px 14px; font-size: 15px;
}
.st-cmdlist { margin-top: 8px; max-height: 50vh; overflow: auto; }
.st-cmditem { padding: 8px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; }
.st-cmditem:hover, .st-cmditem.on { background: rgba(0,243,255,0.08); }

/* stream hud extras */
.st-watermark {
  position: absolute; left: 16px; bottom: 14px; z-index: 5; pointer-events: none;
  font-weight: 900; letter-spacing: 0.18em; color: rgba(0,243,255,0.22); font-size: 18px;
}
.st-lower {
  position: absolute; left: 16px; right: 16px; bottom: 18px; z-index: 5;
  display: none; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: 12px;
  background: linear-gradient(90deg, rgba(8,8,12,0.92), rgba(20,8,18,0.88));
  border: 1px solid rgba(0,243,255,0.25);
}
.st-app.stream .st-lower { display: flex; }
.st-lower .big { font-size: 28px; font-weight: 900; font-family: var(--mono); }
.st-lower .tag { color: var(--cyan); letter-spacing: 0.16em; font-size: 12px; font-weight: 800; }

.st-toast {
  position: fixed; right: 14px; bottom: 14px; z-index: 50;
  background: #12121a; border: 1px solid var(--line2); color: var(--text);
  border-radius: 10px; padding: 10px 12px; font-size: 12px; display: none;
}

.st-mobnav { display: none; }

@media (max-width: 1100px) {
  .st-meta { display: none; }
  .st-body { grid-template-columns: 0 minmax(0, 1fr) 0; }
  .st-watch, .st-rail { display: none; }
  .st-body.show-watch { grid-template-columns: 1fr 0 0; }
  .st-body.show-watch .st-watch { display: flex; }
  .st-body.show-watch .st-center, .st-body.show-watch .st-rail { display: none; }
  .st-body.show-book { grid-template-columns: 0 0 1fr; }
  .st-body.show-book .st-rail { display: grid; }
  .st-body.show-book .st-center, .st-body.show-book .st-watch { display: none; }
  .st-center { grid-template-rows: var(--tool-h) minmax(180px, 1fr) auto minmax(160px, 38vh); }
  .st-bot { grid-template-columns: 1fr; }
  .st-mobnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: #09090f; border-top: 1px solid var(--line);
  }
  .st-mobnav button { flex: 1; background: transparent; border: 0; color: var(--muted); padding: 10px 4px 14px; font-size: 11px; font-weight: 800; }
  .st-mobnav button.on { color: var(--cyan); }
  .st-app { padding-bottom: 48px; }
}

@media (max-width: 640px) {
  .st-top { grid-template-columns: 1fr; height: auto; padding: 8px; }
  .st-app { grid-template-rows: var(--tape-h) auto minmax(0, 1fr); }
  .st-last { font-size: 18px; }
  .st-actions { flex-wrap: wrap; }
}
