:root {
  --bg: #fbf9f5;
  --surface: #ffffff;
  --surface-2: #f4f1ea;
  --ink: #1e1c19;
  --ink-2: #55504a;
  --ink-3: #8a837a;
  --line: #e2ddd3;
  --accent: #2f6f4e;
  --accent-soft: #e6f0e9;
  --warn: #a2542a;
  --warn-soft: #f7ece3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(30,28,25,.05), 0 4px 16px rgba(30,28,25,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16150f;
    --surface: #1f1e18;
    --surface-2: #272620;
    --ink: #f0ece3;
    --ink-2: #b9b3a7;
    --ink-3: #8b857a;
    --line: #34322a;
    --accent: #7bb894;
    --accent-soft: #22332a;
    --warn: #d59263;
    --warn-soft: #2e2519;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.2);
  }
}

* { box-sizing: border-box; }

/* display:flex on a container beats the hidden attribute's display:none.
 * Restate it with weight so [hidden] means hidden everywhere. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ------------------------------------------------------------- topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: flex-end;
  justify-content: space-between;
  padding-top: 16px;
}
h1 { margin: 0; font-size: 21px; letter-spacing: -.01em; }
.tagline { margin: 3px 0 0; color: var(--ink-3); font-size: 13px; }

.tabs { display: flex; gap: 2px; }
.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* -------------------------------------------------------------- views */
.view { padding: 26px 0 8px; }
.view-head {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
}
h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.muted { color: var(--ink-3); font-size: 13px; margin: 4px 0 0; max-width: 66ch; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  font: inherit;
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--ink-3); }
.btn-quiet { background: transparent; color: var(--ink-2); }
.btn-solid { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .btn-solid { color: #12180f; } }

.filter { display: inline-flex; margin-bottom: 16px; }
.chip {
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
}
.filter .chip:first-child { border-radius: 7px 0 0 7px; }
.filter .chip:last-child { border-radius: 0 7px 7px 0; }
.filter .chip + .chip { border-left: 0; }
.chip.is-on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ----------------------------------------------------------- week grid */
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }

.day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.day-name {
  font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3); padding: 10px 12px 8px; border-bottom: 1px solid var(--line);
}

.slot {
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  width: 100%;
  display: block;
  min-height: 86px;
}
.slot:hover { background: var(--surface-2); }
.slot-label {
  font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
  display: flex; justify-content: space-between; gap: 6px;
}
.slot-label .time { font-weight: 600; }
.slot-meal { font-size: 13px; line-height: 1.35; margin-top: 5px; }
.slot-empty { color: var(--ink-3); font-size: 13px; margin-top: 5px; font-style: italic; }
.slot-macros { font-size: 11px; color: var(--ink-3); margin-top: 5px; font-variant-numeric: tabular-nums; }

.day-total {
  margin-top: auto; padding: 9px 12px; background: var(--surface-2);
  font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums;
  display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap;
}
.day-total b { color: var(--ink); font-weight: 600; }

/* ------------------------------------------------------------ summary */
.summary {
  margin-top: 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat.wide { grid-column: 1 / -1; }
.stat .k { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.stat .v { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v .of { font-size: 15px; color: var(--ink-3); }
.stat .n { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.stat .n.prose { font-size: 13px; color: var(--ink-2); margin-top: 4px; line-height: 1.5; }
.stat.good .v { color: var(--accent); }
.stat.off .v { color: var(--warn); }

/* ------------------------------------------------------ shopping list */
.aisle { margin-bottom: 24px; }
.aisle h3 {
  margin: 0 0 8px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); border-bottom: 1px solid var(--line); padding-bottom: 6px;
}
.items { list-style: none; margin: 0; padding: 0; column-width: 300px; column-gap: 28px; }
.items li { break-inside: avoid; }
.item { display: flex; gap: 10px; align-items: baseline; padding: 9px 4px; cursor: pointer; border-radius: 6px; }
.item:hover { background: var(--surface-2); }
.item input { margin: 0; accent-color: var(--accent); position: relative; top: 2px; width: 17px; height: 17px; }
.item-name { flex: 1; font-size: 14px; }
.item-qty { font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.item-need { font-size: 11px; color: var(--ink-3); }
.item.done .item-name, .item.done .item-qty { text-decoration: line-through; color: var(--ink-3); }

.empty {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 34px; text-align: center; color: var(--ink-3); font-size: 14px;
}
.empty p { margin: 0 0 14px; }

/* ---------------------------------------------------- rotation panel */
.rotation {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.rotation h3 { margin: 0 0 4px; font-size: 14px; letter-spacing: -.01em; }
.rotation .muted { margin-bottom: 14px; max-width: 88ch; }
.rotation em { font-style: italic; color: var(--ink-2); }

.rotation-controls { display: flex; gap: 22px; align-items: flex-end; flex-wrap: wrap; }
.stepper { display: flex; flex-direction: column; gap: 4px; }
.s-name { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.s-row { display: flex; align-items: center; gap: 2px; }
.s-btn {
  width: 34px; height: 34px; font: inherit; font-size: 16px; line-height: 1;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; border-radius: 7px;
}
.s-btn:hover:not(:disabled) { border-color: var(--ink-3); }
.s-btn:disabled { opacity: .35; cursor: not-allowed; }
.s-val {
  min-width: 40px; text-align: center; font-size: 19px; font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.s-hint { font-size: 11px; color: var(--ink-3); }
#build-week { padding: 10px 18px; }

/* -------------------------------------------------- rotation report */
.report {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr; gap: 16px;
}
.r-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.r-slot h4 {
  margin: 0 0 8px; font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3);
}
.r-slot ul { list-style: none; margin: 0; padding: 0; }
/* Two rows of text on the left, one badge spanning both on the right.
 * Every cell is placed explicitly — implicit placement put the badge in
 * column 1 and stretched it across the row. */
.r-slot li {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  padding: 7px 0; border-bottom: 1px solid var(--line);
}
.r-slot li:last-child { border-bottom: 0; }
.r-name { grid-column: 1; grid-row: 1; font-size: 13px; line-height: 1.35; }
.r-macros { grid-column: 1; grid-row: 2; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.r-times {
  grid-column: 2; grid-row: 1 / span 2;
  align-self: center; justify-self: end;
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
  background: var(--surface-2); border-radius: 20px; padding: 3px 9px;
}
.r-notes { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.r-notes li { padding: 5px 0 5px 18px; position: relative; color: var(--ink-2); line-height: 1.5; }
.r-notes li::before { position: absolute; left: 0; font-weight: 700; }
.r-notes .ok::before { content: "✓"; color: var(--accent); }
.r-notes .warn::before { content: "!"; color: var(--warn); }
.r-notes b { color: var(--ink); }

/* ------------------------------------------------- stale-list prompt */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-bottom: 16px; padding: 13px 16px;
  border: 1px solid var(--warn); border-left-width: 3px;
  background: var(--warn-soft); border-radius: var(--radius);
}
.banner-text { font-size: 13px; color: var(--ink-2); max-width: 70ch; }
.banner-text b { color: var(--ink); }
.banner-actions { display: flex; gap: 8px; }
/* Quiet only: the solid button must keep its green, or its white text vanishes. */
.banner-actions .btn-quiet { background: var(--surface); }

/* A dot on the tab, so the prompt is discoverable from any view. */
.dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--warn); margin-left: 6px; vertical-align: middle;
}
.dot[hidden] { display: none; }

/* ------------------------------------------------- list header & diff */
.list-meta {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  font-size: 12px; color: var(--ink-3); margin-bottom: 20px;
  font-variant-numeric: tabular-nums;
}
.list-meta .sep { color: var(--line); }
.note {
  margin-bottom: 12px; padding: 11px 14px; border-radius: var(--radius);
  font-size: 13px; color: var(--ink-2); border: 1px solid var(--line);
}
.note b { color: var(--ink); }
.note-good { border-left: 3px solid var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------- recipe cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card:hover { border-color: var(--ink-3); }
.card-top { display: flex; gap: 6px; flex-wrap: wrap; }
.card-name { font-size: 14.5px; font-weight: 600; line-height: 1.35; letter-spacing: -.01em; }
.card-macros {
  display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: auto;
  font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.card-macros b { color: var(--ink-2); font-weight: 600; }

/* -------------------------------------------------------------- pills */
.pill { font-size: 11px; padding: 3px 8px; border-radius: 20px; background: var(--surface-2); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pill.slot-tag { background: var(--accent-soft); color: var(--accent); font-weight: 600; text-transform: capitalize; }
.tier { font-weight: 600; }
.tier.t1 { background: var(--accent-soft); color: var(--accent); }
.tier.t2 { background: var(--surface-2); color: var(--ink-2); }
.tier.t3 { background: var(--warn-soft); color: var(--warn); }

/* -------------------------------------------------------- ingredients */
.ing-group { margin-bottom: 28px; }
.ing-group-head { border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 4px; }
.ing-group-head h3 {
  margin: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
}
.ing-group.s-loved   h3 { color: var(--accent); }
.ing-group.s-liked   h3 { color: var(--accent); }
.ing-group.s-neutral h3 { color: var(--ink-3); }
.ing-group.s-avoid   h3 { color: var(--warn); }
.ing-group.s-banned  h3 { color: var(--warn); }
.ing-group-head .muted { margin-top: 3px; }

.ing-group ul { list-style: none; margin: 0; padding: 0; }
.ing-row {
  display: flex; gap: 18px; align-items: flex-start; justify-content: space-between;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.ing-row:last-child { border-bottom: 0; }
.ing-main { min-width: 0; }
.ing-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.ing-name { font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; }

/* Tags sit to the right of the name: the whole point is to read the quality of
 * a food without reading its paragraph. */
.ing-tags { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.tag {
  font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
  padding: 2px 7px; border-radius: 20px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tag.k-t1   { background: var(--accent-soft); color: var(--accent); }
.tag.k-t2   { background: var(--surface-2); color: var(--ink-2); }
.tag.k-t3   { background: var(--warn-soft); color: var(--warn); }
.tag.k-good { background: var(--accent-soft); color: var(--accent); }
.tag.k-warn { background: var(--warn-soft); color: var(--warn); }
.tag.k-mute { background: var(--surface-2); color: var(--ink-3); }
.tag.k-note { background: var(--surface-2); color: var(--ink-3); font-weight: 500; font-style: italic; }
.ing-note { margin: 5px 0 0; font-size: 13px; color: var(--ink-2); max-width: 80ch; line-height: 1.5; }
.ing-used { margin: 5px 0 0; font-size: 11.5px; color: var(--ink-3); }
.ing-used code { font-size: 11px; background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }

.ing-stance {
  font: inherit; font-size: 13px; padding: 7px 10px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; flex-shrink: 0; min-width: 106px;
}
.ing-stance:hover { border-color: var(--ink-3); }

#ingredient-meta .note { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
#ingredient-meta code, .view-head code {
  font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 3px;
}

/* Preference and exclusion markers */
.banned-tag { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.bonus-tag { font-weight: 600; font-variant-numeric: tabular-nums; }
.bonus-tag.up { background: var(--accent-soft); color: var(--accent); }
.bonus-tag.down { background: var(--warn-soft); color: var(--warn); }

.card.is-excluded { opacity: .55; }
.card.is-excluded:hover { opacity: 1; }

.slot.blocked { background: var(--warn-soft); }
.slot-blocked { color: var(--warn); font-weight: 600; }

.r-bonus { font-weight: 600; }
.r-bonus.up { color: var(--accent); }
.r-bonus.down { color: var(--warn); }
.r-empty { margin: 0; font-size: 12.5px; color: var(--warn); line-height: 1.5; }

.pick-hidden {
  margin: 4px 6px 8px; padding: 8px 10px; font-size: 12px; color: var(--ink-3);
  background: var(--surface-2); border-radius: 7px;
}

.r-yours {
  font-size: 10.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-soft);
  padding: 2px 6px; border-radius: 5px; margin-left: 7px; white-space: nowrap;
}

/* ------------------------------------------------- chosen-meal cards */
.picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; }
.p-card {
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px;
  background: var(--surface); display: flex; flex-direction: column; gap: 8px;
}
.p-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.p-slot { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.p-count { font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.p-meals { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.p-meals li {
  font-size: 12.5px; line-height: 1.35; display: flex; justify-content: space-between; gap: 8px;
}
.p-den { color: var(--ink-3); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.p-none, .p-fill, .p-over { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--ink-3); }
.p-over { color: var(--warn); }
.p-edit { margin-top: auto; align-self: flex-start; font-size: 12px; padding: 6px 10px; }

/* chooser rows */
.sheet-note {
  padding: 12px 18px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  font-size: 12px; color: var(--ink-3); line-height: 1.5; flex-shrink: 0;
}
.sheet-note p { margin: 0 0 6px; }
.sheet-note p:last-child { margin-bottom: 0; }
.sheet-note .c-full { color: var(--warn); font-weight: 600; }
.sheet-note .pick-hidden { margin: 6px 0 0; }

#chooser .sheet-body { padding: 8px; }
.choose {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 11px 12px; border-radius: 8px; cursor: pointer;
}
.choose:hover { background: var(--surface-2); }
.choose.is-on { background: var(--accent-soft); }
.choose input { margin: 2px 0 0; width: 17px; height: 17px; flex-shrink: 0; accent-color: var(--accent); }
.choose:has(input:disabled) { opacity: .45; cursor: not-allowed; }
.c-body { display: block; min-width: 0; }
.c-name { display: block; font-size: 14px; }
.c-macros {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--ink-3); margin-top: 4px; font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ dialogs */
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0;
  width: min(600px, calc(100vw - 32px));
  max-height: 84vh;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
dialog:not([open]) { display: none; }
dialog::backdrop { background: rgba(20,18,15,.5); }

.sheet-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.sheet-head h3 { margin: 0; font-size: 15.5px; letter-spacing: -.01em; }
.sheet-body { padding: 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--line); flex-shrink: 0; background: var(--surface-2);
}
.sheet-foot[hidden] { display: none; }

/* picker rows */
#picker .sheet-body { padding: 8px; }
.pick { display: block; width: 100%; text-align: left; font: inherit; background: none; border: 0; border-radius: 8px; padding: 12px; cursor: pointer; color: inherit; }
.pick:hover { background: var(--surface-2); }
.pick.is-current { background: var(--accent-soft); }
.pick-name { font-size: 14px; }
.pick-macros { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pick.clear { color: var(--ink-3); font-style: italic; border-top: 1px solid var(--line); border-radius: 0; margin-top: 6px; }

/* recipe body */
#recipe-body .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
#recipe-body h4 { margin: 18px 0 6px; font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.ing { list-style: none; margin: 0; padding: 0; }
.ing li { display: flex; justify-content: space-between; gap: 16px; font-size: 13.5px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.ing li:last-child { border-bottom: 0; }
.ing .q { color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.steps { margin: 0; padding-left: 20px; font-size: 13.5px; color: var(--ink-2); }
.steps li { margin-bottom: 7px; }

.callout {
  margin-top: 14px; padding: 11px 13px;
  border: 1px solid var(--line); border-left: 2px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 7px 7px 0;
  font-size: 12.5px; color: var(--ink-2); line-height: 1.5;
}
.callout b { color: var(--ink); }
.callout.kid { border-left-color: var(--warn); background: var(--warn-soft); }

/* ----------------------------------------------------------- footnote */
.footnote { margin: 44px 0 60px; padding-top: 20px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2); max-width: 80ch; }
.footnote h3 { margin: 0 0 10px; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.footnote p { margin: 0 0 10px; }
.tiers { margin: 0 0 12px; padding-left: 18px; }
.tiers li { margin-bottom: 6px; }
.tiers b { color: var(--ink); }
.footnote b.lean { color: var(--accent); }
.footnote b.bal { color: var(--ink); }
.footnote b.rich { color: var(--warn); }

/* =============================================================== MOBILE */
@media (max-width: 900px) {
  .week-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .topbar-inner { align-items: stretch; padding-top: 14px; gap: 4px; }
  .brand { padding-bottom: 2px; }
  h1 { font-size: 19px; }
  .tagline { font-size: 12px; }

  /* Tabs become a full-width scrollable strip, thumb-reachable. */
  .tabs {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid var(--line);
    margin: 0 -14px;
    padding: 0 14px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 1; text-align: center; padding: 13px 10px; }

  .view { padding: 20px 0 8px; }
  .view-head { align-items: stretch; }
  /* flex:1 on the buttons does nothing until the row itself fills the width. */
  .view-head .actions { width: 100%; flex-wrap: nowrap; }
  .actions .btn { flex: 1; padding: 11px 14px; white-space: nowrap; }

  .week-grid { grid-template-columns: 1fr; gap: 12px; }
  .slot { min-height: 0; padding: 13px 14px; }
  .summary { grid-template-columns: 1fr 1fr; }
  .stat.wide { grid-column: 1 / -1; }

  .items { column-width: auto; }
  .item { padding: 11px 4px; }

  .banner { flex-direction: column; align-items: stretch; }
  .banner-actions { width: 100%; }
  .banner-actions .btn { flex: 1; padding: 11px; }

  .rotation-controls { gap: 10px; }
  /* Fixed label column so the +/- controls line up down the stack. A grid
   * track grows past its stated width unless the item may shrink, and
   * "BREAKFAST" is wider than the track — hence min-width:0. */
  .stepper {
    display: grid; grid-template-columns: 84px auto 1fr;
    align-items: center; gap: 8px; width: 100%;
  }
  .stepper .s-name { min-width: 0; }
  .stepper .s-hint { text-align: right; min-width: 0; }
  /* 34px is a comfortable mouse target and a poor thumb one. 44px is the size
   * a finger actually is; the label track gives back the width to pay for it. */
  .s-btn { width: 44px; height: 44px; font-size: 18px; }
  #build-week { width: 100%; padding: 12px; }

  /* Three cards side by side is 119px each at this width, and the row ran 44px
   * past the viewport — which is why the whole page scrolled sideways, even
   * though no single element was wider than the screen. Stack them. */
  .picks { grid-template-columns: 1fr; gap: 10px; }
  .p-edit { width: 100%; text-align: center; font-size: 13px; }

  /* Every button a thumb can hit clears 44px. Applied here rather than to .btn
   * globally, because a desktop toolbar of 44px buttons looks like a kiosk. */
  .btn { min-height: 44px; }
  .p-card { padding: 13px 14px; }

  .card-grid { grid-template-columns: 1fr; }
  .ing-row { flex-direction: column; gap: 10px; }
  /* 16px for the same reason as the password field: a smaller <select> makes
   * iOS zoom in on focus and stay there. */
  .ing-stance { width: 100%; padding: 12px 10px; font-size: 16px; min-height: 44px; }
  .filter { display: flex; width: 100%; }
  .filter .chip { flex: 1; padding: 10px 4px; min-height: 44px; }

  /* Saved weeks: the date alone repeats when you build twice in a day, so the
   * time carries the distinction and must not wrap away from it. */
  .wk-when { font-size: 12.5px; }

  /* Don't let the last row sit under the home indicator. */
  .footnote { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  #login { padding: 24px calc(16px + env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom)); }

  /* Dialogs become bottom sheets: reachable, dismissible, native-feeling. */
  dialog {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    margin: 0;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 16px 16px 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .sheet-foot .btn { flex: 1; padding: 12px; }
  .pick { padding: 14px 12px; }
}

/* -------------------------------------------------------------- print */
@media print {
  .topbar, .view-head .actions, .footnote, #view-plan, #view-recipes, dialog,
  .banner, .note, .list-meta { display: none !important; }
  body { background: #fff; color: #000; }
  .items { column-width: 240px; }
  .item:hover { background: none; }
}

/* ------------------------------------------------------------- login */
#login {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
}
#login-form {
  width: min(360px, 100%); display: grid; gap: 10px;
  border: 1px solid var(--line); border-radius: 14px; padding: 26px 24px; background: var(--surface);
}
#login-form h1 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
#login-form p { margin: 0; font-size: 12.5px; color: var(--ink-3); }
#login-form label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-top: 8px; }
#login-form input {
  /* 16px exactly. iOS Safari zooms the viewport when a focused input is under
   * 16px, and it does not zoom back out — the first thing you would ever do on
   * this site would leave it scaled wrong. */
  font: inherit; font-size: 16px;
  padding: 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink); min-height: 44px;
}
#login-form button { margin-top: 6px; padding: 11px; }
#login-error:empty { display: none; }
#login-error { color: var(--warn); font-weight: 600; }

/* --------------------------------------------------------- save state */
.save-state {
  margin: 14px 0 0; padding: 10px 12px; border-radius: 8px;
  background: var(--warn-soft); color: var(--warn); font-size: 12.5px; font-weight: 600;
}

/* ------------------------------------------------------- saved weeks */
.archive { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.archive h3 { margin: 0 0 4px; font-size: 15px; }
.weeks { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.wk {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; background: var(--surface);
}
.wk.is-active { background: var(--accent-soft); border-color: var(--accent); }
.wk-when { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.wk-meals { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
@media (max-width: 640px) {
  .wk { flex-direction: column; align-items: stretch; gap: 9px; }
  .wk .btn { width: 100%; }
}
