:root {
  --bg: #05070e;
  --panel: #0b1020;
  --panel-2: #10182e;
  --border: rgba(82, 224, 255, 0.22);
  --cyan: #38f9ff;
  --magenta: #ff49d2;
  --gold: #ffd84d;
  --emerald: #4bffa5;
  --violet: #a882ff;
  --text: #eaf4ff;
  --muted: #8ea4c8;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
}

.topbar {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  background: linear-gradient(180deg, #0b1224, #070b17);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 1;
}
.brand-glyph {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: radial-gradient(circle at 30% 30%, rgba(56,249,255,0.32), rgba(255,73,210,0.18));
  border: 1px solid rgba(56,249,255,0.55);
  color: var(--cyan);
  font-size: 16px;
  text-shadow: 0 0 10px var(--cyan);
  flex-shrink: 0;
}
.brand-text h1 {
  margin: 0;
  font-size: 12px;
  letter-spacing: 1.1px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--cyan), #ffffff 55%, var(--magenta));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}
.brand-text { display: none; }
.brand-text .subtitle {
  margin: 1px 0 0;
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
}
@media (min-width: 1200px) {
  .brand-text { display: block; }
}

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.tab {
  background: rgba(18, 28, 52, 0.72);
  color: var(--muted);
  border: 1px solid rgba(142, 164, 200, 0.2);
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.16s ease;
}
.tab:hover {
  color: var(--text);
  border-color: rgba(56, 249, 255, 0.48);
}
.tab.active {
  color: #041019;
  background: linear-gradient(135deg, var(--cyan), #6ef7ff);
  border-color: var(--cyan);
  box-shadow: 0 0 14px rgba(56, 249, 255, 0.45);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.sibling-link {
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  padding: 5px 6px;
  border-radius: 6px;
  border: 1px solid rgba(142, 164, 200, 0.22);
  background: rgba(14, 22, 42, 0.65);
  transition: all 0.15s ease;
  white-space: nowrap;
}
.sibling-link:hover {
  color: var(--cyan);
  border-color: rgba(56, 249, 255, 0.55);
}
.icon-btn {
  background: rgba(18, 28, 52, 0.85);
  color: var(--text);
  border: 1px solid rgba(142, 164, 200, 0.28);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.icon-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.icon-btn.on {
  border-color: var(--emerald);
  color: var(--emerald);
  box-shadow: 0 0 10px rgba(75, 255, 165, 0.3);
}
.icon-btn.accent {
  border-color: rgba(255, 216, 77, 0.55);
  color: var(--gold);
}
.icon-btn.accent:hover {
  background: rgba(255, 216, 77, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 296px;
  height: calc(100vh - 52px);
  width: 100%;
}

.stage-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 48%, #0a1022 0%, #05070e 72%);
}
#stage {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.hud-top-left {
  position: absolute;
  top: 12px;
  left: 14px;
  pointer-events: none;
  background: rgba(7, 11, 24, 0.78);
  border: 1px solid rgba(56, 249, 255, 0.28);
  backdrop-filter: blur(6px);
  border-radius: 9px;
  padding: 7px 12px;
  max-width: 72%;
}
.hud-top-left .hud-kicker {
  font-size: 9.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--cyan);
  font-weight: 700;
}
.hud-top-left .hud-main {
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  margin-top: 2px;
}

.hud-bottom-left {
  position: absolute;
  bottom: 12px;
  left: 14px;
  pointer-events: none;
  background: rgba(7, 11, 24, 0.76);
  border: 1px solid rgba(142, 164, 200, 0.24);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11px;
  color: var(--muted);
  max-width: 76%;
}

.sidebar {
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.panel { display: none; flex-direction: column; gap: 9px; }
.panel.active { display: flex; }

.panel-section {
  background: var(--panel-2);
  border: 1px solid rgba(82, 224, 255, 0.16);
  border-radius: 10px;
  padding: 9px 10px;
}
.panel-section h3 {
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--cyan);
}

.wp-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
}
[data-panel="wallpaper"] { gap: 7px; }
[data-panel="wallpaper"] .panel-section { padding: 7px 9px; }
[data-panel="wallpaper"] .panel-section h3 { margin-bottom: 6px; }
[data-panel="wallpaper"] .color-row { margin-bottom: 6px; }
[data-panel="wallpaper"] .slider-row { margin-bottom: 6px; }
.wp-btn {
  background: rgba(9, 15, 30, 0.85);
  color: var(--muted);
  border: 1px solid rgba(142, 164, 200, 0.22);
  border-radius: 5px;
  padding: 3px 1px;
  font-size: 10px;
  font-family: var(--mono);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
  transition: all 0.14s ease;
}
.wp-btn span.orb { font-size: 8.5px; opacity: 0.78; }
.wp-btn:hover { border-color: var(--cyan); color: #fff; }
.wp-btn.active {
  background: rgba(56, 249, 255, 0.16);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 10px rgba(56, 249, 255, 0.25);
}

.color-row {
  display: flex;
  gap: 7px;
  margin-bottom: 8px;
}
.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--sw);
  border: 2px solid transparent;
  box-shadow: 0 0 8px var(--sw);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.swatch:hover { transform: scale(1.1); }
.swatch.active { border-color: #ffffff; transform: scale(1.14); }

.btn-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.btn-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.btn-grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }

.preset-btn, .toggle-btn {
  background: rgba(9, 15, 30, 0.88);
  color: var(--muted);
  border: 1px solid rgba(142, 164, 200, 0.24);
  border-radius: 6px;
  padding: 6px 5px;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  text-align: center;
}
.preset-btn:hover, .toggle-btn:hover {
  color: #fff;
  border-color: rgba(56, 249, 255, 0.55);
}
.preset-btn.active {
  background: rgba(56, 249, 255, 0.17);
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 10px rgba(56, 249, 255, 0.22);
}
.toggle-btn.active {
  background: rgba(255, 73, 210, 0.16);
  border-color: var(--magenta);
  color: #ff94e6;
}

.slider-row { margin-bottom: 8px; }
.slider-row label {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 4px;
}
.slider-row label span {
  color: var(--gold);
  font-family: var(--mono);
  font-weight: 700;
}
.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
  cursor: pointer;
}

.telemetry {
  background: linear-gradient(180deg, rgba(16, 24, 46, 0.96), rgba(9, 14, 28, 0.96));
  border-color: rgba(255, 216, 77, 0.28);
}
.telemetry h3 { color: var(--gold); }
.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(142, 164, 200, 0.14);
  font-size: 10.5px;
}
.kv:last-child { border-bottom: none; }
.kv span { color: var(--muted); }
.kv strong {
  color: #ffffff;
  font-family: var(--mono);
  font-size: 10.5px;
  text-align: right;
}
.kv strong.ok { color: var(--emerald); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 5, 12, 0.8);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(760px, 94vw);
  max-height: 86vh;
  background: #0b1123;
  border: 1px solid rgba(56, 249, 255, 0.45);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #0e162d;
}
.modal-head h2 {
  margin: 0;
  font-size: 14px;
  color: var(--cyan);
}
.modal-body {
  padding: 14px 16px;
  overflow-y: auto;
  font-size: 12.5px;
  line-height: 1.5;
  color: #d6e4ff;
}
.modal-lead { margin-top: 0; color: var(--muted); }
.modal-body a { color: var(--cyan); }
.modal-body code {
  font-family: var(--mono);
  background: rgba(56, 249, 255, 0.1);
  padding: 1px 4px;
  border-radius: 4px;
  color: #a9f9ff;
  font-size: 11.5px;
}
.cert-card {
  background: rgba(15, 24, 48, 0.85);
  border: 1px solid rgba(82, 224, 255, 0.2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.cert-card h4 {
  margin: 0 0 5px;
  font-size: 12px;
  color: var(--gold);
}
.cert-card p { margin: 0; }

/* 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-glyph { width: 22px; height: 22px; font-size: 0.82rem; }
  .tabs { gap: 2px; }
  .tab { padding: 4px 5.5px; font-size: 0.63rem; }
  .header-actions { gap: 2.5px; }
  .sibling-link { padding: 2.5px 3.5px; font-size: 0.59rem; }
  .icon-btn { padding: 3px 5px; font-size: 0.62rem; }
}
