:root {
  --bg: #f4f6f5; --card: #ffffff; --ink: #14201d; --muted: #5d6b67; --line: #dfe5e3;
  --accent: #0f766e; --accent-ink: #ffffff; --ok: #15803d; --okbg: #ecf7ef; --warn: #b45309; --chip: #eef2f1;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1413; --card: #172120; --ink: #e8efed; --muted: #93a39f; --line: #26322f;
    --accent: #2dd4bf; --accent-ink: #062b27; --ok: #4ade80; --okbg: #13261b; --warn: #fbbf24; --chip: #1f2b29;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
main { max-width: 560px; margin: 0 auto; padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); }
section { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); margin: 12px 0; overflow: hidden; }
h3 { display: flex; justify-content: space-between; align-items: center; margin: 0; padding: 12px 14px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
h3.dh { padding-top: 14px; }
.pad { padding: 4px 14px 12px; margin: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .warn { color: var(--warn); } .ok { color: var(--ok); font-weight: 600; }
button { font: inherit; color: inherit; cursor: pointer; }
.link { background: none; border: 0; color: var(--accent); font-size: 14px; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 4px 0; }

.dayhead { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 4px 4px 0; }
.big { font-size: 22px; font-weight: 700; }
.progress { flex: 0 0 110px; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress div { height: 100%; background: var(--accent); transition: width .3s; }

.banner { display: block; width: 100%; text-align: left; padding: 12px 14px; border: 1px solid var(--warn); color: var(--warn); background: transparent; border-radius: var(--r); font-weight: 600; margin-bottom: 4px; }

.row, .hrow { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 12px 14px; min-height: 60px; }
h3 + .row, h3 + .overdue .row:first-child { border-top: 0; }
.row:active { background: var(--chip); }
.row-main { flex: 1; min-width: 0; }
.title { font-weight: 600; }
.sub { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.row.done { background: var(--okbg); } .row.done .title { color: var(--muted); }
.row.inactive { opacity: .5; }
.chev { font-size: 24px; color: var(--muted); }
.tag { font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 5px; vertical-align: 2px; }
.hrow .x { flex: 0 0 auto; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 4px 10px 12px; }
.card { background: var(--chip); border: 1px solid transparent; border-radius: 12px; padding: 10px; text-align: left; min-height: 88px; }
.card.done { background: var(--okbg); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.card-k { font-size: 12px; color: var(--muted); }
.card-v { font-size: 22px; font-weight: 700; margin: 2px 0; white-space: nowrap; }
.card-v small { font-size: 12px; font-weight: 500; color: var(--muted); }
.card-s { font-size: 12px; color: var(--muted); }
.card.done .card-s { color: var(--ok); font-weight: 600; }

.q { padding: 10px 14px 12px; border-top: 1px solid var(--line); }
h3 + .q { border-top: 0; }
.q-text { font-weight: 500; margin-bottom: 8px; }
.q-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 4px; }
.chips { display: flex; gap: 6px; }
.chips.wrap { flex-wrap: wrap; }
.chips > .chip { flex: 1; }
.chips.wrap > .chip { flex: 0 0 auto; }
.chip { border: 1px solid var(--line); background: var(--chip); border-radius: 10px; min-height: 44px; min-width: 44px; padding: 0 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; }
.chip.sel, label.chip:has(input:checked) { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip.static { min-height: 32px; font-weight: 500; }
label.chip input { display: none; }
.seg { margin-bottom: 8px; }

.btn { border: 1px solid var(--line); background: var(--chip); border-radius: 12px; min-height: 48px; padding: 0 16px; font-weight: 600; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 44px; }
.btn.grow, .grow { flex: 1; }
.stack { display: grid; gap: 8px; }
.x { background: none; border: 0; font-size: 18px; color: var(--muted); min-width: 44px; min-height: 44px; }

nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
nav button { flex: 1; background: none; border: 0; padding: 8px 0 10px; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; }
nav button span { font-size: 18px; line-height: 1; }
nav button.sel { color: var(--accent); font-weight: 700; }

dialog { border: 0; padding: 0; width: 100%; max-width: 560px; margin: auto auto 0; border-radius: 18px 18px 0 0; background: var(--card); color: var(--ink); max-height: 92vh; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.sheet-inner { padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.sheet-inner p { margin: 0; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--ink); }
label.check input { width: 22px; height: 22px; }
input, select, textarea { font: inherit; font-size: 18px; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 48px; width: 100%; }
textarea { min-height: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > select { flex: 0 0 110px; }
.inline > span { flex: 0 0 auto; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row3 .inline span { display: none; }
fieldset { border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 10px; padding: 10px 12px 12px; margin: 0; }
legend { font-size: 13px; color: var(--muted); padding: 0 4px; }
details summary { color: var(--muted); font-size: 14px; padding: 6px 0; }
details[open] { display: grid; gap: 8px; }
.actions { display: flex; gap: 8px; }
.actions .btn { min-height: 56px; font-size: 18px; }
.bignum { display: flex; align-items: baseline; justify-content: center; gap: 8px; }
.bignum input { font-size: 44px; font-weight: 700; text-align: center; max-width: 220px; }
.bignum output { font-size: 44px; font-weight: 700; }
.bignum span { font-size: 20px; color: var(--muted); }
.steppers { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
input[type=range] { padding: 0; border: 0; background: none; accent-color: var(--accent); min-height: 44px; }
[hidden] { display: none !important; }
.counts { width: calc(100% - 28px); margin: 0 14px 12px; font-size: 14px; border-collapse: collapse; }
.counts td { padding: 3px 0; border-bottom: 1px solid var(--line); }
.counts td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
