:root {
  --bg: #f4f5f7; --fg: #15171a; --muted: #6b7078; --card: #ffffff; --line: rgba(0, 0, 0, .12);
  --closed: #1d9e75; --open: #d98324; --moving: #378add; --stop: #e24b4a; --unknown: #8a9099;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14161a; --fg: #eef0f3; --muted: #9aa0a8; --card: #1e2126; --line: rgba(255, 255, 255, .14); }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
[hidden] { display: none !important; }

.view {
  min-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: max(20px, env(safe-area-inset-top)) 24px max(28px, env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto;
}
header { width: 100%; display: flex; justify-content: space-between; align-items: baseline; }
h1 { font-size: 20px; font-weight: 600; margin: 0; }
.conn { font-size: 13px; color: var(--muted); }
.conn.ok::before { content: "● "; color: var(--closed); }
.conn.bad::before { content: "● "; color: var(--stop); }

.pic { width: min(70vw, 260px); margin-top: 4vh; }
.pic-house { fill: var(--card); stroke: var(--line); stroke-width: 1.5; }
.pic-opening { fill: var(--bg); }
.pic-door { fill: var(--tone); transition: fill .3s; }
.pic-lines { stroke: rgba(255, 255, 255, .35); stroke-width: 1.5; }
#panel { transition: transform .5s linear; }

.tone-closed { --tone: var(--closed); }
.tone-open { --tone: var(--open); }
.tone-moving { --tone: var(--moving); }
.tone-unknown { --tone: var(--unknown); }

.phase { font-size: 30px; font-weight: 700; margin: 8px 0 0; color: var(--tone); }
.sub { font-size: 15px; color: var(--muted); margin: 0; font-variant-numeric: tabular-nums; }
.bar { width: 70%; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--moving); transition: width .5s linear; }

.btn {
  margin-top: auto; width: 100%; min-height: 76px; border-radius: 20px; border: 0;
  font-size: 22px; font-weight: 650; color: #fff; background: var(--fg); cursor: pointer;
  transition: transform .08s, background-color .15s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.armed, .btn.stop { background: var(--stop); }
.btn.busy { opacity: .6; }
@media (prefers-color-scheme: dark) { .btn { color: #15171a; } .btn.armed, .btn.stop { color: #fff; } }

.msg { min-height: 1.3em; font-size: 14px; color: var(--muted); margin: 0; text-align: center; }
.msg.err { color: var(--stop); }

#enroll p { line-height: 1.45; }
#enroll form { width: 100%; display: flex; flex-direction: column; gap: 12px; }
#enroll input {
  width: 100%; font-size: 17px; padding: 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); -webkit-user-select: text; user-select: text;
}
#enroll .btn { margin-top: 8px; }
