:root {
  --floor: #0d0a1a;
  --floor-2: #161130;
  --panel: #18122f;
  --line: #2e2552;
  --ink: #f1ecff;
  --muted: #9a90c2;
  --neon: #ff3ea5;
  --neon-2: #5ba8ff;
  --scout: #f2c94c;
  --news: #ff6b6b;
  --senti: #c08bff;
  --charts: #5ba8ff;
  --risk: #3ee08f;
  --decide: #ff9a3c;
  --up: #3ee08f;
  --down: #ff6b6b;
  --warn: #f2c94c;
  --pixel: "Silkscreen", ui-monospace, monospace;
  --sans: "IBM Plex Sans", "Noto Sans TC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--floor); color: var(--ink); font-family: var(--sans); }
body {
  padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto; line-height: 1.45; font-size: 15px;
  background-image:
    radial-gradient(1200px 600px at 50% -200px, rgba(255, 62, 165, .16), transparent 70%),
    linear-gradient(rgba(46, 37, 82, .45) 1px, transparent 1px),
    linear-gradient(90deg, rgba(46, 37, 82, .45) 1px, transparent 1px);
  background-size: auto, 24px 24px, 24px 24px;
  background-attachment: fixed, scroll, scroll;
}
button { font: inherit; color: inherit; }
.num, .metrics dd, .nav-value, td.n { font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 12px; }
.brand { font-family: var(--pixel); font-weight: 400; font-size: 22px; letter-spacing: 1px; margin: 0;
  color: #fff; text-shadow: 0 0 6px var(--neon), 0 0 18px rgba(255, 62, 165, .6); }
.top-meta { display: flex; align-items: center; gap: 10px; }
.mode { font-family: var(--pixel); font-size: 12px; padding: 4px 8px; border: 2px solid var(--scout); color: var(--scout);
  box-shadow: 0 0 10px rgba(242, 201, 76, .35) inset; }
.beat { width: 12px; height: 12px; background: var(--down); box-shadow: 0 0 0 2px var(--floor); }
.beat.ok { background: var(--up); box-shadow: 0 0 0 2px var(--floor), 0 0 10px var(--up); animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 50% { opacity: .35; } }

.banner { border: 2px solid var(--down); background: #3a1d2a; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }

/* ---------- the memorable element: the live trading floor ---------- */
.room { position: relative; margin: 0 -4px 18px; padding: 8px; background: #08060f;
  border: 2px solid var(--neon); box-shadow: 0 0 0 1px #3a0f2a, 0 0 24px rgba(255, 62, 165, .45), inset 0 0 24px rgba(255, 62, 165, .18); }
.room::before, .room::after { content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid #fff; }
.room::before { top: -6px; left: -6px; border-right: 0; border-bottom: 0; }
.room::after { bottom: -6px; right: -6px; border-left: 0; border-top: 0; }
.room-head { display: flex; justify-content: space-between; align-items: center; font-family: var(--pixel); font-size: 11px; color: var(--muted); padding: 0 2px 6px; }
.live { color: #fff; background: var(--neon); padding: 2px 6px; letter-spacing: 1px; }
.live.off { background: #4a4468; }
.room-stage { position: relative; width: 100%; aspect-ratio: 160 / 134; }
#roomCanvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
.room-stage::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 1px, transparent 1px 3px); }
#roomLabels { position: absolute; inset: 0; }
.desk-tag { position: absolute; transform: translate(-50%, 0); border: 0; padding: 1px 4px; cursor: pointer; text-align: center;
  background: rgba(8, 6, 15, .78); color: var(--c); font-family: var(--pixel); font-size: 9px; line-height: 1.25; white-space: nowrap; z-index: 2; }
.desk-tag span { display: block; font-family: var(--sans); font-size: 10px; color: var(--ink); }
.desk-tag span.dn { color: var(--down); } .desk-tag span.upc { color: var(--up); } .desk-tag span.zz { color: var(--muted); }
.desk-tag[aria-pressed="true"] { outline: 1px solid var(--c); box-shadow: 0 0 10px var(--c); }
.wall-tag { position: absolute; left: 19.5%; top: 4.6%; font-family: var(--pixel); font-size: 8px; color: var(--neon); letter-spacing: 1px; z-index: 2; }
.ticker { overflow: hidden; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 6px; white-space: nowrap;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
.ticker-track { display: inline-block; font-family: var(--pixel); font-size: 11px; color: #c9c1ee; animation: tick 38s linear infinite; padding-left: 100%; }
.ticker-track b { color: var(--neon); font-weight: 400; margin: 0 6px; }
@keyframes tick { to { transform: translateX(-100%); } }

/* ---------- account ---------- */
.account { background: linear-gradient(180deg, #1d1540, var(--panel)); border: 1px solid #4a2c6e; padding: 14px; margin-bottom: 14px;
  box-shadow: 0 0 0 1px rgba(255, 62, 165, .15), 0 10px 30px rgba(0, 0, 0, .35); }
.pf-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; scrollbar-width: none; }
.pf-tabs button {
  background: transparent; border: 2px solid var(--line); padding: 6px 10px; font-size: 12px;
  white-space: nowrap; cursor: pointer; color: var(--muted);
}
.pf-tabs button[aria-selected="true"] { border-color: var(--neon); color: #fff; box-shadow: 0 0 10px rgba(255, 62, 165, .5); }
.nav-label { color: var(--muted); font-size: 13px; }
.nav-value { font-family: var(--pixel); font-size: 42px; line-height: 1.1; margin: 2px 0 6px; color: #fff; text-shadow: 0 0 14px rgba(91, 168, 255, .55); }
.nav-sub { display: flex; gap: 18px; color: var(--muted); font-size: 13px; }
.nav-sub b { color: var(--ink); font-weight: 500; }
.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; margin: 14px 0 0; }
.metrics div { border-top: 1px solid var(--line); padding-top: 6px; }
.metrics dt { color: var(--muted); font-size: 12px; }
.metrics dd { margin: 0; font-size: 16px; font-weight: 500; }

.up { color: var(--up); } .down { color: var(--down); } .na { color: var(--muted); font-size: 13px; }
.unavail { color: var(--warn); font-size: 12px; font-weight: 500; }

/* ---------- cards ---------- */
.card { background: rgba(24, 18, 47, .94); border: 1px solid var(--line); padding: 14px; margin-bottom: 14px; position: relative; }
.card::before { content: ""; position: absolute; left: -1px; top: -1px; width: 22px; height: 2px; background: var(--neon); box-shadow: 0 0 8px var(--neon); }
h2 { font-size: 16px; font-weight: 700; margin: 0 0 10px; letter-spacing: .5px; }
h3 { font-size: 14px; font-weight: 600; margin: 16px 0 8px; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 0 0; }

.equity svg { width: 100%; height: 180px; display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; }

.funnel { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; text-align: center; }
.funnel div { padding: 8px 2px; background: var(--floor-2); border-bottom: 3px solid var(--c, var(--line)); }
.funnel b { display: block; font-family: var(--pixel); font-size: 18px; font-weight: 400; color: #fff; text-shadow: 0 0 8px var(--c, transparent); }
.funnel span { font-size: 11px; color: var(--muted); }

.radar .row, #closedPos .row, .pos {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px; margin-bottom: 8px;
  background: var(--floor-2); border-left: 4px solid var(--c, var(--line)); cursor: pointer; width: 100%; text-align: left; border-top: 0; border-right: 0; border-bottom: 0;
}
.row .sym { font-weight: 600; }
.row .tag { font-family: var(--pixel); font-size: 11px; }
.row .meta { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 0; }

.pos { cursor: default; grid-template-columns: repeat(3, 1fr); font-size: 13px; }
.pos .h { grid-column: 1 / -1; display: flex; justify-content: space-between; font-weight: 600; font-size: 14px; }
.pos small { display: block; color: var(--muted); font-size: 11px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
td.n, th.n { text-align: right; }

.status-list { list-style: none; padding: 0; margin: 0; }
.status-list li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

details.sub { margin-top: 10px; }
details.sub summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 6px 0; }

.sheet { width: min(720px, 100vw); max-width: 100vw; max-height: 92vh; margin: auto auto 0; padding: 0 16px 24px;
  background: var(--floor); color: var(--ink); border: 2px solid var(--neon); border-bottom: 0; box-shadow: 0 -10px 40px rgba(255, 62, 165, .3); }
.sheet::backdrop { background: rgba(8, 4, 18, .75); }
.sheet-head { position: sticky; top: 0; background: var(--floor); display: flex; justify-content: space-between; align-items: center; padding: 14px 0 8px; }
.sheet-head button { background: none; border: 0; font-size: 18px; cursor: pointer; }
.sheet details { border: 2px solid var(--line); background: var(--panel); margin-bottom: 8px; }
.sheet summary { padding: 10px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.sheet summary b { font-weight: 600; }
.sheet .body { padding: 0 12px 12px; font-size: 13px; }
.sheet pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: var(--floor-2); padding: 8px; margin: 0; max-height: 320px; overflow: auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.foot { color: var(--muted); font-size: 12px; text-align: center; margin-top: 18px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } .ticker-track { padding-left: 0; white-space: normal; } }

.board th, .board td { white-space: nowrap; font-size: 12px; padding: 7px 3px; }
.board td:nth-child(2) { white-space: normal; }
.board tr { cursor: pointer; }
.board tr.sel td { background: rgba(255, 62, 165, .08); }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; box-shadow: 0 0 6px currentColor; }

button.pos { font: inherit; color: inherit; text-align: left; width: 100%; border-top: 0; border-right: 0; border-bottom: 0; cursor: pointer; }
.pos .why { grid-column: 1 / -1; font-size: 12px; display: block; }
.pos[data-setup] { cursor: pointer; }
