:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-alt: #fafbfd;
  --text: #14161c;
  --text-muted: #6b7280;
  --border: #e6e8f0;
  --accent: #6366f1;
  --accent-dark: #4f46e5;
  --accent-light: #eef0ff;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fef2f2;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(20, 22, 40, 0.05);
  --shadow-md: 0 6px 16px rgba(20, 22, 40, 0.07);
  --shadow-lg: 0 18px 40px rgba(20, 22, 40, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1016;
    --surface: #171923;
    --surface-alt: #1c1f2b;
    --text: #eef0f6;
    --text-muted: #9198ab;
    --border: #2a2e3c;
    --accent: #818cf8;
    --accent-dark: #a5b4fc;
    --accent-light: #24263b;
    --success: #34d399;
    --success-light: #123527;
    --danger: #f87171;
    --danger-light: #3a1d20;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow-sm);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark { font-size: 1.2rem; line-height: 1; }
.brand-year { color: var(--text-muted); font-weight: 500; }

.logout-form { display: flex; align-items: center; gap: 0.85rem; }
.username { color: var(--text-muted); font-size: 0.85rem; }

/* ---------- Layout ---------- */

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

h1 { margin: 0.2rem 0; font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; }
h2.section-title {
  margin-top: 2.75rem;
  margin-bottom: 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.muted { color: var(--text-muted); font-size: 0.9rem; }
.back-link { display: inline-block; margin-bottom: 0.6rem; font-size: 0.85rem; color: var(--text-muted); }

.project-title-row { display: flex; align-items: center; gap: 0.75rem; }

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.button:hover { background: var(--accent-dark); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.button.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); box-shadow: none; }
.button.secondary:hover { background: var(--surface-alt); transform: none; box-shadow: none; }

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
}
.link-button:hover { text-decoration: underline; }
.link-button.danger { color: var(--danger); }
.delete-form { display: inline; }

/* ---------- Empty state ---------- */

.empty-state {
  color: var(--text-muted);
  background: var(--surface);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.empty-state-icon { font-size: 2rem; margin-bottom: 0.4rem; }
.empty-state p { margin: 0; }
.empty-state .button { margin-top: 1rem; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.badge-lg { width: 44px; height: 44px; font-size: 1.2rem; border-radius: 12px; }

.badge-c0 { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.badge-c1 { background: linear-gradient(135deg, #f472b6, #db2777); }
.badge-c2 { background: linear-gradient(135deg, #fbbf24, #d97706); }
.badge-c3 { background: linear-gradient(135deg, #34d399, #059669); }
.badge-c4 { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.badge-c5 { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.badge-c6 { background: linear-gradient(135deg, #fb923c, #ea580c); }
.badge-c7 { background: linear-gradient(135deg, #2dd4bf, #0d9488); }

/* ---------- Project grid / cards ---------- */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.1rem;
}

.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}
.project-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: transparent; }
.project-card-link { color: inherit; display: block; }
.project-card-link:hover { text-decoration: none; }
.project-card-head { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.4rem; }
.project-card h2 { margin: 0; font-size: 1.05rem; font-weight: 700; }

/* ---------- Progress bar ---------- */

.progress-bar {
  background: var(--border);
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
  margin: 0.85rem 0 0.4rem;
}
.progress-bar-fill {
  background: linear-gradient(90deg, var(--accent), #a855f7);
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}
.progress-label { margin: 0; font-size: 0.85rem; font-weight: 700; }

/* ---------- Forms ---------- */

.stacked-form { display: flex; flex-direction: column; gap: 0.4rem; max-width: 480px; }
.stacked-form label { font-size: 0.8rem; font-weight: 600; margin-top: 0.6rem; color: var(--text-muted); }
.stacked-form input,
.stacked-form textarea {
  padding: 0.65rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.stacked-form input:focus,
.stacked-form textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-light);
}
.stacked-form button {
  margin-top: 1.25rem;
  align-self: flex-start;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.65rem 1.3rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.stacked-form button:hover { background: var(--accent-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.form-row { display: flex; gap: 1rem; }
.form-row > div { flex: 1; display: flex; flex-direction: column; }

.error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.95rem;
  font-size: 0.9rem;
  font-weight: 500;
}

/* ---------- Auth ---------- */

.auth-card {
  max-width: 360px;
  margin: 4rem auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent-light);
  font-size: 1.6rem;
  margin-bottom: 0.75rem;
}
.auth-card h1 { font-size: 1.35rem; margin: 0 0 0.25rem; }
.auth-subtitle { margin: 0 0 1.5rem; }
.auth-card .stacked-form { text-align: left; margin: 0 auto; }
.auth-card .stacked-form button { align-self: stretch; text-align: center; margin-top: 1.5rem; }

/* ---------- Task list ---------- */

.task-list { list-style: none; margin: 1rem 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  transition: box-shadow 0.15s ease, opacity 0.15s ease;
}
.task-row:hover { box-shadow: var(--shadow-sm); }
.task-row.task-done { opacity: 0.7; }

.task-toggle-form { margin: 0; }
.checkbox {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.1rem;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}
.checkbox:hover { border-color: var(--accent); transform: scale(1.05); }
.task-done .checkbox { background: var(--success); border-color: var(--success); }

.task-info { flex: 1; min-width: 0; }
.task-title { margin: 0; font-weight: 600; }
.task-done .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-description { margin: 0.2rem 0 0; }
.task-dates { margin: 0.3rem 0 0; font-size: 0.8rem; }

.task-actions { display: flex; gap: 0.85rem; font-size: 0.82rem; white-space: nowrap; padding-top: 0.1rem; }

.task-form { margin-top: 0.75rem; }

@media (max-width: 480px) {
  .task-row { flex-wrap: wrap; }
  .task-actions { width: 100%; justify-content: flex-end; }
  .container { padding: 1.75rem 1.1rem 4rem; }
}
