:root {
  color-scheme: dark;
  --bg: #050506;
  --panel: rgba(14, 15, 18, 0.86);
  --panel-strong: rgba(24, 23, 20, 0.94);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f5f1e7;
  --muted: #b7b1a4;
  --gold: #ffc247;
  --cyan: #5bd8d0;
  --green: #7bd86d;
  --red: #ff755f;
  --button: rgba(255, 255, 255, 0.09);
  --button-hover: rgba(255, 255, 255, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 177, 67, 0.15), transparent 24rem),
    radial-gradient(circle at 85% 12%, rgba(91, 216, 208, 0.12), transparent 22rem),
    linear-gradient(135deg, #050506 0%, #13100c 44%, #07080a 100%);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button);
  color: var(--text);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

button:hover {
  background: var(--button-hover);
  border-color: var(--line-strong);
}

button:active {
  transform: translateY(1px);
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  padding: 16px;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: flex;
  min-width: 260px;
  flex-direction: column;
  justify-content: center;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 10, 10, 0.68);
  backdrop-filter: blur(18px);
}

.brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.brand span {
  margin-top: 4px;
  color: var(--gold);
  font-size: 13px;
}

.status-strip {
  display: grid;
  flex: 1;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.status-item {
  display: grid;
  align-content: center;
  min-height: 70px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 16, 16, 0.72);
  backdrop-filter: blur(18px);
}

.status-item span {
  color: var(--muted);
  font-size: 12px;
}

.status-item strong {
  margin-top: 4px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.15;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
  gap: 12px;
}

.orbit-stage {
  position: relative;
  min-width: 0;
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #030303;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

#spaceCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

#spaceCanvas.dragging {
  cursor: grabbing;
}

.stage-toolbar {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 8px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  background: rgba(8, 8, 8, 0.62);
  backdrop-filter: blur(12px);
  font-size: 19px;
}

.timeline-panel {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: min(420px, calc(100% - 24px));
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 8, 8, 0.68);
  backdrop-filter: blur(16px);
}

.timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.timeline-head strong {
  color: var(--gold);
}

.timeline-track {
  height: 8px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.timeline-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--gold));
  transition: width 120ms linear;
}

.control-panel {
  display: grid;
  min-height: 0;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding-right: 2px;
}

.panel-block {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(18px);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-title h2,
.selected-head h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: 0;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.button-grid button {
  min-height: 38px;
  padding: 0 8px;
  white-space: nowrap;
}

.button-grid button[aria-pressed="true"],
.segmented button.active {
  border-color: rgba(255, 194, 71, 0.62);
  background: rgba(255, 194, 71, 0.18);
  color: #ffe3a0;
}

.range-control {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.range-control input {
  width: 100%;
  accent-color: var(--gold);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}

.segmented button {
  min-height: 36px;
}

.planet-block {
  padding-bottom: 8px;
}

.planet-list {
  display: grid;
  gap: 8px;
}

.planet-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  text-align: left;
}

.planet-row.active {
  border-color: rgba(91, 216, 208, 0.68);
  background: rgba(91, 216, 208, 0.12);
}

.planet-row .planet-name {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.planet-row .planet-period {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.planet-row .planet-progress {
  width: 48px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
}

.planet-row .planet-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--planet-color, var(--gold));
}

.planet-dot {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--planet-color, var(--gold));
  box-shadow: 0 0 16px var(--planet-color, var(--gold));
}

.selected-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.selected-head p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.planet-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

.planet-facts div {
  min-height: 56px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.052);
}

.planet-facts dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.planet-facts dd {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.fact-text {
  margin: 12px 0 0;
  color: #e7dfcf;
  font-size: 13px;
  line-height: 1.55;
}

.mission-list {
  display: grid;
  gap: 8px;
}

.mission-item {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.052);
}

.mission-item.complete {
  border-color: rgba(123, 216, 109, 0.52);
  background: rgba(123, 216, 109, 0.11);
}

.mission-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mission-top strong {
  font-size: 13px;
}

.mission-top span {
  color: var(--muted);
  font-size: 12px;
}

.mission-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.mission-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--cyan));
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .workspace {
    display: grid;
  }

  .orbit-stage {
    height: 64vh;
    min-height: 440px;
  }

  .control-panel {
    overflow: visible;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
  }

  .brand h1 {
    font-size: 20px;
  }

  .button-grid {
    grid-template-columns: 1fr 1fr;
  }

  .planet-facts {
    grid-template-columns: 1fr;
  }

  .stage-toolbar {
    top: 8px;
    left: 8px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }
}
