:root {
  --bg: #f5f5f4;
  --card: #fff;
  --text: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --accent: #2563eb;
  --danger: #dc2626;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0c0a09; --card: #1c1917; --text: #f5f5f4; --muted: #a8a29e; --line: #292524; --accent: #60a5fa; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.center { text-align: center; margin-top: 30vh; }
.error { color: var(--danger); }

/* Sign-in */
.signin { max-width: 380px; margin: 18vh auto 0; padding: 28px; background: var(--card); border-radius: 16px; border: 1px solid var(--line); }
.signin h1 { font-size: 22px; margin: 0 0 6px; }
.signin p { margin: 0 0 16px; }
.signin input { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); margin-bottom: 12px; }
.btn { padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.wide { width: 100%; padding: 11px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Board */
header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
header h1 { font-size: 17px; margin: 0; flex: 1; min-width: 120px; }
header .who { font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 16px 0; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); }
.chip.on { border-color: currentColor; font-weight: 600; }
.board { display: flex; gap: 12px; padding: 12px 16px 40px; overflow-x: auto; align-items: flex-start; min-height: calc(100vh - 110px); scroll-snap-type: x proximity; }
.col { flex: 0 0 290px; background: color-mix(in srgb, var(--line) 45%, transparent); border-radius: var(--radius); padding: 8px; scroll-snap-align: start; }
@media (max-width: 640px) { .col { flex-basis: 86vw; } }
.col h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 6px 8px; display: flex; justify-content: space-between; }
.card { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; margin-bottom: 8px; }
.card:hover { border-color: var(--muted); }
.card .title { font-weight: 550; }
.card .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--muted); }
.card .meta .overdue { color: var(--danger); font-weight: 600; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--tc, #888) 18%, transparent); color: var(--tc, var(--muted)); font-weight: 600; }
.add { width: 100%; text-align: left; color: var(--muted); background: none; border: 0; padding: 6px; }

/* Sheet */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 6vh 12px; }
.sheet { width: 100%; max-width: 560px; background: var(--card); border-radius: 16px; padding: 18px; border: 1px solid var(--line); }
.sheet h2 { margin: 0 0 12px; font-size: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); }
.field textarea { min-height: 110px; resize: vertical; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.datefield { display: flex; gap: 6px; }
.datefield input[type=date] { flex: 1.4; }
.datefield input[type=time] { flex: 1; }
.tagpick { display: flex; gap: 6px; flex-wrap: wrap; }
.tagpick label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text); }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.notes { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 12px; }
.note { margin-bottom: 10px; }
.note .by { font-size: 12px; color: var(--muted); }
.note .body { white-space: pre-wrap; }
.readonly .desc { white-space: pre-wrap; margin: 8px 0; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1c1917; color: #fff; padding: 9px 14px; border-radius: 10px; z-index: 20; font-size: 14px; }
