/* ==========================================================================
   base.css · "Cut & Keep" element defaults + component classes · v1.0
   Requires tokens.css (loaded first). Contains no raw colour, size or time
   values: everything comes from a token. Exceptions are structural numbers
   (0, 1, 100%, fr, ratios, line-clamp counts), the 1px visually-hidden clip,
   em-based text offsets and breakpoints, alpha masks and the SVG check mask.

   Contents
     1  Reset & elements        9  Recipe detail
     2  Typography helpers     10  Caption block
     3  Layout                 11  Ingredient list
     4  Icons                  12  Shopping list (aisle, item, progress)
     5  Buttons                13  Navigation (header, nav, tab bar)
     6  Inputs & fields        14  Modal / sheet
     7  Chips, tags, badges    15  Toasts, notices
     8  Recipe card + tray     16  Skeletons, empty state, onboarding
                               17  Motion keyframes, print, forced colours
   ========================================================================== */


/* 1 · Reset & elements ---------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  font-stretch: var(--stretch-normal);
  line-height: var(--leading-body);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
h1, h2, h3, h4, h5, h6 { font-weight: var(--weight-bold); line-height: var(--leading-heading); text-wrap: balance; }
p { text-wrap: pretty; }
ul[class], ol[class] { list-style: none; margin: 0; padding: 0; }

img, svg, video, picture { display: block; max-width: 100%; }
img { height: auto; }

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: var(--border-1);
  text-underline-offset: 0.2em;
}
a:hover { text-decoration-thickness: var(--border-2); }

button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

::selection { background: var(--color-accent); color: var(--color-on-accent); }

hr { border: 0; border-top: var(--border-1) solid var(--color-rule); margin: var(--space-6) 0; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--space-2); top: var(--space-2);
  z-index: var(--z-toast);
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary); color: var(--color-on-primary);
  border-radius: var(--radius-2);
  font-weight: var(--weight-semibold);
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }


/* 2 · Typography helpers -------------------------------------------------- */

.t-display, .t-h1, .t-h2 {
  font-family: var(--font-sans);
  font-weight: var(--weight-black);
  font-stretch: var(--stretch-condensed);
  letter-spacing: var(--tracking-display);
}
.t-display { font-size: var(--text-4xl); line-height: var(--leading-display); }
.t-h1      { font-size: var(--text-3xl); line-height: var(--leading-display); }
.t-h2      { font-size: var(--text-2xl); line-height: var(--leading-heading); }
.t-h3 {
  font-size: var(--text-xl); line-height: var(--leading-heading);
  font-weight: var(--weight-bold); font-stretch: var(--stretch-semi);
}
.t-h4 {
  font-size: var(--text-md); line-height: var(--leading-ui);
  font-weight: var(--weight-bold); font-stretch: var(--stretch-semi);
}
.t-lead  { font-size: var(--text-md); line-height: var(--leading-body); color: var(--color-text-muted); max-width: var(--measure); }
.t-body  { font-size: var(--text-base); line-height: var(--leading-body); max-width: var(--measure); }
.t-small { font-size: var(--text-sm); line-height: var(--leading-ui); }
.t-muted { color: var(--color-text-muted); }
.t-subtle { color: var(--color-text-subtle); }
.t-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  line-height: var(--leading-ui);
  letter-spacing: var(--tracking-mono-caps);
  text-transform: uppercase;
}
.t-mono { font-family: var(--font-mono); }
.t-num  { font-variant-numeric: tabular-nums; }

/* Highlighter swipe: brand mark, selected titles, "new" emphasis only */
.mark {
  background-image: linear-gradient(var(--color-accent), var(--color-accent));
  background-repeat: no-repeat;
  background-size: 100% 78%;
  background-position: 0 60%;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding-inline: 0.12em;
  color: var(--color-on-accent);
}


/* 3 · Layout -------------------------------------------------------------- */

.page {
  width: 100%;
  max-width: calc(var(--width-content) + 2 * var(--page-pad));
  margin-inline: auto;
  padding-inline: var(--page-pad);
}
.page--reading { max-width: calc(var(--width-reading) + 2 * var(--page-pad)); }
.page--list    { max-width: calc(var(--width-list) + 2 * var(--page-pad)); }
.page--narrow  { max-width: calc(var(--width-narrow) + 2 * var(--page-pad)); }

/* Room for the fixed tab bar + tray so nothing hides under them */
.app-main { padding-bottom: calc(var(--tabbar-h) + var(--tray-h) + var(--space-8) + env(safe-area-inset-bottom)); }
@media (min-width: 56.25em) { .app-main { padding-bottom: calc(var(--tray-h) + var(--space-12)); } }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4);
  padding-block: var(--space-6) var(--space-3);
  margin-bottom: var(--space-5);
  border-bottom: var(--border-2) solid var(--color-text);
}
.page-head__meta { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-text-muted); text-align: right; line-height: var(--leading-ui); }

.stack { display: flex; flex-direction: column; gap: var(--stack-gap, var(--space-4)); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cluster-gap, var(--space-3)); }

.library-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr));
  gap: var(--grid-gap-y) var(--grid-gap-x);
}

.section-head {
  display: flex; align-items: center; gap: var(--space-3);
  margin-block: var(--space-8) var(--space-4);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-mono-caps); text-transform: uppercase;
  color: var(--color-text-muted);
}
.section-head::after { content: ""; flex: 1; border-top: var(--border-1) solid var(--color-rule); }


/* 4 · Icons --------------------------------------------------------------- */
/* Usage: <svg class="icon" aria-hidden="true"><use href="/static/icons/sprite.svg#check"></use></svg> */

.icon {
  display: inline-block;
  width: var(--icon-md); height: var(--icon-md);
  flex: none;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: middle;
}
.icon--xs { width: var(--icon-xs); height: var(--icon-xs); }
.icon--sm { width: var(--icon-sm); height: var(--icon-sm); }
.icon--lg { width: var(--icon-lg); height: var(--icon-lg); stroke-width: 1.75; }
.icon--spin { animation: spin var(--dur-spin) linear infinite; }
.icon--inline { width: 1em; height: 1em; stroke-width: 2.5; vertical-align: -0.125em; }


/* 5 · Buttons ------------------------------------------------------------- */

.btn {
  --btn-bg: transparent;
  --btn-fg: var(--color-text);
  --btn-bd: transparent;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap);
  padding: 0 var(--space-5);
  border: var(--border-2) solid var(--btn-bd);
  border-radius: var(--radius-2);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  font-stretch: var(--stretch-semi);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  transition:
    background-color var(--dur-fast) var(--ease-standard),
    border-color var(--dur-fast) var(--ease-standard),
    color var(--dur-fast) var(--ease-standard),
    transform var(--dur-instant) var(--ease-standard);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(var(--border-1)); }

.btn--primary { --btn-bg: var(--color-primary); --btn-fg: var(--color-on-primary); --btn-bd: var(--color-primary); }
.btn--primary:hover, .btn--primary:active { --btn-bg: var(--color-primary-hover); --btn-bd: var(--color-primary-hover); }
/* Toggle buttons (e.g. "Add to shopping list" on recipe detail): pressed = picked */
.btn[aria-pressed="true"], .btn[aria-pressed="true"]:hover { --btn-bg: var(--color-accent); --btn-fg: var(--color-on-accent); --btn-bd: var(--color-text); }
.btn .when-pressed, .btn[aria-pressed="true"] .when-unpressed { display: none; }
.btn[aria-pressed="true"] .when-pressed { display: inline-flex; align-items: center; gap: var(--space-2); }
.btn .when-unpressed { display: inline-flex; align-items: center; gap: var(--space-2); }

.btn--secondary { --btn-bg: var(--color-surface); --btn-fg: var(--color-text); --btn-bd: var(--color-text); }
.btn--secondary:hover, .btn--secondary:active { --btn-bg: var(--color-surface-sunken); }

.btn--ghost {
  --btn-fg: var(--color-text);
  padding-inline: var(--space-3);
  text-decoration: underline; text-decoration-thickness: var(--border-1); text-underline-offset: 0.2em;
}
.btn--ghost:hover, .btn--ghost:active { --btn-bg: var(--color-surface-sunken); text-decoration: underline; }

.btn--accent { --btn-bg: var(--color-accent); --btn-fg: var(--color-on-accent); --btn-bd: var(--color-accent); font-weight: var(--weight-bold); }
.btn--accent:hover, .btn--accent:active { --btn-bg: var(--color-accent-hover); --btn-bd: var(--color-accent-hover); }

.btn--danger { --btn-bg: var(--color-surface); --btn-fg: var(--color-error); --btn-bd: var(--color-error); }
.btn--danger:hover, .btn--danger:active { --btn-bg: var(--color-error-bg); }

.btn--sm { min-height: var(--space-10); padding-inline: var(--space-3); font-size: var(--text-sm); }
.btn--lg { min-height: var(--tap-lg); padding-inline: var(--space-6); font-size: var(--text-md); }
.btn--block { display: flex; width: 100%; }
.btn--icon { width: var(--tap); padding: 0; }
.btn--icon.btn--sm { width: var(--space-10); }
@media (pointer: coarse) {
  .btn--sm { min-height: var(--tap-min); }
  .btn--icon.btn--sm { width: var(--tap-min); }
}

.btn:disabled, .btn[aria-disabled="true"] {
  --btn-bg: var(--color-surface-sunken);
  --btn-fg: var(--color-text-disabled);
  --btn-bd: var(--color-surface-sunken);
  cursor: not-allowed; transform: none;
}
.btn--ghost:disabled, .btn--ghost[aria-disabled="true"] { --btn-bg: transparent; --btn-bd: transparent; }

.btn[aria-busy="true"] { color: transparent; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: "";
  position: absolute; inset: 0; margin: auto;
  width: var(--icon-sm); height: var(--icon-sm);
  border: var(--border-2) solid var(--btn-fg);
  border-right-color: transparent;
  border-radius: var(--radius-pill);
  animation: spin var(--dur-spin) linear infinite;
}


/* 6 · Inputs & fields ----------------------------------------------------- */

.field { display: grid; gap: var(--space-2); align-content: start; }
.field__label { font-size: var(--text-sm); font-weight: var(--weight-semibold); line-height: var(--leading-ui); }
.field__hint  { font-size: var(--text-sm); color: var(--color-text-muted); line-height: var(--leading-ui); }
.field__error {
  display: flex; align-items: flex-start; gap: var(--space-2);
  font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: var(--leading-ui);
  color: var(--color-error);
}

.input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 var(--space-4);
  background: var(--color-surface);
  color: var(--color-text);
  border: var(--border-1) solid var(--color-border);
  border-radius: var(--radius-2);
  font-family: var(--font-sans);
  font-size: var(--text-base);   /* 16px: prevents iOS zoom on focus */
  line-height: var(--leading-ui);
  transition: border-color var(--dur-fast) var(--ease-standard);
}
.input::placeholder { color: var(--color-text-subtle); opacity: 1; }
.input:hover { border-color: var(--color-text-muted); }
.input:focus-visible { border-color: var(--color-text); }
.input[aria-invalid="true"] { border-color: var(--color-error); box-shadow: inset 0 0 0 var(--border-1) var(--color-error); }
.input:disabled { background: var(--color-surface-sunken); color: var(--color-text-disabled); border-color: var(--color-surface-sunken); cursor: not-allowed; }
.input[readonly] { background: transparent; border-style: dashed; }
textarea.input { min-height: var(--space-24); padding-block: var(--space-3); line-height: var(--leading-body); resize: vertical; }

.search { position: relative; max-width: var(--width-reading); }
.search > .icon { position: absolute; left: var(--space-4); top: 50%; transform: translateY(-50%); color: var(--color-text-subtle); pointer-events: none; }
.search > .input { padding-left: calc(var(--space-4) + var(--icon-md) + var(--space-2)); }


/* 7 · Chips, tags, badges ------------------------------------------------- */

.chip-row {
  display: flex; gap: var(--space-2);
  overflow-x: auto; scrollbar-width: none;
  margin-inline: calc(-1 * var(--page-pad));
  padding: var(--space-1) var(--page-pad);
  scroll-padding-inline: var(--page-pad);
}
.chip-row::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: var(--space-1);
  flex: none;
  min-height: var(--space-10);
  padding: 0 var(--space-4);
  border: var(--border-1) solid var(--color-border);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: 1;
  text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.chip:hover { border-color: var(--color-text); text-decoration: none; }
.chip .icon { width: var(--icon-xs); height: var(--icon-xs); stroke-width: 2.5; }
.chip[aria-pressed="true"], .chip[aria-current="true"], .chip.is-selected {
  background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary);
}
.chip:disabled, .chip[aria-disabled="true"] { background: var(--color-surface-sunken); border-color: var(--color-surface-sunken); color: var(--color-text-disabled); }
.chip__count { font-family: var(--font-mono); font-size: var(--text-xs); opacity: 0.8; }
@media (pointer: coarse) { .chip { min-height: var(--tap-min); } }

.tag {
  display: inline-flex; align-items: center; gap: var(--space-1);
  min-height: var(--space-6);
  padding: 0 var(--space-2);
  border: var(--border-1) solid currentColor;
  border-radius: var(--radius-1);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-mono-caps); text-transform: uppercase; line-height: 1;
  color: var(--color-text-muted);
}
.tag--new { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
.tag--ink { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }

.badge {
  display: inline-grid; place-items: center;
  min-width: var(--space-5); height: var(--space-5);
  padding: 0 var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--color-primary); color: var(--color-on-primary);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-semibold);
  line-height: 1; font-variant-numeric: tabular-nums;
}


/* 8 · Recipe card ("clipping") + selection tray --------------------------- */
/* Markup: rubric §6.3. State classes: .is-selected .card--processing
   .card--missing .card--error. Media is ALWAYS 4:5, cover-cropped. */

.card { position: relative; display: flex; flex-direction: column; min-width: 0; }

.card__media {
  --keyline-w: var(--border-1);
  --keyline-c: var(--color-keyline);
  --keyline-s: solid;
  position: relative; display: block;
  aspect-ratio: var(--ratio-card);
  overflow: hidden;
  background: var(--color-media-placeholder);
  transition: box-shadow var(--dur-base) var(--ease-out);
}
/* The keyline sits on top of the image and any fallback, never under it */
.card__media::before {
  content: ""; position: absolute; inset: 0; z-index: var(--z-raised);
  border: var(--keyline-w) var(--keyline-s) var(--keyline-c);
  pointer-events: none;
  transition: border-width var(--dur-fast) var(--ease-standard);
}
.card__img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: var(--focal-x, 50%) var(--focal-y, 50%);
}

.card__select {
  position: absolute; z-index: var(--z-raised);
  top: 0; right: 0;
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  padding: 0; border: 0; background: none;
  color: var(--color-text);
  border-radius: var(--radius-pill);
}
.card__select-dot {
  display: grid; place-items: center;
  width: var(--space-8); height: var(--space-8);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  box-shadow: inset 0 0 0 var(--border-2) var(--color-text);
  transition: background-color var(--dur-fast) var(--ease-standard), transform var(--dur-base) var(--ease-pop);
}
.card__select-dot .icon { width: var(--icon-sm); height: var(--icon-sm); stroke-width: 2.5; }
.card__select .icon-check { display: none; }
.card__select:hover .card__select-dot { background: var(--color-accent); }
.card__select:focus-visible { outline-offset: calc(-1 * var(--space-1)); }

.card__body { display: flex; flex-direction: column; gap: var(--space-0-5); padding-top: var(--space-1); min-width: 0; }
.card__retry { align-self: flex-start; padding-inline: 0; }

.card__credit {
  position: relative;   /* contains the visually-hidden suffix so overflow clips it */
  display: block;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-caps); text-transform: uppercase;
  line-height: var(--space-6);   /* 24px line box = 24px tap target (WCAG 2.5.8) */
  color: var(--color-text-muted);
  text-decoration: none;
}
.card__credit:hover { color: var(--color-text); text-decoration: underline; }

.card__title {
  font-family: var(--font-sans);
  font-size: var(--card-title-size);
  font-weight: var(--weight-semibold);
  font-stretch: var(--stretch-semi);
  line-height: var(--leading-ui);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow: hidden;
}
.card__title a { text-decoration: none; }
.card__title a:hover { text-decoration: underline; }
.card__title-text {
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
  background-image: linear-gradient(var(--color-accent), var(--color-accent));
  background-repeat: no-repeat; background-position: 0 60%;
  background-size: 0% 78%;
  transition: background-size var(--dur-slow) var(--ease-out);
}

/* Hover (fine pointers only): keyline thickens; the image is never altered */
@media (hover: hover) and (pointer: fine) {
  .card:hover .card__media { --keyline-w: var(--border-2); }
}
.card:has(.card__title a:focus-visible) .card__media { outline: var(--focus-width) solid var(--color-focus); outline-offset: var(--focus-offset); }

/* Selected */
.card.is-selected .card__media {
  --keyline-w: var(--border-3);
  --keyline-c: var(--color-text);
  box-shadow: var(--shadow-mark);
}
.card.is-selected .card__select-dot { background: var(--color-primary); color: var(--color-on-primary); box-shadow: none; }
.card.is-selected .card__select .icon-plus { display: none; }
.card.is-selected .card__select .icon-check { display: block; }
.card.is-selected .card__title-text { background-size: 100% 78%; color: var(--color-on-accent); }

/* Processing: DM received, media/caption still being fetched */
.card--processing .card__media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--color-shimmer), transparent);
  transform: translateX(-100%);
  animation: shimmer var(--dur-shimmer) linear infinite;
}
.card--processing .card__title { color: var(--color-text-subtle); font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--weight-regular); font-stretch: var(--stretch-normal); }
.card--processing .card__select { display: none; }
.card__pending {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--color-text-subtle);
}

/* Missing media: a typographic clipping instead of a broken image */
.card__fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-surface-sunken);
  color: var(--color-text);
}
.card__fallback-text {
  font-family: var(--font-sans); font-weight: var(--weight-black); font-stretch: var(--stretch-condensed);
  font-size: var(--text-xl); line-height: var(--leading-display); text-transform: uppercase;
  overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 5; line-clamp: 5; overflow: hidden;
}
.card__fallback-note { display: flex; align-items: center; gap: var(--space-1); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-text-muted); }
.card--missing .card__fallback { padding-top: var(--tap); }   /* clear of the select dot, the only overlay */
.detail__frame .card__fallback { box-shadow: inset 0 0 0 var(--border-1) var(--color-keyline); }   /* keyline stays on top of the pulp */
@media (max-width: 56.1875em) {   /* 120px detail thumbnail: smaller, and break between words only */
  .detail__frame .card__fallback { padding: var(--space-2); }
  .detail__frame .card__fallback-text { font-size: var(--text-md); overflow-wrap: normal; -webkit-line-clamp: 4; line-clamp: 4; }
}

/* Error: save failed */
.card--error .card__media { --keyline-c: var(--color-error); --keyline-s: dashed; --keyline-w: var(--border-2); }

/* Selection tray (fixed; visible when ≥1 recipe selected) */
.tray {
  --color-text: var(--color-inverse-text);
  --color-text-muted: var(--color-inverse-muted);
  --color-surface-sunken: var(--color-inverse-surface);
  --color-focus: var(--color-focus-inverse);
  position: fixed; z-index: var(--z-tray);
  left: var(--page-pad); right: var(--page-pad);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--space-3));
  max-width: var(--width-tray);
  margin-inline: auto;
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--tray-h);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  background: var(--color-inverse-bg);
  color: var(--color-inverse-text);
  border: var(--border-1) solid var(--color-inverse-edge);
  border-radius: var(--radius-0);
  box-shadow: var(--shadow-2);
  transition: transform var(--dur-slow) var(--ease-out), opacity var(--dur-fade) var(--ease-standard);
}
@starting-style { .tray { transform: translateY(var(--motion-shift-lg)); opacity: 0; } }
@media (min-width: 56.25em) { .tray { bottom: var(--space-6); } }

.tray__thumbs { display: flex; flex: none; padding-left: var(--space-1); }
.tray__thumb {
  width: var(--space-8); aspect-ratio: var(--ratio-card); object-fit: cover;
  outline: var(--border-2) solid var(--color-inverse-bg);
  background: var(--color-inverse-surface);
}
.tray__thumb + .tray__thumb { margin-left: calc(-1 * var(--space-3)); }
.tray__summary { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-0-5); }
.tray__count { font-weight: var(--weight-semibold); font-stretch: var(--stretch-semi); line-height: var(--leading-ui); font-variant-numeric: tabular-nums; }
.tray__count.is-bumped { animation: bump var(--dur-slow) var(--ease-pop); }
.tray__meta { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-inverse-muted); line-height: var(--leading-ui); }
.tray .btn--ghost { --btn-fg: var(--color-inverse-text); }
.tray__clear { display: none; }
@media (min-width: 37.5em) { .tray__clear { display: inline-flex; } }

/* Recipe row: compact clipping used in the review sheet and list sidebar */
.recipe-row {
  display: grid; grid-template-columns: var(--space-12) minmax(0, 1fr) auto;
  align-items: center; gap: var(--space-3);
  padding-block: var(--space-2);
  border-bottom: var(--border-1) solid var(--color-rule);
}
.recipe-row__thumb {
  width: var(--space-12); aspect-ratio: var(--ratio-card); object-fit: cover;
  background: var(--color-media-placeholder);
  outline: var(--border-1) solid var(--color-keyline); outline-offset: calc(-1 * var(--border-1));
}
.recipe-row__title { font-weight: var(--weight-semibold); font-stretch: var(--stretch-semi); line-height: var(--leading-ui); overflow-wrap: anywhere; }
.recipe-row__title a { text-decoration: none; }
.recipe-row__title a:hover { text-decoration: underline; }
.recipe-row__credit { font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: var(--tracking-caps); text-transform: uppercase; line-height: var(--space-6); color: var(--color-text-muted); text-decoration: none; }
.recipe-row__credit:hover { color: var(--color-text); text-decoration: underline; }


/* 9 · Recipe detail ------------------------------------------------------- */
/* One markup, two layouts: compact header on mobile, sticky media column on desktop. */

.detail {
  display: grid;
  grid-template-columns: var(--detail-thumb) minmax(0, 1fr);
  grid-template-areas: "media head" "actions actions" "content content";
  gap: var(--space-5) var(--space-4);
  padding-top: var(--space-4);
}
.detail__media { grid-area: media; display: flex; flex-direction: column; gap: var(--space-2); }
.detail__frame {
  position: relative;
  aspect-ratio: var(--ratio-card);
  overflow: hidden;
  background: var(--color-media-placeholder);
  outline: var(--border-1) solid var(--color-keyline); outline-offset: calc(-1 * var(--border-1));
}
.detail__frame img { width: 100%; height: 100%; object-fit: cover; object-position: var(--focal-x, 50%) var(--focal-y, 50%); }
.detail__head { grid-area: head; align-self: end; display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.detail__credit { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-medium); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--color-text-muted); line-height: var(--leading-ui); }
.detail__credit a { color: var(--color-text); }
.detail__title {
  font-size: var(--text-2xl); font-weight: var(--weight-black); font-stretch: var(--stretch-condensed);
  line-height: var(--leading-heading); letter-spacing: var(--tracking-display);
  overflow-wrap: anywhere;
}
.detail__actions { grid-area: actions; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.detail__actions .btn--primary { flex: 1 1 auto; }
.detail__content { grid-area: content; display: flex; flex-direction: column; gap: var(--space-10); min-width: 0; }
.detail__section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3);
  padding-bottom: var(--space-2); margin-bottom: var(--space-2);
  border-bottom: var(--border-2) solid var(--color-text);
  font-size: var(--text-xl); font-weight: var(--weight-black); font-stretch: var(--stretch-condensed); line-height: var(--leading-heading);
}
.detail__section-title small { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-medium); letter-spacing: var(--tracking-mono-caps); text-transform: uppercase; color: var(--color-text-muted); }
.detail__foot { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-text-muted); line-height: var(--leading-body); }

@media (min-width: 56.25em) {
  .detail {
    grid-template-columns: minmax(var(--detail-media-min), var(--detail-media-max)) minmax(0, var(--width-reading));
    grid-template-rows: auto auto 1fr;
    grid-template-areas: "media head" "media actions" "media content";
    column-gap: var(--space-12); row-gap: var(--space-6);
    padding-top: var(--space-8);
  }
  .detail__media { position: sticky; top: calc(var(--header-h) + var(--space-6)); align-self: start; }
  .detail__frame { aspect-ratio: var(--media-ratio, var(--ratio-card)); max-height: calc(100svh - var(--header-h) - var(--space-24)); }
  .detail__title { font-size: var(--text-3xl); }
}


/* 10 · Caption block: the creator's words, verbatim ----------------------- */

.caption { display: flex; flex-direction: column; gap: var(--space-3); }
.caption__body {
  max-width: var(--measure-mono);
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  font-weight: var(--weight-regular);
  line-height: var(--leading-mono);
  white-space: pre-wrap;           /* keep the creator's line breaks */
  overflow-wrap: anywhere;         /* long URLs and hashtag runs */
  tab-size: 2;
  color: var(--color-text);
}
.caption.is-collapsed .caption__body {
  max-height: calc(var(--caption-lines) * var(--leading-mono) * 1em);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 3 * var(--leading-mono) * 1em), transparent);
  mask-image: linear-gradient(to bottom, #000 calc(100% - 3 * var(--leading-mono) * 1em), transparent);
}
.caption__tag { color: var(--color-text-subtle); }
.caption__mention { font-weight: var(--weight-medium); }
.caption__link { color: var(--color-text-muted); }
.caption__toggle { align-self: flex-start; padding-inline: 0; }
.caption__empty { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-text-subtle); }


/* 11 · Ingredient list (structured, extracted) ---------------------------- */

.ingredients { display: flex; flex-direction: column; gap: var(--space-6); }
.ingredients__group-title {
  margin-bottom: var(--space-1);
  font-family: var(--font-mono); font-size: var(--text-xs); font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-mono-caps); text-transform: uppercase; color: var(--color-text-muted);
}
.ingredient {
  display: grid;
  grid-template-columns: var(--ingredient-qty-col) minmax(0, 1fr);
  column-gap: var(--space-3);
  align-items: baseline;
  padding-block: var(--space-3);
  border-bottom: var(--border-1) solid var(--color-rule);
}
.ingredient__qty {
  font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums; color: var(--color-text);
  line-height: var(--leading-ui);
}
.ingredient__qty:empty::before { content: "—"; content: "—" / ""; color: var(--color-text-subtle); }
.ingredient__name { font-size: var(--text-base); font-weight: var(--weight-medium); line-height: var(--leading-ui); }
.ingredient__note { display: block; margin-top: var(--space-0-5); font-size: var(--text-sm); font-weight: var(--weight-regular); color: var(--color-text-muted); }


/* 12 · Shopping list ------------------------------------------------------ */

.shop-head { display: flex; flex-direction: column; gap: var(--space-3); padding-block: var(--space-6) var(--space-4); }
.shop-head__meta { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }

.progress {
  height: var(--space-1-5);
  background: var(--color-surface-sunken);
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  width: calc(var(--done, 0) * 100%);
  background: var(--color-text);
  transition: width var(--dur-slow) var(--ease-out);
}

.aisle { margin-bottom: var(--space-6); }
.aisle__header {
  position: sticky; top: var(--header-h); z-index: var(--z-sticky);
  display: flex; align-items: center; gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-1);
  background: var(--color-bg);
  border-bottom: var(--border-2) solid var(--color-text);
}
.aisle__name {
  font-size: var(--text-md); font-weight: var(--weight-black); font-stretch: var(--stretch-condensed);
  letter-spacing: var(--tracking-caps); text-transform: uppercase; line-height: var(--leading-ui);
}
.aisle__count {
  margin-left: auto;
  font-family: var(--font-mono); font-size: var(--text-sm); font-weight: var(--weight-medium);
  color: var(--color-text-muted); font-variant-numeric: tabular-nums;
}
.aisle.is-complete .aisle__name { text-decoration: line-through; text-decoration-thickness: var(--border-2); color: var(--color-text-muted); }
.aisle.is-complete .aisle__count { color: var(--color-success); }

.list-item {
  position: relative;
  display: flex; align-items: flex-start; gap: var(--space-4);
  min-height: var(--row-list);
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-3);
  background: var(--color-surface);
  border-bottom: var(--border-1) solid var(--color-rule);
  cursor: pointer;
  -webkit-user-select: none; user-select: none;
  transition: background-color var(--dur-fast) var(--ease-standard);
}
.list-item:active { background: var(--color-surface-sunken); }
@media (hover: hover) and (pointer: fine) { .list-item:hover { background: var(--color-surface-sunken); } }

.list-item__check {
  appearance: none; -webkit-appearance: none;
  flex: none;
  width: var(--checkbox); height: var(--checkbox);
  margin: 0;
  display: grid; place-content: center;
  border: var(--border-2) solid var(--color-text);
  border-radius: var(--radius-1);
  background: var(--color-surface);
  cursor: pointer;
  transition: background-color var(--dur-instant) var(--ease-standard);
}
.list-item__check::before {
  content: "";
  width: var(--icon-sm); height: var(--icon-sm);
  background: var(--color-on-primary);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  transform: scale(0);
  transition: transform var(--dur-fast) var(--ease-pop);
}
.list-item__check:checked { background: var(--color-primary); border-color: var(--color-primary); }
.list-item__check:checked::before { transform: scale(1); }
@supports selector(:has(*)) {
  .list-item:has(.list-item__check:focus-visible) { outline: var(--focus-width) solid var(--color-focus); outline-offset: calc(-1 * var(--focus-width)); }
  .list-item__check:focus-visible { outline: none; }
}

.list-item__body {
  flex: 1; min-width: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--space-3); row-gap: var(--space-0-5);
  align-items: baseline;
}
.list-item__name { font-size: var(--list-item-size); font-weight: var(--weight-medium); line-height: var(--leading-ui); overflow-wrap: anywhere; transition: color var(--dur-base) var(--ease-standard); }
.list-item__text {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 58%;
  background-size: 0% var(--border-2);
  -webkit-box-decoration-break: slice; box-decoration-break: slice;
  transition: background-size var(--dur-strike) var(--ease-out);
}
.list-item__qty {
  font-family: var(--font-mono); font-size: var(--text-base); font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap;
  line-height: var(--leading-ui);
  transition: color var(--dur-base) var(--ease-standard);
}
.list-item__source {
  grid-column: 1 / -1;
  font-family: var(--font-mono); font-size: var(--text-xs); line-height: var(--leading-ui);
  color: var(--color-text-subtle);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Checked: strike drawn left → right, text dims but stays readable (≥ 4.5:1) */
.list-item__check:checked + .list-item__body .list-item__name,
.list-item.is-checked .list-item__name { color: var(--color-text-muted); }
.list-item__check:checked + .list-item__body .list-item__text,
.list-item.is-checked .list-item__text { background-size: 100% var(--border-2); }
.list-item__check:checked + .list-item__body .list-item__qty,
.list-item.is-checked .list-item__qty { color: var(--color-text-subtle); }

.list-item.is-syncing .list-item__check { outline: var(--border-2) dashed var(--color-text-subtle); outline-offset: var(--border-2); }
.list-item--added { animation: wash var(--dur-slower) var(--ease-out); }

.shop-list.hide-checked .list-item.is-checked,
.shop-list.hide-checked .list-item:has(.list-item__check:checked) { display: none; }

.list-add { display: flex; gap: var(--space-2); margin-top: var(--space-4); }
.list-add .input { flex: 1; }

@media (max-width: 37.4375em) {   /* phones: rows run edge to edge, like a receipt */
  .shop-list { margin-inline: calc(-1 * var(--page-pad)); }
  .aisle__header { padding-inline: var(--page-pad); }
  .list-item { padding-inline: var(--page-pad); }
}

.shop-layout { display: grid; gap: var(--space-10); }
.shop-aside { display: flex; flex-direction: column; gap: var(--space-3); }
@media (min-width: 56.25em) {
  .shop-layout {
    grid-template-columns: minmax(0, var(--width-list)) minmax(var(--detail-media-min), 1fr);
    column-gap: var(--space-12); align-items: start;
  }
  .shop-aside { position: sticky; top: calc(var(--header-h) + var(--space-6)); }
}


/* 13 · Navigation --------------------------------------------------------- */

.app-header {
  position: sticky; top: 0; z-index: var(--z-header);
  padding-top: env(safe-area-inset-top);   /* viewport-fit=cover, installed web app */
  background: var(--color-bg);
  border-bottom: var(--border-1) solid var(--color-keyline);
}
.app-header.is-stuck { box-shadow: var(--shadow-1); }  /* toggled by an IntersectionObserver on a sentinel */
.app-header__inner {
  max-width: calc(var(--width-content) + 2 * var(--page-pad));
  margin-inline: auto;
  height: var(--header-h);
  padding-inline: var(--page-pad);
  display: flex; align-items: center; gap: var(--space-4);
}
.app-header__end { margin-left: auto; display: flex; align-items: center; gap: var(--space-1); }

.brand {
  display: inline-flex; align-items: center; gap: var(--space-2);
  text-decoration: none;
  font-size: var(--text-lg); font-weight: var(--weight-black); font-stretch: var(--stretch-condensed);
  letter-spacing: var(--tracking-display); line-height: 1;
}
.brand:hover { text-decoration: none; }
.brand__mark { width: var(--icon-md); height: var(--icon-md); flex: none; }
.brand__word {
  background: var(--color-accent);
  color: var(--color-on-accent);
  padding: 0.12em 0.18em 0.08em;
}

.nav { display: none; }
@media (min-width: 56.25em) { .nav { display: flex; align-items: stretch; gap: var(--space-1); margin-left: var(--space-6); height: 100%; } }
.nav__link {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: 0 var(--space-3);
  font-weight: var(--weight-semibold); font-stretch: var(--stretch-semi);
  color: var(--color-text-muted);
  text-decoration: none;
}
.nav__link:hover { color: var(--color-text); text-decoration: none; }
.nav__link[aria-current="page"] { color: var(--color-text); }
.nav__link[aria-current="page"]::after {
  content: ""; position: absolute; left: var(--space-3); right: var(--space-3); bottom: calc(-1 * var(--border-1));
  height: var(--border-3); background: var(--color-text);
}

.tabbar {
  position: fixed; z-index: var(--z-tabbar);
  left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--color-bg);
  border-top: var(--border-1) solid var(--color-keyline);
}
@media (min-width: 56.25em) { .tabbar { display: none; } }
.tabbar__item {
  position: relative;
  min-height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-0-5);
  font-size: var(--text-xs); font-weight: var(--weight-semibold); line-height: 1;
  color: var(--color-text-muted);
  text-decoration: none;
}
.tabbar__item:hover { text-decoration: none; color: var(--color-text); }
.tabbar__item[aria-current="page"] { color: var(--color-text); }
.tabbar__item[aria-current="page"]::before {
  content: ""; position: absolute; top: calc(-1 * var(--border-1)); left: 28%; right: 28%;
  height: var(--border-3); background: var(--color-text);
}
.tabbar__item .badge { position: absolute; top: var(--space-2); left: calc(50% + var(--space-2)); }


/* 14 · Modal / bottom sheet (native <dialog>) ----------------------------- */

.modal {
  width: min(100% - 2 * var(--page-pad), var(--width-modal));
  max-height: min(85svh, 48rem);
  padding: 0;
  border: var(--border-1) solid var(--color-keyline);
  border-radius: var(--radius-2);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-3);
  overscroll-behavior: contain;
}
.modal::backdrop { background: var(--color-backdrop); }
.modal[open] { animation: rise var(--dur-slow) var(--ease-out); }
.modal[open]::backdrop { animation: fade var(--dur-base) var(--ease-standard); }
.modal__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-2) var(--space-3) var(--space-5);
  border-bottom: var(--border-2) solid var(--color-text);
}
.modal__title { font-size: var(--text-xl); font-weight: var(--weight-black); font-stretch: var(--stretch-condensed); line-height: var(--leading-heading); }
.modal__body { padding: var(--space-5); overflow: auto; display: flex; flex-direction: column; gap: var(--space-4); }
.modal__foot {
  display: flex; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-top: var(--border-1) solid var(--color-rule);
}
@media (max-width: 37.4375em) {
  .modal {
    width: 100%; max-width: 100%;
    margin: auto 0 0;
    border-width: var(--border-1) 0 0;
    border-radius: var(--radius-0);
    max-height: 92svh;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal[open] { animation: sheet var(--dur-slow) var(--ease-out); }
  .modal__foot { flex-direction: column-reverse; }
  .modal__foot .btn { width: 100%; }
}


/* 15 · Toasts & notices --------------------------------------------------- */

.toast-region {
  position: fixed; z-index: var(--z-toast);
  left: var(--page-pad); right: var(--page-pad);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--space-3));
  display: grid; justify-items: center; gap: var(--space-2);
  pointer-events: none;
}
body:has(.tray:not([hidden])) .toast-region,
.has-tray .toast-region { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--tray-h) + var(--space-5)); }
@media (min-width: 56.25em) {
  .toast-region { bottom: var(--space-6); }
  body:has(.tray:not([hidden])) .toast-region,
  .has-tray .toast-region { bottom: calc(var(--tray-h) + var(--space-8)); }
}

.toast {
  --color-text: var(--color-inverse-text);
  --color-text-muted: var(--color-inverse-muted);
  --color-surface-sunken: var(--color-inverse-surface);
  --color-focus: var(--color-focus-inverse);
  --toast-icon: var(--color-inverse-text);
  pointer-events: auto;
  width: 100%; max-width: var(--width-toast);
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--tap-lg);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  background: var(--color-inverse-bg);
  color: var(--color-inverse-text);
  border: var(--border-1) solid var(--color-inverse-edge);
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-2);
  font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: var(--leading-ui);
  animation: rise var(--dur-base) var(--ease-out);
}
.toast.is-leaving { animation: fall var(--dur-fast) var(--ease-in) forwards; }
.toast > .icon { color: var(--toast-icon); }
.toast--success { --toast-icon: var(--color-success-on-inverse); }
.toast--warning { --toast-icon: var(--color-warning-on-inverse); }
.toast--error   { --toast-icon: var(--color-error-on-inverse); }
.toast--info    { --toast-icon: var(--color-info-on-inverse); }
.toast__msg { flex: 1; min-width: 0; }
.toast .btn--ghost { --btn-fg: var(--color-inverse-text); }
.toast .toast__action { --btn-fg: var(--color-accent); font-weight: var(--weight-bold); }

.notice {
  --notice-fg: var(--color-info);
  --notice-bg: var(--color-info-bg);
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--notice-bg);
  border-left: var(--border-3) solid var(--notice-fg);
  color: var(--color-text);
  font-size: var(--text-sm); line-height: var(--leading-body);
}
.notice > .icon { color: var(--notice-fg); margin-top: var(--space-0-5); }
.notice__title { font-weight: var(--weight-semibold); }
.notice--success { --notice-fg: var(--color-success); --notice-bg: var(--color-success-bg); }
.notice--warning { --notice-fg: var(--color-warning); --notice-bg: var(--color-warning-bg); }
.notice--error   { --notice-fg: var(--color-error);   --notice-bg: var(--color-error-bg); }


/* 16 · Skeletons, empty state, onboarding --------------------------------- */

.skeleton {
  position: relative; overflow: hidden;
  background: var(--color-surface-sunken);
  border-radius: var(--radius-0);
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--color-shimmer), transparent);
  transform: translateX(-100%);
  animation: shimmer var(--dur-shimmer) linear infinite;
}
.skeleton--media { aspect-ratio: var(--ratio-card); }
.skeleton--line  { height: var(--space-3); margin-block: var(--space-1); }
.skeleton--line.is-short { width: 60%; }
.skeleton--row   { height: var(--row-list); border-bottom: var(--border-1) solid var(--color-rule); }

.empty {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-5);
  max-width: var(--width-list);
  padding-block: var(--space-6) var(--space-12);
}
.empty__art { width: 100%; max-width: var(--art-max); height: auto; color: var(--color-text); }
.empty__title { font-size: var(--text-3xl); font-weight: var(--weight-black); font-stretch: var(--stretch-condensed); line-height: var(--leading-display); letter-spacing: var(--tracking-display); }
.empty__body { font-size: var(--text-md); color: var(--color-text-muted); max-width: var(--measure); }

.steps { counter-reset: step; display: flex; flex-direction: column; gap: var(--space-4); width: 100%; }
.steps > li {
  counter-increment: step;
  display: grid; grid-template-columns: var(--space-10) minmax(0, 1fr); column-gap: var(--space-3);
  align-items: baseline;
  padding-bottom: var(--space-4);
  border-bottom: var(--border-1) solid var(--color-rule);
}
.steps > li::before {
  content: counter(step);
  font-size: var(--text-2xl); font-weight: var(--weight-black); font-stretch: var(--stretch-condensed); line-height: 1;
}
.steps__title { font-size: var(--text-md); font-weight: var(--weight-bold); font-stretch: var(--stretch-semi); line-height: var(--leading-ui); }
.steps__text { grid-column: 2; font-size: var(--text-base); color: var(--color-text-muted); }

.handle {
  display: inline-flex; align-items: center; gap: var(--space-2);
  max-width: 100%;
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-4);
  background: var(--color-surface);
  border: var(--border-2) solid var(--color-text);
  border-radius: var(--radius-2);
}
.handle__text {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono); font-size: var(--text-md); font-weight: var(--weight-semibold);
}

.onboard {
  display: grid; gap: var(--space-10);
  padding-block: var(--space-10) var(--space-16);
}
.onboard__copy { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-5); }
.onboard__art { width: 100%; max-width: var(--art-max-lg); justify-self: center; color: var(--color-text); }
.onboard__fine { font-size: var(--text-sm); color: var(--color-text-muted); max-width: var(--measure); }
@media (min-width: 56.25em) {
  .onboard { grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); align-items: center; column-gap: var(--space-16); padding-block: var(--space-20); }
}


/* 17 · Motion keyframes, print, forced colours ----------------------------- */

@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes fade    { from { opacity: 0; } }
@keyframes rise    { from { opacity: 0; transform: translateY(var(--motion-shift)); } }
@keyframes fall    { to   { opacity: 0; transform: translateY(var(--motion-shift)); } }
@keyframes sheet   { from { transform: translateY(var(--motion-shift-lg)); opacity: 0; } }
@keyframes bump    { 50% { transform: scale(1.12); } }
@keyframes wash    { from { background-color: var(--color-accent-wash); } }

@media (prefers-reduced-motion: reduce) {
  .skeleton::after, .card--processing .card__media::after { animation: none; display: none; }
  .icon--spin { animation-duration: var(--dur-shimmer); }
  .btn[aria-busy="true"]::after { animation-duration: var(--dur-shimmer); animation-iteration-count: 1; }
  .toast, .modal[open], .modal[open]::backdrop { animation-name: fade; animation-duration: var(--dur-fade); }
}

@media (forced-colors: active) {
  .list-item__check:checked + .list-item__body .list-item__text,
  .list-item.is-checked .list-item__text { text-decoration: line-through; text-decoration-thickness: var(--border-2); }
  .card.is-selected .card__media::before { border-color: Highlight; }
  .mark, .brand__word, .card__title-text { forced-color-adjust: none; }
}

@media print {
  :root, :root[data-theme="dark"] { --color-bg: var(--paper-0); --color-surface: var(--paper-0); --color-text: var(--ink-900); --color-text-muted: var(--ink-600); --color-rule: var(--ink-400); }
  .app-header, .tabbar, .tray, .toast-region, .btn, .list-add, .chip-row { display: none !important; }
  .aisle__header { position: static; }
  .list-item { min-height: 0; padding-block: var(--space-1); break-inside: avoid; }
  .aisle { break-inside: avoid-page; }
}
