/* Mobile/tablet-first base styles. */
:root {
  --bg: #f7f4ee;
  --surface: #ffffff;
  --text: #1f2a26;
  --muted: #5f6b66;
  --accent: #2f5d50;
  --accent-soft: #e3ece8;
  --border: #e2ddd3;
  --danger: #b3261e;
  --radius: 12px;
  font-size: 17px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

a { color: var(--accent); }

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.75rem + env(safe-area-inset-top, 0px)) 1rem 0.75rem;
  background: var(--accent);
  color: #fff;
}
.topbar a { color: #fff; text-decoration: none; }
.topbar .brand { font-weight: 700; font-size: 1.2rem; }
.topbar nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1rem; }
.topbar .logout button {
  background: none;
  border: 0;
  color: #fff;
  font: inherit;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem;
}

.login { max-width: 420px; margin: 10vh auto 0; }
.login h1 { color: var(--accent); font-size: 2.2rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-form label { display: flex; flex-direction: column; gap: 0.3rem; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom, 0px));
}

h1 { margin: 0.5rem 0 0.25rem; font-size: 1.6rem; }
h2 { font-size: 1.2rem; }

.meta { color: var(--muted); margin: 0.25rem 0; }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }
.back { display: inline-block; margin-bottom: 0.5rem; text-decoration: none; }
.empty { color: var(--muted); }

.cards {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.card a { display: block; padding: 1rem; color: inherit; text-decoration: none; min-height: 44px; }
.card h2 { margin: 0 0 0.25rem; }

.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.5rem 0 0; }
.tag {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  font-size: 0.8rem;
}

.nutrition {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0;
}
.nutrition div {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
}
.nutrition dt { color: var(--muted); font-size: 0.8rem; }
.nutrition dd { margin: 0; font-weight: 600; }

.recipe-layout { display: grid; gap: 1.5rem; }
@media (min-width: 800px) {
  .recipe-layout { grid-template-columns: 1fr 2fr; }
}

.ingredients { list-style: none; padding: 0; }
.ingredients li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.ingredients .qty { font-weight: 600; margin-right: 0.25rem; }

.steps { padding-left: 1.25rem; }
.step { margin-bottom: 1rem; }
.step p { margin: 0; }
.step.passive > p:first-child { color: var(--muted); }

[x-cloak] { display: none !important; }

/* --- Buttons & common bits --- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.danger { color: var(--danger); border-color: var(--danger); }
.button.block { display: flex; width: 100%; margin-top: 1rem; }
.button.huge { min-height: 64px; font-size: 1.2rem; padding: 0.75rem 1.5rem; }
.button:disabled { opacity: 0.4; cursor: default; }

.icon-button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.icon-button.big { min-width: 56px; min-height: 56px; font-size: 1.4rem; }
.icon-button.danger { color: var(--danger); }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
form.inline { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin: 0.5rem 0; }
.alert.error { background: #fbe9e7; color: #8a2a1b; }
.alert.success { background: var(--accent-soft); color: var(--accent); }
.alert ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }
.notes { background: var(--surface); border-left: 4px solid var(--accent); padding: 0.5rem 1rem; }

input, select, textarea {
  font: inherit;
  min-height: 44px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
}
input[type="checkbox"] { min-height: 0; width: 1.4rem; height: 1.4rem; accent-color: var(--accent); }

/* --- Recipe list --- */
.filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.filters input { flex: 1 1 200px; }

/* --- Recipe detail --- */
.servings-picker { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
.round-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  user-select: none;
}
.round-button[aria-disabled="true"] { opacity: 0.3; cursor: default; }
.history { list-style: none; padding: 0; }
.history li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.history p { margin: 0.25rem 0 0; }

/* --- Recipe form --- */
.recipe-form fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin: 0 0 1rem;
  padding: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.recipe-form legend { font-weight: 600; padding: 0 0.25rem; }
.recipe-form label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.9rem; }
.recipe-form label.wide { flex: 1 1 100%; }
.recipe-form label.check { flex-direction: row; align-items: center; gap: 0.5rem; min-height: 44px; }
.recipe-form .hint { flex-basis: 100%; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; width: 100%; }
.row .grow { flex: 1 1 160px; }
.num { width: 6rem; }
.step-editor {
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.chips { gap: 0.35rem; }
.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 0.3rem 0.8rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 36px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.form-actions {
  position: sticky;
  bottom: 0;
  padding: 0.75rem 0 calc(0.75rem + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
}

/* --- Cooking mode (tablet on the counter) --- */
.cooking { max-width: 1200px; margin: 0 auto; }
.cooking-app { min-height: 100vh; display: flex; flex-direction: column; }
.cooking-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: calc(0.5rem + env(safe-area-inset-top, 0px)) 1rem 0.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.cooking-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cooking-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.timers {
  position: sticky;
  top: calc(73px + env(safe-area-inset-top, 0px));
  z-index: 9;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg);
}
.timer {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.25rem 0.25rem 0.9rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
}
.timer .icon-button { background: transparent; color: #fff; border-color: rgba(255, 255, 255, 0.4); }
.timer-time { font-variant-numeric: tabular-nums; font-size: 1.3rem; font-weight: 700; }
.timer.ringing { background: var(--danger); animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { opacity: 0.55; } }

.overview {
  margin: 0 1rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.overview ol { list-style: none; margin: 0; padding: 0; }
.overview ol button {
  width: 100%;
  text-align: left;
  min-height: 44px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  font: inherit;
  color: var(--text);
  padding: 0.5rem;
  cursor: pointer;
}
.overview ol button.current { font-weight: 700; color: var(--accent); }
.overview ol button.done { color: var(--muted); text-decoration: line-through; }
.custom-timer { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 1rem; }

.cooking-step { flex: 1; padding: 1rem 1rem 7rem; font-size: 1.25rem; }
.cooking-step h1 { font-size: 2rem; }
.step-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; }
.step-badges .tag { font-size: 0.95rem; padding: 0.2rem 0.8rem; }
.tag.passive { background: #fff3d6; color: #7a5300; }
.step-text { font-size: clamp(1.5rem, 3.2vw, 2.2rem); line-height: 1.35; margin: 0 0 1.5rem; }
.step-ingredients {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.step-ingredients h2 { margin-top: 0; font-size: 1.1rem; color: var(--muted); }
.step-ingredients ul { list-style: none; padding: 0; margin: 0; }
.step-ingredients li { padding: 0.4rem 0; }
@media (min-width: 900px) and (orientation: landscape) {
  .cooking-step:has(.step-main) {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
    align-items: start;
  }
}

.mise { list-style: none; padding: 0; }
.mise li { border-bottom: 1px solid var(--border); }
.mise label, .mise-done { display: flex; align-items: center; gap: 1rem; min-height: 56px; cursor: pointer; }
.mise-done { font-weight: 700; margin-top: 1rem; }
.mise input:checked + span { color: var(--muted); text-decoration: line-through; }

.cooking-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 1rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.cooking-nav .button { flex: 1; }

.finish-form { display: flex; flex-direction: column; gap: 1rem; max-width: 600px; }
.finish-form label { display: flex; flex-direction: column; gap: 0.3rem; }
.stars { display: flex; gap: 0.5rem; }
.star {
  font-size: 2.5rem;
  background: none;
  border: 0;
  color: var(--border);
  cursor: pointer;
  min-width: 56px;
  min-height: 56px;
}
.star.on { color: #e0a100; }
.check-line { flex-direction: row !important; align-items: center; gap: 0.75rem; min-height: 44px; }

/* --- Inventory --- */
.alert.warning { background: #fff3d6; color: #6b4700; }
.alert.warning ul { list-style: none; padding: 0; }
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.05rem 0.55rem;
  font-size: 0.8rem;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.badge.soon { background: #ffe2a8; color: #6b4700; }
.badge.expired { background: #fbd3cd; color: #8a2a1b; }

.quick-add {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0;
}
.quick-add .grow { flex: 1 1 180px; }
.inline-label { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); }

.locations { display: grid; gap: 1rem; }
@media (min-width: 900px) {
  .locations { grid-template-columns: repeat(3, 1fr); align-items: start; }
}
.location {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.location h2 { margin: 0.25rem 0 0.5rem; }
.location h3 { margin: 0.75rem 0 0.25rem; font-size: 0.95rem; color: var(--muted); }
.stock-list { list-style: none; padding: 0; margin: 0; }
.stock-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}
.stock-list li:last-child { border-bottom: 0; }
.stock-list li.expired .stock-name { color: #8a2a1b; }
.stock-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 0.6rem; }
.stock-name { font-weight: 600; }
.stock-actions { display: flex; align-items: center; gap: 0.4rem; }
.qty-edit { display: flex; align-items: center; gap: 0.3rem; }
.add-portion { margin-top: 1rem; }
.add-portion summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }

/* --- Planning --- */
.container.wide { max-width: 1800px; }
.week-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.week-nav strong { flex: 1; text-align: center; min-width: 10rem; }
.week-grid { display: grid; gap: 0.75rem; }
@media (min-width: 700px) { .week-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .week-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1500px) { .week-grid { grid-template-columns: repeat(7, 1fr); } }
.day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.day.today { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.day.past { opacity: 0.65; }
.day-head h2 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.day-head select { width: 100%; min-height: 36px; font-size: 0.9rem; }
.kcal { margin: 0.25rem 0 0; font-size: 0.85rem; color: var(--muted); }
.gap { font-weight: 700; margin-left: 0.25rem; }
.gap.ok { color: var(--accent); }
.gap.under { color: #7a5300; }
.gap.over { color: var(--danger); }
.slot {
  min-height: 64px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.slot-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.add-slot {
  flex: 1;
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
}
.add-slot:hover { background: var(--accent-soft); }
.entry {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent-soft);
  border-radius: 8px;
  padding: 0.35rem;
}
.entry.batch, .entry.leftover { background: #fff3d6; }
.entry-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entry-body a { color: var(--text); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.entry-body .meta { font-size: 0.8rem; margin: 0; }
.entry-actions { display: flex; gap: 0.25rem; }
.entry-actions .icon-button { min-width: 36px; min-height: 36px; }
.drag-handle { cursor: grab; color: var(--muted); padding: 0.25rem; touch-action: none; font-size: 1.2rem; }
.sortable-ghost { opacity: 0.4; }
.servings-inline { display: inline-flex; align-items: center; gap: 0.25rem; }
.servings-inline input { width: 3.2rem; min-height: 30px; padding: 0.1rem 0.3rem; }
.week-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 1rem; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet {
  background: var(--bg);
  width: min(640px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  border-radius: 16px 16px 0 0;
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 16px; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; }
.sheet h3 { font-size: 0.95rem; color: var(--muted); margin: 1rem 0 0.5rem; }
.pick-options { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.pick-options label { display: flex; align-items: center; gap: 0.4rem; }
.pick-options #pick-servings { width: 4.5rem; }
.pick-options input[type="search"] { flex: 1 1 200px; }
.pick-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.pick {
  width: 100%;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.4rem;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  min-height: 52px;
}
.pick:hover { border-color: var(--accent); }

/* --- Shopping list --- */
.list-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0.5rem; }
.total { font-size: 1.2rem; font-weight: 700; margin: 0; }
.aisle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  margin: 0.75rem 0;
}
.aisle h2 { margin: 0.25rem 0; font-size: 1rem; color: var(--muted); }
.covered { margin: 1rem 0; color: var(--muted); }
.covered summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.list-actions { margin: 1.5rem 0; display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }

/* --- Ingredient catalogue --- */
.table-wrap { overflow-x: auto; }
.ingredients-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.ingredients-table th, .ingredients-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.ingredients-table th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.ingredients-table tr.missing td:first-child { box-shadow: inset 4px 0 0 #e0a100; }
.ingredients-table .badge { margin-left: 0.4rem; white-space: normal; }
.num-sm { width: 4.5rem; min-height: 36px; }
.ingredients-table .aisle, .query-input { width: 10rem; min-height: 36px; }

/* --- Batch cooking --- */
.r0 { --c: #2f5d50; }
.r1 { --c: #c0662b; }
.r2 { --c: #5a5fb0; }
.r3 { --c: #a3407a; }
.r4 { --c: #8a7a1c; }
.r5 { --c: #2f7fa0; }
.shared { --c: #8b8f8d; }
.swatch { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 3px; background: var(--c); flex: none; }

.batch-pick { list-style: none; padding: 0; margin: 0; width: 100%; }
.batch-pick li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  border-radius: 8px;
}
.batch-pick li.on { background: var(--accent-soft); }
.batch-pick label.check { align-items: flex-start; }
.batch-pick label.check > span { display: flex; flex-direction: column; }
.servings-field { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }

.timeline-wrap { overflow-x: auto; }
.timeline { min-width: 640px; padding: 1.5rem 0 0.5rem; position: relative; }
.timeline-axis { position: relative; height: 1.2rem; margin-left: 8rem; border-bottom: 1px solid var(--border); }
.timeline-axis span { position: absolute; transform: translateX(-50%); font-size: 0.75rem; color: var(--muted); }
.lane { display: flex; align-items: center; gap: 0; margin-top: 0.4rem; }
.lane.sub { margin-top: 2px; }
.lane-label { width: 8rem; flex: none; font-size: 0.85rem; color: var(--muted); }
.lane-track {
  position: relative;
  flex: 1;
  height: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.bar {
  position: absolute;
  top: 3px;
  bottom: 3px;
  background: var(--c);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  opacity: 0.9;
}
.plan-steps { list-style: none; padding: 0; margin: 1rem 0; }
.plan-steps li {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.plan-steps li .swatch { margin-top: 0.35rem; }
.plan-steps li p { margin: 0; }
.plan-steps li.passive > div > p:last-child { color: var(--muted); }
.plan-time { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 3.5rem; }
.recipe-tag { background: var(--text); color: #fff; }
.allocation { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; }
.allocation legend { font-weight: 600; }

.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border: 2px dashed var(--text);
  border-radius: 8px;
  padding: 0.75rem;
  background: #fff;
  break-inside: avoid;
}
.label strong { font-size: 1.1rem; }
.label-limit { font-weight: 700; }
@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  .container { padding: 0; max-width: none; }
}

/* --- Recommendations --- */
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.tab {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.tab.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.ideas { list-style: none; padding: 0; display: grid; gap: 0.75rem; }
.ideas .tag { background: var(--bg); color: var(--muted); }
.proposal .plan-time { min-width: 9rem; }

pre.log {
  white-space: pre-wrap;
  font-size: 0.85rem;
  max-height: 12rem;
  overflow: auto;
}

/* Leclerc product thumbnails */
img.thumb {
  width: 3.5rem;
  height: 3.5rem;
  flex: none;
  object-fit: contain;
  background: #fff;
  border-radius: 0.4rem;
}
.chosen-products > summary { cursor: pointer; padding: 0.75rem 0; font-weight: 600; }
.stock-list li > img.thumb + .stock-main { flex: 1; min-width: 10rem; }

/* "Ajouter au planning" on a recipe */
.add-to-plan { margin: 0.75rem 0; }
.add-to-plan > summary { display: inline-block; list-style: none; }
.add-to-plan > summary::-webkit-details-marker { display: none; }
.add-to-plan form { margin-top: 0.75rem; }
.plan-slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.plan-slot-day { display: flex; flex-direction: column; gap: 0.25rem; }
.plan-slot-date { font-weight: 600; font-size: 0.9rem; }
.plan-slot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  min-height: 3rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.plan-slot span { font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.plan-slot.taken { background: transparent; border-color: var(--border); color: inherit; }

/* Assistant */
.assistant-summary { white-space: pre-line; margin: 0.35rem 0; }
.assistant-actions { margin: 0.25rem 0 0; padding-left: 1.1rem; font-size: 0.9rem; }
.assistant-requests details summary { cursor: pointer; color: var(--muted); }
.assistant-form .chip { text-align: left; }

/* Drive from the phone */
.code-box { display: block; width: 100%; margin: 0.4rem 0; font: 0.75rem/1.3 ui-monospace, monospace; word-break: break-all; }
.steps li { margin-bottom: 0.6rem; }

/* --- Catalogue --- */
.topbar .count {
  display: inline-block;
  min-width: 1.3rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}

.more-menu { position: relative; }
.more-menu summary { list-style: none; }
.more-menu summary::-webkit-details-marker { display: none; }
.more-menu-items {
  position: absolute;
  right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  min-width: 15rem;
  margin-top: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
}
.more-menu-items a { padding: 0.75rem 1rem; text-decoration: none; }
.more-menu-items a + a { border-top: 1px solid var(--border); }

.tabs { display: flex; gap: 0.25rem; margin: 0.75rem 0 0; border-bottom: 1px solid var(--border); }
.tabs a {
  padding: 0.6rem 0.9rem;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
}
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a span { font-weight: 400; font-size: 0.85rem; }

.catalogue-filters { margin: 0.75rem 0 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.search-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.search-row input { flex: 1 1 220px; }
.filter-chips {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}
.filter-chip { flex: none; cursor: pointer; position: relative; }
.filter-chip input { position: absolute; opacity: 0; pointer-events: none; }
.filter-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 0.9rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.9rem;
  white-space: nowrap;
}
.filter-chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.dish-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 640px) { .dish-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .dish-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1400px) { .dish-grid { grid-template-columns: repeat(4, 1fr); } }

.dish-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.dish-card.chosen { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.dish-photo { position: relative; display: block; aspect-ratio: 16 / 10; background: var(--accent-soft); }
.dish-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dish-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 3.5rem;
}
.dish-labels {
  position: absolute;
  left: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.dish-labels.static { position: static; margin: 0.5rem 0; }
.dish-label {
  padding: 0.15rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.15);
}
.dish-label.protein { background: #1f4e79; color: #fff; }
.dish-label.calorie { background: #3f7d20; color: #fff; }
.dish-label.quick { background: #fff1c1; color: #6b4d00; }
.dish-label.veggie { background: #d9ead3; color: #2c5a1f; }
.dish-label.freezer { background: #dbe7f5; color: #1f4e79; }
.dish-label.season { background: #b4541a; color: #fff; }
.dish-label.new { background: #6c3fb5; color: #fff; }

.dish-body { display: flex; flex-direction: column; flex: 1; gap: 0.3rem; padding: 0.75rem 0.9rem 0.9rem; }
.dish-body h2 { margin: 0; font-size: 1.1rem; line-height: 1.3; }
.dish-body h2 a { color: inherit; text-decoration: none; }
.dish-desc {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dish-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.7rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}
.dish-pick { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-top: auto; padding-top: 0.5rem; }
.dish-pick form { margin: 0; }
.dish-servings { min-width: 5.5rem; text-align: center; }
.dish-chosen { margin-left: auto; color: var(--accent); font-weight: 700; }

.cart-bar {
  position: sticky;
  bottom: 0;
  z-index: 4;
  padding: 0.75rem 0 calc(0.25rem + env(safe-area-inset-bottom, 0px));
}
.cart-bar:not(:has(a)) { display: none; }
.cart-bar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 56px;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
}
.cart-bar-go { font-weight: 700; white-space: nowrap; }
.more-recipes { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin: 1.5rem 0; }

/* Selection & À cuisiner */
.pick-list { list-style: none; padding: 0; margin: 1rem 0; display: flex; flex-direction: column; gap: 0.75rem; }
.pick-row {
  display: flex;
  gap: 0.9rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pick-thumb {
  flex: none;
  width: 96px;
  height: 72px;
  border-radius: 8px;
  overflow: hidden;
  display: block;
  background: var(--accent-soft);
}
.pick-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick-thumb .dish-fallback { font-size: 2rem; }
.pick-main { flex: 1; min-width: 0; }
.pick-title { font-weight: 700; color: inherit; text-decoration: none; }
.pick-main .meta { font-size: 0.9rem; }
.pick-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.4rem; }
.pick-actions form { margin: 0; }
.button.small { min-height: 36px; padding: 0.25rem 0.75rem; font-size: 0.9rem; }
.pick-summary {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.pick-summary p { margin: 0 0 0.5rem; }
.inline-menu > summary { list-style: none; }
.inline-menu > summary::-webkit-details-marker { display: none; }
.inline-menu[open] { flex-basis: 100%; order: 10; }
.inline-menu[open] > summary { background: var(--accent-soft); }
.inline-menu form { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.done-form .check-line { flex-basis: 100%; display: flex; }
.batch-check { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--muted); min-height: 44px; }
.batch-launch { margin: 1rem 0; }
@media (max-width: 480px) {
  .pick-thumb { width: 72px; height: 56px; }
}

/* Recipe detail hero */
.recipe-hero { display: grid; gap: 1rem; margin: 0.75rem 0; }
.recipe-hero-photo {
  aspect-ratio: 16 / 10;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--accent-soft);
}
.recipe-hero-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recipe-hero-photo .dish-fallback { font-size: 5rem; }
.lead { font-size: 1.1rem; margin: 0 0 0.5rem; }
.photo-change { margin-top: 0.75rem; }
.photo-change summary { cursor: pointer; }
.photo-change form { margin-top: 0.5rem; }
@media (min-width: 800px) {
  .recipe-hero { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
}

.recipe-form .months { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.9rem; }
.dish-generated {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.85);
  font-size: 0.75rem;
  color: var(--muted);
}
.recipe-hero-photo { position: relative; }

.plating { margin-top: 1rem; padding: 0.75rem 1rem; background: var(--accent-soft); border-radius: var(--radius); }
.plating p { margin: 0.25rem 0 0; }
