:root {
  --bg: #f5f6f4; --card: #ffffff; --ink: #1c211e; --muted: #66706a; --line: #e2e5e1;
  --accent: #1f7a4d; --accent-ink: #ffffff; --chip: #e9ece8; --done: #9aa39d; --warn: #b26b00; --danger: #b3261e;
  --radius: 12px; color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --card: #1b201d; --ink: #e8ece9; --muted: #9aa49e; --line: #2b322e;
    --accent: #3fb47a; --accent-ink: #08130d; --chip: #252c28; --done: #66706a; --warn: #f0a640; --danger: #f2766c; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: env(safe-area-inset-top) 0 4px; border-bottom: 1px solid var(--line); }
.bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px 6px; }
.bar h1 { font-size: 22px; margin: 0; flex: 1; letter-spacing: -0.01em; }
.status { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 4px 10px; font-size: 13px; color: var(--muted); }
.status.ok::before { content: "●"; color: var(--accent); margin-right: 5px; }
.status.wait::before { content: "●"; color: var(--warn); margin-right: 5px; }
.icon-btn { border: 0; background: none; font-size: 22px; width: 40px; height: 40px; border-radius: 50%; }
.icon-btn:active { background: var(--chip); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; background: var(--chip); border-radius: 999px; padding: 7px 13px; font-size: 14px; white-space: nowrap; }
.chip .n { color: var(--muted); margin-left: 5px; font-size: 13px; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip.on .n { color: inherit; opacity: 0.8; }
.chips.small .chip { padding: 4px 10px; font-size: 13px; }

main { padding: 8px 12px calc(96px + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
.section { margin: 10px 0 18px; }
.section h2 { display: flex; align-items: baseline; gap: 8px; font-size: 15px; margin: 0 4px 6px; color: var(--muted); font-weight: 600; text-transform: none; }
.section h2 .name { color: var(--ink); font-size: 17px; }
.section h2 .grow { flex: 1; }
.section h2 .clear { border: 0; background: none; color: var(--accent); font-size: 14px; padding: 2px 4px; }
ul.items { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
li.item { display: flex; align-items: center; gap: 10px; padding: 11px 6px 11px 12px; border-top: 1px solid var(--line); min-height: 56px; user-select: none; }
li.item:first-child { border-top: 0; }
li.item:active { background: var(--chip); }
.check { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; }
li.done .check { background: var(--accent); border-color: var(--accent); }
li.done .check::after { content: ""; width: 7px; height: 12px; border: solid var(--accent-ink); border-width: 0 3px 3px 0; transform: translateY(-1px) rotate(45deg); }
.body { flex: 1; min-width: 0; }
.name { font-weight: 500; overflow-wrap: anywhere; }
.qty { color: var(--accent); font-weight: 600; margin-right: 6px; white-space: nowrap; }
.sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sub .price { color: var(--ink); white-space: nowrap; }
.sub .proj { background: var(--chip); border-radius: 6px; padding: 0 6px; font-size: 12px; white-space: nowrap; }
li.done .name, li.done .qty, li.done .sub { color: var(--done); text-decoration: line-through; }
.item a.go, .item button.edit { flex: none; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; border: 0; background: none; color: var(--muted); text-decoration: none; font-size: 18px; }
.item a.go:active, .item button.edit:active { background: var(--line); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

.add { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line); }
.add input { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 11px 12px; }
.add select { max-width: 34%; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 0 8px; }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 0 16px; font-weight: 600; min-height: 44px; }
.add .primary { font-size: 24px; width: 48px; padding: 0; }

.menu { position: fixed; top: calc(52px + env(safe-area-inset-top)); right: 12px; z-index: 10; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0,0,0,.18); display: flex; flex-direction: column; min-width: 220px; overflow: hidden; }
.menu button { border: 0; background: none; text-align: left; padding: 13px 16px; border-top: 1px solid var(--line); }
.menu button:first-child { border-top: 0; }
.menu button:active { background: var(--chip); }
.menu .ver { color: var(--muted); font-size: 12px; padding: 8px 16px; border-top: 1px solid var(--line); }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--card); color: var(--ink); box-shadow: 0 16px 48px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog form { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
dialog h2 { margin: 0 0 4px; font-size: 18px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; min-width: 0; }
dialog input, dialog textarea { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 10px 11px; font-size: 16px; width: 100%; }
dialog .row { display: flex; gap: 10px; }
dialog .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
dialog .actions .grow { flex: 1; }
dialog .actions button, dialog .actions .btn { min-height: 44px; border-radius: 10px; padding: 0 14px; border: 1px solid var(--line); background: var(--bg); text-decoration: none; display: inline-grid; place-items: center; }
dialog .actions .primary { border: 0; background: var(--accent); }
.danger { color: var(--danger); }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 12; background: var(--ink); color: var(--bg);
  border-radius: 12px; padding: 10px 10px 10px 16px; display: flex; gap: 12px; align-items: center; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast button { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 6px 8px; }
.lock { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: grid; place-items: center; padding: 24px 16px; }
.lock form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.lock img { align-self: center; border-radius: 16px; }
.lock h2 { margin: 0; font-size: 22px; }
.lock p { margin: 0; color: var(--muted); }
.lock input { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 12px; font-size: 16px; }
.lock .err { color: var(--danger); }
[hidden] { display: none !important; }
