/* skyblu — midnight palette, mobile first.
   Chrome stays near-monochrome; saturation is reserved for the data and for
   the one thing on screen that matters most. */

:root {
  color-scheme: dark;

  --bg:        #050816;
  --panel:     #0a1024;
  --panel-2:   #0d1630;
  --panel-3:   #111c3c;
  --line:      #263557;
  --line-soft: #18233f;

  --text:      #dce9ff;
  --text-dim:  #8fa3c8;
  --text-mute: #5b6d92;

  --cyan:      #00e5ff;
  --mint:      #62f6bf;

  /* Categorical series — validated for CVD separation and >=3:1 contrast
     against the panel surface. Order is fixed and never cycled. */
  --s1: #3987e5;  /* Open-Meteo  */
  --s2: #d95926;  /* MET Norway  */
  --s3: #199e70;  /* 7Timer!     */
  --s4: #c98500;  /* NOAA GFS    */
  --s5: #d55181;  /* DWD ICON    */

  /* Ordinal ramp for the clarity bands: one hue, monotone lightness.
     Always paired with a text label — never colour alone. */
  --b0: #184f95;
  --b1: #256abf;
  --b2: #3987e5;
  --b3: #6da7ec;
  --b4: #9ec5f4;

  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

a { color: var(--text-dim); text-decoration-color: var(--line); }
a:hover { color: var(--cyan); }

/* ---------- header ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, var(--bg) 72%, transparent);
  padding: max(10px, env(safe-area-inset-top)) 14px 8px;
  border-bottom: 1px solid var(--line-soft);
}

.brand { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.brand h1 {
  font-size: 17px; margin: 0; letter-spacing: .04em; font-weight: 650;
}
.brand .mark {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, .10);
}
.brand .tag { color: var(--text-mute); font-size: 11.5px; letter-spacing: .09em; text-transform: uppercase; }
.brand .live {
  margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-mute);
  display: inline-flex; align-items: center; gap: 6px;
}
.brand .live::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--mint); box-shadow: 0 0 6px var(--mint);
}
.brand .live.stale::before { background: var(--text-mute); box-shadow: none; }

/* location chips + view tabs share one scrollable-row treatment */
.sites, .tabs {
  display: flex; gap: 6px; margin-top: 9px;
  overflow-x: auto; scrollbar-width: none;
}
.sites::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }

.sites button, .tabs button {
  flex: 0 0 auto;
  font: inherit; font-size: 13px;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  min-height: 36px;
  transition: color .12s, border-color .12s, background .12s;
}
.sites button[aria-pressed="true"] {
  color: var(--text); border-color: var(--line); background: var(--panel-3);
}
.tabs { margin-top: 8px; }
.tabs button { border-radius: 8px; flex: 1 1 0; }
.tabs button[aria-selected="true"] {
  color: var(--bg); background: var(--cyan); border-color: var(--cyan); font-weight: 600;
}

/* ---------- layout ---------- */

main {
  max-width: 620px;
  margin: 0 auto;
  padding: 14px 14px 28px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card > h2 {
  font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-mute); margin: 0 0 10px; font-weight: 600;
}
.card > h2 .qual { text-transform: none; letter-spacing: 0; color: var(--text-mute); font-weight: 400; }

/* Two columns are kept on a phone: the camera/sensor pair only makes its point
   when both instruments are in view at once. */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 339px) { .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 400px) {
  .instr .stat .n { font-size: 21px; }
  .instr .kv { font-size: 12px; column-gap: 6px; }
}

/* ---------- hero ---------- */

.hero { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.hero .big {
  font-family: var(--mono);
  font-size: 62px; line-height: 1; font-weight: 600;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
}
.hero .unit { font-size: 20px; color: var(--text-mute); }
.hero .band { font-size: 17px; font-weight: 600; }
.hero .sub { color: var(--text-dim); font-size: 13px; width: 100%; margin-top: 2px; }

.meter {
  height: 6px; border-radius: 3px; background: var(--panel-3);
  margin: 12px 0 4px; overflow: hidden;
}
.meter > i { display: block; height: 100%; border-radius: 3px; }

/* ---------- key/value rows ---------- */

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13px; }
.kv dt { color: var(--text-mute); }
.kv dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

.stat { display: flex; flex-direction: column; gap: 1px; }
.stat .n {
  font-family: var(--mono); font-size: 25px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.stat .l { font-size: 11px; color: var(--text-mute); letter-spacing: .06em; text-transform: uppercase; }
.stat .x { font-size: 12px; color: var(--text-dim); }

/* ---------- instrument cards ---------- */

.instr { background: var(--panel-2); border: 1px solid var(--line-soft); border-radius: 8px; padding: 11px; }
.instr h3 {
  margin: 0 0 8px; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-mute); font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.instr h3 .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-mute); }
.instr h3 .dot.on { background: var(--mint); }

.raw {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  color: var(--text-dim); background: var(--bg);
  border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 8px 9px; margin-top: 9px;
  overflow-x: auto; white-space: pre; -webkit-overflow-scrolling: touch;
}
.raw b { color: var(--cyan); font-weight: 600; }

/* satellite tile with site markers */
.tile { position: relative; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.tile img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.tile .pin {
  position: absolute; width: 13px; height: 13px; margin: -7px 0 0 -7px;
  border: 2px solid var(--cyan); border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(5, 8, 22, .85), 0 0 8px rgba(0, 229, 255, .6);
}
.tile .pin.self { background: rgba(0, 229, 255, .3); }
/* figcaption is a sibling of .tile inside the figure, not a descendant. */
figure > figcaption {
  font-size: 11.5px; color: var(--text-mute); padding: 8px 2px 0; line-height: 1.5;
}
figure > figcaption b { color: var(--text-dim); font-weight: 600; }

/* ---------- charts ---------- */

figure { margin: 0; }
.chart { width: 100%; display: block; touch-action: pan-y; overflow: visible; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis { fill: var(--text-mute); font-size: 10px; font-family: var(--mono); }
.chart .band-fill { fill: var(--s1); opacity: .19; }
.chart .series { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .dot { stroke: var(--panel); stroke-width: 2; }
.chart .cursor { stroke: var(--cyan); stroke-width: 1; stroke-dasharray: 3 3; opacity: .8; }
.chart .lbl { fill: var(--text-dim); font-size: 10.5px; font-family: var(--mono); }
.chart .nightband { fill: #0f1830; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 10px; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); }
.legend i { width: 11px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.legend .off { opacity: .4; text-decoration: line-through; }

/* atmospheric cross-section heatmap */
.decks { display: grid; gap: 2px; margin-top: 4px; }
.deckrow { display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 6px; }
.deckrow .name { font-size: 10.5px; color: var(--text-mute); font-family: var(--mono); text-align: right; }
.deckrow .cells { display: grid; gap: 2px; }
.deckcell {
  height: 26px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px; font-variant-numeric: tabular-nums;
}

/* ---------- tables ---------- */

.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left; font-weight: 600; font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-mute);
  padding: 0 8px 7px 0; border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
.tbl td {
  padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text-dim);
}
.tbl td:first-child { color: var(--text); font-family: var(--sans); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -2px; }

/* ---------- misc ---------- */

.pill {
  display: inline-block; font-size: 10.5px; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--text-mute); font-family: var(--mono);
  white-space: nowrap;
}
.pill.warn { border-color: #6b4a1e; color: #c98500; }
.pill.bad  { border-color: #6b2b2b; color: #d55181; }
.pill.ok   { border-color: #1f4a44; color: var(--mint); }

.note { font-size: 12px; color: var(--text-mute); line-height: 1.55; margin: 9px 0 0; }
.note code { font-family: var(--mono); font-size: 11.5px; color: var(--text-dim); }

.formula {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-dim);
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 6px;
  padding: 8px 9px; margin-top: 8px; overflow-x: auto; white-space: nowrap;
}
.formula b { color: var(--text); font-weight: 600; }

details { margin-top: 10px; }
details > summary {
  cursor: pointer; font-size: 12px; color: var(--text-mute);
  list-style: none; padding: 6px 0; user-select: none; min-height: 32px;
  display: flex; align-items: center; gap: 6px;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; color: var(--line); font-size: 10px; }
details[open] > summary::before { content: "▾"; }

.loading { color: var(--text-mute); font-size: 13px; padding: 40px 0; text-align: center; }
.spin {
  display: inline-block; width: 11px; height: 11px; vertical-align: -1px;
  border: 2px solid var(--line); border-top-color: var(--cyan); border-radius: 50%;
  animation: spin .8s linear infinite; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }

.err {
  border: 1px solid #6b2b2b; background: #1a0f14; color: #f0b4b4;
  border-radius: 8px; padding: 10px 12px; font-size: 13px; margin-bottom: 12px;
}

.foot {
  max-width: 620px; margin: 0 auto; padding: 4px 14px max(22px, env(safe-area-inset-bottom));
  font-size: 11.5px; color: var(--text-mute); line-height: 1.6;
}
.foot p { margin: 0 0 6px; }
.foot b { color: var(--text-dim); font-weight: 600; }
.foot .dim { color: var(--line); }
.foot .dim a { color: var(--text-mute); }

/* Tooltip shared by all charts */
.tip {
  position: fixed; z-index: 40; pointer-events: none;
  background: var(--panel-3); border: 1px solid var(--line);
  border-radius: 7px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .55);
  min-width: 132px; opacity: 0; transition: opacity .1s;
}
.tip.on { opacity: 1; }
.tip .t { font-family: var(--mono); font-size: 11px; color: var(--text-mute); margin-bottom: 5px; }
.tip .r { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tip .r span { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); }
.tip .r i { width: 9px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.tip .r b { font-family: var(--mono); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
