:root {
  --bg: #16110e;
  --card: #221a15;
  --card-2: #2c221b;
  --line: #3a2d24;
  --text: #f6ede6;
  --muted: #b09a8a;
  --accent: #ff7a2f;
  --accent-2: #ffb347;
  --good: #6fcf97;
  --warn: #f2c94c;
  --bad: #ff6b6b;
  --radius: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 22px; }

.top { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 20px 6px; }
.top h1 { font-size: 20px; }
.unit { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-weight: 600; }

main { max-width: 520px; margin: 0 auto; padding: 0 18px; }
.tab { display: none; }
.tab.active { display: block; }

.banner { border-radius: 14px; padding: 12px 14px; margin: 10px 0; font-size: 15px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.banner[hidden] { display: none; }
.banner.error { background: #3a1b1b; color: #ffc9c9; border: 1px solid #5a2626; }
.banner.warn { background: #3a311b; color: #ffe8a8; border: 1px solid #5a4a26; }
.link { text-decoration: underline; color: inherit; flex: none; }

.dial-wrap { position: relative; width: min(74vw, 290px); aspect-ratio: 1; margin: 10px auto 6px; }
.dial { width: 100%; height: 100%; transform: rotate(-90deg); }
.dial circle { fill: none; stroke-width: 12; }
.track { stroke: var(--card-2); }
.ring { stroke: var(--accent); stroke-linecap: round; stroke-dasharray: 540.35; stroke-dashoffset: 540.35; transition: stroke-dashoffset .8s ease, stroke .4s; }
.ring.ready { stroke: var(--good); }
.dial-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.temp { font-size: 64px; font-weight: 300; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.status { color: var(--muted); font-size: 15px; padding: 0 24px; }
.status.on { color: var(--accent-2); }
.status.ready { color: var(--good); }

.power { display: block; width: 100%; margin: 14px 0; padding: 18px; border-radius: var(--radius); font-size: 19px; font-weight: 650; background: linear-gradient(135deg, var(--accent), #e8541c); color: #fff; box-shadow: 0 8px 24px #ff7a2f33; transition: transform .1s; }
.power:active { transform: scale(.98); }
.power.stop { background: var(--card-2); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.power.busy { opacity: .7; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.card[hidden] { display: none; }
.label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.target { display: flex; align-items: center; justify-content: space-between; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper .value { min-width: 72px; text-align: center; font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.round { width: 46px; height: 46px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line); font-size: 24px; line-height: 1; }
.round:active { background: var(--line); }

.toggles { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 10px; }
.toggle { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-weight: 550; color: var(--muted); }
.toggle[hidden] { display: none; }
.toggle .ico { font-size: 22px; filter: grayscale(1) opacity(.6); }
.toggle.on { background: #3a2616; border-color: #6a3f1f; color: var(--accent-2); }
.toggle.on .ico { filter: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 15px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0 20px; }
.stats > div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.stats .label { font-size: 11px; }
.stat { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.hint { color: var(--muted); font-size: 14px; margin: 8px 0 14px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.empty[hidden] { display: none; }
.list { display: flex; flex-direction: column; gap: 10px; }

.sched { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; }
.sched.off { opacity: .55; }
.sched .main { flex: 1; min-width: 0; }
.sched .when { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sched .mode { font-size: 13px; color: var(--accent-2); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.sched .meta { color: var(--muted); font-size: 14px; }
.sched .next { color: var(--text); font-size: 14px; margin-top: 4px; }

.switch { position: relative; width: 52px; height: 32px; flex: none; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.switch.on { background: var(--accent); border-color: var(--accent); }
.switch.on::after { transform: translateX(20px); background: #fff; }

.events .ev { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.events .ev time { color: var(--muted); flex: none; width: 92px; font-size: 13px; padding-top: 2px; }
.events .ev.error { color: #ffb4b4; }
.events .ev.warn { color: #ffe39a; }

.primary { background: var(--accent); color: #fff; border-radius: 12px; padding: 12px 18px; font-weight: 650; }
.primary.small { padding: 8px 14px; }
.ghost { padding: 12px 14px; color: var(--muted); }
.danger { color: var(--bad); padding: 12px 6px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #120e0bee; backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; padding: 10px 0 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); }
.tabs button span { font-size: 20px; filter: grayscale(1) opacity(.7); }
.tabs button.active { color: var(--accent-2); }
.tabs button.active span { filter: none; }

dialog { width: min(520px, 100vw); max-width: 100vw; max-height: 92dvh; margin: auto auto 0; border: 0; border-radius: 22px 22px 0 0; background: var(--card); color: var(--text); padding: 20px 18px calc(18px + env(safe-area-inset-bottom)); }
dialog::backdrop { background: #000a; }
dialog h2 { margin-bottom: 14px; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.field[hidden] { display: none; }
.field > span:first-child { color: var(--muted); }
.field input[type="time"], .field input[type="date"], .field input[type="text"] { background: var(--card-2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font: inherit; font-size: 17px; min-width: 0; }
.field input[type="text"] { width: 55%; }
.seg { display: flex; background: var(--card-2); border-radius: 12px; padding: 3px; margin: 8px 0; }
.seg label { flex: 1; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 9px 0; border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg input:checked + span { background: var(--line); color: var(--text); }
.days { display: flex; justify-content: space-between; gap: 6px; margin: 10px 0; }
.days[hidden] { display: none; }
.days button { flex: 1; aspect-ratio: 1; max-width: 46px; border-radius: 50%; background: var(--card-2); border: 1px solid var(--line); font-weight: 650; color: var(--muted); }
.days button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.actions { display: flex; align-items: center; gap: 6px; margin-top: 12px; }
.spacer { flex: 1; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #000d; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 15px; max-width: 90vw; z-index: 10; }
.toast[hidden] { display: none; }

.label[hidden] { display: none; }
.card .chips { margin-bottom: 12px; }
#ready-form .field { border-bottom: 0; padding: 4px 0 14px; }
#ready-form .power { margin: 6px 0 0; }
.ready-card { display: flex; flex-direction: column; gap: 4px; }
.ready-card .when { font-size: 28px; font-weight: 600; }
.ready-card .meta { color: var(--muted); }
.ready-card .danger { align-self: flex-start; padding-left: 0; }
.hint[hidden] { display: none; }

body.login { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.login-card h1 { font-size: 26px; }
.login-card input { width: 100%; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; font: inherit; font-size: 18px; }
.login-card .primary { width: 100%; padding: 14px; font-size: 17px; }
.login-card .banner { width: 100%; justify-content: center; }
