:root {
  --blue: oklch(55% 0.25 258);
  --blue-dark: oklch(45% 0.22 258);
  --blue-tint: oklch(95% 0.045 258);
  --blue-text: oklch(48% 0.22 258);
  --pink: oklch(58% 0.26 330);
  --pink-tint: oklch(95% 0.045 330);
  --pink-text: oklch(50% 0.24 330);
  --purple-tint: oklch(94% 0.045 290);
  --purple-text: oklch(46% 0.20 290);
  --indigo-tint: oklch(94% 0.045 275);
  --indigo-text: oklch(48% 0.19 275);
  --amber-tint: oklch(94% 0.06 85);
  --amber-text: oklch(40% 0.10 70);
  --bg: oklch(99% 0.003 260);
  --card: #ffffff;
  --ink: oklch(24% 0.02 260);
  --muted: oklch(55% 0.02 260);
  --line: oklch(92% 0.008 260);
  --danger: oklch(52% 0.24 340);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: calc(70px + env(safe-area-inset-bottom));
}

#content { max-width: 640px; margin: 0 auto; padding: 16px 14px 24px; }

/* Slim, app-wide offline bar — see setOfflineBanner() in app.js. Sticky
   (not fixed) so it scrolls away with the rest of the page rather than
   permanently eating a strip of a 375px-wide screen, but still starts
   pinned to the very top, above the tab content, on every view. */
.offline-banner {
  position: sticky; top: 0; z-index: 60;
  background: var(--amber-tint); color: var(--amber-text);
  font-size: 0.82rem; line-height: 1.3; text-align: center;
  padding: 6px 14px;
  padding-top: calc(6px + env(safe-area-inset-top));
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small-text { font-size: 0.85rem; }

.view-head { margin-bottom: 14px; }
.view-head h1 { font-size: 1.5rem; margin-bottom: 8px; }

input[type="search"], input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--blue); border-color: var(--blue); }

textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 1rem; font-family: inherit; background: #fff; color: var(--ink); resize: vertical;
}
textarea:focus { outline: 2px solid var(--blue); border-color: var(--blue); }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.card h2 { font-size: 1.05rem; margin-bottom: 8px; }

.field { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; }
.field input { margin-top: 4px; font-size: 1rem; color: var(--ink); }

button {
  font: inherit;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button.primary { background: var(--blue); color: #fff; font-weight: 600; width: 100%; }
button.primary:active { background: var(--blue-dark); }
button.primary.small { width: auto; padding: 10px 16px; }
button.ghost { background: transparent; color: var(--blue); font-weight: 600; }
button.danger { background: transparent; color: var(--danger); font-weight: 600; }
button:disabled { opacity: 0.5; }
/* ...but a button that's disabled because it is BUSY must not look dead.
   startBusy() disables the button (so a second tap can't fire) and drops the
   pot spinner inside it — and the 0.5 fade above then washed out the very
   thing that was meant to say "something is happening", leaving a grey,
   half-invisible button. That is Lisa's report of 18 Aug 2026, "the indicator
   to show the app is working is not visible", on the slowest action in the
   app (building a shopping list). Keep a busy button at full strength; it is
   still functionally disabled and still carries aria-busy, so nothing about
   the guard weakens. Must stay AFTER the rule above to win on specificity. */
button:disabled.is-busy { opacity: 1; }

.actions { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }

.status { font-size: 0.9rem; padding: 8px 2px; }

.warn-note {
  background: var(--amber-tint); color: var(--amber-text);
  border-radius: 10px; padding: 8px 10px; font-size: 0.85rem; line-height: 1.4; margin: 4px 0 10px;
}
.warn-note ul { margin: 4px 0 0 18px; }

.social-toggle-btn { padding: 8px 2px; }
.social-drop {
  display: flex; align-items: center; justify-content: center;
  border: 2px dashed var(--muted); border-radius: 10px; padding: 10px;
  color: var(--muted); font-weight: 600; font-size: 0.9rem; margin: 4px 0 10px; cursor: pointer;
}
.social-photos { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 10px; }

/* ---- Recipes ---- */
.recipe-controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 10px; flex-wrap: wrap;
}
.owner-chips { margin-top: 0; }
.chips button.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.sort-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: var(--muted); white-space: nowrap;
}
.sort-label select { width: auto; padding: 7px 8px; font-size: 0.85rem; border-radius: 999px; }
.owner-tag {
  display: inline-block; margin-left: 8px; vertical-align: middle;
  font-size: 0.65rem; font-weight: 600; color: var(--muted);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 1px 7px;
}

.book-group { margin-bottom: 18px; }
.book-group h2 {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 6px; padding-left: 4px;
}
.book-group h2::before, .cat-group h2::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 6px; background: currentColor; vertical-align: middle;
}
/* rotate a jewel hue through consecutive groups so no two neighbors match */
.book-group:nth-of-type(4n+1) h2, .cat-group:nth-of-type(4n+1) h2 { color: var(--blue-text); }
.book-group:nth-of-type(4n+2) h2, .cat-group:nth-of-type(4n+2) h2 { color: var(--pink-text); }
.book-group:nth-of-type(4n+3) h2, .cat-group:nth-of-type(4n+3) h2 { color: var(--purple-text); }
.book-group:nth-of-type(4n) h2, .cat-group:nth-of-type(4n) h2 { color: var(--indigo-text); }

/* Each row sits on top of a hidden Delete button; swiping left slides the row
   aside to reveal it (see attachSwipe in app.js). */
.swipe-wrap { position: relative; margin-bottom: 8px; border-radius: 12px; overflow: hidden; }
.swipe-del {
  position: absolute; top: 0; bottom: 0; right: 0; width: 96px;
  display: flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff; font-weight: 600;
  border-radius: 0 12px 12px 0; padding: 0;
  visibility: hidden; /* only shown mid-swipe, so its corners never peek out */
}
.swipe-wrap.swiping .swipe-del { visibility: visible; }
.recipe-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px;
  position: relative; touch-action: pan-y; transition: transform 0.18s ease;
  user-select: none; -webkit-user-select: none;
}
.recipe-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--blue); flex-shrink: 0; }
.recipe-row .recipe-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; cursor: pointer; }
.recipe-row .thumb-add {
  width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0; padding: 0;
  background: none; border: 1.5px dashed var(--muted); font-size: 1rem; opacity: 0.55;
}
.recipe-row .title { flex: 1; font-weight: 500; }
/* Read-only rating on a recipe row (renderRecipes in app.js) — block-level
   so it sits on its own line under the title rather than widening the row,
   which at a 375px viewport would risk pushing the ›/👁 buttons off-screen.
   Muted and small so the title stays the thing the eye lands on. */
.row-stars { display: block; font-size: 0.68rem; color: var(--muted); letter-spacing: 1px; margin-top: 1px; }
.recipe-row .view-btn { background: none; color: var(--muted); font-size: 0.95rem; padding: 4px 6px; opacity: 0.7; }
.recipe-row .open-btn { background: none; color: var(--muted); font-size: 1.2rem; padding: 4px 8px; }
.recipe-row .basket-btn { background: none; color: var(--blue); font-size: 1rem; padding: 4px 6px; }

/* ---- Drinks ---- */
.recipe-row .drink-thumb-placeholder {
  display: flex; align-items: center; justify-content: center;
  background: var(--pink-tint); font-size: 1.1rem;
}
.drink-title-col { display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.drink-name-line { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drink-sub-line { font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#make-list-bar {
  position: fixed; bottom: calc(70px + env(safe-area-inset-bottom)); left: 0; right: 0;
  padding: 10px 14px; max-width: 640px; margin: 0 auto;
}
#make-list-bar button { box-shadow: 0 4px 16px rgba(0,0,0,0.18); }

.empty { text-align: center; color: var(--muted); margin-top: 60px; line-height: 1.6; }

/* ---- Add recipe ---- */
.photo-drop {
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  min-height: 110px; border: 2px dashed var(--pink); background: var(--pink-tint);
  border-radius: 12px; color: var(--pink-text); cursor: pointer; margin-bottom: 10px; overflow: hidden;
}
.photo-drop img { max-width: 100%; max-height: 300px; border-radius: 10px; }
/* Visually hidden but still present & activatable — NOT display:none, which iOS
   Safari won't reliably open a file picker for. The label triggers it natively. */
.sr-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

.ing-row { display: grid; grid-template-columns: 3.6em 3.6em 1fr 2em; gap: 6px; margin-bottom: 8px; align-items: center; }
.ing-row input, .ing-row select { padding: 9px 8px; font-size: 0.95rem; }
.ing-row .remove { background: none; color: var(--muted); font-size: 1.1rem; padding: 4px; }
.ing-row-cat { grid-column: 1 / -1; margin-top: -4px; }
.ing-row-cat select { color: var(--muted); font-size: 0.85rem; border: none; background: transparent; padding: 0 0 4px 2px; width: auto; }

#recipe-instructions { margin-bottom: 10px; }
.instr-photos { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 10px; }
.instr-thumb-wrap { position: relative; }
.instr-thumb { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; display: block; cursor: pointer; }
.instr-thumb-remove {
  position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; padding: 0;
  border-radius: 50%; background: var(--danger); color: #fff; font-size: 0.65rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* ---- Shopping list ---- */
.add-item-card form { display: flex; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; font-size: 0.85rem; color: var(--ink);
}
#extras-chips button:nth-of-type(4n+1) { background: var(--blue-tint); border-color: var(--blue-tint); color: var(--blue-text); }
#extras-chips button:nth-of-type(4n+2) { background: var(--pink-tint); border-color: var(--pink-tint); color: var(--pink-text); }
#extras-chips button:nth-of-type(4n+3) { background: var(--purple-tint); border-color: var(--purple-tint); color: var(--purple-text); }
#extras-chips button:nth-of-type(4n) { background: var(--indigo-tint); border-color: var(--indigo-tint); color: var(--indigo-text); }

.cat-group { margin-bottom: 16px; }
.cat-group h2 {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 6px; padding-left: 4px;
}
.item-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 12px;
  touch-action: pan-y; transition: transform 0.18s ease; user-select: none; -webkit-user-select: none;
}
.item-row input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--blue); flex-shrink: 0; border-radius: 50%; }
.item-row .item-name { flex: 1; min-width: 0; }
.item-row .qty { font-weight: 600; white-space: nowrap; }
.item-row .from { display: block; font-size: 0.75rem; color: var(--muted); }
.item-row.checked { opacity: 0.55; }
.item-row.checked .item-name { text-decoration: line-through; }
@keyframes flashAdded {
  0%   { background: var(--blue-tint); box-shadow: 0 0 0 2px var(--blue); }
  100% { background: var(--card); box-shadow: none; }
}
.item-row.flash { animation: flashAdded 1.3s ease-out; }

/* Small aisle button on each list row (item 4b) — tapping it opens
   #category-sheet, a picker of the categories table in display order. Kept
   deliberately compact (an icon + short label, ellipsized) so it never
   crowds the checkbox/name/qty at a 375px viewport; the row's own tap-to-
   check behaviour is untouched since this is its own element with its own
   click handler, not a click handler on the whole row. */
.item-row .item-cat-btn {
  flex-shrink: 0; max-width: 5.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 0.72rem; padding: 4px 8px;
}

/* Shopping-list rows swipe left to reveal TWO actions (item 7: move to store
   cupboard, then delete) instead of the single Delete a recipe row reveals
   (.swipe-del above) — same attachSwipe() mechanics in app.js, given this
   wider reveal width (LIST_SWIPE_W) so both buttons are always fully visible
   even at a 375px viewport. */
.swipe-actions {
  position: absolute; top: 0; bottom: 0; right: 0; width: 176px;
  display: flex; visibility: hidden; border-radius: 0 12px 12px 0; overflow: hidden;
}
.swipe-wrap.swiping .swipe-actions { visibility: visible; }
.swipe-actions button {
  flex: 1; display: flex; align-items: center; justify-content: center;
  border-radius: 0; padding: 0; font-weight: 600; font-size: 0.8rem; color: #fff; text-align: center;
}
.swipe-actions .swipe-cupboard { background: var(--blue); }
.swipe-actions .swipe-del { position: static; width: auto; background: var(--danger); border-radius: 0; }

#list-done h2 { font-size: 0.8rem; text-transform: uppercase; color: var(--muted); margin: 18px 0 6px 4px; }

/* Recipes currently on the active list (item 5) — a row of removable chips
   under the list header, above the add-item box. */
.list-recipes { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.list-recipes .list-recipe-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--purple-tint); color: var(--purple-text);
  border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 0.85rem;
}
.list-recipes .list-recipe-chip button {
  background: rgba(0,0,0,0.08); color: inherit; border-radius: 50%;
  width: 20px; height: 20px; padding: 0; font-size: 0.7rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}

/* Aisle picker sheet (item 4b) — one button per category, in display order,
   same shell as #servings-sheet/#cupboard-check-view. */
.category-sheet-list { display: flex; flex-direction: column; gap: 2px; }
.category-sheet-list button {
  text-align: left; background: none; border: none; border-bottom: 1px solid var(--line);
  padding: 14px 4px; font-size: 1rem; color: var(--ink); border-radius: 0;
}
.category-sheet-list button.active { color: var(--blue); font-weight: 700; }

/* Small "×⅔" scale suffix on a recipe chip (see .list-recipe-chip above) —
   only rendered when the recipe's stored scale isn't 1, so an unscaled list
   looks exactly as it always has (renderListRecipes in app.js). Muted
   rather than full-colour so it reads as a qualifier on the title, not a
   second piece of equally important text. */
.list-recipe-chip .chip-scale { opacity: 0.75; margin-left: 2px; }

/* Scale sheet (recipe-scaling feature, Sep 2026) — one row per selected
   recipe, asked every time recipes go on the list (see #scale-sheet's own
   comment in index.html for why: Lisa wants this prompt every time, never a
   remembered default). Preset buttons are deliberately large/finger-sized
   (matches .segmented's own touch target) so the five presets plus the
   custom field still fit comfortably at 375px without wrapping badly —
   tested at that width, both languages, per this repo's working
   conventions. */
.scale-sheet-rows { display: flex; flex-direction: column; gap: 18px; }
.scale-sheet-row { border-bottom: 1px solid var(--line); padding-bottom: 14px; }
.scale-sheet-row:last-child { border-bottom: none; }
.scale-sheet-row .scale-row-title { font-weight: 600; margin-bottom: 8px; }
.scale-sheet-row .scale-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.scale-sheet-row .scale-presets button {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: 1rem; color: var(--ink); min-width: 48px;
}
.scale-sheet-row .scale-presets button.active {
  background: var(--blue); border-color: var(--blue); color: #fff;
}
.scale-sheet-row .scale-custom {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.scale-sheet-row .scale-custom input {
  width: 90px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--bg); color: var(--ink); font-size: 1rem;
}
.scale-sheet-row .scale-custom input.active { border-color: var(--blue); }

/* ---- Store cupboard ---- */
.list-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.list-toolbar button { padding: 8px 10px; font-size: 0.85rem; }
/* Small inline count pill (unlike .badge, which is absolutely positioned for
   the tab bar) — sits right after the button's label text. */
.count-badge {
  display: inline-block; background: var(--pink); color: #fff;
  font-size: 0.7rem; font-weight: 700; font-style: normal;
  border-radius: 999px; padding: 1px 7px; margin-left: 4px; min-width: 16px;
}
.cupboard-add-form { display: flex; gap: 8px; margin-bottom: 4px; }
/* Separates the suggestion chips from the stored cupboard list below them —
   same visual language as .cat-group h2 / .book-group h2. */
.cupboard-list-heading {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 16px 0 6px 4px;
}
#cupboard-check-list .item-row .item-name { display: flex; flex-direction: column; }

/* ---- Settings ---- */
#key-form, #usda-key-form, #add-item-form, #import-form { display: flex; gap: 8px; }
input[type="url"] {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 1rem; background: #fff; color: var(--ink);
}
/* Lisa / Martin choice buttons (Add form + Settings) */
.segmented { display: flex; gap: 8px; margin-top: 6px; }
.segmented button {
  flex: 1; background: var(--bg); border: 1px solid var(--line);
  color: var(--ink); font-weight: 600; padding: 10px 12px;
}
.segmented button.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.add-mode-toggle { margin: 0 0 14px; }
.add-entry-choice { margin: 0 0 14px; }

/* ---- Star rating (shared by drink + recipe forms/detail views —
   see renderStarRating in app.js) ---- */
.star-rating { display: flex; gap: 4px; margin-top: 4px; }
.star-btn {
  background: none; padding: 4px; font-size: 1.4rem; line-height: 1;
  color: var(--muted); opacity: 0.6;
}
.star-btn.filled { color: var(--pink); opacity: 1; }
.cat-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.cat-row input { flex: 1; padding: 9px 10px; }
.cat-row button { background: var(--bg); border: 1px solid var(--line); padding: 8px 10px; color: var(--ink); }

/* ---- Tab bar ---- */
#tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabbar .tab {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; padding: 8px 1px 10px; font-size: 0.7rem; color: var(--muted);
  border-radius: 0; position: relative;
}
/* Icon only — :first-child keeps this off the label span (added for i18n)
   so a longer translated label doesn't inherit the icon's large size. */
#tabbar .tab span:first-child { font-size: 1.2rem; font-style: normal; }
/* Label span: small and non-wrapping, with a little breathing room below the
   0.7rem default so longer translations (e.g. German "Einstellungen") still
   fit a fifth of a 375px screen without colliding with neighboring tabs. */
#tabbar .tab span:last-of-type { font-size: 0.58rem; white-space: nowrap; }
#tabbar .tab.active { color: var(--blue); font-weight: 600; }
.badge {
  position: absolute; top: 4px; right: calc(50% - 22px);
  background: var(--pink); color: #fff; font-size: 0.65rem; font-style: normal;
  border-radius: 999px; padding: 1px 6px; min-width: 16px;
}

/* ---- Toast ---- */
#toast {
  position: fixed; bottom: calc(84px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 0.9rem; z-index: 50;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25); max-width: 90%;
}

/* ---- Full-screen photo viewer ---- */
#lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.92);
  display: flex; flex-direction: column;
}
#lightbox-scroll {
  flex: 1; overflow: auto; -webkit-overflow-scrolling: touch;
  display: flex; align-items: center; justify-content: center;
}
#lightbox-img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  transition: max-width 0.15s ease; cursor: zoom-in;
}
#lightbox-img.zoomed {
  max-width: 230%; max-height: none; object-fit: initial; cursor: zoom-out;
}
#lightbox-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; z-index: 2;
  background: rgba(0,0,0,0.5); color: #fff; font-size: 1.2rem;
  width: 42px; height: 42px; border-radius: 999px; padding: 0;
}
#lightbox-hint {
  text-align: center; color: rgba(255,255,255,0.7); font-size: 0.8rem;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
}

/* ---- Read-only recipe view (also used by #drink-view, #cupboard-view,
   #cupboard-check-view, #pairings-view, #pairing-suggest-view,
   #servings-sheet and #scale-sheet — same full-screen overlay shell for
   every sheet).
   Stacking note: sheets that can open on top of another sheet (e.g.
   #pairings-view over #drink-view, or #servings-sheet over #recipe-view) rely
   on DOM order at this shared z-index — later markup paints on top — so any
   new overlay meant to nest must be added later in index.html than whatever
   it can be opened from. */
#recipe-view, #drink-view, #cupboard-view, #cupboard-check-view,
#pairings-view, #pairing-suggest-view, #servings-sheet, #category-sheet,
#scale-sheet {
  position: fixed; inset: 0; z-index: 95; background: var(--bg);
  display: flex; flex-direction: column;
}
.recipe-view-head {
  display: flex; align-items: center; gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 14px 12px;
  border-bottom: 1px solid var(--line); background: var(--card);
}
.recipe-view-head h2 { flex: 1; font-size: 1.1rem; }
.recipe-view-head button { background: none; color: var(--muted); font-size: 1.1rem; padding: 6px 8px; }

/* #recipe-view's close button floats independently of the header (rather than
   sitting inline in it) so it can stay put — over the hero photo when there
   is one, or over the plain header otherwise. See #rv-header below. */
#recipe-view-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 12px; z-index: 10;
  background: none; color: var(--muted); font-size: 1.1rem;
  width: 38px; height: 38px; border-radius: 999px; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
#recipe-view.has-photo #recipe-view-close { background: rgba(0,0,0,0.5); color: #fff; }
/* No dish photo: #rv-header shows as a normal title bar; leave room on the
   right so the title never runs under the floating close button. */
#rv-header h2 { padding-right: 44px; }
/* Dish photo present: the hero (photo + title + servings) becomes the top of
   the view instead, so the plain header is not shown. */
#recipe-view.has-photo #rv-header { display: none; }

.recipe-view-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  max-width: 640px; width: 100%; margin: 0 auto;
  padding: 16px 14px calc(24px + env(safe-area-inset-bottom));
}
.recipe-view-body h3 { font-size: 0.95rem; margin: 4px 0 8px; }

/* Hero dish photo — bleeds edge-to-edge by cancelling .recipe-view-body's own
   padding, then re-applies it to the title/servings text underneath. */
.rv-hero { margin: -16px -14px 16px; }
.rv-dish-photo { width: 100%; height: 320px; object-fit: cover; display: block; cursor: zoom-in; }
.rv-hero-title { font-size: 1.3rem; font-weight: 700; padding: 14px 14px 0; }
.rv-hero-servings { padding: 2px 14px 0; color: var(--muted); font-size: 0.85rem; }

.rv-ingredients { list-style: none; margin-bottom: 22px; }
.rv-ingredients li { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rv-ing-qty { font-weight: 600; min-width: 3.6em; flex-shrink: 0; }
.rv-ing-note { color: var(--muted); }
/* Item 12: the recipe's own "(1 cup)" beside the stored metric amount —
   smaller and muted so the converted figure (what the list aggregates on)
   stays visually primary. */
.rv-ing-original { color: var(--muted); font-size: 0.85em; }

/* Same hint, in the edit form — sits under the category row so it doesn't
   fight the qty/unit/name inputs for width at 375px. */
.ing-original-hint { color: var(--muted); font-size: 0.8rem; margin-left: 8px; }

/* Numbered method steps — a visible circular counter per step (not the
   default browser numbering) plus generous spacing/line-height for reading
   at arm's length while cooking. */
.rv-steps { list-style: none; padding-left: 0; counter-reset: rv-step; }
.rv-steps li {
  counter-increment: rv-step;
  display: flex; gap: 12px; align-items: flex-start;
  margin-bottom: 28px; font-size: 1.05rem; line-height: 1.6;
}
.rv-steps li:last-child { margin-bottom: 0; }
.rv-steps li::before {
  content: counter(rv-step);
  flex-shrink: 0; margin-top: 1px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--blue); color: #fff;
  font-weight: 700; font-size: 0.95rem;
  display: flex; align-items: center; justify-content: center;
}

.rv-nutrition-section { margin-bottom: 22px; }
.rv-nutrition-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 10px; }
.rv-nutrition-cell {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 4px; text-align: center;
}
.rv-nutrition-val { display: block; font-weight: 700; font-size: 0.95rem; }
.rv-nutrition-label { display: block; font-size: 0.68rem; color: var(--muted); margin-top: 2px; }
#rv-nutrition-empty { margin-bottom: 8px; }
#rv-nutrition-btn { width: auto; padding: 8px 14px; font-size: 0.9rem; }

/* ---- Read-only drink view ---- */
.dv-photo {
  display: block; width: 100%; max-height: 45vh; object-fit: contain;
  border-radius: var(--radius); margin-bottom: 16px; cursor: zoom-in; background: var(--card);
}
.dv-fields { margin-bottom: 20px; }
.dv-field-row { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dv-field-label { color: var(--muted); min-width: 8em; flex-shrink: 0; }
.dv-field-value { flex: 1; font-weight: 500; }
.dv-notes { margin-top: 10px; line-height: 1.5; }

/* ---- Drink <-> recipe pairings ---- */
.dv-pairings-list { list-style: none; margin: 0 0 20px; }
.dv-pairings-list li { border-bottom: 1px solid var(--line); }
.dv-pairings-list li:last-child { border-bottom: none; }
.link-btn {
  display: block; width: 100%; text-align: left; background: none; font: inherit;
  color: var(--blue); font-weight: 500; padding: 10px 2px;
}
.rv-drinks-list .recipe-row { margin-bottom: 8px; }
#pairings-search { margin-bottom: 8px; }
#pairings-suggest-btn { margin-bottom: 10px; }
.pairings-list .item-name { display: flex; flex-direction: column; }
#pairing-suggest-list { margin-top: 14px; }
#pairing-suggest-list .recipe-row { margin-bottom: 8px; }

/* ---- Type-ahead suggestions ---- */
.field, .ing-row, #add-item-form { position: relative; }
.suggest-box {
  position: absolute; z-index: 40; max-width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.16); overflow: hidden;
}
.suggest-box button {
  display: block; width: 100%; text-align: left; border-radius: 0;
  background: none; color: var(--ink); padding: 10px 12px; font-size: 0.95rem;
  border-bottom: 1px solid var(--line);
}
.suggest-box button:last-child { border-bottom: none; }
.suggest-box button:active { background: var(--bg); }

/* ---- "Whose list?" pickers ---- */
.make-for { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#list-switch { margin: 2px 0 4px; }
#make-list-for {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px; width: max-content; margin: 0 auto 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}
.make-for-label { font-size: 0.8rem; color: var(--muted); }
.make-for button {
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 0.85rem; color: var(--ink);
}
.make-for button.active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ---- First-run "who's using this phone?" ---- */
#who-overlay {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.who-box {
  background: var(--card); border-radius: var(--radius);
  padding: 22px 18px; max-width: 340px; width: 100%; text-align: center;
}
.who-image { width: 140px; height: 140px; object-fit: contain; margin: 0 auto 14px; display: block; }
.who-box h2 { margin-bottom: 6px; }
.who-box p { color: var(--muted); margin-bottom: 14px; line-height: 1.45; }

/* ---- Busy indicator: "pot on the boil" ---- */
/* Cloned from #busy-spinner-tpl (index.html) by makeBusySpinner() in app.js.
   Sized in em and coloured with currentColor so it drops into a button or a
   .status line and matches whatever text sits next to it — see
   startBusy/endBusy in app.js for where this gets attached and removed. */
.busy-spinner { width: 1.35em; height: 1.35em; flex-shrink: 0; vertical-align: -0.3em; color: currentColor; }
/* In a status line the pot is the only thing moving, so it carries the accent
   colour to pull the eye down from the button the thumb just left. Inside a
   button it must stay currentColor instead — a .primary button is solid blue,
   where an accent-coloured pot would be all but invisible. */
.status .busy-spinner { color: var(--blue-text); }
.busy-bubble, .busy-steam {
  transform-box: fill-box; transform-origin: center;
  animation-timing-function: ease-in-out; animation-iteration-count: infinite;
}
.busy-bubble { animation-name: busy-bubble-rise; animation-duration: 1.4s; }
.busy-bubble-2 { animation-delay: 0.35s; }
.busy-bubble-3 { animation-delay: 0.7s; }
.busy-steam { animation-name: busy-steam-drift; animation-duration: 1.8s; }
.busy-steam-2 { animation-delay: 0.45s; }
.busy-steam-3 { animation-delay: 0.9s; }
@keyframes busy-bubble-rise {
  0%   { transform: translateY(0) scale(0.6); opacity: 0; }
  20%  { opacity: 1; }
  85%  { opacity: 0.4; }
  100% { transform: translateY(-5px) scale(1); opacity: 0; }
}
@keyframes busy-steam-drift {
  0%   { transform: translateY(2px); opacity: 0; }
  30%  { opacity: 0.8; }
  100% { transform: translateY(-4px); opacity: 0; }
}
/* Motion-sensitive users still get a "something is happening" signal — the
   whole pot pulses gently in place instead of bubbles rising / steam
   drifting. Never remove the indicator entirely: that was the one thing
   Lisa actually asked for (a plain disabled button wasn't enough). */
@media (prefers-reduced-motion: reduce) {
  .busy-bubble, .busy-steam { animation: none; opacity: 0.6; }
  .busy-spinner { animation: busy-pulse 1.6s ease-in-out infinite; }
}
@keyframes busy-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
/* Layout while busy: the spinner sits inline before whatever text is next to
   it — the button's own (stashed) label, or the .status line's message. */
button.is-busy { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.status { display: flex; align-items: center; gap: 6px; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(22% 0.02 258); --card: oklch(28% 0.03 258); --ink: oklch(96% 0.005 258);
    --line: oklch(35% 0.03 258); --muted: oklch(68% 0.02 258);
    --blue-tint: oklch(32% 0.06 258); --pink-tint: oklch(32% 0.06 330);
    --purple-tint: oklch(32% 0.06 290); --indigo-tint: oklch(32% 0.06 275);
    --amber-tint: oklch(32% 0.06 85);
    --blue-text: oklch(78% 0.16 258); --pink-text: oklch(78% 0.18 330);
    --purple-text: oklch(76% 0.15 290); --indigo-text: oklch(76% 0.14 275);
    --amber-text: oklch(78% 0.14 85);
  }
  input[type="search"], input[type="text"], input[type="password"], input[type="url"], input[type="number"], select, textarea { background: var(--card); color: var(--ink); }
  .segmented button, .owner-tag { background: var(--card); }
  #tabbar { background: var(--card); }
  #toast { background: #000; }
}
