:root {
  --bg: #0b1a24;
  --bg2: #102633;
  --card: #132e3d;
  --line: #1f4254;
  --text: #e8f3f6;
  --muted: #86a8b5;
  --water: #4fd1d9;
  --heat: #ff9a52;
  --heat2: #ff6b3d;
  --ok: #5fe0a0;
  --bad: #ff6b6b;
  --r: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); min-height: 100%; }
body { padding: env(safe-area-inset-top) 0 calc(76px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }
.wrap { max-width: 520px; margin: 0 auto; padding: 14px 16px 24px; }

/* header */
.top { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
.top h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.top .sub { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.dot.off { background: var(--bad); }
.top .grow { flex: 1; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 600; }

/* gauge */
.gauge { position: relative; width: min(78vw, 290px); aspect-ratio: 1; margin: 6px auto 0; }
.gauge svg { width: 100%; height: 100%; transform: rotate(135deg); }
.gauge .center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.gauge .now { font-size: 76px; font-weight: 300; letter-spacing: -.04em; line-height: 1; }
.gauge .now small { font-size: 26px; vertical-align: top; margin-left: 2px; color: var(--muted); }
.gauge .lbl { color: var(--muted); font-size: 13px; margin-top: 6px; }
.state { text-align: center; font-size: 15px; margin: -18px 0 14px; min-height: 22px; }
.state.heating { color: var(--heat); }
.state.ready { color: var(--ok); }
.target { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 18px; }
.target button { width: 54px; height: 54px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); font-size: 28px; line-height: 1; }
.target button:active { background: var(--line); }
.target .val { text-align: center; min-width: 96px; }
.target .val b { font-size: 32px; font-weight: 600; }
.target .val div { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; text-align: left; min-height: 84px; display: flex; flex-direction: column; justify-content: space-between; transition: background .15s, border-color .15s; }
.tile .ic { font-size: 22px; }
.tile .nm { font-weight: 600; }
.tile .st { font-size: 13px; color: var(--muted); }
.tile.on { background: linear-gradient(160deg, #18566a, #134357); border-color: #2a7d93; }
.tile.on.heat { background: linear-gradient(160deg, #6a3a1c, #4d2a17); border-color: #a85a2a; }
.tile.on .st { color: var(--text); }
.tile:disabled { opacity: .5; }
.tile.busy { opacity: .6; }
.btn { display: block; width: 100%; padding: 14px; border-radius: 14px; background: var(--water); color: #04222a; font-weight: 700; text-align: center; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.danger { background: transparent; color: var(--bad); border: 1px solid #5a2a32; font-weight: 600; }
.btn.small { display: inline-block; width: auto; padding: 8px 14px; font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-top: 14px; }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.card .hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.err { background: #3a1a22; border: 1px solid #6b2b36; color: #ffc9cf; padding: 10px 12px; border-radius: 12px; font-size: 14px; margin-bottom: 10px; }
.spark { width: 100%; height: 56px; display: block; }

/* forms */
label.f { display: block; margin-bottom: 12px; }
label.f span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
input, select { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); font-size: 16px; }
input:focus, select:focus { outline: 2px solid var(--water); outline-offset: -1px; }
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--line); color: var(--text); }
.days { display: flex; gap: 6px; margin-bottom: 12px; }
.days button { flex: 1; aspect-ratio: 1; max-width: 44px; border-radius: 50%; border: 1px solid var(--line); font-weight: 600; font-size: 14px; color: var(--muted); }
.days button.on { background: var(--water); color: #04222a; border-color: var(--water); }

/* lists */
.list { margin-top: 10px; }
.item { display: flex; gap: 12px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .main { flex: 1; min-width: 0; }
.item .t { font-weight: 600; }
.item .d { color: var(--muted); font-size: 13px; margin-top: 2px; }
.item .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.sw { width: 50px; height: 30px; border-radius: 15px; background: var(--line); position: relative; flex: none; transition: background .15s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.sw.on { background: var(--water); }
.sw.on::after { transform: translateX(20px); }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }
h2.sec { font-size: 26px; letter-spacing: -.02em; margin: 6px 0 4px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--line); color: var(--muted); margin-left: 6px; vertical-align: 2px; }

/* tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(11, 26, 36, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); display: flex; padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
.tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; padding: 4px 0; }
.tabs button svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--water); }

/* sheet */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet .panel { background: var(--bg2); width: 100%; max-width: 520px; border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; animation: up .2s ease-out; }
.sheet .panel h3 { margin: 0 0 14px; font-size: 19px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(88px + env(safe-area-inset-bottom)); background: #e8f3f6; color: #0b1a24; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 20; max-width: 90vw; }
.toast.bad { background: var(--bad); color: #fff; }

/* login */
.login { padding-top: 8vh; text-align: center; }
.login h1 { font-size: 30px; margin: 12px 0 4px; }
.login p { color: var(--muted); margin: 0 0 24px; }
.login form { max-width: 380px; margin: 0 auto; }
.logo { width: 72px; height: 72px; }
