:root {
  /* meal.io brand palette */
  --purple-950: #2c126b;  /* Ink */
  --purple-800: #5b30b8;  /* Purple 700 */
  --purple-600: #7c4ddb;  /* Purple 500 */
  --purple-400: #b696f5;  /* Lavender 300 */
  --purple-200: #d8c9f8;  /* light lavender (derived tint) */
  --purple-100: #efe9fc;  /* pale lavender (derived tint) */
  --leaf-500:   #4caf83;  /* Mint */
  --citrus-400: #ffb341;  /* Amber */
  --tomato-400: #ff7a59;  /* warm accent (no brand equivalent) */
  --cream:      #f7f5fa;  /* Snow */
  --ink:        #211a2e;  /* body text */

  /* App tokens */
  --bg: #f2edfb;
  --card: #ffffff;
  --muted: #675b80;
  --line: #e7dff5;
  --accent: var(--purple-800);
  --accent-dark: var(--purple-950);
  --accent-soft: var(--purple-100);
  --ok-bg: #e7f3e6;
  --ok-ink: #356b36;
  --err-bg: #fce7e1;
  --err-ink: #b23c20;
  --shadow: 0 10px 30px rgb(44 18 107 / 0.07);
  --shadow-hover: 0 14px 32px rgb(44 18 107 / 0.16);
  --gradient-brand: linear-gradient(135deg, var(--purple-600), var(--purple-950));
  /* Themed dropdown chevron (accent purple), shared by selects + datalist inputs */
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%235b30b8' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* Render native controls (select option lists, datalist popups) in light
     mode so they follow the app theme instead of the OS's dark appearance. */
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #efe9fc 0%, #f7f5fa 100%) no-repeat fixed;
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 max(20px, env(safe-area-inset-left)) 64px max(20px, env(safe-area-inset-right));
}

.site-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* --- Header --- */
.site-header {
  max-width: 760px;
  margin: 0 auto;
  padding: 26px max(20px, env(safe-area-inset-right)) 18px max(20px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 14px 18px;
  flex-wrap: wrap;
}
.logo { display: flex; align-items: center; text-decoration: none; }
.logo-lockup {
  height: 46px;
  width: auto;
  display: block;
}
@media (max-width: 480px) {
  .logo-lockup { height: 40px; }
}

/* --- Cards --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 26px;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}
.card h1 { font-size: 19px; margin: 0 0 14px; }
.card h2 { font-size: 16px; margin: 22px 0 10px; }

.hint { color: var(--muted); font-size: 14px; }

/* --- Forms --- */
.import-form { display: flex; gap: 10px; }
.import-form input[type="url"] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 15px;
}
button {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--purple-200);
  background: #fff;
  color: var(--accent);
  font-weight: 600;
  padding: 9px 17px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
button:not(.primary):not(.link-button):not(.star):hover {
  background: var(--accent-soft);
  border-color: var(--purple-400);
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--cream);
  font-weight: 700;
}
button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button:disabled, button.is-busy {
  cursor: progress;
  opacity: 0.65;
}
button.is-busy:hover { background: var(--accent); border-color: var(--accent); }

/* Import progress feedback (see static/import.js) */
.import-progress { margin: 14px 0 0; }
.import-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--purple-100);
  overflow: hidden;
}
.import-bar-fill {
  height: 100%;
  width: 8%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.4s ease;
}
.import-progress-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 9px 0 0;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}
.import-spinner {
  flex: none;
  width: 15px;
  height: 15px;
  border: 2px solid var(--purple-200);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: import-spin 0.7s linear infinite;
}
@keyframes import-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .import-spinner { animation-duration: 1.6s; }
}
.import-progress--error .import-bar-fill { background: var(--err-ink); }
.import-progress--error .import-progress-line { color: var(--err-ink); }
.import-progress--error .import-spinner { display: none; }
.inline { display: inline; }
.link-button {
  border: none;
  background: none;
  padding: 0;
  color: var(--muted);
  font-weight: 400;
  text-decoration: underline;
}
.link-button:hover { color: var(--accent); }

input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--purple-400);
  outline-offset: 1px;
}

/* --- Themed dropdowns + datalist "filter" boxes ------------------------
   Strips the native OS chrome and gives every <select> and datalist-backed
   text input the same rounded, lavender-bordered look with a purple chevron.
   Per-component rules below only tweak size/spacing and inherit this. */
select {
  appearance: none;
  -webkit-appearance: none;
  padding: 8px 34px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background-color: #fff;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 11px 8px;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease;
}
select:hover { border-color: var(--purple-400); }
select:focus {
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px var(--purple-100);
}
/* Picker inputs read as dropdowns: same chevron, room for it on the right.
   `.combo-input` is added by the JS combobox, which strips the `list` attribute
   (and with it the native, un-themeable popup) but keeps the picker look. */
input[list],
input.combo-input {
  padding-right: 32px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px 8px;
}
/* Hide the browser's own datalist arrow so ours is the only one. */
input[list]::-webkit-calendar-picker-indicator {
  display: none !important;
}

/* --- Themed dropdown (custom combobox) --------------------------------------
   The floating list that replaces the native <datalist> popup. Positioned in JS
   (fixed, anchored under its input) and appended to <body> so it escapes any
   card/overflow clipping. */
.combo-pop {
  position: fixed;
  z-index: 200;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: var(--shadow-hover);
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.combo-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.combo-opt.is-active,
.combo-opt:hover { background: var(--accent-soft); }
.combo-opt-name { flex: 1; min-width: 0; }
.combo-opt.is-on-list .combo-opt-name { color: var(--muted); }
.combo-onlist { color: var(--muted); white-space: nowrap; }
.combo-area {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--area, var(--muted));
  white-space: nowrap;
}
.combo-area::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  margin-right: 4px;
  background: var(--area, var(--muted));
}
.combo-count,
.combo-regular {
  font-size: 11px;
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.combo-regular { color: var(--accent, #2b7); font-weight: 600; }
.combo-empty { padding: 9px 10px; color: var(--muted); font-size: 14px; }

/* --- Flash messages --- */
.flashes { margin-bottom: 18px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 8px;
}
.flash-success { background: var(--ok-bg); color: var(--ok-ink); }
.flash-error { background: var(--err-bg); color: var(--err-ink); }

/* --- Recipe library list --- */
.recipe-list { list-style: none; margin: 0 0 18px; padding: 0; }
.recipe-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.recipe-list li:last-child { border-bottom: none; }
.recipe-name { flex: 1; cursor: pointer; }
.recipe-actions { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.recipe-actions a { color: var(--accent); }

/* --- Page actions (view / print) --- */
.page-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.page-actions a { color: var(--accent); text-decoration: none; }
.action-group { display: flex; align-items: center; gap: 14px; }

/* --- "For:" line on the grocery page --- */
.meta {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 18px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.meta a { color: var(--muted); }

/* --- Single recipe page --- */
.recipe-page {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}

.recipe-hero {
  position: relative;
  background: var(--gradient-brand);
}
.recipe-hero img {
  display: block;
  width: 100%;
  height: clamp(240px, 40vw, 360px);
  object-fit: cover;
}
.recipe-hero--plain { min-height: 200px; }
.hero-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 30px 26px 20px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0));
}
.recipe-hero--plain .hero-overlay {
  position: static;
  background: none;
}
.hero-overlay h1 {
  margin: 0;
  color: #fff;
  font-weight: 800;
  font-size: clamp(26px, 5vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.hero-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 0;
}
.hero-meta .chip {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.38);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 999px;
}

.recipe-body {
  display: grid;
  grid-template-columns: minmax(220px, 260px) 1fr;
  gap: 28px;
  padding: 24px 26px 28px;
}
.recipe-body h2 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.ingredients {
  align-self: start;
  position: sticky;
  top: 16px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}
.ingredients ul { list-style: none; margin: 0; padding: 0; }
.ingredients li {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.ingredients li:last-child { border-bottom: none; }
.ingredient-group {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}
.ingredients ul + .ingredient-group { margin-top: 16px; }
.ingredient-note {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.ingredient-note a { color: var(--accent); }
.source-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.source-link:hover { text-decoration: underline; }

.method ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}
.step-num {
  flex: none;
  font-weight: 800;
  font-size: clamp(40px, 8vw, 60px);
  line-height: 0.85;
  letter-spacing: -0.04em;
  color: var(--accent);
  opacity: 0.22;
}
.step p {
  margin: 0;
  padding-top: 4px;
  line-height: 1.6;
}

/* --- Serving-size scaler (recipe page) --- */
.serving-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
}
.serving-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.serving-step {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
  line-height: 1;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.serving-step:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.serving-step.is-disabled {
  color: var(--line);
  pointer-events: none;
}
.serving-count {
  font-size: 17px;
  min-width: 20px;
  text-align: center;
}
.serving-reset {
  margin-left: 4px;
  font-size: 13px;
  color: var(--muted);
}

/* Per-recipe servings input on the home cards. */
.card-servings {
  width: 46px;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
}

/* --- Grocery list --- */
/* Logical colour per grocery area, used by the list and staples headings.
   --area falls back to the accent for shops and unknown/user-typed areas. */
.area-fruit-veg    { --area: #3f9a55; }
.area-dairy-eggs   { --area: #4a86c5; }
.area-meat-seafood { --area: #cc5b6e; }
.area-bakery       { --area: #d79a3c; }
.area-pantry       { --area: #b3793f; }
.area-frozen       { --area: #3aa6bf; }
.area-drinks       { --area: #8a63c9; }
.area-household    { --area: #6b7a93; }
.area-other        { --area: #998ca8; }

.shop h2 {
  border-bottom: 2px solid var(--area, var(--accent));
  padding-bottom: 4px;
}
.shop h2::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  margin-right: 8px;
  background: var(--area, var(--accent));
  vertical-align: baseline;
}
.grocery-items { list-style: none; margin: 0 0 8px; padding: 0; }
.grocery-items li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.grocery-items li:last-child { border-bottom: none; }
.g-toggle {
  flex: none;
  display: flex;
  align-self: center;
  /* Expand 22px checkbox into a 44×44 hit area without shifting layout. */
  padding: 11px;
  margin: -11px 0 -11px -11px;
}
.g-check {
  width: 22px;
  height: 22px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}
.g-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-top: 2px;
}
.g-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.g-name { font-weight: 500; }
.g-item.is-needed .g-name { font-weight: 700; }
/* In Plan, an item already picked up in Shop reads as done. */
.g-item.is-bought .g-name { font-weight: 500; color: var(--muted); text-decoration: line-through; }
/* A picked-up item greys out but stays on the list, so a mistaken tap is easy
   to undo. The cart toggle itself is left un-greyed as the clear undo target. */
.g-item.is-bought .g-body { opacity: 0.5; }

/* Shop mode: the tick is a shopping-cart icon — filled with a check once the
   item is in the cart. The native checkbox is kept for state/keyboard but sits
   invisibly over the icon. */
.cart-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
}
.cart-check {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.cart-icon {
  display: inline-flex;
  color: var(--muted);
  pointer-events: none;
  transition: color 0.15s ease;
}
.cart-icon svg { width: 24px; height: 24px; }
/* Outline cart until it's in the cart, then a solid one in the accent colour. */
.cart-solid { display: none; }
.cart-check:checked + .cart-icon { color: var(--accent); }
.cart-check:checked + .cart-icon .cart-outline { display: none; }
.cart-check:checked + .cart-icon .cart-solid { display: inline; }
.cart-check:focus-visible + .cart-icon {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* The whole shop-mode row is a tap target for its cart. */
.g-item.is-tappable { cursor: pointer; }
@media (hover: hover) {
  .g-item.is-tappable:hover { background: var(--bg); }
}
.g-item.is-tappable:active { background: var(--accent-soft); }
.g-qty { color: var(--ink); white-space: nowrap; font-size: 14px; }
.g-recipes {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.g-recipes a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--purple-200);
}
.g-recipes a:hover { color: var(--accent); text-decoration-color: var(--accent); }
.g-delete { flex: none; align-self: center; }
.g-icon-btn {
  border: none;
  background: transparent;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}
.g-icon-btn:hover { background: var(--err-bg); color: var(--err-ink); }
.g-icon-btn:focus-visible {
  outline: 2px solid var(--purple-400);
  outline-offset: 2px;
}
.g-icon-btn svg { width: 16px; height: 16px; }

/* Read-only archived list: a tick marker stands in for the live checkbox. */
.g-mark {
  flex: none;
  width: 22px;
  align-self: center;
  text-align: center;
  color: var(--leaf-500);
  font-weight: 700;
  font-size: 18px;
  margin-left: 3px;
}

/* --- Saved (archived) lists index --- */
.saved-lists { list-style: none; margin: 12px 0 0; padding: 0; }
.saved-list {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.saved-list:last-child { border-bottom: none; }
.saved-list-main {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  text-decoration: none;
  color: var(--ink);
}
.saved-list-main:hover .saved-list-date { color: var(--accent); }
.saved-list-date { font-weight: 600; }
.saved-list-count { color: var(--muted); font-size: 14px; }

@media (max-width: 620px) {
  .recipe-body {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 18px;
  }
  .ingredients { position: static; }
  .recipe-hero img { height: clamp(180px, 50vw, 260px); }
}

/* --- Top nav --- */
.site-nav { display: flex; gap: 18px; font-size: 14px; margin-left: auto; align-items: center; }
.site-nav > a { color: var(--muted); text-decoration: none; font-weight: 600; }
.site-nav > a:hover,
.site-nav > a.is-active { color: var(--accent); }

/* "More" disclosure menu (CSS-only dropdown via <details>). */
.nav-more { position: relative; }
.nav-more summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-more summary::-webkit-details-marker { display: none; }
.nav-more summary:hover,
.nav-more summary.is-active { color: var(--accent); }
.nav-more-chevron {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}
.nav-more[open] .nav-more-chevron { transform: rotate(180deg); }
.nav-more-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 55;
  min-width: 168px;
  display: flex;
  flex-direction: column;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-hover);
}
.nav-more-menu a,
.nav-more-menu .link-button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
}
.nav-more-menu a:hover,
.nav-more-menu .link-button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.nav-more-menu .logout-form { margin: 4px 0 0; padding-top: 6px; border-top: 1px solid var(--line); }

/* --- Sign-in page --- */
.login-card { max-width: 360px; margin: 40px auto; }
.login-card .form-actions { margin-top: 16px; }

/* --- Shopping items page --- */
.item-add-form { display: flex; gap: 8px; flex-wrap: wrap; }
.item-add-form input[type="text"],
.item-edit input[type="text"] {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}
.item-add-form input[name="name"] { flex: 1; min-width: 160px; }
.item-add-form input[name="quantity"] { width: 150px; }
.seq-input {
  width: 92px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}

.import-block {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.import-block summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.import-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px 0;
  font-size: 14px;
}
.import-row code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 13px;
}

.count { color: var(--muted); font-weight: 400; font-size: 15px; }

/* --- Lists section: Plan / Shop / Catalog tabs --- */
.lists-head { margin-bottom: 14px; }
.lists-head > h1 { margin: 0 0 10px; }
.list-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--accent-soft);
  border-radius: 11px;
}
.list-tab {
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.list-tab:hover { background: rgb(255 255 255 / 0.5); }
.list-tab.is-active {
  background: var(--card);
  color: var(--accent-dark);
  box-shadow: var(--shadow);
}
@media (max-width: 480px) {
  .list-tabs { display: flex; }
  .list-tab { flex: 1; text-align: center; padding: 8px 10px; }
}

/* --- Plan tab: add an item from the catalog --- */
.staples-pick-list {
  list-style: none;
  margin: 6px 0 12px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 2px;
}
.catalog-pick,
.catalog-pick-form { margin: 0; }
.catalog-pick-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
.catalog-pick-btn:hover { background: var(--accent-soft); border-color: var(--line); }
.catalog-pick-name { flex: 1; }
.catalog-pick-area {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--area, var(--muted));
  white-space: nowrap;
}
.catalog-pick-area::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  margin-right: 4px;
  background: var(--area, var(--muted));
}
.catalog-pick-onlist { display: none; color: var(--muted); white-space: nowrap; }
.catalog-pick.is-on-list .catalog-pick-name { color: var(--muted); }
.catalog-pick.is-on-list .catalog-pick-onlist { display: inline; }

/* How often an item has actually been bought across past lists. */
.catalog-pick-count,
.catalog-pick-regular {
  font-size: 11px;
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.catalog-pick-regular {
  color: var(--accent, #2b7);
  font-weight: 600;
}

/* Items as a flat card grid; each card is a <details> that expands to edit. */
.item-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 14px 0 4px;
}
.item-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease;
}
.item-card:hover { box-shadow: var(--shadow-hover); }
.item-card[open] { box-shadow: var(--shadow-hover); }

.item-card-face {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.item-card-face::-webkit-details-marker { display: none; }
.item-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.item-card-name {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-card-meta {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-card-face .nav-more-chevron { flex: none; color: var(--muted); }
.item-card[open] .nav-more-chevron { transform: rotate(180deg); }

.item-card-body {
  padding: 4px 15px 15px;
  border-top: 1px solid var(--line);
}
.item-edit { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.item-field { display: flex; flex-direction: column; gap: 4px; }
.item-field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.item-field input { width: 100%; box-sizing: border-box; }
.item-field-row { display: flex; gap: 8px; }
.item-field-row .item-field { flex: 1; }
.item-field-seq { flex: 0 0 92px; }
.item-field-seq .seq-input { width: 100%; }
.item-card-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 2px;
}

/* --- Inline "assign" forms on the grocery list (unsorted items) --- */
.g-assign {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 10px;
}
.g-assign form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0;
}
.g-assign input[type="text"] {
  flex: 1 1 140px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}
.g-assign .seq-input { flex: none; width: 96px; padding: 8px 10px; }
.g-assign button {
  padding: 8px 14px;
  font-size: 13px;
  flex: none;
}

/* Known-but-unsorted item: edit it inline like a catalog entry (tap to expand)
   instead of a destructive re-assign that would forget its off-this-trip shop. */
.g-known {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 10px;
}
.g-also-at {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin: 0 0 8px;
}
.g-off-note { color: var(--muted); font-size: 13px; }
.g-also-row { display: flex; gap: 6px; flex: 1 1 200px; }
.g-also-at input[type="text"] {
  flex: 1 1 140px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}
.g-also-at button { padding: 8px 14px; font-size: 13px; flex: none; }
.g-edit > summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  list-style: none;
  width: max-content;
  padding: 2px 0;
}
.g-edit > summary::-webkit-details-marker { display: none; }
.g-edit > summary::before { content: "▸ "; font-size: 11px; }
.g-edit[open] > summary::before { content: "▾ "; }
.g-edit .item-edit { margin-top: 8px; }

/* --- Selected-for-shopping strip (home page) --- */
.selected-strip {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.selected-heading {
  margin: 0 0 10px;
  font-size: 17px;
  color: var(--accent-dark);
}
.selected-count { color: var(--muted); font-weight: 500; font-size: 15px; }
.selected-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
}
.selected-list li {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.selected-list a {
  color: var(--accent-dark);
  font-weight: 600;
  text-decoration: none;
}
.selected-list a:hover { text-decoration: underline; }
.selected-meta { color: var(--muted); font-size: 13px; }
.selected-hint { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.selected-hint a { color: var(--accent); }

/* --- Recipe card grid (home page) --- */
.recipe-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin: 16px 0 20px;
}
.recipe-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.recipe-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}
.card-photo {
  display: block;
  aspect-ratio: 4 / 3;
  background: var(--bg);
}
.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--muted);
  font-size: 13px;
}
.card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  padding: 11px 13px 12px;
}
.card-title {
  font-weight: 600;
  line-height: 1.3;
  color: var(--ink);
  text-decoration: none;
}
.card-title:hover { color: var(--accent); }
.card-meta { margin: 0; color: var(--muted); font-size: 13px; }
.card-foot {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
}
.card-select {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
}
.card-foot .link-button { font-size: 14px; }

/* --- Recipe edit / create form --- */
.recipe-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label { font-size: 14px; font-weight: 600; }
.field-label small { font-weight: 400; color: var(--muted); }
.recipe-form input[type="text"],
.recipe-form input[type="url"],
.recipe-form input[type="number"],
.recipe-form textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
}
.recipe-form textarea { resize: vertical; line-height: 1.5; }
.recipe-form input[type="file"] { font-size: 14px; }
.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }
.form-photo {
  max-width: 220px;
  border-radius: 8px;
  margin-bottom: 2px;
}
.form-actions { display: flex; align-items: center; gap: 14px; }
@media (max-width: 620px) {
  .field-row { flex-direction: column; gap: 18px; }
}

/* --- Photo import review queue --- */
.import-review {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 18px;
}
.import-review:last-child { margin-bottom: 0; }

.import-photos {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.import-source img {
  height: 150px;
  width: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
}

.import-note {
  background: var(--err-bg);
  color: var(--err-ink);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  margin: 0;
}

.import-fields { margin-bottom: 6px; }

.photo-picker {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.photo-option {
  cursor: pointer;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  display: flex;
  line-height: 0;
}
.photo-option input { position: absolute; opacity: 0; }
.photo-option img {
  height: 90px;
  width: auto;
  border-radius: 5px;
  display: block;
}
.photo-option--none {
  align-items: center;
  justify-content: center;
  min-width: 90px;
  line-height: 1.3;
  font-size: 13px;
  color: var(--muted);
}
.photo-option:has(input:checked) {
  border-color: var(--accent);
}

.import-reject { margin-top: 4px; }

/* --- "I made this" tracker (recipe page) --- */
.cook-tracker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px 20px;
  flex-wrap: wrap;
}
.cook-made { display: flex; align-items: center; gap: 12px; }
.cook-count { color: var(--muted); font-size: 14px; }
.cook-rate { display: flex; align-items: center; gap: 8px; }
.cook-rate-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.cook-clear { font-size: 13px; }

/* Star rating — the form lists stars 5..1, row-reverse paints them 1..5
   and lets a hover light up the hovered star plus every star to its left. */
.stars { display: inline-flex; flex-direction: row-reverse; }
.star {
  border: none;
  background: none;
  padding: 6px 3px;
  font-size: 26px;
  line-height: 1;
  color: var(--line);
  cursor: pointer;
  transition: color 0.15s ease;
}
.star.is-on { color: var(--citrus-400); }
.stars:hover .star { color: var(--line); }
.stars .star:hover,
.stars .star:hover ~ .star { color: var(--citrus-400); }

/* Rating + cook count on the home-page recipe cards. */
.card-stats {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.card-stars { letter-spacing: 1px; white-space: nowrap; }
.card-stars .on { color: var(--citrus-400); }
.card-stars .off { color: var(--line); }
.card-made { color: var(--muted); }

/* --- Staples --- */
.staple-check {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}
.staple-check input { accent-color: var(--accent); }

.staples-block {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.staples-block summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.staple-area { margin-top: 10px; }
.staple-area-name {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--area, var(--muted));
}
.staple-area-name::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  margin-right: 6px;
  background: var(--area, var(--muted));
  vertical-align: baseline;
}
.staple-area-name.is-unsorted { font-style: italic; }

/* --- Weekly meal planner --- */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.plan-day {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px 13px;
}
.plan-day.has-meal { border-color: var(--accent-soft); }
.plan-day.is-dragging { opacity: 0.45; }
.plan-day.is-drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft) inset;
}
.plan-day.has-meal .plan-meal {
  cursor: grab;
  touch-action: none; /* a swipe on the tile drags it, not scrolls the page */
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.plan-day.has-meal .plan-meal:active { cursor: grabbing; }
.plan-drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  margin: 0;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--accent-soft);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  opacity: 0.95;
  pointer-events: none;
}
.plan-day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.plan-day-head h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.plan-remove {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}
.plan-remove:hover { color: var(--accent); }
.plan-meal {
  display: flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  color: var(--ink);
}
.plan-meal-photo {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}
.plan-meal-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.plan-meal-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}
.plan-meal-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.plan-meal-title { font-weight: 600; line-height: 1.25; }
.plan-meal:hover .plan-meal-title { color: var(--accent); }
.plan-meal-servings { font-size: 12px; color: var(--muted); }
.plan-empty { margin: 0; color: var(--muted); font-size: 13px; font-style: italic; }
.plan-pick {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 4px;
}
.plan-pick select {
  flex: 1;
  min-width: 0;
  padding: 7px 30px 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #fff;
  font-size: 13px;
}
.plan-servings {
  width: 56px;
  padding: 7px 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

/* --- Recipe library search + sort toolbar --- */
.library-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 14px 0 4px;
}
.library-search {
  flex: 1;
  min-width: 180px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
}
.library-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}
.library-sort select {
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background-color: #fff;
  font-size: 14px;
}
.library-empty { margin: 14px 0; }

/* --- "Plan onto a day" picker on each recipe card --- */
.card-plan {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 13px 12px;
  border-top: 1px solid var(--line);
}
.card-plan-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.card-plan select {
  flex: 1;
  min-width: 0;
  padding: 6px 30px 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #fff;
  font-size: 13px;
}

/* --- Toast (transient confirmation for no-reload actions) --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(78px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  z-index: 60;
  max-width: min(92vw, 420px);
  padding: 11px 16px;
  border-radius: 11px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow-hover);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast--error { background: #b23048; }
.toast a { color: #fff; text-decoration: underline; font-weight: 600; }
@media (min-width: 769px) { .toast { bottom: 24px; } }

/* --- Review pop-up (untick what's already in the cupboard) --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  background: rgb(33 26 46 / 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.modal-overlay.is-shown { opacity: 1; }
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow-hover);
  padding: 20px 20px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(16px);
  transition: transform 0.2s ease;
}
.modal-overlay.is-shown .modal { transform: translateY(0); }
.modal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.modal-title { margin: 0; font-size: 19px; }
.modal-toggle { flex: none; font-size: 13px; }
.modal-sub { color: var(--muted); font-size: 14px; margin: 4px 0 12px; }
.modal-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}
.modal-item { border-bottom: 1px solid var(--line); }
.modal-line {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 2px;
  cursor: pointer;
}
.modal-check { width: 20px; height: 20px; margin-top: 1px; flex: none; }
.modal-text { display: flex; flex-direction: column; gap: 2px; }
.modal-name { font-weight: 600; }
.modal-qty { color: var(--accent); font-size: 13px; }
.modal-from { color: var(--muted); font-size: 12px; }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 14px;
}
.modal-confirm { min-width: 140px; }
@media (min-width: 600px) {
  .modal-overlay { align-items: center; padding: 24px; }
  .modal { border-radius: 18px; }
}

/* A ticked-off item leaving the shop-mode buy list. */
.g-item.is-removing {
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Brand mark shown only on printed pages (hidden on screen). */
.print-brand { display: none; }

/* --- Bottom tab bar (mobile only) --- */
/* Four primary destinations — Recipes / List / Import / Items. The tabbar is
   hidden on desktop where the inline .site-nav covers the same ground. */
.tabbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding:
    8px max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgb(44 18 107 / 0.06);
}
.tab {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 54px;
  padding: 6px 4px;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
}
.tab-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 28px;
  border-radius: 999px;
  transition: background 0.2s ease;
}
.tab-icon {
  width: 22px;
  height: 22px;
  transition: transform 0.2s cubic-bezier(.34, 1.56, .64, 1);
}
.tab-label {
  line-height: 1;
  white-space: nowrap;
}
.tab.is-active { color: var(--accent); }
.tab.is-active .tab-icon-wrap { background: var(--accent-soft); }
.tab.is-active .tab-icon { transform: scale(1.06); }
.tab:active .tab-icon { transform: scale(0.94); }

/* Utility — hide something only on phones (e.g. Print buttons). */
.mobile-hide { /* shown by default; the mobile media query hides it. */ }

/* --- Mobile (≤ 768px): show the tab bar, swap inline nav, tighten layout. --- */
@media (max-width: 768px) {
  .tabbar { display: flex; justify-content: space-around; }
  body.has-tabbar main {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  /* Primary inline links collapse into the bottom tabbar; the "More" menu stays
     in the header so Past lists + Sign out remain reachable. Items flagged
     .mobile-hide inside the menu (Import, Shopping items) are already tabs. */
  .site-nav { gap: 12px; margin-left: auto; }
  .site-nav > a { display: none; }

  .site-header {
    padding-top: 18px;
    padding-bottom: 12px;
    gap: 10px 14px;
  }
  .logo-lockup { height: 38px; }

  main { padding-left: max(16px, env(safe-area-inset-left));
         padding-right: max(16px, env(safe-area-inset-right)); }
  .card { padding: 18px 18px; border-radius: 14px; }
  .card h1 { font-size: 20px; }

  /* iOS zooms inputs whose font-size is < 16px. Number inputs use the
     keypad and are exempt — keeping them small preserves the layout. */
  input[type="text"],
  input[type="url"],
  input[type="email"],
  input[type="password"],
  input[type="search"],
  input[type="tel"],
  textarea,
  select {
    font-size: 16px;
  }
  .g-assign input[type="text"] { font-size: 16px; }
  .g-also-at input[type="text"] { font-size: 16px; }
  .item-add-form input[type="text"],
  .item-edit input[type="text"] { font-size: 16px; }

  .mobile-hide { display: none !important; }

  /* --- Home page card grid: 2 columns on phones --- */
  .recipe-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 18px;
  }
  .card-body { padding: 9px 11px 11px; gap: 5px; }
  .card-title { font-size: 14px; line-height: 1.25; }
  .card-meta { font-size: 12px; }
  .card-stats { font-size: 12px; }
  .card-foot { padding-top: 7px; }
  .card-foot .link-button { font-size: 12px; }
  .card-select { font-size: 13px; gap: 4px; }
  .card-servings { width: 40px; font-size: 14px; }

  /* --- Recipe page hero — lay the title BELOW the photo on phones so it
     stays readable on any image, in any lighting. --- */
  .recipe-hero {
    background: var(--card);
  }
  .recipe-hero img {
    height: clamp(180px, 50vw, 260px);
  }
  .recipe-hero--plain { min-height: 0; }
  .hero-overlay {
    position: static;
    padding: 16px 18px 14px;
    background: linear-gradient(135deg, var(--purple-100) 0%, #fff 100%);
    border-top: 1px solid var(--line);
  }
  .recipe-hero--plain .hero-overlay { border-top: none; }
  .hero-overlay h1 {
    color: var(--ink);
    font-size: 24px;
    letter-spacing: -0.01em;
  }
  .hero-meta .chip {
    background: rgba(91, 48, 184, 0.08);
    border-color: var(--purple-200);
    color: var(--accent);
  }

  .recipe-body { padding: 16px; gap: 18px; }

  /* --- Cook tracker — stack vertically, stars get their own row --- */
  .cook-tracker {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .cook-made { justify-content: space-between; }
  .cook-rate {
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .cook-rate-label { font-size: 12px; }

  /* --- Page action bar (top of recipe / grocery / archived pages) --- */
  .page-actions { gap: 10px; flex-wrap: wrap; }
  .action-group { gap: 10px; flex-wrap: wrap; }

  /* --- Grocery list (mobile) --- */
  .g-name { font-size: 17px; }
  .g-qty { font-size: 15px; }
  .grocery-items li { padding: 12px 0; }

  /* --- Item add / import row stacks on phones --- */
  .item-add-form { flex-direction: column; align-items: stretch; gap: 8px; }
  .item-add-form input[type="text"],
  .item-add-form input[type="number"] { flex: none; width: 100%; min-width: 0; }
  .item-add-form .seq-input { width: 100%; }
  .item-add-form .staple-check { align-self: flex-start; }
  .item-add-form button { width: 100%; }

  /* --- Import page forms stack vertically --- */
  .import-form { flex-direction: column; gap: 10px; }
  .import-form input[type="url"],
  .import-form input[type="file"] { width: 100%; }
  .import-form button { width: 100%; padding: 12px 17px; }

  /* --- Import review queue --- */
  .import-review { padding: 14px; }
  .import-source img { height: 120px; }

  /* --- Recipe form --- */
  .form-actions { flex-direction: column; align-items: stretch; gap: 10px; }
  .form-actions button { width: 100%; padding: 12px 17px; }
  .form-actions .link-button { text-align: center; padding: 8px 0; }
  .form-photo { max-width: 100%; }

  /* --- Login page --- */
  .login-card { margin: 24px auto; }
}

/* --- Smaller phones (≤ 430px): tighter card grid labels --- */
@media (max-width: 430px) {
  .card-select span { display: none; }
  .card-foot { gap: 4px; }
  .card-servings { width: 44px; }
  .card-title { font-size: 13.5px; }
}

/* --- Very narrow phones (≤ 360px) --- */
@media (max-width: 360px) {
  .tab-label { font-size: 10.5px; }
  .tab-icon-wrap { width: 44px; }
  .logo-lockup { height: 34px; }
}

/* --- Print --- */
@media print {
  @page { margin: 1.2cm; }

  .no-print { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .card { border: none; padding: 0; margin: 0; box-shadow: none; }
  a { color: inherit; text-decoration: none; }

  /* Keep the styled colours, photo and tints on paper. */
  .print-brand,
  .recipe-page,
  .recipe-hero,
  .hero-overlay,
  .ingredients,
  .step {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  /* Mealio lockup at the top of every printed page. */
  .print-brand {
    display: flex;
    align-items: center;
    margin-bottom: 0.4cm;
  }
  .print-brand img { height: 38px; width: auto; }

  /* Recipe page: larger type, and the hero photo flexes to fill the sheet so
     the recipe fills (close to) a whole A4 page without spilling over. */
  .recipe-page {
    border: none;
    box-shadow: none;
    overflow: visible;
    display: flex;
    flex-direction: column;
    min-height: 24cm;
  }
  .recipe-hero {
    flex: 1 1 auto;
    min-height: 4.5cm;
  }
  .recipe-hero img { height: 100%; }
  .hero-overlay { padding: 0.5cm 0.7cm 0.45cm; }
  .hero-overlay h1 { font-size: 30pt; }
  .hero-meta { margin-top: 0.25cm; }
  .hero-meta .chip { font-size: 11pt; padding: 2px 11px; }

  .recipe-body {
    flex: none;
    grid-template-columns: 33% 1fr;
    gap: 0.8cm;
    padding: 0.6cm 0 0;
    align-items: start;
  }
  .recipe-body h2 { font-size: 13pt; margin-bottom: 0.3cm; }

  .ingredients {
    position: static;
    padding: 0.45cm 0.55cm;
    break-inside: avoid;
  }
  .ingredients li { font-size: 12pt; padding: 0.13cm 0; }
  .ingredient-group { font-size: 11pt; }
  .ingredients ul + .ingredient-group { margin-top: 0.35cm; }
  .ingredient-note { font-size: 9.5pt; }
  .source-link { display: none; }

  .method ol { gap: 0.4cm; }
  .step {
    gap: 0.5cm;
    padding: 0.3cm 0.45cm;
    break-inside: avoid;
  }
  .step p { font-size: 13pt; line-height: 1.4; padding-top: 0; }
  .step-num { font-size: 40pt; line-height: 0.8; }
}

/* Store on/off bar — switch a shop off for a trip and its items re-route. */
.store-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 4px 0 16px;
}
.store-toggle-label { color: var(--muted); font-size: 14px; }
.store-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.store-chip input { margin: 0; }
.store-chip.is-off {
  background: transparent;
  color: var(--muted);
  border-style: dashed;
}
.store-chip.is-off span { text-decoration: line-through; }
.store-fallbacks { margin: 0 0 16px; }
.store-fallbacks .hint { margin-bottom: 8px; }
.store-fallback-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 14px;
}
.store-fallback-row select {
  padding: 5px 28px 5px 10px;
  background-position: right 10px center;
  border-radius: 8px;
}
