:root {
  --bg: #f6f6f8;
  --card: #ffffff;
  --text: #16161a;
  --muted: #8a8a94;
  --line: #e6e6eb;
  --accent: #3b6cf6;
  --danger: #e5484d;
  --radius: 16px;
  --pad: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101014;
    --card: #1a1a20;
    --text: #f2f2f5;
    --muted: #85858f;
    --line: #2a2a33;
    --accent: #5b86ff;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: none;
}

.top {
  padding: calc(env(safe-area-inset-top) + 20px) var(--pad) 8px;
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
}
.top-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h1 { margin: 0; font-size: 30px; letter-spacing: -0.02em; }
.count { margin: 2px 0 8px; color: var(--muted); font-size: 14px; }
.ghost {
  background: none; border: 0; color: var(--accent);
  font-size: 15px; padding: 8px 4px; min-height: 44px; cursor: pointer;
}

main { flex: 1; padding: 0 var(--pad) 120px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius);
  padding: 14px; min-height: 60px;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  animation: pop .16s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.item.leaving { opacity: 0; transform: scale(.97); transition: .16s ease; }

.check {
  flex: none; width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--line); background: none; padding: 0;
  display: grid; place-items: center; cursor: pointer; color: #fff;
  transition: background .15s, border-color .15s;
}
.check svg { opacity: 0; transform: scale(.6); transition: .15s; }
.item.done .check { background: var(--accent); border-color: var(--accent); }
.item.done .check svg { opacity: 1; transform: scale(1); }

.title { flex: 1; word-break: break-word; padding: 4px 0; }
.item.done .title { color: var(--muted); text-decoration: line-through; }

.del {
  flex: none; width: 44px; height: 44px; border: 0; background: none;
  color: var(--muted); display: grid; place-items: center; cursor: pointer;
}
.del:active { color: var(--danger); }

.empty { text-align: center; color: var(--muted); margin-top: 22vh; line-height: 1.7; }
.empty span { font-size: 15px; opacity: .8; }

.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; gap: 10px;
  padding: 10px var(--pad) calc(env(safe-area-inset-bottom) + 10px);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.composer input {
  flex: 1; min-width: 0; height: 52px; padding: 0 18px;
  font-size: 17px; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 26px;
}
.composer input:focus { outline: none; border-color: var(--accent); }
.composer button {
  flex: none; width: 52px; height: 52px; border: 0; border-radius: 50%;
  background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer;
}
.composer button:active { transform: scale(.94); }
.composer button:disabled { opacity: .4; }
