:root{
  color-scheme:dark;
  --bg:#121314; --surface:#1a1b1d; --surface-2:#222427; --border:#2f3135;
  --text:#ecebe8; --muted:#a3a29b; --accent:#3987e5; --danger:#e66767;
  --c-protein:#F9A8D4; --c-fat:#C026D3; --c-carbs:#4FA3E8;  /* pink / fuchsia / light blue; closest pair is blue vs pink/fuchsia under protan and deutan simulation (~9 deltaE) */
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);color:var(--text);font:15px/1.5 system-ui,sans-serif}
a{color:#6da7ec;text-decoration:none} a:hover{text-decoration:underline}
header.top{padding:.8rem 1.25rem;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:1rem;flex-wrap:wrap}
header.top h1{margin:0;font-size:1.15rem;flex:1} header.top a{color:var(--text)}
main{padding:1rem 1.25rem}
.narrow{max-width:900px;margin:0 auto}
.muted{color:var(--muted);font-size:.85em}
input,select,button{font:inherit;color:var(--text);background:var(--surface-2);border:1px solid var(--border);border-radius:6px;padding:.5rem .6rem}
input:focus,select:focus,button:focus-visible{outline:2px solid var(--accent);outline-offset:1px}
button{cursor:pointer} button:hover{background:#2b2e32}
table{border-collapse:collapse;width:100%}
td,th{padding:.4rem .5rem;border-bottom:1px solid var(--border);text-align:left;vertical-align:middle}
th{font-weight:600;color:var(--muted);font-size:.85em}
.tag{background:var(--surface-2);border-radius:4px;padding:0 .4em;font-size:.8em}

/* day layout */
.day-layout{display:grid;grid-template-columns:minmax(0,28rem) minmax(0,1fr);gap:1.25rem;align-items:start}
@media(max-width:1240px){.day-layout{grid-template-columns:1fr}}   /* planner needs ~42rem for its fixed columns */
.panel{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:1rem;--ring:var(--surface)}
.panel h2{margin:0 0 .75rem;font-size:1rem}
#search{display:flex;flex-direction:column;gap:.5rem;margin-bottom:.75rem}
#search input,#search select{width:100%}
#search input[type=text]{font-size:1rem;padding-right:2.2rem}
.search-box{position:relative;display:block}
.clear-search{position:absolute;top:50%;right:.3rem;transform:translateY(-50%);width:1.7rem;height:1.7rem;padding:0;
  border:0;border-radius:5px;background:none;color:var(--muted);font-size:1.25rem;line-height:1}
.clear-search:hover{color:var(--text);background:var(--surface)}
.food-row{cursor:grab} .food-row:hover{background:var(--surface-2)} .food-row.dragging{opacity:.4}
.search-panel #results .food-row{scroll-margin-top:3.8rem}   /* scrolled to by ↑ ↓: below the sticky key bar and headings */
/* selected for dragging together: an accent bar down the left edge and a tinted row */
.food-row.picked{background:color-mix(in srgb,var(--accent) 16%,transparent)}
.food-row.picked > td:first-child{box-shadow:inset 3px 0 0 var(--accent)}
.food-row.picked:hover{background:color-mix(in srgb,var(--accent) 22%,transparent)}
.select-hint{margin:0 0 .4rem;font-size:.8em}
.ghost-more{padding:.2rem .6rem .4rem;font-size:.85em}
.grip{color:var(--muted);user-select:none}
td.nut{white-space:nowrap;font-size:.9em}

/* planner */
.planner{position:sticky;top:1rem;display:flex;flex-direction:column;gap:.9rem}
.plan-head{display:flex;align-items:center;gap:.75rem;flex-wrap:wrap}
.plan-head h2{margin:0;flex:1}
.plan-head{gap:.5rem}
.plan-head > .muted{font-size:.8em}
/* compact meal-count stepper: one joined pill, "− 3 +" */
.stepper{display:inline-flex;align-items:center;gap:0;border:1px solid var(--border);border-radius:6px;background:var(--surface-2);overflow:hidden}
.stepper button{width:1.5rem;height:1.5rem;padding:0;border:0;border-radius:0;background:transparent;line-height:1;font-size:1rem;color:var(--muted)}
.stepper button:hover{background:#2b2e32;color:var(--text)}
.stepper output{min-width:1.25rem;text-align:center;font-weight:600;font-size:.9em}
.totals{display:flex;gap:1rem;align-items:center}
.totals .big{font-size:1.8rem;font-weight:700;line-height:1}
.legend{display:grid;grid-template-columns:auto auto auto auto;justify-content:start;align-items:center;column-gap:.4em;row-gap:.15rem;font-size:.85em}
.legend span{display:flex;align-items:center}
.legend i{flex:none}
.legend i,.key i{display:inline-block;width:.7em;height:.7em;border-radius:2px;margin-right:.4em}
.meal{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:.7rem;--ring:var(--surface)}
/* selected: a 2px red outline (the 1px border plus a 1px outline outside it, so nothing inside moves) */
.meal.selected{border-color:var(--danger);outline:1px solid var(--danger)}
.meal.drop-over{border-color:var(--accent);background:#1b2230;--ring:#1b2230}
.items{list-style:none;margin:.5rem 0 0;padding:0}
.items li{display:grid;grid-template-columns:minmax(0,1fr) auto auto auto;gap:.5rem;align-items:center;padding:.35rem 0;border-top:1px solid var(--border)}
.items .nm{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.items input[type=number]{width:4.6rem;padding:.2rem .35rem}
.items .rm{padding:.1rem .45rem;color:var(--danger)}
.empty{color:var(--muted);font-size:.9em;border:1px dashed var(--border);border-radius:8px;padding:.8rem;text-align:center;margin-top:.5rem}
svg.pie path,svg.pie circle{stroke:var(--ring,var(--surface));stroke-width:1.5;stroke-linejoin:round}
.s-protein{fill:var(--c-protein)} .s-fat{fill:var(--c-fat)} .s-carbs{fill:var(--c-carbs)}
i.s-protein{background:var(--c-protein)} i.s-fat{background:var(--c-fat)} i.s-carbs{background:var(--c-carbs)}
.key{display:flex;flex-direction:column;font-weight:400;font-size:.8em;color:var(--muted)}
.key span{display:flex;align-items:center;white-space:nowrap}
.key i{flex:none;margin:0 .4em 0 0}

.toggle{font-size:30px;line-height:1;padding:.1rem .3rem;background:transparent;border-color:transparent;color:var(--muted);transition:transform .15s}
.toggle:hover{color:var(--text);background:var(--surface-2)}
.meal.collapsed .toggle{transform:rotate(-90deg)}

/* compact search results */
:is(#results,.drag-ghost,.meal-table) td,:is(#results,.drag-ghost,.meal-table) th{padding:.3rem .4rem}
:is(#results,.drag-ghost,.meal-table) svg.pie{display:block}

.delete-meal{width:26px;height:26px;padding:0;line-height:1;font-size:1.1rem;border-radius:6px;color:var(--muted)}
.delete-meal:hover{color:var(--danger)}
:is(#results,.drag-ghost,.meal-table) .grip-cell{width:1%;padding-right:0;white-space:nowrap;vertical-align:middle;text-align:center}
:is(#results,.drag-ghost,.meal-table) .food-cell{overflow-wrap:anywhere}
:is(#results,.drag-ghost,.meal-table) td.nut{white-space:nowrap;vertical-align:middle}
:is(#results,.drag-ghost,.meal-table) .pie-col{width:1%;white-space:nowrap}
:is(#results,.drag-ghost,.meal-table) th.pie-col{font-size:.85em}
:is(#results,.drag-ghost,.meal-table) .mline{display:flex;align-items:center;white-space:nowrap}
:is(#results,.drag-ghost,.meal-table) .mline i{display:inline-block;flex:none;width:.7em;height:.7em;border-radius:2px;margin-right:.4em}
:is(#results,.drag-ghost,.meal-table) .kcal{white-space:nowrap;font-size:.9em;margin-bottom:.15rem}
:is(#results,.drag-ghost,.meal-table) .key-bar{display:flex;gap:1rem;flex-wrap:wrap;margin-bottom:.4rem;font-size:.8em;color:var(--muted)}
:is(#results,.drag-ghost,.meal-table) .key-bar span{display:flex;align-items:center;white-space:nowrap}
:is(#results,.drag-ghost,.meal-table) .key-bar i{display:inline-block;flex:none;width:.7em;height:.7em;border-radius:2px;margin-right:.4em}
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}

.g-macro{display:inline-flex;align-items:center;white-space:nowrap;font-size:.9em}
.g-macro i{display:inline-block;width:.7em;height:.7em;border-radius:2px;margin-right:.3em}
.item-macros{display:flex;gap:.7rem;font-size:.85em;color:var(--muted)}
.items .nm{white-space:normal}
.drag-ghost{position:fixed;top:-9999px;left:-9999px;background:var(--surface);--ring:var(--surface);color:var(--text);
  font:15px/1.5 system-ui,sans-serif;border:1px solid var(--accent);border-radius:6px;overflow:hidden}
.drag-ghost table{border-collapse:collapse}
.drag-ghost td{border-bottom:0}

/* items inside a meal: same row look as search results */
.meal-table{margin-top:.5rem}
.meal-table td.nut{white-space:nowrap}
#planner .meal-table td.ctrl{white-space:nowrap;text-align:right;vertical-align:middle}
.meal-table .ctrl-row{display:flex;align-items:center;justify-content:flex-end;gap:.4rem}
.meal-table td.ctrl input{width:5.2rem;height:30px;margin:0;padding:0 .4rem;font-size:1em;border-radius:6px}
.meal-table td.ctrl .rm{width:30px;height:30px;padding:0;line-height:1;border-radius:6px;color:var(--danger)}
.meal-table .pie-col .kcal{margin-bottom:.15rem}

.macro-row{display:inline-flex;align-items:center;gap:.8rem;white-space:nowrap}

/* top-right Clear button matches the stepper's height */
.plan-head > button{height:26px;padding:0 .7rem;font-size:.9em;line-height:1;border-radius:6px}

.meal-table td.ctrl .unit-select{height:30px;width:10.6rem;padding:0 .3rem;font-size:.85em;border-radius:6px;text-overflow:ellipsis}

:is(.meal-table,.meal-head) .kcal-pie{display:flex;align-items:center;gap:.5rem;white-space:nowrap}
:is(.meal-table,.meal-head) .kcal-pie .kcal{margin:0}

/* meal items: fixed-width slots so every row's macros, kcal and pie line up (within and across meals) */
.meal-table{table-layout:fixed;width:100%;font-variant-numeric:tabular-nums}
:is(.meal-table,.meal-head) .kcal{min-width:5.4rem;text-align:right;white-space:nowrap;font-size:.9em}
:is(.meal-table,.meal-head) .kcal-pie svg.pie{flex:none}

/* meal item description: one truncated line that takes whatever width the fixed columns leave */
.meal-table .food-line{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.meal-table .food-line .brand{color:var(--muted);font-size:.85em}

/* meal headers: the same columns as their food rows below, so the meal's macro sums line up over its foods' macros.
   Columns: grip, toggle and name | macros | kcal and pie | item count and Clear (over the amount column) */
.meal-head{display:grid;grid-template-columns:minmax(0,1fr) 13.5rem 8.6rem 19.6rem;grid-template-areas:"title macros kcal end";
  align-items:center;font-variant-numeric:tabular-nums}
.meal-title{grid-area:title} .meal-head .macros{grid-area:macros} .meal-kcal-pie{grid-area:kcal;padding:0 .4rem} .meal-end{grid-area:end}
.meal-title{display:flex;align-items:center;gap:.6rem;min-width:0}
.meal-head .name{flex:1;min-width:0;margin:0;font-size:1rem;font-weight:600;padding:.2rem .3rem}
.meal-head .name a{color:inherit}
.meal-head .name a:hover{color:#6da7ec;text-decoration:underline}
.meal-head .macros{padding:0 .4rem;font-weight:600}
.meal-end{display:flex;align-items:center;justify-content:flex-end;gap:.6rem}
:is(.meal-table,.meal-head) .macro-row{gap:0}
:is(.meal-table,.meal-head) .g-macro{width:4.2rem;flex:none}
.macro-row.labeled .g-macro{flex-direction:column;align-items:flex-start}
.macro-label{font-size:.75em;font-weight:400;color:var(--muted);line-height:1.2}
/* the meal's totals and its foods: a line much thicker than the 1px ones between the foods */
#planner .meal-table{border-top:4px solid var(--border)}
.meal-tools{display:flex;justify-content:flex-end;flex-wrap:wrap;gap:.4rem;margin:-.3rem 0}
.meal-tools button{padding:.15rem .55rem;font-size:.85em;color:var(--muted)}
.meal-tools button:hover{color:var(--text)}
.meal.dragging{opacity:.5}
.meal.drop-before{box-shadow:0 -3px 0 var(--accent)} .meal.drop-after{box-shadow:0 3px 0 var(--accent)}

/* meal item rows are small grids: description takes the leftover width, everything else has a fixed slot.
   Columns: description | macros | kcal + pie | amount, unit, delete */
#planner .meal-table, #planner .meal-table tbody{display:block;width:100%}
#planner .meal-table tr.meal-item{display:grid;grid-template-columns:minmax(0,1fr) 13.5rem 8.6rem 19.6rem;align-items:center;
  border-bottom:1px solid var(--border)}
#planner .meal-table tr.meal-item > td{display:block;width:auto;min-width:0;border-bottom:0}
#planner .meal-table td.ctrl .ctrl-row{justify-content:flex-end}
/* narrower windows: the description gets its own line above the numbers so nothing is squeezed */
@media (max-width:1440px){
  /* the header's macros, kcal and pie go on a second line, over those that now start each food's second line */
  .meal-head{grid-template-columns:13.5rem 8.6rem minmax(0,1fr);grid-template-areas:"title title end" "macros kcal ."}
  .meal-head .macros,.meal-kcal-pie{margin-top:.2rem}
  #planner .meal-table tr.meal-item{grid-template-columns:13.5rem 8.6rem minmax(0,1fr);
    grid-template-areas:"food food food" "nut pie ctrl"}
  #planner .meal-table td.food-cell{grid-area:food;padding-bottom:0}
  #planner .meal-table td.nut{grid-area:nut}
  #planner .meal-table td.pie-col{grid-area:pie}
  #planner .meal-table td.ctrl{grid-area:ctrl}
}
/* small windows: amount / unit / delete drop onto their own row, then everything stacks in one column */
@media (max-width:780px){
  .meal-head{grid-template-columns:13.5rem minmax(0,1fr);grid-template-areas:"title end" "macros kcal"}
  #planner .meal-table tr.meal-item{grid-template-columns:13.5rem minmax(0,1fr);grid-template-areas:"food food" "nut pie" "ctrl ctrl"}
  #planner .meal-table td.ctrl .ctrl-row{justify-content:flex-start}
  #planner .meal-table td.ctrl{text-align:left}
}
@media (max-width:470px){
  .meal-head{grid-template-columns:minmax(0,1fr) auto;grid-template-areas:"title end" "macros macros" "kcal kcal"}
  #planner .meal-table tr.meal-item{grid-template-columns:minmax(0,1fr);grid-template-areas:"food" "nut" "pie" "ctrl"}
  #planner .meal-table td.ctrl .ctrl-row{flex-wrap:wrap}
  #planner .meal-table td.ctrl .unit-select{flex:1 1 8rem;min-width:0;width:auto}
}
/* let both columns shrink below their content's natural width instead of forcing sideways scroll */
.day-layout > *{min-width:0}

.legend-item{display:inline-flex;align-items:center;white-space:nowrap}
.legend-item i{display:inline-block;flex:none;width:.7em;height:.7em;border-radius:2px;margin-right:.4em}

/* day legend columns: swatch | name | grams (right-aligned) | "% of calories" - each part lines up row to row */
.legend .legend-item{display:contents}
.legend .lg-g{justify-self:end;text-align:right;white-space:nowrap}
.legend .lg-name,.legend .lg-pct{white-space:nowrap}
.legend .legend-item > i{margin-right:0}

/* search panel: title, text box and type dropdown stay in view; only the results list scrolls (own scrollbar) */
.search-panel{display:flex;flex-direction:column}
.search-panel > h2,.search-panel > #search{flex:none}
/* position:relative makes the scroll box the containing block for the visually-hidden .sr labels; without it they escape
   the scroller and stretch the whole page by thousands of pixels */
.search-panel #results{position:relative;flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;
  margin-right:-.5rem;padding-right:.5rem;scrollbar-width:thin;scrollbar-color:#454950 transparent}
.search-panel #results::-webkit-scrollbar{width:8px}
.search-panel #results::-webkit-scrollbar-thumb{background:#454950;border-radius:4px}
@media (min-width:1241px){
  /* side by side: the panel follows you down the page and is never taller than the window */
  /* 5.4rem = the page header (~4.4rem, which the panel sits below at the top of the page) plus a 1rem bottom margin */
  .search-panel{position:sticky;top:1rem;max-height:calc(100vh - 5.4rem)}
}
@media (max-width:1240px){
  /* stacked above the planner: pinned to the top of the window (under half its height) with its own scrollbar,
     while the planner scrolls underneath. Sticky needs one parent holding both, so a flex column replaces the grid. */
  .day-layout{display:flex;flex-direction:column;gap:1.25rem}
  .search-panel{position:sticky;top:.5rem;z-index:5;max-height:46vh}
}

/* search results: the color key and the Food / Macros / Calories header row stay pinned at the top of the list while it
   scrolls. The key has a fixed height so the header row knows how far down to stick. */
.search-panel #results .key-bar{position:sticky;top:0;z-index:3;box-sizing:border-box;height:1.7rem;margin:0;
  align-items:center;background:var(--surface)}
.search-panel #results th{position:sticky;top:1.7rem;z-index:2;background:var(--surface);
  box-shadow:inset 0 -1px 0 var(--border);border-bottom:0}

/* account */
.account{display:flex;align-items:center;gap:.6rem}
button.link{background:none;border:0;padding:0;color:#6da7ec} button.link:hover{background:none;text-decoration:underline}
.flash{max-width:24rem;margin:0 auto 1rem;padding:.6rem .8rem;border:1px solid var(--border);border-radius:8px;background:var(--surface)}
.auth{max-width:24rem;margin:2rem auto}
.auth form{display:flex;flex-direction:column;gap:.8rem}
.auth .field{display:flex;flex-direction:column;gap:.3rem}
.auth .field input{width:100%}
.auth .check{display:flex;align-items:center;gap:.5rem;font-size:.9em}
.auth .muted{margin:.2rem 0 0}
.error{color:var(--danger);font-size:.85em;margin:0}
button.primary{background:var(--accent);border-color:var(--accent);color:#fff;font-weight:600} button.primary:hover{background:#2f78d0}

/* planner date */
.plan-head h2.plan-date{flex:1 1 100%}
.date-nav{display:inline-flex;align-items:center;gap:.3rem}
.date-nav button{padding:.25rem .55rem}
.date-nav input[type=date]{padding:.25rem .4rem}
.save-status{margin-left:auto;font-size:.8em}
.save-status.error{color:var(--danger)}

/* Day | Week switch */
.view-switch{display:inline-flex;border:1px solid var(--border);border-radius:6px;overflow:hidden}
.view-switch button{padding:.25rem .7rem;border:0;border-radius:0;background:var(--surface-2);color:var(--muted)}
.view-switch button + button{border-left:1px solid var(--border)}
.view-switch button:hover{color:var(--text)}
.view-switch button[aria-pressed=true]{background:var(--accent);color:#fff}

/* week view: seven days side by side; the search panel steps aside to give it the full width */
.day-layout.week-mode{grid-template-columns:minmax(0,1fr)}
.day-layout.week-mode .search-panel{display:none}
.week-hint{margin:1rem 0 0;font-size:.95em;color:#cfcec9}
.week-hint .grip{color:var(--text);font-weight:700}
.week-scroll{overflow-x:auto;margin-top:.5rem}
.week-grid{display:grid;grid-template-columns:repeat(7,minmax(10.5rem,1fr));gap:.6rem;align-items:start}
.week-day{background:var(--surface-2);border:1px solid var(--border);border-radius:10px;padding:.6rem;--ring:var(--surface-2);
  min-width:0;font-size:.9em}
.week-day.today{border-color:var(--accent)}
.week-day.selected{border-color:var(--danger);outline:1px solid var(--danger)}   /* as a selected meal */
.week-day-top{display:flex;align-items:center;gap:.2rem;margin-bottom:.4rem}
.day-grip{cursor:grab;padding:.15rem .3rem;border-radius:4px;font-size:1.1em;line-height:1}
.day-grip:hover{color:var(--text);background:var(--surface)}
.week-day.dragging{opacity:.5}
.week-day.drop-over{border-color:var(--accent);background:#1b2230;--ring:#1b2230}
.week-day-head{display:flex;align-items:baseline;gap:.4rem;flex:1;min-width:0;padding:.2rem .3rem;
  background:transparent;border-color:transparent;text-align:left;cursor:pointer}
.week-day-head:hover{background:var(--surface);border-color:var(--border)}
.week-day-head .wd{font-weight:700} .week-day-head .md{color:var(--muted)}
.today-tag{margin-left:auto;font-size:.75em;color:var(--accent)}
.week-day-total{display:flex;align-items:center;gap:.5rem;padding-bottom:.5rem;border-bottom:1px solid var(--border)}
.week-day-total .macro-row{gap:.5rem;font-size:.9em}
.week-meal{margin-top:.55rem}
.week-meal-head{display:flex;gap:.4rem;align-items:center;font-weight:600}
.meal-grip{cursor:grab;padding:.1rem .15rem;margin-right:-.2rem;border-radius:4px;line-height:1;font-weight:400}
.meal-grip:hover{color:var(--text);background:var(--surface)}
.week-meal.dragging{opacity:.5}
.week-meal.drop-before{box-shadow:0 -3px 0 var(--accent)} .week-meal.drop-after{box-shadow:0 3px 0 var(--accent)}
.week-meal-rm{flex:none;width:18px;height:20px;padding:0;margin-left:-.15rem;line-height:1;border:0;border-radius:4px;background:none;color:var(--danger);font-weight:400}
.week-meal-head svg.pie{flex:none}
.week-meal-name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.week-meal-head .muted{white-space:nowrap;font-weight:400}
.week-meal ul{list-style:none;margin:.2rem 0 0;padding:0}
.week-meal li{display:flex;flex-direction:column;padding:.2rem 0;border-top:1px solid var(--border);line-height:1.3}
.week-food{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.week-day .empty{margin-top:.5rem;padding:.6rem}

/* day nutrition page */
.nutrition-page h3{margin:1.5rem 0 .5rem}
.nutrition-page .facts{max-width:34rem}
.nutrition-page .facts h3{margin-top:0}
.nutrition-page .num{text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}
.facts-table tr.indent-0 td:first-child{font-weight:600}
:is(.facts-table,.nutrient-table) tr.indent-1 td:first-child{padding-left:1.5rem}
:is(.facts-table,.nutrient-table) tr.indent-2 td:first-child{padding-left:3rem}
.nutrient-table tr.indent-3 td:first-child{padding-left:4.5rem}
.partial{display:block;font-size:.75em;color:var(--muted);font-weight:400}
.table-scroll{overflow-x:auto}
.nutrient-table th{position:sticky;top:0;background:var(--bg)}
.nutrient-table td:first-child{min-width:14rem}
.nutrient-table tbody tr:hover,.nutrient-table tr:hover{background:var(--surface)}
.day-links{margin-top:.6rem;font-size:.9em}
.nutrient-table th a{display:inline-block;max-width:9rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:bottom}
.serving-picker{display:flex;flex-wrap:wrap;gap:.5rem 1rem;align-items:center}
.serving-picker input{width:5em}
#results .meal-foods{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}

/* a food page for a food USDA has changed or dropped since */
.notice{border:1px solid var(--accent);border-radius:6px;padding:.5rem .75rem;background:var(--surface)}

/* the list of keyboard shortcuts shown where the search has no results */
.shortcuts{margin-top:1rem;font-size:.85em;color:var(--muted)}
.shortcuts h3{margin:0 0 .3rem;font-size:.95rem;color:var(--text)}
.shortcuts h4{margin:.7rem 0 .25rem;font-size:.8em;font-weight:600;text-transform:uppercase;letter-spacing:.04em}
.shortcuts dl{display:grid;grid-template-columns:6.5rem 1fr;gap:.3rem .8rem;margin:0}
.shortcuts dt{white-space:nowrap} .shortcuts dd{margin:0}
.shortcuts kbd{display:inline-block;min-width:1.4em;padding:.05rem .35rem;text-align:center;font:inherit;font-size:.9em;color:var(--text);
  background:var(--surface-2);border:1px solid var(--border);border-bottom-width:2px;border-radius:4px}
#planner .meal-table tr.meal-item.item-selected{background:color-mix(in srgb,var(--accent) 12%,transparent)}   /* ↑ ↓ */
#planner .meal-table tr.meal-item.item-selected > td:first-child{box-shadow:inset 3px 0 0 var(--accent)}

/* Add a food: the button beside the search panel's title, and its form in a dialog (customFood.js) */
.search-panel > h2{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}
.add-food{margin-left:auto;padding:.2rem .6rem;font-size:.85em;font-weight:400}
dialog.modal{width:min(34rem,calc(100vw - 2rem));max-height:calc(100vh - 2rem);padding:0;overflow:auto;color:var(--text);
  background:var(--surface);border:1px solid var(--border);border-radius:12px}
dialog.modal::backdrop{background:rgb(0 0 0 / .6)}
dialog.modal form{padding:1.1rem 1.25rem}
dialog.modal h2{margin:0 0 .25rem;font-size:1.1rem}
.cf-grid{display:grid;grid-template-columns:1fr 1fr;gap:.6rem .75rem;margin:.75rem 0}
.cf-grid label{display:flex;flex-direction:column;gap:.2rem;font-size:.85em;color:var(--muted)}
.cf-grid .cf-wide{grid-column:1 / -1}
.cf-grid input{width:100%}
.cf-size{display:flex;align-items:center;gap:.5rem}
.cf-grid .cf-size input{width:7rem} .cf-grid .cf-size select{width:6rem}
dialog.modal details{margin:.25rem 0 .5rem} dialog.modal summary{cursor:pointer;color:var(--muted);font-size:.9em}
.cf-check{min-height:2.6em;margin:.5rem 0;font-size:.85em;color:var(--muted)}
.cf-check.ok{color:#7fc68a} .cf-check.bad{color:var(--danger)}
.cf-actions{display:flex;justify-content:flex-end;gap:.5rem;margin-top:.5rem}
button:disabled{opacity:.5;cursor:not-allowed}

/* body page (body.js): one measurement over time */
.body-page{max-width:900px;margin:0 auto}
.body-filters{display:flex;flex-wrap:wrap;gap:.75rem 1.25rem;align-items:center;margin-bottom:1rem}
.body-ranges{display:flex;gap:.25rem}
.body-ranges button{padding:.3rem .7rem} .body-ranges button[aria-pressed=true]{background:var(--accent);border-color:var(--accent);color:#fff}
.body-headline{display:flex;align-items:baseline;gap:.4rem;margin-bottom:.5rem}
.body-value{font-size:2rem;font-weight:600} .body-delta{margin-left:.6rem}
.body-chart{position:relative}
.body-chart svg{display:block;width:100%;height:auto;touch-action:pan-y;outline-offset:2px}
.body-chart .grid{stroke:var(--border);stroke-width:1}
.body-chart .tick{fill:var(--muted);font-size:11px}
.body-chart .line{fill:none;stroke:var(--accent);stroke-width:2;stroke-linejoin:round;stroke-linecap:round}
.body-chart .raw{fill:var(--muted);opacity:.7}
.body-chart .dot{fill:var(--accent);stroke:var(--surface);stroke-width:2}
.body-chart .cross{stroke:var(--muted);stroke-width:1}
.body-tip{position:absolute;top:0;pointer-events:none;background:var(--surface-2);border:1px solid var(--border);border-radius:6px;padding:.3rem .55rem;white-space:nowrap;font-size:.85em}
.body-tip strong{display:block;font-size:1.05em}
.body-tip .key{display:inline-block;width:12px;height:2px;background:var(--accent);vertical-align:middle;margin-right:.35rem}
.body-table{margin-top:1rem} .body-table summary{cursor:pointer;color:var(--muted)}
.body-table-scroll{max-height:18rem;overflow:auto;margin-top:.5rem} th.num,td.num{text-align:right}
.body-legend{display:flex;align-items:center;gap:.4rem;margin:.2rem 0 .4rem}
.body-legend .lk-raw{width:8px;height:8px;border-radius:50%;background:var(--muted);opacity:.7}
.body-legend .lk-line{width:16px;height:2px;background:var(--accent);margin-left:.8rem}
