/* The week builder and the screens around it. Tokens come from styles.css. */

/* ---------- shared controls ---------- */
.button--small { min-height: 36px; padding: 0 13px; font-size: 13px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span { display: block; height: 32px; padding: 0 12px; border: 1px solid var(--rule-2); border-radius: var(--radius); background: var(--white); font-size: 13px; line-height: 30px; white-space: nowrap; }
.chip:hover span { border-color: var(--ink); }
.chip input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--white); }
.chip input:disabled { cursor: default; }
.chip input:disabled + span { opacity: 0.75; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.lock { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid transparent; border-radius: var(--radius); background: none; color: var(--ink-3); cursor: pointer; }
.lock:hover { border-color: var(--rule-2); color: var(--ink); }
.lock[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--white); }
select, input[type="number"], input[type="search"], input[type="text"] { font-family: var(--sans); }

/* ---------- builder frame ---------- */
.wb { min-width: 0; }
.wb__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.wb__group { display: flex; flex-wrap: wrap; gap: 6px; }
.wb__group:empty { display: none; }
.wb__select, .wb__template input, .detail__actions select { height: 36px; max-width: 100%; padding: 0 8px; border: 1px solid var(--rule-2); border-radius: var(--radius); background: var(--white); color: var(--ink); font-size: 13px; }
.wb__template { display: flex; flex-wrap: wrap; gap: 6px; }
.wb__targets { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 28px; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.target { display: grid; gap: 2px; }
.target > span:first-child { font-size: 12px; font-weight: 500; }
.target__row { display: flex; align-items: baseline; gap: 6px; }
.target input { width: 96px; height: 36px; padding: 0 8px; border: 1px solid var(--rule-2); border-radius: var(--radius); font: 400 18px var(--mono); color: var(--ink); background: var(--white); }
.target em { font: normal 400 12px var(--mono); color: var(--ink-3); }
.target small { font-size: 11px; color: var(--ink-3); }
.wb__avoid { flex: 1 1 280px; font-size: 13px; }
.wb__avoid summary { cursor: pointer; padding: 8px 0; }
.wb__avoid .checks { padding: 4px 0 6px; }
.wb__status { padding: 8px 16px; border-bottom: 1px solid var(--rule); background: var(--accent-wash); font-size: 13px; }
.wb__status:empty { display: none; }
.wb__body { display: grid; grid-template-columns: 276px minmax(0, 1fr); }
.wb__main { min-width: 0; }

/* ---------- library ---------- */
.lib { display: flex; flex-direction: column; gap: 10px; min-height: 0; max-height: 920px; padding: 14px 14px 0; border-right: 1px solid var(--ink); }
.lib__head { display: grid; gap: 8px; }
.lib__title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lib__title h3 { font: 500 21px/1.2 var(--display); }
.lib__head p { font-size: 12px; color: var(--ink-3); }
.lib__tabs { display: grid; grid-template-columns: repeat(4, auto); border: 1px solid var(--rule-2); border-radius: var(--radius); }
.lib__tabs button { min-height: 32px; padding: 0 4px; border: 0; background: var(--white); font-size: 12px; cursor: pointer; }
.lib__tabs button + button { border-left: 1px solid var(--rule-2); }
.lib__tabs button[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.lib > input { width: 100%; height: 38px; padding: 0 10px; border: 1px solid var(--rule-2); border-radius: var(--radius); font-size: 14px; }
.lib__list { flex: 1; min-height: 0; overflow-y: auto; margin-inline: -14px; border-top: 1px solid var(--rule); }
.dish { position: relative; display: grid; gap: 2px; width: 100%; padding: 10px 52px 10px 14px; border: 0; border-bottom: 1px solid var(--rule); background: var(--white); text-align: left; cursor: grab; }
.dish:hover { background: var(--stone); }
.dish__name { font-size: 14px; font-weight: 500; line-height: 1.3; }
.dish__meta { font: 400 11px var(--mono); color: var(--ink-3); }
.dish__meta b { margin-left: 8px; font-weight: 500; color: var(--accent); }
.dish__fit { position: absolute; right: 12px; top: 11px; padding: 0 6px; border: 1px solid var(--ink); font: 400 10px/16px var(--mono); }
.lib__none { padding: 12px 14px; font-size: 12px; color: var(--ink-3); }

/* ---------- week grid ---------- */
.wb__daytabs { display: none; }
.grid { display: grid; grid-template-columns: 76px repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--ink); }
.grid__corner { border-bottom: 1px solid var(--ink); }
.grid__day, .wb__daytabs button { display: grid; grid-template-columns: auto auto; justify-content: center; align-items: center; column-gap: 6px; padding: 8px 2px; border: 0; border-left: 1px solid var(--rule); border-bottom: 1px solid var(--ink); background: var(--white); cursor: pointer; }
.grid__day b, .wb__daytabs b { font-size: 13px; font-weight: 500; }
.grid__day small, .wb__daytabs small { grid-column: 1 / -1; font: 400 11px var(--mono); color: var(--ink-3); }
.grid__day i, .wb__daytabs i { width: 8px; height: 8px; border: 1px solid var(--rule-2); border-radius: 50%; }
.is-on > i { background: var(--ink); border-color: var(--ink) !important; }
.is-partial > i { background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); border-color: var(--ink) !important; }
.is-off > i { background: var(--accent); border-color: var(--accent) !important; }
.grid__day[aria-pressed="true"], .wb__daytabs button[aria-pressed="true"] { background: var(--stone-2); }
.grid__meal { display: flex; align-items: center; padding: 0 6px 0 10px; border-bottom: 1px solid var(--rule); font-size: 12px; color: var(--ink-2); }
.cell { position: relative; min-width: 0; min-height: 96px; border-left: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.cell__main { display: flex; flex-direction: column; justify-content: space-between; gap: 4px; width: 100%; height: 100%; padding: 8px 7px 7px; border: 0; background: var(--white); text-align: left; cursor: pointer; overflow: hidden; }
.cell__main:hover { background: var(--stone); }
.cell__name { font-size: 12px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; hyphens: auto; }
.cell__kcal { display: flex; justify-content: space-between; align-items: center; font: 400 10.5px var(--mono); color: var(--ink-3); }
.cell__add { margin: auto; font: 300 22px var(--mono); color: var(--rule-2); }
.cell.is-filled .cell__main { cursor: grab; }
.cell.is-selected { box-shadow: inset 0 0 0 2px var(--accent); }
.cell.is-selected .cell__main { background: var(--accent-wash); }
.cell__remove { position: absolute; top: 1px; right: 1px; width: 22px; height: 22px; border: 0; background: var(--white); font-size: 16px; line-height: 1; cursor: pointer; opacity: 0; }
.cell:hover .cell__remove, .cell:focus-within .cell__remove { opacity: 1; }
.wb.is-dragging .cell { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--stone-2) 6px 7px); }
.wb.is-dragging .cell__main { background: transparent; }
.wb.is-dragging .cell.is-refused { opacity: 0.3; }
.cell.is-over { box-shadow: inset 0 0 0 2px var(--ink); background: var(--stone-2) !important; }

/* ---------- selected meal and day ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; }
.detail > section { padding: 18px 20px 22px; min-width: 0; }
.detail__day { border-left: 1px solid var(--rule); }
.detail h3 { font: 500 22px/1.2 var(--display); }
.detail__when { font-size: 12px; color: var(--accent); }
.detail__sum { margin-top: 4px; font: 400 12px var(--mono); color: var(--ink-2); }
.detail__empty { margin-top: 6px; color: var(--ink-3); font-size: 14px; }
.detail__method { margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.detail__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; margin-top: 12px; }
.lines { margin-top: 12px; border-top: 1px solid var(--ink); }
.lines li { display: grid; grid-template-columns: minmax(0, 1fr) auto 32px auto; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--stone-2); }
.lines li.is-locked { background: var(--accent-wash); }
.lines__name { font-size: 14px; line-height: 1.3; }
.lines__name small { display: block; font-size: 11px; color: var(--ink-3); }
.lines__weight { display: inline-flex; align-items: baseline; gap: 4px; }
.lines__weight input { width: 70px; height: 34px; padding: 0 4px; border: 0; border-bottom: 1px solid var(--rule-2); background: transparent; text-align: right; font: 500 16px var(--mono); color: var(--ink); }
.lines__weight input:focus { border-bottom-color: var(--accent); }
.lines__weight em { font: normal 400 12px var(--mono); color: var(--ink-3); }
.detail__dayhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.pill { padding: 1px 8px; border: 1px solid var(--rule-2); border-radius: var(--radius); font: 400 11px/18px var(--mono); }
.pill.is-on { background: var(--ink); border-color: var(--ink); color: var(--white); }
.pill.is-off { background: var(--accent); border-color: var(--accent); color: var(--white); }
.meters { display: grid; gap: 10px; margin-top: 14px; }
.meter__head { display: flex; align-items: baseline; gap: 6px; }
.meter__head span { flex: 1; font-size: 13px; }
.meter__head b { font: 400 22px/1 var(--mono); letter-spacing: -0.04em; }
.meter__head em { font: normal 400 11px var(--mono); color: var(--ink-3); }
.meter__bar { position: relative; height: 7px; margin-top: 5px; background: var(--stone-2); }
.meter__bar i { position: absolute; inset: 0 auto 0 0; background: var(--ink); transition: width 0.3s var(--ease); }
/* The target sits at four fifths of the bar. */
.meter__bar u { position: absolute; left: 80%; top: -3px; bottom: -3px; width: 2px; background: var(--accent); }
.meter.is-off .meter__bar i { background: var(--accent); }
.meter.is-off .meter__head b { color: var(--accent); }
.meter.is-off .meter__bar u { background: var(--ink); }
.detail__verdict { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--ink-2); }
.detail__verdict.is-off { color: var(--accent); }
.detail__verdict span { color: var(--ink-2); }
.micros { margin-top: 12px; border-block: 1px solid var(--rule); font-size: 13px; }
.micros summary { cursor: pointer; padding: 9px 0; font-weight: 500; }
.micros dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; margin: 0; }
.micros dl div { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px solid var(--stone-2); }
.micros dd { margin: 0; font: 400 12px var(--mono); }
.micros p { padding: 8px 0; }

/* ---------- handout additions ---------- */
.sheet__method { margin-top: 6px; font-size: 12px; color: var(--ink-2); }
.shopping__aisle { padding-top: 14px; break-inside: avoid; }
.shopping__aisle h4 { font: 500 15px var(--display); }

/* ---------- client page ---------- */
.client-head { padding-top: 24px; }
.client-head .page-head { margin-bottom: 16px; }
.client-head .page-head__actions { align-items: center; }
.tabs, .share__tabs { display: flex; flex-wrap: wrap; gap: 24px; border-bottom: 1px solid var(--ink); }
.tab { min-height: 42px; padding: 0 2px; border: 0; border-radius: 0; background: none; color: var(--ink-3); font-size: 14px; }
.tab[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 -3px var(--accent); }
.savestate.is-error { color: var(--accent); font-size: 15px; }
.history { margin-top: 14px; font-size: 13px; }
.history summary { cursor: pointer; font-weight: 500; }
.history ul { margin-top: 8px; max-width: 520px; }
.history li { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid var(--rule); }
.history li span { padding-block: 6px; }
.split { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 48px; align-items: start; }
.split h2, .side h2, .section > h2 { margin: 28px 0 10px; font-size: 28px; }
.split > div > h2:first-of-type, .side h2:first-child { margin-top: 0; }
.side { display: grid; gap: 12px; align-content: start; padding: 22px; border: 1px solid var(--ink); }
.form__grid--even > :first-child { grid-column: auto; }
.labs { display: grid; gap: 8px; }
.labs__row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.rows { border-top: 1px solid var(--ink); }
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.rows li > div { display: grid; gap: 2px; min-width: 0; }
.rows b { font-weight: 500; }
.rows span { font-size: 14px; color: var(--ink-2); }
.rows small { font-size: 12px; color: var(--ink-3); }
.rows li.is-flag b { color: var(--accent); }
.rows .link { flex: none; }
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }
.figure figcaption { font-size: 13px; font-weight: 500; }
.chart { display: block; width: 100%; height: auto; }
.chart__grid { stroke: var(--stone-2); }
.chart__line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart__dot { fill: var(--accent); }
.chart__text { fill: var(--ink-3); font: 400 12px var(--mono); }
.plain { width: 100%; border-collapse: collapse; font-size: 14px; }
.plain th, .plain td { padding: 9px 14px 9px 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.plain thead th { font-size: 12px; font-weight: 400; color: var(--ink-3); border-bottom-color: var(--ink); }
.plain tbody th { font-weight: 500; }
.plain small { display: block; font: 400 11px var(--sans); color: var(--ink-3); }
.sharelink { display: grid; gap: 8px; margin-top: 12px; }
.sharelink input { width: 100%; min-height: 42px; padding: 0 10px; border: 1px solid var(--rule-2); font: 400 13px var(--mono); }
.today { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; margin-bottom: 36px; }
.today h2 { margin-bottom: 8px; font-size: 26px; }
.today a { text-decoration: none; }
.today a:hover { text-decoration: underline; }
.dislikes { display: grid; gap: 0; border-top: 1px solid var(--rule); }
.dislikes details { border-bottom: 1px solid var(--rule); }
.dislikes summary { padding: 9px 0; font-size: 13px; cursor: pointer; }
.dislikes summary b { color: var(--accent); }
.dislikes .checks { padding-bottom: 12px; }

/* ---------- foods and recipes ---------- */
.foodsearch { display: grid; gap: 10px; }
.foodsearch__row { display: flex; flex-wrap: wrap; gap: 8px; }
.foodsearch__row input, .foodsearch__row select, .ingredients input, .ingredients select, .ownfood input { min-height: 42px; padding: 0 10px; border: 1px solid var(--rule-2); border-radius: var(--radius); background: var(--white); font-size: 14px; }
.field .foodsearch__row input { flex: 1 1 240px; width: auto; }
.field .foodsearch__row select { width: auto; max-width: 100%; }
.foodsearch__row input { flex: 1 1 240px; }
.field .found { max-height: 420px; overflow-y: auto; }
.ingredients { border-top: 1px solid var(--ink); }
.ingredients li { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.ingredients__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.field .ingredients__row > input { flex: 1 1 200px; width: auto; }
.field .ingredients__row > select { width: auto; }
.field .ingredients .lines__weight input { width: 76px; min-height: 42px; border-width: 0 0 1px; }
.field .ingredients li > select { width: 100%; }
.totals { font: 400 12px var(--mono); }
.totals:empty { display: none; }
.ownfood { font-size: 13px; }
.ownfood summary { cursor: pointer; font-weight: 500; padding: 6px 0; }
.ownfood__row { display: grid; grid-template-columns: 2fr repeat(4, minmax(0, 1fr)) auto; gap: 6px; margin-top: 6px; }
.field .ownfood__row input { width: 100%; }
.confirm { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.field .confirm input { width: auto; min-height: 0; margin-top: 3px; }
.builtin { margin-top: 36px; }
.builtin summary { cursor: pointer; font-weight: 500; padding: 10px 0; }

/* ---------- homepage additions ---------- */
.tables { margin-top: 64px; padding-top: 18px; border-top: 1px solid var(--ink); }
.tables h3 { font: 500 24px/1.3 var(--display); }
.tables ul { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 18px; }
.tables li { display: grid; padding: 10px 0; border-top: 1px solid var(--rule); }
.tables li b { font-weight: 500; }
.tables li span { font: 400 12px var(--mono); color: var(--ink-3); }
.tables p { margin-top: 16px; font-size: 13px; color: var(--ink-3); }

/* ---------- the client's own page ---------- */
.shared main { max-width: 560px; margin-inline: auto; padding: 24px 18px 48px; }
.share__head h1 { margin-top: 4px; font-size: 38px; line-height: 1.1; }
.share__head p:last-child { color: var(--ink-2); font-size: 14px; }
.share__tabs { margin-top: 18px; }
.share__days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); margin-top: 14px; border: 1px solid var(--ink); }
.daytab { min-height: 44px; border: 0; background: var(--white); font-size: 13px; cursor: pointer; }
.daytab + .daytab { border-left: 1px solid var(--rule); }
.daytab[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.share__message { margin-top: 10px; font-size: 13px; color: var(--accent); }
.share__meal { padding: 20px 0; border-bottom: 1px solid var(--ink); }
.share__meal h2, .share__aisle h2 { font-size: 26px; line-height: 1.2; }
.share__items { margin-top: 10px; }
.share__items li { display: grid; grid-template-columns: minmax(0, 1fr) 64px 88px; gap: 8px; align-items: baseline; padding: 6px 0; border-bottom: 1px dotted var(--rule-2); font-size: 15px; }
.share__items b { font: 500 14px var(--mono); text-align: right; }
.share__items small { font-size: 12px; color: var(--ink-2); }
.share__checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.share__checks button[aria-pressed="true"] { background: var(--ink); color: var(--white); }
.share__other { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.share__other input { flex: 1 1 220px; min-height: 40px; padding: 0 10px; border: 1px solid var(--rule-2); font-size: 16px; }
.share__aisle { padding-top: 22px; }
.share__aisle li { border-bottom: 1px solid var(--rule); }
.share__aisle label { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 46px; cursor: pointer; }
.share__aisle input { width: 18px; height: 18px; accent-color: var(--accent); }
.share__aisle input:checked + span { text-decoration: line-through; color: var(--ink-3); }
.share__aisle b { font: 500 13px var(--mono); text-align: right; }
.share__aisle label span small { display: block; font-size: 12px; color: var(--ink-3); }
.share__foot { margin-top: 28px; font-size: 12px; color: var(--ink-3); }

/* ---------- narrower screens ---------- */
@media (max-width: 1180px) {
  .wb__body { grid-template-columns: 236px minmax(0, 1fr); }
  .grid { grid-template-columns: 62px repeat(7, minmax(0, 1fr)); }
  .cell__name { font-size: 11px; }
  .detail { grid-template-columns: minmax(0, 1fr); }
  .detail__day { border-left: 0; border-top: 1px solid var(--ink); }
}
@media (max-width: 960px) {
  .split, .today { grid-template-columns: minmax(0, 1fr); }
  .tables ul { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; }
  /* One day at a time: the week becomes tabs, the library follows the meals. */
  .wb__body { display: flex; flex-direction: column; }
  .wb__daytabs { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .wb__daytabs button { column-gap: 3px; }
  .wb__daytabs b { font-size: 12px; }
  .grid { grid-template-columns: 84px minmax(0, 1fr); }
  .grid__corner, .grid__day { display: none; }
  .cell { display: none; min-height: 66px; }
  .cell.is-day { display: block; }
  .cell__name { font-size: 14px; }
  .cell__remove { opacity: 1; width: 34px; height: 34px; }
  .cell__main { padding-right: 38px; }
  .lib { order: 2; max-height: 460px; border-right: 0; border-top: 1px solid var(--ink); }
  .wb__main { order: 1; display: flex; flex-direction: column; }
  .ownfood__row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .wb__targets { gap: 10px 14px; }
  .target input { width: 82px; }
  .detail > section { padding: 16px; }
}
@media print {
  .client-head, .manage, .assistant, .history { display: none !important; }
  .shared .share__checks, .shared .share__other, .shared .share__tabs, .shared .share__days { display: none !important; }
}

/* ---------- phone header and touch sizes ---------- */
@media (max-width: 760px) {
  .portal-header { flex-wrap: wrap; height: auto; padding-block: 12px; row-gap: 4px; }
  .portal-nav { flex-wrap: wrap; column-gap: 18px; row-gap: 0; }
  .portal-nav .link { white-space: nowrap; }
  .chip span { height: 38px; line-height: 36px; }
  .lock { width: 40px; height: 40px; border-color: var(--rule); }
  .lines li { grid-template-columns: minmax(0, 1fr) auto 40px; }
}

/* ---------- the three main tabs in the app header ---------- */
.portal-header { justify-content: flex-start; }
.portal-nav--tabs { margin-right: auto; margin-left: clamp(16px, 4vw, 56px); font-weight: 500; }
.create-head .page-head { margin-bottom: 0; }
.create-head .page-head__actions { flex-wrap: wrap; align-items: center; }
.create-head .page-head__actions .wb__select { height: 42px; font-size: 14px; }
.page-head__actions { flex-wrap: wrap; }
@media (max-width: 960px) {
  .portal-header { flex-wrap: wrap; height: auto; padding-block: 12px; row-gap: 6px; }
  .portal-nav { flex-wrap: wrap; column-gap: 18px; }
  .portal-nav--tabs { order: 3; width: 100%; margin: 0; }
  .portal-header > .portal-nav:last-child { margin-left: auto; }
}
@media print { .create-head { display: none !important; } }

/* ---------- add a client, on the Create plans tab ---------- */
.client-box { padding: 24px; border: 1px solid var(--ink); }
.client-box h2 { margin-bottom: 18px; font-size: 30px; }
.create-existing { margin-top: 20px; font-size: 14px; color: var(--ink-2); }
@media (max-width: 760px) { .client-box { padding: 16px; } }
/* On narrow screens the client form comes first, the notes reader after it. */
@media (max-width: 960px) { .client-form .intake { order: 0; } }

/* Energy equation, macro sliders and food sources. */
.target--equation { max-width: 34ch; }
.target--equation select { min-width: 12em; }
.macros { display: grid; gap: 10px; flex: 1 1 360px; min-width: 280px; max-width: 560px; }
.macro { display: grid; grid-template-columns: 5.5em 1fr; gap: 2px 12px; align-items: center; }
.macro--energy { grid-template-columns: 5.5em 1fr auto; }
.macro__label { font-weight: 600; font-size: 14px; }
.macro__out { grid-column: 2 / -1; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.macro__num { display: inline-flex; align-items: baseline; gap: 4px; }
.macro__num input { width: 5.5em; }
.slider { --c: var(--forest); --thumb: 22px; width: 100%; height: 36px; margin: 0; padding: 0; background: transparent; cursor: grab; touch-action: none; -webkit-appearance: none; appearance: none; }
.slider:active { cursor: grabbing; }
.slider--kcal { --c: var(--accent); }
.slider--p { --c: #c2410c; }
.slider--c { --c: #b7791f; }
.slider--f { --c: #2b6cb0; }
.slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--rule-2); }
.slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--rule-2); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: var(--thumb); height: var(--thumb); margin-top: calc((6px - var(--thumb)) / 2); border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 1px 4px rgb(0 0 0 / 0.35); }
.slider::-moz-range-thumb { width: calc(var(--thumb) - 6px); height: calc(var(--thumb) - 6px); border-radius: 50%; border: 3px solid #fff; background: var(--c); box-shadow: 0 1px 4px rgb(0 0 0 / 0.35); }
.slider:focus-visible { outline: 2px solid var(--c); outline-offset: 2px; border-radius: 6px; }
.macros .field__hint { margin: 0; }
.foodpick__hit { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; }
.foodpick__source, .lines__source { display: block; color: var(--ink-2); font-size: 12px; }

.wb__reach { padding: 10px 16px; border-bottom: 1px solid var(--rule); background: #fff7e6; font-size: 13px; display: grid; gap: 4px; }
.wb__reach p { margin: 0; }
.wb__reach b { font-weight: 600; }

/* Tablets and phones: bigger things to touch, and a shorter targets panel so the week stays in view. */
@media (max-width: 1024px), (pointer: coarse) {
  .slider { --thumb: 30px; height: 44px; }
  .macro { grid-template-columns: 4.6em 1fr auto; row-gap: 0; }
  .macro--energy { grid-template-columns: 4.6em 1fr auto; }
  .macro__out { grid-column: 3; grid-row: 1; white-space: nowrap; font-size: 12px; min-width: 12em; text-align: right; }
  .macro--energy .macro__out { grid-column: 1 / -1; grid-row: 2; white-space: normal; }
  .macros { gap: 2px; }
  .target--equation { max-width: none; flex: 1 1 280px; }
  .wb .target select { min-width: 3.2em; }
  .wb .lines__tool, .wb .lock, .wb .cell__remove { min-width: 36px; min-height: 36px; }
  .wb .target select, .wb .target input, .wb .wb__select { min-height: 40px; }
}
/* A weight that the solver just changed glows briefly (js/builder.js). */
.lines__weight input.is-adjusted { animation: weight-adjusted 0.9s var(--ease); }
@keyframes weight-adjusted { 0%, 30% { background-color: #dcefe1; border-color: var(--accent); } 100% { background-color: var(--field, #fff); } }
@media (prefers-reduced-motion: reduce) { .lines__weight input.is-adjusted { animation: none; } }

/* shop products sit in the same list as plain foods, marked by a small tag */
.rows li.is-product .tag-shop { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--stone-2); color: var(--ink); font-size: 11px; font-weight: 600; }
.found__status { margin-top: 8px; }
.rows li.is-product small > span { font-size: 12px; }

/* ---------- an ingredient's nutrition, in a small window under its name ---------- */
.detail__meal { position: relative; }
.lines__open { padding: 0; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
  text-decoration: underline dotted rgb(18 19 15 / 0.3); text-underline-offset: 3px; transition: color .2s, text-decoration-color .2s; }
.lines__open:hover, .lines__open[aria-expanded="true"] { color: var(--accent-deep); text-decoration-color: currentColor; }
.lines__open:focus-visible { outline: 3px solid rgb(71 118 97 / .35); outline-offset: 2px; border-radius: 4px; }
.nutri { position: absolute; z-index: 20; display: grid; gap: 10px; padding: 14px 16px 16px; border-radius: 16px; background: var(--white);
  box-shadow: 0 0 0 1px rgb(18 19 15 / .06), 0 4px 10px rgb(18 19 15 / .06), 0 22px 44px -16px rgb(18 19 15 / .3); will-change: transform, clip-path; }
.nutri::before { content: ""; position: absolute; top: -6px; left: var(--arrow, 20%); width: 12px; height: 12px; margin-left: -6px; background: var(--white);
  transform: rotate(45deg); border-radius: 3px 0 0 0; box-shadow: -1px -1px 0 rgb(18 19 15 / .06); }
.nutri.is-closing { pointer-events: none; }
.nutri__head { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.nutri__head b { display: block; font-size: 15px; line-height: 1.25; }
.nutri__head small { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-3); }
.nutri__close { flex: none; width: 30px; height: 30px; margin: -4px -6px 0 0; border: 0; border-radius: 8px; background: transparent; font-size: 18px; line-height: 1; color: var(--ink-3); cursor: pointer; }
.nutri__close:hover { background: var(--stone-2); color: var(--ink); }
.nutri__kcal { display: flex; align-items: baseline; gap: 6px; margin: 0; }
.nutri__kcal .mono { font: 600 30px/1 var(--mono); letter-spacing: -0.02em; }
.nutri__kcal span:last-child { font-size: 13px; color: var(--ink-3); }
.nutri__split { display: flex; height: 8px; overflow: hidden; border-radius: 99px; background: var(--stone-2); }
.nutri__part { display: block; width: 0; height: 100%; }
.nutri__part + .nutri__part { box-shadow: -2px 0 0 var(--white); }
.nutri__part--protein, .nutri__macro--protein dt::before { background: #477661; }
.nutri__part--carbs, .nutri__macro--carbs dt::before { background: #d2a24c; }
.nutri__part--fat, .nutri__macro--fat dt::before { background: #b8735a; }
.nutri__macros { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 0; }
.nutri__macro { padding: 8px 10px; border-radius: 10px; background: var(--stone); }
.nutri__macro dt { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.nutri__macro dt::before { content: ""; width: 7px; height: 7px; border-radius: 50%; }
.nutri__macro dd { margin: 2px 0 0; font-size: 12px; color: var(--ink-3); }
.nutri__macro dd .mono { font: 600 17px var(--mono); color: var(--ink); }
.nutri__line, .nutri__per { display: flex; justify-content: space-between; gap: 10px; margin: 0; font-size: 13px; color: var(--ink-2); }
.nutri__line .mono { font: 500 13px var(--mono); color: var(--ink); }
.nutri__per { padding-top: 8px; border-top: 1px solid var(--stone-2); font-size: 12px; color: var(--ink-3); }
.nutri__per .mono { font: 400 12px var(--mono); }
@media print { .nutri { display: none; } }

/* on a phone: a card in the ingredient's row, between its name and its tools */
.nutri.is-inline { position: relative; grid-column: 1 / -1; grid-row: 2; margin-top: 10px; margin-bottom: 4px; overflow: hidden; }
.nutri.is-inline::before { display: none; }
@media (max-width: 760px) {
  .lines__open { min-height: 32px; text-align: left; }
  .nutri__close { width: 40px; height: 40px; margin: -8px -10px 0 0; font-size: 22px; }
  .nutri__kcal .mono { font-size: 28px; }
}

/* the library's switch between meals and single foods */
.lib__mode { display: inline-flex; justify-self: start; gap: 2px; padding: 3px; border-radius: 12px; background: var(--stone-2); }
.lib__mode button { min-height: 32px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; font: inherit; font-size: 13px; color: var(--ink-2); cursor: pointer; transition: background-color .2s, box-shadow .2s; }
.lib__mode button[aria-pressed="true"] { background: var(--white); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }
.lib__mode button:focus-visible { outline: 3px solid rgb(71 118 97 / .35); outline-offset: 2px; }
.lib__foods { padding: 12px 14px; }
.lib__foods .foodsearch__row { flex-direction: column; }
.lib__foods .foodsearch__row input, .lib__foods .foodsearch__row select { width: 100%; flex: none; }
.lib__foods .rows li { padding: 9px 0; }
.lib__foods .rows small { line-height: 1.35; }
@media (max-width: 760px), (pointer: coarse) { .lib__mode button { min-height: 44px; } }
/* meals usually eaten at another time, listed after the best fits */
.lib__group { margin: 10px 4px 4px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
/* a changed meal's method: editable, and amber while it is still the recipe's own */
.detail__method-edit { display: grid; gap: 6px; margin-top: 14px; }
.detail__method-edit > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.detail__method-edit textarea { width: 100%; min-height: 88px; padding: 10px 12px; border: 1px solid rgb(18 19 15 / 0.1); border-radius: var(--radius); background: var(--field, #fbfcfa); font: 400 14px/1.5 var(--sans); color: var(--ink); resize: vertical; }
.detail__method-edit.is-stale { padding: 12px; border-radius: 12px; background: var(--amber-wash); }
.detail__method-edit.is-stale small { font-size: 12px; line-height: 1.45; color: var(--amber); }
.detail__method-edit .link { justify-self: start; }

/* ---------- critique fixes: builder ---------- */
/* the library search keeps its height when the panel is short (phone) */
.lib > input { flex: none; }
/* where a food will go, as a chip rather than a grey hint */
.lib__target { display: grid; gap: 2px; padding: 8px 12px; border-radius: 10px; background: var(--accent-wash); color: var(--accent-deep); }
.lib__target b { font-size: 13px; font-weight: 700; }
.lib__target span { font-size: 12px; color: var(--ink-2); }
/* Meals / Foods reads as a choice of list, unlike the meal-place tabs above it */
.lib__mode { display: flex; gap: 18px; padding: 0 2px; border-bottom: 1px solid var(--rule); background: none; box-shadow: none; }
.lib__mode button { padding: 8px 0; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; box-shadow: none; font-weight: 600; color: var(--ink-3); }
.lib__mode button[aria-pressed="true"] { border-bottom-color: var(--accent); color: var(--ink); background: none; box-shadow: none; }
.lines__legend { margin-top: 8px; font-size: 12px; color: var(--ink-3); }
.foodpick__foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; margin-top: 8px; }
.menu__danger { color: var(--warn); }
/* messages near the work, with Undo */
.wb__toast { position: fixed; left: 50%; bottom: 20px; z-index: 40; display: flex; align-items: center; gap: 14px; width: max-content; max-width: min(520px, calc(100vw - 32px)); box-sizing: border-box; padding: 10px 12px 10px 16px; border-radius: 12px; background: var(--ink); color: var(--white); font-size: 14px; box-shadow: 0 2px 4px rgb(18 19 15 / 0.2), 0 12px 32px -8px rgb(18 19 15 / 0.4); transform: translateX(-50%); }
.wb__toast[hidden] { display: none; }
.wb__toast button { flex: none; min-height: 36px; padding: 0 12px; border: 0; border-radius: 8px; background: rgb(255 255 255 / 0.14); color: var(--white); font: 600 14px var(--sans); cursor: pointer; }
.wb__toast button:hover { background: rgb(255 255 255 / 0.24); }
/* on a phone the library sits right under the meal grid, not after the meal and day panels */
@media (max-width: 960px) {
  .wb__main { display: contents; }
  .wb__daytabs { order: 1; }
  .grid { order: 2; }
  .lib { order: 3; }
  .detail { order: 4; }
}
@media print { .wb__toast { display: none !important; } }

/* ---------- critique fixes: food search results ---------- */
.rows li:has(> .found__macros) { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 6px 16px; }
.found__macros { display: grid; grid-template-columns: repeat(4, 50px); gap: 4px; text-align: right; }
.found__macros > span { display: grid; line-height: 1.15; }
.found__macros b { font: 600 14px var(--sans); font-variant-numeric: tabular-nums; color: var(--ink); }
.found__macros small { font-size: 11px; color: var(--ink-3); }
/* narrow places (the meal library, the recipe form): values on their own line under the name */
.lib__foods .rows li:has(> .found__macros), .field .rows li:has(> .found__macros) { grid-template-columns: minmax(0, 1fr) auto; }
.lib__foods .found__macros, .field .found__macros { grid-column: 1; grid-row: 2; justify-content: start; text-align: left; grid-template-columns: repeat(4, auto); gap: 4px 12px; }
.lib__foods .found__macros > span, .field .found__macros > span { display: flex; gap: 3px; align-items: baseline; }
.lib__foods .rows li > .link, .field .rows li > .link { grid-column: 2; grid-row: 1 / span 2; }
.rows li.is-chosen { margin-inline: -10px; padding-inline: 10px; border-radius: 10px; background: var(--accent-wash); }
.tag-doubt { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--amber-wash); color: var(--amber); font-size: 11px; font-weight: 600; }
.found__recent h3 { margin-top: 16px; font-size: 14px; color: var(--ink-3); }
.foods__close { display: none; }
.foods__next { margin-top: 14px; font-size: 13px; color: var(--ink-2); }
@media (max-width: 760px) {
  .rows li:has(> .found__macros) { grid-template-columns: minmax(0, 1fr) auto; }
  .found__macros { grid-column: 1; grid-row: 2; justify-content: start; text-align: left; grid-template-columns: repeat(4, auto); gap: 4px 12px; }
  .found__macros > span { display: flex; gap: 3px; align-items: baseline; }
  .rows li > .link { grid-column: 2; grid-row: 1 / span 2; }
}
/* phone: a food's values open as a sheet over the list */
@media (max-width: 960px) {
  .foods__detail { display: none; }
  .foods__detail.is-open { position: fixed; inset: auto 0 0 0; z-index: 30; display: block; max-height: 82vh; overflow-y: auto; margin: 0; border-radius: 20px 20px 0 0; box-shadow: 0 -12px 40px -12px rgb(18 19 15 / 0.35); }
  .foods__detail.is-open .foods__close { display: inline-flex; min-height: 44px; align-items: center; margin-bottom: 4px; }
}
