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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px 60px;
}

.app {
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.22);
  overflow: hidden;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 28px 28px 22px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  background: rgba(255,255,255,0.18);
  border-radius: 12px;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

header h1 {
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  flex: 1;
  letter-spacing: -0.3px;
}

.task-count {
  background: rgba(255,255,255,0.22);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* ── Filters ── */
.filters {
  display: flex;
  gap: 0;
  padding: 16px 28px 0;
  border-bottom: 1px solid #f0f0f5;
  padding-bottom: 0;
}

.filter-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: #9ca3af;
  padding: 10px 16px;
  border-bottom: 2.5px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.filter-btn:hover {
  color: #667eea;
}

.filter-btn.active {
  color: #667eea;
  border-bottom-color: #667eea;
}

/* ── Input ── */
.input-area {
  display: flex;
  gap: 10px;
  padding: 20px 28px;
}

.input-area input {
  flex: 1;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.95rem;
  color: #111827;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fafafa;
}

.input-area input::placeholder {
  color: #b0b7c3;
}

.input-area input:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102,126,234,0.12);
  background: #fff;
}

#addBtn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 12px;
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 12px rgba(102,126,234,0.35);
}

#addBtn:hover {
  transform: scale(1.07);
  box-shadow: 0 6px 16px rgba(102,126,234,0.45);
}

#addBtn:active {
  transform: scale(0.97);
}

/* ── Task List ── */
.task-list {
  list-style: none;
  padding: 0 20px;
  max-height: 420px;
  overflow-y: auto;
}

.task-list::-webkit-scrollbar {
  width: 5px;
}
.task-list::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 10px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 10px;
  border-bottom: 1px solid #f3f4f6;
  animation: slideIn 0.22s ease;
  border-radius: 10px;
  transition: background 0.15s;
}

.task-item:last-child {
  border-bottom: none;
}

.task-item:hover {
  background: #fafafa;
}

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

/* Custom checkbox */
.task-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.task-checkbox:checked {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: transparent;
}

.task-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 8px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg);
}

.task-checkbox:hover {
  border-color: #667eea;
}

/* Task label */
.task-label {
  flex: 1;
  font-size: 0.95rem;
  color: #1f2937;
  cursor: pointer;
  word-break: break-word;
  transition: color 0.2s;
  line-height: 1.4;
  outline: none;
  border-radius: 4px;
  padding: 2px 4px;
}

.task-label:focus {
  background: #f5f3ff;
  cursor: text;
}

.task-item.done .task-label {
  color: #9ca3af;
  text-decoration: line-through;
}

/* Delete button */
.delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #d1d5db;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
  opacity: 0;
  flex-shrink: 0;
}

.task-item:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  color: #ef4444;
  background: #fef2f2;
}

/* ── Empty State ── */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 28px 36px;
  color: #9ca3af;
  font-size: 0.9rem;
  text-align: center;
  line-height: 1.6;
}

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

/* ── Footer ── */
.footer {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px 20px;
  font-size: 0.82rem;
  color: #9ca3af;
  border-top: 1px solid #f0f0f5;
}

.footer.visible {
  display: flex;
}

#clearCompleted {
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 0.82rem;
  transition: color 0.2s;
}

#clearCompleted:hover {
  color: #ef4444;
}

/* ── Shake animation ── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.shake {
  animation: shake 0.38s ease;
  border-color: #f87171 !important;
  box-shadow: 0 0 0 3px rgba(248,113,113,0.18) !important;
}
