/* ===== Reset & base ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --primary: #4f6ef7;
  --primary-dark: #3d55d8;
  --text: #2d3142;
  --text-muted: #9297a7;
  --danger: #e5533d;
  --border: #e3e5ea;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(45, 49, 66, 0.1);
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(135deg, #e8ebf5 0%, #f4f5f7 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 40px 16px;
}

.app {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  height: fit-content;
}

/* ===== Header ===== */
.back-link {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 14px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all 0.2s;
}

.back-link:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-header h1 {
  font-size: 1.9rem;
  font-weight: 700;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 6px;
}

/* ===== Form ===== */
.todo-form {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.todo-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s;
}

.todo-input:focus {
  border-color: var(--primary);
}

.btn-add {
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-add:hover {
  background: var(--primary-dark);
}

/* ===== Filters ===== */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.filter-btn {
  flex: 1;
  padding: 8px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.filter-btn.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

/* ===== Todo list ===== */
.todo-list {
  list-style: none;
}

.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  animation: slide-in 0.25s ease;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.todo-item .todo-text {
  flex: 1;
  font-size: 1rem;
  word-break: break-word;
  cursor: pointer;
}

.todo-item.completed .todo-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Custom checkbox */
.todo-check {
  appearance: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  display: grid;
  place-content: center;
  transition: all 0.2s;
}

.todo-check:hover {
  border-color: var(--primary);
}

.todo-check:checked {
  background: var(--primary);
  border-color: var(--primary);
}

.todo-check:checked::after {
  content: "✓";
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.btn-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-delete:hover {
  color: var(--danger);
  background: #fdecea;
}

/* ===== Empty state ===== */
.empty-message {
  text-align: center;
  color: var(--text-muted);
  padding: 28px 0;
  font-size: 0.95rem;
}

.hidden {
  display: none;
}

/* ===== Footer ===== */
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.items-left {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.btn-clear {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-clear:hover {
  color: var(--danger);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .app {
    padding: 20px;
  }

  .todo-form {
    flex-direction: column;
  }
}
