:root {
  --bg: #070b14;
  --panel: #0d1424;
  --panel-alt: #10192d;
  --border: #1e2d4d;
  --text: #e6eefc;
  --muted: #8ea2c8;
  --cyan: #22d3ee;
  --emerald: #34d399;
  --magenta: #f472b6;
  --gold: #fbbf24;
  --violet: #a78bfa;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 54px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: linear-gradient(180deg, #0d1526 0%, #09101e 100%);
  border-bottom: 1px solid var(--border);
}

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

.brand-badge {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #22d3ee, #34d399);
  color: #05111a;
  font-weight: 900;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.35);
}

.brand-title {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #f3f7ff;
  line-height: 1.15;
}

.brand-sub {
  font-size: 10px;
  color: var(--gold);
  line-height: 1.15;
}

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

.tab {
  background: #0d1629;
  color: #b7c8e6;
  border: 1px solid #223456;
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

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

.tab.active {
  background: linear-gradient(135deg, #10b981, #22d3ee);
  color: #04131c;
  border-color: transparent;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.35);
}

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

.pill {
  text-decoration: none;
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: filter 0.15s ease;
}
.pill:hover { filter: brightness(1.15); }

.atlas-pill {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.55);
  color: var(--gold);
}

.sibling-pill {
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.45);
  color: var(--cyan);
}

.proofs-pill {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.5);
  color: var(--emerald);
}

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 298px;
  gap: 10px;
  padding: 10px 12px;
}

.stage-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  min-height: 0;
}

.stage-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.38fr) minmax(0, 1fr);
  gap: 10px;
}

.side-stack {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.panel-head {
  padding: 7px 10px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--gold);
  background: rgba(16, 25, 45, 0.9);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-head.cyan { color: var(--cyan); }
.panel-head.magenta { color: var(--magenta); }

.canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #050911;
}

.canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.caption-bar {
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11px;
  color: #b7c8e6;
}

.caption-right {
  color: var(--gold);
  font-weight: 700;
  white-space: nowrap;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
}

.side-header h2 {
  font-size: 15px;
  font-weight: 800;
  color: var(--cyan);
  margin-bottom: 3px;
}

.side-header p {
  font-size: 11.2px;
  line-height: 1.38;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  min-width: 0;
}

.stat-label {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 9px;
  color: #8297be;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-value.magenta { color: var(--magenta); }
.stat-value.gold { color: var(--gold); }
.stat-value.emerald { color: var(--emerald); }

.controls-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.mode-btn, .action-btn {
  flex: 1;
  background: #0b1323;
  color: #c5d4f0;
  border: 1px solid #263a60;
  border-radius: 7px;
  padding: 6px 6px;
  font-size: 10.8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.mode-btn:hover, .action-btn:hover {
  border-color: var(--cyan);
  color: #fff;
}
.mode-btn.active {
  background: rgba(34, 211, 238, 0.16);
  border-color: var(--cyan);
  color: #fff;
}
.action-btn.emerald {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.55);
  color: var(--emerald);
}
.action-btn.magenta {
  background: rgba(244, 114, 182, 0.14);
  border-color: rgba(244, 114, 182, 0.55);
  color: var(--magenta);
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #c9d8f4;
}

.slider-val {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-weight: 700;
  color: var(--cyan);
}

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

.theorem-card {
  background: linear-gradient(180deg, rgba(167, 139, 250, 0.08) 0%, rgba(13, 20, 36, 0.95) 100%);
  border: 1px solid rgba(167, 139, 250, 0.38);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.theorem-head {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--violet);
}

.theorem-eq {
  background: rgba(7, 11, 20, 0.78);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 6px;
  padding: 5px 7px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 10.5px;
  color: var(--gold);
  line-height: 1.35;
}

.theorem-note {
  font-size: 10.8px;
  line-height: 1.38;
  color: #b7c8e6;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-backdrop.hidden { display: none; }

.modal-card {
  width: min(760px, 95vw);
  max-height: 86vh;
  background: #0c1324;
  border: 1px solid #2b416e;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
}

.modal-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--emerald);
}

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

.modal-close {
  background: #142038;
  color: #dbe8ff;
  border: 1px solid #2c436f;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 12px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-body > * {
  flex-shrink: 0;
}

.cli-box {
  background: #060a13;
  border: 1px solid rgba(34, 211, 238, 0.45);
  border-radius: 8px;
  padding: 9px 11px;
}

.cli-label {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 9.5px;
  color: var(--gold);
  margin-bottom: 4px;
}

.cli-box code {
  display: block;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 11px;
  color: var(--cyan);
  word-break: break-all;
  user-select: text;
}

.suite-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suite-item {
  background: #0f182c;
  border: 1px solid #22355a;
  border-radius: 8px;
  padding: 9px 11px;
}

.suite-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.suite-item-title {
  font-size: 12px;
  font-weight: 800;
  color: #f0f6ff;
}

.suite-badge {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--emerald);
  background: rgba(52, 211, 153, 0.14);
  border: 1px solid rgba(52, 211, 153, 0.45);
  border-radius: 5px;
  padding: 2px 6px;
}

.suite-checks {
  font-size: 11px;
  line-height: 1.45;
  color: #b5c7e6;
}
