:root {
  --deep: #0a1026;
  --night: #0d1430;
  --panel: #141d40;
  --panel-2: #1a2550;
  --line: #28356b;
  --ink: #e7ebf7;
  --mute: #8b96c0;
  --amber: #ffb000;
  --amber-2: #ffd36b;
  --amber-dim: #6f5418;
  --acc-ink: #201600;
  --bid: #3ddc84;
  --ask: #ff5468;
  --cyan: #5ec8ff;
  --red: #e5484d;
  --shadow: #05081a;
  --px: 'Silkscreen', ui-monospace, monospace;
  --tt: 'VT323', ui-monospace, monospace;
  --top-h: 60px;
  --tape-h: 32px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--deep);
  color: var(--ink);
  font-family: var(--tt);
  font-size: 20px;
  line-height: 1.2;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ---------- header */
.top {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--night);
  border-bottom: 2px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--px);
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  margin-right: 8px;
}
.chain-badge {
  font-family: var(--px);
  font-size: 10px;
  padding: 3px 7px;
  color: var(--amber);
  border: 2px solid var(--amber-dim);
  white-space: nowrap;
}
.nav { display: flex; gap: 2px; margin-right: auto; }
.tab {
  background: none;
  border: 0;
  padding: 8px 10px;
  font-family: var(--px);
  font-size: 12px;
  color: var(--mute);
}
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--amber); box-shadow: inset 0 -2px 0 var(--amber); }

.ca {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 4px 10px;
  background: var(--panel-2);
  border: 2px solid var(--line);
  font-size: 20px;
}
.ca b { font-family: var(--px); font-size: 12px; color: var(--amber); }
.ca span { color: var(--mute); }
.ca button {
  border: 0;
  background: var(--line);
  padding: 2px 8px;
  font-family: var(--px);
  font-size: 10px;
}
.ca button:disabled { opacity: .45; cursor: default; }

.xlink {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-family: var(--px);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}

.btn {
  font-family: var(--px);
  font-size: 12px;
  padding: 9px 14px;
  border: 2px solid var(--shadow);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .22), 0 3px 0 var(--shadow);
  transform: translateY(-2px);
  transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .22), 0 0 0 var(--shadow); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.hire { background: var(--amber); color: var(--acc-ink); }
.btn.hire:hover { background: var(--amber-2); }
.btn.squawk { background: var(--red); color: #fff; }
.btn.squawk.is-live { animation: blink .5s steps(2) infinite; }
.btn.ghost { background: var(--panel-2); color: var(--ink); border-color: var(--line); box-shadow: 0 3px 0 var(--shadow); }
.btn.wide { width: 100%; padding: 12px; }
@keyframes blink { 50% { background: #7a1c22; } }

/* ---------- tape */
.tape {
  height: var(--tape-h);
  overflow: hidden;
  background: #050915;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
  font-size: 22px;
  line-height: calc(var(--tape-h) - 2px);
}
.tape-track { display: inline-block; animation: tape 70s linear infinite; }
.tk { display: inline-block; padding: 0 18px; border-right: 1px solid #1d2754; }
.tk b { color: var(--amber); font-weight: 400; }
.tk i { font-style: normal; color: var(--ink); margin: 0 6px; }
.up { color: var(--bid); }
.dn { color: var(--ask); }
.tk.zz b { color: var(--mute); }
@keyframes tape { to { transform: translateX(-50%); } }

/* ---------- floor layout */
.floor {
  position: relative;
  display: grid;
  grid-template-rows: clamp(320px, 58dvh, 640px) minmax(0, 1fr);
  height: calc(100dvh - var(--top-h) - var(--tape-h));
}
.stage { position: relative; min-width: 0; overflow: hidden; background: #070b1a; }
#scene {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: pan-y;
  image-rendering: pixelated;
}
#scene.is-drag { cursor: grabbing; }
#scene.is-hot { cursor: pointer; }
#scene:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }

.hud { position: absolute; left: 16px; bottom: 48px; display: flex; gap: 8px; pointer-events: none; }
.pill {
  font-family: var(--px);
  font-size: 11px;
  padding: 5px 9px;
  background: rgba(10, 16, 38, .86);
  border: 2px solid var(--line);
}
.pill.demo { color: var(--amber); border-color: var(--amber-dim); pointer-events: auto; }

.seatmap {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 14px;
  height: 26px;
  padding: 4px 0;
  background: rgba(5, 9, 21, .88);
  border: 2px solid var(--line);
}
.seatmap-row { display: flex; height: 100%; }
.seatmap-row > * { flex: var(--w) 1 0; min-width: 0; }
.cell {
  margin: 0 1px;
  border: 0;
  padding: 0;
  background: #26315e;
}
.cell.up { background: var(--bid); }
.cell.dn { background: var(--ask); }
.cell.zz { background: #3a4266; }
.cell.open { background: transparent; box-shadow: inset 0 0 0 1px var(--amber); animation: open 1.2s steps(2) infinite; }
.cell.head { box-shadow: inset 0 0 0 2px var(--amber); }
.cell.sel { outline: 2px solid #fff; outline-offset: 1px; }
@keyframes open { 50% { box-shadow: inset 0 0 0 1px var(--amber-dim); } }
.seatmap-view {
  position: absolute;
  top: -4px;
  bottom: -4px;
  border: 2px solid var(--amber);
  pointer-events: none;
}
.hint {
  position: absolute;
  right: 16px;
  bottom: 50px;
  margin: 0;
  font-size: 18px;
  color: var(--mute);
  pointer-events: none;
  text-shadow: 0 2px 0 var(--shadow);
  transition: opacity .6s;
}
.hint.is-gone { opacity: 0; }

/* ---------- terminal panels under the desk */
.panels {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr) minmax(0, .9fr);
  min-height: 0;
  background: var(--night);
  border-top: 2px solid var(--line);
}
.side-tabs { display: none; }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; container-type: inline-size; }
.pane + .pane { border-left: 2px solid var(--line); }
.pane h2 {
  margin: 0;
  padding: 10px 14px 8px;
  font-family: var(--px);
  font-size: 13px;
  font-weight: 400;
  color: var(--amber);
}
.pane h2 small { font-size: 10px; color: var(--mute); margin-left: 6px; }
.rows { list-style: none; margin: 0; padding: 0 0 8px; overflow-y: auto; flex: 1; min-height: 0; }
.blotter li {
  display: grid;
  grid-template-columns: 70px 72px 46px 1fr;
  gap: 4px;
  padding: 1px 14px;
  font-size: 19px;
  white-space: nowrap;
}
.blotter li time { color: var(--mute); }
.blotter li b { color: var(--amber); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.blotter li .s-buy { color: var(--bid); }
.blotter li .s-sell { color: var(--ask); }
.blotter li .s-info { color: var(--cyan); }
.blotter li .r { overflow: hidden; text-overflow: ellipsis; }
.blotter li.new { animation: fresh 1.2s steps(4); }

.seat-head, .seat-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 74px 70px 92px 52px;
  gap: 6px;
  padding: 1px 14px;
  white-space: nowrap;
}
.seat-head { font-size: 16px; color: var(--mute); padding-bottom: 2px; }
.seat-head span:nth-child(n+3), .seat-row > span:nth-child(n+3) { text-align: right; }
.seat-row {
  width: 100%;
  border: 0;
  background: none;
  font-size: 19px;
  text-align: left;
}
.seat-row:hover, .seat-row.sel { background: color-mix(in srgb, var(--amber) 10%, transparent); }
.seat-row > span { overflow: hidden; text-overflow: ellipsis; }
.seat-row .n { color: var(--mute); }
.seat-row b { color: var(--amber); font-weight: 400; }
.seat-row .nm { color: var(--mute); margin-left: 6px; }
.seat-row.zz b, .seat-row.zz span { color: var(--mute); }
.scr { display: inline-flex; gap: 2px; justify-content: flex-end; }
.scr i { width: 5px; height: 9px; background: #232d58; }
.scr i.on { background: var(--amber); }
@container (max-width: 470px) {
  .seat-head, .seat-row { grid-template-columns: 26px minmax(0, 1fr) 70px 92px 52px; }
  .seat-head span:nth-child(3), .seat-row > span:nth-child(3) { display: none; }
}
@container (max-width: 360px) {
  .seat-head, .seat-row { grid-template-columns: 22px minmax(0, 1fr) 64px 86px; }
  .seat-head span:nth-child(6), .seat-row > span:nth-child(6) { display: none; }
  .seat-row .nm { display: none; }
}
@keyframes fresh { from { background: color-mix(in srgb, var(--amber) 18%, transparent); } }

.chat li { padding: 2px 14px; font-size: 19px; overflow-wrap: anywhere; }
.chat li b { font-weight: 400; color: var(--cyan); margin-right: 6px; }
.chat li.me b { color: var(--amber); }
.chat li.sys { color: var(--mute); }
.chat-form { display: flex; gap: 6px; padding: 8px 12px 12px; }
.chat-form input {
  flex: 1;
  min-width: 0;
  background: #0b1230;
  border: 2px solid var(--line);
  padding: 4px 8px;
}
.chat-form button {
  font-family: var(--px);
  font-size: 11px;
  background: var(--panel-2);
  border: 2px solid var(--line);
  padding: 0 10px;
}

/* ---------- agent drawer */
.agent {
  position: fixed;
  top: calc(var(--top-h) + var(--tape-h));
  right: 0;
  bottom: 0;
  width: 360px;
  overflow-y: auto;
  background: var(--panel);
  border-left: 2px solid var(--amber);
  padding: 16px 16px 24px;
  z-index: 5;
}
.agent[hidden] { display: none; }
.ag-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: 0;
  font-size: 30px;
  line-height: 1;
  color: var(--mute);
}
.ag-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.ag-head canvas {
  width: 84px;
  height: 114px;
  image-rendering: pixelated;
  background: #0b1230;
  border: 2px solid var(--line);
  flex: none;
}
.ag-name { margin: 0; font-family: var(--px); font-size: 17px; font-weight: 700; }
.ag-tick { margin: 4px 0 8px; color: var(--amber); font-size: 22px; }
.status {
  display: inline-block;
  font-family: var(--px);
  font-size: 10px;
  padding: 3px 7px;
  border: 2px solid currentColor;
}
.st-type { color: var(--bid); }
.st-think { color: var(--cyan); }
.st-sleep { color: var(--mute); }
.st-win { color: var(--bid); }
.st-loss { color: var(--ask); }
.st-stand { color: var(--amber); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin: 0 0 14px; }
.stats div { background: #0f1736; padding: 6px 8px; }
.stats dt { font-size: 16px; color: var(--mute); }
.stats dd { margin: 0; font-size: 24px; }

.ag-sec { margin: 0 0 14px; }
.ag-sec h3 { margin: 0 0 6px; font-family: var(--px); font-size: 11px; font-weight: 400; color: var(--mute); }
.split { display: flex; height: 12px; margin-bottom: 4px; }
.split i { display: block; }
.split .t { background: var(--bid); }
.split .b { background: var(--cyan); }
.split .d { background: var(--amber); }
.split-legend { display: flex; justify-content: space-between; font-size: 17px; color: var(--mute); }
.k-t { color: var(--bid); font-weight: 400; }
.k-b { color: var(--cyan); font-weight: 400; }
.k-d { color: var(--amber); font-weight: 400; }
.directive { margin: 0; padding: 8px 10px; background: #0f1736; border-left: 2px solid var(--amber); font-size: 19px; }
.rules { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; font-size: 18px; margin: 0; }
.rules dt { color: var(--mute); }
.rules dd { margin: 0 0 4px; }
.mini { list-style: none; margin: 0; padding: 0; font-size: 18px; }
.mini li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px solid #1d2754; }
.mini li span:first-child { color: var(--mute); flex: none; }
.mini .empty { color: var(--mute); border: 0; }
.thoughts li span:last-child { text-align: right; }
.ag-buy { width: 100%; margin-top: 4px; }

/* ---------- dialogs */
.dlg {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 22px 24px 24px;
  background: var(--panel);
  color: var(--ink);
  border: 2px solid var(--line);
  box-shadow: 0 6px 0 var(--shadow);
  overflow-y: auto;
}
.dlg::backdrop { background: rgba(3, 6, 18, .72); }
.dlg h2 { margin: 0 0 12px; font-family: var(--px); font-size: 20px; color: var(--amber); }
.dlg-close { position: absolute; top: 8px; right: 10px; }
.dlg-close button { background: none; border: 0; font-size: 30px; line-height: 1; color: var(--mute); }
.dlg-close button:hover { color: var(--ink); }
.how-list { margin: 0 0 14px; }
.how-list div { padding: 8px 0; border-bottom: 1px solid #22305f; }
.how-list dt { font-family: var(--px); font-size: 12px; color: var(--ink); margin-bottom: 2px; }
.how-list dd { margin: 0; color: #c4cbe6; max-width: 62ch; }
.keys { color: var(--mute); }
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 0 5px;
  margin: 0 2px;
  text-align: center;
  background: #0b1230;
  border: 2px solid var(--line);
  border-bottom-width: 3px;
  color: var(--ink);
  font-family: var(--tt);
}
.note { color: var(--amber); font-size: 18px; margin: 0 0 14px; }

.hire-dlg { width: min(900px, calc(100vw - 32px)); }
.lead { margin: 0 0 16px; color: #c4cbe6; max-width: 70ch; }
.hire-grid { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 22px; }
.hire-look { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
#hirePreview {
  width: 100%;
  aspect-ratio: 28 / 38;
  height: auto;
  image-rendering: pixelated;
  background:
    linear-gradient(#0b1230 0 70%, #151d3d 70% 100%);
  border: 2px solid var(--line);
}
.hire-fields { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.hire-fields label { display: flex; flex-direction: column; gap: 4px; font-family: var(--px); font-size: 11px; color: var(--mute); }
.hire-fields .sub { font-family: var(--tt); font-size: 16px; }
.hire-fields input, .hire-fields select, .hire-fields textarea {
  font-family: var(--tt);
  font-size: 20px;
  color: var(--ink);
  background: #0b1230;
  border: 2px solid var(--line);
  padding: 5px 8px;
  width: 100%;
}
.hire-fields textarea { resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.hire-fields label.short { max-width: 220px; }
.opts { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.opts legend { font-family: var(--px); font-size: 11px; color: var(--mute); padding: 0; margin-bottom: 6px; }
.opt-row { display: grid; grid-template-columns: 92px 1fr; align-items: center; gap: 8px; }
.opt-row > span { font-size: 18px; color: var(--mute); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  font-family: var(--px);
  font-size: 10px;
  padding: 4px 7px;
  background: #0f1736;
  border: 2px solid var(--line);
}
.chip[aria-pressed="true"] { border-color: var(--amber); color: var(--amber); }
.sw { width: 22px; height: 22px; padding: 0; border: 2px solid var(--line); }
.sw[aria-pressed="true"] { border-color: var(--amber); box-shadow: 0 0 0 2px var(--amber); }
.err { color: var(--ask); margin: 0; min-height: 0; }
.err:empty { display: none; }
.hire-foot { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; }
.hire-foot .note { margin: 0; max-width: 46ch; }
.hire-foot .btn { padding: 12px 28px; font-size: 14px; flex: none; }

/* ---------- toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  background: var(--panel-2);
  border: 2px solid var(--amber);
  box-shadow: 0 4px 0 var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- live data bits */
.pill.state::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; background: currentColor; vertical-align: 1px; }
.pill.state.live { color: var(--bid); border-color: #1f6b44; }
.pill.state.live::before { animation: pulse 1.6s steps(2) infinite; }
.pill.state.wait { color: var(--amber); border-color: var(--amber-dim); }
.pill.state.down { color: var(--ask); border-color: #6b1f2a; }
@keyframes pulse { 50% { opacity: .3; } }
.rows .empty, .mini .empty { color: var(--mute); padding: 4px 14px; }
.mini .empty { padding: 2px 0; }
.launches li time { color: var(--mute); margin-right: 6px; }
.launches li a { color: inherit; text-decoration: none; }
.launches li a:hover b { text-decoration: underline; }
.launches li b { color: var(--amber); font-weight: 400; margin-right: 4px; }
.launches li .s-buy { color: var(--bid); }
.ag-ca { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; font-size: 18px; color: var(--mute); }
.ag-ca code { font-family: var(--tt); font-size: 19px; color: var(--ink); }
.ag-ca button { font-family: var(--px); font-size: 10px; background: var(--line); border: 0; padding: 2px 8px; }
.mini li span:nth-child(3) { color: var(--mute); flex: none; }
.ag-links { display: flex; gap: 8px; margin-top: 6px; }
.ag-links .btn { flex: 1; text-align: center; text-decoration: none; }
@media (prefers-reduced-motion: reduce) { .pill.state.live::before { animation: none; } }

/* ---------- small screens */
@media (max-width: 980px) {
  .ca span { display: none; }
  .nav .tab#deskTab { display: none; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  .top { height: auto; min-height: var(--top-h); flex-wrap: wrap; gap: 8px; padding: 8px 16px; }
  .brand { margin-right: auto; }
  .nav { order: 5; margin-right: 0; }
  .ca, .xlink { display: none; }
  .btn { padding: 8px 10px; font-size: 11px; }
  .floor { grid-template-rows: auto; height: auto; }
  .stage { height: 54dvh; min-height: 300px; }
  .hint { display: none; }
  .panels { grid-template-columns: 1fr; }
  .side-tabs { display: flex; }
  .side-tabs button {
    flex: 1;
    font-family: var(--px);
    font-size: 12px;
    padding: 10px;
    background: var(--night);
    border: 0;
    border-bottom: 2px solid var(--line);
    color: var(--mute);
  }
  .side-tabs button[aria-selected="true"] { color: var(--amber); border-bottom-color: var(--amber); }
  .pane { display: none; height: 46dvh; }
  .pane.is-on { display: flex; }
  .pane + .pane { border-left: 0; }
  .pane h2 { display: none; }
  .rows { padding-top: 6px; }
  .agent {
    top: auto;
    left: 0;
    width: auto;
    max-height: 78dvh;
    border-left: 0;
    border-top: 2px solid var(--amber);
    box-shadow: 0 -6px 0 var(--shadow);
  }
  .hire-grid { grid-template-columns: 1fr; }
  .hire-look { flex-direction: row; align-items: flex-end; }
  #hirePreview { width: 120px; }
  .row4 { grid-template-columns: 1fr 1fr; }
  .opt-row { grid-template-columns: 1fr; gap: 4px; }
  .hire-foot { flex-direction: column; align-items: stretch; }
  .dlg { padding: 18px 16px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .tape { overflow-x: auto; }
  .tape-track { animation: none; }
  .btn.squawk.is-live, .cell.open { animation: none; }
  .toast { transition: none; }
}
