:root {
  --bg-0: #0b0f17;
  --bg-1: #111827;
  --bg-2: #1a2333;
  --border: #283548;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --cyan: #22d3ee;
  --emerald: #34d399;
  --purple: #c084fc;
  --amber: #fbbf24;
  --blue: #60a5fa;
  --red: #f87171;
  --font-mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans: Inter, system-ui, -apple-system, sans-serif;
}

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

body {
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--font-sans);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo-chip {
  background: linear-gradient(135deg, #0ea5e9, #10b981);
  color: #041019;
  font-weight: 800;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}
.brand h1 { font-size: 15px; font-weight: 700; }
.brand .sub { font-family: var(--font-mono); font-size: 12px; color: var(--cyan); font-weight: 500; margin-left: 4px; }

.controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lab-picker { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.lab-picker select {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12px;
  max-width: 340px;
}

.btn {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.12s, border-color 0.12s;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); border-color: #475569; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 3px 9px; font-size: 11px; }
.btn-primary { background: #059669; border-color: #10b981; color: #fff; }
.btn-accent { background: #7c3aed; border-color: #a78bfa; color: #fff; }
.btn-danger { background: #7f1d1d; border-color: #b91c1c; color: #fecaca; }

.step-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.toggle-pill { display: flex; align-items: center; gap: 5px; font-size: 12px; cursor: pointer; user-select: none; }
.gate-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-2);
  color: var(--muted);
}
.gate-badge.paused { background: #78350f; color: #fde68a; animation: pulse 1.1s infinite; }

@keyframes pulse { 50% { opacity: 0.65; } }

.lab-banner {
  padding: 6px 14px;
  background: #0f172a;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: #cbd5e1;
  flex-shrink: 0;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  min-height: 0;
}

.node-pane, .inspector-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
}
.node-pane:last-child { border-right: none; }

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.node-title { display: flex; align-items: center; gap: 7px; }
.node-title code { font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-n0 { background: var(--cyan); box-shadow: 0 0 6px var(--cyan); }
.dot-n1 { background: var(--emerald); box-shadow: 0 0 6px var(--emerald); }

.node-state {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--bg-2);
  color: var(--muted);
}
.node-state.running { background: #064e3b; color: #6ee7b7; }
.node-state.compiling { background: #1e3a8a; color: #93c5fd; }
.node-state.error { background: #7f1d1d; color: #fca5a5; }

.env-bar {
  display: flex;
  align-items: center;
  background: #0d1320;
  border-bottom: 1px solid var(--border);
  padding: 4px 8px;
  gap: 6px;
}
.env-bar span {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--amber);
}
.env-bar input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fde68a;
  font-family: var(--font-mono);
  font-size: 11.5px;
  outline: none;
}

.code-editor {
  flex: 1.35;
  min-height: 0;
  background: #090d16;
  color: #e2e8f0;
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.48;
  resize: none;
  outline: none;
  tab-size: 4;
}

.term-header {
  display: flex;
  justify-content: space-between;
  padding: 4px 10px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.compile-meta { font-family: var(--font-mono); color: var(--emerald); }

.terminal {
  flex: 0.85;
  min-height: 120px;
  background: #05080f;
  color: #d1d5db;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.42;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Inspector styles */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border-bottom: 1px solid var(--border);
  background: #0d1422;
}
.stat-box {
  padding: 6px 8px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.stat-box:last-child { border-right: none; }
.stat-box .lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.stat-box strong { font-family: var(--font-mono); font-size: 13px; margin-top: 2px; color: var(--cyan); }
.stat-box.fault strong { color: var(--red); }

.subpanel { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--border); }
.timeline-panel { flex: 1.35; }
.detail-panel { flex: 0.95; }
.mpt-panel { flex: 0.75; border-bottom: none; }

.subpanel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 10px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.subpanel-title code { font-family: var(--font-mono); color: var(--cyan); }

.event-list {
  flex: 1;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11px;
}

.ev-row {
  display: grid;
  grid-template-columns: 36px 54px 86px 1fr 56px;
  gap: 6px;
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
}
.ev-row:hover { background: rgba(56, 189, 248, 0.08); }
.ev-row.selected { background: rgba(56, 189, 248, 0.18); }

.ev-seq { color: var(--muted); }
.ev-dir { color: #cbd5e1; font-weight: 600; }
.ev-op { color: #94a3b8; }
.ev-len { text-align: right; color: var(--muted); }

.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 700;
  font-size: 10.5px;
}
.cat-eager { background: rgba(34, 211, 238, 0.16); color: var(--cyan); }
.cat-rndv  { background: rgba(192, 132, 252, 0.18); color: var(--purple); }
.cat-wireup{ background: rgba(251, 191, 36, 0.16); color: var(--amber); }
.cat-rma   { background: rgba(52, 211, 153, 0.18); color: var(--emerald); }
.cat-amo   { background: rgba(96, 165, 250, 0.18); color: var(--blue); }
.cat-am, .cat-stream, .cat-uct { background: rgba(244, 114, 182, 0.16); color: #f472b6; }
.cat-meta  { background: rgba(148, 163, 184, 0.12); color: var(--muted); }
.cat-fault { background: rgba(248, 113, 113, 0.25); color: var(--red); }

.detail-meta {
  padding: 5px 10px;
  font-size: 11.5px;
  background: #0d1422;
  color: #cbd5e1;
  border-bottom: 1px solid var(--border);
}

.hex-dump {
  flex: 1;
  overflow: auto;
  padding: 6px 10px;
  background: #060a12;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  color: #a5f3fc;
}

.mpt-list {
  flex: 1;
  overflow: auto;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.mpt-card {
  background: #0e1625;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 5px 8px;
}
.mpt-top { display: flex; justify-content: space-between; color: var(--emerald); margin-bottom: 3px; }
.mpt-ascii { color: #fde68a; word-break: break-all; }
.empty-hint { color: var(--muted); font-family: var(--font-sans); font-size: 11.5px; padding: 6px; }
