:root {
  --bg: #f6f4ef; --surface: #fff; --ink: #1f2a2e; --muted: #667378; --line: #e4e0d6;
  --accent: #1f6f6b; --accent-ink: #fff; --accent-soft: #e3f0ee; --danger: #b4443a; --ok: #2e7d55; --warn-bg: #fbf0d9;
  --r: 14px; --nav-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #131819; --surface: #1c2325; --ink: #e8eeee; --muted: #93a1a4; --line: #2b3638;
    --accent: #5fbdb5; --accent-ink: #0c1b1a; --accent-soft: #1f3331; --danger: #e07a70; --ok: #6fcf97; --warn-bg: #3a3322; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 -apple-system, "Segoe UI", Heebo, Arial, sans-serif; }
#app { max-width: 640px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 90px); }
header#top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(14px + env(safe-area-inset-top)) 18px 10px; display: flex; align-items: center; gap: 8px; }
h1 { font-size: 22px; margin: 0; font-weight: 700; flex: 1; }
h2 { font-size: 15px; margin: 22px 0 8px; color: var(--muted); font-weight: 600; }
main { padding: 0 16px; }
.icon-btn { border: 0; background: none; color: var(--ink); font-size: 28px; line-height: 1; width: 44px; height: 44px; border-radius: 22px; cursor: pointer; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 10px; }
.card.alert { background: var(--accent-soft); border-color: transparent; display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.card.warn { background: var(--warn-bg); border-color: transparent; }
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 52px; }
.muted { color: var(--muted); font-size: 14px; }
.title { font-weight: 600; }
button, .btn { font: inherit; min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
button.ghost { background: none; border-color: transparent; color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.stack { display: grid; gap: 10px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input, textarea, select { font: inherit; font-size: 16px; width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); flex: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; font-size: 15px; }
.chip[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 36px 12px; }
.badge { position: absolute; top: 4px; inset-inline-start: calc(50% + 6px); background: var(--danger); color: #fff; border-radius: 10px; font-size: 12px; min-width: 20px; height: 20px; line-height: 20px; text-align: center; padding: 0 5px; font-weight: 700; }
nav#nav { position: fixed; bottom: 0; inset-inline: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom); }
nav#nav .in { display: flex; width: 100%; max-width: 640px; }
nav a { flex: 1; position: relative; height: var(--nav-h); display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 12px; cursor: pointer; }
nav a[aria-current=page] { color: var(--accent); font-weight: 700; }
nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.fab { position: fixed; inset-inline-start: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); z-index: 8; min-height: 52px; border-radius: 26px; padding: 0 22px; box-shadow: 0 6px 20px rgba(0,0,0,.18); }
#layer .scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
#layer .sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92dvh; overflow: auto; border-radius: 20px 20px 0 0; padding: 18px 16px calc(24px + env(safe-area-inset-bottom)); }
.sheet h3 { margin: 0 0 14px; font-size: 19px; }
#toast { position: fixed; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); inset-inline: 16px; margin: 0 auto; max-width: 420px; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; z-index: 40; text-align: center; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }
.login { max-width: 360px; margin: 18dvh auto 0; padding: 0 20px; }
.login h1 { margin-bottom: 18px; }
.done { text-decoration: line-through; opacity: .5; }
.list-btn { width: 100%; text-align: start; display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; min-height: 56px; border-radius: var(--r); }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
