:root {
  color-scheme: dark;
  --bg: #02050b;
  --panel: rgba(4, 9, 17, .72);
  --line: rgba(192, 220, 244, .18);
  --line-strong: rgba(213, 234, 251, .42);
  --text: #e9f1f7;
  --muted: #8191a1;
  --dim: #4d5d6c;
  --glow: #dff4ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body {
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: "SFMono-Regular", "Roboto Mono", "Noto Sans Mono", ui-monospace, monospace;
  background:
    radial-gradient(circle at 50% 42%, rgba(23, 45, 67, .15), transparent 34rem),
    linear-gradient(180deg, #030812 0%, #02050b 62%, #010307 100%);
}
button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 1px solid var(--glow); outline-offset: 4px; }

.observatory {
  width: min(1440px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 24px clamp(18px, 3vw, 48px) 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  grid-template-rows: auto minmax(560px, 1fr) auto;
  gap: 18px 26px;
}

.masthead {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}
.series, .subtitle, .readout-kicker, .satellite-id, .category-readout, .footer p { margin: 0; }
.series { color: var(--muted); font-size: 10px; letter-spacing: .18em; }
h1 { margin: 5px 0 6px; font-size: clamp(24px, 3vw, 42px); font-weight: 520; letter-spacing: -.04em; }
.subtitle { color: var(--muted); font-size: 11px; line-height: 1.6; }
.header-tools { display: flex; align-items: center; gap: 18px; padding-top: 3px; }
.language-switch, .live-status { display: flex; align-items: center; gap: 7px; font-size: 10px; letter-spacing: .12em; }
.language-switch span { color: var(--dim); }
.language-button, .mode-button, .filter-button, .clear-button {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.language-button { color: var(--dim); }
.language-button.is-active { color: var(--text); }
.live-status { color: var(--muted); white-space: nowrap; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #5e6b75; box-shadow: 0 0 0 rgba(223,244,255,0); transition: .25s ease; }
.live-status.is-live .live-dot { background: #dff4ff; box-shadow: 0 0 12px rgba(223,244,255,.8); }
.live-status.is-error .live-dot { background: #9b6c6c; }

.stage {
  position: relative;
  min-width: 0;
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 50%, rgba(30, 56, 80, .14), transparent 45%),
    rgba(1, 4, 9, .6);
}
.stage::before, .stage::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 2;
}
.stage::before { inset: 50% 0 auto; border-top: 1px solid rgba(192,220,244,.045); }
.stage::after { inset: 0 auto 0 50%; border-left: 1px solid rgba(192,220,244,.045); }
#globe { display: block; width: 100%; height: 100%; min-height: 560px; touch-action: none; cursor: grab; }
#globe.is-dragging { cursor: grabbing; }
.reticle { position: absolute; inset: 18px; pointer-events: none; z-index: 3; }
.reticle span { position: absolute; width: 14px; height: 14px; border-color: var(--line-strong); }
.reticle span:nth-child(1) { left: 0; top: 0; border-left: 1px solid; border-top: 1px solid; }
.reticle span:nth-child(2) { right: 0; top: 0; border-right: 1px solid; border-top: 1px solid; }
.reticle span:nth-child(3) { right: 0; bottom: 0; border-right: 1px solid; border-bottom: 1px solid; }
.reticle span:nth-child(4) { left: 0; bottom: 0; border-left: 1px solid; border-bottom: 1px solid; }

.loading {
  position: absolute; inset: 0; z-index: 6;
  display: grid; place-content: center; justify-items: center; gap: 16px;
  background: rgba(2,5,11,.82);
  color: var(--muted); font-size: 10px; letter-spacing: .16em;
  transition: opacity .35s ease, visibility .35s ease;
}
.loading.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-orbit { width: 56px; height: 56px; border: 1px solid rgba(213,234,251,.22); border-radius: 50%; position: relative; animation: spin 2.4s linear infinite; }
.loading-orbit::after { content:""; position:absolute; inset:11px; border:1px solid rgba(213,234,251,.08); border-radius:50%; }
.loading-orbit i { position:absolute; width:5px; height:5px; border-radius:50%; background:var(--glow); left:50%; top:-3px; box-shadow:0 0 13px rgba(223,244,255,.8); }
@keyframes spin { to { transform: rotate(360deg); } }

.view-controls {
  position: absolute; left: 28px; top: 24px; z-index: 5;
  display: flex; gap: 14px; font-size: 10px; letter-spacing: .13em;
}
.mode-button { color: var(--dim); padding-bottom: 5px; border-bottom: 1px solid transparent; }
.mode-button.is-active { color: var(--text); border-bottom-color: var(--line-strong); }
.mode-button:disabled { opacity: .35; cursor: default; }
.filters {
  position: absolute; z-index: 5; left: 28px; right: 28px; bottom: 24px;
  display: flex; flex-wrap: wrap; gap: 8px;
}
.filter-button {
  border: 1px solid rgba(192,220,244,.08);
  background: rgba(2,5,11,.4);
  padding: 7px 9px;
  color: var(--dim);
  font-size: 9px;
  letter-spacing: .11em;
  opacity: .35;
  cursor: default;
  transition: color .2s ease, border-color .2s ease, background .2s ease, opacity .2s ease;
}
.filter-button.is-available {
  border-color: var(--line);
  background: rgba(2,5,11,.64);
  color: var(--muted);
  opacity: 1;
  cursor: pointer;
}
.filter-button.is-active { border-color: var(--line-strong); color: var(--text); background: rgba(210,234,251,.07); }
.filter-button:disabled { pointer-events: none; }
.stage-hint {
  position: absolute; z-index: 5; right: 28px; top: 24px; margin: 0;
  color: var(--muted); font-size: 9px; letter-spacing: .05em; max-width: 280px; text-align: right;
}

.readout {
  align-self: stretch;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
  min-width: 0;
}
.readout-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.readout-kicker { color: var(--muted); font-size: 9px; letter-spacing: .14em; }
.clear-button { font-size: 18px; color: var(--muted); line-height: 1; }
#satellite-name { display: block; margin: 24px 0 5px; font-size: clamp(17px, 2vw, 24px); line-height: 1.15; font-weight: 520; overflow-wrap: anywhere; }
.satellite-id { color: var(--dim); font-size: 9px; letter-spacing: .1em; }
.readout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 12px; margin-top: 34px; }
.readout-grid span { display:block; color: var(--dim); font-size: 8px; letter-spacing:.12em; margin-bottom:5px; }
.readout-grid b { font-size: 12px; font-weight: 450; color: var(--text); }
.category-readout { margin-top: 32px; color: var(--muted); font-size: 9px; letter-spacing:.1em; }

.footer {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 18px;
  border-top: 1px solid var(--line); padding-top: 13px;
  color: var(--dim); font-size: 9px; line-height: 1.5;
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--text); }
.back-link { white-space: nowrap; }

@media (max-width: 900px) {
  .observatory { grid-template-columns: 1fr; grid-template-rows: auto minmax(520px, 68dvh) auto auto; }
  .readout { display: grid; grid-template-columns: minmax(0, 1fr) 1fr; gap: 14px 20px; }
  .readout-heading { grid-column: 1 / -1; }
  #satellite-name { margin-top: 8px; }
  .readout-grid { margin-top: 8px; }
  .category-readout { margin-top: 10px; }
  .footer { grid-template-columns: 1fr auto; }
  .footer p:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 620px) {
  .observatory { padding: 16px 12px 14px; gap: 12px; grid-template-rows: auto minmax(500px, 70dvh) auto auto; }
  .masthead { gap: 12px; }
  .subtitle { max-width: 210px; }
  .header-tools { flex-direction: column; align-items: flex-end; gap: 9px; }
  .stage, #globe { min-height: 500px; }
  .view-controls { left: 18px; top: 18px; }
  .stage-hint { top: 52px; right: 18px; max-width: 220px; }
  .filters { left: 18px; right: 18px; bottom: 18px; gap: 6px; }
  .filter-button { padding: 7px 7px; font-size: 8px; }
  .reticle { inset: 12px; }
  .readout { grid-template-columns: 1fr; }
  .readout-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; overflow-x: auto; }
  .readout-grid b { font-size: 10px; }
  .footer { grid-template-columns: 1fr auto; }
}

@media (prefers-reduced-motion: reduce) {
  .loading-orbit { animation: none; }
}