:root {
  --accent: #3478f6;
  --bg: #faf9f8;
  --sidebar-bg: #f3f2f1;
  --panel: #ffffff;
  --text: #201f1e;
  --muted: #6e6e6e;
  --border: #e6e6e6;
  --hover: #ededed;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a19;
    --sidebar-bg: #201f1e;
    --panel: #252423;
    --text: #f3f2f1;
    --muted: #a9a9a9;
    --border: #3b3a39;
    --hover: #323130;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
button { font-family: inherit; cursor: pointer; }

/* ─── Login ─────────────────────────────────────────────────────────────── */
.login {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #6aa0ff);
}
.login-card {
  background: var(--panel); padding: 40px; border-radius: 16px;
  box-shadow: var(--shadow); width: min(380px, 90vw); text-align: center;
}
.login-logo { font-size: 48px; }
.login-card h1 { margin: 8px 0 4px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }
.login-card input, .login-card button { padding: 12px; border-radius: var(--radius); font-size: 15px; }
.login-card input { border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.login-card button { border: none; background: var(--accent); color: #fff; font-weight: 600; }
.login-msg { margin-top: 14px; font-size: 13px; min-height: 18px; word-break: break-word; }
.login-msg a { color: var(--accent); }

/* ─── Layout ────────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 290px 1fr; height: 100vh; }
.app.detail-open { grid-template-columns: 290px 1fr 340px; }

/* ─── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--sidebar-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; padding: 12px 8px;
}
.user-box { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 8px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-weight: 700; text-transform: uppercase;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: transparent; border: none; color: var(--text); font-size: 16px;
  width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--hover); }

.smart-views, .lists { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--radius);
  cursor: pointer; user-select: none; border: none; background: transparent; color: var(--text);
  width: 100%; text-align: left; font-size: 14px;
}
.nav-item:hover { background: var(--hover); }
.nav-item.active { background: var(--hover); font-weight: 600; }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-item .nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item .badge { font-size: 12px; color: var(--muted); }
.nav-item .shared-tag { font-size: 11px; color: var(--muted); }

.lists-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px 6px; font-size: 12px; text-transform: uppercase; color: var(--muted);
  letter-spacing: .5px;
}
hr.sep { border: none; border-top: 1px solid var(--border); margin: 10px 4px; }

/* ─── Main ──────────────────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; overflow: hidden; }
.main-header { display: flex; align-items: center; gap: 12px; padding: 22px 28px 8px; }
.main-header h2 { margin: 0; font-size: 24px; flex: 1; }
.menu-btn { display: none; }
.main-header-actions { display: flex; gap: 6px; }

.add-task { padding: 8px 28px; }
.add-task input {
  width: 100%; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--panel); color: var(--text); font-size: 15px; box-shadow: var(--shadow);
}
.add-task input::placeholder { color: var(--muted); }

.task-list { flex: 1; overflow-y: auto; padding: 8px 28px 40px; }
.task-row {
  display: flex; align-items: flex-start; gap: 12px; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  margin-bottom: 8px; cursor: pointer; box-shadow: var(--shadow);
}
.task-row:hover { border-color: var(--accent); }
.task-check {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted);
  flex: 0 0 auto; margin-top: 1px; display: grid; place-items: center; color: transparent;
  font-size: 12px; background: transparent;
}
.task-row.done .task-check { background: var(--accent); border-color: var(--accent); color: #fff; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-size: 15px; }
.task-row.done .task-title { text-decoration: line-through; color: var(--muted); }
.task-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.task-meta .due.overdue { color: #d13438; }
.star { background: none; border: none; font-size: 17px; color: var(--muted); }
.star.on { color: #f5b301; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.section-label { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 18px 4px 8px; letter-spacing: .5px; }

/* ─── Detail ────────────────────────────────────────────────────────────── */
.detail {
  background: var(--sidebar-bg); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px;
}
.detail-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.detail-top { display: flex; align-items: flex-start; gap: 12px; }
.detail-title { flex: 1; border: none; background: transparent; color: var(--text); font-size: 16px; font-weight: 600; resize: none; }
.detail-title:focus { outline: none; }
.detail-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-top: 1px solid var(--border); cursor: pointer; }
.detail-row:first-child { border-top: none; }
.detail-row .ic { width: 20px; text-align: center; }
.detail-row input[type="date"], .detail-row select { border: none; background: transparent; color: var(--text); font-size: 14px; flex: 1; }
.detail-notes { width: 100%; min-height: 90px; border: none; background: transparent; color: var(--text); resize: vertical; font-size: 14px; font-family: inherit; }
.step { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.step .task-check { width: 18px; height: 18px; }
.step.done span { text-decoration: line-through; color: var(--muted); }
.step input.step-add { border: none; background: transparent; color: var(--text); width: 100%; font-size: 14px; }
.detail-actions { display: flex; justify-content: space-between; margin-top: auto; padding-top: 8px; }
.btn-danger { background: transparent; border: none; color: #d13438; }
.detail-close { background: transparent; border: none; font-size: 18px; color: var(--muted); }

/* ─── Modal ─────────────────────────────────────────────────────────────── */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: grid; place-items: center; z-index: 50; }
.modal {
  background: var(--panel); border-radius: 12px; padding: 22px; width: min(460px, 92vw);
  box-shadow: var(--shadow); max-height: 86vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
.modal input, .modal select {
  width: 100%; padding: 10px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font-size: 14px;
}
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.btn { padding: 9px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.btn.primary { background: var(--accent); color: #fff; border: none; font-weight: 600; }
.token-box { font-family: monospace; background: var(--bg); padding: 10px; border-radius: 6px; word-break: break-all; border: 1px solid var(--border); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); }
.row-between:first-of-type { border-top: none; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; background: var(--hover); color: var(--muted); }
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatch.sel { border-color: var(--text); }

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .app, .app.detail-open { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .app.sidebar-open .sidebar { transform: translateX(0); box-shadow: var(--shadow); }
  .menu-btn { display: grid; }
  .detail { position: fixed; inset: 0; z-index: 40; }
}
