:root {
  --accent: #2564cf;
  --accent-soft: #eff6fc;
  --bg: #faf9f8;
  --panel: #ffffff;
  --text: #201f1e;
  --muted: #605e5c;
  --line: #edebe9;
  --danger: #a4262c;
  --star: #2564cf;
  --radius: 6px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #6ea8fe;
    --accent-soft: #1f2a3a;
    --bg: #1b1a19;
    --panel: #252423;
    --text: #f3f2f1;
    --muted: #a19f9d;
    --line: #3b3a39;
    --danger: #f1707b;
    --star: #6ea8fe;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.btn {
  display: inline-block; padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  text-decoration: none; text-align: center;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.block { display: block; width: 100%; margin-bottom: 8px; }
.icon-btn { background: none; border: 0; font-size: 18px; padding: 6px 8px; cursor: pointer; border-radius: var(--radius); }
.icon-btn:hover { background: var(--line); }

/* Login */
.login { display: grid; place-items: center; height: 100%; padding: 20px; }
.login-card { background: var(--panel); padding: 32px; border-radius: 12px; width: 100%; max-width: 340px;
  display: flex; flex-direction: column; gap: 12px; text-align: center; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.logo { width: 56px; height: 56px; margin: 0 auto; border-radius: 14px; background: var(--accent); color: #fff;
  font-size: 30px; display: grid; place-items: center; }
.login h1 { margin: 0 0 8px; font-weight: 600; }

/* Layout */
.app { display: flex; height: 100%; }
.sidebar { width: 280px; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.me { display: flex; gap: 10px; align-items: center; padding: 16px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.me-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.lists { flex: 1; overflow-y: auto; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; border-left: 3px solid transparent; }
.list-item:hover { background: var(--bg); }
.list-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
.list-item .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .count { color: var(--muted); font-size: 12px; }
.new-list { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line);
  padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.new-list input { flex: 1; border: 0; background: none; outline: none; }
.plus { color: var(--accent); font-size: 18px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 0 24px; overflow-y: auto;
  padding-top: env(safe-area-inset-top); }
.main-head { display: flex; align-items: center; gap: 6px; padding: 20px 0 12px; position: sticky; top: 0; background: var(--bg); z-index: 1; }
.list-title { flex: 1; margin: 0; font-size: 22px; font-weight: 600; color: var(--accent); cursor: text;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { margin-top: 60px; text-align: center; color: var(--muted); }

.new-task { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: 0 1px 2px rgba(0,0,0,.08); margin-bottom: 8px; }
.new-task input[type=text], #new-task-title { flex: 1; border: 0; background: none; outline: none; min-width: 0; }
#new-task-due { border: 0; background: none; color: var(--muted); max-width: 140px; }
.circle { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--accent); flex-shrink: 0; }

.tasks { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: center; gap: 12px; background: var(--panel); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 2px; box-shadow: 0 1px 1px rgba(0,0,0,.05); cursor: pointer; }
.task:hover { background: var(--accent-soft); }
.task.selected { background: var(--accent-soft); }
.task .body { flex: 1; min-width: 0; }
.task .title { overflow-wrap: anywhere; }
.task .sub { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.task .sub .overdue { color: var(--danger); }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.check { appearance: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--muted);
  cursor: pointer; flex-shrink: 0; margin: 0; display: grid; place-items: center; }
.check:hover { border-color: var(--accent); }
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after { content: "✓"; color: #fff; font-size: 12px; }
.star { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); padding: 2px 4px; }
.star.on { color: var(--star); }
.done-toggle { background: none; border: 0; padding: 14px 0 8px; font-weight: 600; cursor: pointer; text-align: left; }
.sync { padding: 16px 0 calc(16px + env(safe-area-inset-bottom)); text-align: center; }

/* Detail */
.detail { width: 340px; background: var(--panel); border-left: 1px solid var(--line); padding: 20px;
  display: flex; flex-direction: column; gap: 14px; padding-top: calc(20px + env(safe-area-inset-top)); }
.detail-head { display: flex; align-items: center; gap: 10px; }
.d-title { flex: 1; font-size: 18px; font-weight: 600; border: 0; border-bottom: 1px solid var(--line);
  background: none; outline: none; padding: 4px 0; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field textarea { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px;
  background: var(--bg); color: var(--text); resize: vertical; }
.detail-foot { margin-top: auto; display: flex; justify-content: space-between;
  padding-bottom: env(safe-area-inset-bottom); }

/* Dialogs */
dialog { border: 0; border-radius: 12px; padding: 20px; width: min(420px, calc(100vw - 32px));
  background: var(--panel); color: var(--text); box-shadow: 0 8px 32px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog h3 { margin-top: 0; }
.invite-box { display: flex; gap: 8px; margin-top: 10px; }
.invite-box input { flex: 1; min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); }
.members { list-style: none; padding: 0; margin: 0; }
.members li { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.members .avatar { width: 28px; height: 28px; font-size: 12px; }
.members .mname { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius); z-index: 10; }

/* Mobile */
.only-mobile { display: none; }
@media (max-width: 760px) {
  .only-mobile { display: inline-block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 84%; max-width: 320px; z-index: 5;
    transform: translateX(-100%); transition: transform .2s; box-shadow: 2px 0 16px rgba(0,0,0,.2); }
  .app.menu-open .sidebar { transform: none; }
  .main { padding: 0 12px; }
  .detail { position: fixed; inset: 0; width: auto; z-index: 6; border: 0; }
  #new-task-due { width: 28px; max-width: 28px; padding: 0; }
  #new-task-due::-webkit-datetime-edit { display: none; }
}
.steps { padding-left: 18px; line-height: 1.6; }
