:root {
  --bg: #0d1626; --panel: rgba(12, 20, 36, .88); --line: rgba(148, 197, 255, .18);
  --text: #e6edf7; --muted: #94a3b8; --accent: #7dd3fc; --good: #3ddc84; --bad: #ff5d5d;
  --hack: #b67cf0; --warn: #f5b942; --sel: #fbbf24;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; }
[hidden] { display: none !important; }

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; }
.label-layer { position: absolute; inset: 0; }
#loading { position: fixed; inset: 0; display: grid; place-items: center; color: var(--muted); font-family: var(--mono); }

/* the "i" badge used in tags and the header */
.i { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); color: #0d1626; font: 700 10px/1 Georgia, serif; font-style: italic; vertical-align: 1px; }

/* --------- labels in the world --------- */
.label { font-size: 12px; line-height: 1.3; text-align: center; padding: 4px 9px; border-radius: 7px;
  background: rgba(10, 16, 30, .85); border: 1px solid var(--line); color: var(--text);
  pointer-events: none; white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,.35); user-select: none; }
.label.station { font-weight: 600; }
.label.big { font-size: 13.5px; font-weight: 700; border-color: var(--accent); }
.label.danger { border-color: var(--bad); }
.label.ok { border-color: var(--good); }
.label.follow { padding: 2px 7px; font-size: 11px; }
.label.clickable { pointer-events: auto; cursor: pointer; transition: transform .12s, border-color .12s, background .12s; }
.label.clickable:hover { transform: scale(1.08); border-color: var(--sel); background: rgba(30, 26, 10, .92); }
.label.selected { border-color: var(--sel); background: rgba(40, 32, 6, .95); box-shadow: 0 0 18px rgba(251,191,36,.45); }
.label.selected .i { background: var(--sel); }
/* compact tags: icon only, the name slides out on hover / selection */
.label .name { display: inline-block; max-width: 0; overflow: hidden; vertical-align: bottom; opacity: 0;
  transition: max-width .2s, opacity .2s, margin .2s; }
.label:hover .name, .label.selected .name { max-width: 260px; opacity: 1; margin-left: 6px; }
.label.station, .label.big { font-size: 14px; padding: 3px 7px; border-radius: 999px; }
.label.follow { background: rgba(217, 119, 87, .9); border-color: transparent; color: #fff; font-weight: 600; }
.label.sandbox-banner { pointer-events: auto; font: 800 18px/1.2 system-ui, sans-serif; letter-spacing: .12em; padding: 8px 18px;
  border: 2px solid var(--accent); border-radius: 12px; background: rgba(8, 30, 48, .92); color: #e0f2fe;
  box-shadow: 0 0 24px rgba(125, 211, 252, .55), inset 0 0 12px rgba(125, 211, 252, .25); animation: field 2.4s ease-in-out infinite; }
.label.sandbox-banner small { display: block; font: 500 11.5px/1.4 system-ui, sans-serif; letter-spacing: .02em; color: var(--accent); margin-top: 2px; }
.label.sandbox-banner .i { position: absolute; top: -7px; right: -7px; }
@keyframes field { 50% { box-shadow: 0 0 40px rgba(125, 211, 252, .85), inset 0 0 18px rgba(125, 211, 252, .35); } }
.label.follow.human { background: rgba(17, 24, 39, .92); border-color: var(--sel); }

/* --------- header --------- */
#brand { position: fixed; top: 16px; left: 16px; max-width: min(520px, calc(100vw - 32px));
  background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
#brand > b { display: block; font-size: 16px; }
#brand > span { color: var(--muted); font-size: 13px; }

/* --------- info card --------- */
#info { position: fixed; top: 16px; right: 16px; width: min(380px, calc(100vw - 32px));
  background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--sel); border-radius: 12px;
  padding: 14px 16px 6px; box-shadow: 0 8px 30px rgba(0,0,0,.4); animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }
#info .kicker { font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--sel); }
#info h2 { margin: 6px 0 6px; font-size: 19px; }
#info p { margin: 0 0 10px; font-size: 14px; }
#info .tip { color: var(--accent); font-size: 13px; }
#info .close { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; padding: 0; font-size: 18px; line-height: 1; }

/* --------- buttons --------- */
button { font: inherit; font-size: 13px; color: var(--text); background: rgba(125, 211, 252, .1);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; cursor: pointer; transition: background .15s; }
button:hover:not(:disabled) { background: rgba(125, 211, 252, .2); }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, #timeline li:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.ghost { background: transparent; }
button.primary { background: rgba(61, 220, 132, .18); border-color: rgba(61, 220, 132, .55); font-weight: 600; }
button.primary:hover:not(:disabled) { background: rgba(61, 220, 132, .3); }
.toggle { display: inline-flex; align-items: center; gap: 7px; }
.toggle .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.toggle.on .dot { background: var(--good); box-shadow: 0 0 8px var(--good); }
#t-gate:not(.on) .dot { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

/* --------- bottom dock --------- */
#dock { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(880px, calc(100vw - 32px));
  max-height: calc(100vh - 120px); overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
  background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.run-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.run-row #b-start { margin-left: auto; padding: 8px 18px; font-size: 14px; }

#timeline { list-style: none; margin: 0; padding: 0; display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; counter-reset: st; }
#timeline li { counter-increment: st; font: 12px var(--mono); padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); cursor: pointer; transition: border-color .12s, color .12s; }
#timeline li::before { content: counter(st) " "; opacity: .6; }
#timeline li:hover { border-color: var(--sel); color: var(--text); }
#timeline li.done { color: var(--good); border-color: rgba(61,220,132,.5); }
#timeline li.active { color: #0d1626; background: var(--accent); border-color: var(--accent); }
#timeline li.selected { box-shadow: 0 0 0 2px var(--sel); }

#gate { background: #1b1a10; border: 2px solid var(--warn); border-radius: 12px; padding: 12px 14px; box-shadow: 0 0 30px rgba(245,185,66,.25); }
#gate h3 { margin: 0 0 6px; font-size: 15px; }
#gate p { margin: 0 0 10px; font-size: 13.5px; }
.gate-actions { display: flex; gap: 8px; flex-wrap: wrap; }

#deliverables { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#deliverables .card { background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 10px; padding: 10px; font-size: 12.5px; min-width: 0; }
#deliverables .card h4 { margin: 0 0 6px; font-size: 13px; }
#deliverables .card p { margin: 0 0 6px; }
#deliverables .e2e { border-top: 3px solid var(--good); }
#deliverables .code { border-top: 3px solid #e08a2e; }
#deliverables .logs { border-top: 3px solid #38bdf8; }
#deliverables details summary { cursor: pointer; color: var(--accent); font-size: 12px; }
#deliverables .logs:has(details[open]) { grid-column: 1 / -1; }
#deliverables pre { font: 11px/1.5 var(--mono); background: rgba(0,0,0,.3); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; overflow-x: auto; white-space: pre; margin: 6px 0 0; }
.ok { color: var(--good); } .bad { color: var(--bad); } .muted { color: var(--muted); }

#console { background: rgba(5, 10, 20, .92); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  height: 140px; overflow-y: auto; font: 11.5px/1.55 var(--mono); flex-shrink: 0; }
#console .line { padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
#console .agent { color: #cbd5e1; }
#console .red { color: #f87171; } #console .green { color: #4ade80; } #console .refactor { color: #60a5fa; }
#console .human { color: #fbbf24; font-weight: 600; }
#console .gate { color: #fbbf24; }
#console .hook { color: #c084fc; }
#console .log { color: #fef3c7; opacity: .85; }
#console .log.deny { color: #fca5a5; }
#console .incident { color: #ff4d4d; font-weight: 700; }
#console .warn { color: var(--warn); }
#console .sonar-fail { color: #f87171; } #console .sonar-pass { color: #4ade80; }
#console .e2e { color: #86efac; }
#console .muted { color: var(--muted); }

@media (max-width: 760px) {
  #brand > span { display: none; }
  #deliverables { grid-template-columns: 1fr; }
  #console { height: 110px; }
  .run-row #b-start { margin-left: 0; }
}
