/* MonarqiLabs Trading Desk — v7 redesign
   Target: dense, readable, professional dark fintech (Stockbit / Bibit bar).
   Rules applied (anti-slop):
   - Off-black (#05070b), never pure black. Single accent = teal, no neon glows.
   - No gradient text, no violet+teal neon gradients, no outer-glow shadows.
   - Tabular mono numerals, right-aligned, minimum 9px labels.
   - Flat surfaces with 1px zinc borders, generous rounded corners.
   - Motion only via transform/opacity.
   - Agent cards: 1-col feed (right col, wider); viewport is locked,
     only #agent-grid and #news-list scroll internally.
   - Holdings + thinking always visible inside each card (no clipping).
*/

:root {
  --bg: #05070b;
  --surface: #0b0e15;
  --surface-2: #0e1219;
  --card: #0d1119;
  --card-2: #10151f;
  --line: rgba(255,255,255,0.07);
  --line-2: rgba(255,255,255,0.12);
  --ink: #f2f5f9;
  --ink-2: #c3ccd8;
  --muted: #7a8595;
  --faint: #5a6473;
  --teal: #17e3c4;
  --teal-dim: rgba(23,227,196,0.12);
  --up: #34d399;
  --up-soft: rgba(52,211,153,0.14);
  --down: #fb7185;
  --down-soft: rgba(251,113,133,0.14);
  --amber: #fbbf24;
  --shock: #ff453a;      /* shocks are red: amber read as a soft warning */
  --radius: 16px;
  --radius-sm: 11px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  gap: 11px;
  background: var(--bg);
  overflow: hidden;
}
::selection { background: rgba(23,227,196,0.28); color: #fff; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
::-webkit-scrollbar-track { background: transparent; }

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.2px; }
.up { color: var(--up); }
.down { color: var(--down); }

/* ================= Header ================= */
#topbar {
  display: flex; align-items: center; gap: 16px;
  flex-shrink: 0; height: 40px;
}
.brand-wrap { display: flex; align-items: baseline; gap: 9px; flex-shrink: 0; }
.brand { font-size: 16px; font-weight: 800; letter-spacing: 0.5px; color: #fff; }
.brand .accent { color: var(--teal); font-weight: 800; }
.brand-sub { font-size: 11px; color: var(--faint); font-weight: 600; letter-spacing: 0.4px; }
#dash-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); font-weight: 600;
  white-space: nowrap; overflow: hidden;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--up); flex-shrink: 0;
  box-shadow: 0 0 0 3px var(--up-soft); }
.live-dot.off { background: var(--faint); box-shadow: none; }
.meta-sep { color: rgba(255,255,255,0.16); }
/* ---- Hero day module: big, significant current-day indicator ---- */
.day-hero {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #111827 0%, #0c1220 100%);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 8px;
  box-shadow: 0 4px 22px rgba(0,0,0,0.35);
  position: relative; overflow: hidden;
}
.day-hero::after {
  content: ""; position: absolute; right: -40px; top: -40px;
  width: 170px; height: 170px;
  background: radial-gradient(circle, rgba(23,227,196,0.09) 0%, transparent 70%);
  pointer-events: none;
}
.day-hero.shock { border-color: rgba(255,180,67,0.4); box-shadow: 0 4px 24px rgba(255,180,67,0.07); }
.day-hero.shock::after { background: radial-gradient(circle, rgba(255,180,67,0.10) 0%, transparent 70%); }
.dh-left { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dh-eyebrow { font-size: 9.5px; font-weight: 800; letter-spacing: 1.6px; color: var(--teal); text-transform: uppercase; }
.day-hero.shock .dh-eyebrow { color: var(--amber); }
.dh-num {
  font-family: var(--mono); font-weight: 800;
  font-size: 46px; line-height: 1.05; color: #fff;
  letter-spacing: -1.5px; white-space: nowrap;
}
.dh-num .dh-total { font-size: 17px; font-weight: 600; color: var(--faint); letter-spacing: 0; margin-left: 2px; }
.dh-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.dh-pct { font-family: var(--mono); font-size: 10px; color: var(--faint); }
.dh-bar { width: 110px; height: 4px; background: var(--card-2); border-radius: 999px; overflow: hidden; }
.dh-bar i { display: block; height: 100%; background: var(--teal); border-radius: 999px; transition: width .3s var(--ease); }
.day-hero.shock .dh-bar i { background: var(--amber); }
#ctrl-cluster { display: flex; align-items: center; gap: 7px; margin-left: auto; flex-shrink: 0; }
button {
  font-family: var(--font); font-size: 12px; font-weight: 600;
  color: var(--ink-2); background: var(--card-2);
  border: 1px solid var(--line-2); border-radius: 9px;
  padding: 6px 12px; cursor: pointer;
  transition: background .16s var(--ease), color .16s var(--ease), border-color .16s var(--ease);
}
button:hover { background: #141b26; color: #fff; border-color: rgba(255,255,255,0.2); }
button.active { background: var(--teal-dim); border-color: rgba(23,227,196,0.4); color: var(--teal); }
#btn-step {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.4px;
  font-weight: 700;
  background: rgba(23,227,196,0.10); border-color: rgba(23,227,196,0.45);
  color: var(--teal);
  padding: 6px 14px;
}
#btn-step:hover { background: var(--teal-dim); color: var(--teal); border-color: rgba(23,227,196,0.4); }
#btn-step:active { background: rgba(23,227,196,0.25); }

/* ---- Day digest (compact per-day summary line) ---- */
#day-digest {
  flex: 0 1 auto; min-height: 0; max-height: 46%;
  overflow-y: auto; margin-bottom: 8px;
  background: var(--card-2); border: 1px solid var(--line-2);
  border-radius: 9px; padding: 8px 10px;
}
.dd-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: 10.5px; line-height: 1.6;
}
.dd-fills {
  color: var(--muted); font-weight: 600; font-size: 10px;
}
.dd-reason {
  color: var(--faint); font-size: 10px; flex: 1; min-width: 80px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dd-reason b { color: var(--ink-2); font-weight: 700; }
.dd-reflect {
  color: var(--faint); font-style: italic; font-size: 10px;
}
.dd-best {
  font-family: var(--mono); font-weight: 700; font-size: 10px;
}
.dd-best.up { color: var(--up); }
.dd-best.down { color: var(--down); }
.dd-news {
  color: var(--faint); font-size: 10px; font-style: italic;
  flex: 1; min-width: 80px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.seek { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.seek input[type="range"] {
  -webkit-appearance: none; width: 130px; height: 4px; border-radius: 999px;
  background: var(--line-2); outline: none;
}
.seek input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: #fff; border: 2px solid var(--teal); cursor: pointer;
  box-shadow: 0 0 0 3px var(--teal-dim); transition: transform .12s var(--ease);
}
.seek input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }

/* ================= KPI strip =================
   Four signal cards. Each is label | big mono value, a one-line sub, and a
   full-width micro-meter pinned to the card floor so the shape of the number
   reads before the number does. */
#kpi-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 11px; flex-shrink: 0;
}
.kpi-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 12px 10px;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto auto;
  column-gap: 8px; row-gap: 2px; align-items: center;
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 2px;
  background: var(--teal); opacity: 0; transition: opacity .2s var(--ease);
}
.kpi-card:hover::before { opacity: 0.6; }
.kpi-lbl {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.7px;
  color: var(--muted); text-transform: uppercase; grid-column: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.kpi-sub { font-size: 10.5px; color: var(--faint); grid-column: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kpi-val {
  font-size: 19px; font-weight: 800; color: #fff; grid-column: 2;
  font-family: var(--mono); letter-spacing: -0.5px; text-align: right;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.kpi-val.up { color: var(--up); }
.kpi-val.down { color: var(--down); }
.kpi-val.warn { color: var(--amber); }

/* The meter: one 0-100% bar. `.bipolar` puts zero in the middle, so net flow
   fills left of centre (net sellers) or right of it (net buyers). */
.kpi-meter {
  grid-column: 1 / -1; position: relative; height: 3px; margin-top: 6px;
  border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden;
}
.kpi-meter.bipolar::after {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px;
  background: rgba(255,255,255,0.22);
}
.kpi-meter i {
  position: absolute; top: 0; bottom: 0; left: 0; width: 0;
  border-radius: 999px; background: var(--teal);
  transition: left .4s var(--ease), width .4s var(--ease);
}
.kpi-meter.up i { background: var(--up); }
.kpi-meter.down i { background: var(--down); }
.kpi-meter.warn i { background: var(--amber); }

/* ================= Ticker tape (DOM, crisp) ================= */
#tape-wrap {
  flex-shrink: 0; height: 38px;
  border-radius: var(--radius-sm); background: var(--card);
  border: 1px solid var(--line); overflow: hidden; position: relative;
}
/* The tape is the desk's status bar now (it sits above the Narasi), so its
   ends fade out instead of being cut off by the card border. */
#tape-view {
  position: absolute; inset: 0; overflow: hidden; display: flex; align-items: center;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 44px, #000 calc(100% - 44px), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 44px, #000 calc(100% - 44px), transparent 100%);
}
#tape-track {
  display: flex; align-items: center; gap: 22px; padding: 0 18px;
  white-space: nowrap; will-change: transform;
  animation: tape-scroll 46s linear infinite;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
}
#tape-wrap:hover #tape-track { animation-play-state: paused; }
@keyframes tape-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.tape-item { display: inline-flex; align-items: center; gap: 7px; }
.tape-item .tk { color: var(--muted); font-weight: 700; letter-spacing: 0.2px; }
.tape-item .px { color: var(--ink-2); }
.tape-item .chg { font-weight: 700; }
.tape-item .chg.up { color: var(--up); }
.tape-item .chg.down { color: var(--down); }
.tape-item .arr { font-size: 8px; opacity: 0.9; }

/* ================= Main layout =================
   User spec 40 / 20 / 40 — HORIZONTAL: one row, three columns.
   Graphs (chart) 40% wide | Movers+Recap stacked 20% | Agents 40%.
   Fixed fr columns so content changes can never shift or resize the chart. */
#layout {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 40fr) minmax(0, 20fr) minmax(0, 40fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 11px;
}
.tier-1 { min-height: 0; min-width: 0; display: flex; }
/* tier-2 is a narrow 20% column: Movers above Recap, stacked.
   Explicit minmax(0,1fr) column so content can never inflate the track
   and bleed into the Agents column. */
.tier-2 {
  min-height: 0; min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 11px;
}
.tier-3 { min-height: 0; min-width: 0; display: flex; }
.tier-3 #agent-wrap { flex: 1; min-width: 0; }

.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px; flex-shrink: 0;
}
.panel-title { font-size: 13px; font-weight: 800; color: #fff; letter-spacing: 0.2px; }
.panel-sub { font-size: 10.5px; color: var(--faint); font-weight: 600; }

/* ---- Chart ---- */
#chart-wrap {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 14px 12px; overflow: hidden; position: relative;
}
.chart-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.ch-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chart-tools { display: flex; align-items: center; gap: 9px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.tf-wrap { display: flex; gap: 3px; background: var(--card-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.tf-btn {
  font-family: var(--mono); font-size: 9.5px; font-weight: 800; letter-spacing: 0.3px;
  color: var(--muted); background: transparent; border: none; border-radius: 6px;
  padding: 3px 7px; cursor: pointer; transition: all .14s var(--ease);
}
.tf-btn:hover { color: var(--ink-2); background: #141b26; }
.tf-btn.active { color: #05070b; background: var(--teal); }
.regime-chip {
  font-size: 10px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 8px; color: var(--muted);
  background: var(--card-2); border: 1px solid var(--line-2); white-space: nowrap;
}
.regime-chip.bull { color: var(--up); background: var(--up-soft); border-color: rgba(52,211,153,0.3); }
.regime-chip.bear { color: var(--down); background: var(--down-soft); border-color: rgba(251,113,133,0.3); }
.regime-chip.flat { color: var(--muted); }
#chart-legend {
  display: flex; flex-wrap: wrap; gap: 5px 6px; margin-bottom: 8px; flex-shrink: 0;
  max-height: 52px; overflow: hidden;
}
.legend-item {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; font-family: var(--mono);
  color: var(--ink-2); background: var(--card-2); border: 1px solid var(--line);
  padding: 2px 7px; border-radius: 7px; cursor: pointer; user-select: none;
  transition: all .14s var(--ease);
}
.legend-item .swatch { width: 8px; height: 8px; border-radius: 3px; }
.legend-item:hover { border-color: var(--line-2); background: #141b26; color: #fff; }
.legend-item.off { opacity: 0.4; text-decoration: line-through; text-decoration-color: rgba(255,255,255,0.35); }
.legend-item.hot { border-color: rgba(255,255,255,0.25); }
.legend-item.solo { border-color: var(--teal); color: var(--teal); background: var(--teal-dim); }
.legend-all {
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.4px;
  color: var(--faint); background: transparent; border: 1px dashed var(--line);
  padding: 2px 8px; border-radius: 7px; cursor: pointer; transition: all .14s var(--ease);
}
.legend-all:hover { color: var(--ink-2); border-color: var(--line-2); }
#chart-canvas-wrap { flex: 1; min-height: 0; position: relative; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 3; display: none;
  background: rgba(11,14,21,0.97); border: 1px solid var(--line-2);
  border-radius: 9px; padding: 8px 10px; font-size: 11px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45); min-width: 130px;
}
.tip-day { font-family: var(--mono); font-weight: 700; color: var(--teal); font-size: 11px; margin-bottom: 5px; }
.tip-row { display: flex; align-items: center; gap: 6px; padding: 1.5px 0; }
.tip-row .sw { width: 7px; height: 7px; border-radius: 2px; flex-shrink: 0; }
.tip-row .tk { font-weight: 700; font-family: var(--mono); color: var(--ink-2); }
.tip-row .val { margin-left: auto; font-family: var(--mono); font-weight: 600; }

/* ---- Movers (tier-2 upper cell, narrow 20% col; scrolls internally) ---- */
#movers-wrap {
  min-height: 0; min-width: 0; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
}
.mover-col-head {
  font-size: 10px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 5px;
}
.mover-col-head .glyph { font-size: 9px; }
.mover-row {
  display: flex; align-items: center; gap: 7px; position: relative;
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 9px; transition: border-color .14s var(--ease);
}
.mover-row::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  border-radius: 9px 0 0 9px; opacity: 0.8;
}
.mover-row.up::before { background: var(--up); }
.mover-row.down::before { background: var(--down); }
.mover-row.up { border-color: rgba(0,200,83,0.2); }
.mover-row.down { border-color: rgba(255,61,87,0.2); }
.mover-row:hover { border-color: var(--line-2); }
.mover-rank { font-family: var(--mono); font-size: 10px; color: var(--faint); font-weight: 700; width: 12px; }
.mover-tk { font-family: var(--mono); font-weight: 800; font-size: 12px; color: #fff; flex: 1; }
.mover-name { font-size: 9.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.mover-chg { font-family: var(--mono); font-weight: 800; font-size: 12px; }
.mover-chg.up { color: var(--up); }
.mover-chg.down { color: var(--down); }

/* ---- Recap ---- */
#recap-wrap {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
}
#news-rail { flex: 1; min-height: 0; display: flex; flex-direction: column; }
/* the rail scrolls internally (see the layout contract at the top of this file) */
#news-list { flex: 1; min-height: 0; overflow-y: auto; }
#movers-list {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 7px; margin-top: 10px;
}
.news-item {
  background: var(--card-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 10px 12px; line-height: 1.4;
  transition: border-color .14s var(--ease);
}
.news-item:hover { border-color: var(--line-2); }
.news-item.today { border-color: rgba(23,227,196,0.3); background: var(--teal-dim); }
.news-top { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.news-top .d { font-family: var(--mono); font-weight: 800; color: var(--teal); flex-shrink: 0; }
.news-top .sent { font-size: 9px; flex-shrink: 0; }
.news-top .sent.up { color: var(--up); }
.news-top .sent.down { color: var(--down); }
.news-head { font-weight: 600; color: var(--ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.news-body { margin-top: 6px; font-size: 11px; color: var(--ink-2); line-height: 1.5; }
.news-body .mv-up { color: var(--up); font-weight: 700; font-family: var(--mono); }
.news-body .mv-down { color: var(--down); font-weight: 700; font-family: var(--mono); }
.recap-meta { margin-top: 6px; display: flex; gap: 10px; font-size: 10px; color: var(--faint); font-weight: 600; }
/* Market Pulse: agent reactions on a given day, nested inside recap item */
.pulse-line { margin-top: 8px; border-top: 1px dashed var(--line-2); padding-top: 7px; display: flex; flex-direction: column; gap: 3px; }
.pulse-line .pulse-ic { color: var(--teal); font-size: 10px; margin-right: 6px; }
.pulse-item { font-size: 11px; color: var(--ink-2); line-height: 1.45; display: flex; gap: 6px; }
.pulse-item .pulse-name { font-weight: 700; color: var(--teal); flex-shrink: 0; min-width: 56px; font-family: var(--mono); font-size: 10.5px; }
.news-quiet { color: var(--faint); font-size: 12px; text-align: center; padding: 24px 8px; font-style: italic; }

/* Run selector (replay mode only) */
.run-select {
  background: var(--card-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 8px;
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  padding: 5px 22px 5px 10px; margin-left: 10px; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2323e5c4' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.run-select:hover { border-color: var(--teal); }
.run-select:focus { outline: none; border-color: var(--teal); }

/* ================= Agents (tier-3 = right 40% column; scrolls internally) ================= */
#agent-wrap {
  flex: 1; min-height: 0;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column;
}
/* 40% column, split kiri-kanan (2 kartu per baris) — lebih luas, less scroll */
#agent-grid {
  flex: 1; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px; align-content: start; margin-top: 10px;
}
.agent-card {
  position: relative; background: var(--card-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
}
.agent-card:hover { border-color: var(--line-2); }
/* agent stripe (left 3px, agent color) — fades out during buy-pulse so
   the teal flash stays clean on all 4 sides, no "kepotong" */
.agent-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--pc, var(--teal)); opacity: 0.85;
  border-radius: 12px 0 0 12px; transition: opacity .15s ease;
}
.agent-card.flash::before { opacity: 0; }
/* today's action state (buy = teal pulse, sell = red pulse) */
.agent-card.flash {
  border-color: var(--teal);
  box-shadow: 0 0 0 1px rgba(23,227,196,0.25), 0 0 14px rgba(23,227,196,0.18);
  animation: cardpulse 1.6s ease-out infinite;
}
@keyframes cardpulse {
  0%   { box-shadow: 0 0 0 0 rgba(23,227,196,0.35); }
  100% { box-shadow: 0 0 0 6px rgba(23,227,196,0); }
}
.a-act { display: flex; align-items: center; gap: 6px; font-size: 10px; color: var(--faint); font-style: italic; }
.a-act .act-chip {
  font-family: var(--mono); font-weight: 800; font-size: 9.5px; letter-spacing: 0.4px;
  padding: 1.5px 7px; border-radius: 7px; color: var(--ink-2); background: var(--card);
  border: 1px solid var(--line);
}
.agent-card.flash .act-chip { color: var(--teal); border-color: rgba(23,227,196,0.35); }
.act-chip.soft { color: var(--muted); }
.a-act-detail { font-weight: 600; font-style: normal; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-head { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 28px; height: 28px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #05070b; background: var(--pc, var(--teal));
}
.a-idwrap { flex: 1; min-width: 0; }
.a-name { font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.25px; }
.a-tag { font-size: 9px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase; color: var(--pc, var(--teal)); opacity: 0.9; margin-top: 1px; }
.a-pnl { font-family: var(--mono); font-weight: 800; font-size: 12px; flex-shrink: 0; padding: 2px 7px; border-radius: 8px; }
.a-pnl.up { color: var(--up); background: var(--up-soft); }
.a-pnl.down { color: var(--down); background: var(--down-soft); }
.a-eq { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.a-eq .lbl { font-size: 9px; font-weight: 700; letter-spacing: 0.5px; color: var(--faint); text-transform: uppercase; }
.a-eq .val { font-family: var(--mono); font-weight: 800; font-size: 14.5px; color: #fff; letter-spacing: -0.3px; }
.a-eq .delta { font-family: var(--mono); font-size: 10.5px; font-weight: 700; }
.a-eq .spark { width: 60px; height: 16px; display: block; margin-left: auto; opacity: 0.95; }
.a-sec { display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.a-sec-lbl { font-size: 9px; font-weight: 700; letter-spacing: 0.5px; color: var(--faint); text-transform: uppercase; }
.a-holds { display: flex; flex-direction: column; gap: 2px; }
.hold-row { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-2); line-height: 1.5; white-space: nowrap; overflow: hidden; }
.hold-tk { font-family: var(--mono); font-weight: 700; color: var(--ink); flex-shrink: 0; }
.hold-qty { font-family: var(--mono); color: var(--faint); flex-shrink: 0; margin-left: auto; }
.hold-name { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; font-size: 10px; }
.hold-mv { font-family: var(--mono); font-weight: 700; flex-shrink: 0; }
.hold-row.empty { color: var(--faint); font-style: italic; font-size: 10px; }
.a-last { font-size: 10.5px; color: var(--faint); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-thought { min-height: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.a-thought .thought, .a-thought .react { font-size: 11.5px; line-height: 1.5; color: var(--ink-2); }
.a-thought .thought.act { color: var(--ink); font-weight: 500; }
.a-thought .thought.think { color: var(--teal); font-weight: 500; }
.a-thought .quiet { color: var(--faint); font-style: italic; }
.a-thought .react-day, .thought .day { font-family: var(--mono); font-weight: 700; color: var(--teal); font-style: normal; font-size: 10px; }
/* 3-line thinking box: action / reason / meta */
.a-thought .thought-lines { display: flex; flex-direction: column; gap: 3px; }
.a-thought .t-line { font-size: 11.5px; line-height: 1.4; }
.a-thought .t-action { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.a-thought .t-action .a-act-detail { font-weight: 400; font-size: 11px; color: var(--ink-2); font-family: var(--mono); }
.a-thought .act-chip { display: inline-block; font-family: var(--mono); font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 3px; letter-spacing: 0.5px; }
.a-thought .act-chip.buy { background: rgba(23,227,196,0.15); color: var(--teal); }
.a-thought .act-chip.sell { background: rgba(239,82,82,0.15); color: #ef5252; }
.a-thought .act-chip:not(.buy):not(.sell) { background: rgba(255,255,255,0.06); color: var(--faint); }
.a-thought .t-reason { color: var(--ink-2); }
.a-thought .t-meta { font-family: var(--mono); font-size: 10px; color: var(--faint); }
/* A6: playbook flash line */
.a-thought .t-playbook { font-size: 10.5px; color: var(--teal); font-weight: 600; letter-spacing: .2px; }
/* Market Pulse fill chip */
.pulse-fill { font-family: var(--mono); font-size: 10px; font-weight: 700; color: var(--teal); background: rgba(23,227,196,0.1); padding: 0 4px; border-radius: 2px; }
.a-acts-lbl { display: flex; align-items: center; gap: 6px; }

/* ── Scenario Lab ────────────────────────────────────────────── */
.hidden { display: none !important; }

/* Launcher button in the topbar */
.lab-launcher {
  background: var(--teal-dim);
  color: var(--teal);
  border: 1px solid rgba(23,227,196,0.35);
  border-radius: 9px;
  padding: 5px 11px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
}
.lab-launcher:hover { background: rgba(23,227,196,0.2); }

/* Drawer (picker) */
#lab-drawer {
  position: fixed;
  inset: 0;
  background: var(--surface);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: 22px 26px;
  overflow: hidden;
}
.lab-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.lab-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--teal);
}
.lab-title {
  display: block;
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 2px;
}
.lab-actions { display: flex; gap: 8px; }
.ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--line-2);
  border-radius: 9px;
  padding: 5px 11px;
  font-size: 12px;
  cursor: pointer;
}
.ghost:hover { color: var(--ink); border-color: rgba(255,255,255,0.25); }
.ghost.active { color: var(--teal); border-color: rgba(23,227,196,0.4); }

#lab-body { flex: 1; min-height: 0; margin-top: 16px; overflow: auto; }

#lab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  grid-auto-rows: min-content;
  padding-bottom: 8px;
}
.lab-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  cursor: pointer;
  transition: border-color 120ms var(--ease), transform 120ms var(--ease);
  position: relative;
}
.lab-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.lab-card.sel { border-color: rgba(23,227,196,0.55); background: var(--teal-dim); }
.lab-card-id {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.lab-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  margin: 3px 0 4px;
}
.lab-card-summary {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.4;
}
.lab-card-meta {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
}
.lab-card-meta .n { color: var(--teal); }

/* Custom form */
#lab-custom { display: flex; flex-direction: column; gap: 10px; padding: 4px 2px; }
.lab-field { display: flex; flex-direction: column; gap: 4px; }
.lab-field > span { font-size: 11px; color: var(--muted); font-weight: 500; }
.lab-field input, .lab-field textarea {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
}
.lab-field input:focus, .lab-field textarea:focus {
  outline: none;
  border-color: rgba(23,227,196,0.4);
}

.lab-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.lab-foot .primary {
  background: var(--teal);
  color: #052420;
  border: none;
  border-radius: 9px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.lab-foot .primary:disabled { opacity: 0.5; cursor: default; }
.lab-foot-note { font-size: 11px; color: var(--faint); font-family: var(--mono); }

/* Result panel — full-screen, top-down information hierarchy, section-scoped scroll */
#lab-result {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: 18px 24px 14px;
  overflow: auto;
}

/* Header: single row — left = eyebrow+title+context text, right = hash chip + Close.
   Fixed-width meta so the title never has to share a row with a wrapping chip. */
.labr-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.labr-head-text { min-width: 0; }
.labr-eyebrow { font-size: 10px; letter-spacing: 0.14em; color: var(--teal); font-weight: 700; }
.labr-title { display: block; font-size: 17px; font-weight: 650; color: var(--ink); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.labr-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.labr-hash {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--faint);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 8px;
  white-space: nowrap;
}

/* KPI row: each card is a vertical stack (label → value → sub), so a long value
   (e.g. "Momentum Max +47.0%") can never collide with its label or sub-line.
   One card now: the index move is the headline answer, and per-name deltas and
   per-agent P&L each have their own panel below. */
.labr-kpis {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  flex-shrink: 0;
  margin-top: 14px;
}
.labr-kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.labr-kpi-lbl {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.labr-kpi-val {
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.labr-kpi-sub {
  font-size: 10.5px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Context band: the scenario's "real-world" description + the 10-ticker universe
   chips live here, on their own background, so wrapping text/chips can never
   spill into the KPI cards above or the charts below. */
.labr-context {
  flex-shrink: 0;
  margin-top: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.labr-context-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  row-gap: 6px;
}
.labr-context-lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  flex-shrink: 0;
}
.labr-universe-chips { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.labr-universe-chip {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--teal);
  background: rgba(23,227,196,0.08);
  border: 1px solid rgba(23,227,196,0.25);
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
}
.labr-real {
  font-size: 12px;
  color: var(--muted);
  margin-top: 7px;
  line-height: 1.55;
  max-width: 900px;
}

/* Charts: two-column grid. Rows 1 = index chart + per-name deltas,
   row 2 = persona P&L (full width). Personas span both columns so their
   card grid never squeezes the deltas box. */
.labr-charts {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.labr-chart {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-height: 240px;
  min-width: 0;
}
.labr-chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-shrink: 0; }
.labr-chart-head .panel-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.labr-chart-head .panel-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; text-align: right; }
.labr-chart canvas { flex: 1; min-height: 120px; width: 100%; }

/* Per-name deltas: chips wrap freely inside the box, never overflow the panel */
.lab-deltas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  align-content: flex-start;
  min-width: 0;
}
.lab-delta {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 9px;
  background: var(--surface-2);
  white-space: nowrap;
}
.lab-delta.up { color: var(--up); border-color: rgba(52,211,153,0.3); background: rgba(52,211,153,0.08); }
.lab-delta.down { color: var(--down); border-color: rgba(251,113,133,0.3); background: rgba(251,113,133,0.08); }
.lab-delta.dim { color: var(--faint); }

/* Empty-state banner so a blank box reads as intentional, not broken */
.labr-emptystate {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  color: var(--faint);
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.labr-emptystate.show { display: flex; }

/* Personas: full-width, own card grid */
.labr-personas { grid-column: 1 / -1; min-height: 0; }
#labr-persona-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  flex: 1;
  align-content: start;
}

/* Compare-to-reality: its own band, separated by a real margin — can never
   paint over the persona cards above */
.labr-reality {
  flex-shrink: 0;
  margin-top: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px 14px;
}
.labr-reality-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.labr-reality-head .panel-title { white-space: nowrap; }
.labr-reality-head .panel-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; text-align: right; }
.labr-reality-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto;
  gap: 12px;
  align-items: end;
}
.labr-reality-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.labr-reality-field > span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
.labr-reality-field input {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  font-size: 13px;
  font-family: var(--mono);
  width: 100%;
  min-width: 0;
}
.labr-reality-field input:focus { outline: none; border-color: rgba(23,227,196,0.4); }
.labr-reality-btn {
  background: var(--teal);
  color: #052420;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  align-self: end;
}
.labr-reality-btn:hover { filter: brightness(1.08); }
.labr-verdict-out {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.55;
}
.lab-verdict-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
}
.lab-verdict-badge {
  flex: none;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
}
.lab-verdict-badge.good { background: rgba(40,175,112,.15); color: var(--up); border: 1px solid rgba(40,175,112,.4); }
.lab-verdict-badge.off  { background: rgba(240,80,80,.15); color: var(--down); border: 1px solid rgba(240,80,80,.4); }
.lab-verdict-badge.weak { background: rgba(240,180,60,.15); color: #f0b445; border: 1px solid rgba(240,180,60,.4); }
.lab-verdict-pred, .lab-verdict-act { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.lab-verdict-pred strong, .lab-verdict-act strong { color: var(--ink); font-family: var(--mono); }
.lab-verdict-note { color: var(--muted); font-size: 12px; margin-top: 6px; font-style: italic; }

/* narrow viewports: stack everything so nothing ever overlaps */
/* A7: time-machine scrubber label + shock markers */
.seek { position: relative; }
.seek-label { font-size: 11px; color: var(--ink-2); font-family: var(--mono); letter-spacing: .3px; white-space: nowrap; }
.seek-marks { position: absolute; left: 0; right: 0; bottom: -6px; height: 6px; pointer-events: none; }
.seek-mark { position: absolute; top: 0; width: 3px; height: 6px; background: var(--amber); border-radius: 2px; opacity: .85; }
/* A4: Narasi hero — the Broadsheet (option 01, 2026-09-14). Auto-written every
   day. A meta strip names the day, regime and fill count; a BOLD serif verdict
   carries the story with the muted evidence beside four hairline ledger cells;
   a full-width index arc closes on its peak. Every pixel is bounded, so the
   section never grows with text and the chart keeps its share of the column. */
#narasi-hero {
  flex-shrink: 0;
  height: 150px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) auto;
  column-gap: 20px;
  background: linear-gradient(180deg, var(--card) 0%, var(--surface) 100%);
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--teal);
  border-radius: var(--radius-sm);
  padding: 8px 14px 7px;
  overflow: hidden;
  position: relative;
  transition: border-left-color .3s var(--ease);
}
#narasi-hero.shock { border-left-color: var(--shock); }

/* --- meta strip: day · regime · fills, with the shock pill -------------- */
.nh-meta {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 9px;
  min-width: 0; padding-bottom: 5px;
}
.nh-kick {
  font-family: var(--mono); font-size: 8.5px; font-weight: 600;
  letter-spacing: .17em; text-transform: uppercase; color: var(--faint);
  display: flex; align-items: center; gap: 7px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.nh-kick b { color: var(--teal); font-weight: 600; }
.nh-kick i { color: var(--faint); font-style: normal; }
.nh-kick .nh-sep { color: rgba(255,255,255,0.14); }
.nh-chip {
  font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: .4px;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap; flex-shrink: 0;
  background: var(--card-2); border: 1px solid var(--line-2); color: var(--ink-2);
}
.nh-chip.shock { color: var(--shock); border-color: rgba(255,69,58,0.4); background: rgba(255,69,58,0.08); }
.nh-chip.hidden { display: none; }

/* --- editorial voice: the serif verdict + muted evidence ---------------- */
.nh-editorial { grid-column: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.nh-lead {
  font-family: "New York", "Iowan Old Style", "Palatino", Georgia, serif;
  font-size: 19px; font-weight: 700; line-height: 1.2;
  letter-spacing: -0.014em; color: var(--ink);
  text-wrap: balance; overflow-wrap: anywhere;
}
.nh-detail { font-size: 11px; line-height: 1.4; color: var(--muted); margin-top: 4px; overflow-wrap: anywhere; }
.nh-detail:empty { display: none; }

/* --- ledger: four hairline cells, sharing the KPI strip's formulas ------ */
.nh-stats { grid-column: 2; display: flex; align-items: stretch; }
.nh-ledger { display: flex; align-items: stretch; }
.nh-cell {
  padding: 0 13px; border-left: 1px solid var(--line-2);
  min-width: 92px; display: flex; flex-direction: column; justify-content: center;
}
.nh-cell:first-child { border-left: 0; padding-left: 0; }
.nh-l {
  font-family: var(--mono); font-size: 8px; letter-spacing: .15em;
  text-transform: uppercase; color: var(--faint);
}
.nh-v {
  font-family: var(--mono); font-size: 18px; font-weight: 500;
  letter-spacing: -0.02em; margin-top: 2px; color: var(--ink);
}
.nh-v small { font-size: 11px; color: var(--faint); font-weight: 400; }
.nh-d { font-size: 9.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; }

/* --- the index arc: full width, ends on its peak ------------------------ */
.nh-spark {
  grid-column: 1 / -1;
  margin-top: 7px; padding-top: 6px; border-top: 1px solid var(--line-2);
  position: relative;
}
.nh-spark svg { display: block; width: 100%; height: 30px; }
.nh-spark-l, .nh-spark-r {
  position: absolute; top: -1px;
  font-family: var(--mono); font-size: 8px; letter-spacing: .13em;
  text-transform: uppercase; color: var(--faint);
}
.nh-spark-l { left: 0; }
.nh-spark-r { right: 0; color: var(--muted); }
.nh-spk { fill: none; stroke: var(--teal); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.nh-fill { stroke: none; }
.nh-grid { stroke: rgba(255,255,255,0.05); stroke-width: 1; vector-effect: non-scaling-stroke; }
.nh-peakdot { fill: var(--bg); stroke: var(--teal); stroke-width: 1.4; }

/* --- motion: subtle, transform/opacity only, played once ---------------- */
@keyframes nhRise { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes nhFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nhWipe { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes nhSweep { from { stroke-dashoffset: var(--len); } to { stroke-dashoffset: 0; } }
/* Gated on .nh-in: the hero is an empty shell until the first day lands, so the
   stagger plays once — when there is actually something to rise into place. */
#narasi-hero.nh-in .nh-meta { animation: nhRise .5s var(--ease) both; }
#narasi-hero.nh-in .nh-editorial { animation: nhRise .5s var(--ease) .06s both; }
#narasi-hero.nh-in .nh-stats { animation: nhRise .5s var(--ease) .12s both; }
#narasi-hero.nh-in .nh-spark { animation: nhRise .5s var(--ease) .18s both; }
/* the reference rules draw in from the left, so the wipe keyframe earns its keep */
#narasi-hero.nh-in .nh-grid { transform-origin: left center; animation: nhWipe .7s var(--ease) .1s both; }
.nh-arc { stroke-dasharray: var(--len); }
#narasi-hero.nh-in .nh-arc { animation: nhSweep 1.1s var(--ease) .18s both; }
#narasi-hero.nh-in .nh-area { animation: nhFade .9s ease .5s both; }

@media (prefers-reduced-motion: reduce) {
  #narasi-hero, #narasi-hero * { animation-duration: .001s !important; animation-delay: 0s !important; }
  .nh-arc { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; }
}

/* B3: scenario replay controls */
.labr-replay { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.labr-replay button { font-size: 11px; min-width: 84px; justify-content: center; }
.labr-replay input[type="range"] { flex: 1; min-width: 80px; }
.labr-replay-frame { font-family: var(--mono); font-size: 10.5px; color: var(--faint); white-space: nowrap; }
.labr-replay button.playing { background: rgba(23,227,196,0.12); border-color: rgba(23,227,196,0.4); color: var(--teal); }

/* B5: share button */
#labr-share { color: var(--teal); border-color: rgba(23,227,196,0.3); }

/* A1: cinematic shock overlay */
#shock-overlay { position: fixed; inset: 0; z-index: 999; pointer-events: none; display: flex; align-items: center; justify-content: center; }
#shock-overlay.hidden { display: none; }
#shock-overlay .shock-tint { position: absolute; inset: 0; background: radial-gradient(ellipse at center, rgba(239,68,68,0.0) 0%, rgba(239,68,68,0.55) 100%); opacity: 0; transition: opacity .35s ease; }
#shock-overlay .shock-banner { position: relative; text-align: center; opacity: 0; transform: translateY(14px); transition: opacity .3s ease, transform .3s ease; }
#shock-overlay.on .shock-tint { opacity: 1; }
#shock-overlay.on .shock-banner { opacity: 1; transform: translateY(0); }
.shock-kicker { display: block; font-family: var(--mono); font-size: 12px; letter-spacing: 4px; color: var(--amber); }
.shock-title { display: block; font-size: clamp(28px, 6vw, 64px); font-weight: 800; color: #fff; text-shadow: 0 2px 24px rgba(0,0,0,0.6); text-transform: uppercase; margin: 10px 0 6px; }
.shock-sub { display: block; font-family: var(--mono); font-size: 13px; color: rgba(255,255,255,0.75); }

/* A8: trading floor vibe — ambient pulse on ticker */
#tape-view.pulse { animation: floorPulse .6s ease; }
@keyframes floorPulse {
  0% { background: rgba(23,227,196,0.0); }
  30% { background: rgba(23,227,196,0.06); }
  100% { background: rgba(23,227,196,0.0); }
} 

/* B6: lab library filter + real badge */
.lab-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.lab-filter { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--faint); }
.lab-filter button { font-size: 10.5px; padding: 2px 8px; }
.lab-filter button.active { background: var(--teal); color: #06121a; font-weight: 700; border-color: transparent; }
.lab-card-real { display: inline-block; margin-left: 6px; font-size: 9px; letter-spacing: .4px; color: #06121a; background: var(--amber); border-radius: 3px; padding: 1px 5px; font-weight: 700; vertical-align: middle; }

/* B7: local track record */
.lab-track { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.lab-track-lbl { color: var(--faint); text-transform: uppercase; letter-spacing: .4px; }
.lab-track-n { color: var(--teal); font-weight: 700; }
.lab-track-bar { width: 70px; height: 5px; background: rgba(255,255,255,0.1); border-radius: 3px; overflow: hidden; }
.lab-track-bar i { display: block; height: 100%; background: var(--teal); }
.lab-track-streak { color: var(--amber); }

/* A2: agent inner-world mood */
.a-mood { font-size: 9.5px; letter-spacing: .3px; margin-top: 2px; font-weight: 600; }
.a-mood.m-up { color: var(--up); }
.a-mood.m-down { color: var(--down); }
.a-mood.m-calm { color: var(--faint); }

/* A5: rivalry chip */
.a-rival { display: block; font-size: 9.5px; color: var(--amber); margin-top: 2px; font-family: var(--mono); }

/* B8: crowd vs agents vs reality */
.labr-crowd { margin-top: 14px; }
.labr-crowd-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.labr-crowd-grid { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
.labr-crowd-card { flex: 1 1 160px; min-width: 140px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--surface); display: flex; flex-direction: column; gap: 4px; }
.labr-crowd-card.lab { border-left: 3px solid var(--teal); }
.labr-crowd-card.agent { border-left: 3px solid var(--amber); }
.labr-crowd-card.reality { border-left: 3px solid var(--purple, #a78bfa); }
.labr-crowd-label { font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); }
.labr-crowd-val { font-family: var(--mono); font-size: 17px; font-weight: 700; }
.labr-crowd-note { font-size: 10.5px; color: var(--ink-2); }
.labr-crowd-winner { flex-basis: 100%; font-size: 13px; font-weight: 700; padding: 7px 10px; border-radius: 8px; text-align: center; margin-bottom: 2px; }
.labr-crowd-winner.lab { background: rgba(23,227,196,0.12); color: var(--teal); }
.labr-crowd-winner.agent { background: rgba(255,180,60,0.12); color: var(--amber); }

/* B1: two-worlds toggle */
.labr-toggle { margin-left: auto; cursor: pointer; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--teal); background: rgba(23,227,196,0.1); border: 1px solid rgba(23,227,196,0.25); border-radius: 20px; padding: 3px 9px; user-select: none; }
.labr-toggle b { font-weight: 800; }
.labr-toggle.off { color: var(--faint); background: rgba(255,255,255,0.04); border-color: var(--line); }

/* B4: verdict reveal banner */
.lab-verdict-banner { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-radius: 10px; margin-bottom: 10px; font-size: 13px; animation: verdictPop .35s ease-out; }
@keyframes verdictPop { 0% { transform: scale(.92); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.lab-verdict-banner.hit { background: rgba(23,227,196,0.14); border: 1px solid rgba(23,227,196,0.4); }
.lab-verdict-banner.miss { background: rgba(255,90,90,0.14); border: 1px solid rgba(255,90,90,0.4); }
.lab-verdict-banner.close { background: rgba(255,180,60,0.14); border: 1px solid rgba(255,180,60,0.4); }
.lab-verdict-title { font-size: 24px; font-weight: 900; letter-spacing: 1px; }
.lab-verdict-banner.hit .lab-verdict-title { color: var(--teal); }
.lab-verdict-banner.miss .lab-verdict-title { color: #ff5a5a; }
.lab-verdict-banner.close .lab-verdict-title { color: var(--amber); }
.lab-verdict-sub { font-size: 12px; color: var(--ink-2); }


/* ---------- A2: agent inner world (fixed drawer, grid-safe) ---------- */
.a-world {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; padding: 0;
  border-radius: 6px; border: 1px solid var(--line); background: var(--card);
  color: var(--muted); font-size: 10px; line-height: 1; cursor: pointer; opacity: 0;
  transition: opacity .12s ease, color .12s ease, border-color .12s ease;
}
.agent-card:hover .a-world { opacity: 1; }
.a-world:hover { color: var(--teal); border-color: var(--teal); }

#agent-world { position: fixed; inset: 0; z-index: 60; }
#agent-world.hidden { display: none; }
.aw-scrim { position: absolute; inset: 0; background: rgba(3,5,9,0.55); }
.aw-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw;
  background: var(--card); border-left: 1px solid var(--line-2);
  padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px;
  box-shadow: -24px 0 60px rgba(0,0,0,0.5); animation: awIn .22s var(--ease);
}
@keyframes awIn { 0% { transform: translateX(24px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.aw-head { display: flex; align-items: flex-start; gap: 10px; }
.aw-avatar { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; color: #05070b; background: var(--teal); }
.aw-idwrap { flex: 1; min-width: 0; }
.aw-name { font-size: 14px; font-weight: 800; color: var(--ink); }
.aw-tag { font-size: 9px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: var(--teal); margin-top: 2px; }
.aw-desc { font-size: 10.5px; color: var(--muted); margin-top: 4px; line-height: 1.45; }
.aw-close { border: 1px solid var(--line); background: var(--card-2); color: var(--muted); border-radius: 7px; width: 22px; height: 22px; cursor: pointer; font-size: 11px; }
.aw-close:hover { color: var(--down); border-color: var(--down); }
.aw-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.aw-kpi { background: var(--card-2); border: 1px solid var(--line); border-radius: 9px; padding: 7px 8px; display: flex; flex-direction: column; gap: 2px; }
.aw-kpi-k { font-size: 8.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--faint); }
.aw-kpi-v { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--ink); }
.aw-kpi-v.up { color: var(--up); }
.aw-kpi-v.down { color: var(--down); }
.aw-sec { border-top: 1px solid var(--line); padding-top: 10px; }
.aw-sec-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; gap: 8px; }
#aw-eq-chart { width: 100%; height: 96px; display: block; background: var(--card-2); border: 1px solid var(--line); border-radius: 9px; }
.aw-fills { display: flex; flex-direction: column; gap: 3px; max-height: 190px; overflow-y: auto; }
.aw-fill { display: grid; grid-template-columns: 34px 46px 1fr auto; gap: 6px; align-items: center; font-family: var(--mono); font-size: 10px; color: var(--ink-2); }
.aw-fill-d { color: var(--faint); }
.aw-fill-side { font-weight: 800; }
.aw-fill-side.up { color: var(--up); }
.aw-fill-side.down { color: var(--down); }
.aw-fill-q { color: var(--muted); }
.aw-diary { display: flex; flex-direction: column; gap: 5px; max-height: 220px; overflow-y: auto; }
.aw-diary-item { display: flex; gap: 7px; font-size: 10.5px; line-height: 1.45; }
.aw-diary-d { color: var(--faint); font-family: var(--mono); flex-shrink: 0; }
.aw-diary-t { color: var(--ink-2); }
.aw-empty { font-size: 10.5px; color: var(--faint); font-style: italic; }

/* ---------- B2: event ripple (source -> sector -> market) ---------- */
.labr-ripple { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0 8px; }
.lr-btn { margin-left: auto; font-size: 10px; padding: 2px 8px; }
.lr-chip { font-family: var(--mono); font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--card-2); color: var(--ink-2); }
.lr-chip.lr-src { color: var(--amber); border-color: rgba(251,191,36,0.4); background: rgba(251,191,36,0.1); }
.lr-chip.lr-sec { color: var(--teal); border-color: rgba(23,227,196,0.35); background: rgba(23,227,196,0.08); }
.lr-chip.lr-mkt { color: var(--ink); border-color: var(--line-2); }
.lr-arrow { color: var(--faint); font-size: 11px; }
.labr-ripple.pulsing .lr-chip { animation: lrPulse .6s ease; }
@keyframes lrPulse { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
.lab-delta.lr-hot { box-shadow: 0 0 0 1px rgba(251,191,36,0.55); }

/* ---------- B3: replay chapter markers ---------- */
.labr-chapters { position: relative; height: 17px; margin: 1px 0 0 96px; }
.lr-chapter { position: absolute; top: 0; transform: translateX(-50%); background: none; border: 0; padding: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.lr-ch-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: block; box-shadow: 0 0 0 2px rgba(0,0,0,0.35); }
.lr-ch-lbl { font-size: 8.5px; letter-spacing: .3px; text-transform: uppercase; color: var(--faint); white-space: nowrap; }
.lr-chapter:hover .lr-ch-dot { transform: scale(1.25); }
.lr-chapter:hover .lr-ch-lbl { color: var(--ink-2); }
.lr-chapter.event .lr-ch-dot { background: var(--amber); }
.lr-chapter.event .lr-ch-lbl { color: var(--amber); }
.lr-chapter.peak .lr-ch-dot { background: var(--down); }
.lr-chapter.peak .lr-ch-lbl { color: var(--down); }
.lr-chapter.recovery .lr-ch-dot { background: var(--up); }
.lr-chapter.recovery .lr-ch-lbl { color: var(--up); }

/* ---------- B5: shareable deep link ---------- */
.labr-share-url { font-family: var(--mono); font-size: 9.5px; color: var(--teal); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid rgba(23,227,196,0.3); background: rgba(23,227,196,0.07); padding: 2px 7px; border-radius: 6px; user-select: all; }
.labr-share-url.hidden { display: none; }

@media (max-width: 900px) {
  .labr-kpis { grid-template-columns: 1fr; }
  .labr-charts { grid-template-columns: 1fr; }
  .labr-reality-grid { grid-template-columns: 1fr; }
  .labr-reality-btn { align-self: stretch; }
  #narasi-hero { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto; column-gap: 0; }
  .nh-stats { grid-column: 1; margin-top: 7px; }
  .nh-cell { min-width: 0; padding: 0 10px; }
  #layout { grid-template-columns: none; grid-template-rows: none; grid-auto-rows: auto; overflow-y: auto; }
  .tier-1, .tier-2, .tier-3 { min-height: 420px; }
  .tier-2 { display: grid; grid-template-rows: auto auto; gap: 11px; }
  #movers-wrap, #recap-wrap { min-height: 220px; }
  #agent-grid { overflow-y: visible; }
}
