* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: oklch(0.065 0.02 255);
  color: oklch(0.92 0.02 250);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  overflow-x: hidden;
}

:root {
  --bg: oklch(0.065 0.02 255);
  --bg-grid: oklch(0.10 0.024 258);
  --panel: oklch(0.12 0.026 258 / 0.95);
  --line: oklch(0.24 0.03 258);
  --line-soft: oklch(0.20 0.026 258);
  --text: oklch(0.92 0.02 250);
  --text-dim: oklch(0.62 0.03 250);
  --text-faint: oklch(0.45 0.025 250);
  --accent: oklch(0.85 0.12 80);
}

/* --- dust background --- */
#dust { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.6; }

/* --- top bar --- */
.topbar {
  position: sticky; top: 0; z-index: 80;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 20px;
  background: oklch(0.09 0.022 258 / 0.85);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  font-size: 11px; letter-spacing: 0.5px; color: var(--text-dim);
}
.tb-left { display: flex; align-items: center; gap: 10px; }
.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 11px; letter-spacing: 0.5px;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.back-link:hover { color: var(--text); border-color: var(--text-dim); background: oklch(0.15 0.03 260); }
.tb-left .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px oklch(0.85 0.12 80 / 0.8);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.tb-mid { text-align: center; color: oklch(0.9 0.04 80); letter-spacing: 3px; font-size: 11px; }
.tb-right { text-align: right; display: flex; gap: 14px; justify-content: flex-end; }

/* --- main / intro --- */
main { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 28px 20px 80px; }
.intro { max-width: 640px; margin: 4px 0 34px; }
.intro h1 {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 22px; font-weight: 600; letter-spacing: 0.2px;
  margin: 0 0 8px; color: oklch(0.96 0.02 250);
}
.intro p {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 13px; line-height: 1.6; color: var(--text-dim); margin: 0;
}

/* --- orbit grid --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(400px, 100%), 1fr));
  gap: 30px;
}

.system {
  position: relative;
  background: linear-gradient(180deg, var(--bg-grid), oklch(0.085 0.02 258));
  border: 1px solid var(--line);
  aspect-ratio: 1 / 1;
  isolation: isolate;
}
.system::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 50%, oklch(0.7 0.1 var(--hue) / 0.10), transparent 65%);
  pointer-events: none;
}
.system.pulse-target::before { animation: floodPulse 1.6s ease-out; }
@keyframes floodPulse {
  0% { background: radial-gradient(ellipse at 50% 50%, oklch(0.8 0.18 var(--hue) / 0.55), transparent 65%); }
  100% { background: radial-gradient(ellipse at 50% 50%, oklch(0.7 0.1 var(--hue) / 0.10), transparent 65%); }
}

.orbit-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.ring-guide { fill: none; stroke: var(--line-soft); stroke-width: 1; stroke-dasharray: 2 5; }
.sun { fill: oklch(0.93 0.09 var(--hue)); }
.sun-glow { mix-blend-mode: screen; }

.planet-hit { fill: transparent; cursor: pointer; pointer-events: all; will-change: transform; }
.planet-core {
  transition: r 0.15s ease, filter 0.15s ease;
  filter: drop-shadow(0 0 2px oklch(0.8 0.1 var(--hue) / 0.6));
  pointer-events: none;
  will-change: transform;
}
.planet-label {
  font-family: ui-monospace, monospace;
  font-size: 9.5px; letter-spacing: 0.2px;
  fill: var(--text-dim);
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: oklch(0.09 0.02 258);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
  transition: fill 0.15s ease;
  will-change: transform;
}
.planet:hover .planet-core, .planet.selected .planet-core { filter: drop-shadow(0 0 7px oklch(0.9 0.18 var(--hue) / 0.95)); r: 8; }
.planet:hover .planet-label, .planet.selected .planet-label { fill: oklch(0.96 0.03 var(--hue)); }
.planet.selected .planet-core { stroke: oklch(0.97 0.02 90); stroke-width: 1.5; }
.planet.pulse-planet .planet-core { animation: planetPulse 1.6s ease-out; }
@keyframes planetPulse {
  0% { r: 13; filter: drop-shadow(0 0 14px oklch(0.95 0.22 var(--hue) / 1)); }
  100% { r: 5; }
}

.system-label { position: absolute; left: 14px; top: 12px; pointer-events: none; }
.system-label .cat { display: block; font-size: 10px; letter-spacing: 3px; color: oklch(0.75 0.1 var(--hue)); }
.system-label .name { display: block; font-size: 14px; letter-spacing: 1.5px; color: oklch(0.94 0.02 250); margin-top: 2px; }

.system-hint {
  position: absolute; right: 14px; bottom: 11px; font-size: 10px; color: var(--text-faint);
  letter-spacing: 0.5px; pointer-events: none; transition: opacity 0.2s ease;
}
.system:hover .system-hint { opacity: 0; }

.beam-layer { position: fixed; inset: 0; z-index: 50; pointer-events: none; }
.beam-path { fill: none; stroke: oklch(0.85 0.16 var(--hue)); stroke-width: 1.4; filter: drop-shadow(0 0 4px oklch(0.8 0.18 var(--hue) / 0.8)); }
.beam-dot { fill: oklch(0.96 0.05 var(--hue)); filter: drop-shadow(0 0 6px oklch(0.9 0.2 var(--hue) / 1)); }

/* --- detail panel --- */
.detail {
  position: fixed; top: 0; right: 0; height: 100%; width: 380px; max-width: 92vw;
  background: var(--panel); backdrop-filter: blur(10px);
  border-left: 1px solid var(--line);
  padding: 70px 24px 24px; overflow-y: auto;
  z-index: 100; transform: translateX(100%); transition: transform 0.28s ease;
}
.detail.open { transform: translateX(0); }
@media (min-width: 721px) {
  .detail.detail-left {
    left: 0; right: auto; border-left: none; border-right: 1px solid var(--line);
    transform: translateX(-100%);
  }
  .detail.detail-left.open { transform: translateX(0); }
}
.detail .close {
  position: absolute; top: 16px; right: 16px; background: none; border: 1px solid var(--line);
  color: var(--text-dim); width: 30px; height: 30px; cursor: pointer; font-size: 15px;
}
.detail .close:hover { color: var(--text); border-color: var(--text-dim); }
.d-cat { font-size: 10px; letter-spacing: 3px; color: oklch(0.8 0.12 var(--hue)); margin-bottom: 8px; }
.d-name { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 23px; font-weight: 600; color: oklch(0.98 0.02 250); margin-bottom: 6px; }
.d-meta { font-size: 10px; color: var(--text-faint); letter-spacing: 1px; margin-bottom: 20px; }
.d-sec { margin-bottom: 22px; }
.d-h { font-size: 10px; letter-spacing: 2.5px; text-transform: uppercase; color: var(--text-dim); margin-bottom: 10px; }
.d-desc { font-family: ui-sans-serif, system-ui, sans-serif; font-size: 13px; line-height: 1.6; color: oklch(0.88 0.02 250); }
.d-empty { font-size: 12px; color: var(--text-faint); }
.pills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pills li { font-size: 11.5px; padding: 5px 9px; border: 1px solid var(--line); background: oklch(0.15 0.03 260); color: var(--text-dim); }
.xlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.xlist li { padding: 8px 10px; border: 1px solid var(--line); border-left: 2px solid oklch(0.85 0.1 80 / 0.7); background: oklch(0.14 0.03 260); cursor: pointer; transition: background 0.15s ease; }
.xlist li:hover { background: oklch(0.19 0.04 260); }
.xrel { font-size: 9.5px; letter-spacing: 1.3px; color: oklch(0.75 0.1 80); text-transform: uppercase; margin-bottom: 4px; }
.xtgt { font-size: 13px; color: oklch(0.95 0.02 250); display: flex; align-items: center; gap: 7px; }
.xdot { width: 7px; height: 7px; border-radius: 50%; flex: none; }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; gap: 22px; }
  .detail {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%; max-width: 100%; height: auto; max-height: 78vh;
    border-left: none; border-top: 1px solid var(--line); transform: translateY(100%); padding: 26px 18px 30px;
  }
  .detail.open { transform: translateY(0); }
  .detail .close { top: 10px; right: 12px; }
  .tb-right { display: none; }
  .planet-label { font-size: 10.5px; }
}

@media (prefers-reduced-motion: reduce) {
  .tb-left .dot { animation: none; }
}
