:root {
  --bg-deep: #050914;
  --bg-panel: rgba(12, 20, 38, 0.84);
  --bg-card: rgba(18, 29, 53, 0.72);
  --border: rgba(94, 142, 212, 0.22);
  --border-bright: rgba(56, 189, 248, 0.48);
  --text-main: #e6f0ff;
  --text-muted: #8ea4c8;
  --cyan: #38bdf8;
  --purple: #a78bfa;
  --emerald: #34d399;
  --amber: #facc15;
  --rose: #fb7185;
  --radius: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 18% 10%, #0d1d3a 0%, #050914 55%, #03050c 100%);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.45;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.04) 1px, transparent 1px);
  background-size: 36px 36px;
  z-index: 0;
}

.topbar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 12, 26, 0.82);
  backdrop-filter: blur(12px);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid var(--border-bright);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-icon svg {
  width: 30px;
  height: 30px;
}

.brand h1 {
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill-cyan {
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.38);
}

.pill-emerald {
  color: #a7f3d0;
  background: rgba(52, 211, 153, 0.13);
  border-color: rgba(52, 211, 153, 0.36);
}

.workspace {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 18px;
  padding: 18px 24px;
  max-width: 1760px;
  margin: 0 auto;
}

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.36);
}

.controls-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-self: start;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(94, 142, 212, 0.14);
}

.panel-section:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.section-header h2,
.viz-header h2 {
  font-size: 0.94rem;
  font-weight: 600;
  color: #f0f6ff;
}

.hint {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.preset-btn {
  text-align: left;
  background: var(--bg-card);
  border: 1px solid rgba(94, 142, 212, 0.2);
  border-radius: 9px;
  padding: 8px 10px;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.16s ease;
}

.preset-btn:hover {
  border-color: var(--cyan);
  background: rgba(56, 189, 248, 0.12);
}

.preset-btn.active {
  border-color: var(--cyan);
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(167, 139, 250, 0.16));
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.28);
}

.preset-btn strong {
  display: block;
  font-size: 0.79rem;
  font-weight: 600;
}

.preset-btn small {
  display: block;
  font-size: 0.69rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.preset-desc {
  font-size: 0.76rem;
  color: #b4c7e7;
  background: rgba(15, 25, 48, 0.65);
  border-left: 3px solid var(--cyan);
  padding: 7px 10px;
  border-radius: 0 8px 8px 0;
}

.segmented {
  display: inline-flex;
  background: rgba(8, 14, 28, 0.85);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.seg-btn.active {
  background: rgba(56, 189, 248, 0.22);
  color: #fff;
  font-weight: 600;
}

.input-group-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hidden {
  display: none !important;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.field label {
  font-size: 0.8rem;
  color: #cbd9f0;
}

.num-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(7, 13, 27, 0.86);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px 7px;
}

.num-wrap input {
  width: 78px;
  background: transparent;
  border: none;
  color: var(--cyan);
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-size: 0.82rem;
  text-align: right;
  outline: none;
}

.num-wrap span {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 18px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--cyan);
  height: 5px;
  cursor: pointer;
}

.btn-edge {
  margin-top: 4px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.45), rgba(76, 29, 149, 0.45));
  color: #f0f9ff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease;
}

.btn-edge:hover {
  border-color: #7dd3fc;
  transform: translateY(-1px);
}

.edge-output {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.73rem;
  color: #a7f3d0;
  background: rgba(6, 20, 28, 0.85);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
  word-break: break-all;
}

.main-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.viz-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.viz-card {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.viz-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.sim-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-small,
.select-small {
  background: rgba(15, 25, 48, 0.9);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.74rem;
  padding: 4px 9px;
  border-radius: 7px;
  cursor: pointer;
}

.btn-small.active {
  border-color: var(--cyan);
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.15);
}

.speed-label {
  font-size: 0.73rem;
  color: var(--text-muted);
}

.subsat-pill {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(167, 139, 250, 0.14);
  border: 1px solid rgba(167, 139, 250, 0.36);
  color: #ddd6fe;
}

.canvas-wrap {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(94, 142, 212, 0.2);
  background: radial-gradient(circle at center, #081229 0%, #030712 100%);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 720 / 440;
}

#orbit3dCanvas {
  cursor: grab;
}

#orbit3dCanvas:active {
  cursor: grabbing;
}

.canvas-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 7px 12px;
  background: rgba(5, 10, 22, 0.85);
  border-top: 1px solid rgba(94, 142, 212, 0.15);
  font-size: 0.73rem;
  color: var(--text-muted);
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

.dot-perigee { background: #34d399; }
.dot-apogee { background: #fb7185; }
.dot-sat { background: #facc15; box-shadow: 0 0 6px #facc15; }
.dot-eq { background: #38bdf8; }
.dot-track { background: #a78bfa; }
.dot-footprint { background: #38bdf8; }

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.kpi-label {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.kpi-value {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 1.08rem;
  color: #f8fafc;
}

.kpi-sub {
  font-size: 0.72rem;
  color: var(--cyan);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.detail-card {
  padding: 14px 16px;
}

.detail-card h3 {
  font-size: 0.88rem;
  color: #bae6fd;
  margin-bottom: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(94, 142, 212, 0.18);
}

.kv-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 0.79rem;
}

.kv-row dt {
  color: var(--text-muted);
}

.kv-row dd {
  font-family: "JetBrains Mono", Consolas, monospace;
  color: var(--text-main);
  text-align: right;
}

.footer {
  position: relative;
  z-index: 1;
  max-width: 1760px;
  margin: 4px auto 18px;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 1280px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .viz-grid {
    grid-template-columns: 1fr;
  }
  .kpi-strip {
    grid-template-columns: repeat(3, 1fr);
  }
  .details-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }
}
