*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: light;
  --bg: #f4f4f5;
  --surface: #ffffff;
  --surface-raised: #fafafa;
  --text: #18181b;
  --text-muted: #71717a;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-subtle: rgba(37, 99, 235, 0.1);
  --success: #16a34a;
  --warning: #ca8a04;
  --danger: #dc2626;
  --border: #e4e4e7;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 10px;
  --font: 'DM Sans', system-ui, -apple-system, sans-serif;
  --priority-low-bg: #f0fdf4;
  --priority-low-text: #15803d;
  --priority-medium-bg: #fefce8;
  --priority-medium-text: #a16207;
  --priority-high-bg: #fef2f2;
  --priority-high-text: #b91c1c;
  --delete-hover-bg: #fef2f2;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #18181b;
  --surface-raised: #27272a;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-subtle: rgba(59, 130, 246, 0.15);
  --success: #4ade80;
  --warning: #facc15;
  --danger: #f87171;
  --border: #3f3f46;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --priority-low-bg: rgba(74, 222, 128, 0.12);
  --priority-low-text: #4ade80;
  --priority-medium-bg: rgba(250, 204, 21, 0.12);
  --priority-medium-text: #facc15;
  --priority-high-bg: rgba(248, 113, 113, 0.12);
  --priority-high-text: #f87171;
  --delete-hover-bg: rgba(248, 113, 113, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #09090b;
    --surface: #18181b;
    --surface-raised: #27272a;
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-subtle: rgba(59, 130, 246, 0.15);
    --success: #4ade80;
    --warning: #facc15;
    --danger: #f87171;
    --border: #3f3f46;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --priority-low-bg: rgba(74, 222, 128, 0.12);
    --priority-low-text: #4ade80;
    --priority-medium-bg: rgba(250, 204, 21, 0.12);
    --priority-medium-text: #facc15;
    --priority-high-bg: rgba(248, 113, 113, 0.12);
    --priority-high-text: #f87171;
    --delete-hover-bg: rgba(248, 113, 113, 0.12);
  }
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  body,
  .card,
  .form-input,
  .btn,
  .task-item,
  .progress-bar__fill {
    transition: none;
  }
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.header__logo {
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.header__title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header__subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--surface-raised);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.theme-toggle__icon {
  display: none;
}

[data-theme="light"] .theme-toggle__icon--moon,
[data-theme="dark"] .theme-toggle__icon--sun {
  display: block;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle__icon--moon {
    display: block;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle__icon--sun {
    display: block;
  }
}

.main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.card__title {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.quote-card__header,
.tasks-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.quote-card__header .card__title,
.tasks-card__header .card__title {
  margin-bottom: 0;
}

.quote-card__text {
  border-left: 2px solid var(--primary);
  padding-left: 1rem;
}

.quote-card__text p {
  font-size: 1rem;
  font-style: italic;
  color: var(--text);
}

.quote-card__author {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.progress-bar {
  height: 6px;
  background: var(--surface-raised);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar__fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.progress-card__percent {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.stat {
  text-align: center;
  padding: 0.75rem 0.5rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat__value {
  display: block;
  font-size: 1.375rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat__value--done {
  color: var(--success);
}

.stat__value--pending {
  color: var(--warning);
}

.stat__label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.task-form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.form-row--split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.form-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9375rem;
  background: var(--surface-raised);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-subtle);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--primary-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn--ghost:hover {
  background: var(--surface-raised);
  color: var(--text);
}

.btn--sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
}

.filter-group {
  display: flex;
  padding: 2px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  gap: 2px;
}

.filter-btn {
  padding: 0.25rem 0.55rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.filter-btn--active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .filter-btn--active {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.filter-btn:hover:not(.filter-btn--active) {
  color: var(--text);
}

.filter-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  transition: background 0.15s, opacity 0.15s, border-color 0.15s;
}

.task-item:hover {
  background: var(--surface-raised);
}

.task-item--done {
  opacity: 0.65;
}

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

.task-item__checkbox {
  width: 1rem;
  height: 1rem;
  accent-color: var(--success);
  cursor: pointer;
  flex-shrink: 0;
}

.task-item__content {
  flex: 1;
  min-width: 0;
}

.task-item__title {
  display: block;
  font-weight: 500;
  font-size: 0.9375rem;
  word-break: break-word;
}

.task-item__meta {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}

.task-item__tag {
  font-size: 0.6875rem;
  padding: 0.1rem 0.4rem;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
}

.task-item__priority {
  font-size: 0.6875rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: capitalize;
}

.task-item__priority--low {
  background: var(--priority-low-bg);
  color: var(--priority-low-text);
}

.task-item__priority--medium {
  background: var(--priority-medium-bg);
  color: var(--priority-medium-text);
}

.task-item__priority--high {
  background: var(--priority-high-bg);
  color: var(--priority-high-text);
}

.task-item__delete {
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}

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

.task-item__delete:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 1.5rem 0.5rem;
}

#clear-completed-btn {
  margin-top: 0.75rem;
}

.footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .form-row--split {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .header__title {
    font-size: 1.25rem;
  }

  .tasks-card__header {
    flex-direction: column;
    align-items: flex-start;
  }
}
