:root {
  --bg: #05070c;
  --panel: rgba(13, 17, 26, 0.82);
  --panel-2: rgba(18, 23, 34, 0.9);
  --line: rgba(120, 145, 180, 0.16);
  --text: #e8eefc;
  --muted: #8b9ab4;
  --dim: #5d6b85;
  --accent: #5ac8fa;
  --violet: #af52de;
  --green: #30d158;
  --amber: #ffd60a;
  --red: #ff453a;
  --mono: "SFMono-Regular", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --ui: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 16px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--ui);
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 18% -10%, rgba(90, 200, 250, 0.14), transparent 60%),
    radial-gradient(900px 600px at 92% 0%, rgba(175, 82, 222, 0.16), transparent 55%),
    radial-gradient(800px 500px at 50% 120%, rgba(48, 209, 88, 0.08), transparent 60%),
    var(--bg);
  overflow: hidden;
}

.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 11, 18, 0.95), rgba(8, 11, 18, 0.55));
  backdrop-filter: blur(10px); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  font-size: 22px; color: #041018;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  box-shadow: 0 0 26px rgba(90, 200, 250, 0.45);
}
.brand h1 { margin: 0; font-size: 17px; letter-spacing: 0.28em; font-weight: 700; }
.brand p { margin: 2px 0 0; font-size: 11px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
.status { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em;
  padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); background: rgba(255, 255, 255, 0.03); white-space: nowrap;
}
.chip-live { color: var(--green); border-color: rgba(48, 209, 88, 0.35); }
.chip-live i {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); margin-right: 6px; box-shadow: 0 0 10px var(--green);
  animation: blink 2.2s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

.layout {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 272px minmax(420px, 1fr) 392px;
  gap: 12px; padding: 12px;
}
.panel {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 20px 40px rgba(0, 0, 0, 0.35);
  min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px; font-size: 11px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--muted);
}
.panel-head h2 { margin: 0; font-size: 11px; font-weight: 600; }
.panel-head.sub { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 12px; }
.count {
  font-family: var(--mono); font-size: 10px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px;
}
.deck { display: flex; flex-direction: column; }
.algo-list { overflow-y: auto; padding: 0 10px 6px; display: grid; gap: 6px; }
.algo-card {
  --card-accent: var(--accent);
  text-align: left; width: 100%; cursor: pointer; color: var(--text);
  border: 1px solid var(--line); border-left: 2px solid var(--card-accent);
  background: rgba(255, 255, 255, 0.022); border-radius: 11px;
  padding: 9px 10px; transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s;
  display: grid; gap: 3px;
}
.algo-card:hover { background: rgba(255, 255, 255, 0.06); transform: translateX(2px); }
.algo-card.active {
  background: linear-gradient(90deg, rgba(90, 200, 250, 0.16), rgba(255, 255, 255, 0.02));
  box-shadow: 0 0 0 1px rgba(90, 200, 250, 0.35), 0 8px 24px rgba(0, 0, 0, 0.3);
}
.algo-card strong { font-size: 12.5px; letter-spacing: 0.02em; display: flex; align-items: center; gap: 7px; }
.algo-card small { font-size: 10.5px; color: var(--muted); line-height: 1.35; }
.algo-card .tags { display: flex; gap: 4px; margin-top: 3px; flex-wrap: wrap; }
.algo-card .tag {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.06em;
  color: var(--dim); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px;
}
.algo-card .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--card-accent); box-shadow: 0 0 8px var(--card-accent); }

.agent-list { overflow-y: auto; padding: 0 10px 12px; display: grid; gap: 5px; }
.agent {
  --agent-accent: var(--accent);
  display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 10px; border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.018); cursor: pointer; transition: background 0.15s;
}
.agent:hover { background: rgba(255, 255, 255, 0.05); }
.agent .glyph {
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 7px;
  font-size: 12px; color: #04070d; background: var(--agent-accent);
  box-shadow: 0 0 12px rgba(90, 200, 250, 0.25);
}
.agent .meta { min-width: 0; }
.agent .name { font-size: 10.5px; letter-spacing: 0.08em; font-family: var(--mono); }
.agent .role { font-size: 9.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent .state { font-family: var(--mono); font-size: 9px; color: var(--dim); }
.agent.working { border-color: rgba(90, 200, 250, 0.4); background: rgba(90, 200, 250, 0.08); }
.agent.working .state { color: var(--accent); animation: blink 1s infinite; }
.agent.done .state { color: var(--green); }
.agent.failed .state { color: var(--red); }

/* ---------------- stage ---------------- */
.stage { position: relative; }
.stage-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 13px 16px 10px; border-bottom: 1px solid var(--line);
}
.stage-title h2 { margin: 0 0 3px; font-size: 15px; letter-spacing: 0.01em; }
.stage-title p { margin: 0; font-size: 11px; color: var(--muted); max-width: 66ch; line-height: 1.45; }
.verdict {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; color: var(--muted);
}
.verdict.pass { color: var(--green); border-color: rgba(48, 209, 88, 0.45); background: rgba(48, 209, 88, 0.08); }
.verdict.fail { color: var(--red); border-color: rgba(255, 69, 58, 0.45); background: rgba(255, 69, 58, 0.08); }
.verdict.busy { color: var(--accent); border-color: rgba(90, 200, 250, 0.45); }
.verdict.busy::after {
  content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 6px;
  border-radius: 50%; background: var(--accent); animation: blink 0.8s infinite;
}

.canvas-wrap {
  position: relative; flex: 1; min-height: 260px;
  background: radial-gradient(ellipse at 50% 38%, rgba(30, 54, 92, 0.35), transparent 68%), #04060a;
  overflow: hidden;
}
#lab-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.hud { position: absolute; pointer-events: none; font-family: var(--mono); font-size: 10px; }
.hud-left { top: 12px; left: 14px; display: grid; gap: 4px; max-width: 48%; }
.hud-left .metric {
  display: flex; gap: 6px; align-items: baseline; padding: 3px 7px;
  background: rgba(5, 8, 13, 0.62); border: 1px solid rgba(120, 145, 180, 0.14);
  border-radius: 6px; color: var(--muted); width: fit-content;
}
.hud-left .metric b { color: var(--text); font-size: 10.5px; }
/* Domain metrics are always "label <b>value</b>", so they can share one grid and
   line their values up in a column; the quantum HUD keeps its richer inline
   markup (state |01> p 0.5 ...) which must stay a plain flex row. */
body.domain-mode .hud-left .metric {
  display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 8px;
  align-items: baseline; width: 100%;
}
.hud-right { top: 10px; right: 12px; display: flex; gap: 6px; pointer-events: auto; }
.icon {
  width: 26px; height: 26px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(8, 12, 19, 0.75); color: var(--muted);
  font-size: 13px; line-height: 1; display: grid; place-items: center;
}
.icon:hover { color: var(--text); border-color: rgba(90, 200, 250, 0.4); }
.icon.active { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
/* The step-panel toggle only means something inside a domain laboratory. */
#btn-rail { display: none; }
body.domain-mode #btn-rail { display: grid; }

.stage-hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em; color: rgba(139, 154, 180, 0.65);
  padding: 3px 9px; border: 1px solid rgba(120, 145, 180, 0.14); border-radius: 999px;
  background: rgba(5, 8, 13, 0.55); pointer-events: none;
}
.popup {
  position: absolute; z-index: 12; min-width: 220px; max-width: 330px;
  background: rgba(9, 13, 21, 0.97); border: 1px solid rgba(90, 200, 250, 0.35);
  border-radius: 12px; padding: 10px 12px; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  font-family: var(--mono); font-size: 10.5px; color: var(--muted); line-height: 1.55;
}
.popup h3 { margin: 0 0 6px; font-size: 11px; color: var(--accent); letter-spacing: 0.1em; }
.popup b { color: var(--text); }
.popup .row { display: flex; justify-content: space-between; gap: 12px; }
.popup .close { position: absolute; top: 6px; right: 8px; cursor: pointer; color: var(--dim); }
.popup .close:hover { color: var(--text); }
.popup pre { margin: 6px 0 0; font-size: 9.5px; color: var(--muted); white-space: pre-wrap; }

.boot {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px;
  background: rgba(4, 6, 10, 0.82); backdrop-filter: blur(4px); z-index: 10;
  transition: opacity 0.4s ease; font-family: var(--mono); font-size: 10.5px; color: var(--muted);
  letter-spacing: 0.12em;
}
.boot.hidden { opacity: 0; pointer-events: none; }
.boot-ring {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid rgba(90, 200, 250, 0.25); border-top-color: var(--accent);
  animation: spin 1.1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- timeline + bottom strip ---------------- */
.timeline {
  display: flex; align-items: center; gap: 10px; padding: 9px 14px;
  border-top: 1px solid var(--line); background: rgba(6, 9, 15, 0.6);
}
.pill {
  width: 30px; height: 26px; border-radius: 8px; cursor: pointer;
  border: 1px solid rgba(90, 200, 250, 0.35); background: rgba(90, 200, 250, 0.12);
  color: var(--accent); font-size: 11px; display: grid; place-items: center;
}
.pill:hover { background: rgba(90, 200, 250, 0.22); }
#scrub { flex: 1; accent-color: var(--accent); height: 3px; cursor: pointer; }
.moment-label { font-family: var(--mono); font-size: 9.5px; color: var(--dim); white-space: nowrap; }

.bottom-strip {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px; padding: 10px 14px 12px; border-top: 1px solid var(--line);
  max-height: 168px; overflow-y: auto;
}
.hist, .checks { display: grid; gap: 3px; align-content: start; }
.strip-label {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.14em;
  color: var(--dim); text-transform: uppercase; margin-bottom: 2px;
}
.hist-row { display: grid; grid-template-columns: 62px 1fr 56px; gap: 6px; align-items: center; }
.hist-row span { font-family: var(--mono); font-size: 9.5px; color: var(--muted); }
.hist-row .bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.hist-row .bar i {
  display: block; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, rgba(90, 200, 250, 0.55), var(--accent));
  transition: width 0.4s ease;
}
.check-row {
  font-family: var(--mono); font-size: 9.5px; display: grid; grid-template-columns: 12px 1fr;
  gap: 5px; color: var(--muted); line-height: 1.35;
}
.check-row b { color: var(--text); font-weight: 500; }
.check-row.pass .mark { color: var(--green); }
.check-row.fail .mark { color: var(--red); }
.check-row .detail { color: var(--dim); font-size: 9px; }

/* ---------------- console ---------------- */
.console { display: flex; flex-direction: column; background: rgba(8, 11, 17, 0.92); }
.console-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.02);
}
.console-head .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.console-head h2 { margin: 0; font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; color: var(--muted); font-weight: 500; }
.console-meta { margin-left: auto; font-family: var(--mono); font-size: 9px; color: var(--dim); }
.console-head .icon { width: 22px; height: 22px; font-size: 11px; }

.terminal {
  flex: 1; min-height: 150px; overflow-y: auto; padding: 10px 12px 14px;
  font-family: var(--mono); font-size: 11px; line-height: 1.5;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.014) 0 1px, transparent 1px 3px),
    rgba(3, 5, 9, 0.9);
  scrollbar-width: thin;
}
.msg { margin-bottom: 12px; animation: rise 0.25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
.msg .who {
  font-size: 9px; letter-spacing: 0.14em; color: var(--dim); margin-bottom: 3px;
  display: flex; gap: 6px; align-items: center;
}
.msg.user .who { color: var(--accent); }
.msg.agent .who { color: var(--violet); }
.msg.system .who { color: var(--amber); }
.msg .who .ts { color: var(--dim); letter-spacing: 0.04em; }
.msg .bubble { white-space: pre-wrap; word-break: break-word; color: #cfd9ea; }
.msg.user .bubble { color: #eaf4ff; }
.msg.agent .bubble { color: #e6dcf7; }
.msg.system .bubble { color: #d8d2b0; }
.msg .facts { margin-top: 4px; color: var(--green); font-size: 10px; }
.msg .meta-line { margin-top: 4px; color: var(--dim); font-size: 9px; }
.msg .crew-facts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.msg .crew-fact {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.06em;
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px;
  color: var(--muted);
}
.msg .crew-fact.ok { border-color: rgba(48, 209, 88, 0.4); color: var(--green); }
.msg .crew-fact.fail { border-color: rgba(255, 69, 58, 0.45); color: var(--red); }

.ascii-block {
  margin-top: 8px; border: 1px solid rgba(120, 145, 180, 0.18); border-radius: 10px;
  background: #04070c; overflow: hidden;
}
.ascii-block header {
  display: flex; gap: 6px; align-items: center; padding: 5px 8px;
  border-bottom: 1px solid rgba(120, 145, 180, 0.12);
  font-size: 8.5px; letter-spacing: 0.1em; color: var(--dim);
}
.ascii-block header .spacer { flex: 1; }
.ascii-block .art {
  margin: 0; padding: 8px; overflow-x: auto; font-family: var(--mono);
  font-size: 8px; line-height: 1.05; letter-spacing: 0; white-space: pre;
}
.ascii-block .art span { text-shadow: 0 0 6px currentColor; }
.mini {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.08em; cursor: pointer;
  border: 1px solid rgba(120, 145, 180, 0.25); background: transparent; color: var(--muted);
  border-radius: 5px; padding: 2px 6px;
}
.mini:hover { color: var(--text); border-color: rgba(90, 200, 250, 0.45); }
/* ---------------- controls + composer ---------------- */
.controls { border-top: 1px solid var(--line); padding: 9px 12px; background: rgba(10, 14, 21, 0.92); }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-bottom: 9px; }
.control-grid label {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 6px;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.1em;
  color: var(--dim); text-transform: uppercase;
}
.control-grid output { color: var(--accent); font-size: 9px; }
.control-grid input[type="range"] {
  grid-column: 1 / -1; width: 100%; height: 2px; accent-color: var(--accent); cursor: pointer;
}
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.act {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.09em; cursor: pointer;
  padding: 7px 6px; border-radius: 8px; color: var(--muted);
  border: 1px solid rgba(120, 145, 180, 0.2); background: rgba(255, 255, 255, 0.025);
  transition: all 0.15s ease; text-transform: uppercase;
}
.act:hover { color: var(--text); border-color: rgba(90, 200, 250, 0.45); background: rgba(90, 200, 250, 0.08); }
.act.primary {
  grid-column: 1 / -1; color: #041018; font-weight: 700; border: none;
  background: linear-gradient(135deg, var(--accent), #7be0ff);
  box-shadow: 0 6px 18px rgba(90, 200, 250, 0.25);
}
.act.primary:hover { box-shadow: 0 8px 24px rgba(90, 200, 250, 0.4); }
.act.active { color: var(--accent); border-color: var(--accent); background: rgba(90, 200, 250, 0.12); }
.act:disabled { opacity: 0.45; cursor: progress; }

.composer {
  display: grid; grid-template-columns: 1fr auto; gap: 8px;
  padding: 10px 12px 12px; border-top: 1px solid var(--line);
  background: rgba(9, 12, 19, 0.96);
}
.composer textarea {
  resize: none; border-radius: 10px; border: 1px solid rgba(120, 145, 180, 0.22);
  background: rgba(3, 5, 9, 0.85); color: var(--text); padding: 8px 10px;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.45; outline: none;
}
.composer textarea:focus { border-color: rgba(90, 200, 250, 0.5); box-shadow: 0 0 0 2px rgba(90, 200, 250, 0.12); }
.composer button {
  align-self: stretch; padding: 0 14px; border-radius: 10px; cursor: pointer;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; font-weight: 700;
  border: none; color: #06121a; background: linear-gradient(135deg, #7be0ff, var(--accent));
}
.composer button:disabled { opacity: 0.5; cursor: progress; }

footer {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 6px 18px 9px; font-family: var(--mono); font-size: 8.5px;
  letter-spacing: 0.06em; color: rgba(93, 107, 133, 0.8);
}
footer a { color: rgba(90, 200, 250, 0.75); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ---------------- overlays ---------------- */
.drop-mask {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: rgba(3, 6, 11, 0.78); backdrop-filter: blur(6px);
  font-family: var(--mono); font-size: 14px; letter-spacing: 0.16em; color: var(--accent);
  border: 2px dashed rgba(90, 200, 250, 0.5); border-radius: 20px; margin: 18px;
}
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: rgba(10, 15, 23, 0.97); border: 1px solid rgba(90, 200, 250, 0.4);
  color: var(--text); font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  padding: 8px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  max-width: 80vw;
}

/* ---------------- responsive ---------------- */
@media (max-width: 1400px) {
  .layout { grid-template-columns: 248px minmax(360px, 1fr) 360px; }
}
@media (max-width: 1180px) {
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .layout { grid-template-columns: 1fr; }
  .deck { max-height: 320px; }
  .stage { min-height: 620px; }
  .console { min-height: 560px; }
  .canvas-wrap { min-height: 380px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}




/* ---------- 1 TOR pay chip ---------- */
.chip-pay {
  cursor: pointer; color: #ffe89a; border-color: rgba(255, 214, 10, 0.45);
  background: linear-gradient(135deg, rgba(255, 214, 10, 0.16), rgba(255, 149, 0, 0.1));
  letter-spacing: 0.12em;
}
.chip-pay b { color: #fff; }
.chip-pay:hover { color: #fff; border-color: var(--amber); }

/* ---------- stage controller + dispatch chain ---------- */
.controller {
  margin: 0 12px 8px; padding: 7px 9px; border: 1px dashed var(--line); border-radius: 10px;
  font-family: var(--mono); font-size: 9.5px; color: var(--muted);
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
}
.controller .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.controller b { color: var(--text); letter-spacing: 0.06em; }
.comms {
  border-top: 1px solid var(--line); margin: 6px 10px 10px; padding-top: 8px;
  max-height: 150px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
}
.comm {
  font-family: var(--mono); font-size: 9.5px; padding: 4px 6px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.02); border-left: 2px solid rgba(90, 200, 250, 0.45);
  display: flex; flex-direction: column; gap: 1px;
}
.comm .route { color: var(--accent); letter-spacing: 0.04em; }
.comm .detail { color: var(--muted); }
.comm.fail { border-left-color: var(--red); }
.comm.idle { border-left-color: var(--dim); }

/* ---------- presenter overlay ---------- */
.presenter {
  position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 4;
  border-radius: 14px; padding: 10px 12px; background: rgba(6, 10, 16, 0.93);
  border: 1px solid rgba(90, 200, 250, 0.35);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5); backdrop-filter: blur(8px);
}
.presenter-bar {
  display: flex; align-items: center; gap: 10px; font-family: var(--mono);
  font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em;
}
.presenter-step { color: var(--accent); }
.presenter-title {
  color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.presenter-actions { display: flex; gap: 6px; }
.presenter-caption { margin: 8px 0 0; font-size: 13.5px; line-height: 1.5; color: #d7e6f7; }

.chip-btn {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--text);
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 9px; cursor: pointer;
}
.chip-btn:hover { border-color: var(--accent); color: #fff; }


/* ---------- agent profile drawer ---------- */
.drawer {
  position: fixed; right: 18px; top: 74px; width: 388px; z-index: 30;
  max-height: calc(100vh - 110px); overflow-y: auto; border-radius: 16px;
  background: rgba(10, 14, 22, 0.97); border: 1px solid var(--line);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.55); padding: 14px;
}
.drawer header {
  display: flex; gap: 10px; align-items: flex-start;
  border-left: 3px solid var(--agent-accent, var(--accent)); padding-left: 10px;
}
.drawer header .glyph { font-size: 22px; color: var(--agent-accent, var(--accent)); }
.drawer header h3 { margin: 0; font-size: 14px; letter-spacing: 0.14em; }
.drawer header p { margin: 2px 0 0; font-size: 11px; color: var(--muted); }
.drawer header .chip-btn { margin-left: auto; }
.drawer .badge {
  margin: 10px 0 0; padding: 6px 8px; border-radius: 8px; font-family: var(--mono);
  font-size: 9.5px; letter-spacing: 0.08em; color: #041018;
  background: linear-gradient(135deg, #5ac8fa, #30d158);
}
.drawer .focus { margin: 10px 0; font-size: 12px; color: #c7d6ea; line-height: 1.5; }
.drawer .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0; }
.drawer .stats div {
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px; text-align: center;
}
.drawer .stats b { display: block; font-family: var(--mono); font-size: 13px; color: #fff; }
.drawer .stats span { font-size: 9px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.1em; }
.drawer h4 {
  margin: 12px 0 6px; font-size: 10px; letter-spacing: 0.16em;
  color: var(--muted); text-transform: uppercase;
}
.drawer .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.drawer .tag {
  font-family: var(--mono); font-size: 9px; padding: 2px 6px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted);
}
.drawer .current, .drawer .note { font-size: 11.5px; color: #b9c9de; line-height: 1.45; margin: 0; }
.drawer .history { display: flex; flex-direction: column; gap: 6px; }
.drawer .history-row {
  display: grid; grid-template-columns: 16px 1fr auto; gap: 8px; align-items: start;
  padding: 6px; border-radius: 9px; background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--line);
}
.drawer .history-row p { margin: 2px 0 0; font-size: 10.5px; color: var(--muted); line-height: 1.4; }

/* ---------- qubit inspector ---------- */
.inspector {
  position: fixed; left: 300px; bottom: 18px; width: 478px; z-index: 28;
  max-height: calc(100vh - 140px); overflow-y: auto; border-radius: 16px;
  background: rgba(8, 12, 20, 0.98); border: 1px solid rgba(90, 200, 250, 0.28);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6); padding: 14px;
}
.inspector header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.inspector header h3 { margin: 0; font-size: 13px; letter-spacing: 0.16em; }
.inspector header p { margin: 3px 0 0; font-family: var(--mono); font-size: 9.5px; color: var(--muted); }
.inspector header .actions { display: flex; gap: 4px; }
.inspector-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 10px; }
.inspector h4 {
  margin: 0 0 6px; font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
}
.inspector .row {
  display: flex; justify-content: space-between; gap: 8px; font-size: 11px;
  padding: 3px 0; border-bottom: 1px dotted rgba(120, 145, 180, 0.12);
}
.inspector .row span { color: var(--muted); }
.inspector .row b { font-family: var(--mono); color: #eaf4ff; font-weight: 500; }
.inspector .prob { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.inspector .prob-row {
  display: grid; grid-template-columns: 28px 1fr 46px; gap: 6px; align-items: center;
  font-family: var(--mono); font-size: 10px; color: var(--muted);
}
.inspector .bar { height: 7px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.inspector .bar i { display: block; height: 100%; border-radius: 999px; }
.inspector .bar.violet i { background: linear-gradient(90deg, #7b3ad6, #af52de); }
.inspector .bar.cyan i { background: linear-gradient(90deg, #2f9bd0, #5ac8fa); }
.inspector .rho { margin-top: 12px; }
.inspector .matrix { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.inspector .cell {
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px; text-align: center;
}
.inspector .cell b { display: block; font-family: var(--mono); font-size: 11px; color: #fff; }
.inspector .cell span { font-size: 9px; color: var(--dim); }
.inspector .history { margin-top: 12px; color: #5ac8fa; }
.inspector .spark { width: 100%; height: 46px; display: block; margin-bottom: 8px; opacity: 0.9; }
.inspector .muted { color: var(--dim); text-transform: none; letter-spacing: 0; }
.inspector .note { font-size: 10.5px; color: var(--muted); line-height: 1.5; }

/* ---------- 1 TOR modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 60; padding: 20px;
  background: rgba(2, 4, 8, 0.82); backdrop-filter: blur(6px);
  display: grid; place-items: center;
}
.pay-card {
  width: min(920px, 96vw); max-height: 90vh; overflow-y: auto;
  border-radius: 20px; padding: 18px 18px 14px;
  background: linear-gradient(180deg, rgba(14, 19, 29, 0.99), rgba(8, 12, 19, 0.99));
  border: 1px solid rgba(255, 214, 10, 0.28);
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.7);
}
.pay-card header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  border-bottom: 1px solid var(--line); padding-bottom: 10px;
}
.pay-card header h3 { margin: 0; font-size: 15px; letter-spacing: 0.16em; }
.pay-card header p { margin: 3px 0 0; font-size: 11.5px; color: var(--muted); }
.pay-grid { display: grid; grid-template-columns: 260px 1fr; gap: 16px; margin-top: 14px; }
.pay-qr img { width: 100%; border-radius: 12px; background: #fff; padding: 6px; }
.pay-uri {
  display: block; margin: 8px 0; font-family: var(--mono); font-size: 9px;
  color: var(--muted); word-break: break-all;
}
.pay-details .row {
  display: flex; justify-content: space-between; gap: 10px; font-size: 11.5px;
  padding: 4px 0; border-bottom: 1px dotted rgba(120, 145, 180, 0.14);
}
.pay-details .row span { color: var(--muted); }
.pay-details .row b { font-family: var(--mono); color: #eaf4ff; font-weight: 500; text-align: right; }
.mono { font-family: var(--mono); }
.pay-field {
  display: block; margin: 10px 0 0; font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.pay-field input {
  width: 100%; margin-top: 4px; padding: 8px 10px; border-radius: 9px;
  background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line);
  color: var(--text); font-family: var(--mono); font-size: 11px;
}
.pay-actions { display: flex; gap: 8px; margin: 12px 0; }
.pay-result { margin-top: 6px; }
.pay-result .rule {
  display: grid; grid-template-columns: 16px 1fr; gap: 6px; font-size: 10.5px;
  padding: 4px 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.02); margin-top: 4px;
}
.pay-result .rule .mark { color: var(--green); }
.pay-result .rule.fail .mark { color: var(--red); }
.pay-result .rule .detail { grid-column: 2; color: var(--muted); font-family: var(--mono); font-size: 9.5px; }
.pay-result .paid {
  color: #041018; background: linear-gradient(135deg, #30d158, #5ac8fa);
  padding: 7px 9px; border-radius: 9px; font-family: var(--mono);
  font-size: 10.5px; letter-spacing: 0.08em; margin-bottom: 6px;
}
.pay-result .refused {
  color: #ffd9d6; border: 1px solid rgba(255, 69, 58, 0.45);
  background: rgba(255, 69, 58, 0.12); padding: 7px 9px; border-radius: 9px; font-size: 11px;
}
.pay-rules { margin: 10px 0 0; padding-left: 16px; color: var(--dim); font-size: 10px; line-height: 1.6; }
.pay-card footer {
  display: flex; justify-content: space-between; margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--line); font-size: 10px; color: var(--dim);
}
.pay-card footer a { color: var(--accent); }
.pay-loading { font-family: var(--mono); font-size: 11px; color: var(--muted); }
@media (max-width: 1280px) {
  .pay-grid { grid-template-columns: 200px 1fr; }
  .inspector { left: 286px; width: 430px; }
}

.drawer .history-row b { font-size: 11px; }
.drawer .history-row .mark { color: var(--green); }
.drawer .history-row.failed .mark { color: var(--red); }
.drawer .history-row .ms { font-family: var(--mono); font-size: 9px; color: var(--dim); }
.agent.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(90, 200, 250, 0.4); }
.agent.controlling .name::after { content: " ◆"; color: var(--green); }

/* ---------------- domain laboratories ---------------- */
body[data-domain="crypto"] { --accent: #ffd60a; }
body[data-domain="biotech"] { --accent: #30d158; }
body[data-domain="materials"] { --accent: #af52de; }

.domain-bar {
  display: flex; gap: 6px; align-items: center; padding: 8px 12px 0;
  flex-wrap: wrap;
}
.dtab {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em;
  padding: 5px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.dtab:hover { color: var(--text); border-color: rgba(90, 200, 250, 0.45); }
.dtab.active {
  color: #04121a; border-color: transparent;
  background: linear-gradient(135deg, var(--accent), rgba(255, 255, 255, 0.65));
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 45%, transparent);
}

.math-rail {
  position: absolute; left: 12px; bottom: 12px; width: min(470px, calc(100% - 24px));
  padding: 10px 12px 9px; border-radius: 12px;
  background: linear-gradient(180deg, rgba(6, 10, 16, 0.93), rgba(4, 7, 12, 0.96));
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px); pointer-events: auto; z-index: 4;
}
/* The rail floats over the stage, so it must never be a trap: the header is the
   drag handle (and the close/reset buttons live in it), while the body stays
   inert for the camera - only the header captures the pointer. */
.math-rail.dragging { border-color: var(--accent); cursor: grabbing; }
.math-head {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent);
  cursor: grab; user-select: none; touch-action: none;
}
.math-head:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.math-rail.dragging .math-head { cursor: grabbing; }
.math-grip { color: var(--dim); letter-spacing: 0; font-size: 10px; }
.math-head .step-kicker {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rail-btn {
  width: 18px; height: 18px; padding: 0; display: grid; place-items: center;
  border-radius: 6px; cursor: pointer; line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.1); background: rgba(255, 255, 255, 0.04);
  color: var(--muted); font-family: var(--mono); font-size: 10px;
  touch-action: manipulation;
}
.rail-btn:hover {
  color: var(--text); border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.math-rail h3 { margin: 5px 0 2px; font-size: 13px; letter-spacing: 0.02em; }
.math-rail p {
  margin: 0 0 6px; font-size: 10.5px; line-height: 1.4; color: var(--muted);
}
.math-grid { display: grid; gap: 6px; grid-template-columns: 1fr; }
.step-math, .step-code {
  margin: 0; padding: 6px 8px; border-radius: 8px; overflow: hidden;
  font-family: var(--mono); font-size: 9.5px; line-height: 1.5;
  display: grid; gap: 1px; white-space: pre-wrap; word-break: break-word;
}
.step-math {
  color: #ffe89a; background: rgba(255, 214, 10, 0.07);
  border-left: 2px solid color-mix(in srgb, var(--accent) 65%, transparent);
}
.step-code {
  color: #86b4d6; background: rgba(90, 200, 250, 0.05);
  border-left: 2px solid rgba(90, 200, 250, 0.4);
  font-size: 9px; opacity: 0.85;
}
.math-line::before, .code-line::before { color: var(--dim); }
.step-progress {
  margin-top: 7px; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.step-progress i {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), #ffffff);
  box-shadow: 0 0 10px var(--accent);
}

.steps {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px;
  border-top: 1px solid var(--line); scrollbar-width: thin;
}
.step-chip {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding: 5px 9px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02);
  color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: 0.06em;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.step-chip:hover { color: var(--text); }
.step-chip.done { color: var(--dim); border-color: rgba(255, 255, 255, 0.08); }
.step-chip.active {
  color: #04121a; border-color: transparent;
  background: linear-gradient(135deg, var(--accent), rgba(255, 255, 255, 0.7));
}
.step-num { opacity: 0.7; }
.step-label { white-space: nowrap; }

/* Domain HUD + checks reuse the quantum strips but with the domain accent. */
body[data-domain="crypto"] .verdict.pass,
body[data-domain="biotech"] .verdict.pass,
body[data-domain="materials"] .verdict.pass { color: var(--green); }
body.domain-mode .stage-hint { display: none; }
body.domain-mode .popup { display: none; }
body.domain-mode .hud-right #btn-inspect { display: none; }
/* ---------------- visual algorithm builder ---------------- */
.builder {
  position: absolute; inset: 10px; z-index: 9;
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid rgba(120, 145, 180, 0.24); border-radius: 14px;
  background: linear-gradient(180deg, rgba(6, 10, 17, 0.97), rgba(8, 12, 20, 0.94));
  backdrop-filter: blur(12px);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.builder.busy { border-color: rgba(90, 200, 250, 0.5); }
.builder-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px;
  border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.025);
}
.builder-head h3 {
  margin: 0; font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em;
  color: var(--accent); font-weight: 600;
}
.builder-grip { color: var(--dim); font-size: 11px; }
.builder-hint {
  font-family: var(--mono); font-size: 9px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52%;
}
.builder-spacer { flex: 1; }
.builder-body {
  flex: 1; min-height: 0; display: grid; gap: 8px; padding: 8px;
  grid-template-columns: 146px minmax(220px, 1fr) 216px;
}
.builder-palette {
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
  padding-right: 5px; border-right: 1px solid var(--line);
}
.palette-head {
  font-family: var(--mono); font-size: 8px; letter-spacing: 0.14em; color: var(--dim);
  padding: 2px 2px 4px; position: sticky; top: 0; background: rgba(6, 10, 17, 0.96);
}
.builder-piece {
  display: flex; align-items: center; gap: 6px; cursor: grab; text-align: left;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.06em; color: var(--muted);
  border: 1px solid rgba(120, 145, 180, 0.22); border-radius: 7px;
  background: rgba(255, 255, 255, 0.03); padding: 5px 7px;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.builder-piece:hover {
  color: var(--text); border-color: rgba(90, 200, 250, 0.5);
  background: rgba(90, 200, 250, 0.08);
}
.builder-piece:active { cursor: grabbing; }
.builder-piece[data-kind="algorithm"] { border-left: 2px solid var(--violet); }
.builder-piece[data-kind="domain"] { border-left: 2px solid var(--amber); }
.piece-glyph { color: var(--accent); font-size: 10px; }
.piece-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.builder-board {
  position: relative; overflow: hidden; border-radius: 12px;
  border: 1px dashed rgba(120, 145, 180, 0.25);
  background:
    radial-gradient(600px 300px at 50% 0%, rgba(90, 200, 250, 0.07), transparent 70%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.014) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.014) 0 1px, transparent 1px 26px),
    rgba(3, 6, 11, 0.72);
}
.builder-wires { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.builder-wires .wire { fill: none; stroke: rgba(90, 200, 250, 0.55); stroke-width: 1.4; }
.builder-wires .wire.draft { stroke-dasharray: 4 4; stroke: var(--violet); }
.builder-wires .wire-dot { fill: var(--accent); }
.builder-nodes { position: absolute; inset: 0; }
.builder-empty {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; color: var(--dim);
  text-align: center; padding: 20px;
}

.builder-node {
  position: absolute; width: 132px; height: 58px; padding: 8px 14px;
  display: grid; align-content: center; gap: 2px;
  border-radius: 10px; cursor: grab; user-select: none; touch-action: none;
  border: 1px solid rgba(120, 145, 180, 0.3);
  border-left: 3px solid var(--accent);
  background: linear-gradient(180deg, rgba(17, 24, 36, 0.98), rgba(9, 14, 22, 0.96));
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.builder-node:hover { border-color: rgba(90, 200, 250, 0.55); }
.builder-node.selected {
  border-color: var(--accent); box-shadow: 0 0 0 1px rgba(90, 200, 250, 0.5),
    0 12px 24px rgba(0, 0, 0, 0.5);
}
.builder-node:active { cursor: grabbing; }
.builder-node.kind-algorithm { border-left-color: var(--violet); }
.builder-node.kind-domain { border-left-color: var(--amber); }
.builder-node .node-label {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.builder-node .node-meta {
  font-family: var(--mono); font-size: 8px; letter-spacing: 0.05em; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.builder-node .node-remove {
  position: absolute; top: 2px; right: 3px; width: 14px; height: 14px;
  border: none; background: transparent; color: var(--dim); cursor: pointer;
  font-size: 11px; line-height: 1; padding: 0; opacity: 0.5;
}
.builder-node .node-remove:hover { color: var(--red); opacity: 1; }
.builder-node .port {
  position: absolute; top: 50%; width: 10px; height: 10px; margin-top: -5px;
  border-radius: 50%; border: 1px solid rgba(90, 200, 250, 0.7);
  background: #081019; z-index: 2;
}
.builder-node .port.in { left: -6px; border-color: rgba(175, 82, 222, 0.8); }
.builder-node .port.out {
  right: -6px; cursor: crosshair; background: var(--accent);
  box-shadow: 0 0 8px rgba(90, 200, 250, 0.7);
}
.builder-node .port.in:hover { background: var(--violet); }

.builder-side { display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.builder-crew { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; max-height: 48%; }
.crew-idle {
  font-family: var(--mono); font-size: 8.5px; color: var(--dim); letter-spacing: 0.08em;
  border: 1px dashed var(--line); border-radius: 8px; padding: 8px; text-align: center;
}
.crew-card {
  --crew-accent: var(--accent);
  display: grid; grid-template-columns: 16px minmax(0, 1fr) auto auto; gap: 4px;
  align-items: center; padding: 5px 6px; border-radius: 8px;
  border: 1px solid var(--line); border-left: 2px solid var(--crew-accent);
  background: rgba(255, 255, 255, 0.02);
}
.crew-card.working { animation: crewPulse 1.1s infinite; }
@keyframes crewPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.crew-card.ok { border-left-color: var(--green); }
.crew-card.fail { border-left-color: var(--red); }
.crew-glyph { color: var(--crew-accent); font-size: 11px; text-align: center; }
.crew-meta { display: grid; gap: 1px; min-width: 0; }
.crew-meta b {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.09em; color: var(--text);
  font-weight: 600;
}
.crew-meta small {
  font-family: var(--mono); font-size: 7.5px; letter-spacing: 0.05em; color: var(--dim);
  text-transform: uppercase;
}
.crew-meta em {
  font-family: var(--mono); font-size: 7.5px; font-style: normal; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crew-ms { font-family: var(--mono); font-size: 7.5px; color: var(--dim); }
.crew-mark { font-size: 9px; color: var(--green); }
.crew-card.fail .crew-mark { color: var(--red); }
.crew-total {
  font-family: var(--mono); font-size: 8px; color: var(--dim); letter-spacing: 0.05em;
  padding: 2px 2px 0;
}
.builder-out {
  flex: 1; min-height: 48px; overflow-y: auto; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(3, 6, 11, 0.75); padding: 5px 6px;
  font-family: var(--mono); font-size: 8px; color: var(--muted);
}
.out-head {
  color: var(--accent); letter-spacing: 0.08em; font-size: 7.5px; margin-bottom: 3px;
}
.out-line { white-space: pre-wrap; word-break: break-word; color: var(--green); }
.builder-code {
  margin: 0; flex: 1.2; min-height: 58px; overflow: auto; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(2, 4, 8, 0.88); padding: 5px 6px;
  font-family: var(--mono); font-size: 7.5px; line-height: 1.35; color: #9fd4ff;
}
.code-line { display: block; white-space: pre; }
.code-line i { color: var(--dim); font-style: normal; display: inline-block; width: 18px; }
.builder-popup {
  position: absolute; z-index: 14; width: min(340px, 72%); max-height: 46%; overflow: auto;
  border: 1px solid rgba(90, 200, 250, 0.35); border-radius: 10px;
  background: rgba(6, 11, 18, 0.98); padding: 8px 10px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.6);
  font-family: var(--mono); font-size: 9px; color: var(--text);
}
.builder-popup header {
  display: flex; gap: 6px; align-items: center; color: var(--accent);
  font-size: 8.5px; letter-spacing: 0.08em;
}
.builder-popup header b {
  flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.builder-popup header span { color: var(--dim); font-size: 7.5px; }
.builder-popup p { margin: 5px 0; color: var(--muted); line-height: 1.45; }
.builder-popup pre {
  margin: 5px 0 0; padding: 5px 6px; border-radius: 6px; background: rgba(2, 4, 8, 0.9);
  color: #9fd4ff; font-size: 7.5px; overflow-x: auto; white-space: pre;
}
.popup-out { margin-top: 5px; display: grid; gap: 1px; color: var(--green); font-size: 7.5px; }
#btn-builder.active { color: var(--accent); border-color: rgba(90, 200, 250, 0.5); }

@media (max-width: 1240px) {
  .builder-body { grid-template-columns: 124px minmax(180px, 1fr) 190px; }
}

@media (max-width: 1100px) {
  .math-rail { width: min(380px, calc(100% - 24px)); }
  .step-code { display: none; }
}

