:root {
  --bg: #050914;
  --panel: #0b1222;
  --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: 8px;
  min-width: 0;
  flex-shrink: 0;
}

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

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

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

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

.tab {
  background: #0d1629;
  color: #b7c8e6;
  border: 1px solid #223456;
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 11px;
  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, #22d3ee, #a78bfa);
  color: #04101c;
  border-color: transparent;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.35);
}

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

.pill {
  text-decoration: none;
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 10.8px;
  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);
}

.comp-pill {
  background: rgba(167, 139, 250, 0.14);
  border-color: rgba(167, 139, 250, 0.55);
  color: var(--violet);
}

.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.2px;
  font-weight: 700;
  letter-spacing: 0.04em;
  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: 10.8px;
  color: #b7c8e6;
}

#caption-left {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

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

.side-header p {
  font-size: 10.5px;
  line-height: 1.32;
  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: 5px 7px;
  min-width: 0;
}

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

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

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

.preset-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.preset-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.preset-btn {
  background: #0b1323;
  color: #c5d4f0;
  border: 1px solid #263a60;
  border-radius: 6px;
  padding: 5px 4px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.preset-btn:hover {
  border-color: var(--cyan);
  color: #fff;
}
.preset-btn.active {
  background: rgba(34, 211, 238, 0.17);
  border-color: var(--cyan);
  color: #fff;
}

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

.action-btn {
  flex: 1;
  background: #0b1323;
  color: #c5d4f0;
  border: 1px solid #263a60;
  border-radius: 7px;
  padding: 5px 6px;
  font-size: 10.4px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}
.action-btn:hover {
  border-color: var(--cyan);
  color: #fff;
}
.action-btn.active {
  background: rgba(34, 211, 238, 0.18);
  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);
}
.action-btn.gold {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.55);
  color: var(--gold);
}

.ctrl-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ctrl-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.6px;
  color: #c9d8f4;
}

.ctrl-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: 12px;
}

.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: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theorem-head {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 9.2px;
  font-weight: 700;
  letter-spacing: 0.05em;
  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: 4px 6px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 10px;
  color: var(--gold);
  line-height: 1.32;
}

.theorem-note {
  font-size: 10.2px;
  line-height: 1.32;
  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;
  flex-shrink: 0;
}

.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: 10.2px;
  color: var(--cyan);
  word-break: break-all;
  user-select: text;
}

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

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

.suite-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
}

.suite-title {
  font-size: 11.8px;
  font-weight: 700;
  color: var(--cyan);
}

.suite-badge {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 9.5px;
  font-weight: 800;
  color: var(--emerald);
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.45);
  border-radius: 999px;
  padding: 2px 7px;
  white-space: nowrap;
}

.suite-checks {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.suite-checks li {
  font-size: 10.8px;
  line-height: 1.35;
  color: #c6d6f2;
  padding-left: 12px;
  position: relative;
}

.suite-checks li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: var(--emerald);
  font-weight: 800;
}

.geo-pill {
  color: #67e8f9;
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(34, 211, 238, 0.08);
}
.geo-pill:hover {
  border-color: rgba(103, 232, 249, 0.72);
  background: rgba(34, 211, 238, 0.16);
}

/* Compact 1024px single-row fit for Special Edition II (4 header pills) */
.topbar { padding: 6px 10px; gap: 8px; }
.brand { gap: 7px; }
.brand-badge { width: 28px; height: 28px; font-size: 16px; }
.brand-title { font-size: 12.5px; }
.brand-sub { font-size: 9.5px; }
.tabs { gap: 4px; }
.tab { padding: 5px 8px; font-size: 11px; }
.header-links { gap: 5px; }
.pill { padding: 5px 8px; font-size: 10.5px; white-space: nowrap; }
.ctrl-group { display: flex; flex-direction: column; gap: 5px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 5px; }
.preset-btn, .action-btn { flex: 1 1 auto; text-align: center; padding: 5px 7px; font-size: 10.5px; }
