:root {
  --bg: #05070d;
  --panel: #0d1220;
  --panel-2: #141b2e;
  --line: #222c45;
  --text: #e6eaf5;
  --muted: #8d97b3;
  --accent: #7fd1ff;
  --retro: #ff5470;
  --pro: #57d9a3;
  --sun: #ffcf5a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

#app { display: flex; height: 100vh; height: 100dvh; }
#stage { position: relative; flex: 1; min-width: 0; overflow: hidden; }
#gl { display: block; width: 100%; height: 100%; touch-action: none; }

/* HUD */
#hud { position: absolute; top: 12px; left: 12px; padding: 10px 12px; min-width: 210px;
  background: rgba(10, 14, 26, .78); border: 1px solid var(--line); border-radius: 10px;
  backdrop-filter: blur(6px); pointer-events: none; }
.hud-mode { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.hud-planet { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; margin: 2px 0 6px; }
.hud-planet .dot { width: 12px; height: 12px; border-radius: 50%; background: #e0603a; box-shadow: 0 0 10px currentColor; }
.hud-row { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; color: var(--muted); }
.hud-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.badge { margin-top: 8px; padding: 6px 10px; border-radius: 6px; font-weight: 700; font-size: 13px; text-align: center; transition: background .2s, color .2s; }
.badge.pro { background: rgba(87, 217, 163, .14); color: var(--pro); }
.badge.retro { background: var(--retro); color: #fff; box-shadow: 0 0 18px rgba(255, 84, 112, .55); }
.badge.station { background: rgba(255, 207, 90, .18); color: var(--sun); }
.event { margin-top: 6px; font-size: 12px; color: var(--sun); min-height: 1em; text-align: center; }

#viewbar { position: absolute; top: 12px; right: 12px; display: flex; background: rgba(10, 14, 26, .78);
  border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
#viewbar button { background: none; border: 0; color: var(--muted); padding: 7px 12px; border-radius: 7px; cursor: pointer; font: inherit; font-weight: 600; }
#viewbar button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
#viewbar button:hover { color: var(--text); }

#earthHint { position: absolute; top: 58px; right: 12px; font-size: 12px; color: var(--muted);
  background: rgba(10, 14, 26, .7); padding: 4px 8px; border-radius: 6px; display: none; pointer-events: none; }
body.view-earth #earthHint { display: block; }

#chartWrap { position: absolute; left: 12px; right: 12px; bottom: 12px; height: 150px;
  background: rgba(10, 14, 26, .82); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
#chartWrap[hidden] { display: none; }
#chart { width: 100%; height: 100%; display: block; }

/* Panel */
#panel { width: 340px; flex: none; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 16px 16px 40px; }
#panel header h1 { font-size: 19px; margin: 0 0 2px; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
#panel section { padding: 14px 0; border-bottom: 1px solid var(--line); }
#panel section:last-child { border-bottom: 0; }
#panel h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 0 0 10px; font-weight: 700; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 8px 6px; border-radius: 7px; cursor: pointer; font: inherit; font-weight: 700; line-height: 1.2; }
.seg button small { display: block; font-weight: 500; font-size: 11px; opacity: .8; }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { display: flex; align-items: center; gap: 6px; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 6px 10px; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; }
.chips button i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chips button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.custom-note { margin-top: 8px; font-size: 12px; color: var(--sun); }

.transport { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.transport .slider { grid-column: 1 / -1; margin-top: 6px; }
button.primary, .transport button { background: var(--panel-2); border: 1px solid var(--line); color: var(--text); padding: 8px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; }
button.primary { background: #1b3a5a; border-color: #2f5f8c; }
.transport button:hover { border-color: var(--accent); }

.slider { display: block; margin: 10px 0; }
.slider > span { display: flex; justify-content: space-between; font-size: 13px; }
.slider output { color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; }
.slider input { width: 100%; accent-color: var(--accent); margin: 4px 0 0; }
.slider.disabled { opacity: .4; }

.check { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; padding: 3px 0; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

details { margin: 4px 0 10px; }
summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
#explainBody p, .try li { font-size: 13px; color: #c9d0e4; margin: 6px 0; }
.try { padding-left: 20px; margin: 4px 0; }
#explainBody b, .try b { color: var(--text); }
.key { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 3px; vertical-align: 0; }
kbd { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font-size: 11px; }

@media (max-width: 820px) {
  #app { flex-direction: column; height: auto; }
  #stage { flex: none; height: 68vh; height: 68svh; }
  #panel { width: 100%; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  #hud { min-width: 0; padding: 7px 9px; top: 8px; left: 8px; }
  .hud-planet { font-size: 16px; margin-bottom: 3px; }
  .hud-row { font-size: 12px; gap: 10px; }
  .badge { font-size: 12px; padding: 4px 8px; }
  #viewbar { top: auto; bottom: 128px; right: 8px; }
  #viewbar button { padding: 6px 9px; }
  #earthHint { display: none !important; }
  #chartWrap { left: 8px; right: 8px; bottom: 8px; height: 112px; }
}
