/* Pool Commander — light glassmorphism UI */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

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

:root {
  /* Sky blue palette */
  --sky-50: #f0f9ff;
  --sky-100: #e0f2fe;
  --sky-200: #bae6fd;
  --sky-400: #38bdf8;
  --sky-600: #0284c7;
  --sky-700: #0369a1;
  --sky-900: #0c4a6e;

  /* Semantic aliases (referenced by app.js inline styles) */
  --bg: var(--sky-50);
  --text: var(--sky-900);
  --dim: var(--sky-700);
  --pool: var(--sky-600);
  --spa: #f97316;
  --cold: #0ea5e9;
  --mint: #10b981;
  --gold: #f59e0b;
  --red: #ef4444;
  --card: rgba(255,255,255,0.65);
  --card-2: rgba(186,230,253,0.5);
  --line: rgba(255,255,255,0.55);

  /* Glass */
  --glass-bg: rgba(255,255,255,0.65);
  --glass-border: rgba(255,255,255,0.6);
  --shadow: 0 8px 32px rgba(14,165,233,0.10);

  /* Layout */
  --nav-h: 72px;
  --input-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

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

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
  animation: bg-shift 24s ease-in-out infinite alternate;
}

@keyframes bg-shift {
  0%   { background: linear-gradient(160deg, #f0f9ff 0%, #e0f2fe 55%, #bae6fd 100%); }
  50%  { background: linear-gradient(160deg, #e0f2fe 0%, #bae6fd 55%, #f0f9ff 100%); }
  100% { background: linear-gradient(160deg, #bae6fd 0%, #f0f9ff 55%, #e0f2fe 100%); }
}

.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(12px + var(--safe-t)) 16px calc(var(--input-h) + var(--nav-h) + var(--safe-b) + 24px);
}

/* ── Top bar ── */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--sky-900);
}

.brand-with-icon {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(2,132,199,0.22);
  flex-shrink: 0;
}

.brand p {
  margin: 2px 0 0;
  font-size: 0.72rem;
  color: var(--dim);
  font-weight: 500;
}

/* Status pill */
.status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid transparent;
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-pill.live .dot { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.status-pill.live { color: #065f46; border-color: rgba(16,185,129,.3); background: rgba(16,185,129,.1); }
.status-pill.syncing .dot { background: var(--gold); animation: pulse 1.2s ease-in-out infinite; }
.status-pill.syncing { color: #78350f; border-color: rgba(245,158,11,.3); background: rgba(245,158,11,.1); }
.status-pill.dead .dot { background: var(--red); }
.status-pill.dead { color: #7f1d1d; border-color: rgba(239,68,68,.3); background: rgba(239,68,68,.1); }

/* User avatar */
.user-avatar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--dim);
  font-size: 0.72rem;
  font-weight: 600;
}

.user-avatar {
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.7);
  box-shadow: 0 2px 8px rgba(14,165,233,0.15);
}

.user-name-short {
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Offline banner */
.offline-banner {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.25);
  color: #b91c1c;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2rem;
  padding: .65rem 1rem;
  border-radius: 12px;
  margin: .5rem 0;
}
.offline-banner .banner-icon { font-size: 1.1rem; opacity: .7; }
.offline-banner .banner-main { font-size: .85rem; font-weight: 700; }
.offline-banner .banner-detail {
  font-size: .72rem;
  font-weight: 500;
  opacity: .75;
  letter-spacing: .02em;
}

.bridge-offline .switch { opacity: .4; pointer-events: none; }
.water-hero-temp.stale { opacity: .55; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* ── Pool Ring ── */
.pool-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 4px 0 20px;
}

.outdoor-weather,
.tomorrow-forecast {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--dim);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.outdoor-weather i,
.tomorrow-forecast i {
  color: #38bdf8;
  font-size: 0.85rem;
}

.tomorrow-forecast {
  margin-top: 5px;
}

.tomorrow-forecast i {
  color: #f59e0b;
}

.pool-ring {
  position: relative;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.9) 0%, rgba(186,230,253,0.65) 60%, rgba(56,189,248,0.3) 100%);
  border: 3px solid rgba(255,255,255,0.85);
  box-shadow: 0 0 0 1px rgba(56,189,248,0.2), 0 0 40px rgba(14,165,233,0.15), var(--shadow);
  animation: pool-breathe 6s ease-in-out infinite;
}

.pool-ring--pool {
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.9) 0%, rgba(186,230,253,0.65) 60%, rgba(2,132,199,0.25) 100%);
  box-shadow: 0 0 0 1px rgba(2,132,199,0.25), 0 0 40px rgba(2,132,199,0.15), var(--shadow);
  animation: pool-breathe-pool 6s ease-in-out infinite;
}

.pool-ring--spa {
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.9) 0%, rgba(254,215,170,0.55) 60%, rgba(249,115,22,0.22) 100%);
  box-shadow: 0 0 0 1px rgba(249,115,22,0.2), 0 0 40px rgba(249,115,22,0.12), var(--shadow);
  animation: pool-breathe-spa 6s ease-in-out infinite;
}

.pool-ring--spa-cold {
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.9) 0%, rgba(186,230,253,0.6) 55%, rgba(14,165,233,0.28) 100%);
  box-shadow: 0 0 0 1px rgba(14,165,233,0.28), 0 0 40px rgba(14,165,233,0.16), var(--shadow);
  animation: pool-breathe 6s ease-in-out infinite;
}

.pool-ring--save {
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.9) 0%, rgba(253,230,138,0.45) 60%, rgba(245,158,11,0.2) 100%);
  box-shadow: 0 0 0 1px rgba(245,158,11,0.2), 0 0 40px rgba(245,158,11,0.10), var(--shadow);
  animation: pool-breathe-save 6s ease-in-out infinite;
}

.pool-ring--summer {
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.9) 0%, rgba(253,230,138,0.45) 60%, rgba(245,158,11,0.2) 100%);
  box-shadow: 0 0 0 1px rgba(245,158,11,0.2), 0 0 40px rgba(245,158,11,0.10), var(--shadow);
  animation: pool-breathe-save 6s ease-in-out infinite;
}

.pool-ring--winter {
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.9) 0%, rgba(186,230,253,0.55) 60%, rgba(56,189,248,0.28) 100%);
  box-shadow: 0 0 0 1px rgba(56,189,248,0.25), 0 0 40px rgba(56,189,248,0.14), var(--shadow);
  animation: pool-breathe 6s ease-in-out infinite;
}

.pool-ring--manual {
  background: radial-gradient(circle at 40% 35%, rgba(255,255,255,0.9) 0%, rgba(226,232,240,0.55) 60%, rgba(100,116,139,0.22) 100%);
  box-shadow: 0 0 0 1px rgba(100,116,139,0.25), 0 0 40px rgba(100,116,139,0.10), var(--shadow);
  animation: pool-breathe 6s ease-in-out infinite;
}

@keyframes pool-breathe {
  0%,100% { box-shadow: 0 0 0 1px rgba(56,189,248,0.2), 0 0 40px rgba(14,165,233,0.12), var(--shadow); }
  50% { box-shadow: 0 0 0 8px rgba(56,189,248,0.07), 0 0 70px rgba(14,165,233,0.20), var(--shadow); }
}

@keyframes pool-breathe-pool {
  0%,100% { box-shadow: 0 0 0 1px rgba(2,132,199,0.25), 0 0 40px rgba(2,132,199,0.12), var(--shadow); }
  50% { box-shadow: 0 0 0 8px rgba(2,132,199,0.08), 0 0 70px rgba(2,132,199,0.22), var(--shadow); }
}

@keyframes pool-breathe-spa {
  0%,100% { box-shadow: 0 0 0 1px rgba(249,115,22,0.2), 0 0 40px rgba(249,115,22,0.10), var(--shadow); }
  50% { box-shadow: 0 0 0 8px rgba(249,115,22,0.07), 0 0 70px rgba(249,115,22,0.18), var(--shadow); }
}

@keyframes pool-breathe-save {
  0%,100% { box-shadow: 0 0 0 1px rgba(245,158,11,0.2), 0 0 40px rgba(245,158,11,0.08), var(--shadow); }
  50% { box-shadow: 0 0 0 8px rgba(245,158,11,0.06), 0 0 70px rgba(245,158,11,0.15), var(--shadow); }
}

.pool-ring-inner {
  text-align: center;
}

.water-hero-temp {
  color: var(--sky-900);
  font-size: 3.75rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.05em;
  display: block;
}

.water-hero-temp.cold-plunge-hero {
  color: var(--cold);
}

.water-hero-sub {
  margin-top: 6px;
  color: var(--dim);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.35;
}

.water-hero-loop {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-top: 3px;
  color: var(--dim);
  line-height: 1;
  opacity: .62;
}

.water-hero-loop-label {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.water-hero-loop strong {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.water-hero-loop[hidden] { display: none !important; }

/* Heat warning */
.heat-warning {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(249,115,22,.08);
  border: 1px solid rgba(249,115,22,.25);
  color: #c2410c;
  font-size: 0.78rem;
  line-height: 1.45;
  font-weight: 500;
}

/* IntelliCenter freeze / winter protection */
.winter-protection-banner {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(56,189,248,.12);
  border: 1px solid rgba(56,189,248,.35);
  color: #0369a1;
  font-size: 0.78rem;
  line-height: 1.45;
  font-weight: 600;
}
.winter-protection-banner i {
  margin-top: 2px;
  flex-shrink: 0;
  color: #0284c7;
}

/* ── Mode selector ── */
.mode-selector {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 6px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

@media (max-width: 480px) {
  .mode-selector {
    grid-template-columns: repeat(3, 1fr);
  }
}

.mode-btn {
  padding: 10px 4px 9px;
  border-radius: 16px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  transition: background .18s, color .18s, border-color .18s;
}

.mode-btn .mode-icon {
  font-size: 1rem;
  display: block;
  line-height: 1;
  margin-bottom: 3px;
}

.mode-btn .mode-hint {
  display: block;
  font-size: 0.52rem;
  font-weight: 600;
  color: var(--dim);
  margin-top: 2px;
  line-height: 1.3;
  opacity: 0.8;
}

.mode-btn.active[data-mode="seasonal"][data-season="summer"],
.mode-btn.active[data-mode="summer"] {
  background: rgba(245,158,11,.15);
  color: #92400e;
  border-color: rgba(245,158,11,.4);
}
.mode-btn.active[data-mode="seasonal"][data-season="winter"],
.mode-btn.active[data-mode="winter"] {
  background: rgba(56,189,248,.15);
  color: #0c4a6e;
  border-color: rgba(56,189,248,.4);
}
.mode-btn.active[data-mode="pool"] {
  background: rgba(2,132,199,.15);
  color: #0c4a6e;
  border-color: rgba(2,132,199,.35);
}
.mode-btn.active[data-mode="spa"][data-spa-entry="heat"],
.mode-btn.active[data-mode="spa"]:not([data-spa-entry]) {
  background: rgba(249,115,22,.15);
  color: #9a3412;
  border-color: rgba(249,115,22,.35);
}
.mode-btn.active[data-mode="spa"][data-spa-entry="cold"] {
  background: rgba(14,165,233,.15);
  color: #0c4a6e;
  border-color: rgba(14,165,233,.45);
}
.mode-btn.active[data-mode="manual"] {
  background: rgba(100,116,139,.15);
  color: #334155;
  border-color: rgba(100,116,139,.4);
}
.mode-btn.active .mode-hint { opacity: 1; }

/* Season modes — automation owns summer↔winter flips (locked, no user pick),
   but from spa/pool/manual/cold-plunge this tab is a live "return to season"
   control (see app.js switchToSeasonalMode), so only the locked state (already
   summer/winter, data-season-locked="1") gets the inert display-only look. */
.mode-btn--season {
  -webkit-user-select: none;
  user-select: none;
}
.mode-btn--season[data-season-locked="1"] {
  cursor: default;
}
.mode-btn--season:not(.active) {
  opacity: 0.55;
}
.mode-btn--season[data-season-locked="0"] {
  cursor: pointer;
  opacity: 0.85;
}
.mode-btn--season[data-season-locked="0"]:hover {
  opacity: 1;
  background: rgba(100,116,139,.08);
}

/* Switching affordance — command in flight / story.phase === "switching";
   the active mode button pulses instead of sitting idle while equipment settles. */
.mode-btn.switching {
  position: relative;
  animation: mode-switching-pulse 1.4s ease-in-out infinite;
}
.mode-btn.switching::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 8px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
}
@keyframes mode-switching-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245,158,11,.35); }
  50% { box-shadow: 0 0 0 6px rgba(245,158,11,0); }
}

/* ── Temp card ── */
.temp-card {
  border-radius: 24px;
  padding: 18px;
  margin-bottom: 14px;
}

.temp-card-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  margin-bottom: 10px;
}

.temp-display {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 12px;
}

.temp-val { font-size: 1.8rem; font-weight: 800; letter-spacing: -0.04em; }
.temp-val.pool-color { color: var(--pool); }
.temp-val.spa-color { color: var(--spa); }
.temp-val.cold-color { color: var(--cold); }
.temp-val.gold-color { color: var(--gold); }
.temp-sep { font-size: 1.1rem; color: var(--dim); }
.temp-unit { font-size: 1rem; color: var(--dim); font-weight: 500; }
.temp-eta { font-size: 0.72rem; color: var(--dim); margin-left: 8px; font-weight: 500; }

/* Current temp badge next to target */
.temp-now-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--pool);
  background: rgba(2,132,199,0.1);
  border: 1px solid rgba(2,132,199,0.2);
  border-radius: 20px;
  padding: 1px 8px;
  margin-left: 8px;
  vertical-align: middle;
}
.temp-now-badge.spa-badge { color: var(--spa); background: rgba(249,115,22,0.1); border-color: rgba(249,115,22,0.2); }
.temp-now-badge.cold-badge { color: var(--cold); background: rgba(14,165,233,0.12); border-color: rgba(14,165,233,0.28); }

/* Current temp marker on slider track */
.temp-current-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--mint);
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  pointer-events: none;
  z-index: 2;
}
.temp-current-marker .marker-label {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--mint);
  white-space: nowrap;
  background: white;
  border-radius: 4px;
  padding: 1px 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Heat/cool/ok status line below slider */
.temp-state {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-top: 8px;
  padding: 5px 10px;
  border-radius: 8px;
}
.temp-state i { font-size: 0.8rem; }
.temp-state.heating { color: #c2410c; background: rgba(249,115,22,0.1); }
.temp-state.cooling { color: var(--pool); background: rgba(56,189,248,0.12); }
.temp-state.ok { color: #065f46; background: rgba(16,185,129,0.1); }
.temp-state.warn { color: #92400e; background: rgba(245,158,11,0.12); }

/* Story detail line (cloud/story.py) — muted one-liner under the headline */
.temp-state-detail {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--dim);
  margin-top: 4px;
  padding: 0 2px;
  line-height: 1.35;
}

.summer-retarget-reason {
  margin-top: 4px;
  padding: 0 2px;
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.35;
}
.summer-retarget-reason i { margin-right: 3px; color: var(--gold); }

/* Pump status line */
.temp-pump {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--dim);
  margin-top: 5px;
  padding: 0 2px;
}
.temp-pump i { color: var(--pool); }

/* Single range slider */
.range-wrap {
  position: relative;
  padding: 8px 0 4px;
}

.range-wrap input[type=range] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 5px;
  background: var(--card-2);
  outline: none;
  cursor: pointer;
}

.range-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--pool);
  box-shadow: 0 2px 12px rgba(2,132,199,0.25);
  cursor: pointer;
}

.range-wrap input[type=range]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--pool);
  background: #fff;
  box-shadow: 0 2px 12px rgba(2,132,199,0.25);
  cursor: pointer;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.65rem;
  color: var(--dim);
  margin-top: 4px;
  font-weight: 600;
}

/* Pump speed slider — editable per product mode (capped ≤50% for cold plunge
   / whenever the chiller is on; 1–100% otherwise). */
.pump-speed-wrap input[type=range] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 5px;
  background: var(--card-2);
  outline: none;
  cursor: pointer;
}

.pump-speed-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--pool);
  box-shadow: 0 2px 10px rgba(2,132,199,0.25);
  cursor: pointer;
}

.pump-speed-wrap input[type=range]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--pool);
  background: #fff;
  box-shadow: 0 2px 10px rgba(2,132,199,0.25);
  cursor: pointer;
}

.pump-speed-wrap input[type=range]:active::-webkit-slider-thumb {
  border-color: var(--cold);
}

.pump-speed-wrap input[type=range]:active::-moz-range-thumb {
  border-color: var(--cold);
}

/* Dual-handle range slider */
.dual-range-wrap {
  position: relative;
  height: 36px;
  display: flex;
  align-items: center;
}

.dual-range-wrap .range-track {
  position: absolute;
  left: 0; right: 0;
  height: 5px;
  border-radius: 5px;
  background: var(--card-2);
  pointer-events: none;
}

.dual-range-wrap .range-fill {
  position: absolute;
  height: 5px;
  background: linear-gradient(to right, var(--gold), #fbbf24);
  border-radius: 5px;
  pointer-events: none;
}

.dual-range-wrap input[type=range] {
  position: absolute;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  background: transparent;
  outline: none;
  cursor: pointer;
  pointer-events: none;
}

.dual-range-wrap input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--gold);
  box-shadow: 0 2px 12px rgba(245,158,11,0.25);
  pointer-events: all;
  cursor: pointer;
}

.dual-range-wrap input[type=range]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: #fff;
  box-shadow: 0 2px 12px rgba(245,158,11,0.25);
  pointer-events: all;
  cursor: pointer;
}

/* Spa preset chips */
.spa-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.spa-preset-chip {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1.5px solid rgba(249,115,22,0.35);
  background: rgba(249,115,22,0.06);
  color: #9a3412;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.spa-preset-chip:hover { background: rgba(249,115,22,0.14); }
.spa-preset-chip.active {
  background: #f97316;
  color: #fff;
  border-color: #f97316;
}

.temp-mode-note {
  margin-top: 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--dim);
  line-height: 1.45;
}
.temp-mode-note.small {
  font-size: 0.7rem;
  opacity: 0.85;
  text-align: center;
}

/* ── Accessories ── */
.accessories {
  border-radius: 24px;
  overflow: hidden;
  margin-bottom: 14px;
}

.accessory-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(186,230,253,0.5);
  min-height: 60px;
  gap: 10px;
}

.accessory-row:last-child { border-bottom: none; }

.accessory-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--sky-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.accessory-icon {
  color: var(--pool);
  width: 16px;
}

/* Lights show panel */
.lights-show-wrap {
  flex: 1;
  padding: 8px 12px 4px 4px;
}
.lights-show-group { margin-bottom: 6px; }
.lights-show-group-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--dim);
  display: block;
  margin-bottom: 5px;
}
.lights-show-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.color-swatch.active { border-color: var(--sky-900); transform: scale(1.18); box-shadow: 0 2px 8px rgba(0,0,0,0.2); }
.color-swatch:active { transform: scale(0.92); }

/* Show buttons (text labels, not circles) */
.show-btn {
  width: auto;
  height: auto;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(14,165,233,0.08);
  color: var(--pool);
  border: 1.5px solid rgba(14,165,233,0.2);
}
.show-btn.active { background: var(--pool); color: white; border-color: var(--pool); }
.show-btn:active { transform: scale(0.95); }

/* Keep old .color-swatches for any legacy use */
.color-swatches {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  flex: 1;
  justify-content: flex-end;
  padding-right: 12px;
}

/* iOS-style switch */
.switch {
  position: relative;
  width: 51px;
  height: 31px;
  flex-shrink: 0;
  border: none;
  border-radius: 31px;
  background: #cbd5e1;
  cursor: pointer;
  transition: background .2s;
  padding: 0;
}

.switch.on { background: var(--pool); }

.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  transition: transform .2s cubic-bezier(.4,0,.2,1);
}

.switch.on::before { transform: translateX(20px); }
.switch.busy { opacity: .5; pointer-events: none; }

/* ── Status strip ── */
.status-strip {
  border-radius: 16px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 0.72rem;
  color: var(--dim);
  font-weight: 500;
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.status-strip-item { white-space: nowrap; }
.status-strip-item strong { color: var(--sky-900); font-weight: 700; }

.strip-link {
  color: var(--pool);
  text-decoration: none;
  font-weight: 700;
}

/* ── Section head ── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px 2px;
}

.section-head h2 {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
}

.section-hint {
  font-size: 0.65rem;
  color: var(--dim);
  font-weight: 600;
  opacity: 0.85;
}

/* ── Sparkline card ── */
.spark-card {
  border-radius: 20px;
  padding: 12px 10px 6px;
  margin-bottom: 14px;
}

.spark-plot {
  position: relative;
}

#spark-canvas {
  cursor: crosshair;
  touch-action: none;
}

.spark-tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 112px;
  max-width: 180px;
  padding: 7px 9px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.92);
  color: #e2e8f0;
  font-size: 11px;
  line-height: 1.35;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22);
  transform: translate(-50%, calc(-100% - 10px));
  white-space: nowrap;
}

.spark-tooltip[hidden] {
  display: none !important;
}

.spark-tooltip .spark-tip-temp {
  font-size: 13px;
  font-weight: 700;
  color: #7dd3fc;
  letter-spacing: -0.02em;
}

.spark-tooltip .spark-tip-meta {
  margin-top: 2px;
  color: #94a3b8;
}

.spark-tooltip .spark-tip-cooler {
  color: #38bdf8;
}

.spark-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 6px 4px 2px;
  font-size: 11px;
  color: #64748b;
}

.spark-legend a {
  color: #0369a1;
  text-decoration: none;
  font-weight: 600;
  margin-left: auto;
}

.spark-legend .spark-range {
  color: #0284c7;
  font-weight: 600;
}

.spark-legend .spark-cooler {
  color: #0ea5e9;
}

.spark-legend .spark-delta-up { color: #ea580c; }
.spark-legend .spark-delta-down { color: #0284c7; }
.spark-legend .spark-delta-flat { color: #64748b; }

/* ── Bottom dock ── */
.bottom-dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  background: rgba(240,249,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(186,230,253,0.6);
  padding: 10px 16px calc(10px + var(--safe-b));
}

.dock-inner {
  max-width: 430px;
  margin: 0 auto;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.85);
  border: 1.5px solid rgba(186,230,253,0.8);
  border-radius: 28px;
  padding: 4px 4px 4px 16px;
  box-shadow: 0 2px 12px rgba(14,165,233,0.08);
}

.input-row input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  min-width: 0;
  outline: none;
}

.input-row input::placeholder { color: #94a3b8; }

.btn-round {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 0.95rem;
}

.btn-mic {
  background: rgba(255,255,255,0.75);
  color: var(--dim);
  border: 1px solid rgba(186,230,253,0.8);
}

.btn-mic.active {
  background: rgba(16,185,129,.15);
  border-color: var(--mint);
  color: var(--mint);
}

.btn-send {
  background: linear-gradient(135deg, var(--pool), var(--sky-700));
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 16px rgba(2,132,199,0.28);
}

.btn-send:disabled { opacity: .45; }

.dock-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
}

.dock-links a {
  color: var(--dim);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.85;
}

.dock-links a:hover { opacity: 1; color: var(--pool); }

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--input-h) + var(--safe-b) + 20px);
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  z-index: 200;
  max-width: calc(100% - 32px);
  width: 380px;
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  transition: opacity .25s, transform .25s;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.ok  { background: rgba(16,185,129,.12); border: 1px solid rgba(16,185,129,.3); color: #065f46; }
.toast.err { background: rgba(239,68,68,.10);  border: 1px solid rgba(239,68,68,.3);  color: #991b1b; }
.toast.info { background: rgba(255,255,255,0.92); border: 1px solid rgba(186,230,253,0.7); color: var(--text); backdrop-filter: blur(8px); }

/* Refresh button */
.refresh-btn {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 0.75rem;
  padding: 4px 8px;
  cursor: pointer;
  font-family: inherit;
}

/* ── Advanced page ── */
.adv-shell {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  position: relative;
  z-index: 1;
}

.adv-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--pool);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 18px;
}

.adv-section {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.adv-section summary, .adv-section-head {
  padding: 14px 16px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid rgba(186,230,253,0.45);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.adv-section summary::-webkit-details-marker { display: none; }
.adv-section-head { cursor: default; }

.adv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  border-bottom: 1px solid rgba(186,230,253,0.35);
  font-size: 0.85rem;
  gap: 10px;
}

.adv-row:last-child { border-bottom: none; }
.adv-row-label { color: var(--dim); flex-shrink: 0; font-size: 0.78rem; font-weight: 500; }
.adv-row-value { text-align: right; word-break: break-all; }
.adv-row-value.on   { color: var(--mint); font-weight: 700; }
.adv-row-value.off  { color: var(--dim); }
.adv-row-value.warn { color: var(--gold); }

.adv-json {
  padding: 12px 16px;
  font-size: 0.7rem;
  color: var(--dim);
  font-family: "SF Mono", "Fira Code", monospace;
  white-space: pre-wrap;
  word-break: break-all;
  background: rgba(240,249,255,0.7);
  border-radius: 0 0 20px 20px;
}

.adv-link {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(2,132,199,.1);
  color: var(--pool);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
}

.circuit-on  { color: var(--mint); font-weight: 700; }
.circuit-off { color: var(--dim); }

@media (min-width: 430px) {
  .shell { padding-top: 24px; }
}
