/* ==========================================================================
   Radiant Waves — design system

   Colour is validated, not eyeballed (dataviz six-checks, OKLab ΔE):

   * Status trio  #0d9488 / #d97706 / #e11d48 clears every gate all-pairs in
     both modes. Status never appears as colour alone — always icon + label.
   * Per-metric accents are single-series: one hue, alone on its own detail
     page. They never co-occur, so the adjacency gates don't apply; each is
     held to the chroma floor and >= 3:1 contrast on its surface. Sibling
     chips and dashboard sparklines deliberately wear status/text tokens so
     these hues can never end up side by side.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Ground */
  --abyss:        #04121c;
  --surface-1:    #071b28;
  --surface-2:    #0a2233;
  --glass:        rgba(255, 255, 255, 0.045);
  --glass-strong: rgba(255, 255, 255, 0.075);
  --hairline:     rgba(255, 255, 255, 0.085);
  --hairline-lit: rgba(255, 255, 255, 0.16);

  /* Ink */
  --text-primary:   #eaf6fb;
  --text-secondary: #9fc0d2;
  --text-muted:     #6d8fa3;

  /* Status — reserved, never used for series identity */
  --ok:       #0d9488;
  --warn:     #d97706;
  --critical: #e11d48;
  --ok-lit:       #2dd4bf;
  --warn-lit:     #fbbf24;
  --critical-lit: #fb7185;

  /* Per-metric accents */
  --m-ph:          #a78bfa;
  --m-orp:         #22d3ee;
  --m-temperature: #38bdf8;
  --m-salt:        #818cf8;
  --m-tds:         #c084fc;
  --m-battery:     #2dd4bf;
  --m-rssi:        #60a5fa;

  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;

  --shadow-lift: 0 24px 60px -28px rgba(0, 0, 0, 0.85);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --shell: min(1180px, 100% - 3rem);
}

:root[data-theme="light"] {
  color-scheme: light;

  --abyss:        #eef6fa;
  --surface-1:    #f2f9fc;
  --surface-2:    #ffffff;
  --glass:        rgba(255, 255, 255, 0.72);
  --glass-strong: rgba(255, 255, 255, 0.92);
  --hairline:     rgba(8, 47, 73, 0.10);
  --hairline-lit: rgba(8, 47, 73, 0.20);

  --text-primary:   #082f49;
  --text-secondary: #3f6b85;
  --text-muted:     #6a8ba0;

  --ok-lit:       #0d9488;
  --warn-lit:     #b45309;
  --critical-lit: #be123c;

  --m-ph:          #7c3aed;
  --m-orp:         #0891b2;
  --m-temperature: #0369a1;
  --m-salt:        #4338ca;
  --m-tds:         #9333ea;
  --m-battery:     #0f766e;
  --m-rssi:        #1d4ed8;

  --shadow-lift: 0 22px 50px -30px rgba(8, 47, 73, 0.4);
}

/* --- Reset ------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

body, h1, h2, h3, h4, p, figure, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100dvh;
  background: var(--abyss);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.55;
  font-feature-settings: "cv05" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { display: block; }

:focus-visible {
  outline: 2px solid var(--m-orp);
  outline-offset: 3px;
  border-radius: 6px;
}

.numeric { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Atmosphere -------------------------------------------------------- */
/* Light moving through water: three slow-drifting colour fields plus a
   fine caustic weave. Purely decorative, and it stops dead under
   prefers-reduced-motion. */

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -10%, #0b3550 0%, transparent 60%),
    linear-gradient(180deg, var(--abyss) 0%, #051826 55%, var(--abyss) 100%);
}

:root[data-theme="light"] .atmosphere {
  background:
    radial-gradient(120% 80% at 50% -10%, #d6ecf7 0%, transparent 62%),
    linear-gradient(180deg, #eef6fa 0%, #e4f1f8 55%, #eef6fa 100%);
}

.atmosphere__field {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  will-change: transform;
}

.atmosphere__field--a {
  width: 46vw; height: 46vw; min-width: 380px; min-height: 380px;
  top: -12vh; left: -8vw;
  background: radial-gradient(circle, rgba(34, 211, 238, 0.30), transparent 68%);
  animation: drift-a 34s var(--ease) infinite alternate;
}
.atmosphere__field--b {
  width: 40vw; height: 40vw; min-width: 340px; min-height: 340px;
  top: 22vh; right: -10vw;
  background: radial-gradient(circle, rgba(129, 140, 248, 0.26), transparent 68%);
  animation: drift-b 42s var(--ease) infinite alternate;
}
.atmosphere__field--c {
  width: 52vw; height: 40vw; min-width: 420px;
  bottom: -18vh; left: 18vw;
  background: radial-gradient(circle, rgba(13, 148, 136, 0.24), transparent 70%);
  animation: drift-c 38s var(--ease) infinite alternate;
}

:root[data-theme="light"] .atmosphere__field { opacity: 0.34; }

@keyframes drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(6vw, 8vh, 0) scale(1.18); }
}
@keyframes drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.1); }
  to   { transform: translate3d(-7vw, 12vh, 0) scale(0.94); }
}
@keyframes drift-c {
  from { transform: translate3d(0, 0, 0) scale(0.96); }
  to   { transform: translate3d(8vw, -9vh, 0) scale(1.16); }
}

.caustics {
  position: fixed;
  inset: -20%;
  z-index: -1;
  pointer-events: none;
  opacity: 0.055;
  mix-blend-mode: screen;
  animation: caustic-swim 26s linear infinite;
}
:root[data-theme="light"] .caustics { opacity: 0.05; mix-blend-mode: multiply; }

@keyframes caustic-swim {
  from { transform: translate3d(-2%, -1%, 0) scale(1.04); }
  50%  { transform: translate3d(2%, 2%, 0) scale(1.10); }
  to   { transform: translate3d(-2%, -1%, 0) scale(1.04); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .caustics { opacity: 0.03; }
}

/* --- Shell ------------------------------------------------------------- */

.shell { width: var(--shell); margin-inline: auto; }

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.9rem 0 1.2rem;
}

.brand { display: flex; align-items: center; gap: 0.85rem; }

.brand__mark { width: 40px; height: 40px; flex: none; }

.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name {
  font-family: var(--font-display);
  font-size: 1.32rem;
  font-weight: 500;
  font-variation-settings: "SOFT" 40, "WONK" 1, "opsz" 40;
  letter-spacing: -0.012em;
}
.brand__sub {
  font-size: 0.66rem;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.22rem;
}

.masthead__actions { display: flex; align-items: center; gap: 0.5rem; }

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.52rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--glass);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.2s var(--ease);
}
.ghost-btn:hover {
  color: var(--text-primary);
  border-color: var(--hairline-lit);
  background: var(--glass-strong);
  transform: translateY(-1px);
}
.ghost-btn svg { width: 15px; height: 15px; }

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #04121c;
  background: linear-gradient(135deg, var(--m-orp), var(--m-temperature));
  box-shadow: 0 12px 30px -14px rgba(34, 211, 238, 0.7);
  transition: transform 0.2s var(--ease), box-shadow 0.2s;
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 18px 38px -14px rgba(34, 211, 238, 0.8); }

main { padding-bottom: 5rem; }

/* --- Panels ------------------------------------------------------------ */

.panel {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px) saturate(1.25);
  -webkit-backdrop-filter: blur(20px) saturate(1.25);
  box-shadow: var(--shadow-lift);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 3rem 0 1.15rem;
}
.section-head h2 {
  font-family: var(--font-display);
  font-size: 1.42rem;
  font-weight: 500;
  font-variation-settings: "SOFT" 40, "opsz" 30;
  letter-spacing: -0.01em;
}
.section-head p { color: var(--text-muted); font-size: 0.86rem; }

/* --- Hero: overall pool health ---------------------------------------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2.5rem;
  align-items: center;
  padding: 2.9rem 2.8rem;
  min-height: 350px;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(120% 140% at 88% 50%, var(--tone-glow, transparent) 0%, transparent 58%);
  opacity: 0.5;
}

.hero[data-tone="ok"]       { --tone: var(--ok);       --tone-lit: var(--ok-lit);       --tone-glow: rgba(13, 148, 136, 0.22); }
.hero[data-tone="warn"]     { --tone: var(--warn);     --tone-lit: var(--warn-lit);     --tone-glow: rgba(217, 119, 6, 0.22); }
.hero[data-tone="critical"] { --tone: var(--critical); --tone-lit: var(--critical-lit); --tone-glow: rgba(225, 29, 72, 0.24); }
.hero[data-tone="unknown"]  { --tone: var(--text-muted); --tone-lit: var(--text-secondary); --tone-glow: transparent; }

.hero__body { position: relative; z-index: 1; min-width: 0; }
.hero--water .hero__body { text-shadow: 0 1px 22px rgba(4, 18, 28, 0.55); }
:root[data-theme="light"] .hero--water .hero__body { text-shadow: 0 1px 18px rgba(240, 249, 253, 0.8); }
.hero--water .ring { position: relative; z-index: 1; }

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.hero__verdict {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 5.5vw, 3.9rem);
  font-weight: 400;
  font-variation-settings: "SOFT" 60, "WONK" 1, "opsz" 100;
  line-height: 1.02;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, var(--text-primary) 12%, var(--tone-lit) 96%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__summary {
  margin-top: 0.9rem;
  max-width: 46ch;
  color: var(--text-secondary);
  font-size: 1.02rem;
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-top: 1.6rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  padding: 0.36rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--abyss) 55%, var(--glass));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 0.78rem;
  color: var(--text-secondary);
  text-shadow: none;
}
.chip__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip--ok       { color: var(--ok-lit); }
.chip--warn     { color: var(--warn-lit); }
.chip--critical { color: var(--critical-lit); }

/* The health ring */
.ring { position: relative; width: 218px; height: 218px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring__track { stroke: var(--hairline); }
.ring__value {
  stroke: var(--tone-lit);
  stroke-linecap: round;
  filter: drop-shadow(0 0 12px var(--tone-glow));
  transition: stroke-dashoffset 1.4s var(--ease);
}
.ring__readout {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.ring__score {
  font-size: 3.5rem;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -0.045em;
  text-shadow: 0 2px 26px rgba(4, 18, 28, 0.9);
}
:root[data-theme="light"] .ring__score { text-shadow: 0 2px 20px rgba(240, 249, 253, 0.95); }
.ring__label {
  margin-top: 0.4rem;
  font-size: 0.63rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- Metric cards ------------------------------------------------------ */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
  gap: 1.05rem;
}

.card {
  --tone: var(--ok);
  --tone-lit: var(--ok-lit);
  position: relative;
  display: block;
  padding: 1.5rem 1.5rem 1.3rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  overflow: hidden;
  transition: transform 0.32s var(--ease), border-color 0.3s, background 0.3s, box-shadow 0.3s;
}

.card[data-severity="warn"]     { --tone: var(--warn);     --tone-lit: var(--warn-lit); }
.card[data-severity="critical"] { --tone: var(--critical); --tone-lit: var(--critical-lit); }
.card[data-severity="unknown"]  { --tone: var(--text-muted); --tone-lit: var(--text-muted); }

.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--tone-lit), transparent);
  opacity: 0.55;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(90% 120% at 50% 0%, color-mix(in srgb, var(--tone-lit) 16%, transparent), transparent 65%);
  transition: opacity 0.32s var(--ease);
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--hairline-lit);
  background: var(--glass-strong);
  box-shadow: var(--shadow-lift);
}
.card:hover::after { opacity: 1; }

.card[data-severity="critical"] { border-color: color-mix(in srgb, var(--critical-lit) 38%, var(--hairline)); }
.card[data-severity="warn"]     { border-color: color-mix(in srgb, var(--warn-lit) 30%, var(--hairline)); }

.card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.card__label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Status is never colour alone: dot + word, always. */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.24rem 0.6rem 0.24rem 0.5rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--tone-lit);
  background: color-mix(in srgb, var(--tone-lit) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--tone-lit) 26%, transparent);
  white-space: nowrap;
}
.status svg { width: 11px; height: 11px; }

.card__readout {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  margin-top: 1.15rem;
}
.card__value {
  font-size: 3.15rem;
  font-weight: 200;
  line-height: 0.95;
  letter-spacing: -0.045em;
}
.card__unit { font-size: 1rem; font-weight: 500; color: var(--text-muted); }

.card__target {
  margin-top: 0.55rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.card__target b { color: var(--text-secondary); font-weight: 600; }

/* Linear gauge: ideal band as a lit segment, current value as a marker. */
.gauge { margin-top: 1.15rem; }
.gauge__rail {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 18%, transparent);
  overflow: visible;
}
.gauge__band {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ok-lit) 34%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ok-lit) 40%, transparent);
}
.gauge__marker {
  position: absolute;
  top: 50%;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--tone-lit);
  border: 2.5px solid var(--surface-1);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--tone-lit) 55%, transparent),
              0 0 14px color-mix(in srgb, var(--tone-lit) 65%, transparent);
  transition: left 0.9s var(--ease);
}
.gauge__scale {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.15rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--hairline);
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 0.34rem;
  font-size: 0.76rem;
  color: var(--text-muted);
}
.trend svg { width: 13px; height: 13px; }
.trend[data-dir="rising"]  svg { transform: rotate(-45deg); }
.trend[data-dir="falling"] svg { transform: rotate(45deg); }

.sparkline { width: 96px; height: 30px; overflow: visible; }
.sparkline path { fill: none; stroke: var(--tone-lit); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }

.card__stale {
  margin-top: 0.7rem;
  font-size: 0.72rem;
  color: var(--warn-lit);
}

/* Diagnostics read quieter than the water chemistry. */
.grid--diagnostic .card { padding: 1.15rem 1.3rem; background: color-mix(in srgb, var(--glass) 60%, transparent); }
.grid--diagnostic .card__value { font-size: 2.15rem; }

/* --- Action plan ------------------------------------------------------- */

.plan { display: grid; gap: 0.9rem; }

.action {
  --tone-lit: var(--warn-lit);
  position: relative;
  padding: 1.5rem 1.6rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  background: var(--glass);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow: hidden;
}
.action[data-severity="critical"] { --tone-lit: var(--critical-lit); }
.action[data-severity="info"]     { --tone-lit: var(--m-orp); }

.action::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tone-lit);
}

.action__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.action__step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  flex: none;
  border-radius: 50%;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--tone-lit);
  background: color-mix(in srgb, var(--tone-lit) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--tone-lit) 30%, transparent);
}

.action__title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-family: var(--font-display);
  font-size: 1.16rem;
  font-weight: 500;
  font-variation-settings: "SOFT" 40, "opsz" 24;
  letter-spacing: -0.008em;
  min-width: 0;
}

.dose {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--tone-lit) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--tone-lit) 22%, transparent);
  flex: none;
}
.dose__product {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.dose__amount {
  font-size: 1.28rem;
  font-weight: 600;
  color: var(--tone-lit);
  letter-spacing: -0.015em;
}

.action__steps { margin-top: 1.2rem; display: grid; gap: 0.6rem; counter-reset: step; }
.action__steps li {
  position: relative;
  padding-left: 1.7rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
  counter-increment: step;
}
.action__steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0.12rem;
  width: 1.15rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  color: var(--tone-lit);
  opacity: 0.8;
}

.action__extra {
  margin-top: 1.15rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hairline);
  display: grid;
  gap: 0.6rem;
}

.caution, .alternative {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.84rem;
  color: var(--text-muted);
}
.caution svg, .alternative svg { width: 15px; height: 15px; flex: none; margin-top: 0.16rem; }
.caution { color: color-mix(in srgb, var(--warn-lit) 78%, var(--text-secondary)); }

.action__retest {
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.all-clear {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  padding: 1.9rem 2rem;
  border-radius: var(--radius-lg);
  border: 1px solid color-mix(in srgb, var(--ok-lit) 26%, var(--hairline));
  background: color-mix(in srgb, var(--ok-lit) 7%, var(--glass));
}
.all-clear svg { width: 34px; height: 34px; color: var(--ok-lit); flex: none; }
.all-clear h3 { font-family: var(--font-display); font-size: 1.25rem; font-weight: 500; }
.all-clear p { color: var(--text-secondary); font-size: 0.92rem; margin-top: 0.2rem; }

/* Ondilo's own advice */
.advice {
  display: grid;
  gap: 0.75rem;
}
.advice__item {
  padding: 1.1rem 1.3rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  background: var(--glass);
}
.advice__item h4 { font-size: 0.95rem; font-weight: 600; }
.advice__item p { margin-top: 0.3rem; font-size: 0.88rem; color: var(--text-secondary); }
.advice__src { font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }

/* --- Metric detail ----------------------------------------------------- */

.detail-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  margin: 1.5rem 0 1.75rem;
}

.detail-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 400;
  font-variation-settings: "SOFT" 60, "WONK" 1, "opsz" 80;
  letter-spacing: -0.025em;
  line-height: 1.05;
}
.detail-blurb { margin-top: 0.7rem; max-width: 52ch; color: var(--text-secondary); }

.detail-readout { display: flex; align-items: baseline; gap: 0.45rem; }
.detail-readout .card__value { font-size: 4.2rem; color: var(--accent); }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: color 0.2s, gap 0.2s var(--ease);
}
.back-link:hover { color: var(--text-primary); gap: 0.7rem; }
.back-link svg { width: 14px; height: 14px; }

.chart-panel { padding: 1.6rem 1.5rem 1.2rem; }

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
}

.range-picker {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--surface-1) 60%, transparent);
}
.range-picker button {
  padding: 0.42rem 0.95rem;
  border-radius: 999px;
  font-size: 0.79rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s;
}
.range-picker button:hover { color: var(--text-primary); }
.range-picker button[aria-pressed="true"] {
  color: var(--text-primary);
  background: var(--glass-strong);
  box-shadow: 0 2px 10px -4px rgba(0, 0, 0, 0.6);
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 1px;
  margin-top: 1.5rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--hairline);
}
.stat {
  padding: 0.95rem 1.1rem;
  background: var(--surface-1);
}
.stat__label {
  font-size: 0.65rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat__value { margin-top: 0.28rem; font-size: 1.42rem; font-weight: 300; letter-spacing: -0.03em; }

/* Chart canvas */
.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }

.chart__grid line { stroke: var(--hairline); stroke-width: 1; }
.chart__axis text { fill: var(--text-muted); font-size: 11px; font-family: var(--font-ui); }
.chart__band { fill: color-mix(in srgb, var(--ok-lit) 11%, transparent); }
.chart__band-edge { stroke: color-mix(in srgb, var(--ok-lit) 42%, transparent); stroke-width: 1; stroke-dasharray: 4 4; }
.chart__band-label { fill: var(--ok-lit); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.chart__area { fill: url(#rw-area); }
.chart__line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart__crosshair { stroke: var(--hairline-lit); stroke-width: 1; stroke-dasharray: 3 4; }
.chart__dot { fill: var(--accent); stroke: var(--surface-1); stroke-width: 2.5; }
.chart__hit { fill: transparent; cursor: crosshair; }

.chart__empty {
  display: grid;
  place-content: center;
  gap: 0.5rem;
  min-height: 240px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.tooltip {
  position: absolute;
  z-index: 5;
  min-width: 132px;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline-lit);
  background: color-mix(in srgb, var(--surface-2) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -118%);
  transition: opacity 0.14s;
}
.tooltip[data-visible="true"] { opacity: 1; }
.tooltip__value { font-size: 1.28rem; font-weight: 400; letter-spacing: -0.02em; }
.tooltip__value span { font-size: 0.82rem; color: var(--text-muted); margin-left: 0.15rem; }
.tooltip__time { margin-top: 0.15rem; font-size: 0.72rem; color: var(--text-muted); }
.tooltip__status { margin-top: 0.4rem; font-size: 0.7rem; font-weight: 600; }

/* Accessible alternative to the plot */
.table-toggle { margin-top: 1.5rem; }
.data-table { width: 100%; margin-top: 1rem; border-collapse: collapse; font-size: 0.85rem; }
.data-table caption { text-align: left; color: var(--text-muted); font-size: 0.78rem; padding-bottom: 0.6rem; }
.data-table th, .data-table td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--hairline); }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; }
.data-table td { color: var(--text-secondary); }

.sibling-nav { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-top: 1.25rem; }
.sibling {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--hairline);
  background: var(--glass);
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: color 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
.sibling:hover { color: var(--text-primary); border-color: var(--hairline-lit); transform: translateY(-1px); }
.sibling__dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.sibling__dot[data-severity="ok"]       { background: var(--ok-lit); }
.sibling__dot[data-severity="warn"]     { background: var(--warn-lit); }
.sibling__dot[data-severity="critical"] { background: var(--critical-lit); }
.sibling__dot[data-severity="unknown"]  { background: var(--text-muted); }
.sibling b { font-weight: 600; color: var(--text-primary); }

/* --- Setup form -------------------------------------------------------- */

.setup { display: grid; gap: 1.5rem; }

.fieldset { padding: 1.9rem 2rem; }
.fieldset__legend {
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 500;
  font-variation-settings: "SOFT" 40, "opsz" 24;
}
.fieldset__hint { margin-top: 0.35rem; color: var(--text-muted); font-size: 0.86rem; max-width: 62ch; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.field { display: flex; flex-direction: column; gap: 0.4rem; }
.field label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.field input, .field select {
  width: 100%;
  padding: 0.72rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--surface-1) 70%, transparent);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.98rem;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.2s, background 0.2s;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--m-orp);
  background: color-mix(in srgb, var(--surface-2) 80%, transparent);
}
.field small { font-size: 0.72rem; color: var(--text-muted); }

/* Sanitiser type selector */
.sanitizer-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem;
  margin-top: 1.5rem;
}
.sanitizer-option { position: relative; }
.sanitizer-option input { position: absolute; opacity: 0; pointer-events: none; }
.sanitizer-option span.body {
  display: block;
  padding: 1.2rem 1.3rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--hairline);
  background: color-mix(in srgb, var(--surface-1) 55%, transparent);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease);
}
.sanitizer-option:hover span.body { transform: translateY(-2px); border-color: var(--hairline-lit); }
.sanitizer-option input:checked + span.body {
  border-color: var(--m-orp);
  background: color-mix(in srgb, var(--m-orp) 10%, transparent);
  box-shadow: 0 0 0 1px var(--m-orp);
}
.sanitizer-option input:focus-visible + span.body { outline: 2px solid var(--m-orp); outline-offset: 3px; }
.sanitizer-option strong { display: block; font-size: 1.02rem; font-weight: 600; }
.sanitizer-option em {
  display: block;
  font-style: normal;
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--m-orp);
  margin-top: 0.2rem;
}
.sanitizer-option p { margin-top: 0.55rem; font-size: 0.84rem; color: var(--text-secondary); }

.volume-readout {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-top: 1.5rem;
  padding: 1.2rem 1.4rem;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--m-orp) 24%, var(--hairline));
  background: color-mix(in srgb, var(--m-orp) 8%, transparent);
}
.volume-readout__value { font-size: 2.1rem; font-weight: 300; letter-spacing: -0.03em; color: var(--m-orp); }
.volume-readout__label { font-size: 0.86rem; color: var(--text-secondary); }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.5rem;
}

.banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
}
.banner svg { width: 18px; height: 18px; flex: none; }
.banner--ok {
  color: var(--ok-lit);
  background: color-mix(in srgb, var(--ok-lit) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--ok-lit) 26%, transparent);
}
.banner--warn {
  color: var(--warn-lit);
  background: color-mix(in srgb, var(--warn-lit) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn-lit) 26%, transparent);
}
.banner--info {
  color: var(--text-secondary);
  background: var(--glass);
  border: 1px solid var(--hairline);
}

/* --- Empty / connect states ------------------------------------------- */

.stage {
  display: grid;
  place-items: center;
  min-height: 68vh;
  text-align: center;
}
.stage__inner { max-width: 30rem; }
.stage h1 {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 5vw, 3.1rem);
  font-weight: 400;
  font-variation-settings: "SOFT" 60, "WONK" 1, "opsz" 90;
  letter-spacing: -0.025em;
  line-height: 1.06;
}
.stage p { margin-top: 1rem; color: var(--text-secondary); }
.stage .primary-btn { margin-top: 1.9rem; }
.stage__note { margin-top: 1.6rem; font-size: 0.8rem; color: var(--text-muted); }

.wordmark-lg { width: 84px; height: 84px; margin: 0 auto 1.9rem; }

/* --- Footer ------------------------------------------------------------ */

.site-foot {
  margin-top: 4.5rem;
  padding: 1.9rem 0 2.5rem;
  border-top: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.site-foot a:hover { color: var(--text-secondary); }
.site-foot__links { display: flex; gap: 1.15rem; flex-wrap: wrap; }

/* --- Entrance ---------------------------------------------------------- */

/* Entrance animates `translate` + `opacity`; the perpetual float animates
   `transform`. Keeping them on separate properties is what lets an element run
   both at once — two animations touching the same property would leave only the
   last one visible. */
@keyframes rise {
  from { opacity: 0; translate: 0 14px; }
  to   { opacity: 1; translate: 0 0; }
}
/* Content is visible by default. The entrance only attaches under .rw-enter,
   which is set once the document is actually being looked at — a background tab
   freezes its animation timeline, and an entrance that starts at opacity 0 would
   otherwise hold there indefinitely. Nothing on this page needs an animation to
   run in order to be readable. */
.rise { animation: none; }
.rw-enter .rise { animation: rise 0.7s var(--ease) var(--rise-delay, 0s) backwards; }
.rise:nth-child(2) { --rise-delay: 0.06s; }
.rise:nth-child(3) { --rise-delay: 0.12s; }
.rise:nth-child(4) { --rise-delay: 0.18s; }
.rise:nth-child(5) { --rise-delay: 0.24s; }
.rise:nth-child(6) { --rise-delay: 0.30s; }
.rise:nth-child(7) { --rise-delay: 0.36s; }

/* --- Responsive -------------------------------------------------------- */

@media (max-width: 900px) {
  :root { --shell: min(1180px, 100% - 2rem); }
  .hero { grid-template-columns: 1fr; gap: 2rem; padding: 2.1rem 1.6rem; }
  .ring { margin-inline: auto; }
  .fieldset { padding: 1.5rem 1.4rem; }
  .action { padding: 1.3rem 1.35rem; }
}

@media (max-width: 620px) {
  .masthead { flex-wrap: wrap; gap: 1rem; padding-top: 1.4rem; }
  .brand__sub { letter-spacing: 0.2em; }
  .grid { grid-template-columns: 1fr; }
  .card__value { font-size: 2.8rem; }
  .detail-head { gap: 1.2rem; }
  .action__head { flex-direction: column; align-items: stretch; }
  .dose { align-items: flex-start; }
  .section-head { margin-top: 2.4rem; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
}

@media print {
  .atmosphere, .caustics, .masthead__actions, .range-picker { display: none; }
  body { background: #fff; color: #000; }
}

/* --- The water portrait ------------------------------------------------ */
/* The hero renders the pool itself. Every layer's strength comes from a real
   reading (see app/water.py) — healthy water is clear, saturated blue with
   clean caustics; each problem pushes it toward what that problem looks like.
   This is an ambient encoding only: the cards below carry the authoritative
   status, and every active cue is also spelled out in words. */

.hero--water {
  --w-base: hsl(var(--w-hue) var(--w-sat) var(--w-light));
  --w-deep: hsl(calc(var(--w-hue) - 8) calc(var(--w-sat) * 0.9) calc(var(--w-light) * 0.55));
  --w-shallow: hsl(calc(var(--w-hue) + 6) var(--w-sat) calc(var(--w-light) + 16%));
  isolation: isolate;
}

.water {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(168deg, var(--w-shallow) 0%, var(--w-base) 42%, var(--w-deep) 100%);
}

/* Everything above the water reads against a legibility scrim. */
.water::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    /* keeps the Bliss ring legible over whatever the water is doing */
    radial-gradient(38% 62% at 84% 50%, rgba(4, 18, 28, 0.72), transparent 70%),
    /* text column scrim, fading out fast so the pool stays visible */
    linear-gradient(96deg,
      rgba(4, 18, 28, 0.86) 0%,
      rgba(4, 18, 28, 0.66) 26%,
      rgba(4, 18, 28, 0.24) 52%,
      rgba(4, 18, 28, 0.06) 72%,
      transparent 100%);
}
:root[data-theme="light"] .water::after {
  background:
    radial-gradient(38% 62% at 84% 50%, rgba(240, 249, 253, 0.80), transparent 70%),
    linear-gradient(96deg,
      rgba(240, 249, 253, 0.92) 0%,
      rgba(240, 249, 253, 0.76) 26%,
      rgba(240, 249, 253, 0.34) 54%,
      rgba(240, 249, 253, 0.10) 74%,
      transparent 100%);
}

.water__layer { position: absolute; inset: -10%; }

/* Caustics: bright and crisp in clear water, dim and smeared in murky water. */
.water__caustics {
  opacity: calc(0.16 + var(--w-clarity) * 0.5);
  filter: blur(calc((1 - var(--w-clarity)) * 3px));
  mix-blend-mode: screen;
  animation: water-swim calc(18s + var(--w-still) * 26s) ease-in-out infinite;
}

/* Algae: a green organic bloom that eats the blue. */
.water__algae {
  opacity: var(--w-algae);
  background:
    radial-gradient(60% 46% at 22% 30%, hsl(112 62% 34% / 0.85), transparent 70%),
    radial-gradient(52% 60% at 74% 66%, hsl(96 58% 30% / 0.8), transparent 72%),
    radial-gradient(40% 40% at 48% 88%, hsl(122 55% 26% / 0.7), transparent 70%);
  mix-blend-mode: multiply;
  filter: blur(14px);
  animation: bloom 22s ease-in-out infinite alternate;
}

/* Cloudiness: calcium haze — a flat milky veil. */
.water__cloud {
  opacity: calc(var(--w-cloud) * 0.85);
  background: radial-gradient(90% 80% at 60% 40%, rgba(233, 244, 248, 0.95), rgba(210, 230, 238, 0.6) 70%, transparent);
  filter: blur(8px);
}

/* Silt: fine suspended particulate. */
.water__silt {
  opacity: calc(var(--w-silt) * 0.9);
  mix-blend-mode: multiply;
}

/* Over-chlorinated glare: a hard specular wash. */
.water__glare {
  opacity: var(--w-glare);
  background: linear-gradient(112deg, transparent 30%, rgba(255, 255, 255, 0.85) 62%, transparent 82%);
  mix-blend-mode: screen;
  filter: blur(3px);
}

/* Salt crystal glint. */
.water__sparkle {
  opacity: var(--w-sparkle);
  mix-blend-mode: screen;
  animation: glint 7s ease-in-out infinite alternate;
}

/* Heat shimmer. */
.water__shimmer {
  opacity: calc(var(--w-shimmer) * 0.7);
  background: repeating-linear-gradient(
    174deg, transparent 0 7px, rgba(255, 236, 200, 0.30) 7px 9px);
  mix-blend-mode: overlay;
  filter: blur(2.5px);
  animation: shimmer 4.5s ease-in-out infinite alternate;
}

/* Acid etch: a hard bite around the edges. */
.water__etch {
  opacity: var(--w-etch);
  box-shadow: inset 0 0 90px 12px hsl(168 28% 34% / 0.65);
}

@keyframes water-swim {
  0%   { transform: translate3d(-1.5%, 0, 0) scale(1.05); }
  50%  { transform: translate3d(1.5%, 1.5%, 0) scale(1.12); }
  100% { transform: translate3d(-1.5%, 0, 0) scale(1.05); }
}
@keyframes bloom {
  from { transform: scale(1) translate3d(0, 0, 0); }
  to   { transform: scale(1.14) translate3d(2%, -2%, 0); }
}
@keyframes glint {
  from { opacity: calc(var(--w-sparkle) * 0.45); }
  to   { opacity: var(--w-sparkle); }
}
@keyframes shimmer {
  from { transform: translateY(0) scaleY(1); }
  to   { transform: translateY(-4px) scaleY(1.04); }
}

/* The written equivalent of the render — never colour alone. */
.water-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.15rem;
}
.water-cue {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.34rem 0.8rem;
  border-radius: 999px;
  font-size: 0.75rem;
  border: 1px solid color-mix(in srgb, var(--cue-tone) 30%, transparent);
  background: color-mix(in srgb, var(--abyss) 62%, color-mix(in srgb, var(--cue-tone) 16%, transparent));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text-secondary);
  text-shadow: none;
}
.water-cue[data-tone="warn"]     { --cue-tone: var(--warn-lit); }
.water-cue[data-tone="critical"] { --cue-tone: var(--critical-lit); }
.water-cue b { color: var(--cue-tone); font-weight: 600; }

.water-caption {
  margin-top: 0.9rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 54ch;
}

/* --- Motion: everything floats ---------------------------------------- */
/*
   Nothing on this page sits perfectly still. Cards, chips and panels drift on
   long, out-of-phase cycles the way objects on water do — each element gets a
   negative animation-delay so nothing bobs in lockstep, which is what would
   make it read as a jitter rather than a current.

   Two rules keep it from becoming noise:
   * Amplitudes are 2-4px over 9-16s. It should be felt more than seen.
   * Only `transform`, `opacity` and `background-position` animate, so none of
     it triggers layout. Hover lift uses the independent `translate` property so
     it composes with the float rather than fighting it.

   All of it collapses under prefers-reduced-motion (handled at the top of this
   file, which zeroes every animation and transition globally).
*/

@keyframes buoy {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0deg); }
  50%      { transform: translate3d(0, -4px, 0) rotate(0.12deg); }
}

@keyframes buoy-soft {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50%      { transform: translate3d(0, -2.5px, 0); }
}

/* A slow highlight travelling across glass, like light moving under a surface. */
@keyframes sheen {
  0%   { background-position: -140% 0; }
  100% { background-position: 240% 0; }
}

@keyframes shimmer-ring {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes tide {
  0%, 100% { background-position: 0% 50%; }
  50%      { background-position: 100% 50%; }
}

/* --- Floating elements ------------------------------------------------- */
/*
   Elements that also have an entrance need BOTH animations, and `animation` is
   a single property — a second rule would replace the first, not add to it. So
   the float is declared once as a comma-composed list and each element only
   varies its phase through custom properties. That also means one place to
   retune the whole page's rhythm.
*/

.floats {
  --float: buoy;
  --float-dur: 13s;
  --float-delay: 0s;
  animation: var(--float) var(--float-dur) ease-in-out var(--float-delay) infinite;
}
.rw-enter .floats {
  animation: rise 0.7s var(--ease) var(--rise-delay, 0s) backwards,
             var(--float) var(--float-dur) ease-in-out var(--float-delay) infinite;
}
.floats:nth-child(2) { --rise-delay: 0.06s; }
.floats:nth-child(3) { --rise-delay: 0.12s; }
.floats:nth-child(4) { --rise-delay: 0.18s; }
.floats:nth-child(5) { --rise-delay: 0.24s; }
.floats:nth-child(6) { --rise-delay: 0.30s; }

.floats--soft { --float: buoy-soft; }

/* No entrance, float only — for things already on screen. */
.floats--calm {
  animation: var(--float, buoy-soft) var(--float-dur, 12s) ease-in-out var(--float-delay, 0s) infinite;
}

.card { --float: buoy; --float-dur: 13s; }
.card:nth-child(2) { --float-dur: 15s;   --float-delay: -3.4s; }
.card:nth-child(3) { --float-dur: 11.5s; --float-delay: -7.1s; }
.card:nth-child(4) { --float-dur: 14.5s; --float-delay: -1.9s; }
.card:nth-child(5) { --float-dur: 12.5s; --float-delay: -5.6s; }
.card:nth-child(6) { --float-dur: 16s;   --float-delay: -9.2s; }

/* Hover uses `translate`, a separate property from `transform`, so the lift
   layers on top of the float instead of cancelling it. */
.card { transition: translate 0.32s var(--ease), border-color 0.3s, background 0.3s, box-shadow 0.3s; }
.card:hover { translate: 0 -5px; }

.action { --float: buoy-soft; --float-dur: 15s; }
.action:nth-child(2) { --float-dur: 17s;   --float-delay: -5.5s; }
.action:nth-child(3) { --float-dur: 13.5s; --float-delay: -10.2s; }
.action:nth-child(4) { --float-dur: 16s;   --float-delay: -2.7s; }

.advice__item { --float: buoy-soft; --float-dur: 14s; }
.advice__item:nth-child(2) { --float-dur: 16.5s; --float-delay: -6.3s; }
.advice__item:nth-child(3) { --float-dur: 12s;   --float-delay: -3.1s; }

.all-clear { --float: buoy-soft; --float-dur: 16s; }

.hero__meta .chip:nth-child(2) { --float-dur: 13s;   --float-delay: -4.2s; }
.hero__meta .chip:nth-child(3) { --float-dur: 9.5s;  --float-delay: -7.4s; }
.hero__meta .chip:nth-child(4) { --float-dur: 12.5s; --float-delay: -2.1s; }
.water-legend .water-cue:nth-child(2) { --float-dur: 13.5s; --float-delay: -5.8s; }
.water-legend .water-cue:nth-child(3) { --float-dur: 10.5s; --float-delay: -8.9s; }

.sibling:nth-child(2) { --float-dur: 14s;   --float-delay: -3.8s; }
.sibling:nth-child(3) { --float-dur: 10.5s; --float-delay: -6.9s; }
.sibling:nth-child(4) { --float-dur: 13s;   --float-delay: -1.4s; }
.sibling:nth-child(5) { --float-dur: 15s;   --float-delay: -9.6s; }
.sibling:nth-child(6) { --float-dur: 11s;   --float-delay: -5.2s; }

.fieldset { --float: buoy-soft; --float-dur: 18s; }
.fieldset:nth-child(2) { --float-dur: 20s;   --float-delay: -6.5s; }
.fieldset:nth-child(3) { --float-dur: 16.5s; --float-delay: -12.1s; }
.fieldset:nth-child(4) { --float-dur: 19s;   --float-delay: -3.3s; }

.stat:nth-child(2) { --float-delay: -2.8s; }
.stat:nth-child(3) { --float-delay: -5.6s; }
.stat:nth-child(4) { --float-delay: -8.4s; }
.stat:nth-child(5) { --float-delay: -11.2s; }

.sparkline     { --float-dur: 9s; }
.gauge__marker { --float-dur: 8s; }
.stat          { --float-dur: 14s; }
.sibling       { --float-dur: 12s; }
.hero__meta .chip,
.water-legend .water-cue { --float-dur: 11s; }

/* --- Surfaces catch the light ------------------------------------------ */

.panel::before,
.card::after,
.chart-panel::before { pointer-events: none; }

.panel:not(.hero)::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(105deg,
    transparent 38%,
    color-mix(in srgb, var(--text-primary) 5%, transparent) 48%,
    transparent 58%);
  background-size: 260% 100%;
  animation: sheen 17s linear infinite;
}

.action::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(105deg,
    transparent 40%,
    color-mix(in srgb, var(--tone-lit) 7%, transparent) 50%,
    transparent 60%);
  background-size: 240% 100%;
  animation: sheen 21s linear infinite;
}

/* The Bliss ring gets a slow halo turning behind it. */
.ring::before {
  content: "";
  position: absolute;
  inset: -6%;
  border-radius: 50%;
  pointer-events: none;
  background: conic-gradient(from 0deg,
    transparent 0deg,
    color-mix(in srgb, var(--tone-lit) 26%, transparent) 55deg,
    transparent 130deg,
    transparent 360deg);
  filter: blur(16px);
  opacity: 0.75;
  animation: shimmer-ring 24s linear infinite;
}

/* Gradient headlines drift along their own ramp. */
.hero__verdict {
  background-size: 220% 100%;
  animation: tide 19s ease-in-out infinite;
}

/* The wordmark's waves roll. */
.brand__mark path { animation: wave-roll 9s ease-in-out infinite; }
.brand__mark path:nth-of-type(2) { animation-duration: 11s; animation-delay: -2.5s; }
.brand__mark path:nth-of-type(3) { animation-duration: 13s; animation-delay: -5s; }

@keyframes wave-roll {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(1.6px); }
}

/* Sparklines rise and fall on the swell. */
.sparkline { animation: buoy-soft 9s ease-in-out infinite; }

/* Gauge markers bob against their rail. */
.gauge__marker { animation: buoy-soft 8s ease-in-out infinite; }

/* Stat tiles in the chart strip breathe together, one after another. */
.stat { animation: buoy-soft 14s ease-in-out infinite; }
.stat:nth-child(2) { animation-delay: -2.8s; }
.stat:nth-child(3) { animation-delay: -5.6s; }
.stat:nth-child(4) { animation-delay: -8.4s; }
.stat:nth-child(5) { animation-delay: -11.2s; }

@media (prefers-reduced-motion: reduce) {
  .ring::before, .panel:not(.hero)::before, .action::after { display: none; }
}

/* --- Simulator --------------------------------------------------------- */

.sim-panel { padding: 1.7rem 1.8rem; margin-bottom: 1.6rem; }

.sim-presets {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 1.4rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--hairline);
}
.sim-presets__label {
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 0.3rem;
}
.sim-presets .ghost-btn[aria-pressed="true"] {
  color: var(--text-primary);
  border-color: var(--m-orp);
  background: color-mix(in srgb, var(--m-orp) 12%, transparent);
}

.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 1.35rem 1.6rem;
}

.sim-control__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  min-height: 2.4em;
}
.sim-control__head label { flex: 1 1 auto; min-width: 0; }
.sim-control__head output { flex: 0 0 auto; white-space: nowrap; }
.sim-control__head label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sim-control__head output { font-size: 1.05rem; font-weight: 500; color: var(--text-primary); }
.sim-control__band { margin-top: 0.45rem; font-size: 0.72rem; color: var(--text-muted); }

.sim-control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    var(--m-orp) 0 var(--fill, 50%),
    color-mix(in srgb, var(--text-muted) 22%, transparent) var(--fill, 50%) 100%);
  outline: none;
  cursor: pointer;
}
.sim-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 3px solid var(--surface-1);
  box-shadow: 0 0 0 1px var(--hairline-lit), 0 4px 14px -4px rgba(0, 0, 0, 0.7);
  transition: transform 0.18s var(--ease);
}
.sim-control input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.14); }
.sim-control input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-primary);
  border: 3px solid var(--surface-1);
  box-shadow: 0 0 0 1px var(--hairline-lit);
}

#sim-readout { transition: opacity 0.18s; }
#sim-readout[aria-busy="true"] { opacity: 0.72; }

.sim-flag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  margin-bottom: 1.1rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--m-orp);
  background: color-mix(in srgb, var(--m-orp) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--m-orp) 28%, transparent);
}

/* --- Connect the sensor ------------------------------------------------ */

.connect-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 2.6rem;
  padding: 2.4rem 2.6rem;
}
.connect-hero__title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  font-weight: 400;
  font-variation-settings: "SOFT" 50, "WONK" 1, "opsz" 60;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0.5rem 0 0.9rem;
}
.connect-hero__body p { color: var(--text-secondary); max-width: 44ch; }
.connect-hero__body .primary-btn { margin-top: 1.6rem; }

.connect-steps { display: grid; gap: 1.15rem; align-content: start; }
.connect-steps li { display: flex; gap: 0.95rem; align-items: flex-start; }
.connect-steps__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px; height: 27px;
  flex: none;
  border-radius: 50%;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--m-orp);
  background: color-mix(in srgb, var(--m-orp) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--m-orp) 30%, transparent);
}
.connect-steps h3 { font-size: 0.97rem; font-weight: 600; }
.connect-steps p { margin-top: 0.28rem; font-size: 0.87rem; color: var(--text-secondary); }
.connect-steps em { font-style: italic; color: var(--text-primary); }

@media (max-width: 900px) {
  .connect-hero { grid-template-columns: 1fr; gap: 2rem; padding: 1.8rem 1.5rem; }
}
