:root {
  --bg: #070b14;
  --panel: #0d1424;
  --panel-2: #121c33;
  --border: rgba(120, 180, 255, 0.16);
  --text: #e6eefc;
  --muted: #8ea2c8;
  --cyan: #38e8ff;
  --amber: #ffb84d;
  --rose: #ff5d8f;
  --emerald: #34f5a8;
  --violet: #b388ff;
  --gold: #ffd166;
}

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

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

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Single-row compact top bar safe at 1024px */
.topbar {
  height: 50px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: rgba(10, 16, 30, 0.94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

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

.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #07101f;
  background: linear-gradient(135deg, var(--cyan), var(--violet));
  box-shadow: 0 0 12px rgba(56, 232, 255, 0.45);
}

.brand-title {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  white-space: nowrap;
}

.brand-sub {
  font-size: 10.5px;
  color: var(--cyan);
  opacity: 0.85;
  white-space: nowrap;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 auto;
  justify-content: center;
  min-width: 0;
}

.tab-btn {
  appearance: none;
  border: 1px solid rgba(120, 180, 255, 0.16);
  background: rgba(18, 28, 51, 0.65);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text);
  border-color: rgba(56, 232, 255, 0.45);
  background: rgba(24, 38, 68, 0.85);
}

.tab-btn.active {
  color: #06101f;
  background: linear-gradient(135deg, var(--cyan), #7cf7ff);
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(56, 232, 255, 0.4);
}

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

.nav-pill {
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 7px;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s ease;
}

.atlas-pill {
  color: var(--gold);
  border: 1px solid rgba(255, 209, 102, 0.42);
  background: rgba(255, 209, 102, 0.1);
}
.atlas-pill:hover {
  background: rgba(255, 209, 102, 0.22);
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.35);
}

.sibling-pill {
  color: var(--cyan);
  border: 1px solid rgba(56, 232, 255, 0.35);
  background: rgba(56, 232, 255, 0.09);
}
.sibling-pill:hover {
  background: rgba(56, 232, 255, 0.2);
}

.proofs-pill {
  color: var(--emerald);
  border: 1px solid rgba(52, 245, 168, 0.38);
  background: rgba(52, 245, 168, 0.1);
  font-family: inherit;
}
.proofs-pill:hover {
  background: rgba(52, 245, 168, 0.22);
}

/* Main workspace */
.workspace {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  background: radial-gradient(circle at 50% 45%, #0c162b 0%, #060a13 85%);
  overflow: hidden;
}

#stage {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.stage-caption {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  padding: 6px 11px;
  border-radius: 8px;
  background: rgba(8, 13, 24, 0.84);
  border: 1px solid rgba(120, 180, 255, 0.18);
  font-size: 11.5px;
  color: #cddaf2;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  backdrop-filter: blur(4px);
}

.stage-caption .cap-hint {
  color: var(--amber);
  font-size: 11px;
  white-space: nowrap;
}

/* Right sidebar: compact so everything fits comfortably in 718px height */
.sidebar {
  width: 304px;
  flex-shrink: 0;
  background: rgba(11, 18, 34, 0.96);
  border-left: 1px solid var(--border);
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow-y: auto;
}

.chamber-head h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 0.01em;
}

.chamber-head p {
  margin-top: 3px;
  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-2);
  border: 1px solid rgba(120, 180, 255, 0.14);
  border-radius: 8px;
  padding: 6px 8px;
}

.stat-label {
  font-size: 9.8px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-val {
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, monospace;
  font-size: 11.4px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-val.cyan { color: var(--cyan); }
.stat-val.amber { color: var(--amber); }
.stat-val.emerald { color: var(--emerald); }
.stat-val.rose { color: var(--rose); }
.stat-val.violet { color: var(--violet); }

.controls-box {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(120, 180, 255, 0.14);
  border-radius: 9px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

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

.ctrl-label span.val {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--cyan);
}

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

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

.ctrl-btn {
  flex: 1 1 auto;
  border: 1px solid rgba(120, 180, 255, 0.22);
  background: rgba(24, 38, 68, 0.75);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.ctrl-btn:hover {
  border-color: var(--cyan);
  background: rgba(56, 232, 255, 0.16);
}

.ctrl-btn.active {
  background: rgba(56, 232, 255, 0.24);
  border-color: var(--cyan);
  color: var(--cyan);
}

.ctrl-btn.primary {
  border-color: rgba(52, 245, 168, 0.42);
  background: rgba(52, 245, 168, 0.14);
  color: var(--emerald);
}

.theorem-box {
  background: linear-gradient(180deg, rgba(22, 34, 62, 0.82), rgba(12, 20, 38, 0.9));
  border: 1px solid rgba(179, 136, 255, 0.28);
  border-radius: 9px;
  padding: 7px 8px;
  font-size: 10.6px;
  line-height: 1.38;
  color: #d6e2f8;
}

.theorem-box .th-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--violet);
  margin-bottom: 3px;
}

.theorem-box .th-eq {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10.7px;
  color: var(--amber);
  margin: 4px 0;
  padding: 4px 6px;
  border-radius: 5px;
  background: rgba(7, 11, 20, 0.65);
  border: 1px solid rgba(255, 184, 77, 0.18);
  overflow-x: auto;
}

/* Proofs Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.78);
  backdrop-filter: blur(6px);
  display: none;
  place-items: center;
  z-index: 50;
  padding: 18px;
}

.modal-backdrop.open {
  display: grid;
}

.modal-card {
  width: min(760px, 95vw);
  max-height: 88vh;
  background: #0c1426;
  border: 1px solid rgba(52, 245, 168, 0.38);
  border-radius: 13px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-head h3 {
  font-size: 14.5px;
  color: var(--emerald);
}

.modal-close {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 11px;
  font-size: 12px;
  line-height: 1.48;
  color: #d6e3fa;
}

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

.cli-box {
  flex-shrink: 0;
  background: #060a14;
  border: 1px solid rgba(56, 232, 255, 0.3);
  border-radius: 8px;
  padding: 9px 11px;
  overflow-x: auto;
}

.cli-box code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11.4px;
  color: var(--cyan);
  white-space: nowrap;
}

.suite-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.suite-item {
  background: rgba(16, 26, 48, 0.72);
  border: 1px solid rgba(120, 180, 255, 0.16);
  border-radius: 8px;
  padding: 8px 10px;
}

.suite-item strong {
  color: var(--amber);
}

.suite-item .badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  color: #061318;
  background: var(--emerald);
  padding: 1px 6px;
  border-radius: 99px;
}
