:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --text: #22201c;
  --muted: #6f6a61;
  --line: #e4ded3;
  --accent: #2f7d4f;
  --accent-soft: #e3f1e8;
  --warn: #b4442c;
  --warn-soft: #fbe9e4;
  --slot-base: #d9a441;
  --slot-protein: #c0573e;
  --slot-veg: #4f9a5c;
  --slot-sauce: #7a5aa6;
  --slot-topping: #8a7d6b;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171614;
    --surface: #211f1c;
    --surface-2: #1c1a18;
    --text: #ece8e1;
    --muted: #a39d92;
    --line: #34312c;
    --accent: #5fbf83;
    --accent-soft: #1f3327;
    --warn: #f08a72;
    --warn-soft: #3a221c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.top { padding: 14px 16px 4px; max-width: 1400px; margin: 0 auto; }
.top h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.01em; }
.sub { margin: 4px 0 0; color: var(--muted); }

main { max-width: 1400px; margin: 0 auto; padding: 12px 16px 40px; }

/* ---- week ---------------------------------------------------------- */
.week {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
}

.day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, box-shadow .15s;
}
.day.is-trip { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.day.is-empty { opacity: .85; }

.day-head { display: flex; align-items: center; justify-content: space-between; }
.day-head h2 { margin: 0; font-size: 1rem; }

.shop-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .85rem; color: var(--muted);
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
.shop-toggle input { accent-color: var(--accent); margin: 0; }
.day.is-trip .shop-toggle { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }

.meal { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.meal-head { display: flex; flex-direction: column; }
.meal-type { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.eaters { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 2px; }
.chip { font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--line); color: var(--muted); }
.chip.adult { background: var(--accent-soft); color: var(--accent); }
.chip.extra { background: transparent; border: 1px dashed var(--line); }

details summary { cursor: pointer; font-size: .82rem; color: var(--muted); margin-top: 4px; }

.portions { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: .8rem; font-variant-numeric: tabular-nums; }
.portions th, .portions td { padding: 2px 4px; text-align: right; }
.portions th:first-child { text-align: left; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.portions thead th { color: var(--muted); font-weight: 600; }
.portions .macros tr:first-child th, .portions .macros tr:first-child td { border-top: 1px solid var(--line); padding-top: 4px; }
.portions .macros th { color: var(--muted); }
.portions td.miss { color: var(--warn); background: var(--warn-soft); border-radius: 4px; }

.slot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.slot-base { background: var(--slot-base); }
.slot-protein { background: var(--slot-protein); }
.slot-veg { background: var(--slot-veg); }
.slot-sauce { background: var(--slot-sauce); }
.slot-topping { background: var(--slot-topping); }

.empty { color: var(--muted); font-size: .85rem; margin: 0; }

/* ---- shopping ------------------------------------------------------ */
.shopping { margin-top: 28px; }
.shopping > h2 { font-size: 1.2rem; margin: 0 0 10px; }

.error { background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: 8px; }

.trips { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }

.trip { background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; }
.trip h3 { margin: 0 0 4px; display: flex; justify-content: space-between; align-items: baseline; }
.count { font-size: .8rem; font-weight: 400; color: var(--muted); }
.trip h4 { margin: 12px 0 4px; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.items, .staples { list-style: none; margin: 0; padding: 0; }
.items li { border-bottom: 1px solid var(--line); }
.items li:last-child { border-bottom: 0; }
.items label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "box name qty" "box need need";
  column-gap: 8px;
  padding: 6px 0;
  cursor: pointer;
}
.items input { grid-area: box; accent-color: var(--accent); margin-top: 3px; }
.items .name { grid-area: name; }
.items .qty { grid-area: qty; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.items .need { grid-area: need; }
.need { font-size: .75rem; color: var(--muted); }
.items input:checked ~ .name, .items input:checked ~ .qty { text-decoration: line-through; color: var(--muted); }

.staples li { padding: 2px 0; font-size: .9rem; }
.covered { font-size: .8rem; color: var(--muted); margin: 10px 0 0; }

/* ---- nav ----------------------------------------------------------- */
.nav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.nav a {
  color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 999px;
  font-size: .9rem; font-weight: 500;
}
.nav a:hover { background: var(--line); color: var(--text); }
.nav a.active { background: var(--text); color: var(--bg); }

/* ---- buttons & form controls --------------------------------------- */
button, .btn, select, input[type="text"], input[type="number"], input[type="password"] {
  font: inherit; color: var(--text);
}
select, input[type="text"], input[type="number"], input[type="password"] {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px;
  max-width: 100%;
}
select:focus, input:focus, button:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn, button.primary {
  display: inline-flex; align-items: center; gap: 4px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 5px 12px; font-size: .88rem;
}
.btn:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.primary { color: #0e1a12; } }
.btn.danger { color: var(--warn); }
button.icon {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 1.15rem; line-height: 1; padding: 2px 6px; border-radius: 4px;
}
button.icon:hover { background: var(--warn-soft); color: var(--warn); }
button.icon.small { font-size: 1rem; padding: 0 4px; }

/* ---- plan additions ------------------------------------------------ */
.meal-head { flex-direction: row; justify-content: space-between; align-items: flex-start; gap: 6px; }
.meal-head > div { display: flex; flex-direction: column; }
.meal.is-foods { border-style: dashed; }

.swaps { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 2px; }
.swap label { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .8rem; }
.swap-label { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swap select { font-size: .8rem; padding: 2px 6px; max-width: 60%; }
.swap.swapped select { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.foods { list-style: none; margin: 6px 0 2px; padding: 0; font-size: .85rem; }
.foods li { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 6px; padding: 2px 0; }

.add-row { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }
details.add > summary {
  list-style: none; font-size: .82rem; color: var(--accent); font-weight: 600; cursor: pointer;
  padding: 4px 0;
}
details.add > summary::-webkit-details-marker { display: none; }
.add-form { display: flex; flex-direction: column; gap: 8px; padding: 8px; margin-top: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; font-size: .85rem; }
.add-form > label, .pair label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
.add-form select, .add-form input[type="number"] { width: 100%; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.eaters-pick { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.eaters-pick legend { color: var(--muted); padding: 0; margin-bottom: 2px; width: 100%; }
.eaters-pick label { display: inline-flex; gap: 4px; align-items: center; }
.eaters-pick input { accent-color: var(--accent); }
.error.small { font-size: .78rem; padding: 4px 8px; margin: 6px 0 0; }

/* ---- recipes page -------------------------------------------------- */
.recipes-layout { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 1.6fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .recipes-layout { grid-template-columns: 1fr; } .recipe-form { order: -1; } }

.recipe-list { display: flex; flex-direction: column; gap: 10px; }
.recipe-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.recipe-card header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.recipe-card h2 { margin: 0; font-size: 1rem; }
.actions { display: flex; gap: 6px; }
.comp-list { list-style: none; margin: 8px 0 4px; padding: 0; font-size: .85rem; }
.comp-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.comp-list li:last-child { border-bottom: 0; }
.comp-name { font-weight: 500; }
.subs { flex-basis: 100%; padding-left: 14px; font-size: .78rem; color: var(--accent); }

.notice { background: var(--accent-soft); color: var(--accent); padding: 8px 12px; border-radius: 8px; margin: 0; }
.error ul { margin: 0; padding-left: 18px; }

.recipe-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.recipe-form h2 { margin: 0 0 10px; font-size: 1.1rem; }
.name-field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.name-field input { font-size: 1rem; padding: 7px 10px; }
.table-scroll { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
.comp-table { border-collapse: collapse; width: 100%; min-width: 720px; font-size: .85rem; }
.comp-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .75rem; padding: 4px; }
.comp-table td { padding: 4px; vertical-align: top; }
.comp-table input[type="number"] { width: 72px; }
.comp-table td:nth-child(2) select { width: 100%; min-width: 180px; }
.comp-table select[multiple] { width: 100%; min-width: 160px; font-size: .78rem; }
.hint { font-size: .78rem; color: var(--muted); margin: 8px 0; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.spacer { flex: 1; }

/* ---- view switch --------------------------------------------------- */
.nav-settings { margin-left: auto; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--line); border-radius: 999px; padding: 3px; }
.segmented a {
  padding: 5px 14px; border-radius: 999px; text-decoration: none; color: var(--muted);
  font-size: .88rem; font-weight: 600;
}
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* ---- week overview ------------------------------------------------- */
.day-head h2 a { color: inherit; text-decoration: none; }
.day-head h2 a:hover { color: var(--accent); text-decoration: underline; }

.slot-list { margin: 0; display: flex; flex-direction: column; }
.slot-row {
  display: grid; grid-template-columns: 74px 1fr; gap: 8px; align-items: baseline;
  padding: 5px 0; border-top: 1px solid var(--line);
}
.slot-row:first-child { border-top: 0; }
.slot-row dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.slot-row dd { margin: 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.meal-name { font-size: .9rem; font-weight: 500; }
.meal-name.is-foods { font-weight: 400; color: var(--muted); font-style: italic; }
.swap-tag, .err-tag {
  display: inline-block; margin-left: 6px; font-size: .65rem; font-weight: 700; font-style: normal;
  text-transform: uppercase; letter-spacing: .04em; padding: 0 5px; border-radius: 4px; vertical-align: 1px;
}
.swap-tag { background: var(--accent-soft); color: var(--accent); }
.err-tag { background: var(--warn-soft); color: var(--warn); }
.add-link {
  color: var(--muted); text-decoration: none; font-size: .9rem; width: 22px; text-align: center;
  border: 1px dashed var(--line); border-radius: 5px; line-height: 18px;
}
.add-link:hover { color: var(--accent); border-color: var(--accent); }

.totals { width: 100%; border-collapse: collapse; font-size: .78rem; font-variant-numeric: tabular-nums; margin-top: auto; }
.totals th, .totals td { padding: 2px 4px; text-align: right; }
.totals thead th { color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
.totals tbody th { text-align: left; font-weight: 600; }
.totals .of { color: var(--muted); font-size: .9em; }
.day .totals { border-top: 1px solid var(--line); padding-top: 4px; }

/* ---- day detail ---------------------------------------------------- */
.day-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.day-strip a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px;
  text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; font-size: .85rem;
}
.day-strip a:hover { border-color: var(--accent); }
.day-strip a.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.day-strip a.is-trip:not(.active) { border-color: var(--accent); }
.dname { font-weight: 600; }
.dmeta { font-size: .72rem; opacity: .75; display: flex; gap: 3px; align-items: center; }
.cart { font-size: .8rem; }

.day-detail {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.day-detail.is-trip { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.day-detail .day-head h2 { font-size: 1.15rem; }
.slot-sections { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; margin-top: 12px; }
.slot-section {
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  scroll-margin-top: 12px;
}
.slot-section:target { border-color: var(--accent); }
.slot-section h3 { margin: 0; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.slot-section .meal { background: var(--surface); }
.day-totals { margin-top: 14px; max-width: 420px; }
.day-totals h3 { margin: 0 0 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.day-totals .totals { font-size: .88rem; }

/* ---- settings ------------------------------------------------------ */
.settings { max-width: 560px; display: flex; flex-direction: column; gap: 10px; }
.settings-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; cursor: pointer; }
.setting-text { display: flex; flex-direction: column; gap: 2px; }
.switch {
  appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--line);
  position: relative; cursor: pointer; flex-shrink: 0; transition: background .15s; margin: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(18px); }

/* ---- nutrient totals ----------------------------------------------- */
.unit { font-size: .8em; font-weight: 400; color: var(--muted); }
.totals thead th.kid { font-weight: 500; }
.totals td { vertical-align: top; }
.bar { display: block; height: 3px; margin-top: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.bar.over i { background: var(--warn); }

/* ---- family page --------------------------------------------------- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin-top: 10px; }
.person-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.person-card.is-new { border-style: dashed; background: var(--surface-2); }
.person-top { display: flex; align-items: center; gap: 10px; }
.person-name { flex: 1; font-size: 1.05rem; font-weight: 600; padding: 6px 10px; min-width: 0; }
.child-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); cursor: pointer; }
.person-card h4 { margin: 0 0 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.target-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.target-grid label { display: flex; flex-direction: column; gap: 2px; font-size: .82rem; }
.target-grid input { width: 100%; }
.scale-field { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; }
.scale-input { display: flex; align-items: center; gap: 8px; }
.scale-input input { width: 90px; }
.person-card .hint { margin: 6px 0 0; }
.person-card .form-actions { margin-top: auto; }
/* Child switch shows portion size instead of targets (no JS needed). */
.person-card:has(input[name="is_child"]:checked) .adult-only { display: none; }
.person-card:not(:has(input[name="is_child"]:checked)) .child-only { display: none; }

.tracked { margin-top: 24px; max-width: 900px; }
.tracked h2 { margin: 0; font-size: 1.1rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip-toggle { cursor: pointer; }
.chip-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.chip-toggle > span {
  display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: .88rem;
}
.chip-toggle input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip-toggle input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- cooking ------------------------------------------------------- */
.warn { background: #fff4d6; color: #8a5a00; padding: 4px 8px; border-radius: 6px; margin: 6px 0 0; }
@media (prefers-color-scheme: dark) { .warn { background: #3a2f12; color: #f0c56a; } }
.warn-tag { display: inline-block; margin-left: 6px; font-size: .65rem; font-weight: 700; padding: 0 5px; border-radius: 4px; background: #fff4d6; color: #8a5a00; vertical-align: 1px; }
@media (prefers-color-scheme: dark) { .warn-tag { background: #3a2f12; color: #f0c56a; } }
.notice.subtle { background: var(--surface-2); color: var(--muted); font-size: .85rem; }

.cook-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.cook-chip { font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.cook-chip.short { border-color: var(--warn); color: var(--warn); }

.cooking { margin-top: 12px; padding: 10px; border: 1px dashed var(--line); border-radius: 8px; display: flex; flex-direction: column; gap: 8px; }
.cooking > h3 { margin: 0; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.cook-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-width: 720px; }
.cook-card.short { border-color: var(--warn); }
.cook-summary { margin: 4px 0; font-size: .9rem; }
.consumers { list-style: none; margin: 4px 0; padding: 0; font-size: .85rem; }
.consumers li { padding: 1px 0; }
.cook-items { border-collapse: collapse; width: 100%; font-size: .85rem; margin: 6px 0; }
.cook-items th { text-align: left; font-size: .72rem; color: var(--muted); font-weight: 600; padding: 2px 4px; }
.cook-items td { padding: 2px 4px; }
.cook-items td:first-child input { width: 100%; min-width: 160px; }
.cook-items input[type="number"] { width: 80px; }
.cook-settings { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 8px 0; font-size: .85rem; align-items: flex-start; }
.cook-settings > label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
.size-mode { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.size-mode legend { color: var(--muted); padding: 0; margin-bottom: 2px; }
.size-mode label { display: flex; align-items: center; gap: 6px; }
input.tiny { width: 64px; padding: 2px 6px; }
.btn.small { font-size: .8rem; padding: 3px 10px; }
.add-form.inline { flex-direction: row; flex-wrap: wrap; align-items: center; }

.items-table { min-width: 0; }
.items-table td:first-child input { width: 100%; min-width: 180px; }
.items-table input[type="number"] { width: 90px; }
.recipe-meta { display: flex; flex-wrap: wrap; gap: 12px 24px; margin: 12px 0 8px; font-size: .85rem; }
.recipe-meta label { display: flex; flex-direction: column; gap: 2px; color: var(--muted); }
.recipe-meta input { width: 80px; }
.comp-table input[type="text"] { width: 100%; min-width: 180px; }

/* ---- ingredients page ---------------------------------------------- */
.ingredients-layout { grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr); }
@media (max-width: 900px) { .ingredients-layout { grid-template-columns: 1fr; } }
.ing-filter { width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; margin-bottom: 8px; }
.ing-group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px; overflow-x: auto; }
.ing-group h3 { margin: 4px 0; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ing-group.unlisted { border-style: dashed; }
.ing-table { width: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.ing-table th { font-size: .72rem; color: var(--muted); font-weight: 600; text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line); }
.ing-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: baseline; }
.ing-table tr:last-child td { border-bottom: 0; }
.ing-table .num { text-align: right; white-space: nowrap; }
.ing-table .pack, .ing-table .basis { white-space: nowrap; }
.ing-table .source { font-size: .72rem; max-width: 220px; }
.ing-name { color: var(--text); font-weight: 500; text-decoration: none; margin-right: 6px; }
.ing-name:hover { color: var(--accent); text-decoration: underline; }

.ing-form { position: sticky; top: 12px; }
@media (max-width: 900px) { .ing-form { position: static; } }
.ing-form h4 { margin: 14px 0 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.grid-2, .grid-3, .grid-5 { display: grid; gap: 8px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 520px) { .grid-3, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ing-form label { display: flex; flex-direction: column; gap: 2px; font-size: .8rem; color: var(--muted); min-width: 0; }
.ing-form input, .ing-form select { width: 100%; }
.lookup-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.source { font-size: .75rem; }
.candidates { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.chip-btn { font: inherit; font-size: .78rem; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); cursor: pointer; }
.chip-btn:hover { border-color: var(--accent); }
.more-nutrients { margin-top: 8px; }
.more-nutrients summary { font-size: .82rem; color: var(--muted); cursor: pointer; margin-bottom: 6px; }
.checks { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.checks label { flex-direction: row; align-items: center; gap: 6px; font-size: .85rem; color: var(--text); }
.checks input { width: auto; accent-color: var(--accent); }

.setting.stacked { flex-direction: column; align-items: stretch; cursor: default; }
.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; font-family: ui-monospace, monospace; }
.settings-form + .settings-form { margin-top: 10px; }

/* ---- stock --------------------------------------------------------- */
.done-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.done-btn { border-color: var(--accent); color: var(--accent); }
.done-tag { display: inline-block; margin-left: 6px; font-size: .68rem; font-weight: 700; padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; }
.meal.is-done, .cook-card.is-done { opacity: .7; }
.meal-name.is-done { color: var(--muted); }
.cook-chip.is-done { opacity: .7; }

.trip-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }

.stock-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.stock-bar .ing-filter { flex: 1; min-width: 180px; margin: 0; }
.segmented .count { font-weight: 400; opacity: .7; margin-left: 2px; }
.stock-table { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.stock-table th { font-size: .72rem; color: var(--muted); font-weight: 600; text-align: left; padding: 3px 6px; border-bottom: 1px solid var(--line); }
.stock-table td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.stock-table tr:last-child td { border-bottom: 0; }
.stock-table tr.is-short td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.stock-table tr.is-have td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.stock-table .have, .stock-table .needcol { white-space: nowrap; }
.short-tag { display: inline-block; font-size: .7rem; font-weight: 700; padding: 0 6px; border-radius: 4px; background: var(--warn-soft); color: var(--warn); margin-left: 4px; }
.ok-tag { color: var(--accent); font-weight: 700; margin-left: 4px; }
.stock-controls form { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; justify-content: flex-end; }
.stock-controls .btn.small { min-width: 30px; justify-content: center; }
.stock-controls .btn:disabled { opacity: .4; cursor: default; }
.btn.subtle { color: var(--muted); }
.set-group { display: inline-flex; gap: 4px; align-items: center; }
.set-group input { width: 72px; padding: 3px 6px; }
.set-group select { padding: 3px 6px; max-width: 120px; }
.stock-controls-h { text-align: right !important; }
@media (max-width: 700px) {
  .stock-table thead { display: none; }
  .stock-table tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
  .stock-table td { border: 0; padding: 2px 6px; }
  .stock-table td.stock-controls { grid-column: 1 / -1; }
  .stock-controls form { justify-content: flex-start; }
}
@media (min-width: 701px) {
  .stock-table { table-layout: fixed; }
  .stock-table th:nth-child(1) { width: 34%; }
  .stock-table th:nth-child(2) { width: 18%; }
  .stock-table th:nth-child(3) { width: 18%; }
  .stock-table th:nth-child(4) { width: 30%; }
  .stock-table td:first-child { overflow: hidden; text-overflow: ellipsis; }
}

/* ---- leftovers / coverage ----------------------------------------- */
.coverage { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line); margin: 6px 0; max-width: 420px; }
.coverage i { display: block; height: 100%; }
.coverage .eaten { background: var(--muted); opacity: .5; }
.coverage .planned { background: var(--accent); }
.coverage .spare { background: repeating-linear-gradient(45deg, var(--accent-soft), var(--accent-soft) 4px, transparent 4px, transparent 8px); border: 1px solid var(--accent); box-sizing: border-box; }
.spare-box { margin: 6px 0; padding: 8px; border: 1px dashed var(--accent); border-radius: 8px; background: var(--surface); }
.spare-box p { margin: 0 0 6px; font-size: .88rem; }
.spare-box .add-form { padding: 0; background: none; border: 0; margin: 0; }
.cook-chip b { color: var(--accent); font-weight: 700; }
.leftovers { border-color: var(--accent); }

/* ---- dates --------------------------------------------------------- */
.date-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-nav h1 { margin: 0; }
.nav-arrow { font-size: 1.1rem; padding: 2px 10px; line-height: 1.2; }
.today-tag { display: inline-block; font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 1px 6px; border-radius: 4px; background: var(--text); color: var(--bg); vertical-align: 3px; }
.dnum { font-weight: 400; color: var(--muted); font-size: .85em; }
.day.is-today { outline: 2px solid var(--text); outline-offset: -1px; }
.day-strip a.is-today:not(.active) { outline: 2px solid var(--text); outline-offset: -2px; }
.carried { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; font-size: .85rem; }
.settings .chips { margin-top: 6px; }
.settings select { margin-top: 4px; max-width: 200px; }

/* ---- per-person ---------------------------------------------------- */
.eaters form { display: inline; }
.eat-chip { border: 1px solid transparent; cursor: pointer; font: inherit; font-size: .75rem; }
.eat-chip:hover { border-color: var(--accent); }
.eat-chip.ate { background: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .eat-chip.ate { color: #0e1a12; } }
.aud-tag { display: inline-block; margin-left: 6px; font-size: .65rem; font-weight: 600; padding: 0 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); vertical-align: 1px; }
.presets { float: right; display: inline-flex; gap: 6px; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-size: .78rem; color: var(--accent); cursor: pointer; text-decoration: underline; }
.eaters-edit { width: 100%; }
.eaters-edit summary { cursor: pointer; font-size: .78rem; }
.person-filter select { padding: 4px 8px; border-radius: 999px; }
.title-row { gap: 8px; }
.slots-pick h4 { margin: 0 0 6px; }
.slots-pick .chips { margin: 0; }
.slots-pick .chip-toggle > span { padding: 3px 10px; font-size: .8rem; }

/* ---- shopping page ------------------------------------------------- */
.trip-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 10px; padding-bottom: 2px; }
.trip-tabs a {
  flex: 1 0 auto; min-width: 96px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); text-decoration: none;
}
.trip-tabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .trip-tabs a.active { color: #0e1a12; } }
.trip-tabs .dmeta { font-size: .75rem; opacity: .8; }

.shop-add { display: grid; grid-template-columns: 1fr 70px auto auto; gap: 6px; margin-bottom: 14px; }
.shop-add input, .shop-add select { padding: 10px; font-size: 1rem; border-radius: 8px; }
.shop-add .primary { padding: 0 16px; font-size: 1rem; }
@media (max-width: 520px) {
  .shop-add { grid-template-columns: 1fr 64px; }
  .shop-add select { grid-column: 1; }
  .shop-add .primary { grid-column: 2; }
}

.shop-aisle { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; margin-bottom: 10px; }
.shop-aisle h3 { margin: 6px 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.shop-list { list-style: none; margin: 0; padding: 0; }
.shop-list li { display: flex; align-items: center; border-top: 1px solid var(--line); }
.shop-list li:first-child { border-top: 0; }
.shop-item { flex: 1; min-width: 0; }
.shop-tick {
  width: 100%; display: grid; grid-template-columns: 28px 1fr auto; grid-template-areas: "box name qty" "box note note";
  column-gap: 10px; align-items: center; text-align: left; padding: 12px 4px; min-height: 52px;
  background: none; border: 0; color: var(--text); font: inherit; font-size: 1.02rem; cursor: pointer;
}
.shop-tick .box {
  grid-area: box; width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--muted);
  display: grid; place-items: center; font-weight: 700; color: #fff;
}
.shop-name { grid-area: name; }
.shop-qty { grid-area: qty; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.shop-note { grid-area: note; font-size: .75rem; color: var(--muted); }
.extra-tag { font-size: .65rem; font-weight: 600; padding: 0 5px; border-radius: 4px; border: 1px dashed var(--line); color: var(--muted); vertical-align: 2px; }
.is-checked .box { background: var(--accent); border-color: var(--accent); }
.is-checked .shop-name, .is-checked .shop-qty { text-decoration: line-through; color: var(--muted); }
.trolley { opacity: .85; }
.shop-del button { font-size: 1.3rem; padding: 8px 10px; }
.staples-box summary { cursor: pointer; padding: 6px 4px; color: var(--muted); font-size: .9rem; }
.staples-box ul { margin: 4px 0 8px; padding-left: 20px; }
.empty.big { font-size: 1.05rem; text-align: center; padding: 20px 0; }

.shop-done-bar { position: sticky; bottom: 0; padding: 10px 0 6px; background: linear-gradient(transparent, var(--bg) 30%); }
.shop-done-bar .primary.big { width: 100%; justify-content: center; padding: 14px; font-size: 1.05rem; border-radius: 12px; }

/* plan page summary */
.shopping > h2 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trip-summaries { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.trip-summary {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent);
  color: var(--text); text-decoration: none;
}
.trip-summary:hover { border-color: var(--accent); }
.trip-peek { font-size: .82rem; color: var(--muted); }
main.page-shopping { max-width: 760px; }

/* ---- compact shopping rows ------------------------------------------ */
.shop-list li { display: block; }
.srow { display: grid; grid-template-columns: 40px 1fr; align-items: start; }
.stick { display: flex; }
.stick .box {
  margin: 8px 6px; width: 24px; height: 24px; border-radius: 6px; border: 2px solid var(--muted);
  background: none; color: #fff; font-weight: 700; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.is-checked .stick .box { background: var(--accent); border-color: var(--accent); }
.sdetail > summary {
  list-style: none; display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  padding: 9px 4px 9px 0; cursor: pointer; min-height: 40px;
}
.sdetail > summary::-webkit-details-marker { display: none; }
.sdetail > summary::after { content: "›"; color: var(--muted); transition: transform .15s; margin-left: 2px; }
.sdetail[open] > summary::after { transform: rotate(90deg); }
.sname { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sqty { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; margin-left: auto; }
.is-checked .sname, .is-checked .sqty { text-decoration: line-through; color: var(--muted); }
.sbody { padding: 2px 4px 10px 0; font-size: .85rem; display: flex; flex-direction: column; gap: 4px; }
.sline { display: grid; grid-template-columns: 84px 1fr; gap: 8px; }
.slabel { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; padding-top: 1px; }
.suses { list-style: none; margin: 0; padding: 0; }
.suses li { padding: 0; border: 0; }
.sdel { margin-top: 4px; }

/* ---- intake: adjusted eating, food log, intake page --------------- */
.eat-chip .adj, .adjust summary b, .intake-items .adj { font-weight: 700; }
.eat-chip.adjusted { box-shadow: inset 0 0 0 1px var(--warn); }
.adjusts { display: flex; flex-wrap: wrap; gap: 2px 10px; }
.adjust summary { font-size: .75rem; margin-top: 2px; }
.adjust[open] { flex-basis: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px 8px; }
.adj-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .chip-btn.on { color: #0e1a12; } }
.adj-grams table { width: 100%; border-collapse: collapse; font-size: .82rem; margin-bottom: 6px; }
.adj-grams th { text-align: left; font-weight: 500; padding: 2px 4px 2px 0; }
.adj-grams td { padding: 2px 0; white-space: nowrap; }
.adj-grams input { width: 64px; }
.adj-grams tr.changed th { color: var(--warn); }

.food-log { margin-top: 14px; max-width: 560px; }
.food-log h3 { margin: 0 0 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.log-list { list-style: none; margin: 0 0 6px; padding: 0; font-size: .88rem; }
.log-list li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.log-line { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 6px; }
.log-what { min-width: 0; overflow-wrap: anywhere; }
.log-edit summary { font-size: .75rem; margin: 0; }
.add-form label.check { flex-direction: row; align-items: center; gap: 6px; align-self: end; padding-bottom: 6px; }

.intake-summary { max-width: 360px; margin-bottom: 12px; }
.intake-summary h3 { margin: 0 0 4px; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.intake-items { list-style: none; margin: 0; padding: 0; font-size: .82rem; display: flex; flex-direction: column; gap: 2px; }
.intake-items .not-eaten { opacity: .65; }

/* ---- week across one screen ---------------------------------------- */
.lead-in { margin: 0 0 8px; }
@media (min-width: 760px) {
  main.page-plan { max-width: none; }
  .week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
  .week .day { padding: 8px; gap: 6px; min-width: 0; }
  .week .day-head { flex-wrap: wrap; gap: 4px; }
  .week .day-head h2 { font-size: .88rem; }
  .week .day-head .dnum { display: block; font-size: .78rem; }
  .week .shop-toggle { padding: 2px 6px; font-size: .72rem; }
  .week .slot-row { grid-template-columns: 1fr; gap: 0; padding: 4px 0; }
  .week .slot-row dt { font-size: .62rem; }
  .week .meal-name { font-size: .8rem; line-height: 1.25; overflow-wrap: anywhere; }
  .week .aud-tag, .week .swap-tag, .week .warn-tag, .week .err-tag { margin-left: 3px; }
  .week .cook-chip { font-size: .68rem; padding: 0 6px; }
  .week .totals { font-size: .66rem; }
  .week .totals th, .week .totals td { padding: 1px 2px; }
  .week .totals .unit { display: none; }
}

/* ---- pack units on the ingredient form ------------------------------- */
#ing-form .ea-only, #ing-form .vol-only { display: none; }
#ing-form:has(select[name="pack_unit"] option[value="ea"]:checked) .ea-only { display: flex; }
#ing-form:has(select[name="pack_unit"] option[value="ml"]:checked) .vol-only,
#ing-form:has(select[name="pack_unit"] option[value="L"]:checked) .vol-only { display: flex; }

/* ---- adjustable shopping text (Settings) ------------------------------ */
.shop-text .sname { font-size: var(--shop-fs, 1.12rem); font-weight: var(--shop-fw, 500); }
.shop-text .sqty { font-size: var(--shop-fs, 1.12rem); font-weight: max(600, var(--shop-fw, 500)); }
/* Keep rows about the same height as text grows: less padding, tighter line height. */
.shop-text .sdetail > summary { padding: 6px 4px 6px 0; line-height: 1.25; align-items: center; }
.shop-preview { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; margin-top: 8px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }

/* ---- login & account ---------------------------------------------- */
.login { max-width: 360px; margin: 8vh auto 0; display: grid; gap: 14px; }
.login h1 { margin: 0; }
.login form, .account-form { display: grid; gap: 10px; }
.login label, .account-form label { display: grid; gap: 4px; font-size: .88rem; color: var(--muted); }
.login input, .account-form input { font-size: 1rem; padding: 8px 10px; }
.login button.primary { justify-content: center; padding: 10px; font-size: 1rem; }
.account-form { padding: 0 14px 14px; max-width: 360px; }
.account-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; }
