/* Mediterranean Family — Meal Prep
 * Mobile-first. Warm Mediterranean palette: olive primary, terracotta accent, cream background.
 * All colours are CSS variables; dark mode via prefers-color-scheme. No external assets.
 */

:root {
  --bg: #fbf6ec;
  --surface: #fffdf8;
  --surface-2: #f5eee0;
  --surface-3: #ebe2cf;
  --input-bg: #ffffff;
  --text: #25231e;
  --muted: #5f594c;
  --border: #e3d8c2;
  --border-strong: #b9aa8c;

  --primary: #4f6428;
  --primary-hover: #435622;
  --on-primary: #ffffff;
  --primary-soft: #e7edd7;
  --primary-text: #3d4f1d;

  --accent: #b04e2e;
  --accent-soft: #f8e4da;
  --accent-text: #8f3c20;
  --on-accent: #ffffff;

  --header-bg: #4f6428;
  --header-text: #fbf6ec;

  --danger: #9e1a1a;
  --danger-strong: #b3261e;
  --danger-soft: #fde3df;
  --danger-border: #e79a90;
  --warn: #6b4a00;
  --warn-soft: #fff3d1;
  --warn-border: #e2b845;
  --ok: #2c6620;
  --ok-soft: #e1f0d9;
  --info: #22506e;
  --info-soft: #e0ecf5;

  --lvl-allergy-bg: #fde0dc; --lvl-allergy-fg: #8f1414; --lvl-allergy-bd: #e0877b;
  --lvl-intolerance-bg: #fde8cf; --lvl-intolerance-fg: #7f4000; --lvl-intolerance-bd: #e3a660;
  --lvl-avoid-bg: #ece2f7; --lvl-avoid-fg: #52267a; --lvl-avoid-bd: #b397d8;
  --lvl-dislike-bg: #ebe9e4; --lvl-dislike-fg: #45423b; --lvl-dislike-bd: #bdb7aa;
  --lvl-like-bg: #def0d6; --lvl-like-fg: #285618; --lvl-like-bd: #8fc27b;

  --focus: #0b5cad;
  --shadow: 0 1px 2px rgba(70, 55, 20, .07), 0 4px 14px rgba(70, 55, 20, .05);
  --radius: 16px;
  --radius-sm: 10px;
  --header-h: 56px;
  --tabbar-h: 62px;
  --sidenav-w: 212px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Times New Roman", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1915;
    --surface: #24231e;
    --surface-2: #2c2a24;
    --surface-3: #37352d;
    --input-bg: #1e1d19;
    --text: #f2ecdf;
    --muted: #c0b8a6;
    --border: #3f3c33;
    --border-strong: #6c6656;

    --primary: #a3bb6c;
    --primary-hover: #b6cc82;
    --on-primary: #151a0b;
    --primary-soft: #2e3721;
    --primary-text: #bcd38c;

    --accent: #e39373;
    --accent-soft: #422a20;
    --accent-text: #f0a88a;
    --on-accent: #1e0f08;

    --header-bg: #27301b;
    --header-text: #f2ecdf;

    --danger: #ffaaa0;
    --danger-strong: #e0564a;
    --danger-soft: #45211d;
    --danger-border: #8e3a31;
    --warn: #f3d27c;
    --warn-soft: #3a3019;
    --warn-border: #8a6d22;
    --ok: #a8d895;
    --ok-soft: #22341c;
    --info: #9fcbea;
    --info-soft: #1d2d38;

    --lvl-allergy-bg: #4a1f1b; --lvl-allergy-fg: #ffb3a9; --lvl-allergy-bd: #9c4136;
    --lvl-intolerance-bg: #43301a; --lvl-intolerance-fg: #ffc98a; --lvl-intolerance-bd: #93642a;
    --lvl-avoid-bg: #33263f; --lvl-avoid-fg: #d9bdf5; --lvl-avoid-bd: #6f4f93;
    --lvl-dislike-bg: #33312c; --lvl-dislike-fg: #d9d4c8; --lvl-dislike-bd: #676256;
    --lvl-like-bg: #243420; --lvl-like-fg: #b4e0a2; --lvl-like-bd: #4f7c42;

    --focus: #8ec5ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); scroll-padding-bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom, 0px)); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
a { color: var(--primary-text); text-underline-offset: 3px; }
img { max-width: 100%; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: .92em; background: var(--surface-3); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
ul, ol { padding-left: 1.3em; }
small, .small { font-size: .88rem; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
#view:focus, h1:focus, h2:focus, h3:focus { outline: none; }
#view:focus-visible { outline: none; }

.skip-link {
  position: absolute; left: 8px; top: -80px; z-index: 200;
  background: var(--surface); color: var(--text); padding: 12px 16px; border-radius: 10px;
  font-weight: 700; box-shadow: var(--shadow);
}
.skip-link:focus { top: 8px; }

/* ---------- busy bar ---------- */
#busybar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 300;
  background: linear-gradient(90deg, transparent, var(--accent), var(--primary), transparent);
  background-size: 50% 100%; background-repeat: no-repeat;
  opacity: 0; transition: opacity .2s ease;
  pointer-events: none;
}
html.is-busy #busybar { opacity: 1; transition-delay: .15s; animation: busy 1.1s linear infinite; }
@keyframes busy { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  min-height: var(--header-h);
  display: flex; align-items: center; gap: 12px;
  padding: env(safe-area-inset-top, 0px) 16px 0;
  background: var(--header-bg); color: var(--header-text);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; min-height: 44px; }
.brand img { border-radius: 8px; flex: none; }
.brand-text { font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; line-height: 1.2; }
.brand-sub { font-weight: 400; opacity: .92; }
@media (max-width: 380px) { .brand-sep, .brand-sub { display: none; } }

/* ---------- offline banner ---------- */
.offline-banner {
  position: sticky; top: var(--header-h); z-index: 35;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; background: var(--warn-soft); color: var(--text);
  border-bottom: 2px solid var(--warn-border); font-size: .95rem;
}

/* ---------- navigation: bottom tabs on phones ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(7, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, .06);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tabbar-h); min-width: 44px; padding: 4px 0;
  color: var(--muted); text-decoration: none; font-size: .66rem; font-weight: 700; letter-spacing: .01em;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--primary-text); }
.tabbar a[aria-current="page"] svg { background: var(--primary-soft); border-radius: 999px; padding: 2px 10px; width: 44px; height: 28px; }
.tabbar a:focus-visible { outline-offset: -3px; }

main#view {
  display: block;
  max-width: 1120px; margin: 0 auto;
  padding: 16px 16px 32px;
  min-height: 60vh;
}

@media (min-width: 900px) {
  html { scroll-padding-bottom: 16px; }
  body { padding-bottom: 0; padding-left: var(--sidenav-w); }
  .app-header { margin-left: calc(-1 * var(--sidenav-w)); }
  .tabbar {
    top: var(--header-h); right: auto; width: var(--sidenav-w);
    display: flex; flex-direction: column; gap: 4px;
    padding: 16px 12px; border-top: 0; border-right: 1px solid var(--border); box-shadow: none;
  }
  .tabbar a {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    min-height: 48px; padding: 0 14px; border-radius: 12px; font-size: 1rem; font-weight: 600;
    color: var(--text);
  }
  .tabbar a:hover { background: var(--surface-2); }
  .tabbar a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-text); font-weight: 800; }
  .tabbar a[aria-current="page"] svg { background: none; padding: 0; width: 24px; height: 24px; }
  main#view { padding: 24px 32px 48px; }
  h1 { font-size: 2rem; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 16px;
  font: inherit; font-weight: 650; font-size: .98rem; line-height: 1.2; text-align: center; text-decoration: none;
  color: var(--text); background: var(--surface);
  border: 1.5px solid var(--border-strong); border-radius: 12px;
  cursor: pointer; user-select: none;
  transition: background-color .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-accent:hover { filter: brightness(.95); background: var(--accent); }
.btn-danger { background: var(--danger-strong); color: #fff; border-color: var(--danger-strong); }
.btn-danger:hover { filter: brightness(.94); background: var(--danger-strong); }
.btn-ghost-danger { color: var(--danger); border-color: var(--danger-border); background: transparent; }
.btn-ghost-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.btn-lg { min-height: 52px; padding: 10px 22px; font-size: 1.05rem; }
.btn-xl { display: flex; width: 100%; min-height: 58px; font-size: 1.12rem; font-weight: 800; border-radius: 14px; }
.btn .ext { font-size: .9em; opacity: .85; }
.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; left: calc(50% - 9px); top: calc(50% - 9px);
  border: 2.5px solid var(--text); border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
}
.btn-primary.is-loading::after, .btn-danger.is-loading::after, .btn-accent.is-loading::after { border-color: var(--on-primary); border-right-color: transparent; }

.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 12px; background: transparent; color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }

.linkbtn {
  display: inline; padding: 0; min-height: 0; border: 0; background: none; font: inherit;
  color: var(--primary-text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

.recipe-link {
  display: block; width: 100%; min-height: 44px; padding: 8px 0;
  border: 0; background: none; font: inherit; font-weight: 700; font-size: 1.06rem; line-height: 1.3;
  color: var(--text); text-align: left; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--border-strong); text-decoration-thickness: 2px; text-underline-offset: 4px;
}
.recipe-link:hover { text-decoration-color: var(--accent); }
.recipe-link.inline { display: inline; width: auto; min-height: 0; padding: 10px 0; font-size: inherit; }

.spinner {
  display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -.2em;
  border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 32px 16px; color: var(--muted); font-weight: 600; }
.loading.inline { justify-content: flex-start; padding: 12px 0; }

/* ---------- layout pieces ---------- */
.view-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.view-head h1 { margin: 0; }
.view-sub { margin: -8px 0 16px; color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin: 0 0 16px; box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card h2 { font-family: var(--font-display); }
@media (min-width: 600px) { .card { padding: 20px; } }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); align-items: start; }
.grid > .card { margin: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section-h { font-family: var(--font-display); font-size: 1.3rem; margin: 24px 0 12px; }

.callout { border-radius: 12px; padding: 12px 16px; border: 1px solid var(--border); margin: 0 0 16px; background: var(--surface-2); }
.callout > :last-child { margin-bottom: 0; }
.callout ul { margin: 0; padding-left: 1.2em; }
.callout-h { font-size: 1rem; margin: 0 0 6px; font-family: var(--font); font-weight: 800; }
.callout.warn { background: var(--warn-soft); border-color: var(--warn-border); }
.callout.warn .callout-h { color: var(--warn); }
.callout.error { background: var(--danger-soft); border-color: var(--danger-border); }
.callout.error .callout-h { color: var(--danger); }
.callout.info { background: var(--info-soft); border-color: transparent; }
.callout.ok { background: var(--ok-soft); border-color: transparent; }

.label-note {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: .9rem; font-weight: 600; margin: 0 0 16px;
  background: var(--warn-soft); border-left: 4px solid var(--warn-border); padding: 8px 12px; border-radius: 8px;
}
.label-note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; fill: none; stroke: var(--warn); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.onboarding { border: 2px solid var(--primary); background: var(--primary-soft); }
.onboarding h2 { font-size: 1.4rem; }
.onboarding ol { margin: 0 0 16px; }
.onboarding li { margin-bottom: 4px; }

.empty { text-align: center; padding: 32px 16px; }
.empty p { color: var(--muted); }

/* ---------- forms ---------- */
.form .field, .field { margin: 0 0 16px; }
.field > label, .field-label { display: block; font-weight: 700; margin-bottom: 6px; }
fieldset { border: 0; padding: 0; margin: 0 0 16px; min-width: 0; }
legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
.hint { font-size: .9rem; color: var(--muted); margin: 6px 0 0; }
input[type="text"], input[type="search"], input[type="number"], input[type="date"], input[type="password"], input[type="email"],
input[type="url"], input:not([type]), select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  font: inherit; font-size: 1rem; color: var(--text); background: var(--input-bg);
  border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
}
textarea { min-height: 80px; resize: vertical; }
select { appearance: auto; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
input:user-invalid, select:user-invalid { border-color: var(--danger-strong); }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--primary); cursor: pointer; }

.field-row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.field-row > .field { margin-bottom: 16px; }
@media (max-width: 420px) { .field-row.stack-sm { grid-template-columns: 1fr; } }

.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.form-actions .btn-primary { min-width: 140px; }

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; font-weight: 500; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0 12px; }
.check.toggle { align-items: flex-start; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 12px; }
.check.toggle input { margin-top: 1px; }
.check.toggle:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.check.toggle small { display: block; color: var(--muted); }

.radio-card {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; margin-bottom: 8px;
  border: 2px solid var(--border); border-radius: 12px; cursor: pointer; background: var(--surface);
}
.radio-card input { margin-top: 2px; }
.radio-card strong { display: block; }
.radio-card small { display: block; color: var(--muted); line-height: 1.4; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

/* segmented pill radios / toggle chips */
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg-opt { position: relative; display: inline-flex; }
.seg-opt input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.seg-opt span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 6px 14px; line-height: 1.25;
  border: 2px solid var(--border-strong); border-radius: 999px; font-weight: 700; background: var(--surface);
}
.seg-opt input:checked + span { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.seg-opt.lvl-allergy input:checked + span { background: var(--lvl-allergy-fg); border-color: var(--lvl-allergy-fg); color: var(--lvl-allergy-bg); }
.seg-opt.lvl-intolerance input:checked + span { background: var(--lvl-intolerance-fg); border-color: var(--lvl-intolerance-fg); color: var(--lvl-intolerance-bg); }
.seg-opt.lvl-avoid input:checked + span { background: var(--lvl-avoid-fg); border-color: var(--lvl-avoid-fg); color: var(--lvl-avoid-bg); }
.seg-opt.lvl-dislike input:checked + span { background: var(--lvl-dislike-fg); border-color: var(--lvl-dislike-fg); color: var(--lvl-dislike-bg); }
.seg-opt.lvl-like input:checked + span { background: var(--lvl-like-fg); border-color: var(--lvl-like-fg); color: var(--lvl-like-bg); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip-row.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.chip-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; min-width: 44px; max-width: 100%; padding: 6px 14px; flex: 0 1 auto;
  font: inherit; font-weight: 700; font-size: .95rem; line-height: 1.25; color: var(--text); text-align: left; overflow-wrap: anywhere;
  background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: 999px; cursor: pointer;
}
.chip-btn:hover { background: var(--surface-2); }
.chip-row.scroll .chip-btn { flex: none; }
.chip-btn[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip-btn:disabled { cursor: default; opacity: 1; }
.chip-btn.is-set { border-style: solid; }

/* ---------- chips & badges (display only) ---------- */
.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  padding: 3px 10px; border-radius: 999px; font-size: .86rem; font-weight: 700; line-height: 1.35;
  border: 1.5px solid var(--border-strong); background: var(--surface-2); color: var(--text);
}
.chip .kind { font-weight: 500; opacity: .85; }
.chip.removable { padding-right: 0; min-height: 44px; }
.chip-x {
  display: inline-grid; place-items: center; width: 40px; height: 40px; margin-left: 2px;
  border: 0; border-radius: 999px; background: transparent; color: inherit; font-size: 1.3rem; line-height: 1; cursor: pointer;
}
.chip-x:hover { background: rgba(0, 0, 0, .08); }
.lvl-allergy { background: var(--lvl-allergy-bg); color: var(--lvl-allergy-fg); border-color: var(--lvl-allergy-bd); }
.lvl-intolerance { background: var(--lvl-intolerance-bg); color: var(--lvl-intolerance-fg); border-color: var(--lvl-intolerance-bd); }
.lvl-avoid { background: var(--lvl-avoid-bg); color: var(--lvl-avoid-fg); border-color: var(--lvl-avoid-bd); }
.lvl-dislike { background: var(--lvl-dislike-bg); color: var(--lvl-dislike-fg); border-color: var(--lvl-dislike-bd); }
.lvl-like { background: var(--lvl-like-bg); color: var(--lvl-like-fg); border-color: var(--lvl-like-bd); }
.seg-opt.lvl-allergy, .seg-opt.lvl-intolerance, .seg-opt.lvl-avoid, .seg-opt.lvl-dislike, .seg-opt.lvl-like { background: none; }

.allergens { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.allergens .chip { display: inline-block; }
.chip-allergen { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.chip-may { background: var(--warn-soft); color: var(--warn); border: 1.5px dashed var(--warn-border); }
.chip-k { font-weight: 900; }
.allergens.big .chip { font-size: .98rem; padding: 6px 12px; }
.chip-opt { background: var(--surface-2); color: var(--text); border: 1.5px dotted var(--border-strong); }
.line-alg, .line-may { display: block; font-size: .8rem; font-weight: 700; }
.line-alg { color: var(--danger); }
.line-may { color: var(--warn); }
.gnotes { margin: 4px 0 0; padding-left: 1.1em; font-size: .88rem; font-weight: 600; color: var(--info); }
.b-auto { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
.kc-line.auto { background: linear-gradient(90deg, var(--warn-soft), transparent 70%); }
.family-alert { flex-basis: 100%; font-size: .88rem; font-weight: 700; color: var(--danger); margin: 0; }

.badges { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px;
  font-size: .76rem; font-weight: 800; letter-spacing: .02em; line-height: 1.5;
  background: var(--surface-3); color: var(--text); max-width: 100%; overflow-wrap: anywhere;
}
.badge svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.diet-mediterranean { background: var(--primary-soft); color: var(--primary-text); }
.diet-keto_mediterranean { background: var(--accent-soft); color: var(--accent-text); }
.diet-low_carb_mediterranean { background: var(--info-soft); color: var(--info); }
.b-encore { background: var(--primary-soft); color: var(--primary-text); border: 1px solid var(--primary); }
.b-lock { background: var(--surface-3); color: var(--text); }
.b-freeze { background: var(--info-soft); color: var(--info); }
.b-fridge { background: var(--primary-soft); color: var(--primary-text); }
.b-fresh { background: var(--ok-soft); color: var(--ok); }
.b-prep { background: var(--primary-soft); color: var(--primary-text); }
.b-side { background: var(--accent-soft); color: var(--accent-text); }
.b-over { background: var(--danger-strong); color: #fff; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-staple { background: var(--surface-3); color: var(--muted); }
.b-today { background: var(--accent); color: var(--on-accent); }
.b-inactive { background: var(--surface-3); color: var(--muted); }

/* ---------- family ---------- */
.member-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }
.member-name { margin: 0; font-size: 1.3rem; font-family: var(--font-display); overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px 16px; margin: 12px 0; }
.facts dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 800; }
.facts dd { margin: 0; font-weight: 600; }
.rgroups { margin: 8px 0 12px; }
.rgroup { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 8px; }
.rlevel { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 900; min-width: 92px; }
.rlevel.lvl-allergy, .rlevel.lvl-intolerance, .rlevel.lvl-avoid, .rlevel.lvl-dislike, .rlevel.lvl-like { background: none; border: 0; }
.member-notes { font-style: italic; color: var(--muted); }
.member-form { border: 2px solid var(--primary); }
.restr-editor { border-top: 1px dashed var(--border-strong); padding-top: 16px; margin-top: 8px; }
.restr-editor h3 { font-family: var(--font-display); font-size: 1.15rem; }
.pick-area { margin-top: 8px; }
.pick-area .chip-btn { font-weight: 600; }
.pick-area .chip-btn.is-set { background: var(--surface-3); color: var(--muted); }

/* typeahead */
.ta-list { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; max-height: 320px; overflow-y: auto; }
.ta-list li + li { border-top: 1px solid var(--border); }
.ta-opt {
  display: block; width: 100%; min-height: 48px; padding: 10px 14px; text-align: left;
  font: inherit; color: var(--text); background: var(--surface); border: 0; cursor: pointer;
}
.ta-opt:hover, .ta-opt:focus-visible { background: var(--primary-soft); }
.ta-opt .mini { display: block; font-size: .84rem; color: var(--muted); }
.ta-opt .mini-allergen { color: var(--danger); font-weight: 700; }

/* ---------- plan ---------- */
.plan-picker { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.plan-picker label { font-weight: 700; font-size: .85rem; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.plan-picker select { min-width: 220px; max-width: 100%; }
@media (max-width: 599px) {
  .view-head .plan-picker { width: 100%; }
  .plan-picker label { flex: 1 1 100%; }
  .plan-picker select { min-width: 0; width: 100%; }
}
.plan-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 24px; }
.plan-head h2 { margin-bottom: 4px; font-size: 1.4rem; }
.plan-head .actions { align-items: flex-start; }
.plan-settings { font-size: .9rem; color: var(--muted); margin: 0; }
.day-jump { margin: 0 0 12px; }
.day-jump .chip-btn { font-size: .85rem; padding: 0 12px; }
.days { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); align-items: start; }
.day { margin: 0; padding: 0; overflow: hidden; }
.day-h {
  display: flex; align-items: baseline; gap: 8px; margin: 0; padding: 12px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); font-family: var(--font-display); font-size: 1.12rem;
}
.day-h .dow { font-weight: 800; }
.day.is-today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.meals { list-style: none; margin: 0; padding: 0 16px; }
.meal { padding: 12px 0 14px; border-top: 1px solid var(--border); }
.meal:first-child { border-top: 0; }
.meal-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.mtype { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 900; color: var(--accent-text); }
.meal-meta { font-size: .9rem; color: var(--muted); margin: 0 0 6px; }
.meal .side { font-size: .95rem; margin: 0 0 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.meal .side .recipe-link { width: auto; display: inline; min-height: 0; padding: 10px 0; font-size: .98rem; }
.meal .side .omit, .meal .side > .muted { flex-basis: 100%; }
.omit { font-size: .88rem; margin: 0 0 6px; padding: 4px 8px; border-radius: 8px; background: var(--warn-soft); color: var(--text); }
.meal-notes { font-size: .88rem; color: var(--muted); margin: 0 0 8px; padding-left: 1.1em; }
.meal-actions { display: flex; gap: 8px; margin-top: 6px; }
.meal.is-locked { background: linear-gradient(90deg, var(--surface-2), transparent); margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.meal.flash { animation: flash 1.4s ease; }
@keyframes flash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }

.nut-wrap { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); align-items: start; }
.nut { margin: 0; padding: 0; overflow: hidden; }
.nut > summary {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 16px; min-height: 48px;
  cursor: pointer; list-style: none; font-weight: 700;
}
.nut > summary::-webkit-details-marker { display: none; }
.nut > summary::before { content: "▸"; color: var(--muted); transition: transform .15s ease; }
.nut[open] > summary::before { transform: rotate(90deg); }
.nut .table-wrap { padding: 0 8px 8px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 8px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: top; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; }
tbody th { font-weight: 600; white-space: nowrap; }
td.nc { font-weight: 800; }
td.nc.keto { font-size: 1.02rem; }
tr.over td.nc { background: var(--danger-soft); color: var(--danger); }
.over-flag { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 900; }

/* ---------- groceries ---------- */
.plan-sub { color: var(--muted); margin: -8px 0 12px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 2px solid var(--border); margin: 0 0 12px; }
.tab {
  flex: none; min-height: 48px; padding: 0 16px; margin-bottom: -2px;
  font: inherit; font-weight: 800; color: var(--muted); background: none; cursor: pointer;
  border: 0; border-bottom: 3px solid transparent;
}
.tab[aria-selected="true"] { color: var(--primary-text); border-bottom-color: var(--primary); }
.trip-h { font-family: var(--font-display); margin: 0; }
.progress-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.progress-row p { margin: 0; font-weight: 700; color: var(--muted); }
.aisle { margin: 0 0 20px; }
.aisle-h {
  display: flex; align-items: baseline; gap: 8px;
  font-size: .9rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 900; color: var(--accent-text);
  border-bottom: 2px solid var(--accent); padding-bottom: 4px; margin: 0 0 4px;
}
.aisle-h .count { font-weight: 700; color: var(--muted); letter-spacing: 0; }
.gitems { list-style: none; margin: 0; padding: 0; }
.gitem { padding: 8px 0 10px; border-bottom: 1px solid var(--border); }
.gcheck { display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding-top: 8px; cursor: pointer; }
.gcheck input { width: 26px; height: 26px; margin-top: -1px; }
.gmain { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; flex: 1; min-width: 0; }
.gname { font-weight: 700; font-size: 1.04rem; }
.gbuy { font-weight: 800; color: var(--primary-text); white-space: nowrap; }
.gdetail { padding-left: 38px; }
.gpk { margin: 2px 0 0; font-weight: 600; }
.gsub { margin: 2px 0 0; font-size: .86rem; color: var(--muted); }
.gitem.is-checked .gname, .gitem.is-checked .gbuy { text-decoration: line-through; opacity: .55; }
.gitem.is-checked .gdetail { opacity: .6; }
.gactions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.gactions .btn { font-size: .88rem; }
.gmore > summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; font-size: .88rem; font-weight: 700; color: var(--primary-text); }
.gmore[open] { flex-basis: 100%; }
.gmore ul { margin: 0 0 8px; font-size: .9rem; }
.gmore .links { display: flex; flex-wrap: wrap; gap: 8px; }
.gmore-sum { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; list-style: none; }
.gmore-sum::-webkit-details-marker { display: none; }
.gmore-sum::before { content: "▸"; color: var(--muted); }
details[open] > .gmore-sum::before { content: "▾"; }
.pantry-check li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; border-bottom: 1px solid var(--border); padding: 2px 0; }
.pantry-check ul { list-style: none; padding: 0; margin: 0 0 12px; }

.store-seg { margin-bottom: 16px; }
.kstep-list { list-style: none; margin: 0; padding: 0; counter-reset: kstep; }
.kstep { position: relative; padding: 0 0 20px 46px; counter-increment: kstep; }
.kstep::before {
  content: counter(kstep); position: absolute; left: 0; top: -2px;
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; background: var(--surface-3); color: var(--text);
}
.kstep.done::before { content: "✓"; background: var(--ok); color: var(--surface); }
.kstep.current::before { background: var(--primary); color: var(--on-primary); }
.kstep.locked { opacity: .6; }
.kstep h3 { font-size: 1.05rem; margin: 2px 0 6px; font-family: var(--font); font-weight: 800; }
.kstep ol { padding-left: 1.2em; }
.kstep ol li { margin-bottom: 8px; }
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.loc-list, .kc-lines, .wm-list, .prod-list, .alt-list, .pantry-list { list-style: none; margin: 0 0 12px; padding: 0; }
.loc, .kc-line, .alt, .pantry-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.loc > div, .kc-line > div, .alt > div:first-child, .pantry-row > div:first-child { flex: 1 1 220px; min-width: 0; }
.kc-line.unmapped .kc-prod { color: var(--warn); font-weight: 700; }
.kc-prod { display: flex; align-items: center; gap: 10px; font-size: .92rem; margin-top: 4px; }
.kc-prod img { width: 44px; height: 44px; object-fit: contain; background: #fff; border-radius: 8px; flex: none; }
.kc-qty { font-weight: 800; white-space: nowrap; }
.result-box { border-radius: 14px; padding: 16px; margin: 0 0 16px; background: var(--ok-soft); }
.result-box h3 { color: var(--ok); }
.wm-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.wm-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 8px; }
.prod { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.prod img, .prod .noimg { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 10px; }
.prod .noimg { background: var(--surface-3); }
.prod .price { font-weight: 800; }
@media (max-width: 480px) {
  .prod { grid-template-columns: 56px 1fr; }
  .prod img, .prod .noimg { width: 56px; height: 56px; }
  .prod .btn { grid-column: 1 / -1; }
}
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-bottom: 12px; }
.inline-form .field { flex: 1 1 200px; margin: 0; }

/* ---------- prep ---------- */
.session h2 { margin-bottom: 2px; }
.session .sess-meta { color: var(--muted); font-weight: 600; }
.prep-recipes, .mise { list-style: none; margin: 0 0 16px; padding: 0; }
.prep-recipe { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.prep-recipe > input { margin-top: 12px; width: 24px; height: 24px; }
.prep-recipe .body { flex: 1; min-width: 0; }
.prep-recipe .recipe-link { min-height: 44px; }
.prep-recipe p { margin: 0 0 4px; font-size: .9rem; }
.mise li { border-bottom: 1px solid var(--border); }
.mise .check { font-weight: 500; }
.mise .amt, .lines .amt { font-weight: 800; white-space: nowrap; }
.mise .check.done span { text-decoration: line-through; opacity: .6; }
.fresh-day { margin: 0 0 12px; }
.fresh-day h3 { font-size: 1rem; margin: 0 0 4px; }
.fresh-day ul { margin: 0; }

/* ---------- recipes ---------- */
.filters { margin-bottom: 16px; }
.filters .field { margin-bottom: 12px; }
.recipe-card h2 { font-size: 1.12rem; margin: 0; font-family: var(--font); }
.recipe-card .recipe-link { font-size: 1.1rem; padding-top: 0; }
.rc-meta { font-size: .9rem; color: var(--muted); margin: 0 0 8px; }
.rc-nut { font-size: .95rem; margin: 8px 0; }
.rc-nut strong { color: var(--accent-text); }
.fit-line { font-size: .9rem; margin: 6px 0 0; padding: 6px 10px; border-radius: 8px; }
.fit-line.bad { background: var(--danger-soft); color: var(--danger); font-weight: 700; }
.fit-line.good { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.fit-line ul { margin: 2px 0 0; padding-left: 1.1em; font-weight: 600; }
.results-count { color: var(--muted); font-weight: 700; margin: 0 0 8px; }

.rd-meta { color: var(--muted); font-size: .92rem; }
.servings-step { display: flex; flex-direction: column; gap: 6px; margin: 12px 0 16px; padding: 12px; background: var(--surface-2); border-radius: 12px; }
.servings-step .cur { font-weight: 800; }
.servings-step .chip-btn { min-width: 44px; padding: 0 10px; }
.lines { list-style: none; padding: 0; margin: 0 0 16px; }
.lines li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; flex-wrap: wrap; }
.lines .amt { min-width: 92px; }
.steps li { margin-bottom: 8px; }
.source { font-size: .88rem; color: var(--muted); }

/* ---------- pantry ---------- */
.pantry-row .amt { font-weight: 800; }
.pantry-row .actions .btn { min-width: 72px; }
.selected-ing { padding: 10px 12px; border-radius: 10px; background: var(--primary-soft); font-weight: 600; margin: 0 0 12px; }

/* ---------- settings / help ---------- */
.help h3 { margin-top: 16px; font-family: var(--font); font-weight: 800; }
.help dl dt { font-weight: 800; margin-top: 8px; }
.help dl dd { margin: 0 0 4px; }
.store-row { padding: 8px 0; border-bottom: 1px solid var(--border); }

/* ---------- toasts ---------- */
.toasts {
  /* Bottom, above the tab bar: never covers the header, the offline banner or the page title. */
  position: fixed; z-index: 500; left: 50%; bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%); width: min(560px, calc(100% - 24px));
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
@media (min-width: 900px) {
  .toasts { left: auto; right: 24px; bottom: 24px; transform: none; width: min(460px, calc(100% - var(--sidenav-w) - 48px)); }
}
dialog .toasts { bottom: 16px; }
.toast {
  display: flex; align-items: flex-start; gap: 6px; pointer-events: auto;
  padding: 10px 6px 10px 14px; border-radius: 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 6px solid var(--primary);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22);
  animation: toast-in .18s ease-out;
}
.toast-msg { flex: 1; padding-top: 2px; overflow-wrap: anywhere; }
.toast-msg ul { margin: 4px 0 0; padding-left: 1.1em; font-size: .92rem; }
.toast-error { border-left-color: var(--danger-strong); background: var(--danger-soft); }
.toast-error .toast-title { color: var(--danger); }
.toast-success { border-left-color: var(--ok); }
.toast-title { font-weight: 900; display: block; }
.toast .icon-btn { width: 40px; height: 40px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- modal ---------- */
/* Hidden until opened even where the browser does not know <dialog> (see shimDialogs in app.js). */
dialog:not([open]) { display: none; }
html.no-dialog dialog[open] {
  display: block; position: fixed; top: 0; right: 0; bottom: 0; left: 0; margin: auto; z-index: 1000;
  height: fit-content; box-shadow: 0 0 0 100vmax rgba(22, 19, 10, .58), 0 24px 70px rgba(0, 0, 0, .4);
}
dialog.modal {
  padding: 0; border: 0; border-radius: 18px;
  width: min(760px, calc(100% - 24px)); max-width: none; max-height: calc(100% - 32px);
  background: var(--surface); color: var(--text);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .4);
}
dialog.modal::backdrop { background: rgba(22, 19, 10, .58); }
dialog.modal[open] { animation: modal-in .16s ease-out; }
@keyframes modal-in { from { opacity: 0; } to { opacity: 1; } }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); margin: 0; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--border); flex: none;
}
.modal-head h2 { margin: 0; font-family: var(--font-display); font-size: 1.25rem; overflow-wrap: anywhere; }
.modal-body { padding: 16px 20px 24px; overflow-y: auto; overscroll-behavior: contain; }
.modal-confirm { width: min(460px, calc(100% - 24px)); }
.modal-confirm #confirm-msg { white-space: pre-line; font-size: 1.02rem; }
.modal-confirm .form-actions { justify-content: flex-end; margin-top: 16px; }
.copy-area { width: 100%; min-height: 260px; font-family: ui-monospace, Consolas, Menlo, monospace; font-size: .9rem; }
@media (max-width: 600px) {
  dialog.modal:not(.modal-confirm) {
    width: 100%; max-height: 94%; margin: auto 0 0; border-radius: 18px 18px 0 0;
  }
  dialog.modal:not(.modal-confirm) .modal-inner { max-height: 94vh; max-height: 94dvh; }
  .modal-body { padding: 14px 16px calc(24px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important;
  }
  html.is-busy #busybar { animation: none; background: var(--accent); }
}

/* ---------- a planned dish that stopped being safe (MF-003, derived on every read) ---------- */
.meal.is-unsafe { outline: 3px solid var(--danger); outline-offset: -3px; }
.callout.unsafe { margin: .4rem 0; }

/* ---------- cook sheets (prep guide) ---------- */
.cook-sheet { margin-top: .5rem; border-top: 1px dashed var(--line, #d9d2c3); padding-top: .4rem; }
.cook-sheet > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.cs-lines { list-style: none; padding: 0; margin: .4rem 0; }
.cs-lines li { padding: .15rem 0; }
.cs-lines .amt { font-weight: 700; margin-right: .25rem; }
.cs-steps { padding-left: 1.3rem; margin: .5rem 0; }
.cs-steps li { margin: .3rem 0; line-height: 1.45; }

/* ---------- print: clean black-on-white checklists ---------- */
.print-only { display: none; }
@media print {
  @page { margin: 12mm; }
  :root { color-scheme: light; }
  html, body { background: #fff !important; color: #000 !important; }
  body { padding: 0 !important; font-size: 11pt; line-height: 1.35; }
  .app-header, .tabbar, .toasts, #busybar, .offline-banner, .skip-link, dialog,
  .no-print, .plan-picker, .toolbar, .gactions, .meal-actions, .tabs, form, .btn, .icon-btn, .chip-x { display: none !important; }
  .print-only { display: block !important; }
  main#view { max-width: none; margin: 0; padding: 0; }
  h1 { font-size: 18pt; }
  .card { border: 0 !important; box-shadow: none !important; background: none !important; padding: 0 !important; margin: 0 0 10pt !important; }
  .callout, .label-note { background: none !important; border: 1px solid #000 !important; color: #000 !important; }
  .chip, .badge, .chip-allergen, .chip-may { background: none !important; color: #000 !important; border: 1px solid #000 !important; }
  .allergens.big .chip, .chip { font-size: 9pt; padding: 0 5pt; }
  a { color: #000 !important; text-decoration: none; }
  .muted, .gsub, .hint { color: #333 !important; }
  .recipe-link { display: inline !important; min-height: 0; padding: 0; text-decoration: none; color: #000 !important; }
  .aisle, .session, .fresh-day, .prep-recipe {
    break-inside: avoid; page-break-inside: avoid;
  }
  .aisle { border: 1px solid #000 !important; padding: 6pt 8pt !important; margin: 0 0 8pt !important; }
  .aisle-h { color: #000 !important; border-bottom: 1px solid #000; }
  .gitem { padding: 3pt 0; border-bottom: 1px solid #bbb; break-inside: avoid; }
  .gitem:last-child { border-bottom: 0; }
  .gcheck { min-height: 0; padding-top: 0; gap: 8pt; }
  .gdetail { padding-left: 20pt; }
  .gitem.is-checked .gname, .gitem.is-checked .gbuy, .gitem.is-checked .gdetail { opacity: 1; }
  .gbuy { color: #000 !important; }
  input[type="checkbox"] {
    -webkit-appearance: none; appearance: none; width: 12pt !important; height: 12pt !important;
    border: 1.5pt solid #000; border-radius: 2pt; background: #fff; flex: none;
  }
  input[type="checkbox"]:checked { background: #000; }
  details.gmore, .gmore, .for-list { display: none !important; }
  details:not(.gmore) > *:not(summary) { display: block; }
  .session { border: 1px solid #000 !important; padding: 8pt !important; }
  .mise li, .prep-recipe { border-bottom: 1px solid #bbb; }
  .prep-recipe:has(details.cook-sheet[open]) { break-inside: auto; page-break-inside: auto; }
  .cook-sheet { border-top: 1px dashed #000; }
  .cook-sheet > summary { min-height: 0; }
  .cs-steps li { margin: 1pt 0; }
  .check { min-height: 0; padding: 2pt 0; }
  table { font-size: 9pt; }
  .nut-wrap, .days { display: block; }
  .day { break-inside: avoid; border: 1px solid #000 !important; margin-bottom: 8pt !important; }
  .day-h { background: none !important; }
  .meal.is-locked { background: none; }
}

/* ---------- recipe editor (the family's own recipes, MF-010) ---------- */
.b-family { background: var(--accent); color: var(--on-accent); }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--border); }
.card-actions .hint { flex-basis: 100%; margin: 0; }
.ed-form { max-width: 820px; }
.ed-grid { display: grid; gap: 0 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px) { .ed-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.ed-grid .field > label { min-height: 2.6em; display: flex; align-items: flex-end; }
.ed-list { list-style: none; margin: 0 0 12px; padding: 0; counter-reset: none; }
.ed-line, .ed-step {
  border: 1.5px solid var(--border); border-radius: 14px; padding: 10px 12px 12px; margin: 0 0 12px;
  background: var(--surface-2);
}
.ed-line .field { margin-bottom: 10px; }
.ed-line .field-row > .field { margin-bottom: 10px; }
.ed-item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.ed-num {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary); font-weight: 900; flex: none;
}
.ed-step-label { font-weight: 800; }
.ed-move { display: flex; gap: 4px; }
.ed-move .icon-btn { border: 1.5px solid var(--border-strong); background: var(--surface); font: inherit; font-size: 1.15rem; font-weight: 900; }
.ed-move .icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.icon-danger { color: var(--danger); border-color: var(--danger-border); }
.ok-mark { color: var(--ok); font-weight: 800; }
.warn-mark { color: var(--warn); font-weight: 800; }
.line-may-inline { color: var(--warn); font-weight: 700; }
.ed-step textarea { min-height: 76px; }
.ed-actions {
  position: sticky; bottom: calc(var(--tabbar-h) + 8px + env(safe-area-inset-bottom, 0px)); z-index: 5;
  background: var(--surface); padding: 12px; margin: 16px -12px -12px; border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 -6px 16px rgba(0, 0, 0, .06);
}
@media (min-width: 900px) { .ed-actions { bottom: 0; } }
.callout.blocked { border-width: 2px; }
.callout.blocked li { margin-bottom: 6px; }
.callout.blocked li .btn { margin-left: 6px; }
@media print { .ed-actions, .card-actions { display: none !important; } }

/* ---------- carb ranges (MF-011), health goals (MF-012), daily targets (MF-013) ---------- */
.req { color: var(--danger); font-weight: 800; }
.carb-range .field-row > .field { margin-bottom: 8px; }
.targets-line { font-size: .92rem; margin: 4px 0 8px; }
.goals-note { margin-top: 16px; }
.goals { border-top: 1px dashed var(--border-strong); padding-top: 16px; margin-top: 8px; }
.goals h3 { font-family: var(--font-display); font-size: 1.15rem; }
.goal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
.goal { border: 1.5px solid var(--border); border-radius: 14px; padding: 10px 12px; background: var(--surface-2); }
.goal-btn { width: 100%; justify-content: flex-start; text-align: left; }
.goal-btn.is-applied, .goal-btn[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-text); opacity: 1; }
.goal-why { margin: 8px 0 4px; }
.evidence > summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--primary-text); }
.evidence p { margin: 0 0 4px; }
.targets-box { border: 1.5px solid var(--border); border-radius: 14px; padding: 4px 12px 8px; background: var(--surface-2); }
.targets-box[open] { padding-bottom: 12px; }
.tgt-field { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 8px; }
.tgt-field .field-row > .field { margin-bottom: 6px; }
.tgt-head { margin-bottom: 4px; }
/* statuses — always words, never colour alone */
.rs { display: block; width: fit-content; margin: 2px 0 0 auto; padding: 0 6px; border-radius: 6px; font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .03em; }
.rs-within { background: var(--ok-soft); color: var(--ok); }
.rs-below { background: var(--warn-soft); color: var(--warn); }
.rs-over { background: var(--danger-strong); color: #fff; }
.rs-not_assessed { background: var(--surface-3); color: var(--muted); }
.b-below { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-border); }
tr.below td.nc { background: var(--warn-soft); }
tr.over td.nc { background: var(--danger-soft); color: var(--danger); }
tr.tgt-row td { text-align: left; padding-top: 0; }
tr:has(+ tr.tgt-row) > * { border-bottom: 0; }
.tchip { display: inline-block; margin: 0 6px 4px 0; padding: 1px 8px; border-radius: 999px; font-size: .78rem; border: 1px solid var(--border-strong); background: var(--surface-2); }
.tchip.ts-met { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tchip.ts-below { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-border); }
.tchip.ts-over { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.tchip.ts-not_assessed { color: var(--muted); }
.nut-targets { padding: 0 16px; }
.nut-legend { padding: 0 16px; margin: 4px 0 12px; }
@media print { .rs, .tchip { border: 1px solid #000 !important; background: none !important; color: #000 !important; } }

.encore-line { color: var(--primary-text); font-weight: 700; }

/* DEC-009: the product says who owns and made it. Clear of the phone tab bar. */
.app-footer { padding: 24px 16px calc(96px + env(safe-area-inset-bottom)); text-align: center; color: var(--muted);
  font-size: 0.85rem; line-height: 1.4; }
.app-footer p { margin: 0 auto; max-width: 60ch; }

/* MF-015: meal picking and the host's requests */
.pick-list, .req-list { list-style: none; margin: 0; padding: 0; }
.pick, .pick-req { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 12px 0;
  border-bottom: 1px solid var(--line, rgba(0,0,0,.08)); }
.pick .actions, .pick-req .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.b-own { background: #e8e0f5; color: #3d2a66; }
@media (prefers-color-scheme: dark) { .b-own { background: #3a2f52; color: #e6dcfa; } }

/* MF-017: what is in the kitchen and when to use it */
.lot-row {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.lot-row > div:first-child { flex: 1 1 240px; min-width: 0; }
.lot-row .actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.lot-row .amt { font-weight: 800; }
.lot-move { width: auto; flex: 0 0 auto; min-height: 36px; padding: 4px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--input-bg); color: var(--text); font: inherit; }
.keep { font-weight: 700; }
.keep-expired .keep, .keep.keep-expired, .keep-wrong_place .keep, .keep.keep-wrong_place { color: var(--danger); }
.keep-use_today .keep, .keep.keep-use_today { color: var(--accent-text); }
.keep-soon .keep, .keep.keep-soon { color: var(--warn); }
.keep-needs_date .keep, .keep.keep-needs_date { color: var(--info); }
.use-soon { border-left: 6px solid var(--accent); }
.use-soon h2 { margin-top: 0; }
.b-place { background: var(--surface-3); color: var(--text); }
.b-opened { background: var(--info-soft); color: var(--info); }
details.lots { margin-top: 6px; }
details.lots > summary { cursor: pointer; color: var(--muted); font-size: .92rem; min-height: 32px; }
.keep-advice { margin-top: 8px; }

/* the cloud: the way back to your households (hidden at home), and the account page's message */
.app-header .households-link { margin-left: auto; }
#message.is-error { border-color: var(--danger-border); background: var(--danger-soft); }
