:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #dbe1ea;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: clamp(1.5rem, 6vw, 4rem) 1rem;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app {
  width: 100%;
  max-width: 36rem;
  align-self: flex-start;
  padding: clamp(1.25rem, 4vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
}

h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  line-height: 1.2;
}

.add-row {
  display: flex;
  gap: 0.5rem;
}

#task-input {
  flex: 1;
  min-width: 0;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  color: inherit;
  background: var(--surface);
}

#task-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

#add-button {
  flex: none;
  padding: 0.75rem 1.1rem;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

#add-button:hover {
  background: var(--accent-hover);
}

#add-button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.task-list {
  display: grid;
  gap: 0.5rem;
  margin: 1.25rem 0;
  padding: 0;
  list-style: none;
}

.task {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.task-checkbox {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.task-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

.task.completed .task-text {
  color: var(--muted);
  text-decoration: line-through;
}

.delete-button {
  flex: none;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

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

.delete-button:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 1px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

#clear-completed {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

#clear-completed:hover:not(:disabled) {
  background: var(--bg);
}

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

#clear-completed:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 26rem) {
  .app {
    border-radius: 12px;
  }

  .toolbar {
    font-size: 0.85rem;
  }
}
