/* Hallmark · redesign: full · shape: app screen · scope: app · genre: editorial (inferred) · theme: Ink (ink: paper) · deal: manual · modes: light+dark
 * signature: the ruled shopping list, one thumb-sized box per row, checked rows sinking grey to the foot of their section
 * pre-emit critique: P4 H5 E4 S4 R5 V3 · weakest: V, a ruled list is what every checklist is; kept it because in the aisle the list is the whole tool, and gave it the notice-board ink rule and section heads instead of cards
 * built: Hallmark (by hand from the v2.0.0 references; sloplint and theme.mjs not run) · v2.0.0
 * Hallmark · waive 22 · ink and greys at zero chroma · a shopping list on a notice board is printed in plain black
 * Hallmark · answered F4 · the floating new-list button and the dialog primary never share a screen: the dialog is modal
 * Hallmark · kept · each list's own colour, shown only as a 4px spine on its row on the home shelf: it is the owner's data, set per list; boxes stay ink */

:root {
  --color-paper: oklch(99.5% 0.003 100); --color-paper-2: oklch(97% 0.004 100); --color-paper-3: oklch(94% 0.006 100);
  --color-ink: oklch(16% 0 0); --color-ink-2: oklch(28% 0 0); --color-muted: oklch(44% 0 0);
  --color-rule: oklch(89% 0.004 100); --color-rule-2: oklch(93.5% 0.003 100);
  --color-accent: oklch(50% 0.095 188); --color-accent-ink: oklch(99.5% 0.003 100); --color-accent-soft: oklch(93% 0.05 190); --color-accent-soft-ink: oklch(27% 0.045 190);
  --color-focus: oklch(50% 0.095 188);
  --color-scrim: oklch(16% 0 0 / 0.42);
  --font-display: "Epilogue", ui-sans-serif, system-ui, sans-serif; --font-body: var(--font-display);
  --radius-card: 12px; --radius-control: 10px; --radius-pill: 999px; --rule-hair: 1px;
  --shadow-card: 0 20px 40px oklch(20% 0 0 / 0.16);
  --tracking-display: -0.04em; --display-weight: 700; --body-weight: 400;

  /* app scale, ratio 1.2 on a 17px body */
  --text-xs: 14px; --text-sm: 15px; --text-md: 17px; --text-lg: 20px; --text-xl: 24px;
  --space-2xs: 4px; --space-xs: 8px; --space-sm: 12px; --space-md: 16px; --space-lg: 24px; --space-xl: 40px;
  --dur-micro: 120ms; --dur-short: 200ms;
  --control: 40px; --hit: 44px; --row: 60px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-mode]) {
    --color-paper: oklch(15% 0.004 100); --color-paper-2: oklch(18% 0.004 100); --color-paper-3: oklch(21% 0.005 100);
    --color-ink: oklch(94% 0 0); --color-ink-2: oklch(84% 0 0); --color-muted: oklch(70% 0 0);
    --color-rule: oklch(32% 0.004 100); --color-rule-2: oklch(26% 0.003 100);
    --color-accent: oklch(68% 0.07 188); --color-accent-ink: oklch(15% 0.004 100); --color-accent-soft: oklch(30% 0.04 190); --color-accent-soft-ink: oklch(90% 0.04 190);
    --color-focus: oklch(68% 0.07 188);
    --color-scrim: oklch(5% 0 0 / 0.6);
    --shadow-card: inset 0 0 0 1px var(--color-rule);
    --body-weight: 350;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: clip; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--color-paper); color: var(--color-ink-2);
  font: var(--body-weight) var(--text-md)/1.55 var(--font-body);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: var(--display-weight); color: var(--color-ink); letter-spacing: var(--tracking-display); line-height: 1.05; overflow-wrap: break-word; min-width: 0; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--color-ink); font-weight: 600; text-underline-offset: 3px; text-decoration-thickness: 1px; transition: text-decoration-color var(--dur-micro); }
::selection { background: var(--color-accent-soft); color: var(--color-accent-soft-ink); }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: -3px; }
@media (hover: hover) { a:hover { text-decoration-color: var(--color-accent); } }

/* ---------- controls: one recipe, eight states ---------- */
.btn, .actions button, .add button, .auth-card button, .banner button {
  min-height: var(--control); padding: 0 var(--space-md); border-radius: var(--radius-control);
  border: var(--rule-hair) solid var(--color-rule); background: var(--color-paper-2); color: var(--color-ink);
  font-weight: 600; position: relative;
  transition: background-color var(--dur-micro), border-color var(--dur-micro);
}
.btn::before, .actions button::before, .add button::before { content: ""; position: absolute; inset: calc((var(--control) - var(--hit)) / 2) 0; }
.primary, .actions .primary, .auth-card .primary, .add button, .banner button { background: var(--color-ink); border-color: var(--color-ink); color: var(--color-paper); }
@media (hover: hover) {
  .actions button:hover, .auth-card button:hover { background: var(--color-paper-3); }
  .actions .primary:hover, .add button:hover, .banner button:hover, .auth-card .primary:hover, .fab:hover { background: var(--color-ink-2); }
}
.actions button:active, .add button:active, .banner button:active, .auth-card button:active, .fab:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.danger { color: var(--color-ink); }
.danger.armed { background: var(--color-ink); border-color: var(--color-ink); color: var(--color-paper); }

input:not([type=checkbox]):not([type=radio]), textarea, select {
  width: 100%; min-height: var(--control); padding: var(--space-xs) var(--space-sm);
  border: var(--rule-hair) solid var(--color-muted); border-radius: var(--radius-control);
  background: var(--color-paper); color: var(--color-ink); font-size: max(16px, var(--text-md));
  outline: 2px solid transparent; outline-offset: -3px;
  transition: background-color var(--dur-micro);
}
@media (hover: hover) { input:not([type=checkbox]):not([type=radio]):hover, textarea:hover, select:hover { background: var(--color-paper-2); } }
input::placeholder, textarea::placeholder { color: var(--color-muted); }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--color-ink); }

.tag { display: inline-flex; align-items: center; padding: 1px var(--space-xs); border-radius: var(--radius-pill); font-size: var(--text-xs); font-weight: 600; line-height: 1.5; white-space: nowrap; background: var(--color-paper-3); color: var(--color-ink-2); }
.tag--in { background: var(--color-accent-soft); color: var(--color-accent-soft-ink); }
.tag--out { background: transparent; box-shadow: inset 0 0 0 var(--rule-hair) var(--color-rule); color: var(--color-muted); }
.tag--on { background: var(--color-ink); color: var(--color-paper); }

/* ---------- top bar ---------- */
.bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: var(--space-xs);
  min-height: 56px; padding: calc(env(safe-area-inset-top) + var(--space-xs)) var(--space-md) var(--space-xs);
  background: var(--color-paper); border-bottom: var(--rule-hair) solid var(--color-ink);
}
.bar h1 { flex: 1; font-size: var(--text-xl); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { position: relative; display: grid; place-items: center; width: var(--control); height: var(--control); margin-inline: calc(var(--space-xs) * -1) 0; border: 0; border-radius: var(--radius-control); background: none; color: var(--color-ink); font-size: 34px; line-height: 1; text-decoration: none; font-weight: 400; }
.icon-btn::before { content: ""; position: absolute; inset: -2px; }
@media (hover: hover) { .icon-btn:hover { background: var(--color-paper-2); } }
.sync { font-size: var(--text-xs); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.sync.pending { color: var(--color-ink); font-weight: 600; }
.sync.offline { padding: 1px var(--space-xs); border-radius: var(--radius-pill); box-shadow: inset 0 0 0 var(--rule-hair) var(--color-rule); }

/* ---------- page ---------- */
main { width: min(100%, 640px); margin-inline: auto; padding: var(--space-md) var(--space-md) calc(env(safe-area-inset-bottom) + 112px); }
.section { font-size: var(--text-lg); margin: var(--space-xl) 0 var(--space-xs); }
.section:first-of-type { margin-top: var(--space-lg); }
.empty { color: var(--color-muted); margin: var(--space-xl) 0; }
.links { display: flex; flex-wrap: wrap; gap: var(--space-lg); margin-top: var(--space-xl); padding-top: var(--space-md); border-top: var(--rule-hair) solid var(--color-rule); }
.linkish { border: 0; background: none; padding: 0; color: var(--color-ink); font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
@media (hover: hover) { .linkish:hover { text-decoration-color: var(--color-accent); } }

.search label, .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* lists of lists: a ruled shelf, not cards */
.cards { list-style: none; margin: 0; padding: 0; border-top: var(--rule-hair) solid var(--color-ink); }
.cards > li { border-bottom: var(--rule-hair) solid var(--color-rule); }
.card { display: flex; align-items: center; gap: var(--space-sm); min-height: var(--row); padding: var(--space-sm) 0; color: var(--color-ink); text-decoration: none; font-weight: 400; }
@media (hover: hover) { .card:hover .name { text-decoration: underline; text-decoration-color: var(--color-accent); text-underline-offset: 3px; } }
.card .spine { flex: none; align-self: stretch; width: 4px; border-radius: 2px; background: var(--spine); }
.card .name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.card .count { color: var(--color-muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.card .count strong { color: var(--color-ink); font-weight: 700; }
.struck { text-decoration: line-through; color: var(--color-muted); }

.fab {
  position: fixed; right: var(--space-md); bottom: calc(env(safe-area-inset-bottom) + var(--space-md)); z-index: 4;
  min-height: 52px; padding: 0 var(--space-lg); border: 0; border-radius: var(--radius-control);
  background: var(--color-ink); color: var(--color-paper); font-weight: 600; box-shadow: var(--shadow-card);
  transition: background-color var(--dur-micro);
}

/* wells and banners */
.banner, .pdesc { margin-bottom: var(--space-md); padding: var(--space-sm) var(--space-md); background: var(--color-paper-2); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-card); }
.banner { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); color: var(--color-ink); font-weight: 600; }
.pdesc summary { cursor: pointer; color: var(--color-ink); font-weight: 600; padding-block: 10px; }
.md { color: var(--color-ink-2); }
.md > :first-child { margin-top: var(--space-2xs); } .md > :last-child { margin-bottom: var(--space-xs); }

/* ---------- the list itself: the signature ---------- */
.tasks { list-style: none; margin: 0; padding: 0; border-top: var(--rule-hair) solid var(--color-ink); }
.row { display: flex; align-items: center; min-height: var(--row); border-bottom: var(--rule-hair) solid var(--color-rule); background: var(--color-paper); touch-action: pan-y; }
.handle { flex: none; width: 28px; align-self: stretch; display: grid; place-items: center; margin-left: -6px; color: var(--color-muted); cursor: grab; touch-action: none; user-select: none; }
.handle.off { cursor: default; }
.check {
  flex: none; position: relative; width: 32px; height: 32px; margin-right: var(--space-sm);
  border: 2px solid var(--box, var(--color-ink)); border-radius: 8px; background: var(--color-paper);
  color: var(--color-paper); font-size: 18px; font-weight: 700; display: grid; place-items: center;
  transition: background-color var(--dur-micro);
}
.check::before { content: ""; position: absolute; inset: -8px; }
.row.done .check { background: var(--box, var(--color-ink)); }
.text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2xs) var(--space-xs); padding: var(--space-sm) 0; border: 0; background: none; text-align: left; color: var(--color-ink); }
.text .content { overflow-wrap: anywhere; }
.row.done .text { color: var(--color-muted); }
.row.done .content { text-decoration: line-through; text-decoration-thickness: 1px; }
.desc { flex-basis: 100%; font-size: var(--text-sm); color: var(--color-muted); }
.desc p { margin: 0; }
.row.done .desc { display: none; }

/* section heads inside a list: set as heads on an ink rule, sentence case */
.row.header { min-height: 52px; margin-top: var(--space-md); border-top: var(--rule-hair) solid var(--color-ink); border-bottom-color: var(--color-rule); }
.tasks > .row.header:first-child { margin-top: 0; border-top: 0; }
.row.header .text { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--text-lg); letter-spacing: var(--tracking-display); padding-top: var(--space-md); }

.row.dragging { background: var(--color-paper); box-shadow: var(--shadow-card); border-radius: var(--radius-control); }
.row.placeholder { background: var(--color-paper-2); border-bottom-style: dashed; }

.add { display: flex; gap: var(--space-xs); margin-top: var(--space-md); }
.add input { flex: 1; min-width: 0; min-height: 48px; }
.add button { min-height: 48px; padding: 0 var(--space-md); }

/* ---------- dialog ---------- */
dialog { width: min(560px, 100vw - 16px); max-height: 90dvh; padding: var(--space-lg); border: 0; border-radius: var(--radius-card); background: var(--color-paper); color: var(--color-ink-2); box-shadow: var(--shadow-card); }
dialog::backdrop { background: var(--color-scrim); }
dialog h2 { font-size: var(--text-xl); margin-bottom: var(--space-md); }
dialog label { display: grid; gap: var(--space-2xs); margin-bottom: var(--space-md); font-size: var(--text-sm); color: var(--color-ink-2); }
dialog label.inline { display: flex; align-items: center; gap: var(--space-xs); min-height: var(--hit); color: var(--color-ink); }
.colors { display: flex; flex-wrap: wrap; gap: var(--space-xs); border: 0; padding: 0; margin: 0 0 var(--space-md); }
.colors legend { font-size: var(--text-sm); margin-bottom: var(--space-2xs); padding: 0; }
.colors label { position: relative; margin: 0; }
.colors input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.colors span { display: block; width: var(--hit); height: var(--hit); border-radius: var(--radius-control); background: var(--c); }
.colors input:checked + span { outline: 2px solid var(--color-ink); outline-offset: 2px; }
.colors input:focus-visible + span { outline: 2px solid var(--color-focus); outline-offset: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-xs); align-items: center; margin-top: var(--space-xs); }
.actions > span { flex: 1; }
#archive + .danger { margin-right: auto; }
.keys { list-style: none; padding: 0; margin: 0 0 var(--space-md); border-top: var(--rule-hair) solid var(--color-ink); }
.keys li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 var(--space-sm); align-items: center; padding: var(--space-sm) 0; border-bottom: var(--rule-hair) solid var(--color-rule); }
.keys .name { font-weight: 600; color: var(--color-ink); }
.keys .muted { grid-row: 2; }
.keys button { grid-row: 1 / 3; grid-column: 2; min-height: var(--control); padding: 0 var(--space-sm); border-radius: var(--radius-control); border: var(--rule-hair) solid var(--color-rule); background: var(--color-paper-2); }
.keys button.armed { background: var(--color-ink); color: var(--color-paper); }

/* ---------- sign-in and consent pages ---------- */
body.auth { display: grid; place-items: center; min-height: 100dvh; padding: var(--space-md); }
.auth-card { width: min(380px, 100%); }
.auth-card h1 { font-size: var(--text-xl); padding-bottom: var(--space-sm); margin-bottom: var(--space-md); border-bottom: var(--rule-hair) solid var(--color-ink); }
.auth-card form { display: grid; gap: var(--space-xs); }
.auth-card > .primary { width: 100%; min-height: 48px; margin-bottom: var(--space-lg); }
.auth-card label { font-size: var(--text-sm); }
.auth-card form button { min-height: 48px; }
.error { color: var(--color-ink); font-weight: 600; }
.error::before { content: "Erreur : "; font-weight: 400; color: var(--color-muted); }
.muted { color: var(--color-muted); font-size: var(--text-sm); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
  .actions button:active, .add button:active, .banner button:active, .auth-card button:active, .fab:active { transform: none; }
}

/* ---------- shopping macros ---------- */
.text .meta { flex-basis: 100%; font-size: var(--text-xs); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.text .meta b { font-weight: 600; color: var(--color-ink-2); }
.row.done .meta { display: none; }
.macros { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-xs); margin-bottom: var(--space-md); padding: var(--space-sm) var(--space-md); background: var(--color-paper-2); border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-card); }
.macros div { display: grid; gap: 2px; min-width: 0; }
.macros .v { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--text-lg); letter-spacing: var(--tracking-display); color: var(--color-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.macros .v small { font-size: var(--text-xs); font-weight: 600; margin-left: 1px; color: var(--color-muted); letter-spacing: 0; }
.macros .k { font-size: var(--text-xs); color: var(--color-muted); }
.macros .note { grid-column: 1 / -1; margin: 0; font-size: var(--text-xs); color: var(--color-muted); }
fieldset.shop { border: var(--rule-hair) solid var(--color-rule); border-radius: var(--radius-card); padding: var(--space-sm) var(--space-md) var(--space-md); margin: 0 0 var(--space-md); }
fieldset.shop legend { font-size: var(--text-sm); font-weight: 600; color: var(--color-ink); padding: 0 var(--space-2xs); }
.macro-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-sm); }
.macro-grid label { margin-bottom: var(--space-sm); }
.shop .hint { margin: 0 0 var(--space-sm); font-size: var(--text-xs); color: var(--color-muted); }
#lookup { min-height: var(--control); padding: 0 var(--space-md); border-radius: var(--radius-control); border: var(--rule-hair) solid var(--color-ink); background: var(--color-paper); color: var(--color-ink); font-weight: 600; }
.food { list-style: none; padding: 0; margin: var(--space-sm) 0 0; }
.food li { border-bottom: var(--rule-hair) solid var(--color-rule); }
.food li.note { padding: var(--space-xs) 0; font-size: var(--text-sm); color: var(--color-muted); border: 0; }
.food button { width: 100%; display: grid; gap: 2px; padding: var(--space-xs) 0; min-height: var(--hit); border: 0; background: none; text-align: left; color: var(--color-ink); }
.food small { color: var(--color-muted); font-weight: 400; }
.food .meta { font-size: var(--text-xs); color: var(--color-muted); font-variant-numeric: tabular-nums; }
@media (min-width: 420px) { .macro-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
