/* QuasiSILEX3 — X-Factor ~1995 industrial HUD */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
  --bg: #0a120a;
  --panel: #0e1a0e;
  --panel2: #122212;
  --border: #2a4a2a;
  --border-hi: #3d6b3d;
  --bevel-light: #3a5c3a;
  --bevel-dark: #061006;
  --text: #9ec89e;
  --text-dim: #5a8a5a;
  --text-hi: #d4f0d4;
  --amber: #e8c040;
  --amber-dim: #a88820;
  --cyan: #40c8c8;
  --magenta: #c848c8;
  --red: #c84040;
  --blue: #4080c8;
  --warn: #e87830;
  --ok: #40c860;
  --raw: #a88840;
  --scan: rgba(0, 255, 80, 0.03);
  --font-pixel: 'Press Start 2P', monospace;
  --font-ui: 'VT323', 'Courier New', monospace;
  --tip-bg: #0c1c0c;
  --tip-border: #3d6b3d;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 17px;
  line-height: 1.25;
  -webkit-font-smoothing: none;
  image-rendering: pixelated;
}

/* CRT scanline overlay — below tooltips */
body::after {
  content: '';
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    var(--scan) 2px,
    var(--scan) 4px
  );
  opacity: 0.5;
}

/* ── Tooltips (body-level float; CSS ::after disabled to avoid clipping) ── */
[data-tip] {
  cursor: help;
}

/* Legacy ::after tips suppressed — JS #float-tip renders above everything */
[data-tip]::after {
  content: none !important;
  display: none !important;
}

#float-tip {
  position: fixed;
  z-index: 100050;
  left: 0;
  top: 0;
  max-width: min(280px, 72vw);
  padding: 7px 9px;
  background: var(--tip-bg);
  border: 1px solid var(--tip-border);
  box-shadow: 2px 2px 0 #000, 0 0 16px rgba(64, 200, 200, 0.18);
  color: var(--text-hi);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.35;
  letter-spacing: 0.02em;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, -100%) scale(0.96);
  transition: opacity 0.1s, visibility 0.1s, transform 0.1s;
}
#float-tip.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -100%) scale(1);
}
#float-tip.below {
  transform: translate(-50%, 8px) scale(0.96);
}
#float-tip.below.show {
  transform: translate(-50%, 8px) scale(1);
}

/* ── Header ── */
#header {
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 10px;
  background: linear-gradient(180deg, #1a2e1a 0%, #0c180c 100%);
  border-bottom: 2px solid var(--border-hi);
  box-shadow: inset 0 1px 0 var(--bevel-light), 0 2px 0 var(--bevel-dark);
}

#header h1 {
  font-family: var(--font-pixel);
  font-size: 9px;
  color: var(--amber);
  letter-spacing: 0.06em;
  text-shadow: 2px 2px 0 #000, 0 0 8px rgba(232, 192, 64, 0.35);
  white-space: nowrap;
}

#header .hstats {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 15px;
  color: var(--text-dim);
}

#header .hstats span {
  white-space: nowrap;
}

#header .hstats b {
  color: var(--amber);
  font-weight: normal;
}

#header .hacts {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ── Layout ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

#body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

#left {
  width: min(40vw, 440px);
  min-width: 300px;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 3px solid var(--border);
  box-shadow: inset -2px 0 0 var(--bevel-dark);
  overflow: hidden;
}

#right {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #060e06;
  overflow: hidden;
}

/* ── Bevel boxes ── */
.box {
  background: var(--panel2);
  border: 2px solid var(--border);
  box-shadow:
    inset 1px 1px 0 var(--bevel-light),
    inset -1px -1px 0 var(--bevel-dark),
    2px 2px 0 #000;
  margin: 5px 7px;
  padding: 7px;
}

.box-title {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--cyan);
  letter-spacing: 0.08em;
  margin-bottom: 5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-shadow: 1px 1px 0 #000;
}

.box-title .dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 5px;
  box-shadow: 1px 1px 0 #000;
  vertical-align: middle;
}

#left-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hi) var(--panel);
}

#left-scroll::-webkit-scrollbar { width: 7px; }
#left-scroll::-webkit-scrollbar-track { background: var(--panel); }
#left-scroll::-webkit-scrollbar-thumb { background: var(--border-hi); border: 1px solid #000; }

/* ── System flow — Rube-Goldberg process machine ── */
#sys-box {
  flex-shrink: 0;
}

.sys-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.sys-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 3px;
  vertical-align: middle;
  box-shadow: 1px 1px 0 #000;
}

.sys-flow {
  position: relative;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(40, 80, 40, 0.15), transparent 55%),
    #060c06;
  border: 1px solid #1a301a;
  box-shadow: inset 1px 1px 0 #000;
  padding: 8px 6px 10px;
  min-height: 320px;
}

.rg-machine {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  position: relative;
}

/* ── Feed / product tanks ── */
.rg-tank {
  position: relative;
  background: linear-gradient(180deg, #122012 0%, #0a140a 100%);
  border: 2px solid #2a4a2a;
  box-shadow:
    inset 1px 1px 0 #3a5c3a,
    inset -1px -1px 0 #061006,
    2px 2px 0 #000;
  padding: 6px 8px 8px;
  text-align: center;
  cursor: pointer;
  z-index: 2;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.rg-tank:hover,
.rg-tank:focus-visible {
  border-color: var(--amber);
  outline: none;
  transform: translateY(-1px);
}
.rg-tank.active-view {
  border-color: var(--amber);
  box-shadow: 0 0 0 1px rgba(232, 192, 64, 0.35), 2px 2px 0 #000;
}
.rg-tank.on { border-color: var(--ok); }
.rg-tank.feed {
  margin: 0 12% 0;
  border-radius: 2px 2px 0 0;
}
.rg-tank-lid {
  height: 6px;
  margin: -6px 8% 4px;
  background: #3a5a30;
  border: 1px solid #1a301a;
  box-shadow: 1px 1px 0 #000;
}
.rg-tank-nozzle {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 14px;
  height: 8px;
  margin-left: -7px;
  background: #3a4a30;
  border: 1px solid #1a301a;
  z-index: 3;
}
.rg-tank-lab {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.rg-tank-val {
  font-size: 17px;
  color: var(--amber);
  line-height: 1.15;
}
.rg-tank.prod .rg-tank-val { color: var(--magenta); }
.rg-tank.tails .rg-tank-val { color: #80a060; }
.rg-tank-bar {
  height: 7px;
  background: #061006;
  border: 1px solid #1a301a;
  margin-top: 4px;
  overflow: hidden;
}
.rg-tank-bar > i {
  display: block;
  height: 100%;
  width: 0%;
  transition: width 0.25s;
}
.rg-tank.feed .rg-tank-bar > i { background: var(--raw); }
.rg-tank.prod .rg-tank-bar > i { background: var(--magenta); }
.rg-tank.tails .rg-tank-bar > i { background: #608050; }
.rg-out-line {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Pipes between stages (material flow) ── */
.rg-pipe {
  position: relative;
  height: 22px;
  margin: 0 auto;
  width: 18px;
  z-index: 1;
}
.rg-pipe-bore {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 10px;
  margin-left: -5px;
  background: #0a100a;
  border-left: 2px solid #2a3a22;
  border-right: 2px solid #2a3a22;
  overflow: hidden;
}
.rg-flange {
  position: absolute;
  left: 50%;
  width: 16px;
  height: 4px;
  margin-left: -8px;
  background: #3a4a30;
  border: 1px solid #1a301a;
  z-index: 2;
}
.rg-flange.top { top: -1px; }
.rg-flange.bot { bottom: -1px; }

.rg-blob {
  position: absolute;
  left: 1px;
  width: 6px;
  height: 6px;
  background: var(--raw);
  box-shadow: 0 0 4px var(--raw);
  opacity: 0.15;
  top: -8px;
}
.sys-flow.running .rg-blob {
  opacity: 1;
  animation: rgDrop 1.15s linear infinite;
}
.rg-pipe.stream-raw .rg-blob {
  background: var(--raw);
  box-shadow: 0 0 5px var(--raw);
}
.rg-pipe.stream-gas .rg-blob {
  background: #40a0c8;
  box-shadow: 0 0 5px #40a0c8;
}
.rg-pipe.stream-hot .rg-blob {
  background: var(--magenta);
  box-shadow: 0 0 5px var(--magenta);
}
.rg-blob.b1 { animation-delay: 0.38s !important; }
.rg-blob.b2 { animation-delay: 0.76s !important; }
.rg-blob.b3 { animation-delay: 1.05s !important; }

@keyframes rgDrop {
  0%   { top: -6px; opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

/* ── Stage machine boxes ── */
.rg-stage {
  --stage: #40c860;
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr 18px;
  align-items: center;
  gap: 6px;
  margin: 0 6%;
  padding: 8px 10px 8px 8px;
  min-height: 44px;
  background:
    linear-gradient(180deg, #142214 0%, #0c160c 55%, #0a120a 100%);
  border: 2px solid #2a4a2a;
  box-shadow:
    inset 1px 1px 0 #3a5c3a,
    inset -1px -1px 0 #061006,
    2px 2px 0 #000;
  cursor: pointer;
  z-index: 2;
  transition: border-color 0.12s, transform 0.1s, box-shadow 0.12s;
}
.rg-stage.side-left  { margin-right: 14%; margin-left: 4%; }
.rg-stage.side-right { margin-left: 14%; margin-right: 4%; }

.rg-stage:hover,
.rg-stage:focus-visible {
  border-color: var(--stage);
  outline: none;
  transform: translateY(-1px);
  box-shadow:
    inset 1px 1px 0 #3a5c3a,
    0 0 10px color-mix(in srgb, var(--stage) 35%, transparent),
    2px 2px 0 #000;
}
.rg-stage.on {
  border-color: var(--stage);
  background:
    linear-gradient(180deg, #183018 0%, #0e1c0e 55%, #0a140a 100%);
}
.rg-stage.active-view {
  border-color: var(--amber);
  box-shadow: 0 0 0 1px rgba(232, 192, 64, 0.4), 2px 2px 0 #000;
}

.rg-stage-bolt {
  position: absolute;
  width: 5px;
  height: 5px;
  background: #4a6a40;
  border: 1px solid #1a301a;
  box-shadow: inset 1px 1px 0 #7a9a60;
}
.rg-stage-bolt.tl { top: 3px; left: 3px; }
.rg-stage-bolt.tr { top: 3px; right: 3px; }
.rg-stage-bolt.bl { bottom: 3px; left: 3px; }
.rg-stage-bolt.br { bottom: 3px; right: 3px; }

.rg-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  color: #041004;
  box-shadow: 1px 1px 0 #000, inset -1px -1px 0 rgba(0,0,0,0.35);
}
.rg-stage-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.rg-name {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.1;
}
.rg-sub {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rg-meter {
  height: 5px;
  background: #061006;
  border: 1px solid #1a301a;
  overflow: hidden;
  margin-top: 1px;
}
.rg-meter > i {
  display: block;
  height: 100%;
  width: 0%;
  transition: width 0.2s;
}
.rg-gear {
  font-size: 12px;
  color: #3a5a3a;
  opacity: 0.7;
  animation: none;
}
.sys-flow.running .rg-stage.on .rg-gear {
  animation: rgSpin 2.8s linear infinite;
  color: var(--stage);
  opacity: 1;
}
@keyframes rgSpin {
  to { transform: rotate(360deg); }
}

/* ── Y-split to product / tails ── */
.rg-ysplit {
  position: relative;
  height: 28px;
  margin: 0 8%;
}
.rg-y-joint {
  position: absolute;
  left: 50%;
  top: 0;
  width: 12px;
  height: 10px;
  margin-left: -6px;
  background: #3a4a30;
  border: 1px solid #1a301a;
}
.rg-y-arm {
  position: absolute;
  top: 8px;
  width: 42%;
  height: 16px;
  border-top: 3px solid #2a3a22;
}
.rg-y-arm.prod {
  left: 8%;
  border-left: 3px solid #2a3a22;
  border-top-left-radius: 8px;
}
.rg-y-arm.tails {
  right: 8%;
  border-right: 3px solid #2a3a22;
  border-top-right-radius: 8px;
}
.rg-y-arm .rg-pipe-bore {
  left: auto;
  right: auto;
  width: 100%;
  height: 8px;
  margin: 0;
  top: -5px;
  border: 1px solid #2a3a22;
  background: #0a100a;
}
.rg-y-arm.prod .rg-blob {
  background: var(--magenta);
  box-shadow: 0 0 4px var(--magenta);
  animation-name: rgSlideLeft;
}
.rg-y-arm.tails .rg-blob {
  background: #608050;
  box-shadow: 0 0 4px #608050;
  animation-name: rgSlideRight;
}
.sys-flow.running .rg-y-arm .rg-blob {
  opacity: 1;
  animation-duration: 1.3s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes rgSlideLeft {
  0%   { left: 90%; top: 0; opacity: 0; }
  15%  { opacity: 1; }
  100% { left: 0%; top: 0; opacity: 0; }
}
@keyframes rgSlideRight {
  0%   { left: 0%; top: 0; opacity: 0; }
  15%  { opacity: 1; }
  100% { left: 90%; top: 0; opacity: 0; }
}

.rg-out-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
  padding: 0 2px;
}
.rg-out-row .rg-tank {
  margin: 0;
  min-height: 64px;
}

.rg-io {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

.rg-stage.bypassed {
  opacity: 0.45;
  filter: grayscale(0.4);
  border-style: dashed;
}
.rg-stage.bypassed .rg-gear {
  animation: none !important;
}

/* Tails → feed recycle loop */
.rg-recycle {
  margin-top: 8px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: linear-gradient(90deg, rgba(96, 128, 80, 0.25), rgba(168, 136, 64, 0.2));
  border: 1px dashed #608050;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  box-shadow: inset 1px 1px 0 #000;
}
.rg-recycle:hover {
  border-color: var(--amber);
  color: var(--text-hi);
}
.rg-recycle-arrow {
  font-size: 16px;
  color: #80a060;
}
.rg-recycle b {
  color: var(--amber);
  font-weight: normal;
}
.rg-recycle-flow {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 11px;
}

.sys-flow.running .rg-recycle {
  animation: recPulse 2.2s ease-in-out infinite;
}
@keyframes recPulse {
  0%, 100% { box-shadow: inset 1px 1px 0 #000; }
  50% { box-shadow: inset 1px 1px 0 #000, 0 0 8px rgba(128, 160, 96, 0.35); }
}

/* ML controller side-node (not on fluid pipes) */
.rg-ctrl {
  margin-top: 6px;
  padding: 6px 8px;
  display: grid;
  grid-template-columns: 24px 1fr 42px;
  align-items: center;
  gap: 6px;
  background: #12180a;
  border: 1px dashed #6a5a20;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
}
.rg-ctrl:hover,
.rg-ctrl.active-view {
  border-color: var(--amber);
  color: var(--text-hi);
}
.rg-ctrl-lab {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rg-ctrl .rg-meter {
  height: 5px;
  background: #061006;
  border: 1px solid #1a301a;
  overflow: hidden;
}
.rg-ctrl .rg-meter > i {
  display: block;
  height: 100%;
  width: 0%;
}

.sys-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
  gap: 6px;
  flex-wrap: wrap;
}
.sys-status .live {
  color: var(--ok);
}
.sys-status .idle {
  color: var(--warn);
}

/* Compact KPI strip */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.kpi {
  background: #0a160a;
  border: 1px solid var(--border);
  padding: 4px 5px;
  box-shadow: inset 1px 1px 0 #000;
  cursor: help;
}
.kpi .k-lab {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.kpi .k-val {
  font-size: 18px;
  color: var(--amber);
  line-height: 1.05;
}

/* Controls */
lbl {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
  margin-bottom: 0;
}

.val {
  font-size: 13px;
  color: var(--text-hi);
  float: right;
}

input[type=range] {
  width: 100%;
  height: 12px;
  accent-color: var(--amber);
  cursor: pointer;
  margin: 1px 0 0;
}

.btn {
  font-family: var(--font-ui);
  font-size: 15px;
  padding: 4px 7px;
  background: linear-gradient(180deg, #1e3a1e 0%, #0e1e0e 100%);
  color: var(--text-hi);
  border: 2px solid var(--border-hi);
  box-shadow: inset 1px 1px 0 var(--bevel-light), 2px 2px 0 #000;
  cursor: pointer;
  text-align: center;
  letter-spacing: 0.04em;
  user-select: none;
}

.btn:hover { color: var(--amber); border-color: var(--amber-dim); }
.btn:active {
  box-shadow: inset 2px 2px 0 #000;
  transform: translate(1px, 1px);
}
.btn.active {
  background: linear-gradient(180deg, #3a4a10 0%, #1e2808 100%);
  color: var(--amber);
  border-color: var(--amber);
  box-shadow: inset 0 0 8px rgba(232, 192, 64, 0.25), 2px 2px 0 #000;
}
.btn.danger {
  border-color: #6a3030;
  color: #e0a0a0;
}
.btn.danger.active {
  border-color: var(--red);
  color: #ff8080;
  background: linear-gradient(180deg, #4a1818 0%, #280808 100%);
}

.btn-row {
  display: flex;
  gap: 4px;
  margin-top: 5px;
}
.btn-row .btn { flex: 1; }

.ctrl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
}

.log {
  font-size: 12px;
  color: var(--text-dim);
  max-height: 64px;
  overflow-y: auto;
  font-family: var(--font-ui);
  line-height: 1.3;
}
.log .ok { color: var(--ok); }
.log .warn { color: var(--warn); }
.log .err { color: var(--red); }
.log .info { color: var(--cyan); }

/* ── Right panel ── */
#view-tabs {
  display: flex;
  flex-wrap: wrap;
  flex-shrink: 0;
  background: #0a160a;
  border-bottom: 2px solid var(--border);
  gap: 0;
}

.vtab {
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 5px 8px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.vtab:hover { color: var(--text-hi); background: #122412; }
.vtab.active {
  color: var(--amber);
  background: #142814;
  border-bottom-color: var(--amber);
}

/* Explainer blurb under tabs (collapsible) */
#view-blurb {
  flex-shrink: 0;
  padding: 6px 12px 6px;
  background: #0a160a;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text);
  line-height: 1.35;
  max-height: 96px;
  overflow-y: auto;
}
#view-blurb.collapsed {
  max-height: 32px;
  overflow: hidden;
}
#view-blurb .blurb-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  gap: 8px;
}
#view-blurb .blurb-head:hover strong {
  color: var(--text-hi);
}
#view-blurb strong,
#blurb-title {
  color: var(--amber);
  font-weight: normal;
  font-family: var(--font-pixel);
  font-size: 8px;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 0;
}
#view-blurb .blurb-body {
  margin-top: 4px;
}
#view-blurb .io {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-dim);
}
#view-blurb .io b {
  color: var(--cyan);
  font-weight: normal;
}

.collapse-chev {
  color: var(--text-dim);
  font-size: 12px;
  min-width: 1em;
  text-align: right;
}
.box.collapsible .box-title {
  cursor: pointer;
  user-select: none;
}
.box.collapsible .box-title:hover {
  color: var(--text-hi);
}
.box.collapsed {
  padding-bottom: 4px;
}
.box-body {
  /* filled by JS display toggle */
}

#view-controls {
  flex-shrink: 0;
  padding: 5px 10px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  min-height: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: flex-end;
}

.vc-group {
  display: flex;
  flex-direction: column;
  min-width: 90px;
  flex: 1 1 90px;
  max-width: 180px;
}
.vc-group lbl {
  margin-top: 0;
  font-size: 12px;
}
.vc-group .val { float: none; }
.vc-group.btn-wrap {
  max-width: 140px;
  flex: 0 0 auto;
  justify-content: flex-end;
}

#stage-canvas-wrap {
  flex: 1 1 auto;
  min-height: 200px;
  position: relative;
  background: #040a04;
  overflow: hidden;
}

#stage-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 200px;
  cursor: crosshair;
  background: #040a04;
}

#stage-caption {
  position: absolute;
  left: 8px;
  bottom: 6px;
  right: 8px;
  font-family: var(--font-pixel);
  font-size: 6px;
  color: var(--amber-dim);
  text-shadow: 1px 1px 0 #000;
  pointer-events: none;
  line-height: 1.5;
  opacity: 0.85;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  #left {
    width: 38vw;
    min-width: 240px;
  }
  #header h1 { font-size: 7px; }
  #header .hstats { font-size: 12px; gap: 7px; }
  .vtab { font-size: 11px; padding: 4px 5px; }
  .kpi .k-val { font-size: 15px; }
  .sys-flow { min-height: 220px; }
  #view-blurb { max-height: 70px; font-size: 12px; }
}

@media (max-height: 500px) {
  #header { height: 30px; }
  #header h1 { font-size: 7px; }
  #view-controls { padding: 2px 6px; }
  #view-blurb { max-height: 48px; padding: 4px 8px; }
  .sys-flow { min-height: 160px; }
}

@media (orientation: portrait) and (max-width: 700px) {
  #body { flex-direction: column; }
  #left {
    width: 100%;
    max-width: none;
    min-width: 0;
    height: 44%;
    border-right: none;
    border-bottom: 3px solid var(--border);
  }
  #right { height: 56%; }
}
