:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-muted: #f7f9fc;
  --text: #17202a;
  --muted: #667085;
  --border: #d8dee8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --shadow: 0 24px 60px rgba(31, 41, 55, 0.14);
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

body.dark {
  color-scheme: dark;
  --bg: #111827;
  --surface: #1f2937;
  --surface-muted: #273447;
  --text: #f9fafb;
  --muted: #aeb8c7;
  --border: #3b4659;
  --primary: #60a5fa;
  --primary-hover: #93c5fd;
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  --focus: 0 0 0 3px rgba(96, 165, 250, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  transition: background-color 180ms ease, color 180ms ease;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px 16px;
}

.todo-app {
  width: min(100%, 680px);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
}

.todo-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 18px;
}

.todo-form input,
.edit-input {
  width: 100%;
  min-width: 0;
  padding: 13px 14px;
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease,
    background-color 160ms ease;
}

.todo-form input:focus,
.edit-input:focus {
  border-color: var(--primary);
  box-shadow: var(--focus);
}

.primary-button,
.ghost-button,
.filter-button,
.icon-button,
.delete-button {
  border: 0;
  border-radius: 8px;
  transition: background-color 160ms ease, color 160ms ease,
    transform 160ms ease, border-color 160ms ease;
}

.primary-button {
  min-width: 86px;
  padding: 0 18px;
  color: #ffffff;
  background: var(--primary);
  font-weight: 700;
}

.primary-button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-button,
.ghost-button {
  min-height: 38px;
  padding: 0 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
}

.filter-button:hover,
.ghost-button:hover {
  color: var(--text);
  background: var(--surface-muted);
}

.filter-button.active {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.icon-button {
  display: grid;
  width: 58px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--text);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  font-weight: 700;
}

.icon-button:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
}

.task-count {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.todo-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.todo-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  animation: task-in 180ms ease both;
  transition: opacity 180ms ease, transform 180ms ease,
    background-color 160ms ease, border-color 160ms ease;
}

.todo-item.removing {
  opacity: 0;
  transform: translateX(16px);
}

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

.todo-item.completed {
  opacity: 0.72;
}

.todo-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

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

.task-text:hover {
  color: var(--primary);
}

.delete-button {
  width: 36px;
  height: 36px;
  color: var(--danger);
  background: transparent;
  font-size: 1.35rem;
  line-height: 1;
}

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

.empty-state {
  display: none;
  margin: 22px 0 0;
  padding: 20px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-muted);
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.empty-state.visible {
  display: block;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 560px) {
  .app-shell {
    align-items: start;
    padding-top: 18px;
  }

  .todo-app {
    padding: 20px;
  }

  .todo-form,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .todo-form {
    display: grid;
  }

  .primary-button {
    min-height: 46px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filters {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-button,
  .ghost-button {
    width: 100%;
  }
}
