/* ==========================================================================
   pool.biswas.me — glass design system

   Dark-first by deliberate choice: the palette, the chart series steps and the
   contrast checks are all selected against the dark surface below, not flipped
   from a light theme. Chart series colours are the validated categorical order
   (adjacent CVD dE 8.4, normal-vision 19.3, all >= 3:1 on --surface-chart).
   ========================================================================== */

:root {
  /* Planes ------------------------------------------------------------- */
  --bg-deep: #080a0f;
  --bg-base: #0b0e14;
  --surface-chart: #141821;

  /* Glass -------------------------------------------------------------- */
  --glass-bg: rgba(255, 255, 255, 0.045);
  --glass-bg-strong: rgba(255, 255, 255, 0.075);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-border-bright: rgba(255, 255, 255, 0.18);
  --glass-blur: 18px;
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);

  /* Ink ---------------------------------------------------------------- */
  --fg: #edeef2;
  --fg-muted: #9aa3b2;
  --fg-dim: #6b7484;

  /* Brand accent: pool water. Used for UI chrome, never as a chart series. */
  --accent: #2ad4c4;
  --accent-strong: #12b8ab;
  --accent-glow: rgba(42, 212, 196, 0.18);
  --accent-ink: #04140f;

  /* Status — fixed, never themed, never reused as a series colour ------- */
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;

  /* Chart series — validated dark categorical order --------------------- */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;

  /* Chart chrome ------------------------------------------------------- */
  --grid: #2c2c2a;
  --axis: #383835;
  --tick: #898781;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 999px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --header-h: 60px;
  --content-max: 1400px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  /* Never pure black: it smears on OLED and kills the glass depth cue. */
  background: var(--bg-deep);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* The ambient field the glass refracts. Fixed, so it never scrolls away. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(58rem 42rem at 12% -8%, rgba(42, 212, 196, 0.13), transparent 60%),
    radial-gradient(48rem 38rem at 92% 4%, rgba(57, 135, 229, 0.14), transparent 62%),
    radial-gradient(52rem 44rem at 68% 96%, rgba(144, 133, 233, 0.10), transparent 60%),
    linear-gradient(178deg, #0d111a 0%, var(--bg-deep) 55%, #06080c 100%);
}

/* A faint grid gives the glass something to sit against. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(70rem 50rem at 50% 0%, #000 20%, transparent 80%);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: clamp(1.9rem, 5vw, 3.1rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.65rem); }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--fg-muted); }
.dim { color: var(--fg-dim); }
.small { font-size: 0.82rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ── Glass primitives ─────────────────────────────────────────────────── */

.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  position: relative;
}

/* The top-edge shine is what sells the material. */
.glass::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  pointer-events: none;
}

.card { padding: 1.25rem; }
.card-pad-lg { padding: 1.6rem; }

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.card-head h3 { font-size: 0.95rem; letter-spacing: 0.01em; }
.card-head .sub { font-size: 0.8rem; color: var(--fg-dim); }

/* ── Layout ───────────────────────────────────────────────────────────── */

.shell { max-width: var(--content-max); margin: 0 auto; padding: 1.25rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); }
.span-2 { grid-column: span 2; }

.row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.row-tight { display: flex; gap: 0.4rem; align-items: center; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }

/* The overview's main split. A class rather than an inline style, so the
   breakpoint below can actually override it. */
.overview-split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 900px) {
  .overview-split { grid-template-columns: minmax(0, 1fr); }
}

/* ── Header ───────────────────────────────────────────────────────────── */

.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: rgba(10, 13, 19, 0.72);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  border-bottom: 1px solid var(--glass-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 680;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent), #2f7fd6);
  box-shadow: 0 0 18px var(--accent-glow);
  flex-shrink: 0;
}
.brand-mark svg { width: 18px; height: 18px; display: block; }

/* The demo notice, directly under the header. */
.demo-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 45;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.5rem 1.25rem;
  font-size: 0.84rem;
  color: var(--fg-muted);
  background: rgba(42, 212, 196, 0.09);
  border-bottom: 1px solid rgba(42, 212, 196, 0.22);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.demo-bar strong { color: var(--accent); }
@media (max-width: 640px) {
  .demo-bar { font-size: 0.78rem; padding: 0.5rem 0.85rem; }
  .demo-bar .spacer { display: none; }
}

/* ── Buttons ──────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  /* 44px minimum touch target. */
  min-height: 44px;
  padding: 0 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border-bright);
  background: var(--glass-bg-strong);
  color: var(--fg);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 560;
  cursor: pointer;
  transition: transform 160ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  text-align: center;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.26); text-decoration: none; }
.btn:active { transform: scale(0.975); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 640;
  box-shadow: 0 6px 20px var(--accent-glow);
}
.btn-primary:hover { background: linear-gradient(145deg, #35e2d1, var(--accent)); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-muted); }
.btn-ghost:hover { background: var(--glass-bg); color: var(--fg); }

.btn-sm { min-height: 34px; padding: 0 0.7rem; font-size: 0.82rem; }
.btn-danger { color: var(--critical); border-color: rgba(208, 59, 59, 0.35); }
.btn-danger:hover { background: rgba(208, 59, 59, 0.14); }
.btn-block { width: 100%; }

.btn-oauth { width: 100%; background: rgba(255, 255, 255, 0.07); }
.btn-oauth svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Forms ────────────────────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 0.35rem; }
/* Labels are always visible: a placeholder is not a label. */
.field label { font-size: 0.78rem; font-weight: 560; color: var(--fg-muted); letter-spacing: 0.01em; }
.field .hint { font-size: 0.72rem; color: var(--fg-dim); }
.field .err { font-size: 0.75rem; color: var(--critical); }

input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 0.55rem 0.75rem;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font: inherit;
  font-size: 0.92rem;
  transition: border-color 160ms var(--ease), box-shadow 160ms var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--fg-dim); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath fill='%239aa3b2' d='M2.5 4.5L6 8l3.5-3.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 2rem;
}
input[type="checkbox"] { width: auto; min-height: auto; accent-color: var(--accent); }
input[type="file"] { padding: 0.5rem; font-size: 0.85rem; }

/* ── Status ───────────────────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg-strong);
  white-space: nowrap;
}
/* Status never rides on colour alone — every pill carries a dot and a word. */
.pill .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pill-good    { color: #4ade4a; border-color: rgba(12, 163, 12, 0.4);  background: rgba(12, 163, 12, 0.12); }
.pill-good    .dot { background: var(--good); }
.pill-warning { color: #fbbf3f; border-color: rgba(250, 178, 25, 0.4); background: rgba(250, 178, 25, 0.12); }
.pill-warning .dot { background: var(--warning); }
.pill-serious { color: #f0906a; border-color: rgba(236, 131, 90, 0.4); background: rgba(236, 131, 90, 0.12); }
.pill-serious .dot { background: var(--serious); }
.pill-critical{ color: #e96b6b; border-color: rgba(208, 59, 59, 0.45); background: rgba(208, 59, 59, 0.14); }
.pill-critical .dot { background: var(--critical); }
.pill-unknown { color: var(--fg-dim); }
.pill-unknown .dot { background: var(--fg-dim); }
.pill-accent  { color: var(--accent); border-color: rgba(42, 212, 196, 0.4); background: rgba(42, 212, 196, 0.12); }
.pill-accent  .dot { background: var(--accent); }

/* ── Stat tiles ───────────────────────────────────────────────────────── */

.stat { padding: 1rem 1.1rem; }
.stat .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--fg-dim);
  font-weight: 620;
  margin-bottom: 0.4rem;
}
.stat .value { font-size: 1.85rem; font-weight: 660; letter-spacing: -0.03em; line-height: 1.05; }
.stat .value .unit { font-size: 0.9rem; font-weight: 500; color: var(--fg-muted); margin-left: 0.2rem; }
.stat .sub { font-size: 0.78rem; color: var(--fg-muted); margin-top: 0.35rem; }

/* ── Reading tiles ────────────────────────────────────────────────────── */

.readings { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(155px, 100%), 1fr)); gap: 0.65rem; }

.reading {
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  transition: border-color 160ms var(--ease), transform 160ms var(--ease);
}
.reading:hover { border-color: var(--glass-border-bright); transform: translateY(-1px); }
.reading .rl { font-size: 0.72rem; color: var(--fg-muted); margin-bottom: 0.3rem; display: flex; align-items: center; gap: 0.3rem; }
.reading .rv { font-size: 1.3rem; font-weight: 640; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.reading .rv .u { font-size: 0.72rem; font-weight: 500; color: var(--fg-dim); margin-left: 0.15rem; }
.reading .rr { font-size: 0.68rem; color: var(--fg-dim); margin-top: 0.2rem; font-variant-numeric: tabular-nums; }
.reading.is-good    { box-shadow: inset 3px 0 0 var(--good); }
.reading.is-warning { box-shadow: inset 3px 0 0 var(--warning); }
.reading.is-serious { box-shadow: inset 3px 0 0 var(--critical); }
.reading.is-unknown { opacity: 0.55; }
/* Unscored readings (temperature, TDS) get no status stripe — they are
   context for the chemistry, not defects to correct. */
.reading.is-neutral { box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.14); }

/* A miniature range bar makes "how far out" legible without reading numbers. */
.range-bar { position: relative; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.08); margin-top: 0.5rem; overflow: hidden; }
.range-bar .band { position: absolute; top: 0; bottom: 0; background: rgba(12, 163, 12, 0.34); }
.range-bar .marker { position: absolute; top: -2px; width: 2px; height: 8px; background: var(--fg); border-radius: 1px; }

/* ── Tables ───────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-dim);
  font-weight: 640;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--glass-border);
  white-space: nowrap;
}
td { padding: 0.6rem 0.7rem; border-bottom: 1px solid rgba(255, 255, 255, 0.05); vertical-align: middle; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* ── Tabs ─────────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 0.25rem; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  min-height: 40px;
  padding: 0 0.9rem;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 160ms var(--ease);
}
.tab:hover { color: var(--fg); background: var(--glass-bg); }
.tab.active {
  color: var(--accent);
  background: rgba(42, 212, 196, 0.12);
  border-color: rgba(42, 212, 196, 0.32);
}

/* ── Charts ───────────────────────────────────────────────────────────── */

.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--font); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--tick); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart .band { fill: rgba(12, 163, 12, 0.10); }
.chart .band-line { stroke: rgba(12, 163, 12, 0.35); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* A 2px surface ring keeps overlapping markers separable. */
.chart .marker { stroke: var(--surface-chart); stroke-width: 2; }
.chart .hover-line { stroke: rgba(255, 255, 255, 0.3); stroke-width: 1; }
.chart .event-line { stroke: rgba(255, 255, 255, 0.16); stroke-width: 1; stroke-dasharray: 2 3; }

.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-top: 0.6rem; font-size: 0.76rem; color: var(--fg-muted); }
.legend .key { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.tooltip {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  background: rgba(16, 20, 28, 0.94);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border-bright);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
  font-size: 0.78rem;
  max-width: 260px;
  opacity: 0;
  transition: opacity 120ms var(--ease);
}
.tooltip.show { opacity: 1; }
.tooltip .tt-title { font-weight: 640; margin-bottom: 0.25rem; font-size: 0.74rem; color: var(--fg-muted); }
.tooltip .tt-row { display: flex; align-items: center; gap: 0.4rem; font-variant-numeric: tabular-nums; }

/* ── Modal ────────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 6, 10, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  animation: fade 180ms var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(720px, 100%);
  margin: min(6vh, 3rem) 0;
  padding: 1.5rem;
  animation: rise 260ms var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.modal-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--fg); background: var(--glass-bg-strong); }

/* ── Toast ────────────────────────────────────────────────────────────── */

.toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 0.5rem; width: min(440px, calc(100vw - 2rem)); }
.toast {
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(16, 20, 28, 0.95);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border-bright);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  font-size: 0.86rem;
  animation: rise 220ms var(--ease);
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}
.toast.err { border-color: rgba(208, 59, 59, 0.5); }
.toast.ok { border-color: rgba(12, 163, 12, 0.45); }

/* ── Misc ─────────────────────────────────────────────────────────────── */

.empty { padding: 2.5rem 1rem; text-align: center; color: var(--fg-dim); }
.empty .big { font-size: 1.6rem; margin-bottom: 0.5rem; opacity: 0.5; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

.note {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-left: 3px solid var(--glass-border-bright);
}
.note.ai { border-left-color: var(--accent); background: rgba(42, 212, 196, 0.045); }
.note .note-head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; font-size: 0.74rem; color: var(--fg-dim); }
.note .body { font-size: 0.88rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.note .body strong { color: var(--fg); font-weight: 640; }

.alert-item { display: flex; gap: 0.65rem; padding: 0.75rem 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.alert-item:last-child { border-bottom: none; }
.alert-item .ico { flex-shrink: 0; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; font-size: 0.7rem; font-weight: 700; margin-top: 1px; }
.alert-item .ico.warning { background: rgba(250,178,25,0.18); color: var(--warning); }
.alert-item .ico.serious { background: rgba(208,59,59,0.18); color: var(--critical); }
.alert-item .ico.good { background: rgba(12,163,12,0.18); color: var(--good); }
.alert-item .t { font-weight: 620; font-size: 0.86rem; margin-bottom: 0.15rem; }
.alert-item .d { font-size: 0.82rem; color: var(--fg-muted); line-height: 1.5; }

.thumb {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(0,0,0,0.3);
  display: block;
}
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)); gap: 0.75rem; }

code, pre { font-family: var(--font-mono); font-size: 0.84em; }
pre {
  background: rgba(0, 0, 0, 0.36);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  overflow-x: auto;
  line-height: 1.55;
}
code:not(pre code) { background: rgba(255,255,255,0.08); padding: 0.12em 0.4em; border-radius: 5px; }

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .shell { padding: 0.85rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: span 1; }
  .card { padding: 1rem; }
  .stat .value { font-size: 1.55rem; }
  .appbar { padding: 0 0.85rem; gap: 0.6rem; }
  .readings { grid-template-columns: repeat(auto-fill, minmax(min(130px, 100%), 1fr)); }
  .modal { padding: 1.15rem; margin: 0.5rem 0; }
  /* Glass blur is expensive on mobile GPUs; ease it off where it is subtle. */
  .glass { -webkit-backdrop-filter: blur(12px) saturate(140%); backdrop-filter: blur(12px) saturate(140%); }
}

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

/* Glass is decorative; if the OS is in forced-colours mode, get out of the way. */
@media (forced-colors: active) {
  .glass, .btn, .reading { border: 1px solid CanvasText; background: Canvas; }
  .glass::before { display: none; }
}
