:root {
  --bg-0: #05070e;
  --bg-1: #0b1020;
  --bg-2: #11182e;
  --border: rgba(130, 165, 255, 0.22);
  --border-hi: rgba(179, 136, 255, 0.55);
  --text: #eef3ff;
  --muted: #93a4cc;
  --cyan: #38f2ff;
  --gold: #ffd166;
  --violet: #b388ff;
  --magenta: #ff5da2;
  --emerald: #4ef2a1;
}

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

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

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

/* Header */
.topbar {
  height: 46px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  background: rgba(8, 12, 26, 0.94);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

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

.brand-badge {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #060914;
  background: linear-gradient(135deg, var(--gold), var(--violet), var(--cyan));
  box-shadow: 0 0 12px rgba(179, 136, 255, 0.45);
}

.brand-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  line-height: 1.1;
  white-space: nowrap;
}

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

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

.tab {
  border: 1px solid rgba(140, 170, 255, 0.22);
  background: rgba(18, 25, 48, 0.72);
  color: #c2d1f4;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

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

.tab.active {
  background: linear-gradient(135deg, rgba(179, 136, 255, 0.28), rgba(56, 242, 255, 0.22));
  border-color: var(--cyan);
  color: #ffffff;
  box-shadow: 0 0 10px rgba(56, 242, 255, 0.24);
}

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

.pill {
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(18, 26, 52, 0.85);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

.atlas-pill {
  border-color: rgba(255, 209, 102, 0.52);
  color: var(--gold);
  background: rgba(255, 209, 102, 0.1);
}

.comp-pill {
  border-color: rgba(56, 242, 255, 0.48);
  color: var(--cyan);
  background: rgba(56, 242, 255, 0.1);
}

.complex-pill {
  border-color: rgba(179, 136, 255, 0.5);
  color: var(--violet);
  background: rgba(179, 136, 255, 0.11);
}

.proofs-pill {
  border-color: rgba(78, 242, 161, 0.55);
  color: var(--emerald);
  background: rgba(78, 242, 161, 0.12);
}

.pill:hover {
  filter: brightness(1.18);
  transform: translateY(-0.5px);
}

/* Workspace */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  gap: 8px;
  padding: 8px;
}

.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, 0.92fr);
  gap: 8px;
}

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

.panel {
  background: linear-gradient(180deg, rgba(14, 20, 40, 0.92), rgba(7, 10, 22, 0.95));
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.panel-head {
  height: 26px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--violet);
  background: rgba(16, 24, 48, 0.85);
  border-bottom: 1px solid rgba(130, 165, 255, 0.16);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-head.cyan { color: var(--cyan); }
.panel-head.magenta { color: var(--magenta); }
.panel-head.gold { color: var(--gold); }

.canvas-wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  width: 100%;
  height: 100%;
}

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

/* Stats Grid */
.stats-grid {
  height: 54px;
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat-card {
  background: rgba(11, 16, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

/* Right Control Column */
.control-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  min-width: 0;
}

.control-panel {
  flex: 1;
  min-height: 0;
}

.controls-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ctrl-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
  color: #cdd8f6;
}

.ctrl-val {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 10.5px;
  color: var(--cyan);
}

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

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

.btn {
  flex: 1 1 auto;
  border: 1px solid rgba(140, 170, 255, 0.25);
  background: rgba(20, 29, 58, 0.85);
  color: #d6e2ff;
  font-size: 10.5px;
  font-weight: 600;
  padding: 5px 6px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.12s ease;
}

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

.btn.active {
  background: linear-gradient(135deg, rgba(56, 242, 255, 0.24), rgba(179, 136, 255, 0.24));
  border-color: var(--cyan);
  color: #ffffff;
}

.btn.gold.active {
  background: rgba(255, 209, 102, 0.22);
  border-color: var(--gold);
  color: var(--gold);
}

.btn.action {
  background: rgba(78, 242, 161, 0.14);
  border-color: rgba(78, 242, 161, 0.45);
  color: var(--emerald);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10.5px;
  color: #cdd8f6;
  cursor: pointer;
  padding: 2px 0;
}

.toggle-row input {
  accent-color: var(--violet);
  cursor: pointer;
}

.hint-box {
  font-size: 10px;
  line-height: 1.38;
  color: var(--muted);
  background: rgba(16, 24, 48, 0.65);
  border: 1px solid rgba(130, 165, 255, 0.16);
  border-radius: 6px;
  padding: 6px 7px;
}

/* Theorem Card */
.theorem-card {
  flex-shrink: 0;
  background: linear-gradient(160deg, rgba(22, 18, 48, 0.94), rgba(9, 13, 28, 0.96));
  border: 1px solid rgba(179, 136, 255, 0.34);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.theorem-head {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--gold);
}

.theorem-eq {
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 10px;
  color: var(--cyan);
  line-height: 1.3;
  word-break: break-word;
}

.theorem-note {
  font-size: 10px;
  line-height: 1.35;
  color: #c5d2f2;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 12, 0.78);
  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(820px, 95vw);
  max-height: 88vh;
  background: #0a0f20;
  border: 1px solid var(--border-hi);
  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;
  background: rgba(17, 25, 50, 0.92);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.modal-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
}

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

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  border-color: var(--magenta);
  color: var(--magenta);
}

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

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

.cli-box {
  flex-shrink: 0;
  background: #060914;
  border: 1px solid rgba(56, 242, 255, 0.35);
  border-radius: 8px;
  padding: 9px 12px;
}

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

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

.suite-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.suite-box {
  background: rgba(14, 21, 42, 0.85);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

.suite-box.full {
  grid-column: 1 / -1;
}

.suite-box h4 {
  font-size: 11px;
  color: var(--gold);
  margin-bottom: 5px;
}

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

.suite-box li {
  font-size: 10.5px;
  line-height: 1.35;
  color: #d0dcf8;
}

.pass-tag {
  color: var(--emerald);
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  margin-right: 4px;
}
