/* ── Reset & Base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f4f5f7;
  --card:      #ffffff;
  --primary:   #4f46e5;
  --primary-h: #4338ca;
  --danger:    #ef4444;
  --danger-h:  #dc2626;
  --text:      #1e1e2e;
  --text-mid:  #6b7280;
  --text-light:#9ca3af;
  --border:    #e5e7eb;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.1);
  --transition: .15s ease;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
               Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

/* ── App Container ────────────────────────────────── */
.app {
  width: 100%;
  max-width: 520px;
}

header { text-align: center; margin-bottom: 1.75rem; }
header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}
.subtitle { color: var(--text-mid); font-size: .95rem; margin-top: .25rem; }

/* ── Input Row ────────────────────────────────────── */
.input-row {
  display: flex;
  gap: .5rem;
  margin-bottom: 1rem;
}

#todo-input {
  flex: 1;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--card);
}
#todo-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}

#add-btn {
  width: 48px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 1.5rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
  line-height: 1;
}
#add-btn:hover { background: var(--primary-h); }

/* ── Filters ──────────────────────────────────────── */
.filters {
  display: flex;
  gap: .25rem;
  margin-bottom: 1rem;
  background: var(--card);
  border-radius: var(--radius);
  padding: .25rem;
  box-shadow: var(--shadow);
}

.filters button {
  flex: 1;
  padding: .5rem .5rem;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-mid);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.filters button.active {
  background: var(--primary);
  color: #fff;
}

.filters button:not(.active):hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

/* ── Progress Bar ─────────────────────────────────── */
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; margin-bottom: .75rem; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--primary), #818cf8); border-radius: 3px; transition: width .4s ease; }
.progress-text { text-align: center; font-size: .8rem; color: var(--text-light); margin-bottom: 1rem; min-height: 1.2em; }

/* ── Todo List ────────────────────────────────────── */
.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: opacity var(--transition), transform var(--transition);
  animation: slideIn .2s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes ripple { to { transform: translate(-50%,-50%) scale(4); opacity: 0; } }

/* Custom checkbox */
.check-circle {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.check-circle:hover { border-color: var(--primary); }

.check-circle.checked {
  background: var(--primary);
  border-color: var(--primary);
}
.check-circle.checked::after {
  content: '';
  width: 6px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

.todo-text {
  flex: 1;
  font-size: .95rem;
  line-height: 1.4;
  word-break: break-word;
}

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

/* Delete button */
.delete-btn {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.15rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all var(--transition);
  line-height: 1;
}
.delete-btn:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

/* ── Empty State ──────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 2rem;
  color: var(--text-light);
}
.empty-icon { font-size: 2.5rem; margin-bottom: .5rem; }
.empty-heading { font-size: 1.05rem; font-weight: 600; color: var(--text-mid); margin-bottom: .25rem; }
.empty-sub { font-size: .85rem; }

/* ── Footer ───────────────────────────────────────── */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding: .75rem 1rem;
  font-size: .85rem;
  color: var(--text-mid);
}

#clear-completed {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .35rem .75rem;
  font-size: .8rem;
  color: var(--text-mid);
  cursor: pointer;
  transition: all var(--transition);
}
#clear-completed:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Onboarding ────────────────────────────────────── */
.onboarding { background: var(--card); border: 2px solid var(--primary); border-radius: var(--radius); padding: 1.5rem; text-align: center; margin-bottom: 1rem; box-shadow: var(--shadow-lg); }
.onboarding h2 { font-size: 1.1rem; color: var(--primary); margin-bottom: .5rem; }
.onboarding p { font-size: .9rem; color: var(--text-mid); margin-bottom: .5rem; }
#onboarding-close { background: var(--primary); color: #fff; border: none; border-radius: var(--radius); padding: .6rem 1.5rem; font-size: .95rem; cursor: pointer; margin-top: .5rem; }
#onboarding-close:hover { background: var(--primary-h); }

/* ── Utility ──────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 480px) {
  body { padding: 1rem .5rem; }
  header h1 { font-size: 1.6rem; }
  .todo-item { padding: .65rem .75rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
