:root {
  --bg-1: #070b1a;
  --bg-2: #0f1838;
  --bg-3: #1b1446;
  --card: rgba(16, 24, 52, .55);
  --card-border: rgba(148, 178, 255, .16);
  --text: #eef3ff;
  --muted: #8d9ac2;
  --accent: #67e8f9;
  --accent-2: #a78bfa;
  --ring: rgba(103, 232, 249, .18);
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --star: #ffffff;
  --shadow: 0 30px 80px -20px rgba(0, 0, 0, .65);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-1: #dbe7ff;
    --bg-2: #eef3ff;
    --bg-3: #e7ddff;
    --card: rgba(255, 255, 255, .6);
    --card-border: rgba(60, 80, 160, .14);
    --text: #0d1530;
    --muted: #5b6690;
    --accent: #0891b2;
    --accent-2: #7c3aed;
    --ring: rgba(8, 145, 178, .2);
    --star: #6b7bb8;
    --shadow: 0 30px 70px -25px rgba(40, 60, 140, .35);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

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

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(120% 90% at 20% 0%, var(--bg-3) 0%, var(--bg-2) 45%, var(--bg-1) 100%) fixed;
  background-color: var(--bg-1);
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Sky background ---------- */
.sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }

.aurora {
  position: absolute; inset: -30%;
  background:
    radial-gradient(40% 30% at 30% 30%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    radial-gradient(35% 30% at 70% 60%, color-mix(in srgb, var(--accent-2) 22%, transparent), transparent 70%);
  filter: blur(40px);
  animation: aurora 28s ease-in-out infinite alternate;
}
@keyframes aurora {
  0%   { transform: translate(-4%, -2%) rotate(0deg) scale(1); }
  100% { transform: translate(4%, 3%) rotate(12deg) scale(1.1); }
}

.stars { position: absolute; top: 0; left: 0; width: 1px; height: 1px; border-radius: 50%; background: transparent; }
.stars-1 { animation: drift 180s linear infinite, twinkle 6s ease-in-out infinite; }
.stars-2 { width: 2px; height: 2px; animation: drift 260s linear infinite, twinkle 9s ease-in-out infinite reverse; }
@keyframes drift { from { transform: translateY(0); } to { transform: translateY(-100vh); } }
@keyframes twinkle { 0%, 100% { opacity: .9; } 50% { opacity: .45; } }

/* ---------- Card ---------- */
.card {
  position: relative; z-index: 1;
  width: min(400px, 100%);
  padding: 22px 22px 16px;
  border-radius: 28px;
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, .08);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  animation: card-in .9s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }

.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.eyebrow {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  white-space: nowrap;
}
.home-label { font: 500 11px/1 "JetBrains Mono", ui-monospace, monospace; color: var(--muted); white-space: nowrap; }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); position: relative; flex: none; }
.live-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: inherit;
  animation: ping 2s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping { 75%, 100% { transform: scale(2.6); opacity: 0; } }
.card[data-state="live"] .live-dot { background: var(--ok); }
.card[data-state="stale"] .live-dot,
.card[data-state="empty"] .live-dot { background: var(--warn); }
.card[data-state="error"] .live-dot { background: var(--err); }

/* ---------- Radar ---------- */
.radar {
  position: relative;
  aspect-ratio: 1;
  border-radius: 50%;
  margin: 0 auto 18px;
  width: 100%;
  max-width: 300px;
  background: radial-gradient(circle, color-mix(in srgb, var(--accent) 8%, transparent) 0%, transparent 70%);
  box-shadow: inset 0 0 0 1px var(--ring), 0 0 60px -20px color-mix(in srgb, var(--accent) 50%, transparent);
  overflow: hidden;
}
.radar-sweep {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg, transparent 300deg, color-mix(in srgb, var(--accent) 35%, transparent) 358deg, transparent 360deg);
  animation: sweep 4s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }

.radar-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.rings circle, .rings line { fill: none; stroke: var(--ring); stroke-width: .6; }
.rings line { stroke-dasharray: 2 3; }
.ring-labels text { text-anchor: end; fill: var(--muted); font: 500 6px "JetBrains Mono", monospace; opacity: .8; }
.compass text { fill: var(--muted); font: 700 7px "Inter", sans-serif; text-anchor: middle; dominant-baseline: middle; opacity: .7; }

.home-dot { fill: var(--accent-2); }

.target { transition: opacity .6s ease; }
.target path { fill: var(--accent); filter: drop-shadow(0 0 3px var(--accent)); }
.link-line { stroke: var(--accent); stroke-width: .6; stroke-dasharray: 2 2; opacity: .55; animation: dash 1.2s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -8; } }

.other { fill: var(--muted); opacity: .55; transition: opacity .6s; }

/* ---------- Info ---------- */
.info { transition: opacity .35s ease, transform .35s ease, filter .35s ease; }
.info.swap-out { opacity: 0; transform: translateY(-8px); filter: blur(4px); }

.ident { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.callsign {
  margin: 0;
  font: 700 clamp(28px, 9vw, 38px)/1.05 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: .02em;
  background: linear-gradient(90deg, var(--text), var(--accent) 60%, var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  overflow-wrap: anywhere;
}
.route {
  font: 600 13px/1 "JetBrains Mono", monospace;
  padding: 6px 10px; border-radius: 999px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
}
.subline { margin-top: 6px; color: var(--muted); font-size: 14px; min-height: 1.3em; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 0; }
.stat {
  padding: 12px 14px; border-radius: 16px;
  background: color-mix(in srgb, var(--text) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--text) 7%, transparent);
}
.stat-wide { grid-column: 1 / -1; display: flex; align-items: baseline; justify-content: space-between; }
.stat dt { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.stat-wide dt { margin: 0; }
.stat dd { margin: 0; display: flex; align-items: baseline; gap: 4px; }
.num { font: 700 22px/1.1 "JetBrains Mono", monospace; font-variant-numeric: tabular-nums; }
.stat-wide .num { font-size: 30px; color: var(--accent); }
.unit { font-size: 12px; color: var(--muted); font-weight: 500; }
.trend { font-size: 14px; margin-left: 2px; }
.trend.up { color: var(--ok); }
.trend.down { color: var(--warn); }
.heading-arrow { display: inline-block; color: var(--accent); font-weight: 700; transition: transform .8s cubic-bezier(.2, .8, .2, 1); }

.card-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--text) 8%, transparent);
  font-size: 12px; color: var(--muted);
}
.card-foot a { color: var(--accent); text-decoration: none; font-weight: 600; white-space: nowrap; }
.card-foot a:hover { text-decoration: underline; }

.card[data-state="loading"] .num,
.card[data-state="loading"] .callsign { animation: shimmer 1.6s ease-in-out infinite; }
@keyframes shimmer { 50% { opacity: .4; } }

@media (max-width: 360px) {
  .eyebrow { letter-spacing: .08em; font-size: 11px; }
  .home-label { font-size: 10px; }
  .card { padding: 18px 16px 14px; border-radius: 22px; }
  .num { font-size: 19px; }
  .stat-wide .num { font-size: 26px; }
}

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