:root {
  color-scheme: light dark;
  --bg: #F8FAFC; --surface: #FFFFFF; --surface-2: #F1F5F9; --fg: #0F172A; --muted: #64748B;
  --border: #E2E8F0; --accent: #16A34A; --accent-strong: #15803D; --on-accent: #FFFFFF;
  --accent-fill: #15803D; --danger-text: #B91C1C; --on-danger: #FFFFFF;
  --accent-soft: #DCFCE7; --danger: #DC2626; --danger-soft: #FEE2E2; --warn: #B45309; --warn-soft: #FEF3C7;
  --ring-track: #E2E8F0; --shadow: 0 1px 2px rgb(15 23 42 / .06), 0 8px 24px rgb(15 23 42 / .06);
  --radius: 20px; --font: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0B1220; --surface: #121A2B; --surface-2: #1B2336; --fg: #F8FAFC; --muted: #94A3B8;
    --border: #273145; --accent: #22C55E; --accent-strong: #4ADE80; --on-accent: #052E16;
    --accent-fill: #22C55E; --danger-text: #F87171; --on-danger: #450A0A;
    --accent-soft: #0F2E1D; --danger: #F87171; --danger-soft: #3A1517; --warn: #FBBF24; --warn-soft: #3A2A0B;
    --ring-track: #273145; --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); line-height: 1.5; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--fg); outline-offset: 3px; }
.icon { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* App shell */
#app { min-height: 100dvh; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; }
.content { flex: 1; display: flex; flex-direction: column; padding: max(20px, env(safe-area-inset-top)) 20px 12px; gap: 16px; }
.view { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; }
.topbar h2 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chip.off { background: var(--danger-soft); color: var(--danger-text); }

/* Hold button */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; }
.hold { position: relative; width: 224px; height: 224px; border: 0; padding: 0; background: none; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; border-radius: 50%; font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.hold:focus-visible { outline: 3px solid var(--fg); outline-offset: 6px; }
.hold svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: scaleX(-1) rotate(-90deg); }
.hold .track { fill: none; stroke: var(--ring-track); stroke-width: 8; }
.hold .prog { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; stroke-dasharray: 653.45; stroke-dashoffset: 653.45; }
.hold .face { position: absolute; inset: 18px; border-radius: 50%; background: var(--accent-fill); color: var(--on-accent); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; box-shadow: 0 10px 30px rgb(22 163 74 / .35); transition: transform .15s ease-out, background-color .2s, box-shadow .2s; }
.hold .face svg.icon { position: static; transform: none; width: 44px; height: 44px; }
.hold .label { font-size: 22px; font-weight: 700; }
.hold .sub { font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.hold .sub:empty { display: none; }
.hold[data-state="arming"] .face, .hold[data-state="requesting"] .face, .hold[data-state="buzzing"] .face { transform: scale(.95); }
.hold[data-state="buzzing"] .face { box-shadow: 0 0 0 10px rgb(34 197 94 / .18), 0 10px 30px rgb(22 163 74 / .35); }
.hold[data-state="error"] .face { background: var(--danger); color: var(--on-danger); box-shadow: 0 10px 30px rgb(220 38 38 / .3); }
.hold[data-state="error"] .prog { stroke: var(--danger); }
.hold[data-state="disabled"] { cursor: not-allowed; }
.hold[data-state="disabled"] .face { background: var(--surface-2); color: var(--muted); box-shadow: none; }
.hint { font-size: 15px; color: var(--muted); text-align: center; min-height: 48px; max-width: 26ch; margin: 0; }
.hint strong { color: var(--fg); font-weight: 600; }
.hint.err strong { color: var(--danger); }

/* Notifications card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; }
.card .ic { flex: none; width: 40px; height: 40px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); display: grid; place-items: center; }
.card .ic svg { width: 22px; height: 22px; }
.card .txt { flex: 1; font-size: 14px; }
.card .txt b { display: block; font-size: 15px; font-weight: 600; }
.card .txt span { color: var(--muted); }
.btn { border: 0; font: inherit; font-weight: 600; font-size: 14px; padding: 10px 14px; border-radius: 12px; background: var(--fg); color: var(--bg); min-height: 44px; min-width: 44px; cursor: pointer; white-space: nowrap; }

/* History */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.day { font-size: 13px; font-weight: 600; color: var(--muted); padding: 4px 4px 0; margin-top: 10px; }
.day:first-child { margin-top: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); min-height: 44px; }
.row:first-child { border-top: 0; }
.row .dot { flex: none; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); }
.row .dot.ring { background: var(--surface-2); color: var(--fg); }
.row .dot.bad { background: var(--danger-soft); color: var(--danger); }
.row .dot svg { width: 18px; height: 18px; }
.row .what { flex: 1; font-size: 15px; }
.row .what small { display: block; color: var(--muted); font-size: 13px; }
.row time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Tabs */
.tabs { position: sticky; bottom: 0; display: flex; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(12px); padding: 6px 8px calc(10px + env(safe-area-inset-bottom)); }
.tabs button { flex: 1; border: 0; background: none; font: inherit; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 500; padding: 6px 0; min-height: 52px; cursor: pointer; border-radius: 12px; }
.tabs button svg { width: 24px; height: 24px; }
.tabs button[aria-selected="true"] { color: var(--accent-strong); }
.tabs button[aria-selected="true"] .pill { background: var(--accent-soft); }
.tabs .pill { padding: 2px 18px; border-radius: 999px; display: grid; place-items: center; }

/* Setup */
.setup { min-height: 100dvh; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: max(24px, env(safe-area-inset-top)) 20px 24px; }
.setup h1 { font-size: 28px; font-weight: 700; margin: 0; }
.setup p { margin: 0; color: var(--muted); }
.setup form { display: flex; flex-direction: column; gap: 14px; }
.setup label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.setup input { font: inherit; min-height: 48px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--fg); width: 100%; text-transform: uppercase; direction: ltr; text-align: center; letter-spacing: .1em; }
.setup .btn { background: var(--accent-fill); color: var(--on-accent); font-size: 16px; }
.code { font: 600 2rem ui-monospace, monospace; letter-spacing: .1em; direction: ltr; text-align: center; color: var(--fg); }
#setup-msg { min-height: 1.5em; color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .hold .face { transition: none; }
  .tabs { backdrop-filter: none; }
}
