/*
 * Mobile first: the base rules are for a phone held in one hand; the min-width queries at the
 * bottom add room on bigger screens. Text and spacing are fluid: each step grows smoothly with the
 * viewport between a floor and a ceiling. The rem part keeps browser zoom and the user's text-size
 * setting working, and body text never drops below 1rem, so iOS doesn't zoom when a field is focused.
 */

:root {
  color-scheme: light dark;
  --bg: #fbfaf8;
  --fg: #1d1b19;
  --muted: #6b665f;
  --accent: #6d5dfc;
  --line: #e4e0da;
  --danger: #c8372d;

  /* Type scale: ~16px -> ~18px body between a 320px phone and a wide window. */
  --step--2: clamp(0.78rem, 0.76rem + 0.1vw, 0.83rem);
  --step--1: clamp(0.875rem, 0.85rem + 0.12vw, 0.94rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --step-1: clamp(1.15rem, 1.08rem + 0.35vw, 1.35rem);
  --step-2: clamp(1.35rem, 1.2rem + 0.7vw, 1.75rem);
  --step-3: clamp(1.6rem, 1.35rem + 1.2vw, 2.25rem);

  /* Spacing grows with the viewport too, so phones stay tight and desktops breathe. */
  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-s: clamp(0.625rem, 0.55rem + 0.35vw, 0.8rem);
  --space-m: clamp(0.875rem, 0.75rem + 0.6vw, 1.25rem);
  --space-l: clamp(1.25rem, 1rem + 1.2vw, 2rem);

  --tap: 2.75rem; /* 44px: the smallest comfortable touch target */
  --radius: 0.6rem;     /* controls: inputs, buttons, tiles */
  --radius-lg: 0.9rem;  /* cards and panels */
  /* The accent tint used for highlighted cards, tips and selected rows. */
  --tint: color-mix(in srgb, var(--accent) 8%, transparent);
  --tint-strong: color-mix(in srgb, var(--accent) 12%, transparent);
  --tint-line: color-mix(in srgb, var(--accent) 20%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #171614; --fg: #ecebe8; --muted: #a39e96; --accent: #9d92ff; --line: #2e2b28; --danger: #ff7a6e; }
}

/* --- Base ------------------------------------------------------------------------------ */

* { box-sizing: border-box; }
/* Author display rules (like button's inline-flex) would otherwise beat the browser's [hidden]. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: system-ui, sans-serif; font-size: var(--step-0); line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 42rem; margin: 0 auto;
  padding: var(--space-m) max(var(--space-m), env(safe-area-inset-right)) var(--space-l) max(var(--space-m), env(safe-area-inset-left));
}
h1, h2, h3 { text-wrap: balance; }
h1 { font-size: var(--step-3); line-height: 1.15; margin: 0 0 var(--space-s); overflow-wrap: anywhere; }
h2 { font-size: var(--step-2); line-height: 1.2; margin: var(--space-m) 0 var(--space-2xs); }
h3 { font-size: var(--step-1); }
p { margin: 0 0 var(--space-s); }
/* Links: interface links (back, Sort, Claim, header, chips…) aren't underlined; links inside running
   text are, so they read as links. Everything underlines on hover where there's a pointer. */
a { color: var(--accent); text-decoration: none; }
:where(.help, .panel-links, .hint, .tip, .notes) a:not([class]) { text-decoration: underline; text-underline-offset: 0.15em; }
@media (hover: hover) { a:hover { text-decoration: underline; } }
.back { display: inline-flex; align-items: center; min-height: var(--tap); font-size: var(--step--1); }
small, .hint { color: var(--muted); font-size: var(--step--1); }
code { font-size: 0.9em; padding: 0.05em 0.3em; border-radius: 0.3em; background: color-mix(in srgb, var(--fg) 8%, transparent); }

/* --- Controls -------------------------------------------------------------------------- */

button, .button, input, select, textarea {
  font: inherit; color: inherit; min-height: var(--tap);
  padding: var(--space-xs) var(--space-s); border-radius: var(--radius); border: 1px solid var(--line);
  background: transparent;
}
input, select, textarea { width: 100%; }
select { background: var(--bg); }
textarea { resize: vertical; field-sizing: content; max-height: 12rem; }
button, .button { cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 0.4em; }
button:active, .button:active { transform: scale(0.97); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); font-weight: 600; }
label { display: grid; gap: var(--space-2xs); }

/* Text-style buttons and links inside dense rows: small to look at, still a full tap target tall. */
button.link { min-height: 0; border: 0; padding: var(--space-xs) 0; color: var(--accent); font-size: inherit; background: none; }
button.icon {
  min-height: var(--tap); min-width: var(--tap); border: 0; padding: 0; background: none;
  color: var(--muted); font-size: var(--step-2); line-height: 1; opacity: 0.6;
}
button.icon:focus-visible { opacity: 1; }

/* Round tick box: drawn at ~26px, but its tap area reaches 44px. */
.check {
  position: relative; flex: none; min-height: 0; width: 1.6rem; height: 1.6rem; padding: 0; margin: 0.1rem 0.1rem 0;
  border-radius: 50%; border: 2px solid var(--muted); line-height: 1; font-size: var(--step--1);
}
.check::after { content: ""; position: absolute; inset: -0.6rem; }
.is-done .check { background: var(--accent); border-color: var(--accent); color: var(--bg); }

/* --- Layout helpers -------------------------------------------------------------------- */

/* A card: sign in / sign up, invite, the welcome screen. (Edit groups, sort steps and the help
   shortcuts card use the same border, radius and padding.) */
.panel { display: grid; gap: var(--space-s); padding: var(--space-m); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel h1, .panel h2 { margin: 0; }
.panel form .button.primary, .panel > .button.primary { width: 100%; }
/* The small brand line at the top of pages that don't have the full header. */
.brand-line { margin: 0 0 var(--space-m); font-size: var(--step-2); font-weight: 700; }
.panel-links { margin: var(--space-m) 0 0; text-align: center; font-size: var(--step--1); }
/* Sign in, sign up and invite: one narrow centered column, even on a wide screen. */
.brand-line, .brand-line ~ .panel, .brand-line ~ .panel-links { max-width: 26rem; margin-inline: auto; }
.brand-line ~ .panel + .panel, .brand-line ~ .panel-links + .panel { margin-top: var(--space-m); }
/* A centered message: "All sorted", "That's the lot", errors. */
.empty-state { display: grid; justify-items: center; gap: var(--space-s); text-align: center; padding: var(--space-l) 0; }
.empty-state h1 { margin: 0; }
.empty-state p { margin: 0; }
.empty-icon { font-size: 3rem; line-height: 1; }

.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-xs) var(--space-m); }
.bar h1 { margin: 0; font-size: var(--step-2); }
.brand { color: inherit; text-decoration: none; }
.bar-actions { display: flex; gap: var(--space-s); align-items: center; }
.wide-only { display: none; }
.bar-actions form { margin: 0; }
.bar-actions a { text-decoration: none; }
.stack { display: grid; gap: var(--space-s); }
.row { display: grid; gap: var(--space-s); }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-m); align-items: center; }
.actions form { margin: 0; }
.empty { color: var(--muted); padding: var(--space-l) 0; text-align: center; }
.count { font-weight: normal; }

/* --- Home: quick add, tabs, flash -------------------------------------------------------- */

/* Stays on screen while scrolling a long list, so adding is always one tap away. */
.quick-add {
  position: sticky; top: 0; z-index: 1; display: flex; gap: var(--space-xs);
  margin: var(--space-s) calc(-1 * var(--space-m)) var(--space-xs); padding: var(--space-xs) var(--space-m);
  background: var(--bg);
}
.quick-add input, .quick-add textarea { flex: 1; min-width: 0; }
.input-wrap { position: relative; display: flex; flex: 1; min-width: 0; }
.input-wrap input { padding-right: var(--tap); }
.clear-input {
  position: absolute; inset: 0 0 0 auto; min-width: var(--tap); padding: 0;
  border: 0; background: none; color: var(--muted);
}
@media (hover: hover) { .clear-input:hover { color: var(--fg); } }
.quick-add button { flex: none; }

.help-button { flex: none; color: var(--muted); }

/* Phones: a bottom bar with the three main lists and "More" (a sheet with the rest), so nothing
   scrolls sideways and the lists sit under the thumb. Wider screens: every list as a tab (below). */
.tabs { display: none; flex-wrap: wrap; gap: var(--space-2xs); margin-bottom: var(--space-xs); border-bottom: 1px solid var(--line); }
.tabs a {
  flex: none; display: inline-flex; align-items: center; gap: 0.35em; min-height: var(--tap);
  padding: 0 var(--space-s); color: var(--muted); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a[aria-current] { color: var(--fg); border-color: var(--accent); font-weight: 600; }
.badge {
  display: inline-block; min-width: 1.4em; padding: 0 0.4em; border-radius: 1em; text-align: center;
  background: var(--accent); color: var(--bg); font-size: var(--step--2); font-weight: 600; line-height: 1.5;
}
.tab-hint { margin: var(--space-2xs) 0 var(--space-xs); }

.bottom-nav {
  position: fixed; inset: auto 0 0; z-index: 2;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.bottom-nav a, .bottom-nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem;
  min-height: 3.5rem; padding: var(--space-2xs) 0; border: 0; border-radius: 0; background: none;
  color: var(--muted); font-size: var(--step--2); text-decoration: none;
}
.bottom-nav button:active { transform: none; }
.bottom-nav [aria-current] { color: var(--accent); font-weight: 600; }
.nav-icon { position: relative; display: grid; place-items: center; }
.nav-icon .badge { position: absolute; top: -0.35rem; left: calc(100% - 0.5rem); }
/* Keep the end of the list clear of the bar. */
main:has(.bottom-nav) { padding-bottom: calc(4.5rem + env(safe-area-inset-bottom)); }
.view-title { margin: var(--space-s) 0 var(--space-2xs); font-size: var(--step-1); }

.more-list { list-style: none; margin: var(--space-xs) 0 0; padding: 0; width: 100%; text-align: left; }
.more-list li + li { border-top: 1px solid var(--line); }
.more-list a { display: grid; gap: 0.1rem; min-height: var(--tap); padding: var(--space-s) var(--space-xs); color: inherit; text-decoration: none; border-radius: var(--radius); }
.more-list a[aria-current] { background: var(--tint-strong); }
.more-list a[aria-current] strong { color: var(--accent); }
#tabs > p > .button { width: 100%; }
.filter { display: flex; gap: var(--space-xs); align-items: baseline; flex-wrap: wrap; margin: var(--space-xs) 0 0; color: var(--muted); }

.flash:not(:empty) {
  display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-s); align-items: center;
  padding: var(--space-xs) var(--space-s); border-radius: var(--radius); margin: var(--space-xs) 0;
  background: var(--tint-strong);
}
.flash.is-error { background: color-mix(in srgb, var(--danger) 15%, transparent); }

/* --- Task list -------------------------------------------------------------------------- */

.group { font-size: var(--step--1); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: var(--space-m) 0 0; }
.group.overdue { color: var(--danger); }
.tasks, .items { list-style: none; margin: 0; padding: 0; }
.task { display: flex; align-items: flex-start; gap: var(--space-s); padding: var(--space-xs) 0; border-bottom: 1px solid var(--line); }
.task form { margin: 0; }
.task > form:first-child { padding-top: 0.55rem; }
.task-body { flex: 1; min-width: 0; display: grid; gap: 0.1rem; padding-top: var(--space-xs); }
.task-title { overflow-wrap: anywhere; }
a.task-title { color: inherit; text-decoration: none; }
.task.is-done .task-title { text-decoration: line-through; color: var(--muted); }
/* Blocked by another task: still on the list, but visibly not ready yet. */
.task.is-blocked .task-title { color: var(--muted); }
.blocked { color: var(--fg); }
.holding-up { margin: var(--space-xs) 0 0; padding: var(--space-xs) var(--space-s); border-radius: var(--radius); background: var(--tint); font-size: var(--step--1); }
.task.is-high .task-title::before { content: "! "; color: var(--danger); font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 0 var(--space-s); font-size: var(--step--1); color: var(--muted); align-items: center; }
/* Links in the meta line (Claim, Sort, chips) get a taller hit area without looking any bigger. */
.meta a, .meta button.link { display: inline-block; padding: var(--space-2xs) 0; margin: calc(-1 * var(--space-2xs)) 0; }
.meta form.inline { display: inline; }
.due.overdue { color: var(--danger); }
.due.today { color: var(--accent); font-weight: 600; }
.project { color: var(--c); }
.who { display: inline-flex; align-items: center; gap: 0.3rem; }
.dot { width: 0.75rem; height: 0.75rem; border-radius: 50%; flex: none; }
.who .dot { width: 0.6rem; height: 0.6rem; }
/* Renaming a task in place: the title turns into a text box with its actions underneath. */
.rename { flex: 1; min-width: 0; display: grid; gap: var(--space-xs); padding: var(--space-2xs) 0; }
.rename-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-s); font-size: var(--step--1); }
.rename-actions .button { min-height: 2.25rem; padding-inline: var(--space-s); }
.rename-actions a { margin-left: auto; }
button.link.danger { color: var(--danger); }
.rename-button { font-size: inherit; }
.chip { color: inherit; text-decoration: none; }
.chip.tag { color: var(--accent); }

/* --- Task page -------------------------------------------------------------------------- */

.task-head { margin-bottom: var(--space-m); }
.task-head h1 { margin-bottom: var(--space-2xs); }
.task-head.is-done h1 { text-decoration: line-through; color: var(--muted); }
.task-head.is-high h1::before { content: "! "; color: var(--danger); }
.task-head .actions { margin-top: var(--space-s); }
.notes { white-space: pre-wrap; color: var(--muted); }

/* Edit form: the title and notes, then grouped sections of chips, with Save/Cancel pinned to the bottom. */
.edit { display: grid; gap: var(--space-s); margin-bottom: var(--space-m); }
.edit-main {
  display: grid; gap: var(--space-2xs); padding: var(--space-m); border-radius: var(--radius-lg);
  background: var(--tint); border: 1px solid var(--tint-line);
}
.edit-main .hint { font-size: var(--step--2); }
.edit-title {
  min-height: 0; padding: 0.1rem 0; border: 0; border-bottom: 1px dashed transparent; border-radius: 0;
  font-size: var(--step-2); font-weight: 650; line-height: 1.25; background: none;
}
.edit-title:focus { outline: none; border-bottom-color: var(--accent); }
.edit-main textarea { min-height: 0; padding: var(--space-2xs) 0; border: 0; border-radius: 0; background: none; font-size: var(--step--1); }
.edit-main textarea:focus { outline: none; }
.edit-group { display: grid; gap: var(--space-xs); padding: var(--space-s) var(--space-m) var(--space-m); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.edit-group h3 { margin: 0; font-size: var(--step-0); }
.edit-group h3 .hint { font-weight: normal; }
.edit-group legend { padding: 0; margin-bottom: var(--space-2xs); font-size: var(--step--1); color: var(--muted); width: 100%; }
.edit-group fieldset { margin: 0; padding: 0; border: 0; }
.edit-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-xs); }
/* The date picker needs more room than the time; text fields stack on phones so hints aren't cut off. */
.edit-row.is-when { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
.edit-row.is-stacked { grid-template-columns: 1fr; }
.edit-row label { font-size: var(--step--1); color: var(--muted); }
.edit-row input { color: var(--fg); font-size: var(--step-0); }
.waiting-field { display: none; font-size: var(--step--1); color: var(--muted); }
.waiting-field input { color: var(--fg); font-size: var(--step-0); }
.edit-group:has(input[name="list"][value="waiting"]:checked) .waiting-field { display: grid; }
.new-blocker { display: none; font-size: var(--step--1); color: var(--muted); }
.new-blocker input { color: var(--fg); font-size: var(--step-0); }
.edit-group:has(select[name="waitingTaskId"] option[value="new"]:checked) .new-blocker { display: grid; }
.edit-actions {
  position: sticky; bottom: 0; z-index: 1; display: grid; grid-template-columns: 1fr 2fr; gap: var(--space-xs);
  margin: 0 calc(-1 * var(--space-m)); padding: var(--space-s) var(--space-m) max(var(--space-s), env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
/* A utility, so it wins over any component rule (like .edit-group legend's width). */
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; margin: 0 !important; padding: 0 !important; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.edit fieldset { min-width: 0; }
label.pill span { overflow-wrap: anywhere; }

#checklist-head { margin-top: var(--space-m); }
#checklist-head h2 { font-size: var(--step-1); margin: 0; }
.checklist-hint { margin: var(--space-2xs) 0 0; }
#add-items { position: static; margin: var(--space-xs) 0; padding: 0; }
.item { display: flex; align-items: center; gap: var(--space-s); padding: var(--space-2xs) 0; border-bottom: 1px solid var(--line); }
.item form { margin: 0; }
.item-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item .rename { padding: 0; }
.item.is-done .item-text { text-decoration: line-through; color: var(--muted); }
.qty { font-weight: 600; }
.checklist .actions { margin-top: var(--space-s); font-size: var(--step--1); }

/* --- Sort page -------------------------------------------------------------------------- */

/* One question at a time: the task in a card, "What is this?" as tiles, then a small follow-up
   step for the answers that need a detail. */
.sort-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-s); font-size: var(--step--1); }
.sort-left { color: var(--muted); }
.sort { display: grid; gap: var(--space-m); margin-top: var(--space-s); }

.sort-card {
  display: grid; gap: var(--space-2xs); padding: var(--space-m); border-radius: var(--radius-lg);
  background: var(--tint); border: 1px solid var(--tint-line);
}
.sort-card label { font-size: var(--step--2); }
.sort-card-title {
  min-height: 0; padding: 0.1rem 0; border: 0; border-bottom: 1px dashed transparent; border-radius: 0;
  font-size: var(--step-2); font-weight: 650; line-height: 1.25; background: none;
}
.sort-card-title:focus { outline: none; border-bottom-color: var(--accent); }
.sort-card .notes { margin: 0; font-size: var(--step--1); }

.sort-question { margin: 0 0 var(--space-s); font-size: var(--step-2); }
.sort-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-xs); }
.sort-tile {
  display: grid; justify-content: stretch; justify-items: start; align-content: start; gap: 0.15rem; min-height: 6.5rem;
  padding: var(--space-s); text-align: left; border-radius: var(--radius); background: var(--bg);
}
.sort-tile strong { line-height: 1.25; }
.sort-tile .hint { font-size: var(--step--2); line-height: 1.35; }
.sort-tile.is-delete strong { color: var(--danger); }
@media (hover: hover) { .sort-tile:hover { border-color: var(--accent); } }

.sort-step { display: grid; gap: var(--space-s); padding: var(--space-m); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.sort-step h2 { margin: 0; font-size: var(--step-1); }
.sort-step .hint { margin: -0.4rem 0 0; }
.sort-step > .link { justify-self: start; }
.sort-step .button:disabled { opacity: 0.45; cursor: not-allowed; }

/* Pill chips: radio buttons for Who, buttons for the quick dates. */
.pills, fieldset.who { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
fieldset.who { margin: 0; padding: 0; border: 0; }
fieldset.who legend { padding: 0; margin-bottom: var(--space-2xs); }
label.pill { position: relative; display: inline-flex; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
label.pill span, button.pill {
  display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0 var(--space-s);
  border: 1px solid var(--line); border-radius: 2rem; cursor: pointer; background: none;
}
.pill input:checked + span, button.pill.is-on { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.pill input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.sort-footer { text-align: center; font-size: var(--step--1); margin-top: var(--space-m); }

/* --- Household, help ---------------------------------------------------------------------- */

.household { margin-top: var(--space-l); padding-top: var(--space-m); border-top: 1px solid var(--line); }
.household summary { cursor: pointer; color: var(--muted); padding: var(--space-xs) 0; }
.household .members, .household #invite { margin-top: var(--space-s); }
.members { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--space-2xs); }
.members li { display: flex; align-items: center; gap: var(--space-xs); }
/* How it works: a hero with a 4-step overview, then the steps as a numbered timeline. */
.help { counter-reset: step; }
.help-hero { margin-bottom: var(--space-l); }
.lead { font-size: var(--step-1); line-height: 1.45; }
.overview { list-style: none; margin: var(--space-m) 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2xs); }
.overview a {
  display: grid; justify-items: center; gap: 0.1rem; padding: var(--space-xs) 0; border-radius: var(--radius);
  color: inherit; text-decoration: none; font-size: var(--step--1); font-weight: 600;
  background: var(--tint);
}
.overview span { font-size: var(--step-2); line-height: 1.2; }

.steps { list-style: none; margin: 0; padding: 0; }
.step { position: relative; padding: 0 0 var(--space-l) 2.75rem; scroll-margin-top: var(--space-m); }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 0; width: 2rem; height: 2rem; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--bg); font-weight: 700;
}
/* The line joining each step to the next. */
.step:not(:last-child)::after { content: ""; position: absolute; left: calc(1rem - 1px); top: 2.4rem; bottom: 0.4rem; width: 2px; background: var(--line); }
.step h2 { margin: 0.1rem 0 var(--space-xs); font-size: var(--step-2); }

.mock-add { display: flex; gap: var(--space-xs); margin: var(--space-s) 0 var(--space-2xs); }
.mock-input, .mock-button { padding: var(--space-xs) var(--space-s); border: 1px solid var(--line); border-radius: var(--radius); }
.mock-input { flex: 1; min-width: 0; }
.mock-result { font-size: var(--step--1); }
.tip { padding: var(--space-xs) var(--space-s); border-radius: var(--radius); font-size: var(--step--1); background: var(--tint); }

.choice-tiles { list-style: none; margin: var(--space-s) 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-xs); }
.choice-tiles li { display: grid; align-content: start; gap: 0.15rem; padding: var(--space-s); border: 1px solid var(--line); border-radius: var(--radius); }
.choice-tiles strong { line-height: 1.25; }
.choice-tiles .hint { font-size: var(--step--2); line-height: 1.35; }
.help-card .shortcut-example { margin-top: var(--space-m); }
.tile-icon { font-size: var(--step-1); }

.list-guide { list-style: none; margin: var(--space-s) 0; padding: 0; display: grid; gap: var(--space-xs); }
.list-guide > li { display: grid; grid-template-columns: 2rem 1fr; column-gap: var(--space-xs); align-items: center; }
.list-guide > li > .hint { grid-column: 2; }
.guide-icon { grid-row: span 2; display: grid; place-items: center; color: var(--accent); }
.list-guide ul { grid-column: 2; list-style: none; margin: var(--space-2xs) 0 0; padding: 0 0 0 var(--space-s); border-left: 2px solid var(--line); display: grid; gap: var(--space-2xs); font-size: var(--step--1); }

.help-card { padding: var(--space-m); border: 1px solid var(--line); border-radius: var(--radius-lg); scroll-margin-top: var(--space-m); }
.help-card h2 { margin-top: 0; }
.help-footer { display: grid; gap: var(--space-s); justify-items: center; text-align: center; margin: var(--space-l) 0; }
.help-footer .button { width: 100%; }

/* --- Bigger screens ------------------------------------------------------------------------ */

@media (min-width: 30rem) {
  .wide-only { display: inline; }
  .narrow-only { display: none; }
  .bar-actions { gap: var(--space-m); }
  .row { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); }
  #invite.stack { max-width: 22rem; }
  #tabs > p > .button { width: auto; }
  .choice-tiles { grid-template-columns: repeat(3, 1fr); }
  .help-footer .button { width: auto; min-width: 12rem; }
  .sort-tiles { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 48rem) {
  /* Room for every list as a tab on one line: a little more width, a little less padding per tab. */
  main { max-width: 46rem; }
  .tabs { display: flex; }
  .tabs a { padding-inline: var(--space-xs); }
  .bottom-nav, .view-title { display: none; }
  main:has(.bottom-nav) { padding-bottom: var(--space-l); }
  .quick-add { margin-inline: 0; padding-inline: 0; }
  .edit-actions { margin-inline: 0; padding-inline: 0; grid-template-columns: auto auto; justify-content: end; }
  .edit-actions .button { min-width: 7rem; }
  .edit-row.is-stacked { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Hover only where there's a pointer that can hover; on touch these would stick after a tap. */
@media (hover: hover) {
  a.task-title:hover { text-decoration: underline; }
  .chip:hover { color: var(--accent); text-decoration: underline; }
  .check:hover { border-color: var(--accent); }
  button.icon { opacity: 0.35; }
  .task:hover button.icon, .item:hover button.icon, button.icon:hover { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  button:active, .button:active { transform: none; }
}

/* --- QR dialog ------------------------------------------------------------------------------ */

.icon-button { min-width: var(--tap); padding: 0; border: 0; background: none; color: var(--fg); }
@media (hover: hover) { .icon-button:hover { color: var(--accent); } }

/* A bottom sheet on phones (thumb-reachable, slides up); a centered card on bigger screens.
   @starting-style gives the opening state; `overlay` and `display` with allow-discrete keep the
   dialog in the top layer until its closing transition has finished. */
dialog.sheet {
  --sheet-hidden: translateY(100%);
  width: 100%; max-width: 100%; max-height: 90dvh; overflow: auto;
  margin: auto 0 0; padding: 0; border: 0; border-radius: 1.25rem 1.25rem 0 0;
  background: var(--bg); color: var(--fg); box-shadow: 0 -0.5rem 2rem rgb(0 0 0 / 0.2);
  opacity: 0; transform: var(--sheet-hidden);
  transition:
    opacity 0.25s ease, transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1),
    overlay 0.35s allow-discrete, display 0.35s allow-discrete;
}
dialog.sheet[open] { opacity: 1; transform: none; }
@starting-style { dialog.sheet[open] { opacity: 0; transform: var(--sheet-hidden); } }

dialog.sheet::backdrop {
  background: rgb(0 0 0 / 0);
  transition: background 0.3s ease, overlay 0.35s allow-discrete, display 0.35s allow-discrete;
}
dialog.sheet[open]::backdrop { background: rgb(0 0 0 / 0.45); }
@starting-style { dialog.sheet[open]::backdrop { background: rgb(0 0 0 / 0); } }

.sheet-body {
  display: grid; justify-items: center; gap: var(--space-xs); text-align: center;
  padding: var(--space-l) var(--space-m) max(var(--space-l), env(safe-area-inset-bottom));
}
/* The little grab handle that says "this is a sheet". */
.sheet-body::before { content: ""; width: 2.5rem; height: 0.3rem; border-radius: 1rem; background: var(--line); margin-bottom: var(--space-xs); }
.sheet-body h2 { margin: 0; font-size: var(--step-1); }
.sheet-body .hint { margin: 0; }
.sheet-body form { width: 100%; margin: var(--space-xs) 0 0; }
.sheet-body form .button { width: 100%; }
.qr { width: min(16rem, 70vw); aspect-ratio: 1; margin: var(--space-s) 0 0; padding: var(--space-xs); border-radius: var(--radius); background: #fff; }
.qr svg { display: block; width: 100%; height: 100%; }
.qr-url { margin: 0; font-size: var(--step--1); color: var(--muted); overflow-wrap: anywhere; }

/* Nothing behind the dialog scrolls while it's open. */
html:has(dialog[open]) { overflow: hidden; }

@media (min-width: 30rem) {
  dialog.sheet {
    --sheet-hidden: translateY(0.75rem) scale(0.94);
    width: min(24rem, calc(100% - 2rem)); margin: auto; border-radius: 1.25rem;
    box-shadow: 0 1rem 3rem rgb(0 0 0 / 0.25);
  }
  .sheet-body { padding-bottom: var(--space-l); }
  .sheet-body::before { display: none; }
  .sheet-body form .button { width: auto; min-width: 8rem; }
  #shortcuts-dialog { width: min(30rem, calc(100% - 2rem)); }
}

@media (prefers-reduced-motion: reduce) {
  dialog.sheet, dialog.sheet::backdrop { transition-duration: 0.01s; }
}

/* Shortcuts drawer: each example is a chip you can tap to add it to the task being typed. */
/* Grouped by question (When, Who, Where…): a heading per group, then short labelled rows of chips. */
.shortcut-groups { display: grid; gap: var(--space-s); width: 100%; margin-top: var(--space-xs); text-align: left; }
.shortcut-group { display: grid; gap: var(--space-2xs); padding-top: var(--space-s); border-top: 1px solid var(--line); }
.shortcut-group:first-child { border-top: 0; padding-top: 0; }
.shortcut-group h3 { margin: 0; font-size: var(--step-0); }
.shortcut-group .hint { margin: 0; }
.shortcut-row { display: grid; grid-template-columns: 4.25rem 1fr; gap: var(--space-xs); align-items: center; }
.shortcut-row.no-label { grid-template-columns: 1fr; }
.shortcut-group h3 .hint { font-weight: normal; margin-left: 0.35em; }
.shortcut-label { font-size: var(--step--1); color: var(--muted); }
.tokens { display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
.sheet-body > .shortcut-example { width: 100%; text-align: left; margin: var(--space-s) 0 0; }
.shortcut-example .token { height: auto; padding-block: 0.35rem; text-align: left; justify-content: flex-start; }
code.token { display: inline-flex; align-items: center; min-height: 1.9rem; }
.token {
  min-height: 2.25rem; padding: 0 var(--space-xs); border-radius: 1rem;
  font-family: ui-monospace, monospace; font-size: var(--step--1);
  background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 25%, transparent);
}
.sheet-body > .hint:not(.shortcut-example) { text-align: center; }
@media (hover: hover) { .token:hover { border-color: var(--accent); } .help-button:hover { color: var(--accent); } }
