:root {
  --bg: #f4f6fa; --card: #ffffff; --text: #16233a; --muted: #6b778c; --line: #dde3ee;
  --accent: #2f6fed; --red: #d93a3a; --green: #1f9d55; --gray: #8b95a7; --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1522; --card: #16233a; --text: #eaf0fb; --muted: #93a1b8; --line: #263653; --accent: #5a8cff; --red: #ff6b6b; --green: #3ecf82; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; }
main { max-width: 520px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
h1 { font-size: 22px; margin: 0; flex: 1; }
h2 { font-size: 15px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; } .row > * { flex: 1; }
.row.tight > * { flex: 0 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
header { display: flex; align-items: center; gap: 8px; }
button, select, input { font: inherit; color: inherit; }
button { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; min-height: 48px; cursor: pointer; }
button:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.big { min-height: 64px; font-size: 18px; font-weight: 700; color: #fff; border: none; }
button.arm { background: var(--red); } button.disarm { background: var(--green); } button.neutral { background: var(--accent); }
button.icon { flex: 0 0 auto; min-width: 48px; padding: 0 12px; }
.tabs { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.tabs button { flex: 1; border: none; background: transparent; min-height: 40px; }
.tabs button.on { background: var(--accent); color: #fff; font-weight: 600; }
.badge { align-self: center; padding: 10px 22px; border-radius: 999px; font-weight: 700; font-size: 20px; background: color-mix(in srgb, var(--c, var(--gray)) 15%, transparent); color: var(--c, var(--gray)); }
.badge.armed { --c: var(--red); } .badge.disarmed { --c: var(--green); } .badge.busy { opacity: .5; }
.error { color: var(--red); } .ok { color: var(--green); }
img.screen { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 46px; color: var(--text); width: 100%; }
.scroller { overflow: auto; max-height: 320px; border: 1px solid var(--line); border-radius: 10px; background: #000; touch-action: pan-x pan-y; }
canvas.frame { display: block; }
canvas.frame.pixel { image-rendering: pixelated; }
canvas.loupe { border: 1px solid var(--line); border-radius: 6px; width: 198px; height: 198px; align-self: center; image-rendering: pixelated; }
.nudge { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(2, 48px); gap: 6px; justify-content: center; }
.nudge button { padding: 0; } .nudge .up { grid-column: 2; } 
.seg { display: flex; gap: 6px; } .seg button { flex: 1; min-height: 40px; } .seg button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.checks { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); max-width: 488px; margin: 0 auto; background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 12px; font-size: 14px; }
label.row { flex-direction: row; align-items: center; }
