:root {
  --bg: #f6f3ef;
  --card: #ffffff;
  --text: #1d1a16;
  --muted: #6f675e;
  --line: #e4ddd4;
  --off: #d9d3cb;
  --off-text: #4a443d;
  --hot: #f0642a;
  --hot-2: #ff8a3d;
  --hot-text: #ffffff;
  --error: #c0362c;
  --banner-bg: #fbe6df;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --card: #221e19;
    --text: #f3eee8;
    --muted: #a59c91;
    --line: #3a342d;
    --off: #3a342d;
    --off-text: #d9d3cb;
    --hot: #f0642a;
    --hot-2: #ff8a3d;
    --error: #ff7b6e;
    --banner-bg: #3d211b;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
main {
  max-width: 420px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(env(safe-area-inset-top) + 20px) 20px calc(env(safe-area-inset-bottom) + 20px);
  display: flex;
  flex-direction: column;
}
.screen { flex: 1; display: flex; flex-direction: column; }
.screen[hidden] { display: none; }
h1 { font-size: 28px; margin: 8px 0 8px; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* PIN screens */
.pin-form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.pin-form label { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--muted); }
.pin-form input {
  font-size: 28px;
  letter-spacing: 0.3em;
  text-align: center;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  width: 100%;
}
.pin-form input:focus { outline: 2px solid var(--hot); outline-offset: 1px; }
.error { color: var(--error); min-height: 1.4em; margin: 0; font-size: 15px; }
button { font: inherit; cursor: pointer; }
.primary {
  background: var(--hot);
  color: var(--hot-text);
  border: 0;
  border-radius: 14px;
  padding: 16px;
  font-weight: 600;
}
.primary:disabled { opacity: 0.6; }
.link { background: none; border: 0; color: var(--muted); padding: 10px; text-decoration: underline; }

/* main screen */
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.updated { font-size: 13px; color: var(--muted); }
.banner {
  background: var(--banner-bg);
  color: var(--error);
  border-radius: 12px;
  padding: 10px 14px;
  margin: 4px 0 0;
  font-size: 15px;
}
.power-wrap { display: flex; flex-direction: column; align-items: center; margin: 28px 0 12px; }
.power {
  width: 168px;
  height: 168px;
  border-radius: 50%;
  border: 0;
  background: var(--off);
  color: var(--off-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: background 0.25s, box-shadow 0.25s, transform 0.1s;
}
.power svg { width: 46px; height: 46px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.power:active { transform: scale(0.97); }
.power.on {
  background: radial-gradient(circle at 35% 30%, var(--hot-2), var(--hot));
  color: var(--hot-text);
  box-shadow: 0 10px 40px -8px rgba(240, 100, 42, 0.65);
}
.power.busy { opacity: 0.6; }
.state { margin: 16px 0 0; color: var(--muted); }
.note {
  margin: 10px 0 0;
  font-size: 14px;
  text-align: center;
  color: var(--text);
  background: var(--banner-bg);
  border-radius: 12px;
  padding: 8px 12px;
}
#screen-loading { justify-content: center; gap: 16px; }

.temp {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 14px;
  margin-top: 18px;
}
.step {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 32px;
  line-height: 1;
}
.step:active { background: var(--line); }
.step:disabled { opacity: 0.35; }
.temp-value { font-size: 64px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.temp-value .unit { font-size: 24px; color: var(--muted); margin-left: 2px; vertical-align: super; }
.temp.pending .temp-value { color: var(--hot); }
.foot { margin-top: auto; padding-top: 32px; display: flex; justify-content: center; gap: 16px; }

/* schedule list */
.sched { margin-top: 30px; }
.sched-head { display: flex; align-items: center; justify-content: space-between; }
.sched-head h2 { font-size: 20px; margin: 0; }
.pill {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 600;
  font-size: 15px;
}
.pill:disabled { opacity: 0.4; }
.sched-next { margin: 10px 0 0; font-weight: 600; color: var(--hot); font-size: 15px; }
.sched-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.sched-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 4px 14px 4px 4px;
}
.sched-item.paused .sched-main { opacity: 0.55; }
.sched-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  background: none;
  border: 0;
  color: var(--text);
  padding: 10px 10px;
  border-radius: 14px;
}
.sched-main:active { background: var(--bg); }
.sched-days { font-weight: 600; }
.sched-times { font-size: 15px; }
.sched-meta { font-size: 13px; color: var(--muted); }
.sched-meta.warn { color: var(--error); }

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--off);
  transition: background 0.2s;
}
.switch .slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}
.switch input:checked + .slider { background: var(--hot); }
.switch input:checked + .slider::after { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--hot); outline-offset: 2px; }

/* schedule editor */
.sched-form { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.sched-form fieldset { border: 0; padding: 0; margin: 0; }
.sched-form legend { font-size: 15px; color: var(--muted); margin-bottom: 8px; }
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.day {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 0;
  font-size: 14px;
  font-weight: 600;
}
.day[aria-pressed="true"] { background: var(--hot); border-color: var(--hot); color: var(--hot-text); }
.presets { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.preset {
  border: 0;
  background: none;
  color: var(--hot);
  font-size: 15px;
  font-weight: 600;
  padding: 6px 4px;
}
.opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px 12px 10px 14px;
  min-height: 60px;
}
.opt.sub { margin-top: -10px; margin-left: 22px; }
.opt.off { opacity: 0.45; }
.check { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.check input { width: 22px; height: 22px; accent-color: var(--hot); margin: 0; }
.opt input[type="time"] {
  font: inherit;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  min-width: 104px;
}
.opt input[type="time"].unused { visibility: hidden; }
.mini-step { display: flex; align-items: center; gap: 10px; }
.step.small { width: 40px; height: 40px; font-size: 22px; }
.mini-value { font-size: 20px; font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: center; }
.danger {
  background: none;
  border: 1px solid var(--error);
  color: var(--error);
  border-radius: 14px;
  padding: 14px;
  font-weight: 600;
}
