:root {
  --bg: #05070d;
  --panel: rgba(12, 16, 28, 0.86);
  --line: rgba(255, 255, 255, 0.12);
  --text: #e8ecf4;
  --muted: #8d95a8;
  --accent: #7cc4ff;
}
* { 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", sans-serif; overflow: hidden; }
#globe { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
a { color: var(--accent); }

#panel {
  position: fixed; top: 16px; left: 16px; width: 320px; max-height: calc(100% - 96px);
  display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; backdrop-filter: blur(12px); overflow: hidden;
}
#panel header { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
#panel h1 { margin: 0 0 8px; font-size: 18px; letter-spacing: 0.04em; }
#panel section { padding: 12px 16px; overflow-y: auto; }
#panel footer { padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

#modes { display: flex; gap: 6px; }
#modes button, #timeline button, #timeline select, #route select {
  background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font: inherit; cursor: pointer;
}
#modes button.on { background: var(--accent); color: #06111f; border-color: transparent; }

#constellations { list-style: none; margin: 0; padding: 0; }
#constellations li { border-bottom: 1px solid var(--line); padding: 8px 0; }
#constellations li:last-child { border-bottom: 0; }
#constellations .row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
#constellations .swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
#constellations .name { flex: 1; }
#constellations .name small { color: var(--muted); margin-left: 6px; }
#constellations .count { font-variant-numeric: tabular-nums; color: var(--muted); }
#constellations input { accent-color: var(--accent); }
#constellations .shells { margin: 8px 0 0 22px; font-size: 12px; color: var(--muted); display: none; }
#constellations li.open .shells { display: block; }
#constellations .shells div { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
#constellations .shells b { color: var(--text); font-weight: 500; }

#route label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; }
#route select { flex: 1; max-width: 200px; }
#route input[type=range] { flex: 1; accent-color: var(--accent); }
#route-result { margin: 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
#route-result .big { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
#route-result .vs { color: var(--muted); font-size: 12px; margin-top: 4px; }
#route-result .none { color: #ffb347; }

.hint { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

#sat { border-bottom: 1px solid var(--line); flex: none; }
#sat .sat-head { display: flex; align-items: center; gap: 10px; }
#sat .swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; }
#sat b { flex: 1; font-weight: 600; }
#sat-close { background: none; border: 0; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; }
#sat-close:hover { color: var(--text); }
#sat-facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 10px 0 0; font-size: 13px; }
#sat-facts dt { color: var(--muted); }
#sat-facts dd { margin: 0; font-variant-numeric: tabular-nums; }
#sat .links { margin: 10px 0 0; font-size: 12px; }
#globe.pick { cursor: pointer; }

#timeline {
  position: fixed; left: 16px; right: 16px; bottom: 16px; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(12px);
}
#timeline input[type=range] { flex: 1; accent-color: var(--accent); }
#clock { font-variant-numeric: tabular-nums; min-width: 150px; text-align: right; }
#play { width: 36px; }

#loading { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); color: var(--muted); font-size: 16px; letter-spacing: 0.05em; }
#loading.done { display: none; }

#share { display: block; width: 100%; margin: 0 0 12px; padding: 8px; background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font: inherit; cursor: pointer; }
.grip { display: none; }
#timeline .when { display: contents; }

/* Phones: the panel is a bottom sheet that folds down to its header, and the
   timeline moves to the top. Insets keep both clear of the notch and the
   home indicator. */
@media (max-width: 720px) {
  body { -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
  #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 62%;
    border-radius: 16px 16px 0 0; border-bottom: 0; padding-bottom: env(safe-area-inset-bottom);
    transition: transform 0.25s ease; user-select: none; -webkit-user-select: none;
  }
  #panel.folded { transform: translateY(calc(100% - var(--head, 96px))); }
  #panel header { padding-top: 6px; cursor: pointer; }
  .grip { display: block; width: 36px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.25); margin: 0 auto 8px; }
  #panel section { -webkit-overflow-scrolling: touch; }
  #timeline {
    left: 8px; right: 8px; bottom: auto; top: calc(8px + env(safe-area-inset-top));
    padding: 8px 10px; gap: 8px;
  }
  /* Clock and "now" drop to a second row; the slider keeps the first. */
  #timeline { flex-wrap: wrap; }
  #timeline .when { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 8px; }
  #clock { min-width: 0; font-size: 12px; white-space: nowrap; flex: none; text-align: left; }
  #timeline input[type=range] { min-width: 40px; width: 0; }
  #modes button, #timeline button, #timeline select, #route select { padding: 8px 12px; min-height: 40px; }
  #timeline button, #timeline select { padding: 8px 8px; }
  #constellations li { padding: 10px 0; }
}

footer .lang { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
footer .lang select { background: rgba(255,255,255,0.06); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font: inherit; }
