:root {
  --bg: #070b14;
  --panel: #0c1322;
  --panel-2: #10192d;
  --border: #1e2d4a;
  --text: #e6eefc;
  --muted: #8ea3c7;
  --cyan: #38e8ff;
  --amber: #ffb84d;
  --rose: #ff4f9a;
  --emerald: #34f5a8;
  --violet: #a97bff;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 13px;
  line-height: 1.35;
}

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

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

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

.brand-badge {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  color: #06101c;
  background: linear-gradient(135deg, var(--cyan), var(--emerald));
  box-shadow: 0 0 12px rgba(56, 232, 255, 0.45);
}

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

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

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

.tab {
  border: 1px solid #243759;
  background: #0d172b;
  color: #c2d4f2;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.14s ease;
}

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

.tab.active {
  background: linear-gradient(135deg, #27e3ff, #38f2b7);
  color: #06101c;
  border-color: transparent;
  box-shadow: 0 0 12px rgba(56, 232, 255, 0.4);
}

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

.pill {
  text-decoration: none;
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all 0.14s ease;
}

.pill-atlas {
  background: rgba(255, 184, 77, 0.12);
  border-color: rgba(255, 184, 77, 0.55);
  color: var(--amber);
}
.pill-atlas:hover { background: rgba(255, 184, 77, 0.24); }

.pill-peer {
  background: rgba(56, 232, 255, 0.1);
  border-color: rgba(56, 232, 255, 0.5);
  color: var(--cyan);
}
.pill-peer:hover { background: rgba(56, 232, 255, 0.22); }

.pill-proofs {
  background: rgba(52, 245, 168, 0.12);
  border-color: rgba(52, 245, 168, 0.55);
  color: var(--emerald);
}
.pill-proofs:hover { background: rgba(52, 245, 168, 0.24); }

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

.stage-col {
  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: 1.38fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 8px;
}

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

.panel-main {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.panel-sub1 {
  grid-column: 2;
  grid-row: 1;
}

.panel-sub2 {
  grid-column: 2;
  grid-row: 2;
}

.panel-head {
  padding: 6px 10px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.45px;
  color: var(--amber);
  background: rgba(8, 13, 24, 0.65);
  border-bottom: 1px solid rgba(30, 45, 74, 0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.panel-sub1 .panel-head { color: var(--rose); }
.panel-sub2 .panel-head { color: var(--cyan); }

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

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

.caption-bar span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.sidebar {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  overflow: hidden;
}

.side-header h1 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 3px;
  line-height: 1.2;
}

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

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

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

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

.stat-val {
  margin-top: 2px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

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

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

.ctrl-val {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 700;
  color: var(--cyan);
}

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

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

.btn {
  flex: 1;
  border: 1px solid #2b4169;
  background: #111c33;
  color: #dce8ff;
  border-radius: 7px;
  padding: 5px 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}

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

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

.btn.action {
  border-color: rgba(52, 245, 168, 0.55);
  background: rgba(52, 245, 168, 0.14);
  color: var(--emerald);
}
.btn.action:hover { background: rgba(52, 245, 168, 0.25); }

.btn.warn {
  border-color: rgba(255, 79, 154, 0.55);
  background: rgba(255, 79, 154, 0.14);
  color: var(--rose);
}
.btn.warn:hover { background: rgba(255, 79, 154, 0.25); }

.theorem-card {
  background: linear-gradient(180deg, #101730 0%, #0b1123 100%);
  border: 1px solid rgba(169, 123, 255, 0.4);
  border-radius: 9px;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}

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

.theorem-eq {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10.5px;
  color: var(--amber);
  background: rgba(7, 11, 20, 0.72);
  border: 1px solid rgba(255, 184, 77, 0.24);
  border-radius: 6px;
  padding: 5px 7px;
  line-height: 1.32;
}

.theorem-body {
  font-size: 11px;
  color: #c2d4f2;
  line-height: 1.32;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.78);
  display: grid;
  place-items: center;
  z-index: 90;
  padding: 16px;
}

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

.modal-card {
  width: min(740px, 94vw);
  max-height: 86vh;
  background: #0c1426;
  border: 1px solid rgba(56, 232, 255, 0.45);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7);
}

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

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

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

.modal-close {
  background: #15223c;
  border: 1px solid var(--border);
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
}

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

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

.cli-box {
  flex-shrink: 0;
  background: #060a13;
  border: 1px solid rgba(52, 245, 168, 0.45);
  border-radius: 8px;
  padding: 9px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--emerald);
  overflow-x: auto;
  white-space: nowrap;
}

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

.proof-item {
  background: #0f1a30;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 11px;
}

.proof-name {
  font-weight: 700;
  font-size: 12px;
  color: var(--cyan);
  margin-bottom: 3px;
}

.proof-detail {
  font-size: 11.2px;
  color: #c8d8f5;
  line-height: 1.38;
}
