:root {
  --primary-purple: #8b5cf6;
  --secondary-pink: #ec4899;
  --accent-blue: #3b82f6;
  --light-purple: #f5f3ff;
  --card-white: #ffffff;
  --text-dark: #1e1b4b;
  --text-muted: #6b7280;
  --border-gray: #e5e7eb;
  --danger: #ef4444;
  --gradient-primary: linear-gradient(135deg, var(--primary-purple), var(--secondary-pink));
  --gradient-accent: linear-gradient(135deg, var(--secondary-pink), var(--accent-blue));
}

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

body {
  background-color: var(--light-purple);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  color: var(--text-dark);
}

.max-width {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
}

header {
  background-image: var(--gradient-primary);
  color: var(--card-white);
  text-align: center;
  padding: 2rem 1.5rem;
  border-radius: 0 0 16px 16px;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.25);
  margin-bottom: 1rem;
}

header h1 {
  font-size: 1.75rem;
  margin-bottom: 0.35rem;
}

header p {
  opacity: 0.9;
  font-size: 0.95rem;
}

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

.stat-card {
  background-color: var(--card-white);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  background-image: var(--gradient-accent);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

form {
  background-color: var(--card-white);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

input[type="text"] {
  flex: 1;
  border: 2px solid var(--border-gray);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  outline: none;
  color: var(--text-dark);
  background: #fff;
}

input[type="text"]:focus {
  border-color: var(--primary-purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

button[type="submit"] {
  background-image: var(--gradient-primary);
  background-size: 100% 100%;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.7rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

button[type="submit"]:hover {
  opacity: 0.95;
}

button[type="submit"]:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.filter-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.filter-buttons button {
  background: var(--card-white);
  border: 1px solid var(--border-gray);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.filter-buttons button.active {
  background-image: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
}

.habit-list-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 120px;
}

.habit-item {
  background: var(--card-white);
  border-radius: 14px;
  padding: 0.9rem 1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.habit-toggle {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
  accent-color: var(--primary-purple);
}

.habit-name {
  flex: 1;
  word-break: break-word;
}

.habit-delete {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
}

.habit-delete:hover {
  background: rgba(239, 68, 68, 0.08);
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 1rem;
  background: var(--card-white);
  border-radius: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.error-banner {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  display: none;
}

.error-banner.visible {
  display: block;
}

footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 2rem 0 1rem;
}

@media (max-width: 480px) {
  form {
    flex-direction: column;
  }

  .stats-bar {
    gap: 0.5rem;
  }

  .stat-number {
    font-size: 1.5rem;
  }
}
