:root {
  color-scheme: dark;
  --bg-space: radial-gradient(circle at 20% 20%, #111b3a, #030510 58%, #01030a 100%);
  --panel-bg: rgba(11, 16, 33, 0.75);
  --panel-border: rgba(255, 255, 255, 0.08);
  --ink: #f5f8ff;
  --muted: rgba(245, 248, 255, 0.7);
  --accent: #ffc857;
  --accent-strong: #ff7b54;
  --emerald: #4ff2c9;
  --ms-band: rgba(79, 242, 201, 0.2);
  --giant-band: rgba(255, 148, 112, 0.18);
  --dwarf-band: rgba(173, 174, 255, 0.2);
  --font-sans: "Trebuchet MS", "Gill Sans", "Segoe UI", "Fira Sans", sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", monospace;
  --transition-fast: 180ms ease-out;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  background: var(--bg-space);
  color: var(--ink);
  line-height: 1.5;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2.5rem clamp(1.5rem, 4vw, 4rem) 3rem;
  gap: 2rem;
}

.app-header,
.diagram-panel,
.info-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: clamp(1.5rem, 2vw, 2.5rem);
  backdrop-filter: blur(12px);
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
}

.app-kicker {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.8rem;
  color: var(--muted);
}

h1, h2, h3 {
  margin: 0.35rem 0;
  font-weight: 600;
}

.app-summary {
  color: var(--muted);
  max-width: 66ch;
}

.header-hint {
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  color: var(--muted);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 2.5fr) minmax(260px, 1fr);
  gap: 1.75rem;
  align-items: stretch;
}

.diagram-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 1rem;
  min-height: 0;
  height: 100%;
}

.panel-label {
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.panel-subtext {
  margin: 0;
  color: var(--muted);
}

.diagram-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.region-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.region-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.region-chip {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.hr-diagram {
  width: 100%;
  height: 100%;
  min-height: 380px;
  max-height: 780px;
  background: rgba(3, 4, 12, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
}

.grid-line {
  stroke: rgba(255, 255, 255, 0.06);
  stroke-dasharray: 6 6;
}

.axis-line {
  stroke: rgba(255, 255, 255, 0.35);
  stroke-width: 1.2;
}

.hr-diagram text {
  font-family: var(--font-sans);
  fill: rgba(255, 255, 255, 0.85);
  font-size: 12px;
}

.axis-title {
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  fill: rgba(255, 255, 255, 0.75);
}

.diagram-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

#regionLayer polygon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stage-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.stage-progress {
  font-size: 0.9rem;
  color: var(--muted);
}

.stage-subtitle {
  margin-top: 0.4rem;
  color: var(--muted);
}

.info-description {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  min-height: 96px;
}

.info-facts {
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.info-facts dt {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.info-facts dd {
  margin: 0.12rem 0 0;
}

#coordinateDetail {
  white-space: pre-line;
}

.control-stack {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 1.25rem;
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.mass-selector,
.stage-controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stage-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.mass-slider {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.slider-display {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mass-value {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.mass-range-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

#massSlider {
  width: 100%;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  outline: none;
}

#massSlider::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  box-shadow: 0 0 12px rgba(255, 200, 87, 0.7);
  cursor: pointer;
  border: none;
}

#massSlider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  border: none;
  box-shadow: 0 0 12px rgba(255, 200, 87, 0.7);
  cursor: pointer;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.slider-ticks span {
  min-width: 32px;
  text-align: center;
}

button {
  font: inherit;
  border-radius: 999px;
  padding: 0.65rem 1.35rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.accent,
.stage-buttons .accent {
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  color: #1c0c05;
  border-color: transparent;
}

.stage-buttons .ghost {
  border-color: rgba(255, 255, 255, 0.4);
}

button:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.control-hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.app-footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.star-marker {
  fill: var(--accent);
  stroke: rgba(255, 255, 255, 0.5);
  stroke-width: 1.5;
  filter: drop-shadow(0 0 18px rgba(255, 200, 87, 0.65));
}

.star-halo {
  fill: none;
  stroke: rgba(255, 255, 255, 0.25);
  stroke-width: 1;
  opacity: 0.8;
}

@media (max-width: 1100px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 1.5rem;
  }

  .stage-buttons {
    flex-direction: column;
  }

  button {
    width: 100%;
    text-align: center;
  }
}
