:root {
  --bg: #f3f7fc;
  --surface: #ffffff;
  --text: #20344d;
  --muted: #52677f;
  --line: #d4deea;
  /* Borders of fields and buttons: at least 3:1 against the surface and page,
     so every place to type or tap is visible. */
  --field: #ffffff;
  --field-line: #71859c;
  --accent: #245fa8;
  --accent-text: #ffffff;
  --soft: #e6f0fb;
  --note: #eaf2fc;
  /* A note's own icon colour; a list's is the accent. */
  --kind-note: #1d6f55;
  --kind-note-soft: #e0f3ea;
  --danger: #a33a2c;
  --danger-text: #ffffff;
  --danger-soft: #f8e5e0;
  --warn-bg: #fff0ce;
  --shadow: 0 3px 12px #20344d06;
  --menu-shadow: 0 10px 28px #20344d24;
  --backdrop: #101d3066;
  --toast-bg: #245fa8;
  --toast-text: #ffffff;
  --toast-action-bg: #ffffff;
  --toast-action: #245fa8;
  --important: #b54708;
  --important-text: #ffffff;
  --important-soft: #fdeedc;
  --priority-high: #a52e3b;
  --priority-high-bg: #fbe7e9;
  --priority-medium: #865000;
  --priority-medium-bg: #fff0ce;
  --priority-low: #216b50;
  --priority-low-bg: #e0f3ea;
  --priority-solid-text: #ffffff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121d2b;
    --surface: #1c2b3d;
    --text: #edf3fa;
    --muted: #b4c3d4;
    --line: #3b4d62;
    --field: #142131;
    --field-line: #7a8fa8;
    --accent: #a4c9fa;
    --accent-text: #122b49;
    --soft: #263d57;
    --note: #263950;
    --kind-note: #8fd8b9;
    --kind-note-soft: #1f3c33;
    --danger: #ffac9c;
    --danger-text: #3a120b;
    --danger-soft: #4a2c26;
    --warn-bg: #443923;
    --shadow: none;
    --menu-shadow: 0 10px 28px #0000005c;
    --backdrop: #00000080;
    --toast-bg: #a4c9fa;
    --toast-text: #122b49;
    --toast-action-bg: #122b49;
    --toast-action: #a4c9fa;
    --important: #f2a65e;
    --important-text: #2b1a08;
    --important-soft: #46301c;
    --priority-high: #ffb4bc;
    --priority-high-bg: #502932;
    --priority-medium: #f6ca7d;
    --priority-medium-bg: #49371e;
    --priority-low: #9cddbb;
    --priority-low-bg: #203e32;
    --priority-solid-text: #121d2b;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); text-underline-offset: 3px; }
button, input, textarea, select { font: inherit; }
button, select {
  min-height: 46px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  padding: 10px 18px;
  color: var(--text);
  background: var(--surface);
}
button, summary, select { cursor: pointer; }
button:hover, select:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.link { background: none; border: 0; padding: 10px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 4px; }
button.link.danger { color: var(--danger); }
button.icon { padding: 6px 12px; min-width: 44px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
input, textarea {
  width: 100%;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--field-line);
  border-radius: 12px;
  background: var(--field);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:hover, textarea:hover { border-color: var(--accent); }
input:focus, textarea:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 2.8rem); line-height: 1.15; letter-spacing: -0.045em; margin-bottom: 12px; }
h2 { font-size: 1.125rem; margin-bottom: 0; font-weight: 650; }
h3 { font-size: 1.3rem; line-height: 1.35; letter-spacing: -0.025em; }
main { max-width: 1168px; margin: 0 auto; padding: 0 max(24px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left)); }
main:focus { outline: none; }
.sr-only, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link:focus { display: block; padding: 12px; background: var(--surface); }
.masthead { max-width: 1168px; margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 24px max(24px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-size: 1.25rem; font-weight: 700; letter-spacing: -0.03em; text-decoration: none; color: var(--text); }
.who { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--muted); font-size: 0.9375rem; }
.who-name { color: var(--text); font-weight: 600; }
.who-switch { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.who-switch button { min-height: 38px; padding: 6px 14px; border: 0; border-radius: 11px; background: none; color: var(--muted); }
.who-switch button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.brand-mark { background: var(--accent); color: var(--accent-text); display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; }
.welcome { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 0 20px; }
.welcome h1 { margin-bottom: 0; }
.intro { color: var(--muted); margin-bottom: 0; max-width: 440px; }
.create-actions { display: flex; gap: 10px; flex-shrink: 0; }
form { margin: 0; }
.browse { display: flex; align-items: center; gap: 10px; padding: 12px; margin-bottom: 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.search-field { flex: 1; min-width: 0; }
.reset-search { padding: 10px 4px; }
.meta { color: var(--muted); font-size: 0.9375rem; margin: 0; }
.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 24px; align-items: start; }
.group h2 { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.group-count { color: var(--muted); font-size: 0.9375rem; font-weight: 400; }
.rows { container-type: inline-size; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.row-line { display: flex; align-items: center; border-top: 1px solid var(--line); }
.row-line:first-child { border-top: 0; }
.row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 8px 14px; color: var(--text); text-decoration: none; }
/* Held to delete (app.js): no selection or phone link menu while holding. */
[data-press-delete] { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.row-line:hover { background: var(--soft); }
/* A bin beside every row, item, attachment and in a note's top bar; holding
   a row asks the same (app.js). */
.row-delete, .item-delete, .bar-delete button, .file-delete, .deleted-item .purge { display: grid; place-items: center; flex: none; width: 44px; min-height: 44px; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--muted); }
.row-delete:hover, .item-delete:hover, .bar-delete button:hover, .file-delete:hover, .deleted-item .purge:hover { color: var(--danger); background: var(--danger-soft); }
.row-delete { margin-right: 4px; }
.row:focus-visible { outline-offset: -3px; }
/* Lists and notes each have their own icon, wherever they appear. */
.kind-icon { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; }
.kind-list { background: var(--soft); color: var(--accent); }
.kind-note { background: var(--kind-note-soft); color: var(--kind-note); }
.create-actions button, .new-list-form h2 { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.create-actions .kind-icon { width: auto; height: auto; background: none; color: inherit; }
.row-icon { flex: none; width: 24px; text-align: center; color: var(--accent); }
img.logo { display: block; width: 22px; height: 22px; border-radius: 5px; }
.row-icon img.logo { margin: 0 auto; }
.row-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.row-title.untitled { color: var(--muted); font-weight: 400; }
.row-meta { flex: none; display: flex; gap: 10px; color: var(--muted); font-size: 0.9375rem; white-space: nowrap; }
.row-count { color: var(--accent); font-variant-numeric: tabular-nums; }
.row-count.complete { color: var(--muted); }
.row-lock { flex: none; display: grid; color: var(--muted); }
.trash-link { grid-column: 1 / -1; margin: 0; }
.trash-link a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--muted); text-decoration: none; }
.trash-link a:hover { color: var(--text); }
/* Important lists and notes carry a round "!" and come first. */
.flag { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--important); color: var(--important-text); font-size: 0.8125rem; font-weight: 800; line-height: 1; }
.important-toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.important-toggle .flag { background: none; color: inherit; box-shadow: inset 0 0 0 2px currentColor; }
.important-toggle[aria-pressed="true"] { color: var(--important); border-color: var(--important); background: var(--important-soft); font-weight: 600; }
.important-toggle[aria-pressed="true"] .flag { background: var(--important); color: var(--important-text); box-shadow: none; }
.paper-heading .important-toggle { min-height: 40px; padding: 4px 14px 4px 10px; border-radius: 20px; font-size: 0.9375rem; }
.heading-toggles { display: contents; }
.owner-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); background: var(--soft); }
.kind-label { display: inline-flex; gap: 7px; align-items: center; font-size: 0.9375rem; font-weight: 600; }
progress { height: 6px; border: 0; border-radius: 3px; background: var(--line); color: var(--accent); overflow: hidden; -webkit-appearance: none; appearance: none; }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--accent); border-radius: 3px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 3px; }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 48px 24px; border: 1px dashed var(--line); border-radius: 18px; }
.empty-state p { max-width: 480px; color: var(--muted); margin: 0 auto 16px; }
.empty-mark { display: inline-grid; place-items: center; width: 56px; height: 56px; background: var(--soft); color: var(--accent); border-radius: 18px; font-size: 1.7rem; margin-bottom: 20px; }
.empty-state h3 { margin-bottom: 10px; }
.device-help { margin-top: 36px; padding: 20px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9375rem; }
summary { min-height: 44px; padding: 10px 0; }
.device-help p { max-width: 720px; margin: 8px 0 14px; }
.account { display: flex; justify-content: space-between; gap: 12px 24px; align-items: baseline; flex-wrap: wrap; padding-top: 12px; }
.account-actions { display: flex; gap: 24px; align-items: flex-start; font-size: 0.9375rem; }
.account-menu { color: var(--muted); }
.banner { position: fixed; z-index: 5; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(560px, calc(100% - 32px)); padding: 12px 20px; border-radius: 12px; background: var(--warn-bg); color: var(--text); box-shadow: 0 4px 16px #0000002e; text-align: center; font-size: 0.9375rem; }
.note-page { max-width: 880px; }
.bar { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; margin-bottom: 12px; }
.editor-bar { position: sticky; top: 0; z-index: 6; flex-wrap: nowrap; gap: 8px; padding: max(12px, env(safe-area-inset-top)) 0 8px; background: var(--bg); }
.back { display: inline-flex; align-items: center; gap: 2px; flex: 1 1 auto; min-height: 44px; font-weight: 600; text-decoration: none; }
.save-status { min-width: 0; font-size: 0.9375rem; color: var(--muted); text-align: right; }
.menu summary::-webkit-details-marker { display: none; }
.note-menu { position: relative; }
.note-menu summary { display: grid; place-items: center; width: 44px; min-height: 44px; padding: 0; list-style: none; border-radius: 12px; color: var(--muted); }
.note-menu[open] summary { background: var(--soft); }
.menu-panel { position: absolute; top: 100%; right: 0; z-index: 7; display: flex; flex-direction: column; min-width: 240px; padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--menu-shadow); }
button.menu-item { display: flex; align-items: center; width: 100%; padding: 0 12px; border: 0; border-radius: 10px; background: none; text-align: left; white-space: nowrap; }
button.menu-item:hover { background: var(--soft); }
.paper { background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 20px; padding: 32px; }
.paper-heading { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 24px; }
.category-menu { position: relative; }
.category-menu summary { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 4px 10px 4px 12px; list-style: none; border: 1px solid var(--field-line); border-radius: 20px; background: var(--surface); color: var(--text); }
.category-menu summary::after { content: ""; width: 7px; height: 7px; margin: 0 4px 4px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.category-menu summary:hover, .category-menu[open] summary { border-color: var(--accent); }
.category-panel { left: 0; right: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; width: min(360px, calc(100vw - 56px)); }
.category-panel .menu-item { gap: 10px; }
.category-panel .menu-item[aria-pressed="true"] { background: var(--soft); font-weight: 700; }
.category-clear { grid-column: 1 / -1; color: var(--muted); }
#editor { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 10px; margin-bottom: 12px; }
#editor .kind-icon { width: 48px; height: 48px; border-radius: 12px; }
#editor .kind-icon svg { width: 24px; height: 24px; }
/* The name and the text are boxed like every other field, so it is clear
   where to type. */
#editor input[name="title"] { font-size: clamp(1.5rem, 5vw, 2rem); line-height: 1.2; font-weight: 700; letter-spacing: -0.03em; padding: 10px 14px; }
#editor input[name="title"]::placeholder { font-weight: 400; }
.note-body { display: block; margin-bottom: 20px; min-height: 40vh; resize: none; padding: 12px 14px; line-height: 1.8; overflow-wrap: anywhere; }
.conflict { background: var(--warn-bg); border-radius: 12px; padding: 16px; margin-bottom: 20px; }
.conflict .theirs { background: var(--surface); border-radius: 8px; padding: 12px; margin: 12px 0; max-height: 40vh; overflow: auto; }
.conflict pre { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; margin: 0; }
.theirs-title { font-weight: 600; margin: 0 0 4px; }
.conflict button { margin: 4px 0; }

/* Lists. On a PC the add field sits above the items; on a phone it sticks to
   the bottom, by the thumb and above the keyboard. */
.paper-list { padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
.list-body { display: flex; flex-direction: column; }
.add-item { order: -2; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 20px; }
.add-field { flex: 1; min-width: 0; display: flex; align-items: center; height: 52px; padding-right: 5px; border: 1px solid var(--field-line); border-radius: 26px; background: var(--field); }
.add-field:hover { border-color: var(--accent); }
.add-field:focus-within { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.add-field input, .add-field input:hover, .add-field input:focus { height: 100%; padding: 0 8px 0 20px; border: 0; border-radius: 26px; background: none; outline: none; }
.add-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none; height: 52px; border-radius: 26px; }
.add-priority { flex-basis: 100%; min-width: 0; margin: 0; padding: 0; border: 0; }
.add-priority legend { padding: 0; margin-bottom: 4px; color: var(--muted); font-size: 0.875rem; font-weight: 600; }
.priority-choice { position: relative; display: grid; place-items: center; min-height: 44px; border: 1px solid var(--field-line); border-radius: 12px; cursor: pointer; font-size: 0.9375rem; }
.priority-choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.priority-choice:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 3px; }
.priority-choice:has(input:checked) { font-weight: 700; }
button.attach-button { display: grid; place-items: center; flex: none; width: 42px; height: 42px; min-height: 0; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); }
button.attach-button:hover { color: var(--accent); background: var(--soft); }
.sort-bar { order: -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; margin-bottom: 12px; border-radius: 12px; background: var(--soft); }
.sort-bar p { margin: 0; font-size: 0.9375rem; }
.item-save-status { order: -1; margin-bottom: 12px; }
.list-summary { margin-bottom: 12px; }
.list-summary progress { display: block; width: 100%; margin-top: 8px; }
.items { display: grid; gap: 8px; }
.item { display: flex; align-items: center; padding-right: 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.item:hover { border-color: var(--field-line); }
.done .item { background: none; box-shadow: none; }
button.item-tick { flex: none; display: grid; place-items: center; width: 56px; min-height: 58px; padding: 0 2px 0 4px; border: 0; border-radius: 14px 0 0 14px; background: none; }
.item-tick:focus-visible { outline-offset: -3px; }
.tick-box { display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid var(--muted); border-radius: 8px; }
.item-tick:hover .tick-box { border-color: var(--accent); }
.item-tick[aria-pressed="true"] .tick-box { background: var(--accent); border-color: var(--accent); }
.item-tick[aria-pressed="true"] .tick-box::after { content: ""; width: 6px; height: 12px; margin-top: -3px; border: solid var(--accent-text); border-width: 0 3px 3px 0; transform: rotate(45deg); }
.item-body { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 8px 4px 8px 0; font-size: 1.0625rem; line-height: 1.35; cursor: pointer; list-style: none; }
.item-body::-webkit-details-marker { display: none; }
.item-text { overflow-wrap: anywhere; }
/* A task's priority: Hoog, Middel and Laag chips; the sheet's toggles match. */
.priority { flex: none; padding: 2px 8px; border: 1px solid transparent; border-radius: 10px; font-size: 0.8125rem; font-weight: 700; line-height: 1.3; }
.priority.priority-2 { background: var(--priority-high-bg); color: var(--priority-high); }
.priority.priority-1 { background: var(--priority-medium-bg); color: var(--priority-medium); }
.priority.priority--1 { background: var(--priority-low-bg); color: var(--priority-low); }
.item:has(.item-tick[aria-pressed="true"]) .priority { opacity: 0.55; }
.sheet-label { margin-bottom: -6px; font-size: 0.875rem; font-weight: 600; color: var(--muted); }
.sheet-row.priority-row { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.priority-toggle { padding-left: 4px; padding-right: 4px; }
.priority-toggle.priority-2, .priority-choice.priority-2 { border-color: var(--priority-high); background: var(--priority-high-bg); color: var(--priority-high); }
.priority-toggle.priority-1, .priority-choice.priority-1 { border-color: var(--priority-medium); background: var(--priority-medium-bg); color: var(--priority-medium); }
.priority-toggle.priority--1, .priority-choice.priority--1 { border-color: var(--priority-low); background: var(--priority-low-bg); color: var(--priority-low); }
.priority-toggle.priority-0, .priority-choice.priority-0 { color: var(--muted); background: var(--surface); }
.priority-toggle[aria-pressed="true"] { font-weight: 700; }
.priority-toggle.priority-2[aria-pressed="true"], .priority-choice.priority-2:has(input:checked) { background: var(--priority-high); color: var(--priority-solid-text); }
.priority-toggle.priority-1[aria-pressed="true"], .priority-choice.priority-1:has(input:checked) { background: var(--priority-medium); color: var(--priority-solid-text); }
.priority-toggle.priority--1[aria-pressed="true"], .priority-choice.priority--1:has(input:checked) { background: var(--priority-low); color: var(--priority-solid-text); }
.priority-toggle.priority-0[aria-pressed="true"], .priority-choice.priority-0:has(input:checked) { border-color: var(--text); background: var(--text); color: var(--surface); }
.item:has(.item-tick[aria-pressed="true"]) .item-text { color: var(--muted); text-decoration: line-through; }
.item-delete { min-height: 56px; }
.item-menu { position: relative; flex: 1; min-width: 0; }
.item-menu summary { border-radius: 10px; }
.item-menu summary:hover { color: var(--accent); background: var(--soft); }
.item-menu[open] summary { background: var(--soft); }
.item-menu[open] > summary::before { content: ""; position: fixed; inset: 0; z-index: 30; background: var(--backdrop); cursor: default; }
.item-sheet { position: fixed; z-index: 31; left: 0; right: 0; bottom: 0; display: grid; gap: 12px; max-height: 90dvh; overflow-y: auto; padding: 12px max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); border-radius: 20px 20px 0 0; background: var(--surface); box-shadow: 0 -8px 24px #00000024; }
.item-sheet::before { content: ""; justify-self: center; width: 40px; height: 5px; border-radius: 3px; background: var(--line); }
.item-sheet label { margin-bottom: -6px; font-size: 0.875rem; font-weight: 600; color: var(--muted); }
.item-sheet button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.sheet-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-heading h2 { font-size: 1.2rem; line-height: 1.25; }
.sheet-eyebrow { color: var(--muted); font-size: 0.8125rem; font-weight: 600; }
.item-sheet .sheet-close { width: 44px; min-height: 44px; padding: 0; border: 0; background: var(--soft); color: var(--text); font-size: 1.5rem; line-height: 1; }
.sheet-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.sheet-footer .primary { min-width: 110px; }
.sheet-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.item-grip { display: none; flex: none; place-items: center; width: 48px; min-height: 56px; padding: 0; border: 0; border-radius: 0; background: none; color: var(--muted); cursor: grab; touch-action: none; }
.is-sorting .item-grip { display: grid; }
.item-grip:focus-visible { outline-offset: -3px; }
.is-sorting .item-delete, .is-sorting .done, .is-sorting .item-tick { display: none; }
.is-sorting .item-body { padding-left: 4px; cursor: default; }
.item.is-dragging { position: relative; z-index: 2; box-shadow: 0 10px 28px #20344d38, 0 0 0 1px var(--line); }
.is-dragging .item-grip { color: var(--accent); cursor: grabbing; }
.list-empty { padding: 28px 20px; border: 1px dashed var(--field-line); border-radius: 14px; color: var(--muted); text-align: center; }
.list-empty p { margin: 0 0 12px; }
.done { margin-top: 20px; }
.done-heading { display: flex; align-items: center; min-height: 48px; margin: 0 0 8px; padding: 0 12px; font-size: 1rem; font-weight: 600; color: var(--muted); }
.done > summary { display: flex; align-items: center; justify-content: space-between; min-height: 48px; margin-bottom: 8px; padding: 0 12px; list-style: none; font-weight: 600; color: var(--muted); border-radius: 12px; }
.done > summary:hover { background: var(--soft); color: var(--text); }
.done > summary::-webkit-details-marker { display: none; }
.done > summary::after { content: ""; width: 8px; height: 8px; margin: 0 8px 4px 0; border: solid currentColor; border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform 150ms; }
.done[open] > summary::after { margin-bottom: -4px; transform: rotate(-135deg); }
.done-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px 0 4px; }
.done-actions button { min-height: 44px; padding: 8px 16px; border-radius: 22px; font-size: 0.9375rem; }
.deleted-help { padding: 12px 4px 4px; }
.deleted-items { margin: 0; padding: 0; list-style: none; }
.deleted-items { display: grid; gap: 8px; }
.deleted-item { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 4px 4px 4px 14px; border: 1px dashed var(--field-line); border-radius: 14px; }
.deleted-text { flex: 1; min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
.deleted-item .restore { flex: none; min-height: 40px; padding: 4px 14px; border-radius: 20px; font-size: 0.9375rem; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; justify-content: space-between; gap: 8px; width: min(480px, calc(100% - 24px)); min-height: 52px; padding: 6px 6px 6px 16px; border-radius: 14px; background: var(--toast-bg); color: var(--toast-text); box-shadow: 0 6px 20px #00000038; font-size: 0.9375rem; font-weight: 600; }
.toast-text { overflow-wrap: anywhere; }
.toast button { flex: none; min-height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--toast-action-bg); color: var(--toast-action); font-weight: 700; }
.files { margin-top: 28px; padding: 20px 32px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.files-heading { margin: 0 0 4px; font-size: 1rem; color: var(--muted); }
.file:last-child { border-bottom: 0; }
.file { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.file img { max-width: 100%; max-height: 160px; border-radius: 8px; display: block; }
.file a { flex: 1; min-width: 0; }

/* Trash: deleted lists and notes open to show what they hold. */
.trash-page h1 { margin: 8px 0 8px; }
.trash-intro { max-width: 640px; margin-bottom: 24px; }
.trash-entry { border-top: 1px solid var(--line); }
.trash-entry:first-child { border-top: 0; }
.trash-entry > summary { min-height: 50px; padding: 8px 14px; list-style: none; cursor: pointer; }
.trash-entry > summary::-webkit-details-marker { display: none; }
.trash-entry > summary::after { content: ""; flex: none; width: 8px; height: 8px; margin: 0 4px 4px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.trash-entry[open] > summary { background: var(--soft); }
.trash-entry[open] > summary::after { margin-bottom: -4px; transform: rotate(-135deg); }
.trash-preview { display: grid; gap: 10px; padding: 12px 16px 16px 50px; }
.trash-body { margin: 0; max-height: 40vh; overflow: auto; overflow-wrap: anywhere; }
.trash-list { margin: 0; padding-left: 20px; }
.trash-list .is-done { color: var(--muted); text-decoration: line-through; }
.trash-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.trash-footer { display: flex; justify-content: flex-end; margin-top: 16px; }

/* The question before deleting. */
.dialog { width: min(420px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: 0 18px 48px #0000004d; }
.dialog::backdrop { background: #101d3080; }
.dialog-body { display: grid; justify-items: center; gap: 6px; padding: 28px 24px 20px; text-align: center; }
.dialog-icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 8px; border-radius: 50%; background: var(--danger-soft); color: var(--danger); }
.dialog-icon svg { width: 26px; height: 26px; }
.dialog h2 { margin: 0; font-size: 1.25rem; line-height: 1.35; overflow-wrap: anywhere; }
.dialog p { margin: 0; color: var(--muted); }
.dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; margin-top: 18px; }
/* A new list asks for its name and category in a dialog first. */
.new-list-form { display: grid; gap: 8px; padding: 24px; }
.new-list-form h2 { margin-bottom: 8px; text-align: left; }
.new-list-form > label, .category-choices legend { font-weight: 600; }
.category-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 8px 0 0; padding: 0; border: 0; }
.category-choices legend { margin-bottom: 8px; padding: 0; }
.category-choice { position: relative; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px; border: 1px solid var(--field-line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.category-choice:hover { border-color: var(--accent); }
.category-choice input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.category-choice:has(input:checked) { border-color: var(--accent); background: var(--soft); font-weight: 700; }
.category-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
.new-list-form .dialog-actions { margin-top: 12px; }
button.dialog-ok { background: var(--danger); border-color: var(--danger); color: var(--danger-text); font-weight: 600; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }
.login { max-width: 440px; margin: 12vh auto 0; padding: 36px; display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login h1 { font-size: 2rem; text-align: center; margin: 0; }
.error { color: var(--danger); margin: 0; }
@media (min-width: 700px) {
  .item-menu[open] > summary::before { display: none; }
  .item-sheet { position: absolute; top: 100%; right: 0; left: auto; bottom: auto; width: 340px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--menu-shadow); }
  .item-sheet::before { display: none; }
}
@media (max-width: 699px) {
  .add-item, .sort-bar { order: 1; position: sticky; bottom: 0; z-index: 3; margin: 20px -16px 0; padding: 10px 16px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); border-radius: 0; background: var(--surface); box-shadow: 0 -6px 18px #20344d0f; }
  .note-page:has(.paper-list) { padding-bottom: 0; }
  .add-button { width: 52px; padding: 0; }
  .add-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .paper-heading { margin-bottom: 16px; }
}
/* A phone with its keyboard open leaves little height (the viewport resizes
   with the keyboard): let the top bar scroll away and fold the add field's
   priority row into one compact line, so the items stay in view. */
@media (max-width: 699px) and (max-height: 560px) {
  .editor-bar { position: static; }
  .add-item { gap: 8px; padding-top: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .add-field, .add-button { height: 46px; }
  .add-button { width: 46px; }
  .add-priority legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .add-priority .priority-choice { min-height: 32px; border-radius: 10px; font-size: 0.875rem; }
}
@media (max-width: 1000px) {
  .welcome { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 359px) {
  .item-delete { display: none; }
  .trash-preview { padding-left: 16px; }
}
@media (max-width: 600px) {
  main { padding-right: max(16px, env(safe-area-inset-right)); padding-left: max(16px, env(safe-area-inset-left)); }
  .masthead { padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 16px max(16px, env(safe-area-inset-left)); }
  .brand { font-size: 1.125rem; gap: 8px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
  form.who .who-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .who-switch button { min-height: 36px; padding: 4px 10px; }
  .welcome { padding: 16px 0 24px; gap: 20px; }
  .create-actions { width: 100%; }
  .create-actions > * { flex: 1; }
  .create-actions button { width: 100%; }
  .browse { flex-wrap: wrap; margin-bottom: 20px; }
  .search-field { flex-basis: 100%; }
  .browse select { flex: 1; min-width: 0; }
  .groups { gap: 20px; }
  .account { display: block; }
  .account-actions { margin-top: 8px; }
  .paper, .files { padding: 20px 16px; border-radius: 16px; }
  .paper-list { padding: 0; border-radius: 0; }
  .paper-heading { gap: 6px; }
  .paper-heading .important-toggle, .category-menu summary { min-height: 40px; padding: 2px 10px 2px 8px; gap: 6px; font-size: 0.875rem; }
  .category-menu summary { padding-right: 6px; }
  .kind-label { font-size: inherit; }
  .bar { gap: 8px 12px; }
  .login { margin-top: 8vh; padding: 28px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
