:root {
  --bg: #060a13;
  --panel: rgba(17, 25, 40, 0.72);
  --panel-solid: #0f1726;
  --line: rgba(148, 170, 210, 0.12);
  --line-strong: rgba(148, 170, 210, 0.22);
  --text: #e7edf7;
  --muted: #8a97ad;
  --dim: #5d6a80;
  --tn: #00a9ce;
  --ntn: #f58220;
  --ok: #34d399;
  --bad: #f87171;
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(0, 169, 206, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(245, 130, 32, 0.12), transparent 60%),
    radial-gradient(1px 1px at 12% 22%, rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(1px 1px at 32% 68%, rgba(255,255,255,0.35), transparent 60%),
    radial-gradient(1px 1px at 58% 12%, rgba(255,255,255,0.45), transparent 60%),
    radial-gradient(1px 1px at 76% 44%, rgba(255,255,255,0.30), transparent 60%),
    radial-gradient(1px 1px at 91% 82%, rgba(255,255,255,0.40), transparent 60%),
    radial-gradient(1px 1px at 44% 91%, rgba(255,255,255,0.30), transparent 60%),
    radial-gradient(1.5px 1.5px at 67% 73%, rgba(255,255,255,0.50), transparent 60%),
    radial-gradient(1.5px 1.5px at 22% 48%, rgba(255,255,255,0.40), transparent 60%),
    var(--bg);
}

a { color: inherit; text-decoration: none; }

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h2 { font-size: 15px; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(16px, 4vw, 28px);
  background: rgba(6, 10, 19, 0.78);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 30px; height: 30px; }
.logo .orbit { fill: none; stroke: var(--tn); stroke-width: 1.6; opacity: 0.7; }
.logo .planet { fill: var(--tn); }
.logo .sat { fill: var(--ntn); }
.brand-name { font-weight: 700; letter-spacing: 0.22em; font-size: 14px; }

.ghost-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.ghost-link:hover { color: var(--text); }
.ghost-link svg { width: 12px; height: 12px; }

main { max-width: 1180px; margin: 0 auto; padding: clamp(16px, 4vw, 32px); }

.eyebrow { color: var(--tn); font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, #00a9ce, #0083a8);
  color: #fff;
  font: 600 15px var(--sans);
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 169, 206, 0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}

.primary:hover { transform: translateY(-1px); box-shadow: 0 14px 36px rgba(0, 169, 206, 0.35); }
.primary svg { width: 16px; height: 16px; }

/* Landing */

.landing {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  grid-template-areas: "copy art" "features features";
  align-items: center;
  align-content: center;
  gap: 56px 48px;
  min-height: min(calc(100vh - 140px), 820px);
}

.landing-copy { grid-area: copy; display: flex; flex-direction: column; gap: 18px; }
.landing h1 { font-size: clamp(36px, 6vw, 60px); line-height: 1.05; }
.lead { color: var(--muted); font-size: clamp(16px, 2vw, 18px); max-width: 34em; }

.lookup { display: flex; gap: 10px; margin-top: 8px; max-width: 620px; }
.lookup input {
  flex: 1;
  min-width: 0;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: rgba(15, 23, 38, 0.85);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.lookup input::placeholder { color: var(--dim); }
.lookup input:focus { border-color: var(--tn); box-shadow: 0 0 0 4px rgba(0, 169, 206, 0.18); }
.lookup input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 4px rgba(248, 113, 113, 0.15); }
.lookup.busy button { opacity: 0.6; pointer-events: none; }
.lookup-error { color: var(--bad); font-size: 14px; max-width: 620px; }

.orbit-art { grid-area: art; justify-self: center; width: min(100%, 420px); }
.orbit-art svg { width: 100%; height: auto; overflow: visible; }
.orbit-art .earth { fill: #0b2a3a; stroke: rgba(0, 169, 206, 0.6); stroke-width: 1.5; }
.orbit-art .ring { fill: none; stroke: rgba(0, 169, 206, 0.45); stroke-width: 1.2; stroke-dasharray: 2 6; }
.orbit-art .ring.faint { stroke: rgba(148, 170, 210, 0.18); }
.orbit-art .satellite { fill: var(--ntn); filter: drop-shadow(0 0 8px rgba(245, 130, 32, 0.9)); }
.orbit-art .tag { fill: var(--tn); }
.orbit-art .tag-pulse { fill: none; stroke: var(--tn); stroke-width: 2; transform-origin: 226px 168px; animation: pulse 2.4s ease-out infinite; }

@keyframes pulse {
  from { transform: scale(1); opacity: 0.9; }
  to { transform: scale(5); opacity: 0; }
}

.features { grid-area: features; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.feature { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); display: grid; gap: 6px; }
.feature .dot { margin-bottom: 4px; }

/* Shared */

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--dim); }
.dot.tn { background: var(--tn); box-shadow: 0 0 8px rgba(0, 169, 206, 0.8); }
.dot.ntn { background: var(--ntn); box-shadow: 0 0 8px rgba(245, 130, 32, 0.8); }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px rgba(52, 211, 153, 0.7); }

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

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.chip.ok { color: var(--ok); border-color: rgba(52, 211, 153, 0.4); }
.chip.tn { color: #7fe3fb; border-color: rgba(0, 169, 206, 0.4); }
.chip.ntn { color: #ffb877; border-color: rgba(245, 130, 32, 0.4); }

/* Device */

#device { display: grid; gap: 16px; }

.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 14px; width: fit-content; }
.back:hover { color: var(--text); }
.back svg { width: 14px; height: 14px; }

.hero { display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.hero-main { display: flex; align-items: center; gap: 18px; min-width: 0; }
.hero-id { font-size: clamp(15px, 2.4vw, 20px); font-weight: 600; word-break: break-all; margin: 2px 0 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.status-ring {
  flex: none;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: radial-gradient(circle, rgba(148, 170, 210, 0.25) 0 6px, transparent 7px);
}

.status-ring.online { border-color: var(--ok); background: radial-gradient(circle, var(--ok) 0 7px, transparent 8px); animation: breathe 2.4s ease-in-out infinite; }
.status-ring.online.tn { border-color: var(--tn); background: radial-gradient(circle, var(--tn) 0 7px, transparent 8px); }
.status-ring.online.ntn { border-color: var(--ntn); background: radial-gradient(circle, var(--ntn) 0 7px, transparent 8px); }
.status-ring.waiting { border-style: dashed; animation: spin 8s linear infinite; }

@keyframes breathe { 50% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0.08); } }
@keyframes spin { to { transform: rotate(360deg); } }

.facts { display: grid; grid-template-columns: repeat(3, auto); gap: 8px 32px; }
.facts label { display: block; color: var(--muted); font-size: 12px; }
.facts b { font-weight: 600; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.step { position: relative; display: flex; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(6, 10, 19, 0.35); }
.step p { font-size: 13px; margin-top: 2px; }
.step .mark { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-strong); margin-top: 1px; }
.step.done .mark { border-color: var(--ok); background: var(--ok) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5' fill='none' stroke='%23060a13' stroke-width='2'/%3E%3C/svg%3E") center / 14px no-repeat; }
.step.current { border-color: rgba(0, 169, 206, 0.45); }
.step.current .mark { border-color: var(--tn); border-top-color: transparent; animation: spin 1.2s linear infinite; }
.step.failed { border-color: rgba(248, 113, 113, 0.4); }
.step.failed .mark { border-color: var(--bad); background: var(--bad) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5 5l6 6M11 5l-6 6' fill='none' stroke='%23060a13' stroke-width='2'/%3E%3C/svg%3E") center / 12px no-repeat; }
.step.pending { opacity: 0.6; }

.grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.side { display: grid; gap: 16px; }

.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

.map-wrap { position: relative; }
.map { height: 420px; border-radius: 10px; overflow: hidden; }
.map-empty { position: absolute; inset: auto 12px 12px 12px; z-index: 500; padding: 10px 12px; border-radius: 10px; background: rgba(6, 10, 19, 0.85); color: var(--muted); font-size: 13px; }
#trackNote { margin-top: 10px; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 10px; background: rgba(6, 10, 19, 0.4); }
.segmented.wide { display: flex; margin-bottom: 12px; }
.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 500 13px var(--sans);
  padding: 9px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.segmented button:hover { color: var(--text); }
.segmented button:disabled { cursor: progress; opacity: 0.6; }
.segmented button.on { background: rgba(0, 169, 206, 0.18); color: #7fe3fb; }
.segmented button.on[data-mode="ntn"] { background: rgba(245, 130, 32, 0.18); color: #ffb877; }
.mode-pending { color: var(--ntn); font-size: 13px; margin-bottom: 8px; }

.facts-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 14px; }
.facts-list dt { color: var(--muted); }
.facts-list dd { margin: 0; word-break: break-all; }

.uplinks { list-style: none; margin: 0; padding: 0; display: grid; }
.uplinks li { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); font-size: 14px; }
.uplinks li:first-child { border-top: 0; }
.uplinks .time { min-width: 6em; text-align: right; }

.missing { display: grid; gap: 18px; justify-items: start; padding-top: 10vh; max-width: 640px; }
.missing h1 { font-size: clamp(30px, 5vw, 44px); }
.missing .primary { height: 46px; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 2000; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.build { position: fixed; left: 10px; bottom: 6px; color: var(--muted); font-size: 10px; opacity: 0.5; pointer-events: none; }
.toast { padding: 12px 14px; border: 1px solid var(--line-strong); border-left: 3px solid var(--tn); border-radius: 10px; background: var(--panel-solid); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4); font-size: 14px; }
.toast.bad { border-left-color: var(--bad); }

.leaflet-container { background: #0a101b; font-family: var(--sans); }
.leaflet-bar a, .leaflet-control-layers { background: var(--panel-solid) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: rgba(6, 10, 19, 0.7) !important; color: var(--dim) !important; }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-tooltip { background: var(--panel-solid); color: var(--text); border: 1px solid var(--line-strong); border-radius: 8px; font-size: 12px; }
.trail { fill: var(--dim); }
.trail.tn { fill: var(--tn); }
.trail.ntn { fill: var(--ntn); }
.accuracy { stroke: var(--tn); fill: var(--tn); }
.accuracy.ntn { stroke: var(--ntn); fill: var(--ntn); }
.pin { position: relative; width: 22px; height: 22px; }
.pin span { position: absolute; inset: 4px; border-radius: 50%; border: 2px solid #0a101b; background: var(--tn); box-shadow: 0 0 14px rgba(0, 169, 206, 0.9); }
.pin.ntn span { background: var(--ntn); box-shadow: 0 0 14px rgba(245, 130, 32, 0.9); }
.pin::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--tn); animation: ping 2s ease-out infinite; }
.pin.ntn::after { border-color: var(--ntn); }

@keyframes ping { from { transform: scale(0.6); opacity: 0.9; } to { transform: scale(2.2); opacity: 0; } }

@media (max-width: 900px) {
  .landing { grid-template-columns: 1fr; grid-template-areas: "art" "copy" "features"; min-height: 0; gap: 20px; }
  .orbit-art { width: min(70%, 260px); }
  .features { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .map { height: 320px; }
}

@media (max-width: 560px) {
  .lookup { flex-direction: column; }
  .lookup input { flex: none; }
  .steps { grid-template-columns: 1fr; }
  .facts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; width: 100%; }
  .uplinks li { grid-template-columns: auto 1fr auto; }
  .uplinks li > span:nth-child(3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
