:root {
  color-scheme: light dark;
  --bg: #f5f5f2;
  --card: #ffffff;
  --text: #1c1c1a;
  --muted: #6f6f6a;
  --line: #e3e3de;
  --accent: #2f6f4f;
  --accent-text: #ffffff;
  --danger: #b3382c;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161715;
    --card: #1f211e;
    --text: #ecece8;
    --muted: #9b9b94;
    --line: #30332f;
    --accent: #6fbf94;
    --accent-text: #10130f;
    --danger: #f08a7e;
  }
}

* { box-sizing: border-box; }

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

main {
  max-width: 560px;
  margin: 0 auto;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.count {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

button {
  font: inherit;
  cursor: pointer;
}

.add {
  display: flex;
  gap: 8px;
}

.add input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
}

.add button {
  padding: 12px 20px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

nav {
  display: flex;
  gap: 4px;
  margin: 20px 0 10px;
}

nav a {
  padding: 4px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
}

nav a[aria-current="page"] {
  background: var(--card);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

.todos {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.todos li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.todos li:first-child { border-top: 0; }

.todos form { display: flex; }

.title {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

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

.check {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--accent-text);
  font-size: 13px;
  line-height: 1;
}

.done .check {
  border-color: var(--accent);
  background: var(--accent);
}

.delete {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

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

.empty {
  justify-content: center;
  color: var(--muted);
  padding: 28px 14px;
}

.clear {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.clear button {
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
}

footer {
  margin-top: 32px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}
