:root {
  color-scheme: light dark;
  --canvas: #f5f5f7;
  --surface: #ffffff;
  --surface-subtle: #fafafa;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --quiet: #86868b;
  --line: rgba(0, 0, 0, 0.1);
  --line-strong: rgba(0, 0, 0, 0.16);
  --accent: #0066cc;
  --green: #55ad68;
  --red: #d94242;
  --radius: 14px;
  --radius-small: 10px;
  --content-width: 1180px;
  --page-gutter: clamp(20px, 3.5vw, 64px);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 12px 30px rgba(0, 0, 0, 0.035);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #000000;
    --surface: #1c1c1e;
    --surface-subtle: #111113;
    --ink: #f5f5f7;
    --muted: #a1a1a6;
    --quiet: #8e8e93;
    --line: rgba(255, 255, 255, 0.12);
    --line-strong: rgba(255, 255, 255, 0.2);
    --accent: #2997ff;
    --green: #92ffa8;
    --red: #ff6961;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-header, .page-shell, footer {
  width: min(var(--content-width), calc(100% - (var(--page-gutter) * 2)));
  margin-inline: auto;
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
}
.wordmark { font-size: .94rem; font-weight: 680; letter-spacing: -.018em; }
.top-navigation { display: flex; align-items: center; gap: 20px; color: var(--muted); font-size: .84rem; }
.top-navigation span { display: flex; align-items: center; gap: 7px; }
.top-navigation i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 14%, transparent); }
.top-navigation .is-syncing i { background: var(--quiet); box-shadow: none; }
.top-navigation .is-error i { background: var(--red); box-shadow: none; }
.text-button { padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.text-button:hover { color: var(--ink); }
.page-shell { min-height: calc(100vh - 126px); }
section { padding: 32px 0 36px; border-bottom: 1px solid var(--line); }
.lead { margin: 0; color: var(--muted); font-size: 1rem; }
.section-label { margin: 0 0 7px; color: var(--green); font-size: .68rem; font-weight: 720; letter-spacing: .08em; text-transform: uppercase; }
.muted-label { color: var(--quiet); }
.login-panel { width: min(480px, 100%); margin: 0 auto; padding: clamp(64px, 12vh, 110px) 0; border: 0; }
.login-panel h1 { margin: 0 0 12px; font-size: clamp(2.8rem, 6vw, 4.4rem); letter-spacing: -.055em; line-height: .95; }
.login-form { display: grid; gap: 12px; }
.login-form h1 { margin-bottom: 14px; }
.remember-toggle { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; color: var(--muted); cursor: pointer; font-size: .78rem; }
.remember-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.remember-toggle i { position: relative; width: 34px; height: 20px; border-radius: 20px; background: var(--line-strong); transition: background 140ms; }
.remember-toggle i::after { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, .24); content: ""; transition: transform 140ms; }
.remember-toggle input:checked + i { background: var(--green); }
.remember-toggle input:checked + i::after { transform: translateX(14px); }
.remember-toggle input:focus-visible + i { outline: 3px solid var(--accent); outline-offset: 3px; }
.login-form > label:not(.checkbox-row), .composer label > span, .composer-title > label, .notes-field > span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 650;
}
input[type="password"], input[type="text"], select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--ink);
}
input[type="password"], input[type="text"], select { height: 48px; padding: 0 14px; }
input[type="password"].invalid { border-color: var(--red); }
textarea { display: block; min-height: 84px; padding: 12px 14px; line-height: 1.5; resize: vertical; }
::placeholder { color: color-mix(in srgb, var(--quiet) 75%, transparent); }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; color: var(--muted); font-size: .84rem; }
.checkbox-row input { width: 17px; height: 17px; }
.primary-button, .small-button {
  min-height: 44px;
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius-small);
  background: var(--ink);
  color: var(--canvas);
  font-weight: 680;
  cursor: pointer;
}
.primary-button:hover, .small-button:hover { opacity: .88; }
.primary-button:disabled, .small-button:disabled { cursor: wait; opacity: .5; }
.login-form .primary-button { width: 100%; }
.form-message { min-height: 18px; margin: 0; color: var(--red); font-size: .78rem; }

.dashboard-section { padding-top: 34px; }
.dashboard-heading { display: flex; align-items: end; justify-content: space-between; gap: 28px; margin-bottom: 22px; }
.dashboard-heading h1 { margin: 0; font-size: clamp(2.8rem, 5.5vw, 4.8rem); font-weight: 700; letter-spacing: -.055em; line-height: .95; }
.dashboard-state { display: grid; justify-items: end; gap: 5px; color: var(--quiet); font-size: .73rem; }
.status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.status b { font-weight: 600; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 14%, transparent); }
.composer { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.composer-title { display: grid; gap: 7px; }
.composer-title input { height: 54px; font-size: 1.05rem; font-weight: 560; }
.composer-grid { display: grid; grid-template-columns: 180px 220px minmax(280px, 1fr); gap: 12px; align-items: end; }
.composer-grid > label { display: grid; gap: 7px; }
.accent-picker { display: flex; align-items: center; gap: 9px; min-height: 48px; margin: 0; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-small); }
.accent-picker legend { padding: 0 5px; color: var(--muted); font-size: .7rem; font-weight: 650; }
.accent-picker label { position: relative; }
.accent-picker input { position: absolute; opacity: 0; pointer-events: none; }
.accent-picker span { display: block; width: 24px; height: 24px; overflow: hidden; border: 2px solid transparent; border-radius: 50%; background: var(--swatch); color: transparent; cursor: pointer; font-size: 0; text-indent: -9999px; }
.accent-picker input:checked + span { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface); }
.accent-picker input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 3px; }
.notes-field { display: grid; gap: 7px; }
.notes-field small { color: var(--quiet); font-weight: 400; }
.composer-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.composer-actions .primary-button { width: auto; min-width: 160px; }

.list-section { padding-top: 30px; }
.inline-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.inline-heading h2 { margin: 0; font-size: clamp(1.55rem, 2.2vw, 2.05rem); letter-spacing: -.04em; line-height: 1.05; }
.inline-heading > span { color: var(--quiet); font-size: .82rem; }
.task-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.task-row { --task-accent: var(--green); position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; min-height: 82px; padding: 14px 15px 14px 19px; border-bottom: 1px solid var(--line); background: var(--surface); transition: background 120ms, opacity 120ms; }
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: var(--surface-subtle); }
.task-row.dragging { opacity: .42; }
.task-row.drag-over { box-shadow: inset 0 2px 0 var(--accent); }
.completion-button { display: grid; place-items: center; width: 26px; height: 26px; margin-top: 1px; padding: 0; border: 1.5px solid var(--line-strong); border-radius: 50%; background: transparent; cursor: pointer; }
.completion-button:hover { border-color: var(--task-accent); }
.completion-button span { width: 8px; height: 4px; border-bottom: 1.5px solid transparent; border-left: 1.5px solid transparent; transform: rotate(-45deg); }
.task-content { min-width: 0; }
.task-heading { display: flex; align-items: baseline; gap: 9px; }
.task-heading h3 { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 1rem; letter-spacing: -.018em; }
.editable-text { cursor: text; outline: 0; }
.editable-text:focus { background: color-mix(in srgb, var(--task-accent) 7%, transparent); border-radius: 4px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--task-accent) 7%, transparent); }
.editable-text:empty::before { color: var(--quiet); content: attr(data-placeholder); opacity: .7; }
.priority-picker { width: auto; height: auto; padding: 2px; border: 0; border-radius: 5px; background: transparent; color: var(--quiet); cursor: pointer; font-size: .65rem; font-weight: 720; letter-spacing: .055em; text-transform: uppercase; appearance: none; -webkit-appearance: none; }
.priority-picker.high, .priority-picker.urgent { color: var(--task-accent); }
.priority-badge { flex: 0 0 auto; color: var(--quiet); font-size: .65rem; font-weight: 720; letter-spacing: .055em; text-transform: uppercase; }
.priority-badge.high, .priority-badge.urgent { color: var(--task-accent); }
.task-notes { margin: 5px 0 0; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; font-size: .84rem; }
.task-notes { min-height: 20px; }
.task-meta { margin-top: 8px; color: var(--quiet); font-size: .71rem; }
.task-author { display: inline-block; min-width: 28px; }
.task-actions { display: flex; align-items: flex-start; gap: 3px; }
.icon-button { min-height: 28px; padding: 5px 7px; border: 0; border-radius: 7px; background: transparent; color: var(--quiet); font-size: .72rem; cursor: pointer; }
.icon-button:hover { background: var(--line); color: var(--ink); }
.icon-button:disabled { opacity: .25; cursor: default; }
.delete-button:hover { background: color-mix(in srgb, var(--red) 10%, transparent); color: var(--red); }
.drag-handle { padding: 2px 2px 0 5px; color: var(--quiet); cursor: grab; font-size: 1.15rem; line-height: 24px; }
.color-control { position: absolute; z-index: 1; top: 0; bottom: 0; left: 0; width: 7px; overflow: hidden; border-radius: 3px 0 0 3px; background: var(--task-accent); cursor: pointer; }
.color-control:hover { width: 9px; }
.color-picker { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.color-control:has(.color-picker:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.draft-row { margin: 8px; min-height: 84px; border: 1px dashed var(--line-strong) !important; border-radius: var(--radius-small); background: transparent; }
.draft-row:hover { background: color-mix(in srgb, var(--task-accent) 3%, transparent); }
.draft-row.saving { opacity: .55; }
.draft-row .completion-button { border-style: dashed; opacity: .45; }
.edit-form { display: grid; gap: 11px; margin-top: 13px; padding-top: 13px; border-top: 1px solid var(--line); }
.edit-form > label, .edit-grid label { display: grid; gap: 5px; color: var(--muted); font-size: .72rem; font-weight: 650; }
.edit-form input, .edit-form select { height: 40px; }
.edit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.edit-actions { display: flex; justify-content: flex-end; align-items: center; gap: 15px; }
.small-button { min-height: 36px; padding: 7px 12px; font-size: .8rem; }
.empty-state { display: grid; place-items: center; min-height: 116px; padding: 20px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 3px; color: var(--ink); }
.completed-section { border-bottom: 0; }
.completed-list .task-row { opacity: .66; }
.completed-list .task-heading h3 { text-decoration: line-through; text-decoration-color: var(--quiet); }
.completed-list .completion-button { border-color: var(--task-accent); background: var(--task-accent); }
.completed-list .completion-button span { border-color: #000; }
.completed-list .move-up, .completed-list .move-down, .completed-list .drag-handle { display: none; }
footer { display: flex; justify-content: space-between; padding: 20px 0 28px; border-top: 1px solid var(--line); color: var(--quiet); font-size: .7rem; }

@media (max-width: 820px) {
  .dashboard-heading { align-items: flex-start; flex-direction: column; gap: 14px; }
  .dashboard-state { justify-items: start; }
  .composer-grid { grid-template-columns: 1fr 1fr; }
  .accent-picker { grid-column: 1 / -1; }
  .task-row { grid-template-columns: 32px minmax(0, 1fr); }
  .task-actions { grid-column: 2; }
  .drag-handle { margin-left: auto; }
}

@media (max-width: 600px) {
  :root { --page-gutter: 16px; }
  .site-header { min-height: 58px; }
  .top-navigation { gap: 12px; }
  .top-navigation #sync-state { display: none; }
  .login-panel h1 { font-size: clamp(2.7rem, 14vw, 4rem); }
  .dashboard-heading h1 { font-size: clamp(3rem, 16vw, 4.4rem); }
  .composer { padding: 14px; }
  .composer-grid { grid-template-columns: 1fr; }
  .accent-picker { grid-column: auto; }
  .composer-actions { align-items: stretch; flex-direction: column; gap: 8px; }
  .composer-actions .primary-button { width: 100%; }
  .inline-heading > span { display: none; }
  .task-row { gap: 8px; padding: 13px 10px; }
  .task-actions { flex-wrap: wrap; }
  .move-up, .move-down { display: none; }
  .edit-grid { grid-template-columns: 1fr; }
  footer { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
