/* ddHome. Follows the phone's light/dark setting. Mobile first; a side rail on wide screens. */

:root {
  color-scheme: light dark;
  --bg: #f2f3f6;
  --bg-glow: #e7ecf5;
  --surface: #ffffff;
  --surface-2: #f4f5f8;
  --surface-3: #e9ebf0;
  --line: rgba(20, 24, 36, .08);
  --line-2: rgba(20, 24, 36, .14);
  --text: #12151b;
  --text-2: #4d5462;
  --muted: #7d8492;
  --accent: #2f6df6;
  --accent-soft: rgba(47, 109, 246, .12);
  --on-accent: #ffffff;
  --warm: #f5a524;
  --warm-2: #ffcf6e;
  --warm-ink: #3a2600;
  --warm-tile: linear-gradient(135deg, #ffe7b3, #ffd27a);
  --warm-fill: rgba(255, 190, 80, .55);
  --heat: #f06a2b;
  --heat-soft: rgba(240, 106, 43, .13);
  --cool: #2f8cf6;
  --cool-soft: rgba(47, 140, 246, .13);
  --water: #11a7c4;
  --water-soft: rgba(17, 167, 196, .13);
  --ok: #17a35b;
  --ok-soft: rgba(23, 163, 91, .13);
  --bad: #e5484d;
  --bad-soft: rgba(229, 72, 77, .12);
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 1px rgba(16, 24, 40, .03);
  --shadow-2: 0 10px 30px rgba(16, 24, 40, .12), 0 2px 6px rgba(16, 24, 40, .06);
  --nav-bg: rgba(255, 255, 255, .78);
  --scrim: rgba(10, 12, 18, .38);
  --r-tile: 22px;
  --r-card: 26px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --nav-h: 66px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d11;
    --bg-glow: #131924;
    --surface: #161a21;
    --surface-2: #1c2129;
    --surface-3: #262c36;
    --line: rgba(255, 255, 255, .07);
    --line-2: rgba(255, 255, 255, .13);
    --text: #eef1f6;
    --text-2: #b5bcc9;
    --muted: #8a92a1;
    --accent: #6d9bff;
    --accent-soft: rgba(109, 155, 255, .16);
    --on-accent: #0b0d11;
    --warm: #ffbb4a;
    --warm-2: #ffd27a;
    --warm-ink: #2b1c00;
    --warm-tile: linear-gradient(135deg, #ffd486, #f4b649);
    --warm-fill: rgba(255, 190, 80, .42);
    --heat: #ff8a4c;
    --heat-soft: rgba(255, 138, 76, .16);
    --cool: #5aa6ff;
    --cool-soft: rgba(90, 166, 255, .16);
    --water: #35c4de;
    --water-soft: rgba(53, 196, 222, .15);
    --ok: #3ccf82;
    --ok-soft: rgba(60, 207, 130, .15);
    --bad: #ff6b6f;
    --bad-soft: rgba(255, 107, 111, .15);
    --shadow-1: 0 0 0 1px rgba(255, 255, 255, .035) inset;
    --shadow-2: 0 18px 50px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .05) inset;
    --nav-bg: rgba(18, 21, 27, .78);
    --scrim: rgba(0, 0, 0, .55);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(900px 520px at 0% -10%, var(--bg-glow), transparent 70%) var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Google Sans", system-ui, sans-serif;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--accent); text-decoration: none; }
svg.i { width: 22px; height: 22px; flex: none; display: block; }
svg.i.sm { width: 18px; height: 18px; }
svg.i.xs { width: 15px; height: 15px; }
svg.i.lg { width: 26px; height: 26px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 12px; }

/* ---------- shell ---------- */

.app { display: flex; min-height: 100dvh; }
.rail { display: none; }
main {
  flex: 1;
  min-width: 0;
  padding: calc(var(--safe-t) + 14px) 16px calc(var(--nav-h) + var(--safe-b) + 28px);
  max-width: 1180px;
  margin: 0 auto;
  width: 100%;
}

.top { display: flex; align-items: flex-start; gap: 12px; margin: 4px 2px 18px; }
.top .hello { flex: 1; min-width: 0; }
.top h1 { font-size: 28px; line-height: 1.15; letter-spacing: -.02em; margin: 0; font-weight: 700; }
.top .sub { color: var(--text-2); margin-top: 4px; font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.top .sub span { display: inline-flex; align-items: center; gap: 5px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; overflow: hidden;
  background: var(--accent-soft); color: var(--accent); display: grid; place-items: center;
  font-weight: 700; font-size: 16px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line-2);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
  background: var(--surface); box-shadow: var(--shadow-1); border: 1px solid var(--line); color: var(--text-2);
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.chip.home .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.chip.away .dot { background: var(--warm); box-shadow: 0 0 0 3px rgba(245, 165, 36, .18); }
.chip.admin .dot { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chip.off .dot { background: var(--bad); }

/* bottom nav (phones) */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; justify-content: space-around; align-items: stretch;
  background: var(--nav-bg); backdrop-filter: saturate(1.6) blur(22px); -webkit-backdrop-filter: saturate(1.6) blur(22px);
  border-top: 1px solid var(--line);
}
.nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .01em; min-width: 0;
}
.nav button .pill { width: 56px; height: 30px; border-radius: 999px; display: grid; place-items: center; transition: background .25s var(--ease), color .25s; }
.nav button[aria-current="page"] { color: var(--text); }
.nav button[aria-current="page"] .pill { background: var(--accent-soft); color: var(--accent); }

@media (min-width: 900px) {
  .nav { display: none; }
  .rail {
    display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100dvh; width: 232px; flex: none;
    padding: 22px 14px; border-right: 1px solid var(--line);
  }
  .rail .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 4px 10px 18px; letter-spacing: -.01em; }
  .rail .brand img { width: 30px; height: 30px; border-radius: 9px; }
  .rail button {
    display: flex; align-items: center; gap: 14px; height: 46px; padding: 0 14px; border-radius: 14px;
    color: var(--text-2); font-weight: 600; text-align: left;
  }
  .rail button:hover { background: var(--surface-2); }
  .rail button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
  .rail .spacer { flex: 1; }
  main { padding: 30px 36px 48px; }
  .top h1 { font-size: 32px; }
}

/* ---------- sections ---------- */

.section { margin: 26px 0 0; }
.section:first-child { margin-top: 0; }
.sec-head { display: flex; align-items: center; gap: 10px; margin: 0 4px 12px; min-height: 32px; }
.sec-head h2 { font-size: 19px; margin: 0; font-weight: 700; letter-spacing: -.01em; flex: 1; min-width: 0; }
.sec-head .meta { color: var(--muted); font-size: 13px; font-weight: 500; }
.link-btn { color: var(--accent); font-weight: 600; font-size: 14px; padding: 6px 4px; border-radius: 10px; }

.toolbar { display: flex; gap: 10px; align-items: center; margin: 0 2px 16px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

.seg {
  display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface-3); gap: 2px; position: relative;
}
.seg button {
  height: 32px; padding: 0 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  transition: background .2s, color .2s, box-shadow .2s; display: inline-flex; align-items: center; gap: 6px;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg.big { width: 100%; padding: 4px; }
.seg.big button { flex: 1; height: 46px; font-size: 15px; justify-content: center; }

.btn {
  height: 40px; padding: 0 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface-3); color: var(--text);
  transition: transform .12s var(--ease), background .2s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.warm { background: var(--warm); color: var(--warm-ink); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.block { width: 100%; height: 48px; font-size: 15px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- tiles ---------- */

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; } }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }

.tile {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 92px; padding: 14px 14px 12px; border-radius: var(--r-tile);
  background: var(--surface); box-shadow: var(--shadow-1); border: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px; text-align: left;
  user-select: none; -webkit-user-select: none; touch-action: pan-y;
  transition: transform .15s var(--ease), background .25s, border-color .25s, color .25s;
}
.tile:active { transform: scale(.975); }
.tile .ic {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2); transition: background .25s, color .25s;
}
.tile .name { font-weight: 650; font-size: 14.5px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile .state { color: var(--muted); font-size: 12.5px; font-weight: 500; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .row1 { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tile .more {
  width: 30px; height: 30px; margin: -4px -4px 0 0; border-radius: 50%; display: grid; place-items: center; color: var(--muted);
}
.tile .fill {
  position: absolute; inset: 0; z-index: -1; transform-origin: left center;
  background: var(--warm-fill); transform: scaleX(var(--b, 0)); transition: transform .3s var(--ease); opacity: 0;
}
.tile.on { background: var(--warm-tile); border-color: transparent; color: var(--warm-ink); }
.tile.on .fill { opacity: 1; background: rgba(255, 255, 255, .28); }
.tile.on.dimmable { background: linear-gradient(135deg, #fff1d1, #ffe2a6); }
.tile.on.dimmable .fill { background: var(--warm-tile); }
.tile.on .ic { background: rgba(255, 255, 255, .55); color: #b26b00; }
.tile.on .state, .tile.on .more { color: rgba(58, 38, 0, .72); }
@media (prefers-color-scheme: dark) {
  .tile.on { background: linear-gradient(135deg, #b97a1d, #d39532); color: #fff7e8; }
  .tile.on.dimmable { background: #3a2d17; color: #fff7e8; }
  .tile.on.dimmable .fill { background: linear-gradient(135deg, #b97a1d, #d39532); }
  .tile.on .ic { background: rgba(255, 255, 255, .18); color: #ffe2a6; }
  .tile.on .state, .tile.on .more { color: rgba(255, 247, 232, .8); }
}
.tile.dragging .fill { transition: none; }
.tile.dragging { transform: none; }
.tile.busy::after {
  content: ""; position: absolute; top: 12px; right: 12px; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; opacity: .55; animation: spin .8s linear infinite;
}
.tile.locked { opacity: .55; }
.tile .bri {
  position: absolute; top: 12px; right: 14px; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity .2s;
}
.tile.dragging .bri { opacity: 1; }
.tile.dragging .more { opacity: 0; }
.tile.unavailable { opacity: .5; }

.tile.status { min-height: 84px; }
.tile.status .big { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tile.heat .ic { background: var(--heat-soft); color: var(--heat); }
.tile.cool .ic { background: var(--cool-soft); color: var(--cool); }
.tile.water .ic { background: var(--water-soft); color: var(--water); }
.tile.okc .ic { background: var(--ok-soft); color: var(--ok); }

@keyframes spin { to { transform: rotate(360deg); } }

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

.card {
  background: var(--surface); border-radius: var(--r-card); box-shadow: var(--shadow-1); border: 1px solid var(--line);
  padding: 18px;
}
.card + .card { margin-top: 12px; }
.card h3 { margin: 0 0 2px; font-size: 16px; font-weight: 700; }
.card .hint { color: var(--muted); font-size: 13px; }

.list { display: flex; flex-direction: column; }
.list .item {
  display: flex; align-items: center; gap: 14px; min-height: 58px; padding: 8px 2px; border-top: 1px solid var(--line);
}
.list .item:first-child { border-top: 0; }
.list .item .txt { flex: 1; min-width: 0; }
.list .item .t1 { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .item .t2 { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .item .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.list .item.clickable { cursor: pointer; }
.list .item .val { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* switch */
.switch {
  width: 52px; height: 32px; border-radius: 999px; background: var(--surface-3); position: relative; flex: none;
  transition: background .25s var(--ease); box-shadow: inset 0 0 0 1px var(--line);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .25); transition: transform .25s var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch.warm[aria-checked="true"] { background: var(--warm); }
.switch.heat[aria-checked="true"] { background: var(--heat); }
.switch.water[aria-checked="true"] { background: var(--water); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch[disabled] { opacity: .45; pointer-events: none; }

/* ---------- garage ---------- */

.garage {
  display: flex; align-items: center; gap: 16px; padding: 16px 16px 16px 18px;
}
.garage .gic {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; flex: none;
  background: var(--ok-soft); color: var(--ok);
}
.garage.open .gic { background: rgba(245, 165, 36, .16); color: var(--warm); }
.garage.moving .gic { background: var(--accent-soft); color: var(--accent); }
.garage.problem .gic { background: var(--bad-soft); color: var(--bad); }
.garage .txt { flex: 1; min-width: 0; }
.garage .t1 { font-size: 17px; font-weight: 700; }
.garage .t2 { color: var(--muted); font-size: 13.5px; }
.garage .btn { min-width: 96px; height: 44px; }
.garage .btn.confirm { background: var(--warm); color: var(--warm-ink); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { filter: brightness(1.12); } }

/* ---------- banners ---------- */

.banner {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 20px; margin-bottom: 14px;
  background: var(--accent-soft); color: var(--text); font-size: 14px;
}
.banner .i { color: var(--accent); margin-top: 1px; }
.banner.warm { background: rgba(245, 165, 36, .14); }
.banner.warm .i { color: var(--warm); }
.banner.bad { background: var(--bad-soft); }
.banner.bad .i { color: var(--bad); }
.banner b { font-weight: 650; }
.banner .acts { display: flex; gap: 8px; margin-top: 10px; }
.banner .acts .btn { height: 36px; }

/* ---------- climate ---------- */

.thermo { display: grid; gap: 18px; }
@media (min-width: 760px) { .thermo { grid-template-columns: minmax(300px, 1fr) minmax(280px, 1fr); align-items: start; } }
.dial-wrap { display: flex; flex-direction: column; align-items: center; padding: 6px 0 4px; }
.dial { position: relative; width: min(300px, 78vw); aspect-ratio: 1; }
.dial svg { width: 100%; height: 100%; display: block; }
.dial .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.dial .now-label { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.dial .now { font-size: 68px; font-weight: 300; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.dial .now sup { font-size: 26px; font-weight: 400; vertical-align: 32px; margin-left: 2px; }
.dial .act { margin-top: 8px; font-size: 14px; font-weight: 650; display: inline-flex; align-items: center; gap: 6px; }
.dial .act.heating { color: var(--heat); }
.dial .act.cooling { color: var(--cool); }
.dial .act.idle { color: var(--muted); }
.setpoints { display: flex; gap: 10px; justify-content: center; margin-top: 4px; flex-wrap: wrap; }
@media (max-width: 420px) {
  .setpoints .stepper button { width: 40px; height: 40px; }
  .setpoints .stepper .v { min-width: 62px; }
  .setpoints .stepper .v .n { font-size: 22px; }
  .setpoints { gap: 8px; }
}
.stepper.compact { padding: 4px; }
.stepper.compact button { width: 40px; height: 40px; }
.stepper.compact .v { min-width: 62px; }
.stepper.compact .v .n { font-size: 22px; }
.stepper.compact .v .l { display: none; }
.stepper {
  display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line);
}
.stepper button {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: var(--surface);
  box-shadow: var(--shadow-1); border: 1px solid var(--line); transition: transform .1s;
}
.stepper button:active { transform: scale(.92); }
.stepper .v { min-width: 78px; text-align: center; }
.stepper .v .n { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.1; }
.stepper .v .l { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stepper.heat .v .l { color: var(--heat); }
.stepper.cool .v .l { color: var(--cool); }
.stepper.water .v .l { color: var(--water); }
.stepper.pending .v .n { opacity: .55; }

.opt-row { display: flex; gap: 8px; flex-wrap: wrap; }
.opt {
  height: 40px; padding: 0 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line);
  font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 8px; color: var(--text-2);
}
.opt[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.opt.heat[aria-pressed="true"] { background: var(--heat); color: #fff; }
.opt.cool[aria-pressed="true"] { background: var(--cool); color: #fff; }
.opt-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 16px 2px 8px; }
.opt-label:first-child { margin-top: 0; }

.radio-list .item { cursor: pointer; }
.radio {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; position: relative; transition: border-color .2s;
}
.radio[aria-checked="true"] { border-color: var(--accent); }
.radio[aria-checked="true"]::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--accent); }
.tag { font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag.warm { background: rgba(245, 165, 36, .16); color: #b26b00; }
@media (prefers-color-scheme: dark) { .tag.warm { color: var(--warm); } }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.muted { background: var(--surface-3); color: var(--muted); }

.sensor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sensor { padding: 14px 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.sensor .room { font-weight: 650; font-size: 14px; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.sensor .vals { display: flex; gap: 6px 14px; flex-wrap: wrap; }
.sensor .v { display: flex; align-items: baseline; gap: 4px; }
.sensor .v .n { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sensor .v .u { color: var(--muted); font-size: 13px; font-weight: 600; }
.sensor .v svg { align-self: center; color: var(--muted); }

.weather { display: flex; align-items: center; gap: 16px; }
.weather .wic { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; background: var(--cool-soft); color: var(--cool); flex: none; }
.weather .t { font-size: 34px; font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.weather .d { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- cameras ---------- */

.cams { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .cams { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); } }
.cam {
  position: relative; border-radius: var(--r-card); overflow: hidden; background: #0d0f13; aspect-ratio: 16 / 9;
  box-shadow: var(--shadow-1); border: 1px solid var(--line); display: block; width: 100%; text-align: left;
}
.cam img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: opacity .4s; }
.cam .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, .35), transparent 30%, transparent 62%, rgba(0, 0, 0, .55)); }
.cam .label { position: absolute; left: 14px; bottom: 12px; right: 14px; color: #fff; display: flex; align-items: center; gap: 8px; font-weight: 650; text-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.cam .label .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cam .live { position: absolute; top: 12px; left: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; background: rgba(0, 0, 0, .45); color: #fff; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; backdrop-filter: blur(8px); }
.cam .live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #ff4d4f; }
.cam .live.idle::before { background: #aaa; }
.cam .play { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 54px; height: 54px; border-radius: 50%; background: rgba(0, 0, 0, .4); color: #fff; display: grid; place-items: center; backdrop-filter: blur(8px); opacity: .9; }
.cam .placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255, 255, 255, .4); }

.viewer { position: fixed; inset: 0; z-index: 60; background: #000; display: flex; flex-direction: column; animation: fade .2s; }
.viewer .vtop, .viewer .vbot { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 12px 14px; color: #fff; z-index: 2; }
.viewer .vtop { top: 0; padding-top: calc(var(--safe-t) + 12px); background: linear-gradient(180deg, rgba(0, 0, 0, .6), transparent); }
.viewer .vbot { bottom: 0; padding-bottom: calc(var(--safe-b) + 16px); background: linear-gradient(0deg, rgba(0, 0, 0, .7), transparent); justify-content: center; flex-wrap: wrap; }
.viewer .vtop .t { flex: 1; font-weight: 700; font-size: 17px; }
.viewer .vtop .s { font-size: 12.5px; opacity: .75; font-weight: 500; }
.viewer .round { width: 44px; height: 44px; border-radius: 50%; background: rgba(255, 255, 255, .16); display: grid; place-items: center; color: #fff; backdrop-filter: blur(10px); }
.viewer .round[aria-pressed="true"] { color: #ffcf4a; }
.viewer .stage { flex: 1; display: grid; place-items: center; position: relative; }
.viewer video, .viewer .stage img { width: 100%; height: 100%; object-fit: contain; background: #000; }
.viewer .vbot .btn { background: rgba(255, 255, 255, .16); color: #fff; backdrop-filter: blur(10px); }
.viewer .msg { position: absolute; color: rgba(255, 255, 255, .8); display: flex; align-items: center; gap: 10px; font-size: 14px; background: rgba(0, 0, 0, .45); padding: 8px 14px; border-radius: 999px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }

/* ---------- pool ---------- */

.pool-bodies { display: grid; gap: 12px; }
@media (min-width: 760px) { .pool-bodies { grid-template-columns: 1fr 1fr; } }
.body-card { position: relative; overflow: hidden; }
.body-card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(380px 200px at 0% 0%, color-mix(in srgb, var(--tc, var(--water)) 18%, transparent), transparent 70%);
}
.body-card.off::before { opacity: .35; }
.body-card .head { display: flex; align-items: center; gap: 10px; position: relative; }
.body-card .head h3 { flex: 1; margin: 0; font-size: 18px; }
.body-card .reading { display: flex; align-items: flex-end; gap: 14px; margin: 14px 0 16px; position: relative; }
.body-card .temp { font-size: 64px; font-weight: 300; letter-spacing: -.04em; line-height: .9; font-variant-numeric: tabular-nums; color: var(--tc, var(--text)); }
.body-card.off .temp { color: var(--muted); }
.body-card .temp sup { font-size: 24px; vertical-align: 30px; font-weight: 400; }
.body-card .cap { color: var(--text-2); font-size: 14px; padding-bottom: 6px; }
.body-card .cap b { color: var(--heat); }
.body-card .ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0 0; border-top: 1px solid var(--line); position: relative; }
.body-card .ctl-row + .ctl-row { margin-top: 12px; }
.body-card .ctl-row .lbl { font-weight: 600; display: flex; align-items: center; gap: 10px; }
.body-card .ctl-row .lbl small { display: block; color: var(--muted); font-weight: 500; font-size: 12.5px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.stat { padding: 12px 14px; border-radius: 18px; background: var(--surface-2); }
.stat .k { color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 22px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat .v small { font-size: 13px; color: var(--muted); font-weight: 600; margin-left: 3px; }

/* ---------- wifi ---------- */

.net { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .net { grid-template-columns: auto 1fr; align-items: center; } }
.qr { width: 172px; height: 172px; border-radius: 18px; background: #fff; padding: 10px; justify-self: center; box-shadow: var(--shadow-1); }
.qr img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.kv { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 14px; align-items: center; }
.kv .k { color: var(--muted); font-size: 13px; font-weight: 600; }
.kv .v { font-weight: 650; font-size: 16px; word-break: break-all; font-variant-numeric: tabular-nums; }
.kv .v.secret { letter-spacing: .12em; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--text-2); background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }

/* ---------- sheets ---------- */

.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 50; animation: fade .2s; }
.sheet {
  position: fixed; z-index: 51; left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 28px 28px 0 0; box-shadow: var(--shadow-2);
  padding: 10px 20px calc(var(--safe-b) + 22px); animation: up .32s var(--ease);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto 12px; }
.sheet .sh-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.sheet .sh-head h2 { flex: 1; margin: 0; font-size: 20px; letter-spacing: -.01em; }
.sheet .sh-head .sub { color: var(--muted); font-size: 13px; font-weight: 500; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; width: min(560px, 92vw); max-height: 86dvh; transform: translate(-50%, -50%); border-radius: 28px; padding: 22px 24px 24px; animation: pop .25s var(--ease); }
  .sheet .grab { display: none; }
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { transform: translate(-50%, -47%) scale(.97); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.vslider-wrap { display: flex; justify-content: center; padding: 6px 0 18px; }
.vslider {
  position: relative; width: 112px; height: min(300px, 42dvh); border-radius: 34px; overflow: hidden; touch-action: none;
  background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--line); cursor: ns-resize;
}
.vslider .lvl { position: absolute; left: 0; right: 0; bottom: 0; background: var(--warm-tile); height: calc(var(--v) * 1%); transition: height .12s; }
.vslider.dragging .lvl { transition: none; }
.vslider .pct { position: absolute; left: 0; right: 0; top: 16px; text-align: center; font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; mix-blend-mode: normal; }
.vslider .bulb { position: absolute; left: 0; right: 0; bottom: 16px; display: grid; place-items: center; color: var(--warm-ink); }

.ct-bar { height: 44px; border-radius: 14px; position: relative; background: linear-gradient(90deg, #ffb25b, #ffe1b8 45%, #fff 60%, #cfe3ff); touch-action: none; box-shadow: inset 0 0 0 1px var(--line); cursor: ew-resize; }
.ct-bar .knob { position: absolute; top: 4px; bottom: 4px; width: 10px; margin-left: -5px; left: calc(var(--p) * 100%); border-radius: 6px; background: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 42px; height: 42px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); transition: transform .12s; }
.swatch:active { transform: scale(.9); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent); }

.form { display: grid; gap: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 0 2px 6px; text-transform: uppercase; letter-spacing: .06em; }
.field input, .field select, .field textarea {
  width: 100%; height: 46px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface-2); padding: 0 14px; font-size: 16px; outline: none;
}
.field textarea { height: auto; min-height: 80px; padding: 12px 14px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .help { color: var(--muted); font-size: 12.5px; margin: 6px 2px 0; }
.checks { display: grid; gap: 2px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 16px; padding: 4px 12px; }
.checks label { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 500; border-top: 1px solid var(--line); }
.checks label:first-child { border-top: 0; }
.checks label small { color: var(--muted); margin-left: auto; font-size: 12px; }
.checks input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.row-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; flex-wrap: wrap; }

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

.empty { text-align: center; padding: 36px 18px; color: var(--muted); }
.empty .ic { width: 64px; height: 64px; border-radius: 22px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.empty h3 { color: var(--text); margin: 0 0 6px; font-size: 17px; }
.empty p { margin: 0 auto; max-width: 340px; font-size: 14px; }

.toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { .toast-host { bottom: 28px; } }
.toast { background: #1d2129; color: #fff; padding: 12px 18px; border-radius: 16px; font-size: 14px; font-weight: 550; box-shadow: var(--shadow-2); animation: up .25s var(--ease); max-width: 440px; display: flex; gap: 10px; align-items: center; }
@media (prefers-color-scheme: dark) { .toast { background: #e9ecf2; color: #12151b; } }
.toast.bad svg { color: var(--bad); }

.conn { position: fixed; top: calc(var(--safe-t) + 8px); left: 50%; transform: translateX(-50%); z-index: 70; }

.signin { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.signin .box { width: min(400px, 100%); text-align: center; }
.signin .logo { width: 84px; height: 84px; border-radius: 26px; margin: 0 auto 20px; box-shadow: var(--shadow-2); }
.signin h1 { font-size: 30px; margin: 0 0 6px; letter-spacing: -.02em; }
.signin p { color: var(--text-2); margin: 0 0 26px; }
.gbtn { display: inline-flex; align-items: center; justify-content: center; gap: 12px; height: 52px; width: 100%; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-2); font-weight: 650; font-size: 16px; color: var(--text); box-shadow: var(--shadow-1); }
.gbtn svg { width: 20px; height: 20px; }
.signin .err { margin-top: 18px; color: var(--bad); background: var(--bad-soft); padding: 12px 14px; border-radius: 14px; font-size: 14px; }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-tile); min-height: 92px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.fav-edit .tile { animation: wiggle .3s ease-in-out infinite alternate; }
@keyframes wiggle { from { transform: rotate(-.6deg); } to { transform: rotate(.6deg); } }
.fav-x { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border-radius: 50%; background: var(--bad); color: #fff; display: grid; place-items: center; z-index: 3; }

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

/* quick-control cards on Home */
.quick { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.quick .q-head { display: flex; align-items: center; gap: 12px; color: var(--muted); cursor: pointer; }
.quick .q-head h3 { flex: 1; margin: 0; color: var(--text); font-size: 16px; }
.quick .ic { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); }
.quick .ic.water { background: var(--water-soft); color: var(--water); }
.quick .ic.heat { background: var(--heat-soft); color: var(--heat); }
.quick .ic.cool { background: var(--cool-soft); color: var(--cool); }
.quick .q-temps { display: flex; gap: 28px; }
.quick .qt { font-size: 34px; font-weight: 600; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.quick .ql { color: var(--muted); font-size: 13px; font-weight: 500; margin-top: 4px; }
.quick .q-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.quick .q-steps { display: flex; gap: 8px; flex-wrap: wrap; }
.quick .seg.big button { height: 40px; }
.field .checks label { text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--text); margin: 0; font-weight: 500; }
.field .checks label small { text-transform: none; letter-spacing: 0; }
@media (max-width: 420px) {
  .top h1 { font-size: 26px; }
  .opt-row .opt { flex: 1 1 0; min-width: 0; flex-direction: column; height: 62px; gap: 4px; justify-content: center; padding: 0 6px; font-size: 13px; }
}
.stepper.mini { padding: 4px; }
.stepper.mini button { width: 38px; height: 38px; }
.stepper.mini .v { min-width: 58px; }
.stepper.mini .v .n { font-size: 20px; }
.stepper.mini .v .l { font-size: 9.5px; }
.quick .q-row { flex-direction: column; align-items: stretch; }
.quick .q-steps { justify-content: flex-start; }
