:root {
  --bg: #f4f1ec;
  --card: #fffdf9;
  --ink: #1c2321;
  --muted: #66706c;
  --line: #e2ddd3;
  --accent: #1f4d46;
  --on-accent: #ffffff;
  --warm: #c8551f;
  --good: #2e8b57;
  --bad: #b3261e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161a19;
    --card: #1f2523;
    --ink: #eceeea;
    --muted: #9aa5a0;
    --line: #313937;
    --accent: #8fd0c2;
    --on-accent: #10201d;
    --warm: #f0935f;
    --good: #6fcf97;
    --bad: #ff8a80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main {
  max-width: 30rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(env(safe-area-inset-bottom, 0px) + 32px);
  display: grid;
  gap: 14px;
}
[hidden] { display: none !important; }
h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
h2 { margin: 10px 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0; }

header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.contact { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.contact.online .dot { background: var(--good); }
.contact.offline { color: var(--bad); }
.contact.offline .dot { background: var(--bad); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 14px; }
.label { font-size: 14px; color: var(--muted); }
.detail { font-size: 14px; color: var(--muted); }

.now { grid-template-columns: auto 1fr; align-items: end; gap: 20px; }
.big { font-size: 64px; line-height: 1; font-weight: 700; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; }
.now-side { display: grid; gap: 4px; justify-items: end; text-align: right; padding-bottom: 4px; }
.state { font-size: 19px; font-weight: 600; }
.state.heating { color: var(--warm); }

.notice { padding: 11px 14px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: 15px; }
.notice.bad { border-color: var(--bad); color: var(--bad); }
.notice.busy::before {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 9px; vertical-align: -1px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .notice.busy::before { animation: none; } }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

button, input { font: inherit; color: inherit; }
button {
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: transparent; cursor: pointer; touch-action: manipulation; white-space: nowrap; flex: none;
}
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.wide { width: 100%; }
button.link { border: 0; padding: 0; min-height: 32px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; justify-self: start; }

.segments { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.segments button { border: 0; border-radius: 0; min-width: 48px; padding: 0 14px; }
.segments button + button { border-left: 1px solid var(--line); }
.segments button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }

.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 44px; padding: 0; font-size: 22px; line-height: 1; }
.stepper output { min-width: 3.2ch; text-align: center; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }

.events { list-style: none; margin: 0; padding: 0; display: grid; }
.events li { display: grid; grid-template-columns: 5.2rem 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.events time { color: var(--muted); font-variant-numeric: tabular-nums; }
.events .empty { display: block; color: var(--muted); }

form.card label { font-size: 14px; color: var(--muted); }
input[type="password"] { min-height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); width: 100%; }
.error { color: var(--bad); font-size: 14px; min-height: 1.45em; }
footer { display: grid; justify-items: center; gap: 4px; padding-top: 6px; }
footer button.link { justify-self: center; }
.notice a, footer a { color: inherit; text-underline-offset: 3px; white-space: nowrap; }
