/* LeDoit — mobile-first, single column, dark */
:root {
  --bg: #12141d;
  --bg-card: #1a1e2b;
  --bg-input: #222736;
  --border: #2c3245;
  --text: #e8eaf2;
  --text-dim: #9aa1b5;
  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, .16);
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f9;
    --bg-card: #ffffff;
    --bg-input: #f0f1f6;
    --border: #e2e4ee;
    --text: #1c2030;
    --text-dim: #6b7280;
    --accent: #4f46e5;
    --accent-soft: rgba(79, 70, 229, .10);
    --shadow: 0 8px 30px rgba(30, 35, 60, .10);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); }

/* ---------- Auth ---------- */
.auth {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.brand h1 { margin: 0; font-size: 1.4rem; letter-spacing: .5px; }
.brand.small { margin: 0; }
.auth-card h2 { margin: 0 0 18px; font-size: 1.15rem; }
.auth label { display: block; margin: 12px 0 6px; font-size: .85rem; color: var(--text-dim); }
.auth input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
.auth input:focus { border-color: var(--accent); }
.field-error, .form-error { color: var(--danger); font-size: .82rem; margin: 6px 0 0; }
.btn-primary {
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 600;
}
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.switch { margin-top: 18px; font-size: .9rem; color: var(--text-dim); }
.switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.turnstile-wrap { margin-top: 16px; min-height: 66px; display: flex; justify-content: center; }

/* ---------- App ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 8px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.chip {
  background: var(--accent-soft);
  color: var(--accent);
  border: none;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: .82rem;
  font-weight: 600;
}
.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 10px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-btn.danger { color: var(--danger); border-color: var(--danger); }

.controls { padding: 4px 16px 8px; display: flex; flex-direction: column; gap: 10px; }
.controls input[type="search"] {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
.chips { display: flex; gap: 8px; overflow-x: auto; }
.filter-chip {
  background: var(--bg-input);
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .82rem;
  white-space: nowrap;
}
.filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Task list ---------- */
.task-pane { padding: 4px 16px 90px; max-width: 720px; margin: 0 auto; }
.quick-add {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.quick-add input {
  flex: 1;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}
.task-list { display: flex; flex-direction: column; gap: 2px; }
.task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: 10px;
  cursor: pointer;
}
.task-row:hover { background: var(--bg-input); }
.task-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
}
.task-row.done .task-check {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.task-title { flex: 1; min-width: 0; }
.task-title .tt { display: block; word-break: break-word; }
.task-row.done .tt { text-decoration: line-through; color: var(--text-dim); }
.task-sub {
  font-size: .78rem;
  color: var(--text-dim);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 2px;
}
.badge { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 1px 8px; font-size: .72rem; font-weight: 600; }
.badge.priority-HIGH { background: rgba(239, 68, 68, .14); color: var(--danger); }
.badge.priority-MEDIUM { background: rgba(245, 158, 11, .14); color: #f59e0b; }
.badge.status-DONE { color: var(--ok); }
.badge.due-overdue { color: var(--danger); }
.chevron {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s;
  border-radius: 6px;
  background: transparent;
  border: none;
}
.chevron.open { transform: rotate(90deg); }
.children { margin-left: 26px; border-left: 1px solid var(--border); padding-left: 6px; }
.empty { color: var(--text-dim); text-align: center; padding: 40px 0; }

/* ---------- Bottom sheet ---------- */
.sheet {
  border: none;
  border-radius: 18px 18px 0 0;
  background: var(--bg-card);
  color: var(--text);
  width: 100%;
  max-width: 640px;
  margin: auto auto 0;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(0, 0, 0, .5); }
.sheet-head { display: flex; gap: 10px; align-items: center; }
#s-title {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  font-weight: 600;
}
#s-desc {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  resize: none;
}
.sheet-row { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.sheet-row .field-label { font-size: .82rem; color: var(--text-dim); min-width: 60px; }
.pill {
  border: 1px solid var(--border);
  background: var(--bg-input);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .82rem;
  cursor: pointer;
  color: var(--text-dim);
}
.pill:has(input:checked) { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); font-weight: 600; }
.pill input { display: none; }
.sheet input[type="date"], .sheet input[type="text"] {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  flex: 1;
}
@media (min-width: 640px) {
  .sheet { border-radius: 18px; margin: auto; }
}