/* World: meal-prep boxes on a kitchen counter. The day is one tall translucent container, filled meal by meal
   with layers of carbs (grain), protein (salmon) and fat (avocado); its lid sits at the daily goal.
   Lids are the one brand color.
   Scene: logged at a glance in bright kitchens, supermarkets and gyms -> light first; dark for evenings. */
:root {
  --ground: #e6eaec;
  --ground-2: #dde2e5;
  --panel: #f7f9fa;
  --ink: #152024;
  --ink-2: #4a5a60;
  --hair: #c9d1d5;
  --lid: #0e5c57;
  --lid-2: #0a4541;
  --lid-ink: #ffffff;
  --lid-soft: #d3e6e3;
  --carbs: #d98f1f;
  --protein: #cc3f5a;
  --fat: #5d8a2c;
  --warn: #9a4a00;
  --warn-soft: #fbe7cf;
  --danger: #b3261e;
  --danger-ink: #ffffff;
  --glass: rgba(236, 246, 250, 0.2);
  --glass-edge: rgba(120, 150, 165, 0.55);
  --shadow: 0 1px 1px rgba(20, 36, 40, 0.06), 0 8px 24px -8px rgba(20, 36, 40, 0.18);
  --w-trend: #2a78d6; /* chart slots, validated with dataviz validate_palette (light) */
  --w-dot: #eb6834;
  --radius: 18px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0f1417;
    --ground-2: #141b1f;
    --panel: #182125;
    --ink: #eaf1f2;
    --ink-2: #a3b3b8;
    --hair: #2a363b;
    --lid: #3cb3a4;
    --lid-2: #2a8f83;
    --lid-ink: #06201d;
    --lid-soft: #173430;
    --carbs: #f0aa45;
    --protein: #f06d86;
    --fat: #93c35c;
    --warn: #f3ad5c;
    --warn-soft: #33250f;
    --danger: #ff8a80;
    --danger-ink: #2a0906;
    --glass: rgba(150, 190, 205, 0.12);
    --glass-edge: rgba(160, 200, 215, 0.35);
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
    --w-trend: #3987e5; /* validated for the dark surface */
    --w-dot: #d95926;
    color-scheme: dark;
  }
}
@font-face {
  font-family: "Archivo";
  src: url("/static/fonts/archivo-var-latin.woff") format("woff");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.4 "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  padding: env(safe-area-inset-top) 0 calc(84px + env(safe-area-inset-bottom));
}
::selection { background: var(--lid); color: var(--lid-ink); }
input { caret-color: var(--lid); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.boot { text-align: center; color: var(--ink-2); margin-top: 40vh; }
main { max-width: 560px; margin: 0 auto; padding: 8px 16px 96px; }
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; }
h2 { font-size: 1.05rem; font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 12px 18px; min-height: 48px;
  background: var(--lid); color: var(--lid-ink); font-weight: 700; text-decoration: none;
  box-shadow: inset 0 -3px 0 var(--lid-2);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.btn:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 var(--lid-2); }
.btn.secondary { background: var(--lid-soft); color: var(--ink); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--lid); box-shadow: none; padding: 8px 10px; min-height: 44px; font-weight: 600; }
.btn.danger { background: transparent; color: var(--danger); box-shadow: none; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; }
.icon-btn {
  display: inline-grid; place-items: center; border: 0; background: transparent;
  min-width: 44px; min-height: 44px; border-radius: 14px; color: var(--ink);
}
.icon-btn:active { background: var(--ground-2); }
:focus-visible { outline: 3px solid var(--lid); outline-offset: 2px; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin: 12px 0 5px; }
input, select {
  width: 100%; border: 1.5px solid var(--hair); background: var(--panel);
  border-radius: 12px; padding: 11px 12px; min-height: 48px; font-size: 16px;
}
input::placeholder { color: var(--ink-2); opacity: 1; }
input:focus { border-color: var(--lid); outline: none; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid2 > * { min-width: 0; }
.error { color: var(--danger); font-size: .9rem; margin: 8px 0 0; }
.note { background: var(--warn-soft); color: var(--ink); border-radius: 12px; padding: 9px 12px; font-size: .85rem; margin: 10px 0 0; }

/* ---------- day header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 6px; }
.topbar h1 { font-size: 1.2rem; font-weight: 800; text-align: center; flex: 1; letter-spacing: -.01em; }

/* ---------- hero: readout + 3D stack ---------- */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 176px; align-items: center; gap: 4px; margin: 0 0 8px; min-height: 250px; }
.readout .kcal { font-size: clamp(3rem, 17vw, 4.8rem); font-weight: 850; font-stretch: 78%; letter-spacing: -.03em; line-height: .92; display: flex; }
.readout .kcal span { display: inline-block; }
.readout .unit { font-weight: 700; color: var(--ink-2); margin-top: 4px; }
.readout .goal { font-size: .9rem; color: var(--ink-2); margin-top: 2px; }
.readout .over { color: var(--warn); font-weight: 700; }
/* legend spans the hero: three columns, one per layer, top to bottom like the box */
.legend { grid-column: 1 / -1; list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr); column-gap: 7px; align-items: center; font-size: .85rem; color: var(--ink-2); }
.legend .sw { width: 12px; height: 12px; border-radius: 4px; }
.legend .v { grid-column: 1 / -1; font-weight: 800; font-size: 1rem; color: var(--ink); white-space: nowrap; }
.sw.carbs { background: var(--carbs); }
.sw.protein { background: var(--protein); }
.sw.fat { background: var(--fat); }

.stage { height: 250px; perspective: 780px; perspective-origin: 50% 30%; touch-action: pan-y; cursor: grab; user-select: none; }
.stage:active { cursor: grabbing; }
/* ---------- the day box ---------- */
.tstack {
  position: relative; width: var(--w); height: 250px; margin: 0 auto;
  transform-style: preserve-3d;
  transform: rotateX(calc(-20deg + var(--tx, 0deg))) rotateY(calc(-30deg + var(--ty, 0deg)));
  transition: transform .9s var(--ease);
}
.tstack.dragging { transition: none; }
.tbox { position: absolute; left: 0; bottom: 38px; width: var(--w); height: var(--h); transform-style: preserve-3d; }
.tbox .g { position: absolute; left: 0; top: 0; backface-visibility: visible; background: var(--glass); border: 1.5px solid var(--glass-edge); border-radius: 12px; }
.tbox .g.front, .tbox .g.back { width: var(--w); height: var(--h); }
.tbox .g.left, .tbox .g.right { width: var(--d); height: var(--h); left: calc((var(--w) - var(--d)) / 2); }
.tbox .g.bottom { width: var(--w); height: var(--d); top: calc((var(--h) - var(--d)) / 2); border-radius: 14px; background: color-mix(in srgb, var(--glass-edge) 22%, transparent); }
.tbox .g.front { transform: translateZ(calc(var(--d) / 2)); }
.tbox .g.back { transform: rotateY(180deg) translateZ(calc(var(--d) / 2)); }
.tbox .g.right { transform: rotateY(90deg) translateZ(calc(var(--w) / 2)); }
.tbox .g.left { transform: rotateY(-90deg) translateZ(calc(var(--w) / 2)); }
.tbox .g.bottom { transform: rotateX(-90deg) translateZ(calc(var(--h) / 2)); }
/* glass: a sheen on the front and a measuring scale like on a jug; the rim is the goal */
.tbox .g.front {
  background-image:
    linear-gradient(104deg, rgba(255, 255, 255, .55) 0 9%, rgba(255, 255, 255, 0) 22%, rgba(255, 255, 255, 0) 74%, rgba(255, 255, 255, .22) 86%, rgba(255, 255, 255, 0) 94%);
}
.tbox .tick { position: absolute; right: 7px; width: 11px; height: 2px; border-radius: 1px; background: var(--glass-edge); bottom: calc(4px + var(--p) * (var(--h) - 8px)); }
.tbox .tick:nth-child(2) { width: 17px; }
.rim-label { position: absolute; right: 8px; top: 17px; font-size: 9.5px; font-weight: 800; font-stretch: 85%; color: var(--ink-2); letter-spacing: .02em; }
.tbox.over .g { border-color: color-mix(in srgb, var(--warn) 70%, var(--glass-edge)); }
.tbox.over .rim-label { color: var(--warn); }
/* the food: one cuboid per meal, stacked; a light seam separates the meals */
.segs { position: absolute; inset: 0; transform-style: preserve-3d; }
.seg {
  position: absolute; left: 5px; width: calc(var(--w) - 10px); bottom: calc(4px + var(--b, 0px)); height: var(--sh, 0px);
  transform-style: preserve-3d; transition: bottom .85s var(--ease), height .85s var(--ease);
}
.seg.none { display: none; }
.seg .s { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: var(--layers); backface-visibility: visible; }
.seg .s.front, .seg .s.back, .seg .s.left, .seg .s.right { box-shadow: inset 0 2px 0 rgba(255, 255, 255, .6); }
.seg .front { transform: translateZ(calc(var(--d) / 2 - 5px)); border-radius: 0 0 8px 8px; }
.seg .back { transform: rotateY(180deg) translateZ(calc(var(--d) / 2 - 5px)); }
.seg .left, .seg .right { width: calc(var(--d) - 10px); left: calc((var(--w) - var(--d)) / 2); }
.seg .right { transform: rotateY(90deg) translateZ(calc((var(--w) - 10px) / 2)); }
.seg .left { transform: rotateY(-90deg) translateZ(calc((var(--w) - 10px) / 2)); }
.seg .top { height: calc(var(--d) - 10px); top: calc(-1 * (var(--d) - 10px) / 2); background: var(--top); filter: brightness(1.12) saturate(.9); transform: rotateX(90deg); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35); }
/* past the goal: what stands above the rim is striped orange */
.spill { position: absolute; left: 3px; width: calc(var(--w) - 6px); bottom: calc(var(--h) - 4px); height: var(--over); transform-style: preserve-3d; pointer-events: none; }
.spill .s { position: absolute; left: 0; top: 0; width: 100%; height: 100%; backface-visibility: visible;
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--warn) 62%, transparent) 0 5px, color-mix(in srgb, var(--warn) 18%, transparent) 5px 10px);
  border: 1.5px solid var(--warn); border-bottom: 0; border-radius: 6px 6px 0 0; }
.spill .front { transform: translateZ(calc(var(--d) / 2 - 2px)); }
.spill .back { transform: rotateY(180deg) translateZ(calc(var(--d) / 2 - 2px)); }
.spill .left, .spill .right { width: calc(var(--d) - 4px); left: calc((var(--w) - var(--d)) / 2 - 1px); }
.spill .right { transform: rotateY(90deg) translateZ(calc((var(--w) - 6px) / 2)); }
.spill .left { transform: rotateY(-90deg) translateZ(calc((var(--w) - 6px) / 2)); }
/* the lid, with the two clips of a meal-prep box and a grip */
.tlid {
  position: absolute; left: -4px; top: calc((var(--h) - var(--d)) / 2 - 4px);
  width: calc(var(--w) + 8px); height: calc(var(--d) + 8px); border-radius: 14px;
  background: var(--lid); box-shadow: inset 0 0 0 3px var(--lid-2), inset 0 -10px 18px -10px rgba(0, 0, 0, .25);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, .26) 0 20%, transparent 42%);
  transform-style: preserve-3d;
}
.tlid .handle { position: absolute; left: 30%; right: 30%; top: 42%; height: 16%; border-radius: 8px; background: var(--lid-2); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .25); }
.tlid .clip { position: absolute; top: 100%; width: 20px; height: 10px; margin-top: -1px; border-radius: 0 0 5px 5px; background: var(--lid-2); transform-origin: 50% 0; transform: rotateX(-90deg); }
.tlid .clip.a { left: 18%; }
.tlid .clip.b { right: 18%; }
.stage.flat .tstack { transform: none; }
.stage.flat .tlid { display: none; }
.sticker {
  position: absolute; left: 7px; top: 50%; transform: translateY(-50%);
  background: rgba(255, 255, 255, .93); color: #152024; border-radius: 5px; padding: 2px 6px;
  font-size: 10.5px; line-height: 1.15; font-weight: 700; font-stretch: 85%; white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.sticker b { font-weight: 850; }
.floor {
  position: absolute; left: -34px; width: calc(var(--w) + 68px); height: calc(var(--d) + 56px); bottom: -42px;
  background: radial-gradient(closest-side, rgba(15, 40, 45, .34), rgba(15, 40, 45, 0));
  transform: rotateX(90deg); pointer-events: none;
}
.dropper {
  position: absolute; left: 12px; width: calc(var(--w) - 24px); height: 10px; top: 0;
  border-radius: 3px; background: var(--layers); pointer-events: none; box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

/* ---------- meals ---------- */
.meal { margin-bottom: 12px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
/* lid clip: the tab you pull to open a meal-prep box */
.meal::before { content: ""; display: block; height: 6px; margin: 0 22%; background: var(--lid); border-radius: 0 0 8px 8px; }
.meal-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 4px 16px; }
.meal-head h2 { flex: 1; font-size: 1.08rem; font-weight: 800; font-stretch: 90%; }
.meal-head .sum { font-weight: 800; font-size: .95rem; color: var(--ink-2); }
.meal-head .add { width: 40px; height: 40px; min-width: 40px; min-height: 40px; border-radius: 50%; background: var(--lid); color: var(--lid-ink); box-shadow: inset 0 -3px 0 var(--lid-2); }
.meal-head .add:active { transform: translateY(1px); }
.meal-body { padding: 2px 16px 8px; }
.entry {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; background: transparent; text-align: left;
  padding: 11px 0; border-top: 1px solid var(--hair); min-height: 56px;
}
.entry:first-child { border-top: 0; }
.entry .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.entry .kcal { font-weight: 800; white-space: nowrap; }
.entry .bar3 { display: flex; width: 34px; height: 8px; border-radius: 3px; overflow: hidden; flex: none; background: var(--hair); }
.entry .bar3 i { display: block; height: 100%; }
.entry .bar3 .c { background: var(--carbs); }
.entry .bar3 .p { background: var(--protein); }
.entry .bar3 .t { background: var(--fat); }
.empty-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; }
.empty-row .muted { font-size: .9rem; }

/* ---------- bottom bar ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, minmax(0, 112px)); justify-content: center; align-items: end;
  background: var(--panel); border-top: 1px solid var(--hair);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  border: 0; background: transparent; padding: 9px 2px 8px; min-height: 60px; min-width: 0;
  font-size: .76rem; font-weight: 600; font-stretch: 92%; color: var(--ink-2); white-space: nowrap;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
nav.tabs button[aria-current="page"] { color: var(--lid); }
nav.tabs .plus { position: relative; }
nav.tabs .plus .disc {
  display: grid; place-items: center; width: 60px; height: 60px; margin-top: -26px; border-radius: 20px;
  background: var(--lid); color: var(--lid-ink);
  box-shadow: inset 0 -4px 0 var(--lid-2), 0 10px 24px -8px rgba(10, 40, 38, .6);
}
nav.tabs .plus .disc svg.i { width: 28px; height: 28px; stroke-width: 2.4; }
nav.tabs .plus:active .disc { transform: translateY(2px); }

/* ---------- sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(8, 20, 22, .42); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--ground); width: 100%; max-width: 560px; max-height: 100%;
  border-radius: 22px 22px 0 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 8px 16px calc(22px + env(safe-area-inset-bottom));
}
.sheet.full { height: 100%; border-radius: 0; padding-top: calc(8px + env(safe-area-inset-top)); }
.sheet-head { display: flex; align-items: center; gap: 6px; position: sticky; top: 0; background: var(--ground); padding: 6px 0 10px; z-index: 1; }
.sheet-head h2 { flex: 1; font-size: 1.15rem; font-weight: 800; }
.searchbar { display: flex; gap: 8px; }
.searchbar input { flex: 1; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.quick-actions .btn { flex: 1 1 auto; padding: 10px 12px; font-size: .92rem; }
.quick-actions .btn svg.i { width: 20px; height: 20px; }
.result {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 0; border-bottom: 1px solid var(--hair); background: transparent; text-align: left;
  padding: 10px 2px; min-height: 64px;
}
/* brand marks: the logo on a white tile (logos are made for white), or a letter badge */
.mark {
  width: 46px; height: 46px; border-radius: 12px; flex: none; display: grid; place-items: center; overflow: hidden;
  background: #fff; box-shadow: inset 0 0 0 1px rgba(20, 36, 40, .12);
}
.mark img { width: 84%; height: 84%; object-fit: contain; display: block; }
.mark.mono {
  background: hsl(var(--hue, 180) 46% 90%); color: hsl(var(--hue, 180) 50% 24%);
  font-weight: 850; font-size: 1rem; font-stretch: 88%; letter-spacing: -.01em; box-shadow: none;
}
.mark.dish, .mark.tpl, .mark.quick { background: var(--lid-soft); color: var(--lid); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--lid) 45%, transparent); }
.mark.dish svg.i, .mark.tpl svg.i, .mark.quick svg.i { width: 24px; height: 24px; }
.mark.none { background: var(--ground-2); color: var(--ink-2); font-weight: 800; box-shadow: none; }
.entry .mark { width: 38px; height: 38px; border-radius: 10px; font-size: .85rem; }
.entry .mark svg.i { width: 20px; height: 20px; }
/* brand choice: a grid of cards with logo, name and how many products */
.brand-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 6px 0 10px; }
.brand-card {
  display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left;
  border: 0; border-radius: 16px; padding: 10px; background: var(--panel); box-shadow: var(--shadow); min-height: 64px;
}
.brand-card:active { transform: translateY(1px); }
.brand-card .mark { width: 40px; height: 40px; border-radius: 10px; }
.brand-card .grow { display: grid; min-width: 0; }
.brand-card .name { font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-card .meta { font-size: .78rem; color: var(--ink-2); }
.brand-bar { display: flex; align-items: center; gap: 10px; margin: 14px 0 4px; }
.brand-bar .mark { width: 34px; height: 34px; border-radius: 9px; font-size: .8rem; }
.brand-bar b { font-size: 1.05rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-bar .chip { min-height: 36px; padding: 5px 10px; font-size: .85rem; }
.add-own { margin-top: 14px; }
.result .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.result .meta { font-size: .85rem; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; border-radius: 6px; padding: 1px 6px; background: var(--lid-soft); color: var(--ink); vertical-align: middle; }
.badge.warn { background: var(--warn-soft); }
.section-title { font-size: .95rem; font-weight: 800; margin: 18px 0 4px; }
.amount-input { display: flex; align-items: center; gap: 8px; }
.amount-input input { font-size: 2rem; font-weight: 900; text-align: center; letter-spacing: -.02em; min-height: 64px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.chip { border: 1.5px solid var(--hair); background: var(--panel); border-radius: 12px; padding: 7px 12px; min-height: 40px; font-weight: 600; }
.chip[aria-pressed="true"] { background: var(--lid); color: var(--lid-ink); border-color: var(--lid); }
.segmented { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; background: var(--ground-2); padding: 4px; border-radius: 14px; }
.segmented button { border: 0; background: transparent; border-radius: 10px; padding: 8px 2px; min-height: 42px; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
/* amount preview: the portion as one layered slab of the box */
.slab { display: flex; height: 16px; border-radius: 5px; overflow: hidden; margin: 14px 0 6px; background: var(--hair); }
.slab i { display: block; height: 100%; transition: flex-grow .4s var(--ease); }
.slab .c { background: var(--carbs); }
.slab .p { background: var(--protein); }
.slab .t { background: var(--fat); }
.preview { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 6px; margin: 4px 0 14px; }
.preview > div { min-width: 0; }
.preview .value { font-weight: 900; font-size: 1.2rem; }
.facts { width: 100%; border-collapse: collapse; font-size: .9rem; }
.facts td { padding: 6px 0; border-bottom: 1px solid var(--hair); }
.facts td:last-child { text-align: right; font-weight: 600; }
details summary { cursor: pointer; padding: 8px 0; }
.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; max-height: 60vh; width: 100%; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; left: 10%; right: 10%; top: 36%; height: 28%; border: 3px solid rgba(255, 255, 255, .92); border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }

/* ---------- week: seven boxes on a shelf ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 170px; margin-top: 14px; }
.week .col { border: 0; background: transparent; padding: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.week .jar { width: 100%; max-width: 38px; height: 120px; border: 1.5px solid var(--glass-edge); background: var(--glass); border-radius: 6px 6px 8px 8px; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; position: relative; }
.week .jar::before { content: ""; position: absolute; left: -2px; right: -2px; top: 0; height: 7px; background: var(--lid); border-radius: 4px; }
.week .jar i { display: block; width: 100%; }
.week .jar .c { background: var(--carbs); }
.week .jar .p { background: var(--protein); }
.week .jar .t { background: var(--fat); }
.week .jar.over { border-color: var(--warn); }
.week .lbl { font-size: .75rem; font-weight: 600; color: var(--ink-2); }
.week .val { font-size: .7rem; color: var(--ink-2); min-height: 1em; }
.big { font-size: 2.4rem; font-weight: 900; letter-spacing: -.03em; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 40;
  max-width: 528px; margin: 0 auto;
  background: var(--ink); color: var(--ground); border-radius: 14px; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px; box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .4);
}
#toast[hidden] { display: none; }
#toast .grow { font-size: .95rem; }
#toast button { border: 0; background: transparent; color: var(--lid-soft); font-weight: 800; min-height: 40px; }
#toast.error { background: var(--danger); color: var(--danger-ink); }

.auth { max-width: 380px; margin: 8vh auto 0; }
.auth .brand { display: grid; place-items: center; margin-bottom: 18px; }
.auth h1 { font-size: 2rem; font-weight: 900; letter-spacing: -.03em; }
.link { border: 0; background: none; color: var(--lid); padding: 10px 0; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.codebox { font: 800 1.35rem/1.2 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .08em; padding: 12px; background: var(--lid-soft); border-radius: 12px; text-align: center; user-select: all; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 9px 0; border-bottom: 1px solid var(--hair); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; font-weight: 600; color: var(--ink); margin: 0; }
.switch input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative;
  width: 52px; min-height: 30px; height: 30px; padding: 0; border-radius: 15px; border: 0;
  background: var(--hair); transition: background .2s var(--ease); cursor: pointer;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s var(--ease);
}
.switch input:checked { background: var(--lid); }
.switch input:checked::after { transform: translateX(22px); }

@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: rise .32s var(--ease); }
  @keyframes rise { from { transform: translateY(28px); opacity: .5; } to { transform: none; opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) {
  .tstack, .seg, .slab i { transition: none !important; }
}

/* ---------- v1.1 additions ---------- */
.link-btn { border: 0; background: none; padding: 0; color: var(--lid); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.legend li > span:nth-child(2) { min-width: 0; overflow-wrap: anywhere; hyphens: auto; }
.week { position: relative; }
.week .goal-line { position: absolute; left: 0; right: 0; border-top: 2px dashed color-mix(in srgb, var(--ink-2) 55%, transparent); pointer-events: none; }
.week .goal-line span { position: absolute; right: 0; top: -18px; font-size: .7rem; font-weight: 700; color: var(--ink-2); background: var(--panel); padding: 0 4px; }
@media (max-width: 360px) {
  .hero { grid-template-columns: minmax(0, 1fr) 132px; }
  .stage { transform: scale(.78); transform-origin: 60% 50%; }
  .readout .kcal { font-size: 2.7rem; }
  .legend { gap: 6px; }
  .legend li { font-size: .78rem; }
  .legend .v { font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  .dropper { display: none; }
}

.result-row { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--hair); }
.result-row .result { border-bottom: 0; flex: 1; min-width: 0; }
.quick-add {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  border: 1.5px solid var(--lid); background: var(--lid-soft); color: var(--ink);
  border-radius: 14px; padding: 6px 10px 6px 6px; min-height: 44px; font-weight: 800; font-size: .85rem;
}
.quick-add svg.i { width: 20px; height: 20px; color: var(--lid); }
.quick-add:active { transform: translateY(1px); }
.readout .unit.over { color: var(--warn); }

/* ---------- weight ---------- */
.wstats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0 4px; align-items: end; }
.wstats .big { font-size: 2.2rem; }
.wtrendval { font-size: 1.15rem; font-weight: 850; }
.wform { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }
.wform input[inputmode=decimal] { font-size: 1.3rem; font-weight: 800; }
.wdate { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin: 0; }
.wdate span { flex: none; }
.wdate input { flex: 1; min-width: 0; }
.wform input { min-width: 0; }
.segmented.three { grid-template-columns: repeat(3, 1fr); margin-top: 14px; }
.wlegend { list-style: none; display: flex; gap: 16px; padding: 0; margin: 12px 0 4px; font-size: .82rem; color: var(--ink-2); }
.wlegend li { display: flex; align-items: center; gap: 6px; }
.wsw.line { width: 18px; height: 3px; border-radius: 2px; background: var(--w-trend); }
.wsw.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--w-dot); }
.wchart { position: relative; }
.wsvg { width: 100%; height: auto; display: block; touch-action: pan-y; }
.wgrid { stroke: var(--hair); stroke-width: 1; }
.wtick { fill: var(--ink-2); font-size: 11px; font-family: inherit; }
.wend { fill: var(--ink); font-size: 12px; font-weight: 800; font-family: inherit; }
.wdot { fill: var(--w-dot); stroke: var(--panel); stroke-width: 2; }
.wtrend { fill: none; stroke: var(--w-trend); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.wcross { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; }
.wtip {
  position: absolute; top: 4px; transform: translateX(-50%); pointer-events: none;
  background: var(--ink); color: var(--ground); border-radius: 10px; padding: 6px 10px;
  display: grid; font-size: .8rem; line-height: 1.3; box-shadow: var(--shadow); white-space: nowrap;
}
.wtip .muted { color: var(--ground); opacity: .85; }
.wlist li { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.wtip[hidden] { display: none; }
.wform input[inputmode=decimal]::placeholder { font-weight: 500; }

/* ---------- meal templates ---------- */
.meal-foot { display: flex; justify-content: flex-end; border-top: 1px solid var(--hair); padding-top: 4px; margin-top: 2px; }
.tpl-items li { display: flex; align-items: center; gap: 10px; }
.contents { display: contents; }

/* ---------- own dishes ---------- */
.dish-head { margin: 16px 0 2px; }
.dish-head h3 { font-size: .95rem; font-weight: 800; }
.dish-items li { display: flex; align-items: center; gap: 10px; }
.dish-items .mark { width: 36px; height: 36px; border-radius: 9px; font-size: .8rem; }
.dish-items .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dish-items .muted.small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gram-input { display: flex; align-items: center; gap: 4px; flex: none; }
.gram-input input { width: 74px; min-height: 42px; padding: 8px; text-align: right; font-weight: 700; }
.dish-items + .btn { margin-top: 10px; }
.dish-sum { margin-top: 6px; }
.dish-box { background: var(--panel); border-radius: 16px; padding: 10px 12px; margin: 14px 0 4px; box-shadow: var(--shadow); }
.dish-box b { font-size: .9rem; }
.dish-box .mark { width: 30px; height: 30px; border-radius: 8px; font-size: .72rem; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mark.mono { background: hsl(var(--hue, 180) 28% 22%); color: hsl(var(--hue, 180) 60% 84%); }
}
