/* Shared base for all three backtest status concepts.
   Mirrors the existing app's vibe: dark slate panel, mint accent, mono type. */

:root {
  --bg-page:      #0b0f14;
  --bg-panel:     #161c24;
  --bg-panel-2:   #1c2330;
  --bg-inset:     #0d1219;
  --bg-inset-2:   #11171f;
  --line:         #2a3340;
  --line-soft:    #1f2733;
  --text-1:       #e6edf3;
  --text-2:       #b6c2cf;
  --text-3:       #6b7785;
  --text-4:       #4a5460;
  --mint:         #22c55e;
  --mint-soft:    #16a34a;
  --mint-dim:     rgba(34,197,94,0.18);
  --mint-glow:    rgba(34,197,94,0.55);
  --red:          #ef4444;
  --red-dim:      rgba(239,68,68,0.18);
  --amber:        #f59e0b;
  --amber-dim:    rgba(245,158,11,0.18);
  --blue:         #60a5fa;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

.bt-panel {
  background: linear-gradient(180deg, var(--bg-panel) 0%, var(--bg-panel-2) 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text-1);
  font-family: var(--mono);
  position: relative;
  overflow: hidden;
}
.bt-panel.glow {
  box-shadow:
    0 0 0 1px rgba(34,197,94,0.08),
    0 24px 48px -24px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.03);
}

.mono { font-family: var(--mono); }
.sans { font-family: var(--sans); }

.muted { color: var(--text-3); }
.dim   { color: var(--text-4); }
.mint  { color: var(--mint); }
.red   { color: var(--red); }
.amber { color: var(--amber); }

/* tiny utility for blinking caret / cursor */
@keyframes bt-blink { 0%,49% { opacity: 1 } 50%,100% { opacity: 0 } }
.bt-caret { display: inline-block; width: .55em; height: 1em; background: var(--mint); vertical-align: -0.12em; margin-left: 2px; animation: bt-blink 1s steps(1) infinite; }

/* scrolling hairline underline used in many places */
@keyframes bt-shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* shake / heartbeat for retries */
@keyframes bt-shake {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-1px,0); }
  40% { transform: translate(1px,1px); }
  60% { transform: translate(-1px,1px); }
  80% { transform: translate(1px,0); }
}
.retry-2 { animation: bt-shake 1.6s ease-in-out infinite; }
.retry-3 { animation: bt-shake 0.9s ease-in-out infinite; }
.retry-4 { animation: bt-shake 0.5s ease-in-out infinite; }

.retry-tier-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  border: 1px solid var(--line);
  background: var(--bg-inset);
  color: var(--text-3);
}
.retry-tier-pill .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--mint); box-shadow: 0 0 8px var(--mint-glow);
}
.retry-tier-pill[data-tier="2"] { color: var(--amber); border-color: rgba(245,158,11,0.4); }
.retry-tier-pill[data-tier="2"] .dot { background: var(--amber); box-shadow: 0 0 8px rgba(245,158,11,0.7); }
.retry-tier-pill[data-tier="3"] { color: var(--red); border-color: rgba(239,68,68,0.4); }
.retry-tier-pill[data-tier="3"] .dot { background: var(--red); box-shadow: 0 0 8px rgba(239,68,68,0.7); }
.retry-tier-pill[data-tier="4"] { color: #fff; background: var(--red); border-color: var(--red); }
.retry-tier-pill[data-tier="4"] .dot { background: #fff; }

/* generic faint scanlines you can drop on inset displays */
.scanlines { position: relative; }
.scanlines::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(180deg,
    rgba(255,255,255,0.018) 0 1px,
    transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* small uppercase label */
.kicker {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ----- design canvas tweak: bring our dark bg through ----- */
body { background: #0a0d12; }
/* =========================================================
   CONCEPT 1 v2 — Bloomberg Terminal HUD (upgraded)
   ========================================================= */
/* ─────────────  AUTOFIT WRAPPER  ───────────── */
.c1-autofit {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.c1-autofit-inner {
  transform-origin: center center;
  flex: none;
}

.c1-root {
  width: 980px;
  padding: 0;
  display: flex; flex-direction: column;
  font-size: 13px;
  position: relative;
}
.c1-root.is-done { box-shadow: 0 0 0 1px rgba(34,197,94,0.5), 0 0 60px rgba(34,197,94,0.18), 0 24px 48px -24px rgba(0,0,0,0.6); }

/* shell shake effects when retry tier high */
.c1-root.retry-shell-2 { animation: c1-shake-soft 1.6s ease-in-out infinite; }
.c1-root.retry-shell-3 { animation: c1-shake-mid 1.0s ease-in-out infinite; }
.c1-root.retry-shell-4 { animation: c1-shake-hard 0.5s ease-in-out infinite; }
@keyframes c1-shake-soft {
  0%,100% { transform: translate(0,0); }
  50%     { transform: translate(0.4px,0); }
}
@keyframes c1-shake-mid {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(-0.6px,0); }
  75% { transform: translate(0.6px,0); }
}
@keyframes c1-shake-hard {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(-1px,0.5px); }
  50% { transform: translate(1px,-0.5px); }
  75% { transform: translate(-0.5px,0.5px); }
}

/* ─────────────  TOP BAR  ───────────── */
.c1-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.012);
  gap: 16px;
}
.c1-topbar-l { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.c1-topbar-r { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.c1-topbar-led {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--mint); box-shadow: 0 0 10px var(--mint-glow);
  animation: c1-pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}
.c1-topbar-led.idle { animation: none; background: var(--text-4); box-shadow: none; }
.c1-sid { font-size: 11px; }
.c1-divider {
  width: 1px; height: 14px;
  background: var(--line);
  flex-shrink: 0;
}
.c1-scope { display: block; flex-shrink: 0; }
@keyframes c1-pulse {
  0%,100% { box-shadow: 0 0 6px var(--mint-glow); opacity: 1; }
  50%     { box-shadow: 0 0 14px var(--mint-glow); opacity: 0.85; }
}
.c1-cancel {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-2);
  padding: 5px 12px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 150ms;
}
.c1-cancel:hover { border-color: var(--red); color: var(--red); background: rgba(239,68,68,0.06); }

/* ─────────────  ALERT STRIP  ───────────── */
.c1-alert {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  background: rgba(245,158,11,0.08);
}
.c1-alert.tier-3 { background: rgba(249,115,22,0.1); }
.c1-alert.tier-4 { background: rgba(239,68,68,0.14); }
.c1-alert-icon {
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--amber); color: #0b0f14;
  font-weight: 700; font-size: 11px;
  flex-shrink: 0;
  animation: c1-pulse 0.9s infinite;
}
.c1-alert.tier-3 .c1-alert-icon { background: #f97316; }
.c1-alert.tier-4 .c1-alert-icon { background: var(--red); animation: c1-pulse 0.4s infinite; }
.c1-alert .kicker { color: var(--amber); }
.c1-alert.tier-3 .kicker { color: #f97316; }
.c1-alert.tier-4 .kicker { color: var(--red); }
.c1-alert-msg { color: var(--text-1); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c1-alert-tier { color: var(--text-3); flex-shrink: 0; }

/* ─────────────  MAIN GRID  ───────────── */
.c1-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  grid-template-rows: auto auto;
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.c1-mod {
  background: var(--bg-panel);
  padding: 14px 16px;
  min-height: 0;
}
.c1-mod-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}
.c1-mod-head-r { font-size: 11px; color: var(--text-3); letter-spacing: 0.08em; }

/* ─────────────  PHASE LADDER  ───────────── */
.c1-ladder-list { display: flex; flex-direction: column; }
.c1-ladder-row {
  display: grid;
  grid-template-columns: 14px 22px 80px 1fr 36px;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  border-top: 1px dashed var(--line-soft);
  font-size: 11px;
  transition: background 200ms;
}
.c1-ladder-row:first-child { border-top: none; }
.c1-ladder-mark { color: var(--text-4); text-align: center; }
.c1-ladder-num  { color: var(--text-4); font-variant-numeric: tabular-nums; font-size: 11px; letter-spacing: 0.08em; }
.c1-ladder-name { color: var(--text-3); letter-spacing: 0.06em; font-size: 11.5px; }
.c1-ladder-time { color: var(--text-4); font-variant-numeric: tabular-nums; font-size: 11px; text-align: right; }

.c1-ladder-bar {
  position: relative;
  height: 4px;
  background: var(--bg-inset);
  border-radius: 999px;
  overflow: hidden;
}
.c1-ladder-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--text-4);
  border-radius: 999px;
  transition: width 400ms cubic-bezier(.2,.7,.2,1);
}

.c1-ladder-row.done .c1-ladder-mark { color: var(--mint); }
.c1-ladder-row.done .c1-ladder-name { color: var(--text-2); }
.c1-ladder-row.done .c1-ladder-num  { color: var(--text-3); }
.c1-ladder-row.done .c1-ladder-bar-fill { background: rgba(34,197,94,0.55); }
.c1-ladder-row.done .c1-ladder-time { color: var(--mint); }

.c1-ladder-row.active { background: rgba(34,197,94,0.04); }
.c1-ladder-row.active .c1-ladder-mark { color: var(--mint); animation: c1-pulse 1.4s ease-in-out infinite; }
.c1-ladder-row.active .c1-ladder-name { color: var(--mint); font-weight: 600; }
.c1-ladder-row.active .c1-ladder-num  { color: var(--mint); }
.c1-ladder-row.active .c1-ladder-bar-fill {
  background: var(--mint);
  box-shadow: 0 0 8px var(--mint-glow);
  position: relative;
}
.c1-ladder-row.active .c1-ladder-bar-fill::after {
  content: "";
  position: absolute; right: 0; top: -1px; bottom: -1px;
  width: 8px;
  background: linear-gradient(90deg, transparent, #fff);
  opacity: 0.6;
}
.c1-ladder-row.active .c1-ladder-time { color: var(--mint); }
/* ─────────────  RESEARCH-MODE PIECES  ───────────── */
.rc-mode-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(96,165,250,0.04);
  font-size: 11px;
}
.rc-mode-strip .kicker { color: var(--text-4); }
.rc-mode-pill {
  padding: 2px 8px; border-radius: 3px;
  background: rgba(96,165,250,0.15);
  color: var(--blue);
  font-size: 9.5px; letter-spacing: 0.16em; font-weight: 700;
  border: 1px solid rgba(96,165,250,0.4);
}
.rc-tickers-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.rc-series-row {
  display: flex; align-items: center; gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-soft);
  flex-wrap: wrap;
}
.rc-series-label { flex: 0 0 auto; margin-right: 4px; }
.rc-series-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  background: var(--bg-inset);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  font-size: 11.5px;
}
.rc-series-light {
  width: 6px; height: 6px; border-radius: 50%;
  background: #2a3340;
}
.rc-series-name { color: var(--text-3); letter-spacing: 0.04em; }
.rc-series-pill.done .rc-series-light { background: var(--mint); box-shadow: 0 0 6px var(--mint-glow); }
.rc-series-pill.done .rc-series-name { color: var(--text-2); }
.rc-series-pill.done { border-color: rgba(34,197,94,0.2); }
.rc-series-pill.active {
  border-color: var(--amber); background: rgba(245,158,11,0.08);
}
.rc-series-pill.active .rc-series-light { background: var(--amber); animation: c1-pulse 0.8s infinite; }
.rc-series-pill.active .rc-series-name { color: var(--amber); }

/* Research handoff strip — shown when done, hands off to report renderer */
.rc-handoff {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  background: linear-gradient(180deg, rgba(11,15,20,0.96), rgba(11,15,20,0.99));
  border-top: 1px solid rgba(34,197,94,0.45);
  z-index: 6;
  animation: c1-complete-in 480ms cubic-bezier(.2,.7,.2,1);
}
.rc-handoff-led {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 16px var(--mint), 0 0 32px var(--mint-glow);
  animation: c1-pulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}
.rc-handoff-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rc-handoff-text .kicker { color: var(--mint); }
.rc-handoff-msg {
  font-size: 13px; font-weight: 500; color: var(--text-1);
  letter-spacing: -0.005em;
}
.rc-handoff-arrow {
  font-size: 18px; color: var(--mint);
  font-variant-numeric: tabular-nums;
  animation: rc-handoff-slide 1.6s ease-in-out infinite;
}
@keyframes rc-handoff-slide {
  0%, 100% { transform: translateX(0); opacity: 0.6; }
  50%      { transform: translateX(4px); opacity: 1; }
}

.c1-ladder-current {
  margin-top: 8px;
  padding: 6px 10px;
  background: var(--bg-inset);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  font-size: 11.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ─────────────  TELEMETRY  ───────────── */
.c1-telemetry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.c1-counter {
  background: var(--bg-inset);
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line-soft);
}
.c1-counter-big {
  font-size: 28px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-1);
  line-height: 1.1; margin-top: 4px;
  letter-spacing: -0.02em;
}
.c1-counter-unit { font-size: 13px; color: var(--text-3); margin-left: 1px; }
.c1-trend { font-size: 12px; margin-left: 8px; vertical-align: middle; }
.c1-trend.up { color: var(--mint); }
.c1-trend.dn { color: var(--amber); }

.c1-spark-wrap {
  background: var(--bg-inset);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: 8px 10px;
}
.c1-spark-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px;
}
.c1-spark { display: block; width: 100%; height: 40px; }

/* ─────────────  TICKER MATRIX (cells with bar fills) ───────────── */
.c1-matrix-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}
.c1-cell {
  position: relative;
  display: grid;
  grid-template-columns: 8px 1fr;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 7px;
  background: var(--bg-inset);
  border: 1px solid var(--line-soft);
  border-radius: 4px;
  font-size: 11px;
  overflow: hidden;
  transition: border-color 200ms, background 200ms;
}
.c1-cell-light {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-4);
  flex-shrink: 0;
}
.c1-cell-sym { font-weight: 600; letter-spacing: 0.02em; }
.c1-cell-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 2px;
  background: rgba(255,255,255,0.03);
}
.c1-cell-bar-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--mint);
  box-shadow: 0 0 6px var(--mint-glow);
  transition: width 500ms cubic-bezier(.2,.7,.2,1);
}
.c1-cell.pending .c1-cell-light { background: #2a3340; }
.c1-cell.pending .c1-cell-sym   { color: var(--text-4); }
.c1-cell.done .c1-cell-light    { background: var(--mint); box-shadow: 0 0 6px var(--mint-glow); }
.c1-cell.done .c1-cell-sym      { color: var(--text-2); }
.c1-cell.done                   { border-color: rgba(34,197,94,0.2); }
.c1-cell.active {
  border-color: var(--amber);
  background: rgba(245,158,11,0.08);
  box-shadow: 0 0 0 1px rgba(245,158,11,0.2), 0 0 14px rgba(245,158,11,0.15);
}
.c1-cell.active .c1-cell-light  { background: var(--amber); box-shadow: 0 0 8px rgba(245,158,11,0.7); animation: c1-pulse 0.8s infinite; }
.c1-cell.active .c1-cell-sym    { color: var(--amber); }
.c1-cell.active .c1-cell-bar-fill { background: var(--amber); box-shadow: 0 0 6px rgba(245,158,11,0.7); }
.c1-cell.retry                  { border-color: var(--red); background: rgba(239,68,68,0.06); }
.c1-cell.retry .c1-cell-light   { background: var(--red); box-shadow: 0 0 8px rgba(239,68,68,0.7); }
.c1-cell.retry .c1-cell-sym     { color: var(--red); }
.c1-cell.retry .c1-cell-bar-fill { background: var(--red); }
.c1-cell.selected { border-color: var(--text-2); background: rgba(255,255,255,0.04); }
.c1-cell:hover { cursor: pointer; }

/* ─────────────  TICKER DETAIL POPOVER  ───────────── */
.c1-ticker-detail {
  position: absolute;
  right: 16px;
  bottom: 96px;
  width: 280px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  z-index: 6;
  box-shadow: 0 12px 32px -8px rgba(0,0,0,0.6);
  animation: c1-detail-in 200ms cubic-bezier(.2,.7,.2,1);
}
@keyframes c1-detail-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.c1-ticker-detail.pinned { border-color: var(--mint-dim); }
.c1-ticker-detail-head {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.c1-ticker-detail-sym {
  font-size: 18px; font-weight: 700; letter-spacing: 0.04em;
  font-family: var(--mono);
  color: var(--text-1);
  flex: 1;
}
.c1-ticker-detail-status {
  font-size: 9px; letter-spacing: 0.12em; font-weight: 700;
  padding: 3px 8px; border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--text-3);
}
.c1-ticker-detail-status.done    { color: var(--mint); border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.08); }
.c1-ticker-detail-status.active  { color: var(--amber); border-color: rgba(245,158,11,0.5); background: rgba(245,158,11,0.08); }
.c1-ticker-detail-status.retry   { color: var(--red); border-color: rgba(239,68,68,0.5); background: rgba(239,68,68,0.08); }
.c1-ticker-detail-status.pending { color: var(--text-4); }
.c1-ticker-detail-close {
  background: transparent; border: none; color: var(--text-3);
  font-size: 18px; cursor: pointer; padding: 0 4px;
  line-height: 1;
}
.c1-ticker-detail-close:hover { color: var(--text-1); }
.c1-ticker-detail-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 4px 0;
  font-size: 11px;
}
.c1-ticker-detail-hint {
  margin-top: 6px;
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.08em;
}

/* ─────────────  EVENT LOG  ───────────── */
.c1-log-list {
  display: flex; flex-direction: column;
  font-size: 11.5px;
  max-height: 168px;
  overflow: hidden;
}
.c1-log-row {
  display: grid;
  grid-template-columns: 56px 50px 1fr;
  gap: 8px;
  padding: 3px 0;
  border-top: 1px dashed var(--line-soft);
  color: var(--text-3);
  white-space: nowrap; overflow: hidden;
  align-items: center;
  animation: c1-log-in 350ms cubic-bezier(.2,.7,.2,1);
}
@keyframes c1-log-in {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.c1-log-row:first-child { border-top: none; }
.c1-log-row.fresh .c1-log-msg { color: var(--text-1); }
.c1-log-row.fresh::before {
  /* fresh row gets a left bar accent */
  content: ""; position: absolute; left: 0; width: 2px; height: 16px;
  background: var(--mint);
  box-shadow: 0 0 8px var(--mint-glow);
}
.c1-log-t { font-variant-numeric: tabular-nums; font-size: 11px; }
.c1-log-tag {
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.08em;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--line);
  color: var(--text-3);
  font-weight: 600;
}
.tag-info  { color: var(--blue); border-color: rgba(96,165,250,0.4) !important; background: rgba(96,165,250,0.08); }
.tag-ok    { color: var(--mint); border-color: rgba(34,197,94,0.4) !important; background: rgba(34,197,94,0.08); }
.tag-retry { color: var(--amber); border-color: rgba(245,158,11,0.5) !important; background: rgba(245,158,11,0.08); }
.tag-warn  { color: var(--red); border-color: rgba(239,68,68,0.5) !important; background: rgba(239,68,68,0.08); }
.c1-log-msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─────────────  BOTTOM TIMELINE  ───────────── */
.c1-bottom {
  background: var(--bg-panel);
  padding: 14px 16px;
}
.c1-bottom-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 10px;
}
.c1-segbar {
  display: flex;
  gap: 4px;
}
.c1-seg {
  position: relative;
  height: 22px;
  background: var(--bg-inset);
  border: 1px solid var(--line-soft);
  border-radius: 3px;
  overflow: hidden;
  min-width: 40px;
}
.c1-seg.done   { border-color: rgba(34,197,94,0.3); }
.c1-seg.active { border-color: var(--mint); box-shadow: 0 0 0 1px var(--mint-dim), inset 0 0 12px rgba(34,197,94,0.1); }
.c1-seg-fill {
  position: absolute; inset: 0 auto 0 0;
  background: linear-gradient(90deg, rgba(34,197,94,0.5), rgba(34,197,94,0.85));
  transition: width 400ms cubic-bezier(.2,.7,.2,1);
}
.c1-seg.done .c1-seg-fill { width: 100% !important; background: rgba(34,197,94,0.4); }
.c1-seg-label {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; letter-spacing: 0.12em; color: var(--text-2);
  z-index: 2;
  font-weight: 600;
  text-shadow: 0 0 4px rgba(0,0,0,0.6);
}
.c1-seg.done .c1-seg-label, .c1-seg.active .c1-seg-label { color: #fff; }

.c1-bars { margin-top: 12px; }
.c1-bars-head {
  display: flex; align-items: baseline; gap: 8px;
  margin-bottom: 5px; font-size: 11px;
}
.c1-bars-spacer { flex: 1; }
.c1-bars-track {
  position: relative; height: 8px;
  background: var(--bg-inset);
  border-radius: 999px;
  overflow: visible;
  border: 1px solid var(--line-soft);
}
.c1-bars-fill {
  position: absolute; inset: 0 auto 0 0; height: 100%;
  background: linear-gradient(90deg, var(--mint-soft), var(--mint));
  border-radius: 999px;
  box-shadow: 0 0 12px var(--mint-glow);
  transition: width 400ms ease;
}
.c1-bars-head-mark {
  position: absolute; top: -3px; bottom: -3px;
  width: 2px; background: #fff;
  transform: translateX(-1px);
  box-shadow: 0 0 8px var(--mint), 0 0 14px var(--mint-glow);
  border-radius: 1px;
}

/* ─────────────  QUEUED OVERLAY  ───────────── */
.c1-overlay {
  position: absolute;
  left: 0; right: 0; top: 56px; bottom: 0;
  background: rgba(11, 15, 20, 0.92);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 5;
}
.c1-queued-card {
  text-align: center;
  padding: 32px 48px;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 320px;
}
.c1-queued-pos {
  font-size: 88px;
  font-weight: 600;
  color: var(--mint);
  line-height: 1;
  margin: 8px 0 4px;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px var(--mint-glow);
  letter-spacing: -0.04em;
}
.c1-queued-label {
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--text-3);
  margin-bottom: 12px;
}
.c1-queued-sub {
  font-size: 11px;
  margin-bottom: 16px;
}
.c1-queued-dots { display: flex; justify-content: center; gap: 6px; }
.c1-queued-dots span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--mint);
  animation: c1-queued-bounce 1.4s ease-in-out infinite;
}
.c1-queued-dots span:nth-child(2) { animation-delay: 0.2s; }
.c1-queued-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes c1-queued-bounce {
  0%,80%,100% { opacity: 0.3; transform: scale(0.7); }
  40%         { opacity: 1; transform: scale(1); }
}

/* ─────────────  COMPLETE BANNER  ───────────── */
.c1-complete-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(90deg, rgba(34,197,94,0.15), rgba(34,197,94,0.05));
  border-top: 1px solid rgba(34,197,94,0.4);
  animation: c1-complete-in 600ms cubic-bezier(.2,.7,.2,1);
}
@keyframes c1-complete-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.c1-complete-led {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 16px var(--mint), 0 0 32px var(--mint-glow);
  animation: c1-pulse 1.4s ease-in-out infinite;
}
.c1-complete-banner .kicker {
  color: var(--mint);
  font-size: 12px;
  letter-spacing: 0.16em;
}
.c1-complete-sub {
  flex: 1;
  font-size: 11px;
  color: var(--text-2);
}
.c1-complete-btn {
  background: var(--mint);
  border: none;
  color: #0b0f14;
  padding: 7px 16px;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  font-weight: 700;
  cursor: pointer;
  transition: all 150ms;
}
.c1-complete-btn:hover {
  background: #4ade80;
  box-shadow: 0 0 16px var(--mint-glow);
}

/* =========================================================
   MOBILE — Prompt-Status HUD (≤700px viewports)
   Compact vertical layout. Activated by entry.jsx switching
   from C1.Concept/RC.Concept to M1.Backtest/M1.Research.
   Class prefix `m1-*` — never collides with desktop `c1-*`.
   ========================================================= */

.m1-root {
  width: 100%;
  height: 100%;
  min-height: 540px;
  background: #0b0f14;
  color: #c8d0db;
  font-family: ui-monospace, "JetBrains Mono", "Roboto Mono", "SF Mono", monospace;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.m1-root .kicker {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #4d5562;
  font-weight: 600;
}
.m1-root .dim { color: #4d5562; }
.m1-root .muted { color: #6a7280; }
.m1-root .mono { font-family: inherit; font-variant-numeric: tabular-nums; }
.m1-root .warn { color: #f59e0b; }
.m1-root .mint { color: #4ade80; }

/* In-chat host (mobile only): drop the desktop max-width:90% squeeze so the
   HUD fills the chat reply area edge-to-edge on phones. */
@media (max-width: 700px) {
  .reply-box.status-hud-host {
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    transform: none !important;
    padding: 0 !important;
  }
}

/* ─────────────  TOP BAR  ───────────── */
.m1-topbar {
  flex: none;
  padding: max(12px, env(safe-area-inset-top, 12px)) 16px 10px;
  border-bottom: 1px solid #161b22;
  background: linear-gradient(180deg, #0d1218 0%, #0b0f14 100%);
  position: relative;
}
.m1-topbar-row {
  display: flex; align-items: center; gap: 8px;
  min-width: 0;
}
.m1-topbar-row > * { flex-shrink: 0; }
.m1-topbar-sid { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m1-status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.25);
  font-size: 10px; font-weight: 700; letter-spacing: 0.12em;
  color: #4ade80;
  flex-shrink: 0;
}
.m1-status-pill.queue { background: rgba(96,165,250,0.1); border-color: rgba(96,165,250,0.25); color: #60a5fa; }
.m1-status-pill.retry { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: #f59e0b; animation: m1-pulse 1.4s infinite; }
.m1-status-pill.warn  { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.4); color: #ef4444; animation: m1-pulse 0.8s infinite; }
.m1-status-pill.ok    { background: rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.4); }
.m1-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.m1-status-pill.live .m1-status-dot { animation: m1-pulse 1.4s infinite; }
.m1-mode-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px;
  border: 1px solid #1a212c;
  border-radius: 6px;
  font-size: 9.5px;
}
.m1-mode-name { color: #c8d0db; font-weight: 700; letter-spacing: 0.1em; }
.m1-topbar-meta {
  display: flex; justify-content: space-between;
  margin-top: 6px;
  font-size: 9.5px;
}
.m1-topbar-meta .warn { animation: m1-pulse 1s infinite; font-weight: 700; }
/* Cancel button repositioned for mobile (existing .c1-cancel handles styling). */
.m1-cancel.c1-cancel {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 9px;
  padding: 4px 8px;
}

/* ─────────────  SCROLL CONTAINER  ───────────── */
.m1-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #2a3340 transparent;
}
.m1-scroll::-webkit-scrollbar { width: 4px; }
.m1-scroll::-webkit-scrollbar-thumb { background: #2a3340; border-radius: 2px; }

/* ─────────────  MODULE WRAPPER  ───────────── */
.m1-mod {
  background: #11161e;
  border: 1px solid #1a212c;
  border-radius: 8px;
  padding: 10px 12px;
}
.m1-mod-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}

/* ─────────────  PROGRESS HERO  ───────────── */
.m1-hero {
  background: linear-gradient(180deg, #11161e 0%, #0d1218 100%);
  border: 1px solid #1a212c;
  border-radius: 10px;
  padding: 18px 14px 12px;
  position: relative;
  overflow: visible;
}
.m1-hero-row {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 8px;
}
.m1-hero-pct {
  display: flex; align-items: baseline; gap: 2px;
  color: #4ade80;
  text-shadow: 0 0 16px rgba(34,197,94,0.3);
  min-width: 0;
}
.m1-hero-num {
  font-size: 38px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.m1-hero-pct-unit {
  font-size: 18px;
  color: #4ade80;
  opacity: 0.7;
  margin-left: 1px;
}
.m1-hero-eta { text-align: right; }
.m1-hero-eta-val {
  font-size: 16px; font-weight: 600;
  color: #c8d0db;
  margin-top: 2px;
}
.m1-hero-bar {
  height: 6px;
  background: #0a0d12;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  margin-bottom: 8px;
  margin-top: 4px;
}
.m1-hero-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e 0%, #4ade80 100%);
  border-radius: 3px;
  box-shadow: 0 0 12px rgba(34,197,94,0.5);
  transition: width 200ms ease-out;
}
.m1-hero-bar-shine {
  position: absolute;
  top: 0; bottom: 0;
  width: 24px;
  margin-left: -24px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  pointer-events: none;
  transition: left 200ms ease-out;
}
.m1-hero-msg {
  display: flex; flex-direction: column; gap: 2px;
  font-size: 11.5px;
  line-height: 1.4;
  min-width: 0;
  word-break: break-word;
}
.m1-hero-msg-primary { color: #4ade80; font-weight: 500; }
.m1-hero-msg-detail { font-size: 10.5px; word-break: break-word; }

/* ─────────────  PHASE LADDER  ───────────── */
.m1-ladder { display: flex; flex-direction: column; }
.m1-ladder-row {
  display: grid;
  grid-template-columns: 14px 22px 1fr auto auto;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border: none;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
  border-top: 1px dashed #1a212c;
  position: relative;
}
.m1-ladder-row:first-child { border-top: none; }
.m1-ladder-row.idle { opacity: 0.5; }
.m1-ladder-row.done { opacity: 0.85; }
.m1-ladder-row.active { background: rgba(34,197,94,0.04); }
.m1-ladder-mark {
  font-size: 11px;
  text-align: center;
  color: #4d5562;
}
.m1-ladder-row.active .m1-ladder-mark { color: #4ade80; animation: m1-pulse 1.2s infinite; }
.m1-ladder-row.done   .m1-ladder-mark { color: #22c55e; }
.m1-ladder-num {
  font-size: 9.5px; color: #4d5562;
}
.m1-ladder-name {
  font-size: 11px;
  color: #8b95a3;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m1-ladder-row.active .m1-ladder-name,
.m1-ladder-row.done .m1-ladder-name { color: #c8d0db; }
.m1-ladder-bar {
  width: 60px;
  height: 3px;
  background: #0a0d12;
  border-radius: 2px;
  overflow: hidden;
}
.m1-ladder-bar-fill {
  height: 100%;
  background: #4ade80;
  border-radius: 2px;
  transition: width 200ms ease-out;
}
.m1-ladder-row.done .m1-ladder-bar-fill { opacity: 0.5; }
.m1-ladder-time {
  font-size: 9.5px; color: #6a7280;
  font-variant-numeric: tabular-nums;
  min-width: 32px; text-align: right;
}
.m1-ladder-row.active .m1-ladder-time { color: #4ade80; }
.m1-ladder-expand {
  grid-column: 1 / -1;
  padding: 6px 4px 2px 36px;
  margin-top: 2px;
  border-top: 1px dashed #1a212c;
}
.m1-ladder-desc {
  font-size: 10.5px;
  color: #8b95a3;
  line-height: 1.4;
}

/* ─────────────  TELEMETRY  ───────────── */
.m1-tele-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.m1-tele-cell {
  background: #0a0d12;
  border: 1px solid #161b22;
  border-radius: 5px;
  padding: 6px 8px;
}
.m1-tele-val {
  font-size: 16px;
  font-weight: 700;
  color: #c8d0db;
  margin-top: 2px;
  line-height: 1;
}
.m1-tele-sub {
  font-size: 9px;
  margin-top: 2px;
}

/* ─────────────  TICKERS  ───────────── */
.m1-tickers {
  display: grid;
  gap: 4px;
}
.m1-cell {
  background: #0a0d12;
  border: 1px solid #161b22;
  border-radius: 4px;
  padding: 5px 6px 7px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  overflow: hidden;
}
.m1-cell-light {
  position: absolute; top: 5px; right: 5px;
  width: 4px; height: 4px; border-radius: 50%;
  background: #2a3340;
}
.m1-cell-sym {
  font-size: 10.5px;
  font-weight: 600;
  color: #8b95a3;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.m1-cell-bar {
  height: 2px;
  background: #161b22;
  border-radius: 1px;
  overflow: hidden;
  margin-top: 2px;
}
.m1-cell-bar-fill {
  height: 100%;
  background: #4ade80;
  transition: width 200ms ease-out;
}
.m1-cell.done .m1-cell-light { background: #22c55e; box-shadow: 0 0 4px rgba(34,197,94,0.5); }
.m1-cell.done .m1-cell-sym { color: #c8d0db; }
.m1-cell.active .m1-cell-light { background: #4ade80; animation: m1-pulse 0.8s infinite; }
.m1-cell.active { border-color: rgba(74,222,128,0.4); }
.m1-cell.active .m1-cell-sym { color: #4ade80; }
.m1-cell.retry .m1-cell-light { background: #f59e0b; }
.m1-cell.retry .m1-cell-sym { color: #f59e0b; }

/* ─────────────  SERIES (research)  ───────────── */
.m1-series-mod { background: rgba(96,165,250,0.04); border-color: rgba(96,165,250,0.15); }
.m1-series-row {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.m1-series-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px;
  background: #0a0d12;
  border: 1px solid #161b22;
  border-radius: 999px;
  font-size: 10px;
}
.m1-series-light {
  width: 5px; height: 5px; border-radius: 50%;
  background: #2a3340;
}
.m1-series-name { color: #8b95a3; }
.m1-series-pill.done .m1-series-light { background: #22c55e; box-shadow: 0 0 4px rgba(34,197,94,0.4); }
.m1-series-pill.done .m1-series-name { color: #c8d0db; }
.m1-series-pill.done { border-color: rgba(34,197,94,0.2); }
.m1-series-pill.active { border-color: rgba(245,158,11,0.5); background: rgba(245,158,11,0.06); }
.m1-series-pill.active .m1-series-light { background: #f59e0b; animation: m1-pulse 0.8s infinite; }
.m1-series-pill.active .m1-series-name { color: #f59e0b; }

/* ─────────────  EVENTS  ───────────── */
.m1-events {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
}
.m1-event {
  display: grid;
  grid-template-columns: 50px 56px 1fr;
  gap: 6px;
  align-items: baseline;
  padding: 4px 0;
  border-top: 1px dashed #1a212c;
  font-size: 10.5px;
  line-height: 1.4;
}
.m1-event:first-child { border-top: none; }
.m1-event-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #6a7280;
}
.m1-event.info .m1-event-tag { color: #60a5fa; }
.m1-event.retry .m1-event-tag { color: #f59e0b; }
.m1-event.warn .m1-event-tag { color: #ef4444; }
.m1-event.ok .m1-event-tag { color: #22c55e; }
.m1-event-time { font-size: 9.5px; }
.m1-event-msg {
  color: #c8d0db;
  word-break: break-word;
  font-size: 10.5px;
}
.m1-events-empty {
  padding: 12px 0;
  text-align: center;
  font-size: 10px;
}

/* ─────────────  QUEUED OVERLAY  ───────────── */
.m1-queued {
  background: linear-gradient(180deg, rgba(96,165,250,0.05) 0%, transparent 100%);
  border: 1px solid rgba(96,165,250,0.2);
  border-radius: 10px;
  padding: 32px 16px;
  text-align: center;
  position: relative;
}
.m1-queued-rings {
  position: relative;
  width: 60px; height: 60px;
  margin: 0 auto 14px;
}
.m1-queued-rings span {
  position: absolute;
  top: 50%; left: 50%;
  width: 16px; height: 16px;
  border: 2px solid #60a5fa;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: m1-ring 1.6s ease-out infinite;
  opacity: 0;
}
.m1-queued-rings span:nth-child(2) { animation-delay: 0.5s; }
.m1-queued-rings span:nth-child(3) { animation-delay: 1.0s; }
@keyframes m1-ring {
  0%   { width: 16px; height: 16px; opacity: 0.8; }
  100% { width: 60px; height: 60px; opacity: 0; }
}
.m1-queued-pos {
  font-size: 28px;
  font-weight: 700;
  color: #60a5fa;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.m1-queued-help {
  font-size: 11px;
  margin-top: 4px;
}

/* ─────────────  DONE STRIP  ───────────── */
.m1-done {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(11,15,20,0.96), rgba(11,15,20,0.99));
  border-top: 1px solid rgba(34,197,94,0.4);
  z-index: 10;
  animation: m1-done-in 360ms cubic-bezier(.2,.7,.2,1);
}
.m1-done.research { border-top-color: rgba(96,165,250,0.4); }
.m1-done-led {
  width: 10px; height: 10px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 12px #4ade80, 0 0 24px rgba(34,197,94,0.4);
  animation: m1-pulse 1.4s infinite;
  flex-shrink: 0;
}
.m1-done.research .m1-done-led {
  background: #60a5fa;
  box-shadow: 0 0 12px #60a5fa, 0 0 24px rgba(96,165,250,0.4);
}
.m1-done-headtext { flex: 1; min-width: 0; }
.m1-done-headtext .kicker { color: #4ade80; }
.m1-done.research .m1-done-headtext .kicker { color: #60a5fa; }
.m1-done-msg {
  font-size: 12px;
  color: #c8d0db;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m1-done-arrow {
  font-size: 18px;
  color: #4ade80;
}
.m1-done.research .m1-done-arrow { color: #60a5fa; }
@keyframes m1-done-in {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ─────────────  RETRY TIER SHELL  ───────────── */
.m1-root.tier-2 { animation: m1-shake 0.4s ease-out; }
.m1-root.tier-2 .m1-topbar { border-bottom-color: rgba(245,158,11,0.4); }
.m1-root.tier-3 .m1-topbar { border-bottom-color: rgba(239,68,68,0.4); }
@keyframes m1-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-1.5px); }
  75% { transform: translateX(1.5px); }
}

/* ─────────────  ANIMATIONS  ───────────── */
@keyframes m1-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
