:root {
  --bg: #060910;
  --panel: #0c1220;
  --panel-2: #111a2e;
  --border: #1d2a44;
  --border-bright: #2e436d;
  --text: #e6eefb;
  --muted: #8b9ec2;
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --amber: #fbbf24;
  --magenta: #f43f5e;
  --emerald: #34d399;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

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

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

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 7px 14px;
  background: linear-gradient(180deg, #0b111e 0%, #080c16 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-title {
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--amber));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sub {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.room-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  order: 3;
  flex-basis: 100%;
}

.tab-btn {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 7.5px;
  font-size: 10.8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.tab-btn:hover {
  color: var(--text);
  border-color: var(--border-bright);
  background: var(--panel-2);
}

.tab-btn.active {
  color: #06101a;
  background: linear-gradient(135deg, var(--cyan), #7dd3fc);
  border-color: var(--cyan);
  box-shadow: 0 0 16px rgba(34, 211, 238, 0.35);
}

.util-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.util-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.util-btn:hover {
  border-color: var(--cyan);
  background: var(--panel-2);
}

.util-btn.on {
  border-color: var(--emerald);
  color: var(--emerald);
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.25);
}

/* Main workspace */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

.stage-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 45%, #0b1326 0%, #05080f 75%);
  border-right: 1px solid var(--border);
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

#mirrorCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.stage-hud {
  position: absolute;
  top: 12px;
  left: 14px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(8, 13, 24, 0.82);
  border: 1px solid rgba(46, 67, 109, 0.65);
  backdrop-filter: blur(6px);
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  width: fit-content;
}

.hud-hint {
  font-size: 11px;
  color: var(--muted);
  background: rgba(8, 13, 24, 0.72);
  padding: 3px 9px;
  border-radius: 6px;
  width: fit-content;
}

/* Inspector */
.inspector {
  background: var(--panel);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 13px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cyan);
}

.room-heading {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.room-desc {
  font-size: 12.5px;
  color: var(--muted);
}

/* Controls */
.ctrl-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ctrl-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text);
}

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

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

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-btn {
  background: #0a101e;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mini-btn:hover {
  color: var(--text);
  border-color: var(--border-bright);
}

.mini-btn.active {
  color: #06101a;
  background: var(--cyan);
  border-color: var(--cyan);
}

.mini-btn.gold.active {
  background: var(--amber);
  border-color: var(--amber);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

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

/* Telemetry */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.stat-box {
  background: #080d18;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 9px;
}

.stat-k {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-v {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

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

.zone-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  background: #080d18;
}

.zone-badge.lit {
  border-color: rgba(34, 211, 238, 0.55);
  background: rgba(34, 211, 238, 0.09);
  color: var(--cyan);
}

.zone-badge.dark {
  border-color: rgba(139, 158, 194, 0.25);
  background: #05080f;
  color: #64748b;
}

.zone-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.math-note {
  font-size: 12px;
  color: #b7c6e0;
  line-height: 1.55;
}

.math-note code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: #080d18;
  color: var(--amber);
  padding: 1px 4px;
  border-radius: 4px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.78);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--panel);
  border: 1px solid var(--border-bright);
  border-radius: 14px;
  max-width: 780px;
  width: 100%;
  max-height: 86vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.modal-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--cyan);
}

.modal-section h3 {
  font-size: 13.5px;
  color: var(--amber);
  margin-bottom: 5px;
}

.modal-section p {
  font-size: 12.5px;
  color: #c8d5ec;
  margin-bottom: 6px;
}

.cert-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11.5px;
  margin-top: 6px;
}

.cert-table th, .cert-table td {
  border: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
}

.cert-table th {
  background: #090f1d;
  color: var(--cyan);
}

.cert-table td.pass {
  color: var(--emerald);
  font-weight: 700;
}

.download-link {
  display: inline-block;
  margin-top: 4px;
  color: var(--cyan);
  text-decoration: none;
  font-weight: 600;
  font-size: 12.5px;
}

.download-link:hover {
  text-decoration: underline;
}

@media (max-width: 920px) {
  .app-shell {
    height: auto;
    overflow: visible;
  }
  .workspace {
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .stage-wrap {
    min-height: 460px;
    height: 460px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

/* 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);
}
