:root {
  --bg:              #0d0f18;
  --surface:         #161929;
  --surface-raised:  #1e2235;
  --border:          #252840;
  --text:            #f0f2fa;
  --text-muted:      #7c85a2;
  --text-subtle:     #454e6b;
  --accent:          #5b8df6;
  --accent-hover:    #4a7ce5;
  --accent-glow:     rgba(91, 141, 246, 0.15);
  --success:         #34d399;
  --danger:          #f87171;
  --danger-hover-bg: rgba(248, 113, 113, 0.08);
  --radius-sm:       6px;
  --radius:          10px;
  --radius-lg:       16px;
  --shadow-card:     0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.25);
  --shadow-raised:   0 2px 8px rgba(0,0,0,0.5), 0 8px 32px rgba(0,0,0,0.3);
  --transition:      0.18s ease;
  --font:            -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

/* ── Auth page ── */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-bg-glow {
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse, rgba(91, 141, 246, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-raised);
  position: relative;
  z-index: 1;
}

.auth-logo {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--accent);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-logo::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 3px;
  flex-shrink: 0;
}

.auth-tagline {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.auth-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  padding: 12px;
  transition: background var(--transition);
}

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

.auth-switch {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

.auth-switch button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  text-decoration: underline;
}

.error-msg {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  display: none;
  font-size: 14px;
  padding: 10px 14px;
}

/* ── App page ── */

.app-header {
  background: rgba(22, 25, 41, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--border), var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-logo {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-logo::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 3px;
  flex-shrink: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
}

.user-email {
  color: var(--text-muted);
  font-size: 14px;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 7px 14px;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-hover-bg);
}

.app-main {
  max-width: 640px;
  margin: 36px auto;
  padding: 0 24px;
}

/* ── Stats row ── */

.stats-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 20px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.stats-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  align-items: center;
}

.stats-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stats-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.stats-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── Add form ── */

.add-form {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px 4px 4px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.add-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.add-form input {
  background: transparent;
  border: none;
  color: var(--text);
  flex: 1;
  font-size: 15px;
  outline: none;
  padding: 10px 8px 10px 0;
}

.add-form input::placeholder {
  color: var(--text-subtle);
}

.btn-add {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  font-size: 22px;
  font-weight: 300;
  padding: 8px 18px;
  transition: background var(--transition);
  line-height: 1;
}

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

/* ── Filter tabs ── */

.filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
}

.filter-tab {
  flex: 1;
  background: none;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 0;
  transition: background var(--transition), color var(--transition);
}

.filter-tab:hover {
  color: var(--text);
  background: var(--surface-raised);
}

.filter-tab.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ── Todo list ── */

.todo-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Todo item ── */

.todo-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px 16px 20px;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
  overflow: hidden;
}

.todo-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.todo-item:hover {
  border-color: #353858;
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.todo-item:hover::before,
.todo-item.is-editing::before {
  opacity: 1;
}

.todo-item.completed::before {
  background: var(--success);
  opacity: 0.5;
}

/* ── Custom checkbox ── */

.todo-check {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color var(--transition), background var(--transition);
  background: transparent;
}

.todo-check:hover {
  border-color: var(--accent);
}

.todo-check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.todo-check:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.todo-check:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── Todo body ── */

.todo-body {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}

.todo-title {
  flex: 1;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.todo-edit-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  flex: 1;
  font-size: 15px;
  outline: none;
  padding: 6px 10px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.todo-edit-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

/* ── Todo action buttons ── */

.todo-edit-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.edit-btn,
.save-btn,
.cancel-btn,
.delete-btn {
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 14px;
  opacity: 0;
  padding: 5px 8px;
  transition: color var(--transition), opacity var(--transition), background var(--transition);
}

.todo-item:hover .edit-btn,
.todo-item:hover .delete-btn,
.todo-item.is-editing .save-btn,
.todo-item.is-editing .cancel-btn,
.todo-item.is-editing .delete-btn {
  opacity: 1;
}

.todo-item.is-editing .edit-btn {
  opacity: 0 !important;
}

.edit-btn:hover,
.save-btn:hover {
  color: var(--accent);
  background: var(--accent-glow);
}

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

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

/* ── Empty state ── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 24px;
  list-style: none;
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 16px;
  opacity: 0.35;
  display: block;
  line-height: 1;
}

.empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

/* ── Error banner ── */

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

.app-error {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  display: none;
  font-size: 14px;
  margin-bottom: 16px;
  padding: 10px 14px;
  animation: slideDown 0.2s ease;
}
