/* Layout: a notebook desk. A slim header, then a horizontally scrolling row of ruled "pages" (lists), with the Done archive as the last page. */
:root {
  --bg: #eef0f3;
  --surface: #fbfcfd;
  --ink: #1d2430;
  --muted: #56616f;
  --rule: #cfd8e3;
  --margin: #d9534f;
  --accent: #2f5bd3;
  --line: #dde3ea;
  --shadow: 0 1px 2px rgb(20 30 50 / .08), 0 6px 18px rgb(20 30 50 / .06);
  --font-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, sans-serif;
  --font-hand: "Kalam", "Bradley Hand", "Segoe Print", cursive;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161c; --surface: #1b2129; --ink: #e8edf3; --muted: #adb7c3;
    --rule: #2c3540; --margin: #e2706c; --accent: #7fa2ff; --line: #2a323c;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 18px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161c; --surface: #1b2129; --ink: #e8edf3; --muted: #adb7c3;
  --rule: #2c3540; --margin: #e2706c; --accent: #7fa2ff; --line: #2a323c;
  --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 6px 18px rgb(0 0 0 / .3);
  color-scheme: dark;
}
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.4;
  display: flex; flex-direction: column;
}
button, input { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

header.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding-block: 14px 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.brand h1 { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; letter-spacing: -.025em; margin: 0; white-space: nowrap; }
.brand h1 .hand { font-family: var(--font-hand); font-weight: 400; font-size: .82em; letter-spacing: 0; margin: 0 .06em; color: var(--accent); }
.brand .date { font-family: var(--font-hand); font-size: 1.15rem; color: var(--muted); }
.tools { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; align-items: center; }
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px;
  padding: 7px 12px; font-size: .9rem; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--surface); font-weight: 700; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.settings .toggle:has(input[type="radio"]) { display: flex; margin: 0; }
.note {
  font-size: .82rem; color: var(--muted);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 8px;
}
.note b { color: var(--ink); }

.board {
  flex: 1; min-height: 0;
  display: flex; gap: 16px; align-items: flex-start;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x proximity;
  padding-block: 6px 20px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.col {
  --c: #7b9cff;
  flex: 0 0 300px; max-width: calc(100vw - 48px);
  max-height: 100%; display: flex; flex-direction: column;
  scroll-snap-align: start;
  border-radius: 14px; box-shadow: var(--shadow);
  background: color-mix(in oklab, var(--c) 20%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--c) 35%, var(--line));
}
.col-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 8px; position: relative; }
.swatch-btn {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 2px solid var(--surface); background: var(--c);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--c) 60%, var(--ink));
}
.col-title {
  flex: 1; min-width: 0; border: 1px solid transparent; background: transparent;
  font-family: var(--font-display); font-weight: 700; font-size: 1.2rem;
  padding: 2px 6px; border-radius: 6px;
}
.col-title:hover { border-color: color-mix(in oklab, var(--c) 50%, var(--line)); }
.col-title:focus { background: var(--surface); border-color: color-mix(in oklab, var(--c) 65%, var(--ink)); outline: none; }
.count { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
/* Shared lists: a small people mark by the count; tapping it opens the list menu. */
.shared-mark {
  display: inline-flex; align-items: center; border: none; border-radius: 6px; padding: 3px 4px;
  background: color-mix(in oklab, var(--c) 30%, transparent); color: color-mix(in oklab, var(--c) 35%, var(--ink));
}
.shared-mark:hover { background: color-mix(in oklab, var(--c) 45%, transparent); }
.pop .lbl.shared-lbl { text-transform: none; letter-spacing: 0; font-size: .8rem; max-width: 240px; }
.icon-btn { border: none; background: transparent; border-radius: 6px; padding: 4px 6px; color: var(--muted); line-height: 1; }
.icon-btn:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); color: var(--ink); }

/* the ruled page */
.col-body {
  flex: 1; min-height: 120px; overflow-y: auto;
  margin: 0 10px; padding: 6px 6px 6px 14px;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 6px, color-mix(in oklab, var(--margin) 55%, transparent) 6px 7px, transparent 7px),
    var(--surface);
  display: flex; flex-direction: column; gap: 0;
}
.empty { font-family: var(--font-hand); color: var(--muted); padding: 8px 4px; font-size: 1.02rem; }

.todo {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 8px 4px; min-height: 40px;
  border-bottom: 1px solid var(--rule);
  background: transparent; position: relative;
}
.todo:hover { background: color-mix(in oklab, var(--c) 10%, var(--surface)); }
.grip {
  touch-action: none; cursor: grab; color: var(--muted); border: none; background: none;
  padding: 2px 2px; font-size: 14px; line-height: 1.4; opacity: .55;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.todo:hover .grip, .grip:focus-visible { opacity: 1; }
.check {
  appearance: none; flex: none; width: 20px; height: 20px; margin: 1px 0 0;
  border: 2px solid color-mix(in oklab, var(--c) 70%, var(--ink)); border-radius: 5px;
  background: var(--surface); cursor: pointer; display: grid; place-content: center;
}
.check:checked { background: color-mix(in oklab, var(--c) 70%, var(--ink)); }
.check:checked::after { content: ""; width: 10px; height: 5px; border: solid var(--surface); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.text { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 1px; font-family: var(--font-hand); font-size: 1.08rem; line-height: 1.3; }
.todo.done .text { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.text[contenteditable="true"] { background: var(--surface); outline: 1px solid var(--accent); border-radius: 4px; padding: 0 4px; font-family: var(--font-body); font-size: .95rem; }
.todo .more { opacity: 0; }
.todo:hover .more, .todo .more:focus-visible, .todo .more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .todo .more, .grip { opacity: .8; } }
.tag { font-size: .72rem; color: var(--muted); white-space: nowrap; padding-top: 4px; }

.add { display: flex; gap: 6px; padding: 10px; }
.add input {
  flex: 1; min-width: 0; border: 1px solid color-mix(in oklab, var(--c) 40%, var(--line));
  background: var(--surface); border-radius: 8px; padding: 8px 10px;
}
.add input::placeholder { color: var(--muted); }
/* Focus in the list's own color instead of the system blue: a deeper border plus a soft glow keeps it clearly visible. */
.add input:focus, .add input:focus-visible {
  outline: none;
  border-color: color-mix(in oklab, var(--c) 65%, var(--ink));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--c) 45%, transparent);
}

/* Done archive */
.col.archive { --c: #8a94a3; }
.archive .col-title { pointer-events: none; }
.archive .col-body { background: var(--surface); padding-left: 8px; }
.day-label { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 8px 4px 2px; font-weight: 700; }
.archive .todo .text { font-family: var(--font-body); font-size: .92rem; }
.from { font-size: .72rem; color: var(--muted); white-space: nowrap; padding-top: 3px; }
.archive .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; }
.archive mark { background: color-mix(in oklab, #f2b84b 45%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.done-tools { display: flex; flex-direction: column; gap: 8px; padding: 0 10px 8px; }
.done-search {
  width: 100%; border: 1px solid color-mix(in oklab, var(--c) 40%, var(--line));
  background: var(--surface); color: var(--ink); border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 16px; /* 16px keeps iOS from zooming in on focus */
}
.done-search::placeholder { color: var(--muted); }
.done-search:focus, .done-search:focus-visible, .done-list:focus-visible {
  outline: none; border-color: color-mix(in oklab, var(--c) 65%, var(--ink));
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--c) 45%, transparent);
}
.done-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid color-mix(in oklab, var(--c) 40%, var(--line)); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 3px 10px; font: inherit; font-size: .8rem; cursor: pointer;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 700; }
.done-meta { display: flex; align-items: center; gap: 8px; }
.done-meta:empty { display: none; }
.done-summary { flex: 1; font-size: .8rem; color: var(--muted); font-weight: 700; }
.done-list {
  margin-left: auto; max-width: 55%; border: 1px solid color-mix(in oklab, var(--c) 40%, var(--line));
  background: var(--surface); color: var(--ink); border-radius: 8px; padding: 2px 6px; font: inherit; font-size: 16px;
}
.put-back {
  flex: none; max-width: 45%; display: inline-flex; align-items: center; gap: 2px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px;
  padding: 3px 9px; font: inherit; font-size: .74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.put-back:hover { color: var(--ink); border-color: var(--muted); }
.clear-filter { align-self: flex-start; margin: 4px; font-size: .85rem; }

.new-list {
  flex: 0 0 200px; align-self: stretch; max-height: 220px;
  border: 2px dashed var(--line); border-radius: 14px; background: transparent;
  color: var(--muted); font-family: var(--font-display); font-weight: 500; font-size: 1.05rem;
  display: grid; place-content: center; gap: 4px; text-align: center;
}
.new-list:hover:not([disabled]) { border-color: var(--accent); color: var(--accent); }
.new-list small { font-family: var(--font-body); font-size: .78rem; }
.new-list[disabled] { cursor: not-allowed; opacity: .6; }

/* popovers */
.pop {
  position: fixed; z-index: 40; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 6px; min-width: 190px; display: flex; flex-direction: column; gap: 2px;
}
.pop .lbl { font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 4px 8px 2px; }
.pop button.item { text-align: left; border: none; background: none; padding: 7px 8px; border-radius: 6px; display: flex; gap: 8px; align-items: center; }
.pop button.item:hover { background: color-mix(in oklab, var(--ink) 7%, transparent); }
.pop .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.pop .danger { color: var(--margin); }
.swatches { display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; padding: 6px 8px; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.swatches button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }
.custom-color { display: flex; align-items: center; gap: 8px; padding: 4px 8px 6px; font-size: .85rem; color: var(--muted); }
.custom-color input { width: 36px; height: 26px; border: none; background: none; padding: 0; }

/* drag */
.ghost {
  position: fixed; z-index: 50; pointer-events: none; width: 270px;
  background: var(--surface); border-radius: 8px; box-shadow: 0 12px 30px rgb(0 0 0 / .25);
  padding: 8px 10px; font-family: var(--font-hand); font-size: 1.08rem; transform: rotate(-2deg);
}
.placeholder { height: 34px; border-radius: 8px; border: 2px dashed var(--accent); background: color-mix(in oklab, var(--accent) 10%, transparent); flex: none; }
.todo.dragging { opacity: .3; }
/* While a todo is held: no text selection or iOS callouts anywhere, and no native gestures,
   so a second finger can swipe between lists (handled in app.js). Snapping is paused so the board follows that finger. */
body.is-holding, body.is-holding * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none; }
body.is-dragging, body.is-dragging * {
  cursor: grabbing !important; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none;
}
body.is-dragging .board { scroll-snap-type: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--surface); padding: 9px 16px; border-radius: 999px; font-size: .9rem;
  box-shadow: var(--shadow); z-index: 60;
  display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
}
/* Undo the browser's popover box (centered, bordered) so the toast keeps its place. */
.toast[popover] { inset: auto; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); margin: 0; border: 0; overflow: visible; }
.toast[popover]:not(:popover-open) { display: none; }
.settings .msg.device-msg:empty { display: none; }
.settings .msg.device-msg.ok { color: var(--ink); }
.toast-undo {
  font: inherit; font-weight: 700; color: inherit; background: none; border: 0; cursor: pointer;
  margin: -9px -10px -9px 0; padding: 9px 10px; border-radius: 999px; text-decoration: underline; text-underline-offset: 3px;
}
.toast-undo:hover { background: color-mix(in srgb, var(--surface) 14%, transparent); }
.toast-undo:focus-visible { outline: 2px solid var(--surface); outline-offset: -4px; }
@media (prefers-reduced-motion: no-preference) {
  .todo { transition: background .15s; }
  .toast { animation: rise .25s ease-out; }
  @keyframes rise { from { transform: translate(-50%, 8px); opacity: 0; } }
}
@media (max-width: 520px) {
  .tools { margin-left: 0; }
  .col { flex-basis: calc(100vw - 48px); }
  /* Phones stack the title, date and buttons; keep those gaps tight. */
  header.top { row-gap: 8px; }
  .brand { row-gap: 0; }
  .board { padding-top: 2px; }
}

/* ---------- PWA additions ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); overscroll-behavior-y: none; }
[hidden] { display: none !important; }
/* Status bar fade: the installed iPhone app blurs a band just below the
   status bar. With the "default" status bar style the page starts under the
   status bar, so safe-area-inset-top is 0 and can't be used to detect it.
   Key off standalone display instead: drop the header 18px so the title
   clears the blur, and trim the gaps below it so the lists barely move.
   Browser tabs and desktop installs are unchanged. */
@media (display-mode: standalone) and (pointer: coarse) {
  header.top { padding-top: 32px; padding-bottom: 4px; }
  .board { padding-top: 0; }
}
@media (display-mode: standalone) and (pointer: coarse) and (max-width: 520px) {
  header.top { row-gap: 6px; }
}

.sync {
  display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 10px;
}
.sync::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.sync[data-state="ok"]::before { background: #3aa76d; }
.sync[data-state="busy"]::before { background: var(--accent); }
.sync[data-state="error"]::before { background: var(--margin); }
.sync[data-state="offline"]::before, .sync[data-state="pending"]::before { background: #e0a030; }
.sync[data-state="error"] { color: var(--margin); border-color: color-mix(in oklab, var(--margin) 45%, var(--line)); }
.sync[data-state="busy"]::before { animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .sync[data-state="busy"]::before { animation: none; } }
.sync { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Todos edited here that haven't reached the Worker yet. Only shown while
   offline or failing, so a normal save doesn't flash a dot on every edit. */
.unsynced-dot { display: none; flex: none; width: 8px; height: 8px; margin-top: 8px; border-radius: 50%;
  border: 2px solid #e0a030; background: transparent; }
body[data-sync="offline"] .todo.unsynced .unsynced-dot,
body[data-sync="error"] .todo.unsynced .unsynced-dot,
body[data-sync="pending"] .todo.unsynced .unsynced-dot { display: block; }
.toast { max-width: calc(100vw - 32px); width: max-content; text-align: center; border-radius: 18px; }

dialog.settings {
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink);
  width: min(460px, calc(100vw - 32px)); padding: 0; box-shadow: var(--shadow);
  /* Fit the screen (minus notch/home bar) so only the body scrolls, never the header. */
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}
dialog.settings[open] { display: flex; flex-direction: column; }
dialog.settings::backdrop { background: rgb(10 15 25 / .45); }
body:has(dialog.settings[open]) { overflow: hidden; }
.settings form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.settings-head {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.settings-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 14px; padding: 16px 20px 20px;
}
.settings .close-x {
  flex: none; width: 44px; height: 44px; display: grid; place-items: center;
  border: none; background: transparent; border-radius: 10px; color: var(--muted);
}
.settings .close-x:hover { background: color-mix(in oklab, var(--ink) 8%, transparent); color: var(--ink); }
.settings h2 { font-family: var(--font-display); margin: 0; font-size: 1.3rem; flex: 1; min-width: 0; }
.settings h3 { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0; padding-left: 2px; }
.settings p { margin: 0; color: var(--muted); font-size: .88rem; }
.settings label.field { display: flex; flex-direction: column; gap: 4px; font-size: .88rem; font-weight: 700; }
.settings input[type="url"], .settings input[type="password"], .settings input[type="text"] {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 9px 10px; font-weight: 400; width: 100%;
}
.settings .row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.settings .row.start { justify-content: flex-start; }
.settings select {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 8px; padding: 8px 10px;
  font: inherit; font-size: .88rem; flex: 1 1 100%; min-width: 0;
}
.settings .cloud-backups { display: flex; flex-direction: column; gap: 8px; }
.settings .restore-box {
  display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: color-mix(in oklab, var(--margin) 7%, var(--surface));
}
.settings .restore-box[hidden] { display: none; }
.settings p.note { font-size: .8rem; }
.settings p a { color: var(--accent); }
.settings .btn.danger { color: var(--margin); }
.settings .btn.primary.danger { background: var(--margin); border-color: var(--margin); color: #fff; }
.settings .invite-new input { flex: 1 1 12em; width: auto; }
.settings .invite-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: .88rem; }
.settings .invite-list:empty { display: none; }
.settings .invite-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.settings .invite-list li span { min-width: 0; overflow-wrap: anywhere; }
.settings .invite-list li .btn { flex: none; }
.settings .restore-box p { color: var(--ink); }
.settings .restore-box .toggle { align-items: flex-start; }
.settings .restore-box .toggle input { margin-top: 3px; }
.settings .msg { font-size: .85rem; min-height: 1.2em; color: var(--muted); }
.settings .msg.bad { color: var(--margin); }
.settings .version { font-variant-numeric: tabular-nums; }
.settings .row.update { align-items: center; }
.settings .row.update .msg:empty { display: none; }
.settings .new-dot {
  font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--surface); background: var(--margin); border-radius: 999px; padding: 1px 7px;
}
.settings .new-dot[hidden] { display: none; }
/* The badge is its own signal: no link underline under it. */
.settings a .new-dot, .settings a:has(.new-dot) { text-decoration: none; }

/* ---------- Settings layout: grouped cards, with Sync and Backups as sub-pages ---------- */
.settings .pane { display: flex; flex-direction: column; gap: 22px; }
.settings .pane[hidden], .settings .group[hidden], .settings .item[hidden] { display: none; }
.settings .group { display: flex; flex-direction: column; gap: 8px; }
.settings .card {
  display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); overflow: hidden;
}
/* Settings pages sit on the desk color, so their cards read as index cards. */
dialog.settings#settings .settings-body { background: var(--bg); }
.settings .card.pad { padding: 14px; gap: 12px; }
.settings .item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 10px 14px;
  border: 0; background: transparent; color: var(--ink); text-align: left; text-decoration: none;
  font-size: .92rem; border-radius: 0;
}
.settings .card > .item + .item { border-top: 1px solid var(--line); }
.settings .item.stack { flex-direction: column; align-items: stretch; gap: 10px; padding-block: 12px; }
.settings .item-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.settings .item-text small { color: var(--muted); font-size: .8rem; }
.settings .item-text small.bad { color: var(--margin); }
.settings .item-value { color: var(--muted); }
.settings .item .chev { flex: none; color: var(--muted); }
.settings .item.nav { cursor: pointer; }
.settings .item.nav:hover { background: color-mix(in oklab, var(--ink) 5%, transparent); }
.settings .item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.settings .switch-row { cursor: pointer; }
/* An on/off switch, in Ballpoint when on. */
.settings .switch {
  appearance: none; -webkit-appearance: none; flex: none; position: relative; margin: 0;
  width: 46px; height: 28px; border-radius: 999px; background: var(--rule); cursor: pointer;
  transition: background-color .18s ease;
}
.settings .switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .25); transition: transform .18s ease;
}
.settings .switch:checked { background: var(--accent); }
.settings .switch:checked::before { transform: translateX(18px); }
.settings .switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .settings .switch, .settings .switch::before { transition: none; } }
.settings .back-btn {
  flex: none; display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 10px 0 2px;
  margin-left: -12px; border: 0; background: transparent; color: var(--accent); font-size: .95rem; border-radius: 10px;
}
.settings .back-btn[hidden] { display: none; }
.settings .back-btn:hover { background: color-mix(in oklab, var(--accent) 10%, transparent); }
dialog.settings.sub h2 { font-size: 1.1rem; }
.settings .version { font-size: .8rem; padding-left: 2px; }
.settings .danger-zone h3 { color: var(--margin); }

/* ---------- Appearance, haptics and keyboard shortcuts ---------- */
/* Theme picker: a three-way segmented control. */
.settings .choice {
  display: flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; background: var(--bg);
}
.settings .choice label {
  flex: 1; white-space: nowrap; text-align: center; padding: 7px 6px; border-radius: 7px; font-size: .88rem; color: var(--muted); cursor: pointer;
}
.settings .choice input { position: absolute; opacity: 0; pointer-events: none; }
.settings .choice label:has(input:checked) { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }
.settings .choice label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Shortcuts only matter with a keyboard and mouse; hide the button on phones. */
@media (hover: none), (pointer: coarse) { .kb-only { display: none !important; } }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; text-align: center;
  font-family: var(--font-body); font-size: .8rem; line-height: 1.5; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
}
.keylist { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; margin: 0; align-items: center; font-size: .9rem; }
.keylist dt { white-space: nowrap; color: var(--muted); font-size: .8rem; }
.keylist dd { margin: 0; }

/* The todo picked with the arrow keys. */
.todo:focus { outline: none; }
.todo:focus-visible {
  outline: none; border-radius: 6px;
  background: color-mix(in oklab, var(--c) 22%, var(--surface));
  box-shadow: inset 3px 0 0 color-mix(in oklab, var(--c) 75%, var(--ink));
}
.todo:focus-visible .more, .todo:focus-visible .grip { opacity: 1; }

/* ---------- No zoom, no page scroll ----------
   The app is a fixed canvas: only the board (sideways), each list, and dialogs scroll.
   pan-x pan-y lets fingers scroll but turns off pinch and double-tap zoom; the grip's
   touch-action: none still wins for drags. overscroll-behavior keeps a list that hits
   its top or bottom from dragging the whole page along with it. */
html, body { overflow: hidden; overscroll-behavior: none; touch-action: pan-x pan-y; }
.board, .col-body { overscroll-behavior: contain; }
/* iOS zooms in on any field under 16px when it gets focus. */
@media (pointer: coarse) {
  input, select, textarea, .text[contenteditable="true"] { font-size: 16px !important; }
}

/* ---------- Welcome: first visit only ---------- */
dialog.welcome {
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink);
  width: min(480px, calc(100vw - 32px)); padding: 0; box-shadow: var(--shadow);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}
dialog.welcome[open] { display: flex; flex-direction: column; }
dialog.welcome::backdrop { background: color-mix(in oklab, var(--bg) 82%, transparent); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
body:has(dialog.welcome[open]) { overflow: hidden; }
.welcome form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.welcome-top { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 0 22px; }
.welcome-dots { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.welcome-dots li { width: 7px; height: 7px; border-radius: 50%; background: var(--rule); transition: width .2s, background .2s; }
.welcome-dots li.on { width: 20px; border-radius: 4px; background: var(--accent); }
.welcome-skip { border: 0; background: transparent; color: var(--muted); font-size: .9rem; min-height: 44px; padding: 0 12px; border-radius: 10px; }
.welcome-skip:hover { color: var(--ink); background: color-mix(in oklab, var(--ink) 6%, transparent); }
.welcome-step {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: 16px; padding: 8px 22px 6px;
}
.welcome-step[hidden] { display: none; }
.welcome-step h2 { font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; letter-spacing: -.02em; margin: 6px 0 0; }
.welcome-step h2.welcome-mark { font-size: 2.3rem; letter-spacing: -.03em; margin-top: 10px; line-height: 1.05; }
.welcome-mark .hand { font-family: var(--font-hand); font-weight: 400; font-size: .82em; letter-spacing: 0; margin: 0 .06em; color: var(--accent); }
.welcome-tag { margin: -10px 0 0; font-family: var(--font-hand); font-size: 1.25rem; color: var(--muted); }
.welcome-lede { margin: 0; font-size: 1rem; line-height: 1.5; }
.welcome-note { margin: 0; font-size: .85rem; color: var(--muted); }
.welcome-step a { color: var(--accent); }

/* Three little ruled pages, like the board itself. */
.welcome-pages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.welcome-pages .mini {
  display: flex; flex-direction: column; min-width: 0; min-height: 112px; border-radius: 10px; overflow: hidden;
  background: color-mix(in oklab, var(--c) 22%, var(--surface)); border: 1px solid color-mix(in oklab, var(--c) 45%, var(--surface));
  padding: 0 0 8px;
}
.welcome-pages .mini b {
  font-family: var(--font-display); font-weight: 700; font-size: .78rem; padding: 7px 9px 5px;
  display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.welcome-pages .mini b::before { content: ""; flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.welcome-pages .mini i {
  font-style: normal; font-family: var(--font-hand); font-size: .78rem; line-height: 1.25;
  margin: 0 6px; padding: 5px 4px 3px 8px; background: var(--surface);
  border-bottom: 1px solid var(--rule); box-shadow: inset 2px 0 0 color-mix(in oklab, var(--margin) 55%, transparent);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.welcome-pages .mini i:first-of-type { border-radius: 6px 6px 0 0; }
.welcome-pages .mini i.done { text-decoration: line-through; color: var(--muted); }

.welcome-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.welcome-list li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.45; font-size: .95rem; }
.welcome-list li[hidden] { display: none; }
.welcome-list strong { display: block; }
.welcome-list .dot { flex: none; width: 12px; height: 12px; margin-top: 5px; border-radius: 50%; background: var(--c); }
.welcome .row { display: flex; flex-wrap: wrap; gap: 8px; }
.welcome-nav {
  flex: none; display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 22px max(18px, env(safe-area-inset-bottom, 0px));
}
.welcome-nav .btn { min-height: 44px; padding: 8px 18px; font-size: .95rem; }
.welcome-nav .btn.primary { min-width: 8em; justify-content: center; }
.welcome-nav #welcomeBack { margin-right: auto; }
.welcome-nav #welcomeBack[hidden] { display: none; }

/* On a phone the welcome fills the screen. */
@media (max-width: 520px) {
  dialog.welcome {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .welcome-step h2.welcome-mark { font-size: 2.6rem; margin-top: 4vh; }
}
@media (prefers-reduced-motion: no-preference) {
  .welcome-step:not([hidden]) { animation: welcome-in .22s ease-out; }
  @keyframes welcome-in { from { opacity: 0; transform: translateX(10px); } }
}
