:root {
  --blue-700: #1d4ed8;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-100: #dbeafe;
  --blue-50: #eff6ff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --danger: #dc2626;
  --radius: 20px;
  --shadow: 0 20px 50px -18px rgba(37, 99, 235, 0.28), 0 4px 14px -6px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 85% -80px, var(--blue-100), transparent 70%),
    linear-gradient(180deg, var(--blue-50) 0%, #ffffff 46%);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 16px 32px;
  -webkit-font-smoothing: antialiased;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Hero ---------- */
.hero { text-align: center; margin-bottom: 28px; }

.hero-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 60px; height: 60px; border-radius: 18px;
  color: #fff; background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  box-shadow: 0 12px 24px -8px rgba(37, 99, 235, 0.5);
  margin-bottom: 14px;
}
.hero-logo svg { width: 30px; height: 30px; }

.hero h1 { margin: 0 0 6px; font-size: clamp(1.5rem, 4vw, 2rem); letter-spacing: -0.02em; }
.hero p { margin: 0; color: var(--muted); font-size: 0.98rem; }

/* ---------- Card ---------- */
.app-card {
  width: 100%; max-width: 620px;
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ---------- Form ---------- */
#task-form { display: flex; gap: 10px; }

#task-input {
  flex: 1; min-width: 0;
  font: inherit; color: var(--ink);
  padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #f8fafc;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
#task-input::placeholder { color: #94a3b8; }
#task-input:focus {
  outline: none; border-color: var(--blue-600); background: #fff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
}

#add-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-weight: 600; color: #fff;
  padding: 0 18px; border: 0; border-radius: 14px; cursor: pointer;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  box-shadow: 0 8px 18px -8px rgba(37, 99, 235, 0.6);
  transition: transform 0.12s, box-shadow 0.15s, filter 0.15s;
}
#add-btn svg { width: 17px; height: 17px; }
#add-btn:hover { filter: brightness(1.07); box-shadow: 0 10px 22px -8px rgba(37, 99, 235, 0.7); }
#add-btn:active { transform: scale(0.97); }

button:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.45); outline-offset: 2px; }

/* ---------- Progress ---------- */
.progress { display: flex; align-items: center; gap: 12px; margin: 20px 2px 16px; }
.progress-track {
  flex: 1; height: 7px; border-radius: 99px; background: var(--blue-100); overflow: hidden;
}
.progress-fill {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--blue-500), var(--blue-700));
  transition: width 0.4s ease;
}
#progress-label { font-size: 0.82rem; font-weight: 600; color: var(--blue-700); white-space: nowrap; }

/* ---------- Filters ---------- */
.filters {
  display: flex; gap: 4px;
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 14px;
}
.filter {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 0.9rem; font-weight: 600; color: var(--muted);
  padding: 9px 6px; border: 0; border-radius: 10px; background: transparent; cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.filter:hover { color: var(--blue-700); }
.filter.is-active {
  background: #fff; color: var(--blue-700);
  box-shadow: 0 2px 8px -2px rgba(15, 23, 42, 0.14);
}
.count {
  min-width: 24px; padding: 1px 7px;
  font-size: 0.76rem; font-weight: 700;
  border-radius: 99px; background: var(--blue-100); color: var(--blue-700);
}
.filter.is-active .count { background: var(--blue-600); color: #fff; }

/* ---------- Task list ---------- */
#task-list { list-style: none; margin: 0; padding: 0; }

.task-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  border-radius: 12px;
  animation: task-in 0.25s ease;
}
.task-item:last-child { border-bottom: 0; }
.task-item:hover { background: var(--blue-50); }

@keyframes task-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.task-toggle {
  flex: none;
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid #cbd5e1; border-radius: 50%;
  background: #fff; color: transparent; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
}
.task-toggle svg { width: 14px; height: 14px; }
.task-toggle:hover { border-color: var(--blue-500); transform: scale(1.08); }
.task-item.is-done .task-toggle {
  background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  border-color: transparent; color: #fff;
}

.task-title { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.4; transition: color 0.15s; }
.task-item.is-done .task-title { color: var(--muted); text-decoration: line-through; text-decoration-color: #94a3b8; }

.task-delete {
  flex: none;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 9px; background: transparent; color: #94a3b8; cursor: pointer;
  opacity: 0.55;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
}
.task-delete svg { width: 16px; height: 16px; }
.task-item:hover .task-delete, .task-delete:focus-visible { opacity: 1; }
.task-delete:hover { background: #fef2f2; color: var(--danger); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 34px 16px 26px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; color: var(--blue-100); margin-bottom: 10px; }
.empty p { margin: 0; font-size: 0.95rem; }

/* ---------- Card footer ---------- */
.app-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--line);
}
#summary-text { font-size: 0.86rem; color: var(--muted); }

#clear-done {
  font: inherit; font-size: 0.86rem; font-weight: 600; color: var(--blue-700);
  border: 0; background: transparent; border-radius: 8px; padding: 6px 10px; cursor: pointer;
  transition: background 0.15s;
}
#clear-done:hover { background: var(--blue-50); text-decoration: underline; }

/* ---------- Page note ---------- */
.page-note { margin-top: 22px; font-size: 0.8rem; color: var(--muted); text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  body { padding: 32px 12px 24px; }
  .app-card { padding: 18px; }
  #task-form { flex-direction: column; }
  #add-btn { justify-content: center; padding: 12px; }
  .filter { font-size: 0.82rem; gap: 5px; }
  .app-footer { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
