:root {
  --bg: #f6f7f8; --card: #fff; --text: #17202a; --muted: #6b7280;
  --line: #e5e7eb; --accent: #0f766e; --accent-ink: #fff; --danger: #b91c1c;
  --warn-bg: #fef3c7; --warn-ink: #78350f;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1214; --card: #181c20; --text: #e6e8ea; --muted: #8b949e;
    --line: #2a3036; --accent: #2dd4bf; --accent-ink: #062a26; --danger: #f87171;
    --warn-bg: #3b2f0b; --warn-ink: #fde68a;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: env(safe-area-inset-bottom); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: .5rem;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem; background: var(--accent); color: var(--accent-ink); }
.bar select { flex: 1; font-family: inherit; font-size: 1.2rem; font-weight: 600; color: inherit; background: transparent;
  border: 0; padding: .2rem 0; appearance: none; -webkit-appearance: none; }
.bar select option { color: #000; }
.icon-btn { width: 2.5rem; height: 2.5rem; border-radius: 50%; font-size: 1.4rem; line-height: 1; }
.icon-btn:active { background: rgba(0,0,0,.12); }
.live { width: .6rem; height: .6rem; border-radius: 50%; background: currentColor; opacity: .3; }
.live.on { opacity: 1; box-shadow: 0 0 0 3px rgba(255,255,255,.25); }

.banner { margin: .75rem 1rem 0; padding: .6rem .8rem; border-radius: .5rem;
  background: var(--warn-bg); color: var(--warn-ink); font-size: .92rem; }

main { max-width: 40rem; margin: 0 auto; padding: .75rem 1rem 3rem; }

.add { display: flex; gap: .5rem; margin-bottom: .75rem; }
.add input { flex: 1; min-width: 0; padding: .7rem .9rem; border-radius: .6rem;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; }
.add button { width: 3rem; border-radius: .6rem; background: var(--accent); color: var(--accent-ink);
  font-size: 1.6rem; line-height: 1; }

.items { list-style: none; margin: 0; padding: 0; background: var(--card);
  border-radius: .75rem; overflow: hidden; }
.items:empty { display: none; }
.item { display: flex; align-items: center; gap: .6rem; padding: .35rem .4rem .35rem .8rem;
  border-bottom: 1px solid var(--line); min-height: 3.1rem; }
.item:last-child { border-bottom: 0; }
.item.pending { opacity: .55; }
.check { flex: none; width: 1.5rem; height: 1.5rem; border-radius: 50%; border: 2px solid var(--muted); position: relative; }
.check::after { content: ""; position: absolute; inset: 0; margin: auto; width: .45rem; height: .8rem;
  border: solid transparent; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.item.checked .check { background: var(--accent); border-color: var(--accent); }
.item.checked .check::after { border-color: var(--accent-ink); }
.item.checked .name { color: var(--muted); text-decoration: line-through; }
.name { flex: 1; min-width: 0; overflow-wrap: anywhere; padding: .3rem 0; }
.name[contenteditable="true"] { outline: 2px solid var(--accent); border-radius: .3rem; padding: .3rem .4rem; }
.del { color: var(--muted); font-size: 1.5rem; }
.del:hover { color: var(--danger); }

.empty { color: var(--muted); text-align: center; margin: 2rem 0; }

.done { margin-top: 1.25rem; }
.done summary { display: flex; justify-content: space-between; align-items: center;
  color: var(--muted); padding: .4rem .2rem; cursor: pointer; list-style: none; }
.done summary::-webkit-details-marker { display: none; }
.done summary::before { content: "▸ "; }
.done[open] summary::before { content: "▾ "; }
.done summary span { flex: 1; }
.link { color: var(--accent); font-size: .92rem; }

.login { display: grid; place-items: center; min-height: 70vh; padding: 1rem; }
.login form { width: min(20rem, 100%); display: grid; gap: .75rem; }
.login h1 { margin: 0 0 .5rem; text-align: center; }
.login input { padding: .75rem .9rem; border-radius: .6rem; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; }
.login button { padding: .75rem; border-radius: .6rem; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.error { color: var(--danger); min-height: 1.4em; margin: 0; text-align: center; }
