:root {
  --bg: #04060d;
  --bg-2: #080c18;
  --panel: #0a0f1d;
  --card: #0f1627;
  --card-2: #141d33;
  --line: #1d2842;
  --text: #e6ecff;
  --muted: #8d9ac0;
  --dim: #5b678c;
  --accent: #7cf5c4;      /* aurora green */
  --quake: #ffb347;
  --quake-hot: #ff5a3c;
  --storm: #5ad1ff;
  --fire: #ff7a2f;
  --volcano: #ff3b3b;
  --ice: #cfe9ff;
  --sun: #ffd36b;
  --violet: #b58cff;
  --radius: 14px;
  --font: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }

/* ---------------- layout ---------------- */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  height: 100vh;
  overflow: hidden;
}
.stage {
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 55%, #0b1430 0%, var(--bg) 70%);
  touch-action: none;
  user-select: none;
}
#globe { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; display: block; }
#earth, #aurora { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
#aurora { filter: blur(3px) saturate(1.5); mix-blend-mode: screen; }
.stage:not(.gl) #earth, .stage:not(.gl) #aurora { display: none; }
#globe.dragging { cursor: grabbing; }
#globe.pointing { cursor: pointer; }

.panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 16px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

/* ---------------- stage overlays ---------------- */
.brand { position: absolute; top: 18px; left: 20px; pointer-events: none; }
.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: 0.22em; font-size: 15px;
}
.heartbeat {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(124, 245, 196, 0.6);
  animation: beat 2.4s infinite;
}
.heartbeat.stale { background: var(--quake); }
@keyframes beat {
  0% { box-shadow: 0 0 0 0 rgba(124, 245, 196, 0.55); }
  70% { box-shadow: 0 0 0 12px rgba(124, 245, 196, 0); }
  100% { box-shadow: 0 0 0 0 rgba(124, 245, 196, 0); }
}
.clock { margin-top: 6px; color: var(--muted); font-size: 13px; }
.clock .sep { margin: 0 6px; color: var(--dim); }
.clock .mono { color: var(--text); }

.views {
  position: absolute; top: 16px; right: 16px;
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end;
}
.views button, .legend button, .cat-tabs button, .menu button {
  background: rgba(15, 22, 39, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s, opacity .15s;
}
.views button, .legend button { backdrop-filter: blur(6px); }
.views { align-items: flex-start; }
.view-layers { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.menu-wrap { position: relative; }
.menu-btn .caret { color: var(--muted); font-size: 10px; margin-left: 2px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 7;
  display: flex; flex-direction: column; gap: 2px; min-width: 132px; padding: 5px;
  background: rgba(10, 15, 29, 0.94); border: 1px solid var(--line); border-radius: 12px;
  backdrop-filter: blur(8px); box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.menu button { border: 0; border-radius: 8px; text-align: left; padding: 7px 10px; background: transparent; }
.menu button:hover { background: var(--card-2); }
.cat-tabs button { background: var(--card-2); }
.views button:hover, .legend button:hover, .cat-tabs button:hover, .menu button:hover { border-color: #33426a; }
.views button.on { border-color: var(--accent); color: var(--accent); }

.legend {
  position: absolute; left: 16px; bottom: 70px;
  max-width: calc(100% - 32px); overflow-x: auto; scrollbar-width: none;
}
/* Chips sit side by side at their natural widths; app.js sets this row's width so they wrap into
   exactly two balanced lines. If that is wider than the screen, both lines scroll together. */
.legend-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.legend::-webkit-scrollbar { display: none; }
.legend.scrolls { -webkit-mask-image: linear-gradient(to right, #000 88%, transparent); mask-image: linear-gradient(to right, #000 88%, transparent); }
.legend button, .layer-chip { display: inline-flex; align-items: center; gap: 7px; }
.layer-chip .sw { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.layer-chip .ct { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.layer-chip.off { opacity: 0.4; }
.layer-chip.off .sw { box-shadow: none; }

.boot {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); letter-spacing: .12em; font-size: 13px; pointer-events: none;
}
.boot.gone { display: none; }
.boot.error { color: var(--quake-hot); padding: 24px; text-align: center; }

.tooltip {
  position: absolute; z-index: 5;
  min-width: 180px; max-width: 290px;
  background: rgba(10, 15, 29, 0.94);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
}
.tooltip.sticky { pointer-events: auto; border-color: #33426a; }
.tooltip .t-title { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; }
.tooltip .t-kind { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--c, var(--muted)); margin-bottom: 2px; }
.tooltip .t-meta { color: var(--muted); }
.tooltip a { display: inline-block; margin-top: 6px; }

.toasts {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  pointer-events: none; z-index: 6;
}
.toast {
  background: rgba(15, 22, 39, 0.92);
  border: 1px solid var(--quake);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12.5px;
  animation: toast-in .35s ease-out, toast-out .5s ease-in 7.5s forwards;
  box-shadow: 0 0 24px rgba(255, 179, 71, 0.25);
}
.toast b { color: var(--quake); font-family: var(--mono); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

/* time scrubber */
.timebar {
  position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 4;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 6px;
  background: rgba(10, 15, 29, 0.74); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(8px);
}
.tl-btn {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; letter-spacing: -1px;
  background: var(--card-2); border: 1px solid var(--line); cursor: pointer;
}
.tl-btn:hover { border-color: var(--accent); color: var(--accent); }
.tl-range { display: flex; flex-shrink: 0; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.tl-range button { background: transparent; border: 0; padding: 5px 9px; font-size: 11.5px; cursor: pointer; color: var(--muted); }
.tl-range button.on { background: var(--card-2); color: var(--text); }
.tl-track { position: relative; flex: 1; min-width: 120px; height: 32px; }
#tl-hist { position: absolute; left: 0; right: 0; top: 2px; width: 100%; height: 24px; pointer-events: none; }
#tl-slider {
  --p: 100%;
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background:
    linear-gradient(rgba(230, 236, 255, 0.45), rgba(230, 236, 255, 0.45)) 0 calc(100% - 3px) / var(--p) 1px no-repeat,
    linear-gradient(#232d49, #232d49) 0 calc(100% - 3px) / 100% 1px no-repeat;
}
#tl-slider::-webkit-slider-runnable-track { height: 32px; background: transparent; }
#tl-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 2px; height: 32px; border-radius: 1px; background: #fff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
}
#tl-slider::-moz-range-track { height: 32px; background: transparent; }
#tl-slider::-moz-range-thumb { width: 2px; height: 32px; border: 0; border-radius: 1px; background: #fff; box-shadow: 0 0 6px rgba(255, 255, 255, 0.35); }
#tl-slider:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.tl-label { flex-shrink: 0; min-width: 196px; text-align: right; font-size: 12px; white-space: nowrap; }
.tl-when { color: var(--text); font-weight: 600; }
.tl-sub { color: var(--dim); margin-left: 4px; }
.tl-live {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; font-size: 11.5px; cursor: pointer; color: var(--muted);
}
.tl-live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.tl-live.on { color: var(--accent); border-color: rgba(124, 245, 196, 0.5); }
.tl-live.on .dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: beat 2.4s infinite; }
.stage.replay .timebar { border-color: rgba(230, 236, 255, 0.22); }
.tl-guide { position: absolute; top: 0; bottom: 4px; width: 1px; background: rgba(230, 236, 255, 0.45); pointer-events: none; }
.tl-tip {
  position: absolute; bottom: calc(100% + 8px); z-index: 6; width: 300px; max-width: calc(100% - 8px);
  padding: 8px 11px; border-radius: 10px; font-size: 12px;
  background: rgba(10, 15, 29, 0.96); border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); pointer-events: none;
}
.tt-when { font-weight: 600; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; white-space: nowrap; }
.tt-back { color: var(--dim); font-weight: 400; font-family: var(--mono); font-size: 11px; }
.tt-row { display: flex; align-items: center; gap: 8px; color: var(--muted); margin-top: 2px; }
.tt-bar { width: 1px; height: 11px; background: rgba(141, 154, 192, 0.7); flex-shrink: 0; margin: 0 4.5px; }
.tt-bar.big { background: #fff; }
.tt-line { width: 10px; height: 1px; background: rgba(230, 236, 255, 0.45); flex-shrink: 0; }
.tt-hint { color: var(--dim); font-size: 11px; margin-top: 6px; padding-top: 5px; border-top: 1px solid var(--line); line-height: 1.35; }
.stage.replay .layer-chip.live-only { opacity: 0.22; }

/* ---------------- panel ---------------- */
.vitals { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.vital {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 13px;
}
.v-label { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.v-num { font-size: 26px; font-weight: 600; margin-top: 2px; line-height: 1.15; }
.v-sub { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
}
.card h2 {
  margin: 0 0 10px;
  font-size: 12px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
.h-note { font-size: 11px; letter-spacing: .02em; text-transform: none; color: var(--dim); font-weight: 400; text-align: right; }

/* weekly */
#weekly { background: linear-gradient(160deg, #132041 0%, var(--card) 60%); }
.since { margin: -4px 0 10px; color: var(--muted); font-size: 12.5px; }
.since:empty { display: none; }
.record {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.record[role="button"] { cursor: pointer; }
.record[role="button"]:hover .rec-v { color: #fff; }
.rec-k { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.rec-v { display: flex; align-items: baseline; gap: 10px; margin-top: 2px; }
.rec-big { font-size: 24px; font-weight: 600; flex-shrink: 0; }
#rq-mag { color: var(--quake); }
#ra-kp { color: var(--accent); }
#rn-pct { color: var(--violet); }
.rec-meta { color: var(--dim); font-size: 12px; margin-top: 2px; }

/* dial */
.dial-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; }
#dial { width: 150px; height: 150px; }
.dial-facts { font-size: 12.5px; color: var(--muted); display: grid; gap: 5px; }
.dial-facts b { color: var(--text); font-weight: 500; font-family: var(--mono); }
.dial-facts .big { font-size: 20px; color: var(--text); font-family: var(--mono); }
.city-grid {
  margin-top: 12px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4px 12px;
  font-size: 12.5px;
}
.city { display: flex; justify-content: space-between; gap: 8px; cursor: pointer; padding: 2px 0; }
.city:hover .c-name { color: #fff; }
.c-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-time { font-family: var(--mono); color: var(--text); font-size: 12px; }
.aurora-watch { margin: 10px 0 0; font-size: 12.5px; color: var(--muted); }
.aurora-watch b { color: var(--accent); font-weight: 500; }

/* pinned place */
.pin-bar { display: flex; align-items: center; gap: 10px; margin: -2px 0 12px; flex-wrap: wrap; }
.mini-btn {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; font-size: 12px; cursor: pointer; color: var(--text);
}
.mini-btn:hover { border-color: var(--accent); }
.mini-btn:disabled { opacity: 0.6; cursor: progress; }
.pin-hint { font-size: 12px; color: var(--dim); }
.replay-note { color: var(--accent); font-size: 11.5px; }
.pin-rows { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--line); }
.pin-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 4px; border-radius: 8px; }
.pin-row.link { cursor: pointer; }
.pin-row.link:hover, .pin-row.link:focus-visible { background: var(--card-2); outline: none; }
.pin-ico {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-size: 13px; font-family: var(--mono); font-weight: 600; color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
}
.pin-v { font-weight: 500; }
.pin-m { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-aside { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.pin-aurora {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--card-2); border: 1px solid var(--line); border-left: 3px solid var(--c, var(--dim));
}
.pin-aurora:empty { display: none; }
.pa-k { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.pa-h { font-weight: 600; font-size: 14px; color: var(--c, var(--text)); margin-top: 2px; }
.pa-w { font-size: 12px; color: var(--dim); margin-top: 3px; }

/* weather extremes & air */
.wx-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.wx-tile {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; cursor: pointer; position: relative; overflow: hidden;
}
.wx-tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--c); opacity: .8; }
.wx-tile:hover { border-color: #33426a; }
.wx-tile.empty-tile { cursor: default; }
.wx-k { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.wx-v { font-size: 20px; font-weight: 600; color: var(--c, var(--text)); margin-top: 1px; }
.wx-p { font-size: 11.5px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card h3.sub {
  margin: 14px 0 6px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
#aq-list { max-height: none; }
.list li.aq-sep { display: block; cursor: default; padding: 8px 4px 2px; }
.list li.aq-sep:hover { background: none; }

/* alerts */
.alert-sum { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: baseline; margin-bottom: 8px; font-size: 12px; color: var(--muted); }
.alert-sum .lvl { display: inline-flex; align-items: center; gap: 5px; }
.alert-sum .lvl::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.alert-sum .lvl b { color: var(--text); font-weight: 600; }
.alert-sum .lvl-note { margin-left: auto; color: var(--dim); font-size: 11.5px; }
.tooltip .t-alert { display: flex; align-items: center; gap: 6px; margin-top: 5px; color: var(--c); font-size: 12px; font-weight: 500; }
.tooltip .t-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); box-shadow: 0 0 6px var(--c); flex-shrink: 0; }
.tooltip .t-sev { color: var(--muted); font-weight: 400; }

/* kp */
.kp-head { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.kp-big {
  font-size: 40px; font-weight: 600; line-height: 1;
  min-width: 70px; color: var(--accent);
  text-shadow: 0 0 24px rgba(124, 245, 196, .35);
}
.kp-level { font-weight: 600; }
.kp-desc { font-size: 12px; color: var(--dim); }
#kp-chart { width: 100%; height: auto; display: block; }
#kp-chart text { font-family: var(--mono); font-size: 9px; fill: var(--dim); }
.oval-stats { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 6px; flex-wrap: wrap; }
.oval-stats b { color: var(--text); font-family: var(--mono); font-weight: 500; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.list li {
  display: grid; grid-template-columns: 46px 1fr auto; gap: 10px; align-items: center;
  padding: 7px 4px; border-top: 1px solid var(--line); cursor: pointer; border-radius: 6px;
}
.list li:first-child { border-top: 0; }
.list li:hover { background: var(--card-2); }
.badge {
  font-family: var(--mono); font-weight: 600; font-size: 12.5px; text-align: center;
  border-radius: 7px; padding: 3px 0; color: #0a0f1d; background: var(--c);
}
.badge.glyph { background: transparent; color: var(--c); border: 1px solid var(--c); font-size: 13px; }
.li-main { min-width: 0; }
.li-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-meta { font-size: 11.5px; color: var(--dim); }
.li-time { font-size: 11.5px; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
.empty { color: var(--dim); font-size: 12.5px; padding: 8px 0; cursor: default !important; display: block !important; }

.cat-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cat-tabs button { padding: 4px 10px; font-size: 11.5px; }
.cat-tabs button.on { border-color: var(--c, var(--accent)); color: var(--c, var(--accent)); }

/* feeds */
.feeds { font-size: 11.5px; color: var(--dim); padding: 0 4px; }
#feed-status { display: grid; gap: 3px; }
.feed { display: flex; align-items: center; gap: 8px; }
.feed .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex-shrink: 0; }
.feed.ok .dot { background: var(--accent); }
.feed.err .dot { background: var(--quake-hot); }
.feed.loading .dot { background: var(--quake); }
.feed .f-name { color: var(--muted); }
.feed .f-when { margin-left: auto; font-family: var(--mono); }
.credits { margin: 10px 0 0; }

/* ---------------- responsive ---------------- */
@media (min-width: 901px) and (max-width: 1240px) {
  /* narrower laptops: slightly tighter chips so both rows still fit beside the side panel */
  .legend-chips { gap: 5px; }
  .legend button { padding: 5px 9px; font-size: 11.5px; gap: 6px; }
  .legend .layer-chip .sw { width: 8px; height: 8px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; height: auto; overflow: visible; }
  .panel > * { min-width: 0; }
  .stage { height: 72vh; min-height: 420px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  .legend { bottom: 112px; left: 10px; right: 10px; max-width: none; }
  .legend-chips { gap: 5px; }
  .legend button { padding: 5px 10px; }
  .timebar { left: 10px; right: 10px; bottom: 10px; flex-wrap: wrap; row-gap: 4px; }
  .tl-track { order: 5; flex-basis: 100%; }
  .tl-label { min-width: 0; flex: 1; }
  .views { top: auto; bottom: auto; top: 74px; left: 16px; right: 16px; justify-content: flex-start; }
}
@media (max-width: 420px) {
  .dial-wrap { grid-template-columns: 1fr; justify-items: center; }
  .views button, .legend button { padding: 5px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  .heartbeat { animation: none; }
  .toast { animation: none; }
}
