/* ============================================================
   NEW-TRITION — Page-specific styles
   ============================================================ */

/* ================= Landing / Login ================= */
body.landing {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(1100px 480px at 88% -8%, rgba(132, 204, 22, 0.12), transparent 60%),
    radial-gradient(900px 420px at -8% 108%, rgba(22, 163, 74, 0.10), transparent 60%),
    radial-gradient(700px 320px at 50% 118%, rgba(255, 215, 0, 0.10), transparent 65%),
    #fff;
  padding: 24px 16px;
  gap: 22px;
}
.login-card {
  width: min(94vw, 420px);
  background: #fff;
  border: 2px solid var(--gold); border-radius: 16px;
  box-shadow: var(--frame-shadow), 0 18px 44px rgba(120, 90, 0, 0.10);
  padding: 30px 28px 26px;
  position: relative;
}
.login-card::before {
  content: ""; position: absolute; inset: 6px; pointer-events: none;
  border: 1px solid rgba(255, 215, 0, 0.35); border-radius: 12px;
}
.login-logo { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-logo img { width: 58px; height: 58px; }
.login-logo .wordmark {
  font-family: var(--font-display); font-size: var(--fs-hero); font-weight: 700; letter-spacing: 1px;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  line-height: 1.05; text-align: center;
}
.login-logo .tagline { font-size: var(--fs-xs); color: var(--gold-deep); letter-spacing: 2.6px; text-transform: uppercase; }
.login-form { display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }
.login-error { background: var(--danger-soft); color: var(--danger); border-radius: 8px; padding: 8px 12px; font-size: var(--fs-sm); display: none; }
.login-error.show { display: block; }
.login-alt { text-align: center; font-size: var(--fs-sm); color: var(--ink-faint); margin-top: 4px; }
.login-footer { text-align: center; color: var(--ink-faint); font-size: var(--fs-xs); max-width: 460px; }
.demo-note {
  width: min(94vw, 420px);
  background: var(--sky-soft); border: 1px solid var(--sky); color: var(--sky-deep);
  border-radius: 10px; padding: 8px 14px; font-size: var(--fs-xs);
}

/* ================= App shell — Person context strip ================= */
.context-strip {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.context-strip .ctx-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink-faint); font-weight: 700; }

/* ================= People page ================= */
.perm-grid-wrap { max-height: 380px; overflow: auto; border: 1px solid var(--bg-sunken); border-radius: 8px; }
.people-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: var(--sp-4); }
.person-selected td { background: var(--bg-hover) !important; }

/* ================= Ingredients page ================= */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.category-tag { font-size: 9px; font-weight: 800; letter-spacing: 0.5px; color: var(--gold-deep); background: #FFF7CC; padding: 1px 6px; border-radius: 4px; text-transform: uppercase; }
/* fixed-column ingredients grid: keep the sticky name column compact and the
   21 nutrient columns uniform so the widest tables still fit on screen */
#ingredient-list td .select.sm { width: 100%; max-width: 100%; }
#ingredient-list input.cell-num { width: 100%; max-width: 52px; }
#ingredient-list th, #ingredient-list td { padding: 5px 7px; }
#ingredient-list thead th { padding-top: 6px; padding-bottom: 6px; }

/* ================= Dishes page ================= */
.dish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--sp-5); }
.dish-card { display: flex; flex-direction: column; }
.dish-card .dish-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--bg-sunken); }
.dish-card .dish-head input.dish-name {
  border: 1px solid transparent; background: transparent; border-radius: 6px;
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-h3); color: var(--green-deep);
  padding: 3px 8px; min-width: 0; flex: 1;
}
.dish-card .dish-head input.dish-name:hover { border-color: #E4DCB0; background: #fff; }
.dish-card .dish-head input.dish-name:focus { outline: none; border-color: var(--gold-mid); background: #fff; box-shadow: 0 0 0 2px rgba(255,215,0,0.3); }
.dish-meta { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px 0; }
.dish-ing-table { width: 100%; border-collapse: collapse; }
.dish-ing-table td { padding: 4px 6px; border-bottom: 1px dashed var(--bg-sunken); font-size: var(--fs-sm); }
.dish-ing-table td.g { width: 90px; }
.dish-foot { padding: 10px 12px; display: flex; gap: 8px; justify-content: flex-end; }
.dish-summary { padding: 10px 12px; background: var(--bg-tint); border-top: 1px dashed var(--gold); font-size: var(--fs-xs); }
.dish-summary .row { display: flex; flex-wrap: wrap; gap: 4px 14px; }

/* ================= Meal Planner — split panels ================= */
.planner-layout { display: grid; grid-template-columns: 1fr; gap: var(--sp-5); align-items: start; }
@media (min-width: 1101px) and (orientation: landscape) {
  .planner-layout { grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.85fr); }
}
@media (min-width: 961px) and (max-width: 1100px) {
  .planner-layout { grid-template-columns: 1fr; }
}
.planner-panel { min-width: 0; }

/* Day header — nutrient totals strip */
.day-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--bg-tint);
  border-bottom: 2px solid var(--gold);
}
.day-head .day-title { display: flex; align-items: baseline; gap: 8px; }
.day-head .day-title h3 { font-size: var(--fs-h3); color: var(--green-deep); }
.day-head .day-date { font-size: var(--fs-xs); color: var(--ink-faint); }
.day-head .day-mass { font-size: var(--fs-xs); color: var(--gold-deep); font-weight: 700; }
.day-head .day-cost { font-size: var(--fs-xs); color: var(--ink-soft); font-weight: 700; font-variant-numeric: tabular-nums; }

.nut-strip {
  display: flex; gap: 4px; overflow-x: auto; padding: 8px 10px;
  border-bottom: 1px solid var(--bg-sunken);
  background: linear-gradient(180deg, var(--bg-tint), #fff);
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}
.nut-strip::-webkit-scrollbar { height: 6px; }
.nut-cell {
  flex: none; width: 84px;
  scroll-snap-align: start;
  background: #fff; border: 1px solid var(--bg-sunken); border-radius: 8px;
  padding: 4px 7px 5px; display: flex; flex-direction: column; gap: 2px;
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}
.nut-cell:hover { border-color: var(--gold); box-shadow: 0 1px 5px rgba(120, 90, 0, 0.12); }
.nut-cell .n-name { font-size: 9.5px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nut-cell .n-vals { display: flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; }
.nut-cell .n-actual { font-size: 11.5px; font-weight: 700; color: var(--ink); }
.nut-cell .n-target { font-size: 9.5px; color: var(--ink-faint); }
.nut-cell .n-target .mode-tag { font-weight: 800; }
.nut-cell .mode-tag.off { color: #B9B29A; } .nut-cell .mode-tag.eq { color: var(--gold-deep); }
.nut-cell .mode-tag.le { color: var(--lime-deep); } .nut-cell .mode-tag.ge { color: var(--green-deep); }
/* the daily-cost cell at the end of the strip gets a gold tint */
.nut-cell.cost-cell { background: linear-gradient(180deg, #FFFDF0, #fff); border-color: #EFE4B0; }
.nut-cell.cost-cell .n-actual { color: var(--gold-deep); }

/* ---- narrow phones: 7 day tabs must fit one row without scrolling ---- */
@media (max-width: 600px) {
  .day-tabs .strip { gap: 2px; }
  .day-tab { min-width: 0; flex: 1 1 0; padding: 5px 1px 6px; border-radius: 6px; }
  .day-tab .dw { font-size: 8px; }
  .day-tab .dd { font-size: var(--fs-sm); }
  .day-tab .cal-dashes { gap: 1px; }
  .day-tab .cal-dashes .cd { width: 5px; }
  .day-tabs .week-label { font-size: 8.5px; padding-left: 2px; }
}

/* Meals */
.meal-sec { border-bottom: 1px solid var(--bg-sunken); }
.meal-sec:last-child { border-bottom: none; }
.meal-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px;
  padding: 8px 12px; cursor: pointer; user-select: none;
  background: var(--bg-tint);
}
.meal-head:hover { background: var(--bg-hover); }
.meal-head .caret { transition: transform var(--tr-med); font-size: 10px; color: var(--gold-deep); flex: none; }
.meal-sec.collapsed .caret { transform: rotate(-90deg); }
.meal-head .m-name { font-weight: 800; font-size: var(--fs-sm); color: var(--green-deep); text-transform: uppercase; letter-spacing: 0.6px; }
.meal-head .m-mass { font-size: var(--fs-xs); color: var(--gold-deep); font-weight: 700; font-variant-numeric: tabular-nums; }
.meal-head .m-cost { font-size: var(--fs-xs); color: var(--ink-soft); font-weight: 700; font-variant-numeric: tabular-nums; }
.meal-head .m-kcal { font-size: var(--fs-xs); color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.meal-head .m-mini { display: flex; gap: 10px; margin-left: auto; font-size: var(--fs-xs); color: var(--ink-faint); font-variant-numeric: tabular-nums; overflow: hidden; }
.meal-body { padding: 0 6px 8px; }
.meal-sec.collapsed .meal-body { display: none; }

/* ---- swipeable all-nutrient chips (meal heads & item rows) ---- */
.m-nutstrip {
  flex: 1 1 100%; display: flex; gap: 4px; align-items: center;
  overflow-x: auto; padding: 3px 0 1px; scrollbar-width: thin;
  -webkit-overflow-scrolling: touch; cursor: default;
}
.i-nuts {
  grid-column: 1 / -1; display: flex; gap: 4px; align-items: center;
  overflow-x: auto; padding: 1px 0 2px; scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
/* scrollbars on strips are now visible (see v19 block at end) */
.nut-chip {
  flex: none; display: inline-flex; align-items: baseline; gap: 2px;
  font-size: 9px; line-height: 1.7; color: var(--ink-soft);
  background: var(--bg-sunken); border-radius: 4px; padding: 0 5px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.nut-chip b { color: var(--green-deep); font-weight: 700; }
.nut-chip.z { opacity: 0.4; }

.item-row {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) 58px 20px 20px 20px;
  gap: 3px; align-items: center;
  padding: 4px 8px; border-radius: 8px;
}
.item-row:hover { background: var(--bg-hover); }
.item-row .i-name { font-size: var(--fs-sm); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .i-name .type-tag { font-size: 8.5px; font-weight: 800; letter-spacing: 0.4px; padding: 1px 5px; border-radius: 4px; margin-right: 5px; vertical-align: 1px; }
.type-tag.dish { background: var(--orange-soft); color: var(--orange-deep); }
.type-tag.ing { background: var(--lime-soft); color: var(--lime-deep); }
.item-row.past-lock { opacity: 0.68; }
.item-row .i-qty { display: flex; align-items: center; gap: 3px; }
.item-row .i-qty input { width: 48px; text-align: right; font-variant-numeric: tabular-nums; border: 1px solid transparent; background: transparent; border-radius: 5px; font: 600 var(--fs-sm) var(--font-ui); color: var(--ink); padding: 3px 5px; }
.item-row .i-qty input:hover { border-color: #E4DCB0; background: #fff; }
.item-row .i-qty input:focus { outline: none; border-color: var(--gold-mid); background: #fff; box-shadow: 0 0 0 2px rgba(255,215,0,0.3); }
.item-row .i-qty .u { font-size: 10px; color: var(--ink-faint); }
.item-row .i-kcal { font-size: var(--fs-xs); color: var(--ink-soft); text-align: right; font-variant-numeric: tabular-nums; }
.item-row .i-del { border: none; background: none; color: transparent; cursor: pointer; font-size: 13px; line-height: 1; padding: 2px; border-radius: 4px; }
.item-row:hover .i-del { color: #C9B8A0; }
.item-row .i-del:hover { color: var(--danger) !important; }

/* ---- copy from / send to arrows (day, meal, item) ---- */
.copy-btn {
  border: 1px solid #DCD6BC; background: #fff; color: var(--ink-soft);
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 3px 7px; border-radius: var(--r-pill); cursor: pointer;
  transition: all var(--tr-fast);
}
.copy-btn:hover { border-color: var(--gold); color: var(--gold-deep); background: var(--gold-pale); }
.meal-head .m-copy {
  color: #C9B8A0; cursor: pointer; font-size: 12px; font-weight: 700;
  line-height: 1; padding: 2px 3px; border-radius: 4px; flex: none;
  transition: color var(--tr-fast), background var(--tr-fast);
}
.meal-head:hover .m-copy, .m-copy:hover { color: var(--gold-deep); }
.m-copy:hover { background: var(--bg-hover); }
.item-row .i-copy {
  border: none; background: none; color: #C9B8A0; cursor: pointer;
  font-size: 12px; font-weight: 700; line-height: 1; padding: 2px; border-radius: 4px;
  transition: color var(--tr-fast);
}
.item-row .i-copy:hover { color: var(--gold-deep); }

/* ---- day picker modal ---- */
.day-pick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.day-pick {
  display: flex; flex-direction: column; align-items: center; gap: 0;
  border: 1.5px solid #DCD6BC; background: #fff; border-radius: 8px;
  padding: 6px 4px 5px; cursor: pointer; transition: all var(--tr-fast);
}
.day-pick .dp-dw { font-size: 9px; font-weight: 700; text-transform: uppercase; color: var(--ink-soft); }
.day-pick .dp-dd { font-size: var(--fs-h3); font-weight: 700; font-variant-numeric: tabular-nums; }
.day-pick .dp-n { font-size: 9px; color: var(--ink-faint); }
.day-pick:hover { border-color: var(--gold); background: var(--gold-pale); }
.day-pick.me { border-color: var(--green-mid); background: var(--green-soft); }
.day-pick.past { opacity: 0.45; cursor: not-allowed; }

.add-item-row { display: flex; gap: 8px; padding: 2px 8px 6px 26px; align-items: center; }
.add-item-row .ac-wrap { flex: 1; }

/* Planner expanded nutrient columns for item rows */
.item-row.expanded { grid-template-columns: 44px minmax(130px, 1fr) 76px 70px 26px; }

/* ================= Summary panel ================= */
.summary-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 2px solid var(--gold); background: var(--bg-tint); }
.summary-head .sh-title { font-weight: 800; color: var(--green-deep); }

.summary-table { width: 100%; border-collapse: collapse; }
.summary-table th, .summary-table td { padding: 4px 7px; font-size: var(--fs-sm); border-bottom: 1px solid var(--bg-sunken); }
.summary-table thead th { position: sticky; top: 0; background: #fff; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-soft); border-bottom: 2px solid var(--gold); z-index: 2; white-space: nowrap; }
.summary-table thead th:first-child { text-align: left; }
.summary-table thead th:not(:first-child) { text-align: right; }
.summary-table .group-row td { background: var(--bg-tint); font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: var(--gold-deep); padding: 4px 8px; }
.summary-table .n-name { font-weight: 600; white-space: nowrap; }
.summary-table .n-name .unit { color: var(--ink-faint); font-weight: 400; font-size: 10px; }
.summary-table td.avg, .summary-table td.tgt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.summary-table td.tgt input { width: 56px; text-align: right; font-variant-numeric: tabular-nums; border: 1px solid transparent; background: transparent; border-radius: 5px; font: 600 var(--fs-sm) var(--font-ui); color: var(--ink); padding: 2px 5px; }
.summary-table td.tgt input:hover { border-color: #E4DCB0; background: #fff; }
.summary-table td.tgt input:focus { outline: none; border-color: var(--gold-mid); background: #fff; box-shadow: 0 0 0 2px rgba(255,215,0,0.3); }
.summary-table td.mode-cell { text-align: right; white-space: nowrap; }
.summary-table td.mode-cell .chip { padding: 1px 8px; font-size: 9px; }
.summary-table .bar-cell { width: 60px; min-width: 60px; }
.summary-table tr.total-row td { border-top: 2px solid var(--gold); }

.solve-btn-row { padding: 10px 14px; border-bottom: 1px solid var(--bg-sunken); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ================= Shopping list (card list — no horizontal scrolling) ================= */
.shop-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.person-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.person-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid #DCD6BC; background: #fff; border-radius: var(--r-pill);
  padding: 4px 12px; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; color: var(--ink-soft);
  transition: all var(--tr-fast);
}
.person-chip.on { background: var(--green-deep); border-color: var(--gold); color: var(--gold); }
.shop-list { padding-bottom: 2px; }
.shop-cat {
  position: sticky; top: 0; z-index: 2;
  padding: 8px 14px 6px;
  font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--gold-deep); background: linear-gradient(180deg, #FFFDF0, var(--bg-tint));
  border-bottom: 1px solid var(--bg-sunken);
}
.shop-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 14px; border-bottom: 1px solid var(--bg-sunken);
  cursor: pointer; user-select: none;
  transition: background var(--tr-fast);
}
.shop-item:hover { background: var(--bg-hover); }
.shop-item .cb { width: 18px; height: 18px; }
.shop-item .si-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.shop-item .si-name { font-weight: 600; font-size: var(--fs-sm); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-item .si-meta { font-size: var(--fs-xs); color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.shop-item .si-cost { flex: none; font-weight: 800; color: var(--gold-deep); font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }
.shop-item.shop-done .si-name { text-decoration: line-through; opacity: 0.45; }
.shop-item.shop-done .si-meta { opacity: 0.6; }
.shop-item.shop-done .si-cost { opacity: 0.4; text-decoration: line-through; }
.shop-total {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 14px;
  background: var(--bg-tint); border-top: 2px solid var(--gold);
  font-weight: 800; color: var(--ink);
}
.shop-total b { color: var(--gold-deep); font-variant-numeric: tabular-nums; font-size: var(--fs-body); }

/* ================= Modal report details ================= */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.report-card { border: 1px solid var(--bg-sunken); border-radius: 8px; padding: 8px 10px; font-size: var(--fs-xs); }
.report-card .rc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-weight: 700; }
.report-card.ok { border-color: var(--green-soft); background: var(--green-soft); }
.report-card.bad { border-color: var(--danger-soft); background: var(--danger-soft); }
.report-card .rc-note { color: var(--ink-soft); }

/* ================= Narrow phones ================= */
@media (max-width: 480px) {
  /* name gets every spare pixel; qty box holds 4 digits (longer scrolls) */
  .item-row { grid-template-columns: 22px minmax(0, 1fr) 58px 20px 20px 20px; gap: 2px; }
  .page-title h1 { font-size: 1.25rem; }
  .frame-head h2 { font-size: var(--fs-h3); }
}

/* ---- planner summary table fills the panel without horizontal scrolling ----
   (kept after the base .summary-table rules so the overrides win the cascade) */
@media (max-width: 600px) {
  .summary-table th, .summary-table td { padding: 3px 3px; font-size: var(--fs-xs); }
  .summary-table thead th { font-size: 7.5px; letter-spacing: 0.2px; }
  .summary-table .n-name { white-space: normal; line-height: 1.15; }
  .summary-table td.tgt input { width: 42px; padding: 2px 2px; font-size: var(--fs-xs); }
  .summary-table td.mode-cell .chip { padding: 1px 4px; font-size: 7.5px; letter-spacing: 0; }
  .summary-table .bar-cell { width: 30px; min-width: 30px; }
  .summary-table .cbar { min-width: 24px; }
  .summary-head { padding: 10px; }
  .summary-head .sh-title { font-size: var(--fs-sm); }
  .solve-btn-row { padding: 8px 10px; }
  .solve-btn-row .btn.hero { padding: 9px 16px; font-size: var(--fs-sm); }
}

/* ============================================================
   v17 — full-viewport app fit (desktop) · drag-scroll · dishes
   ============================================================ */

/* ---- desktop: the page itself never scrolls, only blocks inside do ---- */
@media (min-width: 961px) {
  html, body { height: 100%; overflow: hidden; }
  body:not(.landing) .page {
    height: calc(100dvh - var(--header-h));
    display: flex; flex-direction: column; overflow: hidden;
    padding-bottom: var(--sp-5);
  }
  .page > * { flex: 0 0 auto; min-height: 0; }

  /* a lone frame fills the remaining height; its body scrolls inside */
  .page > .frame:not(.planner-panel) { flex: 1 1 auto; display: flex; flex-direction: column; }
  .page > .frame:not(.planner-panel) > .frame-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
  .page > .frame:not(.planner-panel) > .frame-body.flush { display: flex; flex-direction: column; overflow: hidden; }
  .page .table-scroll { flex: 1 1 auto; min-height: 0; max-height: none !important; }
  .page > .dish-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .page > .perm-grid-wrap { flex: 1 1 auto; min-height: 0; }

  /* planner: both panels stretch to identical height, tops aligned,
     and scroll internally */
  .planner-layout { flex: 1 1 auto; min-height: 0; align-items: stretch; }
  .planner-panel { display: flex; flex-direction: column; min-height: 0; }
  .planner-panel > .frame-body,
  .planner-panel > .day-head,
  .planner-panel > .nut-strip,
  .planner-panel > .summary-head,
  .planner-panel > .solve-btn-row { flex: 0 0 auto; }
  .planner-panel > #meals { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  .planner-panel > .table-scroll { flex: 1 1 auto; }

  /* between 961-1100px the planner stacks — let the stack scroll as a block */
  @media (max-width: 1100px) {
    .planner-layout { display: flex; flex-direction: column; overflow-y: auto; }
    .planner-panel { flex: 0 0 auto; max-height: none; }
    .planner-panel > #meals, .planner-panel > .table-scroll { overflow: visible; }
  }
}

/* ---- meal chooser (second page of the day/meal picker) ---- */
.day-pick-grid.meals { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
.day-pick.meal-pick { padding: 10px 6px; }
.day-pick.meal-pick .dp-dw { text-transform: none; letter-spacing: 0.3px; font-size: var(--fs-sm); }

/* ---- dish nutrient ribbon ---- */
.dish-ribbon {
  display: flex; gap: 4px; align-items: center;
  overflow-x: auto; padding: 4px 0 2px; scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
/* dish ribbon scrollbar visible (v19) */

/* ---- mouse drag-to-scroll affordance (desktop) ---- */
@media (min-width: 961px) {
  .m-nutstrip, .i-nuts, .nut-strip, .dish-ribbon, .day-tabs .strip, .tabs, .ac-rail { cursor: grab; }
  body.drag-scrolling, body.drag-scrolling * { cursor: grabbing !important; user-select: none !important; }
}

/* ingredient table: category select fills its (widened) cell — no clipped text */
.cols-fixed td .select.sm { width: 100%; max-width: 100%; padding-right: 22px; }

/* ---- v19: planner panels align exactly (kill the .frame + .frame margin
   inside the two-column grid) + visible thin scrollbars on the strips ---- */
@media (min-width: 961px) {
  .planner-layout .planner-panel { margin-top: 0 !important; }
}

/* strips: thin always-visible scrollbars instead of hidden ones */
.m-nutstrip, .i-nuts, .dish-ribbon, .tabs, .day-tabs .strip { scrollbar-width: thin; scrollbar-color: #E3D48A transparent; }
.m-nutstrip::-webkit-scrollbar, .i-nuts::-webkit-scrollbar, .dish-ribbon::-webkit-scrollbar,
.tabs::-webkit-scrollbar, .day-tabs .strip::-webkit-scrollbar { height: 6px; display: block; }
.m-nutstrip::-webkit-scrollbar-thumb, .i-nuts::-webkit-scrollbar-thumb, .dish-ribbon::-webkit-scrollbar-thumb,
.tabs::-webkit-scrollbar-thumb, .day-tabs .strip::-webkit-scrollbar-thumb {
  background: #E3D48A; border-radius: 3px;
}
.m-nutstrip::-webkit-scrollbar-thumb:hover, .i-nuts::-webkit-scrollbar-thumb:hover,
.dish-ribbon::-webkit-scrollbar-thumb:hover, .tabs::-webkit-scrollbar-thumb:hover { background: var(--gold-mid); }
.m-nutstrip::-webkit-scrollbar-track, .i-nuts::-webkit-scrollbar-track, .dish-ribbon::-webkit-scrollbar-track,
.tabs::-webkit-scrollbar-track { background: transparent; }

/* ---- A–Z letter strip (ingredients) ---- */
.az-strip { flex: 1 1 100%; gap: 3px; padding: 4px; }
.az-strip .tab { min-width: 30px; flex: 1 0 30px; text-align: center; padding: 5px 4px; font-variant-numeric: tabular-nums; }
.az-strip .tab:disabled { opacity: 0.28; cursor: default; }
.az-strip .tab:disabled:hover { background: transparent; }

/* ---- v21: keep the height chain through the .scroll-wrap edge-fade wrapper.
   enhanceScrollables() wraps every .table-scroll/.nut-strip in .scroll-wrap,
   which broke the flex chain and froze internal scrolling on desktop. ---- */
@media (min-width: 961px) {
  .scroll-wrap { min-height: 0; }
  .page > .frame:not(.planner-panel) > .frame-body.flush > .scroll-wrap {
    flex: 1 1 auto; display: flex; flex-direction: column;
  }
  .planner-panel > .scroll-wrap { flex: 0 0 auto; }
  .planner-panel > .scroll-wrap:has(> .table-scroll) {
    flex: 1 1 auto; display: flex; flex-direction: column;
  }
  .scroll-wrap > .table-scroll { flex: 1 1 auto; min-height: 0; }
}

/* ============================================================
   v22 — mobile full-screen fit (ingredients · people · shopping ·
   dishes): the page locks to the viewport between header and tab
   bar, and the list scrolls inside — native-app feel.
   ============================================================ */
@media (max-width: 960px) {
  html, body { height: 100%; }
  body.fit-page { overflow: hidden; }
  body.fit-page .page {
    height: calc(100dvh - var(--header-h) - var(--tabbar-h) - env(safe-area-inset-bottom, 0px));
    padding-bottom: 0;
    display: flex; flex-direction: column; overflow: hidden;
  }
  body.fit-page .page > * { flex: 0 0 auto; min-height: 0; }
  body.fit-page .page > .frame { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  body.fit-page .page > .frame > .frame-body.flush {
    flex: 1 1 auto; min-height: 0;
    display: flex; flex-direction: column; overflow: hidden;
  }
  /* the edge-fade wrapper must pass the height through to the scroller */
  body.fit-page .frame-body.flush > .scroll-wrap {
    flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
  }
  body.fit-page .scroll-wrap > .table-scroll { flex: 1 1 auto; min-height: 0; max-height: none !important; }
  body.fit-page .table-scroll { flex: 1 1 auto; min-height: 0; max-height: none !important; }
  body.fit-page .page > .dish-grid { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
  body.fit-page .page > .perm-grid-wrap { flex: 1 1 auto; min-height: 0; }

  /* A–Z strip: shrink to the screen and scroll letters inside it */
  .az-strip { min-width: 0; }
  .az-strip .tab { min-width: 24px; flex: 1 0 24px; padding: 5px 2px; }
}

/* compact filter bar + subtitles on phones */
@media (max-width: 600px) {
  .filter-bar { gap: 6px; }
  .filter-bar .input.search { flex: 1 1 100%; width: auto !important; }
  .page-title .sub {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* the filter bar itself must be shrinkable inside the frame-head flex row,
   else the A–Z strip's percentage basis forces it wider than the screen */
.filter-bar { min-width: 0; }

/* ============================================================
   v24 — less chrome, clearer meals, touch-friendly sizing
   ============================================================ */

/* slim button row left where a page heading used to be (dishes) */
.slim-bar { display: flex; align-items: center; margin-bottom: var(--sp-3); }

/* ingredient count sits beside the category select */
#ing-count { margin-left: 4px; white-space: nowrap; }
#ing-cat { min-width: 150px; }

/* meals as clearly separated bordered blocks */
.meal-sec {
  border: 1px solid var(--bg-sunken);
  border-radius: 12px;
  margin: 7px 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(28, 36, 25, 0.05);
}
.meal-sec > .meal-head { border-radius: 11px 11px 0 0; }
.meal-sec.collapsed { margin-bottom: 7px; }

/* ---- a bit bigger text everywhere ---- */
:root {
  --fs-body: 0.92rem;
  --fs-sm:   0.82rem;
  --fs-xs:   0.72rem;
}

/* ---- larger touch targets on phones/tablets (desktop pointers unchanged) ---- */
@media (pointer: coarse) {
  .btn { padding: 9px 16px; }
  .btn.sm { padding: 7px 12px; }
  .btn.lg { padding: 12px 24px; }
  .input, .select { padding: 10px 12px; font-size: 0.95rem; }
  .input.sm, .select.sm { padding: 8px 10px; font-size: 0.88rem; }
  .cell-num, .cell-name { padding: 4px 6px !important; }
  input[type="checkbox"].cb { width: 19px; height: 19px; }
  input[type="radio"].cb { width: 18px; height: 18px; }
  .switch { width: 40px; height: 22px; }
  .switch .thumb { width: 18px; height: 18px; top: 2px; }
  .switch input:checked ~ .thumb { left: 20px; }
  .switch.sm { width: 34px; height: 19px; }
  .switch.sm .thumb { width: 15px; height: 15px; }
  .switch.sm input:checked ~ .thumb { left: 17px; }
  .tab { padding: 8px 14px; }
  .day-tab { min-width: 54px; padding: 7px 4px 8px; }
  .day-tab .dd { font-size: 0.9rem; }
  .tabbar a { font-size: 11px; }
  .tabbar a .ico { font-size: 19px; }
  .item-row { padding: 6px 8px; }
  .item-row .i-qty input { padding: 6px 5px; width: 46px; }
  .i-del, .i-copy { font-size: 15px; padding: 5px 3px; }
  .nut-chip { font-size: 10px; }
  .ac-item { padding: 11px 12px; }
  .modal-close { font-size: 24px; padding: 8px; }
  .chip { padding: 4px 12px; }
  .seg button { padding: 7px 13px; }
  .az-strip .tab { padding: 7px 2px; min-width: 28px; flex-basis: 28px; }
}

/* ============================================================
   v26 — planner ribbon targets · day picker · dishes table · fit
   ============================================================ */

/* ---- day selector: exactly 7 tabs across the phone width ---- */
@media (max-width: 600px) {
  .day-tabs .strip { gap: 3px; }
  .day-tab { flex: 1 1 0; min-width: 0; padding: 6px 2px 7px; }
  .day-tab .dw { font-size: 9px; }
  .day-tab .dd { font-size: 0.85rem; }
  /* today's date circled */
  .day-tab.today .dd {
    width: 26px; height: 26px; margin: 0 auto;
    display: grid; place-content: center;
    border: 2px solid var(--gold); border-radius: 50%;
  }
  .day-tab.active.today .dd { border-color: #FFD700; }
}

/* ---- meal blocks: dark-green outline with a soft 3-D lift ---- */
.meal-sec {
  border: 1.5px solid var(--green-deep);
  border-radius: 12px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 3px 10px rgba(20, 83, 45, 0.20);
}
.meal-sec > .meal-head { border-radius: 10px 10px 0 0; background: linear-gradient(180deg, var(--bg-tint), #fff); }
.meal-sec > .meal-body { border-radius: 0 0 10px 10px; }

/* ---- ribbon: Daily master cell + no-wrap headings ---- */
.nut-cell.daily-cell { cursor: default; }
.nut-cell.daily-cell .switch { margin: 3px 0 2px; }
.sh-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.summary-head { flex-wrap: wrap; row-gap: 8px; }
.day-head .day-title h3 { white-space: nowrap; }
.day-head { row-gap: 6px; }

/* ---- add-item input + dropdown fill the meal block on phones ---- */
@media (max-width: 600px) {
  .add-item-row { padding-left: 8px; padding-right: 8px; }
  .add-item-row .ac-wrap { flex: 1 1 100%; }
  .ac-menu { min-width: 0; left: 0; right: 0; }
}

/* bigger A–Z letters on touch */
@media (pointer: coarse) {
  .az-strip .tab { min-width: 32px; flex-basis: 32px; padding: 8px 2px; font-size: 0.8rem; }
}

/* ---- dish table (mirrors the ingredients table) ---- */
#dish-table td .cell-num { width: 100%; max-width: 64px; }
#dish-table th, #dish-table td { padding: 5px 7px; }
#dish-table thead th { padding-top: 6px; padding-bottom: 6px; }
#dish-table td.rowhead { font-weight: 600; }
#dish-table tr.dish-ing td { background: var(--bg-tint); }
#dish-table tr.dish-ing td.rowhead { padding-left: 26px; }
#dish-table tr.dish-ing .ing-name {
  display: inline-block; max-width: 170px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: middle;
}
#dish-table .chev {
  border: none; background: none; cursor: pointer; user-select: none;
  color: var(--gold-deep); font-size: 11px; width: 18px; flex: none;
  padding: 4px 2px; border-radius: 4px; transition: transform var(--tr-fast);
}
#dish-table .chev:hover { color: var(--green-deep); background: var(--bg-hover); }
#dish-table .dish-row td { border-top: 1px solid var(--bg-sunken); }
#dish-table .dish-row:first-child td { border-top: none; }

/* ============================================================
   v27 — filter-bar fit, food picker, dish-table polish
   ============================================================ */

/* view segs never spill: scroll inside their own pill on narrow screens */
.filter-bar .seg { max-width: 100%; min-width: 0; overflow-x: auto; scrollbar-width: none; flex: 0 1 auto; }
.filter-bar .seg::-webkit-scrollbar { display: none; }
.filter-bar .seg button { white-space: nowrap; }
#ing-count, #dish-count { white-space: nowrap; }

/* ---- food picker popup ---- */
.fp-body { display: flex; flex-direction: column; gap: 10px; }
.fp-list {
  max-height: 300px; overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--bg-sunken); border-radius: 8px; background: #fff;
}
.fp-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 12px; border: none; background: none; cursor: pointer;
  font: 500 var(--fs-sm) var(--font-ui); color: var(--ink); text-align: left;
  border-bottom: 1px solid var(--bg-sunken);
}
.fp-item:last-child { border-bottom: none; }
.fp-item:hover { background: var(--bg-hover); }
.fp-item.sel { background: var(--green-deep); color: var(--gold); }
.fp-item.sel .tiny, .fp-item.sel .fp-kcal { color: #B5D3A8; }
.fp-item .fp-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fp-item .fp-kcal { flex: none; font-size: var(--fs-xs); color: var(--ink-faint); }
.fp-empty { padding: 14px; text-align: center; color: var(--ink-faint); font-size: var(--fs-sm); }
.fp-qty { display: flex; align-items: center; gap: 10px; }
.fp-chips { max-height: 84px; }
.fp-checklist { display: flex; flex-direction: column; max-height: 320px; overflow-y: auto; }
.fp-check {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-bottom: 1px solid var(--bg-sunken); cursor: pointer;
}
.fp-check:hover { background: var(--bg-hover); }
.fp-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--green-deep); }
.fp-check-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: var(--fs-sm); }
.fp-check-g { flex: none; color: var(--ink-faint); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }

/* ---- dish table polish ---- */
#dish-table .i-remove {
  border: none; background: none; cursor: pointer; flex: none;
  color: #C9B8A0; font-size: 12px; font-weight: 700; line-height: 1;
  width: 22px; height: 22px; border-radius: 5px; margin-right: 2px;
  transition: color var(--tr-fast), background var(--tr-fast);
}
#dish-table .i-remove:hover { color: var(--danger); background: var(--danger-soft); }
#dish-table td.rowhead .cell-name { flex: 1 1 auto; min-width: 60px; }

/* ============================================================
   v28 — dishes chrome parity + picker nutrient table
   ============================================================ */

/* the sticky corner cell always wins the stacking contest */
#dish-table thead th.rowhead { z-index: 5; }
#dish-table tbody td.rowhead { display: flex; align-items: center; gap: 3px; }
#dish-table .i-remove { margin-right: 0; }

/* food picker: nutrient table */
.fp-table-wrap {
  max-height: 190px; overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--bg-sunken); border-radius: 8px; background: #fff;
}
.fp-table { width: max-content; min-width: 100%; }
.fp-table th, .fp-table td { padding: 3px 6px; font-size: var(--fs-xs); }
.fp-table thead tr.grp-row th { top: 0; }
.fp-table thead tr.nut-row th { top: 24px; }
.fp-kinds { display: flex; }

/* ============================================================
   v29 — picker table · dish header corners · A–Z fill · badges
   ============================================================ */

/* food picker: full nutrient table like the ingredients page */
.fp-table-wrap { max-height: 46dvh; }
.fp-table .rowhead { position: sticky; left: 0; z-index: 2; background: var(--bg); text-align: left; }
.fp-table thead .rowhead { z-index: 4; }
.fp-table .fp-name { display: inline-block; max-width: 176px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
tr.fp-sel td { background: var(--green-deep) !important; color: var(--gold) !important; }
tr.fp-sel td .tiny, tr.fp-sel td.num { color: var(--gold) !important; }
tr.fp-sel:hover td { background: var(--green-mid) !important; }
.fp-body .filter-bar { flex-wrap: wrap; row-gap: 6px; }

/* dish header: frozen corner cell in BOTH header rows */
#dish-table thead tr.grp-row th.rowhead { top: 0; z-index: 5; }

/* dish name column: name first, delete at the right edge, no indent */
#dish-table td.rowhead { display: flex; align-items: center; gap: 4px; }
#dish-table tr.dish-ing td.rowhead { padding-left: 7px; }
#dish-table td.rowhead .spacer { flex: 1 1 auto; }
#dish-table td.rowhead .cell-name { flex: 1 1 auto; min-width: 50px; }

/* ingredient-count circle replaces the chevron */
.count-badge {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--gold); background: var(--gold-pale);
  color: var(--gold-deep); font: 700 10px/1 var(--font-ui);
  display: grid; place-content: center; cursor: pointer; padding: 0;
  transition: all var(--tr-fast);
}
.count-badge:hover { border-color: var(--gold-mid); box-shadow: 0 1px 4px rgba(120, 90, 0, 0.25); }
.count-badge.open { background: var(--green-deep); border-color: var(--gold); color: var(--gold); }

/* A–Z ribbon fills the block width when space allows */
.az-strip { flex: 1 1 100%; }
.az-strip .tab { flex: 1 1 0; min-width: 0; }
@media (pointer: coarse) {
  .az-strip .tab { flex: 1 0 32px; }
}

/* ============================================================
   v30 — planner 3-panel grid · picker-mode · A–Z fill · perms
   ============================================================ */

/* desktop: day tabs top-left, weekly summary below them, meals right */
@media (min-width: 1101px) {
  .planner-layout {
    grid-template-columns: minmax(330px, 0.95fr) minmax(0, 1.3fr) !important;
    grid-template-areas: "tabs meals" "sum meals" !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
  }
  .planner-layout .p-tabs { grid-area: tabs !important; }
  .planner-layout .p-day { grid-area: meals !important; display: flex; flex-direction: column; min-height: 0; }
  .planner-layout .p-sum { grid-area: sum !important; display: flex; flex-direction: column; min-height: 0; }
  .planner-layout .p-sum .table-scroll { flex: 1 1 auto; min-height: 0; max-height: none !important; }
  .planner-layout .p-day > #meals { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
}
@media (min-width: 961px) and (max-width: 1100px) {
  .planner-layout { display: flex; flex-direction: column; }
  .planner-layout .p-tabs, .planner-layout .p-sum, .planner-layout .p-day { max-height: none; }
}

/* A–Z strip: fill the block width, keep short */
.az-strip { flex: 1 1 100%; width: 100%; }
.az-strip .tab { flex: 1 1 0; min-width: 0; padding-top: 3px; padding-bottom: 3px; }
@media (pointer: coarse) { .az-strip .tab { flex: 1 0 30px; } }

/* ---- picker mode: a real page inside the popup iframe ---- */
body.picker-mode .app-header,
body.picker-mode .tabbar,
body.picker-mode .skip-link { display: none !important; }
body.picker-mode .page { height: 100dvh; padding: 8px !important; }
body.picker-mode .page-title, body.picker-mode .slim-bar { display: none; }
.fp-frame {
  width: 100%; height: min(64dvh, 560px);
  border: 1px solid var(--bg-sunken); border-radius: 8px; background: #fff;
}

/* people sharing modal */
.perm-list { display: flex; flex-direction: column; gap: 2px; max-height: 170px; overflow-y: auto; }
.perm-list label { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; }
.perm-list label:hover { background: var(--bg-hover); }
.perm-sec { font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; color: var(--gold-deep); margin: 10px 0 4px; }

/* desktop planner: exact areas for the 3-panel structure */
@media (min-width: 961px) {
  .planner-layout {
    display: grid !important;
    grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.35fr);
    grid-template-areas: "tabs meals" "sum meals";
    grid-template-rows: auto minmax(0, 1fr);
  }
  .planner-layout .p-tabs { grid-area: tabs; }
  .planner-layout .p-day { grid-area: meals; }
  .planner-layout .p-sum { grid-area: sum; }
  .planner-layout .p-sum .summary-head { padding: 10px 14px; }
  .planner-layout .p-sum .sh-title { white-space: normal; }
}

/* password eye toggle */
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { width: 100%; padding-right: 40px; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: none; cursor: pointer; color: var(--ink-faint);
  font-size: 13px; line-height: 1; padding: 4px; border-radius: 4px;
}
.pw-eye:hover { color: var(--gold-deep); background: var(--bg-hover); }
.pw-eye.on { color: var(--green-deep); }

/* copy ↓ / send ↑ arrows: small dark-green circles, white background, gold arrow */
.copy-btn, .m-copy {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 1.5px solid var(--green-deep);
  color: var(--gold-mid) !important;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px !important; font-weight: 700; cursor: pointer;
  box-shadow: 0 1px 3px rgba(20, 83, 45, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all var(--tr-fast);
  text-shadow: none;
}
.copy-btn:hover, .m-copy:hover {
  background: var(--green-deep); border-color: var(--gold);
  color: var(--gold) !important;
  box-shadow: 0 2px 6px rgba(20, 83, 45, 0.35);
}

/* dish table corner cells: both header rows get a solid sticky-left cell
   (previously only the tbody rowhead had one, so scrolling right showed
   nutrient headers sliding across the frozen column) */
#dish-table thead tr.grp-row th.rowhead {
  position: sticky; left: 0; top: 0; z-index: 5;
  background: var(--bg-tint);
  box-shadow: inset -2px 0 0 rgba(201, 151, 28, 0.25);
  display: table-cell;               /* never flex: flex breaks rowspan covering */
  vertical-align: bottom;
}
#dish-table thead tr.nut-row th { border-bottom: 2px solid var(--gold); }

/* day-head copy/send circles match the shared style */
.copy-btn { margin: 0 2px; }

/* ============================================================
   v32 — bigger day ribbon; Auto Portion stays on one line
   ============================================================ */

/* ribbon cells stack: name / live value / symbol+target / progress bar */
#nut-strip { align-items: stretch; }
.nut-cell {
  width: auto; min-width: 96px;
  padding: 6px 10px 7px;
  display: flex; flex-direction: column; gap: 1px;
  align-items: flex-start; text-align: left;
}
.nut-cell .n-name { font-size: 10px; }
.nut-cell .n-actual { font-size: 1rem; line-height: 1.35; }
.nut-cell .n-target { font-size: 0.8rem; line-height: 1.3; }
.nut-cell .cbar { width: 100%; align-self: stretch; }
.nut-cell.daily-cell { min-width: 86px; justify-content: center; }
.nut-cell.daily-cell .switch { width: 40px; height: 22px; }
.nut-cell.daily-cell .switch .thumb { width: 18px; height: 18px; }
.nut-cell.daily-cell .switch input:checked ~ .thumb { left: 20px; }

/* Auto Portion + title share one line even on mobile: no wrap between them */
.summary-head { flex-wrap: wrap; }
.summary-head > div { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.summary-head .btn.hero { flex: none; white-space: nowrap; }
.summary-head .seg { flex: none; }
@media (max-width: 600px) {
  /* person · date · Auto Portion stay on exactly one line; the title truncates */
  .summary-head { flex-wrap: nowrap; gap: 8px; }
  .summary-head > div { flex-wrap: nowrap; }
  .summary-head .btn.hero { padding: 9px 14px; }
  .summary-head .seg button { padding: 6px 9px; }
}

/* past days: editable but excluded from solving — items read normally,
   only the auto toggle is locked off */
.item-row.past-day { opacity: 1; }
.item-row.past-day .switch.auto { opacity: 0.45; }
.day-pick.past { opacity: 0.6; }

/* ============================================================
   v45 — ingredient auto-fill lookup
   ============================================================ */
.lk-name-wrap { display: flex; align-items: center; gap: 4px; }
.lk-name-wrap input { flex: 1 1 auto; min-width: 0; }
.lk-btn { flex: none; padding: 3px 8px; font-size: 13px; }
.lk-list { display: flex; flex-direction: column; max-height: 340px; overflow-y: auto; }
.lk-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border: none; background: none; cursor: pointer;
  font: 500 var(--fs-sm) var(--font-ui); color: var(--ink); text-align: left;
  border-bottom: 1px solid var(--bg-sunken);
}
.lk-item:last-child { border-bottom: none; }
.lk-item:hover { background: var(--bg-hover); }
.lk-src { flex: none; min-width: 44px; justify-content: center; }
/* two lines per result: the name on top (auto-scroll marquee on hover),
   source chip / fill count / energy beneath */
.lk-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lk-name {
  flex: 1 1 auto; min-width: 0;
  overflow-x: auto; white-space: nowrap;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.lk-name::-webkit-scrollbar { display: none; }
.lk-meta { display: flex; align-items: center; gap: 10px; }
.lk-kcal { flex: none; color: var(--ink-faint); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }

/* ============================================================
   v48 — recipe popup (steps + share/copy)
   ============================================================ */
.rcp-btn {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--green-deep); background: #fff;
  color: var(--green-deep); font: 700 12px/1 var(--font-ui);
  cursor: pointer; display: grid; place-content: center; padding: 0;
  transition: all var(--tr-fast);
}
.rcp-btn:hover { background: var(--green-deep); color: var(--gold); }
.rcp-body { display: flex; flex-direction: column; gap: 14px; }
.rcp-body h4 {
  margin: 0 0 6px; font-size: var(--fs-xs); letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--gold-deep);
}
.rcp-ing-table { border-collapse: collapse; width: 100%; }
.rcp-ing-table td { padding: 4px 6px 4px 0; font-size: var(--fs-sm); border-bottom: 1px dashed var(--bg-sunken); }
.rcp-ing-table td.num { text-align: right; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rcp-steps { display: flex; flex-direction: column; gap: 8px; }
.rcp-step { display: flex; gap: 10px; align-items: flex-start; }
.rcp-n {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--green-deep); color: var(--gold);
  font: 700 11px/22px var(--font-ui); text-align: center; margin-top: 1px;
}
.rcp-t { font-size: var(--fs-sm); line-height: 1.5; }

/* ============================================================
   v54 — picker check ticks · send-to · sticky-cell guards ·
   one-row meal heads · scrollable item names
   ============================================================ */

/* ---- picker mode: check circle before the name; exactly one row at a
   time can carry the ✓ (the page toggles tr.fp-sel) ---- */
.fp-tick { display: none; }
body.picker-mode #ing-body tr .fp-tick,
body.picker-mode #dish-list tr.dish-row .fp-tick {
  display: inline-grid; place-content: center; flex: none;
  width: 19px; height: 19px; border-radius: 50%;
  border: 1.5px solid #C9C2A2; background: #fff;
  color: transparent; font: 800 12px/1 var(--font-ui);
  cursor: pointer; transition: all var(--tr-fast);
}
body.picker-mode #ing-body tr:hover .fp-tick,
body.picker-mode #dish-list tr.dish-row:hover .fp-tick { border-color: var(--gold-mid); }
body.picker-mode #ing-body tr.fp-sel .fp-tick,
body.picker-mode #dish-list tr.fp-sel .fp-tick {
  background: var(--green-deep); border-color: var(--green-deep); color: var(--gold);
}

/* ---- ingredients: send-to circle before the name ---- */
.sendto-btn {
  flex: none; width: 21px; height: 21px; border-radius: 50%;
  border: 1.5px solid var(--green-deep); background: #fff;
  color: var(--green-deep); font: 700 12px/1 var(--font-ui);
  display: inline-grid; place-content: center; padding: 0; cursor: pointer;
  transition: all var(--tr-fast);
}
.sendto-btn:hover { background: var(--green-deep); color: var(--gold); }

/* ---- sticky name columns: nothing (✕ delete, ⌕ lookup) may ever poke
   out of the frozen column into the nutrient grid ---- */
#ingredient-list td.rowhead,
#ingredient-list tfoot td.rowhead { overflow: hidden; }
#ingredient-list td.rowhead .rname-flex { flex-wrap: nowrap; }
#ing-add-row input.cell-name { min-width: 0; }
#dish-table td.rowhead { overflow: hidden; }
#dish-table td.rowhead .cell-name { min-width: 0; flex: 1 1 30px; }
#dish-table td.rowhead .fp-tick { margin-right: 1px; }

/* ---- meal head: two rows, both always visible (collapsed or not) —
       row 1: badge · name · mass · price · ↓ · ↑ · row 2: nutrient chips.
       nowrap is REQUIRED: a wrapping COLUMN flex container sizes each line
       to its content, so the chip strip would stretch to its max-content
       width (≈1800px) instead of the head and spill off the panel — with
       nowrap the single line is the head's width and the strip scrolls
       inside itself ---- */
.meal-head { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0; padding: 0; }
.meal-head .m-row {
  display: flex; align-items: center; flex-wrap: nowrap; gap: 8px;
  padding: 8px 12px; width: 100%;
}
.meal-head .m-name { flex: 0 1 auto; min-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-head .m-mass, .meal-head .m-cost { flex: none; }
.meal-head .spacer { flex: 1 1 auto; min-width: 6px; }
.meal-head .count-badge { width: 26px; height: 26px; font-size: 11px; }
.meal-sec:not(.collapsed) .meal-head .count-badge { background: var(--green-deep); border-color: var(--gold); color: var(--gold); }
.meal-head .caret { display: none; }   /* the count badge replaced the caret */

/* meal nutrient chips: the header's second row (inside the clickable head,
   so they stay visible when the meal is collapsed) */
.meal-head > .m-nutstrip {
  flex: none; display: flex; gap: 4px; align-items: center;
  overflow-x: auto; padding: 0 12px 6px; scrollbar-width: thin;
  -webkit-overflow-scrolling: touch; cursor: default;
}

/* ---- plan item names: scroll horizontally when longer than the row,
   snapped back to the left on any click elsewhere ---- */
.item-row .i-name { display: flex; align-items: center; overflow: hidden; }
.item-row .i-name .nm {
  flex: 1 1 auto; min-width: 0; display: block;
  overflow-x: auto; white-space: nowrap;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.item-row .i-name .nm::-webkit-scrollbar { display: none; }
/* the selected row keeps a soft tint and its overlong name auto-scrolls */
.item-row.sel-row { background: var(--bg-hover); }

/* ---- lookup results: how much of the 29-nutrient profile is filled ---- */
.lk-fill {
  flex: none; font-size: var(--fs-xs); font-weight: 700;
  color: var(--gold-deep); font-variant-numeric: tabular-nums;
}

/* ---- recipe method editor ---- */
.rcp-edit {
  flex: 1 1 auto; min-width: 0; resize: vertical;
  font: 500 var(--fs-sm) var(--font-ui); line-height: 1.45;
}
#dish-table .rcp-steps .rcp-step .i-remove {
  color: #C9B8A0; width: 22px; height: 22px; flex: none;
}

/* ============================================================
   v55 — restored dish methods · db- dish ids · consistent circles
   · send-to at the right of name columns · picker popup compaction
   · 7-days-per-week day picker · planner row rework
   ============================================================ */

/* ---- ingredients rowhead: name fills the column, send-to at its right ---- */
#ingredient-list td.rowhead .rname-flex .cell-name,
#ingredient-list tfoot td.rowhead .cell-name {
  flex: 1 1 auto; width: auto; min-width: 0;
}
#ingredient-list td.rowhead .sendto-btn { margin-left: 2px; }

/* ---- dishes rowhead: name fills, recipe ℹ + send-to ↑ at the right;
     the delete cross moved to the trailing Actions column ---- */
#dish-table td.rowhead .cell-name { flex: 1 1 auto; }
#dish-table td.action-cell { text-align: center; }
#dish-table td.action-cell .i-remove { margin: 0 auto; }
#dish-table thead th.hcenter { text-align: center; }

/* ---- meal head: the ＋ Add button lives on the bottom row again; the ↓/↑
     arrows must be perfect circles — the old .meal-head .m-copy rule
     (border-radius 4px, padding 2px 3px) out-specifies the shared circle
     style, so re-assert shape + size at equal specificity, later ---- */
.meal-head .m-copy { border-radius: 50%; padding: 0; width: 20px; height: 20px; }

/* ---- plan item rows: send-to ↑ and remove ✕ as small circles (match the
     day/meal copy arrows); the ✕ sits right-most, qty box to its left ---- */
.item-row .i-copy, .item-row .i-del {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; line-height: 1; padding: 0;
  cursor: pointer; transition: all var(--tr-fast);
}
.item-row .i-copy {
  border: 1.5px solid var(--green-deep); background: #fff; color: var(--gold-mid);
  box-shadow: 0 1px 3px rgba(20, 83, 45, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.item-row .i-copy:hover {
  background: var(--green-deep); border-color: var(--gold); color: var(--gold) !important;
}
.item-row .i-del { border: 1.5px solid #DCD6BC; background: #fff; color: var(--ink-faint); }
.item-row:hover .i-del { color: #C9B8A0; }
.item-row .i-del:hover {
  background: var(--danger); border-color: var(--danger); color: #fff !important;
}

/* solver state selector: green A = auto (solver may adjust), grey = fixed */
.auto-toggle {
  flex: none; width: 18px; height: 18px; border-radius: 50%;
  border: none; padding: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--lime-deep); color: #fff;
  font: 800 9px/1 var(--font-ui);
  transition: background var(--tr-fast), filter var(--tr-fast);
}
.auto-toggle:hover { filter: brightness(1.08); }
.auto-toggle.off { background: #C4BD9E; }
.auto-toggle:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- day picker: 7 days side by side per labelled week ---- */
.day-pick-weeks { display: flex; flex-direction: column; gap: 12px; }
.dp-week { display: flex; flex-direction: column; gap: 4px; }
.dp-week-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase; color: var(--gold-deep); padding-left: 2px;
}
.day-pick-grid:not(.meals) { grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day-pick-grid:not(.meals) .day-pick { padding: 5px 2px 4px; border-radius: 7px; }
.day-pick-grid:not(.meals) .dp-dw { font-size: 8px; }
.day-pick-grid:not(.meals) .dp-dd { font-size: 1rem; }
.day-pick-grid:not(.meals) .dp-n { font-size: 8.5px; }
@media (max-width: 480px) {
  .day-pick-grid:not(.meals) { gap: 3px; }
  .day-pick-grid:not(.meals) .dp-dd { font-size: 0.9rem; }
  .day-pick-grid:not(.meals) .dp-n { display: none; }
}

/* ---- food picker popup: compact chrome, maximum table ---- */
.modal.compact .modal-head { padding: 7px 12px; }
.modal.compact .modal-head h3 { font-size: var(--fs-body); }
.modal.compact .modal-close { font-size: 17px; padding: 2px 4px; }
.modal.compact .modal-body { padding: 8px 10px; }
.modal.compact .modal-foot { padding: 7px 10px; gap: 8px; }
.modal.compact .fp-foot { display: flex; align-items: center; gap: 8px; width: 100%; }
.modal.compact .fp-foot-left { margin-right: auto; display: flex; align-items: center; min-width: 0; }
.modal.compact .fp-foot .btn { padding: 5px 12px; }
.fp-body { gap: 8px; }
.fp-frame { height: min(74dvh, 680px); }
body.picker-mode .page { padding: 6px !important; }

/* picker mode: rows are choices — no send/delete chrome (kept invisible so
   the column layout never shifts) */
body.picker-mode #dish-list .sendto-btn,
body.picker-mode #dish-list .action-cell { visibility: hidden; }
