:root {
  color-scheme: dark;
  --bg: #05060c;
  --panel-bg: rgba(15, 18, 32, 0.72);
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #e8ecf6;
  --text-dim: #9aa3bd;
  --accent: #6ea8ff;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  overflow: hidden;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
}

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

/* ---------- Loading overlay ---------- */

#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: #ffcc33;
  animation: spin 0.9s linear infinite;
}

#loading-overlay p {
  color: var(--text-dim);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Shared panel look ---------- */

#title-bar,
#planet-nav,
#toolbar,
#info-panel {
  position: absolute;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10;
  pointer-events: auto;
}

/* ---------- Title ---------- */

#title-bar {
  top: 16px;
  left: 16px;
  padding: 10px 16px;
  max-width: min(60vw, 420px);
}

#title-bar h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

#title-bar .subtitle {
  margin: 4px 0 0;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ---------- Planet nav ---------- */

#planet-nav {
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
  max-height: 70vh;
  overflow-y: auto;
}

.planet-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
  font-family: inherit;
}

.planet-btn:hover,
.planet-btn.active {
  background: rgba(255, 255, 255, 0.1);
}

.planet-btn .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--dot, #fff);
  flex: none;
  box-shadow: 0 0 6px var(--dot, #fff);
}

/* ---------- Toolbar ---------- */

#toolbar {
  left: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 16px;
  flex-wrap: wrap;
  max-width: calc(100vw - 32px);
}

#play-pause-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  flex: none;
}

#play-pause-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.control input[type="range"] {
  width: 110px;
  accent-color: var(--accent);
}

.control output {
  display: inline-block;
  width: 3.4em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.control.checkbox {
  cursor: pointer;
  user-select: none;
}

.control.checkbox input {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
}

#reset-view-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

#reset-view-btn:hover,
#play-pause-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* ---------- Info panel ---------- */

#info-panel {
  right: 16px;
  bottom: 16px;
  width: 300px;
  max-width: calc(100vw - 32px);
  max-height: 60vh;
  overflow-y: auto;
  padding: 18px 20px;
}

#info-close-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

#info-close-btn:hover {
  color: var(--text);
}

#info-panel h2 {
  margin: 0 0 2px;
  font-size: 1.3rem;
}

.info-type {
  margin: 0 0 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

#info-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0 0 14px;
  font-size: 0.82rem;
}

#info-facts dt {
  color: var(--text-dim);
}

#info-facts dd {
  margin: 0;
  text-align: right;
}

#info-blurb {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-dim);
}

/* ---------- Scrollbars for dark panels ---------- */

#planet-nav::-webkit-scrollbar,
#info-panel::-webkit-scrollbar {
  width: 6px;
}

#planet-nav::-webkit-scrollbar-thumb,
#info-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* ---------- Planet labels (CSS2D) ---------- */

.planet-label {
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  padding: 2px 6px;
  white-space: nowrap;
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.9), 0 0 8px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  transform: translateY(-100%);
}

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  #title-bar {
    max-width: calc(100vw - 32px);
    padding: 8px 12px;
  }

  #title-bar .subtitle {
    display: none;
  }

  #planet-nav {
    top: auto;
    bottom: 16px;
    left: 16px;
    right: 16px;
    max-height: none;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 4px;
  }

  .planet-btn span:not(.dot) {
    display: none;
  }

  #toolbar {
    top: 70px;
    left: 16px;
    right: 16px;
    bottom: auto;
    justify-content: space-between;
  }

  .control input[type="range"] {
    width: 70px;
  }

  #info-panel {
    left: 16px;
    right: 16px;
    width: auto;
    bottom: 72px;
  }
}
