:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #14161a;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #b91c1c;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #171a20;
    --text: #e7e9ee;
    --muted: #9aa2ae;
    --line: #2a2f38;
    --accent: #3b82f6;
    --accent-text: #0b1220;
    --danger: #f87171;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 2rem 1rem 4rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app {
  max-width: 34rem;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.app__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.app__title { margin: 0; font-size: 1.5rem; }

.app__count { margin: 0; color: var(--muted); font-size: 0.875rem; }

.composer { display: flex; gap: 0.5rem; }

.composer__input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.composer__input:focus-visible,
.todo__editfield:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.composer__add {
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
}

.composer__add:hover { filter: brightness(1.08); }

.filters { display: flex; gap: 0.375rem; margin: 1rem 0 0.25rem; }

.filters__btn {
  padding: 0.3rem 0.7rem;
  font: inherit;
  font-size: 0.875rem;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.filters__btn[aria-pressed="true"] {
  color: var(--accent-text);
  background: var(--accent);
  border-color: var(--accent);
}

.todos { list-style: none; margin: 0.5rem 0 0; padding: 0; }

.todo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.25rem;
  border-bottom: 1px solid var(--line);
}

.todo:last-child { border-bottom: 0; }

.todo__check { width: 1.05rem; height: 1.05rem; accent-color: var(--accent); flex: none; cursor: pointer; }

.todo__text { flex: 1; min-width: 0; overflow-wrap: anywhere; cursor: text; }

.todo--done .todo__text { color: var(--muted); text-decoration: line-through; }

.todo__editfield {
  flex: 1;
  min-width: 0;
  padding: 0.25rem 0.4rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 6px;
}

.iconbtn {
  flex: none;
  padding: 0.2rem 0.45rem;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
}

.iconbtn:hover { color: var(--text); border-color: var(--line); }

.iconbtn--danger:hover { color: var(--danger); }

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

.app__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
}

.hint { margin: 0; color: var(--muted); font-size: 0.8125rem; }

.linkbtn {
  padding: 0;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--danger);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
