:root {
  color-scheme: light dark;
  --canvas: #f6f6f5;
  --surface: #ffffff;
  --surface-muted: #eeeeec;
  --text: #20201e;
  --muted: #787774;
  --line: rgba(28, 28, 26, .10);
  --hover: rgba(28, 28, 26, .055);
  --accent: #0a7cff;
  --accent-soft: rgba(10, 124, 255, .10);
  --danger: #d93838;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; min-height: 100dvh; color: var(--text); background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.todo-shell { width: min(720px, 100%); margin: 0 auto; padding: max(22px, env(safe-area-inset-top)) 18px max(40px, env(safe-area-inset-bottom)); }
header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
h1 { margin: 2px 0 0; font-size: clamp(30px, 8vw, 42px); letter-spacing: -.045em; line-height: 1; }
.eyebrow { color: var(--muted); font-size: 12px; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.sync-status { padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface-muted); font-size: 11px; font-weight: 600; }
.sync-status[data-state="saved"]::before { content: "✓ "; color: var(--accent); }
.sync-status[data-state="offline"] { color: #aa641d; }
.icon-button { min-height: 32px; border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; background: var(--surface); cursor: pointer; }

.quick-add { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 7px 7px 7px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.quick-add > span { color: var(--accent); font-weight: 600; }
.quick-add input, .search input { min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; }
.quick-add button, .primary { border: 1px solid rgba(10, 124, 255, .22); border-radius: 9px; padding: 8px 12px; color: var(--accent); background: var(--accent-soft); font-weight: 650; cursor: pointer; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 8px; color: var(--muted); font-size: 12px; }
.search { display: flex; flex: 1; align-items: center; gap: 7px; max-width: 360px; padding: 8px 10px; border-radius: 9px; background: var(--surface-muted); }
.search input { width: 100%; }
.task-list { overflow: hidden; border-top: 1px solid var(--line); }
.task-row { display: grid; grid-template-columns: 4px 30px 1fr auto 28px; align-items: center; gap: 8px; min-height: 54px; border-bottom: 1px solid var(--line); }
.task-row:hover { background: var(--hover); }
.task-row.dragging { z-index: 2; opacity: .72; background: var(--surface-muted); }
.priority-bar { width: 4px; height: 32px; border-radius: 2px; background: #9aa5b1; }
.priority-bar[data-priority="urgent"] { background: #e85d75; }
.priority-bar[data-priority="high"] { background: #e99a5e; }
.priority-bar[data-priority="medium"] { background: #d7b45a; }
.priority-bar[data-priority="low"] { background: #6f92c4; }
.priority-bar[data-priority="normal"] { background: #9aa5b1; }
.task-toggle { display: grid; width: 30px; height: 38px; place-items: center; border: 0; background: transparent; cursor: pointer; }
.task-toggle span { display: grid; width: 20px; height: 20px; place-items: center; border: 1.7px solid #979794; border-radius: 50%; color: transparent; font-size: 12px; }
.task-row.completed .task-toggle span { border-color: var(--accent); color: white; background: var(--accent); }
.task-content { min-width: 0; border: 0; padding: 10px 0; text-align: left; background: transparent; cursor: pointer; }
.task-title { display: block; overflow: hidden; font-size: 14px; font-weight: 550; text-overflow: ellipsis; white-space: nowrap; }
.task-note { display: block; overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.task-row.completed .task-title { color: var(--muted); text-decoration: line-through; }
.task-date { padding-right: 8px; color: var(--muted); font-size: 11px; }
.drag-handle { display: grid; width: 28px; height: 38px; place-items: center; border: 0; padding: 0; color: var(--muted); background: transparent; cursor: grab; touch-action: none; }
.drag-handle:active { cursor: grabbing; }
.drag-handle:disabled { visibility: hidden; }
body.task-dragging { user-select: none; }
.section-toggle { display: flex; width: 100%; align-items: center; gap: 7px; min-height: 46px; border: 0; padding: 0; background: transparent; font-weight: 650; cursor: pointer; }
.chevron { transform: rotate(0); font-size: 20px; line-height: 1; }
.section-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }
.muted { color: var(--muted); font-weight: 400; }
.empty-state { display: grid; place-items: center; min-height: 260px; color: var(--muted); text-align: center; }
.empty-state span { display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-size: 20px; }
.empty-state strong { margin-top: 12px; color: var(--text); }
.empty-state p { margin: 4px 0 0; font-size: 12px; }

.login-shell { display: grid; min-height: 100dvh; place-items: center; padding: 24px; }
.login-card { width: min(360px, calc(100vw - 48px)); padding: 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.app-mark { display: block; width: 64px; height: 64px; border-radius: 16px; }
.login-card h1 { margin-top: 18px; }
.login-card p { margin: 8px 0 24px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.login-card form { display: grid; gap: 9px; }
.login-card label, dialog label { color: var(--muted); font-size: 12px; font-weight: 600; }
.login-card input, dialog input, dialog textarea, dialog select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; outline: 0; color: var(--text); background: var(--canvas); }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.error { min-height: 18px; color: var(--danger); font-size: 12px; }

dialog { width: min(520px, calc(100% - 24px)); border: 1px solid var(--line); border-radius: 16px; padding: 0; color: var(--text); background: var(--surface); }
dialog::backdrop { background: rgba(0, 0, 0, .24); }
dialog form { display: grid; gap: 10px; padding: 18px; }
.dialog-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dialog-header h2 { margin: 0; font-size: 18px; }
dialog textarea { resize: vertical; }
.dialog-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; }
.danger { border: 1px solid rgba(217, 56, 56, .2); border-radius: 9px; padding: 8px 12px; color: var(--danger); background: rgba(217, 56, 56, .07); cursor: pointer; }
.sr-only { position: absolute; overflow: hidden; width: 1px; height: 1px; clip: rect(0, 0, 0, 0); white-space: nowrap; }

button:active { opacity: .72; }
@media (prefers-reduced-motion: no-preference) {
  .task-row, button { transition: background-color 100ms ease, opacity 100ms ease; }
  .chevron { transition: transform 140ms cubic-bezier(.23, 1, .32, 1); }
}
@media (prefers-color-scheme: dark) {
  :root { --canvas: #191918; --surface: #222221; --surface-muted: #2b2b29; --text: #f2f2ef; --muted: #a2a29e; --line: rgba(255, 255, 255, .10); --hover: rgba(255, 255, 255, .055); }
}
@media (min-width: 760px) {
  .todo-shell { padding-top: 54px; }
}
