:root {
  --paper: #ECE7DC;
  --surface: #F7F4EC;
  --ink: #22281F;
  --ink-soft: #5F6558;
  --ink-faint: #8B9081;
  --line: #D6CFBB;
  --accent: #2F5233;
  --accent-ink: #F7F4EC;
  --accent-soft: #DFE6D9;
  --gold: #A8752E;
  --danger: #9C3F2C;
  --danger-soft: #F1DED7;
  --radius: 3px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}

body {
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

button {
  font-family: var(--sans);
  cursor: pointer;
}

input {
  font-family: var(--sans);
}

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

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

.auth-card {
  width: 100%;
  max-width: 380px;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  color: var(--ink);
}

.auth-sub {
  font-size: 14px;
  color: var(--ink-soft);
  margin: 0 0 24px;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.auth-tab {
  background: transparent;
  border: none;
  padding: 8px 4px 10px;
  margin-right: 20px;
  font-size: 14px;
  color: var(--ink-faint);
  border-bottom: 2px solid transparent;
}

.auth-tab.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

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

.auth-form label,
.auth-config label {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 8px;
}

.auth-form input,
.auth-config input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
}

.auth-form input:focus,
.auth-config input:focus,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.auth-form button,
.cfg-save-row button {
  margin-top: 4px;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
}

.auth-form button:hover { background: #24401F; }

.auth-status {
  min-height: 18px;
  font-size: 13px;
  color: var(--accent);
  margin: 10px 0 0;
}

.auth-config {
  margin-top: 28px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.auth-config summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-soft);
}

.auth-config p {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.auth-config button {
  margin-top: 10px;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--surface);
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
}

/* ---------- App shell ---------- */

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
}

.topbar .wordmark { font-size: 20px; }

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

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

.ghost-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: 13px;
}

.ghost-btn:hover { border-color: var(--ink-soft); color: var(--ink); }

.ghost-btn.danger {
  color: var(--danger);
  border-color: var(--danger-soft);
}

.ghost-btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sidebar-head h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 15px;
  margin: 0;
  color: var(--ink-soft);
}

.project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.project-list li {
  border-radius: var(--radius);
}

.project-list button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 9px 10px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.project-list button:hover { background: var(--surface); }

.project-list li.active button {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.project-count {
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
  font-size: 12px;
}

.project-list li.active .project-count { color: var(--accent); }

.new-project-form {
  display: flex;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.new-project-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 13px;
}

.new-project-form button {
  padding: 8px 12px;
  background: var(--ink);
  color: var(--surface);
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
}

/* ---------- Main ---------- */

.main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

.empty-state {
  max-width: 400px;
  margin-top: 60px;
}

.empty-state p { margin: 0 0 6px; font-size: 15px; }
.empty-state .empty-sub { color: var(--ink-soft); font-size: 13px; }

.project-view-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

#project-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 26px;
  margin: 0;
}

.progress-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  max-width: 420px;
}

.progress-track {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gold);
  width: 0%;
  transition: width 0.25s ease;
}

.progress-label {
  font-size: 12px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.task-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  max-width: 560px;
  border-top: 1px solid var(--line);
}

.task-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
}

.task-list input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.task-title {
  flex: 1;
  font-size: 14px;
}

.task-list li.done .task-title {
  color: var(--ink-faint);
  text-decoration: line-through;
}

.task-remove {
  background: transparent;
  border: none;
  color: var(--ink-faint);
  font-size: 16px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.1s;
}

.task-list li:hover .task-remove { opacity: 1; }

.task-remove:hover { color: var(--danger); background: var(--danger-soft); }

.new-task-form {
  display: flex;
  gap: 8px;
  max-width: 560px;
}

.new-task-form input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 14px;
}

.new-task-form button {
  padding: 10px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
}

.new-task-form button:hover { background: #24401F; }

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
    max-height: 40vh;
  }
  .main { padding: 24px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill { transition: none; }
}
