:root {
  --bg: #070b14;
  --panel: #0c1322;
  --panel-alt: #10192b;
  --border: #1d2c48;
  --border-hi: #2b426b;
  --text: #e4eefc;
  --muted: #8ea6c8;
  --cyan: #2ce6ff;
  --emerald: #2ee6a6;
  --amber: #ffbe46;
  --magenta: #ff4fa3;
  --violet: #a87aff;
  --mono: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
}

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

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

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

.brand-badge {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  color: #061019;
  background: linear-gradient(135deg, var(--amber), var(--magenta));
  box-shadow: 0 0 12px rgba(255, 190, 70, 0.35);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-title {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #f3f7ff;
  white-space: nowrap;
}

.brand-sub {
  font-size: 10px;
  color: var(--amber);
  white-space: nowrap;
}

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

.tab-btn {
  background: #0e1729;
  color: #b7cae6;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

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

.tab-btn.active {
  background: linear-gradient(135deg, rgba(44, 230, 255, 0.92), rgba(46, 230, 166, 0.92));
  color: #05111c;
  border-color: transparent;
  box-shadow: 0 0 12px rgba(44, 230, 255, 0.3);
}

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

.atlas-home-pill, .sibling-pill, .proofs-pill {
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.atlas-home-pill {
  background: rgba(255, 190, 70, 0.14);
  color: var(--amber);
  border: 1px solid rgba(255, 190, 70, 0.45);
}

.atlas-home-pill:hover {
  background: rgba(255, 190, 70, 0.24);
}

.sibling-pill {
  background: rgba(44, 230, 255, 0.12);
  color: var(--cyan);
  border: 1px solid rgba(44, 230, 255, 0.4);
}

.sibling-pill:hover {
  background: rgba(44, 230, 255, 0.22);
}

.proofs-pill {
  background: rgba(46, 230, 166, 0.14);
  color: var(--emerald);
  border: 1px solid rgba(46, 230, 166, 0.45);
}

.proofs-pill:hover {
  background: rgba(46, 230, 166, 0.25);
}

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

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

.canvas-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 0.92fr);
  gap: 8px;
}

.panel-col {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

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

.panel-header {
  height: 28px;
  flex-shrink: 0;
  padding: 0 11px;
  display: flex;
  align-items: center;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.45px;
  color: var(--amber);
  background: rgba(16, 26, 46, 0.85);
  border-bottom: 1px solid rgba(29, 44, 72, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-col .panel:first-child .panel-header { color: var(--magenta); }
.panel-col .panel:last-child .panel-header { color: var(--cyan); }

.panel canvas {
  flex: 1;
  width: 100%;
  height: 100%;
  display: block;
  min-height: 0;
}

.caption-bar {
  height: 34px;
  flex-shrink: 0;
  padding: 0 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 11.5px;
  color: #c7d8f0;
  overflow: hidden;
}

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

.caption-hint {
  color: var(--amber);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

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

.chamber-head h1 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--cyan);
  line-height: 1.22;
  margin-bottom: 3px;
}

.chamber-head p {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.36;
}

.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: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.35px;
  color: #829bc0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value.amber { color: var(--amber); }
.stat-value.emerald { color: var(--emerald); }
.stat-value.magenta { color: var(--magenta); }

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

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

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

.ctrl-val {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--cyan);
  font-size: 11px;
}

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

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

.ctrl-btn {
  flex: 1;
  background: #101b30;
  color: #cfe0f8;
  border: 1px solid var(--border-hi);
  border-radius: 7px;
  padding: 5px 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

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

.ctrl-btn.active {
  background: rgba(44, 230, 255, 0.18);
  border-color: var(--cyan);
  color: #fff;
}

.ctrl-btn.emerald {
  background: rgba(46, 230, 166, 0.14);
  border-color: rgba(46, 230, 166, 0.55);
  color: var(--emerald);
}

.ctrl-btn.emerald:hover {
  background: rgba(46, 230, 166, 0.24);
}

.ctrl-btn.magenta {
  background: rgba(255, 79, 163, 0.15);
  border-color: rgba(255, 79, 163, 0.55);
  color: var(--magenta);
}

.theorem-card {
  background: linear-gradient(160deg, rgba(24, 20, 48, 0.92), rgba(11, 18, 34, 0.95));
  border: 1px solid rgba(168, 122, 255, 0.42);
  border-radius: 9px;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.theorem-title {
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.45px;
  color: var(--violet);
}

.theorem-eq {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--amber);
  background: rgba(7, 11, 20, 0.65);
  border: 1px solid rgba(255, 190, 70, 0.25);
  border-radius: 6px;
  padding: 5px 7px;
  line-height: 1.35;
}

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

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

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

.modal-card {
  width: min(740px, 95vw);
  max-height: 88vh;
  background: #0c1425;
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

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

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

.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: #fff; }

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

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

.modal-intro {
  font-size: 12.5px;
  color: #c8dbf4;
  line-height: 1.45;
}

.cli-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #060b14;
  border: 1px solid rgba(46, 230, 166, 0.45);
  border-radius: 8px;
  padding: 9px 11px;
  flex-shrink: 0;
}

.cli-box code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--emerald);
  word-break: break-all;
}

.copy-btn {
  background: rgba(46, 230, 166, 0.16);
  color: var(--emerald);
  border: 1px solid rgba(46, 230, 166, 0.5);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.copy-btn:hover { background: rgba(46, 230, 166, 0.28); }

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

.suite-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: rgba(16, 25, 43, 0.85);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.8px;
  color: #cfe0f6;
  line-height: 1.4;
}

.suite-badge {
  background: rgba(46, 230, 166, 0.18);
  color: var(--emerald);
  border: 1px solid rgba(46, 230, 166, 0.45);
  border-radius: 5px;
  padding: 2px 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  flex-shrink: 0;
}
