:root {
  --bg: #050814;
  --bg-panel: #0b1124;
  --bg-card: #101935;
  --border: rgba(94, 234, 212, 0.22);
  --text: #e6f1ff;
  --muted: #8ea4c8;
  --cyan: #22d3ee;
  --magenta: #f472b6;
  --gold: #fbbf24;
  --emerald: #34d399;
  --violet: #a78bfa;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 22% 18%, #0d1633 0%, var(--bg) 68%);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 13px;
}

.topbar {
  height: 48px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(7, 11, 26, 0.94);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.brand-star {
  color: var(--gold);
  font-size: 16px;
  text-shadow: 0 0 10px rgba(251, 191, 36, 0.75);
}

.brand-title {
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #67e8f9, #f9a8d4, #fde68a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tab {
  background: rgba(16, 25, 53, 0.8);
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: var(--muted);
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.tab:hover {
  color: var(--text);
  border-color: rgba(34, 211, 238, 0.55);
}

.tab.active {
  color: #04101f;
  background: linear-gradient(135deg, #22d3ee, #67e8f9);
  border-color: #67e8f9;
  box-shadow: 0 0 14px rgba(34, 211, 238, 0.45);
}

.header-links {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.pill {
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.pill:hover { transform: translateY(-1px); }

.atlas-pill {
  color: #fde68a;
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.52);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.22);
}

.sibling-pill {
  color: #67e8f9;
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.42);
}

.proofs-pill {
  color: #6ee7b7;
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.48);
}

.workspace {
  height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: 1fr 296px;
  gap: 10px;
  padding: 10px;
}

.stage-wrap {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #040712;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(14, 165, 233, 0.08);
}

#stageCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.caption-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 11px;
  border-radius: 8px;
  background: rgba(6, 10, 24, 0.84);
  border: 1px solid rgba(103, 232, 249, 0.22);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.caption-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #04101f;
  background: var(--gold);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.caption-text {
  font-size: 11.5px;
  color: #cbdcf5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(11, 17, 36, 0.92);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 9px;
  overflow-y: auto;
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 700;
  color: #f0f9ff;
  margin-bottom: 2px;
}

.panel-header p {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ctrl-group {
  background: rgba(16, 25, 53, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  padding: 5px 7px;
}

.ctrl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
  font-size: 11px;
}

.ctrl-label {
  color: #cbd5e1;
  font-weight: 600;
}

.ctrl-val {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  color: var(--cyan);
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
  cursor: pointer;
  height: 14px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.mini-btn {
  flex: 1 1 auto;
  background: rgba(15, 23, 48, 0.9);
  border: 1px solid rgba(103, 232, 249, 0.25);
  color: #cbdcf5;
  font-size: 10.2px;
  font-weight: 600;
  padding: 4px 5px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.14s ease;
  text-align: center;
}

.mini-btn:hover {
  border-color: var(--cyan);
  color: #fff;
}

.mini-btn.active {
  background: rgba(34, 211, 238, 0.22);
  border-color: var(--cyan);
  color: #67e8f9;
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.25);
}

.mini-btn.gold-active {
  background: rgba(251, 191, 36, 0.2);
  border-color: var(--gold);
  color: #fde68a;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.stat-card {
  background: rgba(16, 25, 53, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 8px;
  padding: 5px 7px;
}

.stat-label {
  font-size: 9.2px;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 1px;
  font-weight: 600;
}

.stat-val {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11px;
  font-weight: 700;
  color: #f8fafc;
}

.stat-val.cyan { color: var(--cyan); }
.stat-val.gold { color: var(--gold); }
.stat-val.magenta { color: var(--magenta); }
.stat-val.emerald { color: var(--emerald); }

.theorem-box {
  background: linear-gradient(135deg, rgba(16, 25, 53, 0.85), rgba(20, 18, 52, 0.85));
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 10.2px;
  line-height: 1.32;
  color: #cbdcf5;
}

.theorem-box strong {
  color: var(--gold);
}

.theorem-box code {
  font-family: 'JetBrains Mono', monospace;
  color: #67e8f9;
  font-size: 10.3px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 18, 0.8);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 18px;
}

.modal-backdrop.hidden { display: none; }

.modal-card {
  width: min(860px, 95vw);
  max-height: 88vh;
  overflow-y: auto;
  background: #090f24;
  border: 1px solid rgba(52, 211, 153, 0.45);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.modal-head h2 {
  font-size: 16px;
  color: #6ee7b7;
}

.modal-sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 2px;
}

.modal-close {
  background: rgba(148, 163, 184, 0.14);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: #e2e8f0;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
}

.cli-box {
  background: #040814;
  border: 1px solid rgba(34, 211, 238, 0.38);
  border-radius: 8px;
  padding: 9px 11px;
  margin-bottom: 12px;
}

.cli-label {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--gold);
  font-weight: 700;
  margin-bottom: 4px;
}

.cli-box code {
  display: block;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 11.5px;
  color: #67e8f9;
  word-break: break-all;
}

.proof-suites {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.suite-card {
  background: rgba(16, 25, 53, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 9px;
  padding: 9px 11px;
}

.suite-card.wide { grid-column: 1 / -1; }

.suite-card h3 {
  font-size: 12px;
  color: #fde68a;
  margin-bottom: 5px;
}

.suite-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #cbdcf5;
  line-height: 1.35;
}

.suite-card code {
  color: #6ee7b7;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
}
