:root {
  --bg: #070b12;
  --bg-panel: #0d1420;
  --bg-elevated: #131c2b;
  --border: #1e2a3d;
  --text: #e8eef7;
  --muted: #8b9bb5;
  --accent: #3d8bfd;
  --accent-soft: rgba(61, 139, 253, 0.15);
  --nasa-red: #fc3d21;
  --success: #3dd68c;
  --font: "Outfit", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 10% -10%, #12203a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.45;
}

a {
  color: var(--accent);
}

.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2rem;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: conic-gradient(from 210deg, var(--nasa-red), #1a3a6e 40%, #2d6a4f 70%, var(--nasa-red));
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.08);
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.tagline {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.transport {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr minmax(260px, 300px);
  gap: 1rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
}

.panel h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.field.hidden {
  display: none;
}

.field input[type="text"],
.field textarea,
.field input[type="url"],
.field input[type="date"],
.field select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.field textarea {
  resize: vertical;
  min-height: 4.5rem;
  line-height: 1.35;
  word-break: break-all;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: #334155;
  background: #1a2436;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #4a94ff, #2563eb);
  border-color: #3b82f6;
  color: #fff;
}

.btn-accent {
  width: 100%;
  background: linear-gradient(180deg, rgba(252, 61, 33, 0.25), rgba(252, 61, 33, 0.08));
  border-color: rgba(252, 61, 33, 0.45);
}

.btn-file {
  display: inline-flex;
  align-items: center;
}

.inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.inline output {
  min-width: 4.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.hint.ok {
  color: var(--success);
}

.hint.err {
  color: #f87171;
}

.hint.small {
  font-size: 0.72rem;
  line-height: 1.45;
}

.hint.small a {
  color: var(--accent);
}

.scan-mode-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  max-width: 28rem;
  line-height: 1.4;
}

.view-mode-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin: 0.5rem 0 0.35rem;
  width: 100%;
}

.field.inline-compact {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-size: 0.82rem;
}

.field.inline-compact select {
  min-width: 11rem;
}

.globe-host {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  cursor: grab;
  touch-action: none;
}

.globe-host:active {
  cursor: grabbing;
}

.canvas-wrap.mode-globe-view .globe-host {
  display: block;
}

.canvas-wrap.mode-globe-view #viewCanvas,
.canvas-wrap.mode-globe-view #overlayCanvas {
  opacity: 0;
  pointer-events: none;
}

.canvas-wrap.mode-globe-view.mode-eyes:not(.mode-live) .globe-host {
  display: none;
}

.canvas-wrap.mode-globe-view.mode-eyes:not(.mode-live) #viewCanvas,
.canvas-wrap.mode-globe-view.mode-eyes:not(.mode-live) #overlayCanvas {
  opacity: 0;
}

.canvas-wrap.mode-globe-view.mode-live .globe-host {
  display: block;
}

.canvas-wrap.mode-globe-view.mode-live #eyesWrap {
  opacity: 0;
  pointer-events: none;
}

.visual-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.scan-mode {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.scan-mode label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 1;
  background: #05080f;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.canvas-wrap.mode-eyes #viewCanvas,
.canvas-wrap.mode-eyes #overlayCanvas {
  opacity: 0;
  pointer-events: none;
}

.eyes-wrap {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  background: #000;
}

.eyes-wrap.hidden {
  display: none;
}

.eyes-wrap iframe {
  flex: 1;
  width: 100%;
  border: 0;
  min-height: 0;
  background: #000;
}

.eyes-banner {
  flex-shrink: 0;
  padding: 0.45rem 0.65rem;
  font-size: 0.75rem;
  color: #cbd5e1;
  background: linear-gradient(180deg, #0f172a, #0b1220);
  border-top: 1px solid var(--border);
}

.eyes-share-opt {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  margin-top: 0.35rem;
  cursor: pointer;
}

.eyes-banner-sub {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.72rem;
}

.canvas-wrap.mode-live #eyesWrap {
  opacity: 0.15;
  pointer-events: none;
}

.canvas-wrap.mode-live #viewCanvas,
.canvas-wrap.mode-live #overlayCanvas {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}

.video-wrap {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

.video-wrap.hidden {
  display: none;
}

.media-player {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.media-player.hidden {
  display: none;
}

.canvas-wrap.mode-video #viewCanvas,
.canvas-wrap.mode-video #overlayCanvas {
  opacity: 0;
  pointer-events: none;
}

.canvas-wrap.mode-video-analyze #videoWrap {
  opacity: 0.12;
  pointer-events: none;
}

.canvas-wrap.mode-video-analyze #viewCanvas,
.canvas-wrap.mode-video-analyze #overlayCanvas {
  opacity: 1;
  z-index: 4;
}

.mode-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.12rem 0.45rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.45);
  border-radius: 999px;
  vertical-align: middle;
}

.mode-badge.hidden {
  display: none;
}

.video-sonify-panel {
  border: 1px solid rgba(59, 130, 246, 0.35);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  margin: 0 0 0.85rem;
  background: rgba(59, 130, 246, 0.06);
}

.video-sonify-panel.hidden {
  display: none;
}

.video-sonify-panel legend {
  font-size: 0.78rem;
  color: #93c5fd;
  padding: 0 0.25rem;
}

.panel-note {
  margin: 0 0 0.5rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.inline-check {
  flex-direction: row !important;
  align-items: center;
  gap: 0.45rem !important;
  font-size: 0.8rem;
  color: var(--text);
}

.canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
}

#overlayCanvas {
  pointer-events: none;
}

.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

.canvas-placeholder.hidden {
  display: none;
}

.canvas-placeholder .small {
  font-size: 0.78rem;
  opacity: 0.85;
}

.pixel-readout {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.65rem;
  padding: 0.5rem 0.65rem;
  background: var(--bg-elevated);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

#pixelInfo {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
}

.intro {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 0.75rem;
}

.sphere-legend {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  margin: 0 0 0.85rem;
}

.sphere-legend legend {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 0.25rem;
}

.sphere-legend ul {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.78rem;
}

.sphere-legend li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.25rem 0;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.atmos { background: #e2e8f0; }
.dot.geo { background: #a67c52; }
.dot.hydro { background: #0284c7; }
.dot.cryo { background: #7dd3fc; }
.dot.bio { background: #22c55e; }

.channels {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  margin-bottom: 0.85rem;
}

.channels label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.meters {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.meter {
  display: grid;
  grid-template-columns: 1.25rem 1fr;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.meter .bar {
  height: 6px;
  background: #1a2436;
  border-radius: 999px;
  overflow: hidden;
}

.meter .bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  transition: width 0.05s linear;
}

#waveCanvas {
  width: 100%;
  height: 64px;
  background: #05080f;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.boot-banner {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(560px, 92vw);
  padding: 0.75rem 1rem;
  background: #7f1d1d;
  border: 1px solid #fca5a5;
  color: #fff;
  border-radius: 10px;
  font-size: 0.85rem;
  z-index: 9999;
  box-shadow: var(--shadow);
}

.boot-banner.hidden {
  display: none;
}

.boot-banner code {
  font-family: var(--mono);
  font-size: 0.78rem;
}

.btn-small {
  margin-top: 0.45rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.75rem;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--muted);
}
