/* The colours of the two looks. js/theme.js (and index.html before the first paint) puts data-theme="light" or "dark" on <html>.
   --accent fills (buttons, the active tab), --accent-text is the same colour for text and icons that stand on the background. */
:root {
  color-scheme: dark;
  --bg: #1a110e;
  --surface: #2a1d17;
  --surface-2: #36261e;
  --border: #3f2f26;
  --text: #f6ece4;
  --muted: #ab9a8b;
  --accent: #f3b27a;
  --on-accent: #35200f;
  --accent-text: #f3b27a;
  --accent-soft: #46301f;
  --danger: #ff8a73;
  --on-danger: #3b0d03;
  --heart: #ff6a45;
  --chip-on-bg: #f1e6dc;
  --chip-on-fg: #2a1d17;
  --scrim: rgb(0 0 0 / 0.6);
  --shadow-fab: 0 6px 18px rgb(0 0 0 / 0.45);
  --shadow-drag: 0 10px 28px rgb(0 0 0 / 0.55);
  --shadow-pop: 0 8px 24px rgb(0 0 0 / 0.5);
  --shadow-dialog: 0 20px 50px rgb(0 0 0 / 0.5);
  --shadow-card: 0 6px 16px rgb(0 0 0 / 0.35), inset 0 1px 0 rgb(255 255 255 / 0.25);
  --thumb-from: #4a3224;
  --thumb-to: #2a1d17;
  --tone-orange-bg: #5b3822;
  --tone-orange-fg: #f3b27a;
  --tone-green-bg: #2f4a37;
  --tone-green-fg: #97d9ab;
  --tone-purple-bg: #44375a;
  --tone-purple-fg: #c8aef5;
  --tone-gold-bg: #5a4725;
  --tone-gold-fg: #f0d07c;
  --tone-rose-bg: #5a2d3c;
  --tone-rose-fg: #f4a9c0;
  --radius: 18px;
  --tabbar-h: 68px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --content-w: 720px;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #fbf5ef;
  --surface: #ffffff;
  --surface-2: #f5ebe1;
  --border: #e7d8ca;
  --text: #2b1d16;
  --muted: #76604f;
  --accent: #eb9a5a;
  --on-accent: #2b1608;
  --accent-text: #9c4a0c;
  --accent-soft: #fcebdb;
  --danger: #c0381f;
  --on-danger: #ffffff;
  --heart: #d6401f;
  --chip-on-bg: #2b1d16;
  --chip-on-fg: #fbf5ef;
  --scrim: rgb(43 29 22 / 0.45);
  --shadow-fab: 0 6px 18px rgb(90 45 10 / 0.28);
  --shadow-drag: 0 10px 28px rgb(90 45 10 / 0.3);
  --shadow-pop: 0 8px 24px rgb(90 45 10 / 0.25);
  --shadow-dialog: 0 20px 50px rgb(90 45 10 / 0.3);
  --shadow-card: 0 6px 16px rgb(90 45 10 / 0.25), inset 0 1px 0 rgb(255 255 255 / 0.25);
  --thumb-from: #fde3cc;
  --thumb-to: #f5ebe1;
  --tone-orange-bg: #fde3cc;
  --tone-orange-fg: #a24d0e;
  --tone-green-bg: #dcefe1;
  --tone-green-fg: #2d6a43;
  --tone-purple-bg: #e8e0f5;
  --tone-purple-fg: #5b3f9a;
  --tone-gold-bg: #f8ecc4;
  --tone-gold-fg: #765608;
  --tone-rose-bg: #f9dde6;
  --tone-rose-fg: #a3355a;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 20px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.center { text-align: center; }
.grow { flex: 1; min-width: 0; }

/* ---- App frame ---- */

main {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
}

.page { display: flex; flex-direction: column; gap: 16px; }
.page.has-fab { padding-bottom: 72px; }
.page-title h1 { font-size: 1.7rem; line-height: 1.2; }
.page-title p { margin-top: 2px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }

.tabbar {
  position: fixed;
  inset: auto 0 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tabbar > div { display: flex; width: 100%; max-width: var(--content-w); }
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: var(--tabbar-h);
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.7rem;
}
.tab-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 30px;
  border-radius: 12px;
  transition: background 0.15s;
}
.tab[aria-current='page'] { color: var(--accent-text); font-weight: 600; }
.tab[aria-current='page'] .tab-icon { background: var(--accent); color: var(--on-accent); }
.badge {
  position: absolute;
  top: -5px;
  right: -2px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--heart);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-weight: 600;
  white-space: nowrap;
  color: inherit; /* also for a button that is a link */
  text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 0.9rem; border-radius: 12px; }
.btn.square { width: 48px; padding: 0; flex: none; border-radius: 50%; }
.btn:disabled { opacity: 0.5; cursor: default; }

.link { border: 0; background: none; padding: 6px 0; color: var(--accent-text); font-size: 0.9rem; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn[aria-pressed='true'] { color: var(--heart); }

input[type='text'], input[type='search'], input[type='number'], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
textarea { resize: vertical; }

.add-row { display: flex; gap: 10px; }

.search { position: relative; flex: 1; min-width: 0; }
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-left: 44px; }

.chips { display: flex; gap: 8px; }
.chips.scroll { overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips.wrap { flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 19px;
  background: var(--surface);
  font-size: 0.9rem;
  white-space: nowrap;
}
.chip.active { background: var(--chip-on-bg); border-color: var(--chip-on-bg); color: var(--chip-on-fg); font-weight: 600; }

.empty { padding: 40px 12px; text-align: center; color: var(--muted); }
.empty-title { color: var(--text); font-weight: 600; font-size: 1.1rem; margin-bottom: 6px; }

.fab {
  position: fixed;
  right: max(16px, calc((100vw - var(--content-w)) / 2 + 16px));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  z-index: 4;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-fab);
}
.fab-wide {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  z-index: 4;
  max-width: calc(var(--content-w) - 32px);
  margin: 0 auto;
  box-shadow: var(--shadow-fab);
}

/* ---- Home ---- */

.greeting { font-size: 1.7rem; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
}
.tile-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--tone-bg); color: var(--tone-fg); }
.tone-orange { --tone-bg: var(--tone-orange-bg); --tone-fg: var(--tone-orange-fg); }
.tone-green { --tone-bg: var(--tone-green-bg); --tone-fg: var(--tone-green-fg); }
.tone-purple { --tone-bg: var(--tone-purple-bg); --tone-fg: var(--tone-purple-fg); }
.tone-gold { --tone-bg: var(--tone-gold-bg); --tone-fg: var(--tone-gold-fg); }
.tone-rose { --tone-bg: var(--tone-rose-bg); --tone-fg: var(--tone-rose-fg); }
.tile.wide { grid-column: 1 / -1; }
.tile-title { display: block; font-weight: 700; }
.tile-sub { display: block; color: var(--muted); font-size: 0.8rem; }

.recipe-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.recipe-card { display: flex; flex-direction: column; gap: 8px; padding: 0; border: 0; background: none; text-align: left; min-width: 0; }
.recipe-card .thumb { width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius); }
.recipe-card .recipe-title { font-size: 1rem; }

/* ---- Recipes ---- */

.thumb { display: block; object-fit: cover; background: var(--surface-2); }
.thumb.placeholder { display: grid; place-items: center; font-size: 2rem; background: linear-gradient(135deg, var(--thumb-from), var(--thumb-to)); }

.recipe-list { display: flex; flex-direction: column; gap: 12px; }
.recipe-row { position: relative; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.recipe-open { display: flex; align-items: center; gap: 14px; width: 100%; padding: 10px 56px 10px 10px; border: 0; background: none; text-align: left; }
.recipe-row .thumb { flex: none; width: 96px; height: 76px; border-radius: 12px; }
.recipe-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.recipe-title { font-weight: 600; font-size: 1.05rem; line-height: 1.25; overflow-wrap: anywhere; }
.recipe-row .heart { position: absolute; top: 6px; right: 6px; }
.meta { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 0.85rem; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }

/* ---- The recipe database ---- */

.library-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.library-toolbar .chips { flex-wrap: wrap; gap: 6px; }
.library-toolbar .chip { min-height: 34px; padding: 0 14px; font-size: 0.85rem; }
.recipe-open.library { padding-right: 12px; }
.rating-badge { display: inline-flex; align-items: center; gap: 4px; color: var(--text); font-size: 0.85rem; }
.rating-badge .icon { color: var(--accent-text); }
.rating-badge.none { color: var(--muted); }
.stars { display: inline-flex; gap: 2px; }
.star { display: inline-flex; color: var(--muted); }
.star.on { color: var(--accent-text); }
.rating-summary, .published-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  text-align: left;
}
.published-line { justify-content: flex-start; color: var(--accent-text); font-size: 0.9rem; }
.published-text { flex: 1; min-width: 0; }
.published-line .chev, .rating-summary .chev { margin-left: auto; color: var(--muted); flex: none; }
.ratings { margin-top: 22px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ratings-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px; border: 0; background: none; text-align: left; }
.ratings-title { flex: 1; font-weight: 700; font-size: 1.05rem; }
.ratings-toggle .chev { color: var(--muted); transition: transform 0.15s ease; }
.ratings-toggle[aria-expanded='true'] .chev { transform: rotate(90deg); }
.ratings-body { display: flex; flex-direction: column; gap: 14px; padding: 0 14px 14px; }
.my-rating { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--accent); border-radius: 14px; background: var(--accent-soft); }
.my-rating p { margin: 0; }
.rating-list { list-style: none; margin: 0; padding: 0; }
.rating-item { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--border); }
.rating-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rating-comment { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.rating-actions { display: flex; gap: 16px; }
.rating-actions .link { padding: 0; color: var(--muted); font-size: 0.8rem; }
.report-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.report-card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.report-card p { margin: 0; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.report-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.publish-status { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--accent); border-radius: 14px; background: var(--accent-soft); }
.publish-status .icon { flex: none; margin-top: 2px; color: var(--accent-text); }
.publish-text { display: flex; flex-direction: column; gap: 2px; }
.stars-input { display: flex; align-items: center; justify-content: center; gap: 6px; }
.star-btn { display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--muted); }
.star-btn.on { color: var(--accent-text); border-color: var(--accent); }
.star-btn.zero { font-weight: 700; }
.stars-caption { margin: 0; text-align: center; color: var(--muted); }

.hero { position: relative; }
.hero img { display: block; width: 100%; height: 280px; object-fit: cover; }
.hero::after { content: ''; position: absolute; inset: auto 0 0; height: 80px; background: linear-gradient(transparent, var(--bg)); }
.hero-bar { position: sticky; top: 0; z-index: 3; height: 0; }
.hero-bar > div {
  position: absolute;
  inset: 0 0 auto;
  display: flex;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 0;
}
.hero-bar .actions { display: flex; gap: 8px; }
.hero-bar .icon-btn { background: rgb(26 17 14 / 0.65); color: #f6ece4; backdrop-filter: blur(6px); }
.recipe-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.recipe-head h2 { font-size: 1.6rem; line-height: 1.2; }

.no-top { margin-top: 0; }
.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper .icon-btn { width: 38px; height: 38px; border: 1px solid var(--border); background: var(--surface); }
.stepper output { min-width: 78px; text-align: center; font-weight: 600; }

.ing-card { list-style: none; margin: 10px 0 14px; padding: 4px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.ing { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.ing:last-child { border-bottom: 0; }
.ing-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.ing-amount { flex: none; color: var(--muted); text-align: right; }
.ing .ing-add {
  display: grid;
  place-items: center;
  flex: none;
  align-self: center;
  width: 36px;
  height: 36px;
  margin: -6px 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: none;
  color: var(--accent-text);
}
.ing .ing-add.done { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.ing-heading { padding: 12px 0 4px; font-weight: 700; color: var(--accent-text); }
.ing-card.select .ing { align-items: center; justify-content: flex-start; cursor: pointer; }
.ing-card.select .ing-name { flex: 1; }
.ing-card.select input { width: 24px; height: 24px; accent-color: var(--accent); flex: none; }

.steps { list-style: none; counter-reset: step; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.steps li { position: relative; padding-left: 42px; min-height: 30px; }
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 0.9rem;
}

/* "New recipe": the link of a recipe page, or write one by hand */
.sheet-body.import { display: flex; flex-direction: column; gap: 14px; }
.import .center { text-align: center; margin: 0; }
/* photos of a recipe to read */
.import-pages { display: flex; flex-direction: column; gap: 10px; }
.page-strip { display: flex; gap: 10px; }
.page-thumb { position: relative; flex: 1; min-width: 0; max-width: 33%; }
.page-thumb img { display: block; width: 100%; height: 110px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); }
.page-thumb .row-action.small { position: absolute; top: 4px; right: 4px; }
.import-details { border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; background: var(--surface); }
.import-details summary { cursor: pointer; font-size: 0.9rem; }
.import-details p { margin: 6px 0 0; overflow-wrap: anywhere; }

/* a photo under a step in the recipe */
.steps li .step-photo { display: block; width: 100%; max-height: 240px; margin-top: 8px; object-fit: cover; border-radius: 14px; }

/* ingredients and steps in the form: written in a row, added with +, listed below */
.entry-editor { gap: 8px; }
.entry-editor .add-row { align-items: flex-start; }
.entry-editor .add-row textarea { resize: none; }
.edit-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.edit-list:empty { display: none; }
.edit-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 4px 8px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.14s ease;
}
.edit-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 700;
  font-size: 0.8rem;
}
.edit-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.edit-text {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 8px 0;
  border: 0;
  background: none;
  text-align: left;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.edit-text.heading { font-weight: 700; color: var(--accent-text); }
.edit-input { min-height: 44px; padding: 8px 10px; border-radius: 10px; -webkit-user-select: text; user-select: text; }
.row-action {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--muted);
}
.row-action:hover { background: var(--surface-2); color: inherit; }
.row-action.small { width: 28px; height: 28px; background: rgb(0 0 0 / 0.6); color: #fff; }
.step-thumb-box { position: relative; align-self: flex-start; }
.step-thumb { display: block; padding: 0; border: 0; border-radius: 12px; background: none; overflow: hidden; }
.step-thumb img { display: block; width: 140px; height: 96px; object-fit: cover; }
.step-thumb-box .row-action.small { position: absolute; top: 4px; right: 4px; }
.edit-list.is-dragging { overflow: visible; }
.edit-list .edit-item.dragging {
  position: relative;
  z-index: 3;
  transition: none;
  background: var(--surface-2);
  box-shadow: var(--shadow-drag);
}

.notice { padding: 12px 14px; border: 1px solid var(--accent); border-radius: 14px; background: var(--accent-soft); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.notice p { margin: 0; }
.browser-hint { align-items: stretch; }
.hint-icon { align-self: center; display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.recipe-note { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.photo-field { display: flex; flex-direction: column; gap: 8px; }
.photo-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  height: 120px; border: 1.5px dashed var(--border); border-radius: var(--radius); background: var(--surface); color: var(--muted);
}
.photo-preview { width: 100%; height: 200px; object-fit: cover; border-radius: var(--radius); }
.photo-actions { display: flex; gap: 10px; }

/* ---- Shopping ---- */

.quick details { margin-bottom: 8px; }
.quick summary { cursor: pointer; padding: 6px 0; font-weight: 600; color: var(--muted); }
.quick .chips { margin: 6px 0 4px; }

.group-head { display: flex; align-items: center; justify-content: space-between; }
.group-title { margin: 6px 0; font-size: 0.9rem; color: var(--muted); font-weight: 600; }
.items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.item { display: flex; align-items: center; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.check {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 9px 6px 9px 14px;
  border: 2px solid var(--muted);
  border-radius: 8px;
  background: none;
  color: var(--on-accent);
  padding: 0;
}
.item.done .check { background: var(--accent); border-color: var(--accent); }
.item-main {
  flex: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 8px 16px 8px 8px;
  border: 0;
  background: none;
  text-align: left;
}
.item-text { display: flex; flex-direction: column; min-width: 0; }
.item-name { font-weight: 600; overflow-wrap: anywhere; }
.item-by { color: var(--muted); font-size: 0.78rem; }
.item-qty { color: var(--muted); font-size: 0.9rem; white-space: nowrap; }
.qty-stepper { display: flex; align-items: center; flex: none; gap: 4px; padding-right: 10px; }
.qty-stepper .item-qty { min-width: 3.2ch; text-align: center; }
/* swiping to the next list: the page keeps vertical scrolling and leaves sideways movements to the app */
html.swipe-lists { touch-action: pan-y pinch-zoom; }
.chips.scroll { touch-action: pan-x pan-y; }
@keyframes slide-from-right { from { opacity: 0.3; transform: translateX(40px); } }
@keyframes slide-from-left { from { opacity: 0.3; transform: translateX(-40px); } }
.page.slide-in-right { animation: slide-from-right 0.2s ease-out; }
.page.slide-in-left { animation: slide-from-left 0.2s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .page.slide-in-right, .page.slide-in-left { animation: none; }
}

/* page header with a menu button on the right */
.page-title.with-menu { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.page-title.with-menu .icon-btn { flex: none; margin: 2px -8px 0 0; }

.color-dot { width: 10px; height: 10px; margin-left: 2px; border-radius: 50%; flex: none; }

/* items that can be moved by holding them */
.items.reorder .item {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.14s ease;
}
.items.is-dragging { overflow: visible; }
.items.reorder .item.dragging {
  position: relative;
  z-index: 3;
  transition: none;
  border-radius: 14px;
  background: var(--surface-2);
  box-shadow: var(--shadow-drag);
}
.items.reorder .item.dragging .item-main { cursor: grabbing; }

.qty-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
}
.item.done .qty-stepper { padding-right: 16px; }
.item.done .item-name { text-decoration: line-through; color: var(--muted); font-weight: 400; }

/* ---- Loyalty cards ---- */

.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 560px) { .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card-grid .empty.wide { grid-column: 1 / -1; }
.card-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 12px; flex-wrap: wrap; }
.card-toolbar .chips { gap: 6px; }
.card-toolbar .chip { min-height: 32px; padding: 0 12px; font-size: 0.85rem; }

/* a card like in the wallet: the colour of the shop, in the middle its logo or its name, the end of the number below */
.card-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  min-height: 112px;
  padding: 14px;
  border: 0;
  border-radius: 18px;
  background-image: linear-gradient(135deg, rgb(255 255 255 / 0.2), rgb(0 0 0 / 0.16));
  box-shadow: var(--shadow-card);
  text-align: left;
  min-width: 0;
  transition: transform 0.12s ease;
}
.card-tile:active { transform: scale(0.97); }
.card-head { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; text-align: center; }
.card-title { display: block; font-weight: 800; font-size: 1.2rem; line-height: 1.08; overflow-wrap: anywhere; }
.name-line { display: block; }
.card-tail { font-size: 0.78rem; opacity: 0.75; font-variant-numeric: tabular-nums; letter-spacing: 0.05em; }

/* text for readers of the screen only (the logo says the name to the eye) */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* the logo of a shop: a one-colour glyph in the text colour of the card (a mask), or a full-colour logo on a white plate.
   The box is the most the logo may take, the logo fills it as far as its shape allows and sits in the middle of it */
.logo { display: block; flex: none; max-width: 100%; }
.logo.mono { background-color: currentColor; -webkit-mask: center / contain no-repeat; mask: center / contain no-repeat; }
.logo.plate { display: grid; place-items: center; padding: 4px; border-radius: 8px; background: #fff; box-sizing: border-box; }
.logo.plate img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-tile { width: 104px; height: 52px; }
.logo-story { width: 54px; height: 40px; }
.logo-hero { width: 128px; height: 60px; }

/* the cards used most: round pictures in a row, with the logo or the name of the shop inside */
.card-quick { display: flex; gap: 14px; overflow-x: auto; scrollbar-width: none; margin: 14px -16px 0; padding: 8px 16px; }
.card-quick[hidden] { display: none; }
.story {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 68px;
  height: 68px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-image: linear-gradient(135deg, rgb(255 255 255 / 0.2), rgb(0 0 0 / 0.16));
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--accent);
}
.story-text { display: block; max-width: 58px; font-weight: 800; line-height: 1.05; text-align: center; overflow-wrap: anywhere; }

.card-hero { display: flex; align-items: center; justify-content: center; min-height: 92px; padding: 16px 18px; border-radius: var(--radius) var(--radius) 0 0; font-weight: 800; font-size: 1.8rem; line-height: 1.1; text-align: center; overflow-wrap: anywhere; background-image: linear-gradient(135deg, rgb(255 255 255 / 0.2), rgb(0 0 0 / 0.16)); }
.card-view { display: flex; flex-direction: column; gap: 12px; }
.card-view .card-hero { margin-bottom: -12px; }
.code { padding: 20px; background: #fff; color: #000; border-radius: 0 0 var(--radius) var(--radius); }
.code svg { display: block; width: 100%; fill: #000; }
.code.linear svg { height: 130px; }
.code.square svg { width: min(100%, 280px); aspect-ratio: 1; margin: 0 auto; }
.code.error { color: #b3352a; text-align: center; }
.code-preview .code { border-radius: var(--radius); padding: 14px; }
.code-preview .code.linear svg { height: 80px; }
.card-digits { text-align: center; font-size: 1.4rem; font-weight: 700; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.note { padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); white-space: pre-wrap; }

/* the shops found for the name of a new card */
.shop-suggestions:empty { display: none; }
.shop-results { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
.shop-result { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px 14px; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; }
.shop-dot { flex: none; width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.15); }
.shop-text { display: flex; flex-direction: column; min-width: 0; }
.shop-name { font-weight: 600; overflow-wrap: anywhere; }
.shop-meta { color: var(--muted); font-size: 0.8rem; }
.shop-more { margin: 0; padding: 10px 14px; text-align: center; }
.shop-result:last-child { border-bottom: 0; }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { display: grid; place-items: center; width: 38px; height: 38px; border: 2px solid transparent; border-radius: 50%; color: #fff; padding: 0; }
.swatch.selected { border-color: var(--text); }

.scanner-video { width: 100%; max-height: 60dvh; background: #000; border-radius: var(--radius); object-fit: cover; }

/* ---- More ---- */

.menu { list-style: none; margin: 0; padding: 4px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.menu li { border-bottom: 1px solid var(--border); }
.menu li:last-child { border-bottom: 0; }
.menu-row { display: flex; align-items: center; gap: 14px; width: 100%; padding: 12px 0; border: 0; background: none; text-align: left; }
.menu-row .tile-icon { width: 42px; height: 42px; border-radius: 12px; flex: none; }
.menu-row > .icon:last-child { margin-left: auto; color: var(--muted); flex: none; }
.menu-text { display: flex; flex-direction: column; min-width: 0; }
.prose { display: flex; flex-direction: column; gap: 12px; }
.prose ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }

/* the account, two numbers and the list of what is here */
.profile-card { display: grid; grid-template-columns: auto 1fr; gap: 14px 16px; align-items: center; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.avatar { display: grid; place-items: center; width: 68px; height: 68px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 1.9rem; font-weight: 700; }
.avatar.plain { background: var(--surface-2); color: var(--muted); }
.profile-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.profile-name { font-size: 1.3rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.profile-mail { color: var(--muted); overflow-wrap: anywhere; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.pill { padding: 5px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 0.85rem; font-weight: 600; }
.profile-actions { grid-column: 1 / -1; }
.stat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 18px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.stat-number { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--muted); }
.menu-row.line { min-height: 58px; padding: 0; }
.menu-row.line > .icon:first-child { flex: none; color: var(--accent-text); }
.row-title { flex: 1; min-width: 0; font-size: 1.05rem; }
.row-value { flex: none; color: var(--muted); }
.menu-row.line > .icon:last-child { margin-left: 0; }

/* ---- Sheets ---- */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  background: var(--scrim);
  animation: fade 0.15s ease-out;
}
.sheet:not(.dialog) { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 1px); } /* the tab bar stays visible under the screens */
.sheet-panel {
  width: 100%;
  max-width: 640px;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  outline: none;
  padding-bottom: 28px;
  animation: rise 0.2s ease-out;
}
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px;
  background: var(--bg);
}
.sheet-title { flex: 1; min-width: 0; font-size: 1.25rem; overflow-wrap: anywhere; }
.sheet-actions { display: flex; align-items: center; gap: 4px; }
.sheet-body { padding: 0 16px; }

@media (min-width: 700px) {
  .sheet { align-items: center; }
  .sheet-panel { height: auto; max-height: 94%; border-radius: 22px; border: 1px solid var(--border); }
  .hero img { border-radius: 22px 22px 0 0; }
}

/* a small window in the middle (asking before something is deleted) */
.sheet.dialog { align-items: center; padding: 16px; }
.sheet.dialog .sheet-panel {
  height: auto;
  max-height: 90dvh;
  width: min(100%, 420px);
  padding: 22px 20px 20px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
}
.dialog-body { display: flex; flex-direction: column; gap: 8px; }
.dialog-title { font-size: 1.25rem; line-height: 1.25; overflow-wrap: anywhere; }
.dialog-text { color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.dialog-body .stack { margin: 10px 0 0; }
.dialog-body .btn.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); font-weight: 700; }

.form { display: flex; flex-direction: column; gap: 16px; padding: 4px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.field > label { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 600; font-size: 0.9rem; }
.hint { color: var(--muted); font-size: 0.8rem; }
.row { display: flex; gap: 10px; }
.scan-actions { display: grid; gap: 6px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.form-error { color: var(--danger); font-size: 0.9rem; }
.stack { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }

/* ---- Groups, sharing, login sheet ---- */

.form.flush { padding: 0; }
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.form .link { align-self: center; }

.splash {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 60vh;
}
.splash.small { min-height: 0; padding: 24px 0; }
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

.account-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.account-card .btn { margin-top: 6px; }

.segmented {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
.seg {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--muted);
  font-weight: 600;
}
.seg.active { background: var(--accent); color: var(--on-accent); }

.byline { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px; color: var(--muted); font-size: 0.85rem; }
.shared-mark { display: inline-flex; vertical-align: -2px; margin-left: 8px; color: var(--accent-text); }

.members { list-style: none; margin: 0; padding: 4px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.member { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.member:last-child { border-bottom: 0; }
.member-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.tag { padding: 2px 10px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); font-size: 0.78rem; font-weight: 600; }

.invite-code {
  padding: 18px 12px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent-text);
  font: 700 2rem/1.1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.14em;
  text-align: center;
  user-select: all;
}

.menu-row.switch .check-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  margin-left: auto;
  border: 2px solid var(--border);
  border-radius: 50%;
}
.menu-row:disabled { opacity: 0.6; cursor: default; }
.menu-row.switch.on .check-mark { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }

/* ---- Install bar (js/install-bar.js) ---- */

.install-bar {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--accent-soft);
  border-bottom: 1px solid var(--accent);
  animation: drop 0.3s ease-out;
}
.install-bar > div { display: flex; align-items: center; gap: 8px; max-width: var(--content-w); margin: 0 auto; padding: 3px 2px 3px 16px; min-height: 44px; }
.install-text { flex: 1; min-width: 0; font-size: 0.85rem; font-weight: 600; line-height: 1.25; }
.install-bar .btn.small { flex: none; min-height: 32px; padding: 0 12px; font-size: 0.85rem; }
.install-bar .icon-btn { flex: none; }

/* ---- Toast ---- */

#toast {
  position: fixed;
  left: 0;
  right: 0;
  margin: 0 auto;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 84px);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
  box-shadow: var(--shadow-pop);
}
#toast button { border: 0; background: none; color: var(--accent-text); font-weight: 700; padding: 6px 0; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@keyframes drop { from { transform: translateY(-100%); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .sheet, .sheet-panel, .install-bar { animation: none; }
}

/* ---- The cooking helper (chat) ---- */
.sheet-panel:has(.chat) { height: 100%; padding-bottom: 0; overflow: hidden; display: flex; flex-direction: column; }
@media (min-width: 700px) { .sheet-panel:has(.chat) { height: 94%; } }
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat .sheet-head { position: static; flex: none; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 10px; padding: 8px 16px 12px; }
.chat-msg { max-width: 92%; padding: 10px 14px; border-radius: 18px; overflow-wrap: anywhere; }
.chat-msg p { margin: 0; white-space: pre-wrap; }
.chat-msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 6px; }
.chat-msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 6px; display: flex; flex-direction: column; gap: 10px; }
.chat-msg.assistant.live p:only-child, .chat-msg.assistant.live p:first-child:empty { color: var(--muted); }
.chat-msg.error { align-self: stretch; max-width: none; background: transparent; border: 1px solid var(--danger); color: var(--danger); display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.chat-cards { display: flex; flex-direction: column; gap: 10px; }
.chat-cards:empty { display: none; }
.chat-card { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.chat-card h4 { margin: 0; font-size: 1.05rem; }
.chat-card p { margin: 0; }
.chat-card summary { cursor: pointer; color: var(--accent-text); font-size: 0.9rem; padding: 4px 0; }
.chat-ing, .chat-steps { margin: 6px 0 0; padding-left: 20px; }
.chat-ing { list-style: none; padding-left: 0; }
.chat-ing li.heading { font-weight: 700; margin-top: 6px; }
.chat-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.chat-empty { display: flex; flex-direction: column; gap: 14px; padding-top: 6px; }
.chat-hello { margin: 0; font-size: 1.05rem; }
.chat-empty .muted { margin: 0; }
.chat-composer { flex: none; padding: 8px 12px 10px; background: var(--bg); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.chat-composer .add-row { align-items: flex-end; }
.chat-input { resize: none; max-height: 130px; line-height: 1.35; }
.chat-options { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.chat-options:empty { display: none; }
.chat-chip { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 4px 6px 4px 12px; border: 1px solid var(--border); border-radius: 16px; font-size: 0.85rem; overflow: hidden; }
.chat-chip button { display: grid; place-items: center; width: 24px; height: 24px; border: 0; background: none; color: var(--muted); flex: none; }
.chat-mine { display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; }
.chat-mine input { width: 20px; height: 20px; accent-color: var(--accent); }
