:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #16181d;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #dc2626;
  --must-do: #dc2626;
  --good-to-have: #2563eb;
  --not-started: #9ca3af;
  --in-progress: #d97706;
  --completed: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

/* Ensure the hidden attribute always wins over component display rules below. */
[hidden] { display: none !important; }

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

button, input, select {
  font-family: inherit;
  font-size: 14px;
}

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

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  border: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
}

.auth-sub {
  color: var(--text-muted);
  margin: 8px 0 24px;
  font-size: 14px;
}

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

.auth-form input {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}

.auth-form input:focus {
  border-color: var(--primary);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.auth-row {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
}

.link-btn:hover { color: var(--primary); }

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin: 18px 0;
}

.divider::before, .divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--border);
}

.divider span { padding: 0 10px; }

.btn-google {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text);
}

.btn-google:hover { background: #f9fafb; }

.auth-error {
  margin-top: 14px;
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

.auth-note {
  margin-top: 14px;
  color: var(--completed);
  font-size: 13px;
  text-align: center;
}

/* ---------- App view ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

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

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-ghost:hover { background: var(--bg); }

.main {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.add-task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}

.add-task-card h2 {
  margin: 0 0 14px;
  font-size: 16px;
}

.task-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#task-name {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

#task-name:focus { border-color: var(--primary); }

.field-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
  min-width: 130px;
}

.field-label select {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

.add-btn {
  height: 38px;
  white-space: nowrap;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.dashboard-header h2 {
  font-size: 16px;
  margin: 0;
}

.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.priority-hint {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
  font-style: italic;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.task-card.completed { opacity: 0.6; }

.task-main {
  flex: 1;
  min-width: 0;
}

.task-name {
  font-weight: 600;
  font-size: 14.5px;
  margin: 0 0 4px;
  word-break: break-word;
}

.task-card.completed .task-name {
  text-decoration: line-through;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-must_do { background: #fee2e2; color: var(--must-do); }
.badge-good_to_have { background: #dbeafe; color: var(--good-to-have); }

.due-date { white-space: nowrap; }
.due-date.overdue { color: var(--danger); font-weight: 600; }

.status-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
}

.status-select.not_started { color: var(--not-started); }
.status-select.in_progress { color: var(--in-progress); }
.status-select.completed { color: var(--completed); }

.delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
}

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

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 0;
  font-size: 14px;
}

@media (max-width: 520px) {
  .field-row { flex-direction: column; align-items: stretch; }
  .add-btn { width: 100%; }
  .task-card { flex-wrap: wrap; }
  .topbar { padding: 14px 16px; }
}
