:root {
  --bg: #f6f6f4;
  --card: #ffffff;
  --fg: #1b1b1b;
  --muted: #6b6b6b;
  --line: #e2e2de;
  --accent: #1f6feb;
  --danger: #c0392b;
  --p1: #c0392b;
  --p2: #b7791f;
  --p3: #4b7a5e;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --card: #1c1c1e;
    --fg: #ededed;
    --muted: #9a9a9a;
    --line: #2c2c2e;
    --accent: #5aa0ff;
    --danger: #ff6b5b;
    --p1: #ff6b5b;
    --p2: #e0a53d;
    --p3: #6fbf8e;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
h1 { font-size: 24px; margin: 0; display: flex; align-items: baseline; gap: 10px; }
.count { font-size: 15px; color: var(--muted); font-weight: 500; }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }

button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--fg); padding: 10px 14px; min-height: 44px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.link { background: none; border: none; color: var(--muted); padding: 6px 4px; min-height: 0; }
button.link:hover { color: var(--fg); }
input[type="text"], input[type="password"] { font: inherit; width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--fg); }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.add { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 18px; }
.add input[type="text"] { grid-column: 1 / -1; }
.seg { display: flex; gap: 6px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg input:checked + .pill { outline: 2px solid currentColor; }
.seg input:focus-visible + .pill { box-shadow: 0 0 0 2px var(--accent); }

.pill { display: inline-flex; align-items: center; justify-content: center; min-width: 56px; min-height: 36px; padding: 4px 10px; border-radius: 999px; border: 1px solid currentColor; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; background: var(--card); user-select: none; }
.pill.p1 { color: var(--p1); }
.pill.p2 { color: var(--p2); }
.pill.p3 { color: var(--p3); }

.list { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.list:empty { display: none; }
.item { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; border-top: 1px solid var(--line); }
.item:first-child { border-top: none; }
.item.done .title { text-decoration: line-through; color: var(--muted); }
.item.done .pill { opacity: 0.5; }
.item input[type="checkbox"] { width: 24px; height: 24px; margin: 0; accent-color: var(--accent); }
.item .title { overflow-wrap: anywhere; padding: 6px 0; }
.item .pill { cursor: pointer; }
.item .del { background: none; border: none; color: var(--muted); font-size: 20px; line-height: 1; padding: 8px 10px; min-height: 44px; }
.item .del:hover { color: var(--danger); }
.sep { padding: 6px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-top: 1px solid var(--line); background: var(--bg); }

.empty { text-align: center; color: var(--muted); margin: 28px 0; }
.foot { display: flex; justify-content: center; margin-top: 14px; }

.login { max-width: 320px; margin: 18vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.login h1 { text-align: center; justify-content: center; }
.error { color: var(--danger); margin: 0; text-align: center; }
