:root {
  --bg: #060a13;
  --panel: rgba(11, 18, 34, 0.90);
  --border: rgba(82, 232, 214, 0.22);
  --cyan: #5ef2ff;
  --emerald: #3ef0a8;
  --magenta: #ff6ad5;
  --gold: #ffd166;
  --text: #e8f4ff;
  --muted: #8ea9c7;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  overflow: hidden;
}

.topbar {
  height: 52px;
  padding: 0 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  background: rgba(8, 13, 25, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
}

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

.brand-orb {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d6fff4, #3ef0a8 42%, #5ef2ff 72%, #1e3268 100%);
  box-shadow: 0 0 12px rgba(62, 240, 168, 0.65);
  flex-shrink: 0;
}

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

.brand-title {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: linear-gradient(90deg, #5ef2ff, #3ef0a8 48%, #ffd166 92%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.brand-sub {
  font-size: 9.2px;
  color: var(--muted);
  letter-spacing: 0.025em;
  white-space: nowrap;
}

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

.tab {
  appearance: none;
  border: 1px solid rgba(94, 242, 255, 0.22);
  background: rgba(15, 24, 44, 0.74);
  color: #b7d6f2;
  font-size: 10.8px;
  font-weight: 600;
  padding: 5px 7px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
}

.tab:hover {
  border-color: rgba(62, 240, 168, 0.7);
  color: #ffffff;
}

.tab.active {
  background: linear-gradient(135deg, rgba(62, 240, 168, 0.24), rgba(94, 242, 255, 0.22));
  border-color: var(--emerald);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(62, 240, 168, 0.28);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.pill-link {
  text-decoration: none;
  font-size: 9.8px;
  font-weight: 700;
  color: #9ec8ea;
  border: 1px solid rgba(94, 242, 255, 0.22);
  background: rgba(15, 24, 44, 0.7);
  padding: 3.5px 4.8px;
  border-radius: 999px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.pill-link:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.action-btn {
  appearance: none;
  border: 1px solid rgba(255, 209, 102, 0.55);
  background: rgba(255, 209, 102, 0.12);
  color: #ffe39b;
  font-size: 10px;
  font-weight: 700;
  padding: 4.5px 7.5px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.action-btn:hover {
  background: rgba(255, 209, 102, 0.24);
  color: #ffffff;
}

.workspace {
  display: flex;
  height: calc(100vh - 52px);
  width: 100%;
}

.stage-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  background: #060a13;
}

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

.hud-caption {
  position: absolute;
  left: 14px;
  bottom: 12px;
  max-width: calc(100% - 28px);
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(8, 12, 25, 0.88);
  border: 1px solid rgba(62, 240, 168, 0.28);
  color: #cde6ff;
  font-size: 11px;
  line-height: 1.38;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.hud-caption strong { color: var(--gold); }
.hud-caption code {
  color: var(--emerald);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
}

.sidebar {
  width: 274px;
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  background: rgba(8, 13, 25, 0.95);
  border-left: 1px solid var(--border);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 11px;
}

.card h3 {
  font-size: 10.3px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--emerald);
  margin-bottom: 7px;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.btn-grid.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.chip {
  appearance: none;
  border: 1px solid rgba(94, 242, 255, 0.24);
  background: rgba(16, 27, 50, 0.8);
  color: #cfe6ff;
  font-size: 10.8px;
  font-weight: 600;
  padding: 5.5px 6px;
  border-radius: 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.14s ease;
}

.chip:hover {
  border-color: var(--cyan);
  background: rgba(94, 242, 255, 0.14);
  color: #ffffff;
}

.chip.active {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(62, 240, 168, 0.22), rgba(255, 209, 102, 0.22));
  color: #ffffff;
  box-shadow: 0 0 10px rgba(62, 240, 168, 0.22);
}

.chip.wide {
  grid-column: 1 / -1;
}

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

.ctrl-row label {
  font-size: 10.8px;
  color: #b7d4f2;
  display: flex;
  justify-content: space-between;
}

.ctrl-row label span {
  color: var(--gold);
  font-family: ui-monospace, monospace;
  font-weight: 700;
}

.ctrl-row input[type="range"] {
  width: 100%;
  accent-color: var(--emerald);
  cursor: pointer;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
  font-size: 11.2px;
  color: #cfe6ff;
  cursor: pointer;
}

.toggle-row input[type="checkbox"] {
  accent-color: var(--emerald);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  padding: 3.5px 0;
  border-bottom: 1px solid rgba(94, 242, 255, 0.1);
  font-size: 10.8px;
}

.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--muted); flex-shrink: 0; }
.stat-row strong {
  color: #f4f9ff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.6px;
  text-align: right;
  word-break: break-word;
}

.badge-ok { color: var(--emerald) !important; }
.badge-warn { color: var(--magenta) !important; }
.badge-gold { color: var(--gold) !important; }

/* Proofs & Certs Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 16, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 18px;
}

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

.modal-card {
  width: min(820px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  background: #0b1223;
  border: 1px solid rgba(62, 240, 168, 0.45);
  border-radius: 16px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.72);
  padding: 16px 20px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.modal-head h2 {
  font-size: 16.5px;
  color: var(--gold);
  margin-bottom: 3px;
}

.modal-sub {
  font-size: 11.6px;
  color: var(--muted);
}

.modal-sub code {
  color: var(--emerald);
  font-family: ui-monospace, monospace;
}

.modal-close {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

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

.cert-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cert-card {
  background: rgba(15, 23, 44, 0.85);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 13px;
}

.cert-card:nth-child(5) { grid-column: 1 / -1; }

.cert-card h3 {
  font-size: 12px;
  color: var(--emerald);
  margin-bottom: 5px;
}

.cert-card p {
  font-size: 11.3px;
  line-height: 1.43;
  color: #cfe6ff;
}

.math-case { text-transform: none; }

/* Golden home-star pill linking back to The Neon Decet — Grand Constellation Atlas */
.atlas-home-pill {
  color: #ffd666 !important;
  border-color: rgba(255, 214, 102, 0.58) !important;
  background: rgba(255, 214, 102, 0.12) !important;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 0 10px rgba(255, 214, 102, 0.18);
}
.atlas-home-pill:hover {
  color: #fff3c4 !important;
  border-color: rgba(255, 214, 102, 0.92) !important;
  background: rgba(255, 214, 102, 0.24) !important;
  box-shadow: 0 0 14px rgba(255, 214, 102, 0.38);
}

/* Responsive single-row fit for full 10-volume Decet + Atlas header at 1024px */
@media (max-width: 1240px) {
  .topbar { padding: 0 6px; gap: 4px; }
  .brand { gap: 4px; }
  .brand-orb { width: 15px; height: 15px; }
  .brand-title { font-size: 0.68rem; }
  .brand-sub { font-size: 0.53rem; }
  .tabs { gap: 2px; }
  .tab { padding: 4px 5.5px; font-size: 0.64rem; }
  .top-actions { gap: 2.5px; }
  .pill-link { padding: 2.5px 3.5px; font-size: 0.59rem; }
  .action-btn { padding: 3.5px 5.5px; font-size: 0.62rem; }
}
