:root {
  --bg: #0b0e14;
  --panel: rgba(15, 18, 26, 0.82);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text: #e5e7eb;
  --text-dim: #9aa3b2;
  --accent: #38bdf8;
  --accent-2: #22d3ee;
  --success: #34d399;
  --warn: #fbbf24;
  --error: #f87171;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#app { position: fixed; inset: 0; }

#scene-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- Top bar ---------- */
.topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  z-index: 20;
  pointer-events: none;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, var(--accent));
  box-shadow: 0 0 12px var(--accent);
}
.brand h1 { font-size: 18px; font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { font-size: 12px; color: var(--text-dim); letter-spacing: 0.06em; }

.tle-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-dim);
  font-family: var(--mono);
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); }
.status-dot.ok { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.err { background: var(--error); box-shadow: 0 0 8px var(--error); }

/* ---------- Camera controls ---------- */
.cam-controls {
  position: absolute;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  z-index: 20;
}
.cam-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease-out, color 0.15s ease-out;
}
.cam-btn:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.cam-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cam-btn.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06222e;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.4);
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  left: 16px;
  bottom: 16px;
  width: 300px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  z-index: 20;
}
.hud-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.hud-title { font-size: 11px; font-weight: 700; letter-spacing: 0.14em; color: var(--text-dim); }
.hud-live {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  color: var(--success);
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}
.hud-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.metric { display: flex; flex-direction: column; gap: 3px; }
.metric-label { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; color: var(--text-dim); }
.metric-value {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.metric-value.small { font-size: 13px; color: var(--text-dim); }
.metric-value.day { color: var(--warn); }
.metric-value.night { color: var(--accent); }
.hud-foot {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--panel-border);
  display: flex; flex-direction: column; gap: 3px;
}

/* ---------- Legend ---------- */
.legend {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  z-index: 20;
  font-size: 12px;
  color: var(--text-dim);
}
.legend span { display: flex; align-items: center; gap: 8px; }
.swatch { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.swatch.orbit { background: var(--accent-2); box-shadow: 0 0 8px rgba(34, 211, 238, 0.6); }
.swatch.foot { background: rgba(56, 189, 248, 0.5); border: 1px solid var(--accent); }
.swatch.subsat { background: var(--warn); border-radius: 50%; width: 8px; height: 8px; }

/* ---------- Loading ---------- */
.loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px;
  background: var(--bg);
  z-index: 50;
  transition: opacity 0.4s ease-out;
}
.loading.hidden { opacity: 0; pointer-events: none; }
.spinner {
  width: 44px; height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { font-size: 14px; color: var(--text-dim); }

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 520px;
  padding: 12px 18px;
  background: rgba(248, 113, 113, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fecaca;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 40;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .brand-sub { display: none; }
  .hud { width: calc(100% - 32px); left: 16px; right: 16px; }
  .legend { display: none; }
  .cam-controls { top: 72px; }
  .cam-btn { padding: 8px 12px; font-size: 12px; }
  .topbar { top: 10px; left: 10px; right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .live-dot, .spinner { animation: none; }
  * { transition: none !important; }
}
