@font-face {
  font-family: "Inter";
  src: url("fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --paper: #F8F9FB; --card: #FFFFFF; --mist: #EEF1F5; --line: #D5DBE3; --faint: #A8B2C0;
  --ink: #141A26; --ink-soft: #64748B;
  --good: #22C55E; --good-tint: #D3F5DF; --over: #E11D48; --over-tint: #FDE3E9; --carbs: #FF7A1A; --fat: #3D4A63;
  --k1: #FFFFFF; --k2: #E9EDF2; --rim: #E1E5EB; --lip: #C9D0DA; --shade: rgba(20, 26, 38, .2);
  --w1: #4A566C; --w2: #141A26; --primary-rim: #4B566A; --sheen: rgba(255, 255, 255, .07); --primary-face: var(--ink);
  --hi: inset 0 1px 0 rgba(255, 255, 255, .9); --card-ring: var(--mist); --badge: #FFFFFF; --liq1: 26%; --liq2: 50%;
  --cap1: var(--k1); --cap2: var(--k2); --cap-ink: var(--ink); --cap-soft: var(--ink-soft); --cap-ring: 0%; --liq-c: 100%;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --pad: 20px;
  /* the tactile key: raised face, pale rim, a thicker lip underneath, soft ambient shadow */
  --key-face: linear-gradient(var(--k1) 35%, var(--k2));
  --key-shadow: var(--hi), 0 0 0 1px var(--rim), 0 3px 0 0 var(--lip), 0 12px 18px -10px var(--shade);
  --key-pressed: var(--hi), 0 0 0 1px var(--rim), 0 1px 0 0 var(--lip), 0 4px 8px -6px var(--shade);
  --card-shadow: var(--hi), 0 0 0 1px var(--card-ring), 0 18px 32px -24px var(--shade);
  /* an active field sinks in: the pressed counterpart of the raised keys */
  --halo: inset 0 2px 5px var(--shade), inset 0 0 0 1px var(--faint), 0 1px 0 0 var(--k1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --paper: #151A23; --card: #1D2430; --mist: #28313F; --line: #3A4557; --faint: #74839A;
  --ink: #F1F4F8; --ink-soft: #9AA7BA;
  --good: #34D377; --good-tint: #153F29; --over: #FB5A7C; --over-tint: #4A1522; --carbs: #FF8F3D; --fat: #B9C4D6;
  --k1: #3D4859; --k2: #283140; --rim: #0B0E13; --lip: #040507; --shade: rgba(0, 0, 0, .7);
  --hi: inset 0 1px 0 rgba(255, 255, 255, .16); --card-ring: #2C3644; --badge: #FFFFFF; --liq1: 100%; --liq2: 100%; --liq-c: 70%;
  --cap1: #2B3443; --cap2: #1A212C; --cap-ink: #FFFFFF; --cap-soft: rgba(255, 255, 255, .74); --cap-ring: 100%; --fat: #A9B8D0; --good: #2FD377; --carbs: #FF8A33;
  --w1: #FFFFFF; --w2: #B4BECC; --primary-rim: #C5CCD8; --sheen: transparent; --primary-face: #EEF1F6; --primary-rim: #FFFFFF;
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --paper: #151A23; --card: #1D2430; --mist: #28313F; --line: #3A4557; --faint: #74839A;
  --ink: #F1F4F8; --ink-soft: #9AA7BA;
  --good: #34D377; --good-tint: #153F29; --over: #FB5A7C; --over-tint: #4A1522; --carbs: #FF8F3D; --fat: #B9C4D6;
  --k1: #3D4859; --k2: #283140; --rim: #0B0E13; --lip: #040507; --shade: rgba(0, 0, 0, .7);
  --hi: inset 0 1px 0 rgba(255, 255, 255, .16); --card-ring: #2C3644; --badge: #FFFFFF; --liq1: 100%; --liq2: 100%; --liq-c: 70%;
  --cap1: #2B3443; --cap2: #1A212C; --cap-ink: #FFFFFF; --cap-soft: rgba(255, 255, 255, .74); --cap-ring: 100%; --fat: #A9B8D0; --good: #2FD377; --carbs: #FF8A33;
  --w1: #FFFFFF; --w2: #B4BECC; --primary-rim: #C5CCD8; --sheen: transparent; --primary-face: #EEF1F6; --primary-rim: #FFFFFF;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: var(--mist); }
html, .view, .cap, .macros, #meal-list { transition: background-color .3s; }
body {
  margin: 0; color: var(--ink);
  font: 400 16px/1.4 "Inter", system-ui, "Helvetica Neue", Arial, sans-serif;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
h1, h2, p, ol { margin: 0; padding: 0; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* The app is a phone-width column everywhere; on a wide screen it sits centred on grey. */
.view {
  max-width: 460px; min-height: 100dvh; margin: 0 auto; background: var(--paper);
  padding: 0 var(--pad) calc(112px + env(safe-area-inset-bottom));
}
h2 { font-size: 20px; font-weight: 600; letter-spacing: -.02em; margin: 36px 0 12px; }
.help { color: var(--ink-soft); font-size: 15px; }

/* ---------- bars and buttons ---------- */
.bar-actions { display: flex; gap: 10px; }
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding-top: env(safe-area-inset-top); box-sizing: content-box; }
.mark { font-weight: 700; font-size: 24px; letter-spacing: -.045em; }
.bar-title { font-weight: 600; font-size: 17px; }
.icon { width: 46px; height: 46px; display: grid; place-items: center; background: none; border: 0; border-radius: 50%; }
button.icon, .datebtn, .ghost { background: var(--key-face); box-shadow: var(--key-shadow); transition: transform .12s var(--ease), box-shadow .12s var(--ease); }
button.icon:active, .datebtn:active, .ghost:active { transform: translateY(2px); box-shadow: var(--key-pressed); }
.icon svg, .datebtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.primary, .ghost {
  width: 100%; min-height: 58px; border-radius: 29px; border: 0; padding: 0 24px;
  font-weight: 500; font-size: 17px; letter-spacing: -.01em;
}
.primary {
  color: var(--paper);
  background: linear-gradient(118deg, transparent 40%, var(--sheen) 40% 49%, transparent 49% 52%, var(--sheen) 52% 57%, transparent 57%), var(--primary-face);
  box-shadow: inset 0 0 0 2px var(--primary-rim), 0 0 0 1px var(--primary-face), 0 18px 24px -12px var(--shade);
  transition: transform .12s var(--ease), box-shadow .12s var(--ease);
}
.primary:disabled { opacity: .5; }
.primary:active { transform: translateY(2px); box-shadow: inset 0 0 0 2px var(--primary-rim), 0 0 0 1px var(--primary-face), 0 8px 12px -8px var(--shade); }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; pointer-events: none;
  padding: 28px var(--pad) calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 62%, transparent);
  max-width: 460px; margin: 0 auto;
}
.dock > * { pointer-events: auto; }

/* ---------- date and week ---------- */
.datebtn { display: inline-flex; align-items: center; gap: 6px; min-height: 46px; margin: 0; padding-block: 0; padding-inline: 20px 14px; border: 0; border-radius: 23px; font-size: 17px; font-weight: 500; letter-spacing: -.01em; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 8px -4px 0; }
.week button { display: grid; justify-items: center; align-content: start; gap: 4px; padding: 10px 0 8px; background: none; border: 0; border-radius: 24px; min-height: 76px; }
.week .wd { font-size: 12px; color: var(--ink-soft); }
.week .dn { position: relative; min-height: 26px; display: grid; place-items: center; font-size: 17px; font-weight: 500; }
.week .dn::after { content: ""; position: absolute; left: 50%; top: 100%; width: 6px; height: 6px; margin: 4px 0 0 -3px; border-radius: 50%; }
.week button[aria-current="date"] { background: var(--key-face); box-shadow: var(--key-shadow); }
.week button[aria-current="date"] .wd { color: var(--ink); font-weight: 600; }
.week button:disabled { opacity: .35; }
.dn.good::after { background: var(--good); }
.dn.logged::after { background: var(--faint); }
.dn.over::after { background: var(--over); }

/* ---------- the gauge ---------- */
.gauge { position: relative; margin: 36px 0 0; }
#gauge { display: block; width: 100%; height: auto; overflow: visible; }
#gauge rect { fill: var(--mist); stroke: var(--card-ring); stroke-width: .5; transition: fill .35s var(--ease); }
#gauge rect.on { fill: var(--ink); stroke: none; }
.gauge.good #gauge rect.on { fill: var(--good); }
.gauge.over #gauge rect.on { fill: var(--over); }
.gauge-mid { position: absolute; left: 0; right: 0; top: 0; aspect-ratio: 320 / 176; display: grid; align-content: end; justify-items: center; pointer-events: none; }
#flame { width: 46px; height: 54px; margin-bottom: 2px; overflow: visible; }
#flame .body { transform-box: fill-box; transform-origin: 50% 100%; transform: scale(.42); transition: transform .7s var(--ease); }
#flame .outer { fill: var(--faint); transition: fill .4s; }
#flame .inner { fill: #FFE08A; opacity: 0; transition: opacity .4s; }
#flame[data-fire="1"] .body { transform: scale(.6); }
#flame[data-fire="2"] .body { transform: scale(.8); }
#flame[data-fire="3"] .body { transform: none; }
#flame:not([data-fire="0"]) .outer { fill: url(#g-flame); }
#flame:is([data-fire="2"], [data-fire="3"]) .inner { opacity: 1; }
#flame .alert { opacity: 0; transform-box: fill-box; transform-origin: 50% 60%; transform: scale(.5); transition: opacity .3s, transform .5s var(--ease); }
#flame .face { fill: var(--over); stroke: var(--over); stroke-width: 9; stroke-linejoin: round; }
#flame .lip { fill: color-mix(in srgb, var(--over) 62%, #000); stroke: color-mix(in srgb, var(--over) 62%, #000); stroke-width: 9; stroke-linejoin: round; }
#flame .bang { fill: none; stroke: #fff; stroke-width: 4.500; stroke-linecap: round; } #flame .dot { fill: #fff; }
.gauge.over #flame .body { opacity: 0; }
.gauge.over #flame .alert { opacity: 1; transform: none; animation: breathe 2.2s ease-in-out .6s infinite; }
.gauge.over #flame { filter: drop-shadow(0 8px 14px color-mix(in srgb, var(--over) 50%, transparent)); }
@keyframes breathe { 50% { transform: scale(1.07); } }
#flame[data-fire="3"] { filter: drop-shadow(0 4px 10px rgba(255, 122, 26, .45)); }
.gauge-mid b { margin-top: 2px; font-size: clamp(34px, 11vw, 46px); line-height: 1; font-weight: 700; letter-spacing: -.04em; }
.gauge-mid span { margin-top: 4px; font-size: 15px; color: var(--ink-soft); }
.gauge.over .gauge-mid b { color: var(--over); }
.pans { display: flex; justify-content: space-between; margin-top: 10px; }
.pans p { display: grid; flex: 0 1 72px; min-width: 0; text-align: center; }
.pans b { font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.pans span { font-size: 13px; color: var(--ink-soft); }

/* ---------- verdict ---------- */
.verdict { margin-top: 32px; }
.verdict h1 { font-size: clamp(28px, 8.2vw, 36px); line-height: 1.08; font-weight: 600; letter-spacing: -.04em; text-wrap: balance; }
.verdict p { margin-top: 10px; color: var(--ink-soft); font-size: 16px; }
.verdict.over h1 { color: var(--over); }

/* ---------- macros ---------- */
.macros, #meal-list { background: var(--card); border-radius: 28px; box-shadow: var(--card-shadow); }
.macros { margin-top: 28px; padding: 20px 8px 16px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.macro { display: grid; justify-items: center; text-align: center; min-width: 0; --c: var(--good); }
.macro.carbs { --c: var(--carbs); }
.macro.fat { --c: var(--fat); }
.cap {
  position: relative; overflow: hidden; width: min(74px, 100%); min-height: 124px; border-radius: 37px; padding: 20px 0 14px;
  display: grid; grid-template-rows: 1fr auto; justify-items: center;
  background: linear-gradient(var(--cap1) 45%, var(--cap2)); color: var(--cap-ink);
  box-shadow: var(--hi), 0 0 0 1.500px color-mix(in srgb, var(--c) var(--cap-ring), var(--rim)), 0 4px 0 0 color-mix(in srgb, color-mix(in srgb, var(--c) 60%, #000) var(--cap-ring), var(--lip)), 0 16px 20px -12px var(--shade);
  transition: box-shadow .4s;
}
.cap .liquid {
  position: absolute; inset: auto 0 0 0; height: calc(var(--fill, 0) * 100%);
  background: linear-gradient(transparent, color-mix(in srgb, color-mix(in srgb, var(--c) var(--liq-c), #000) var(--liq1), transparent) 22px, color-mix(in srgb, color-mix(in srgb, var(--c) var(--liq-c), #000) var(--liq2), transparent));
  transition: height 1s var(--ease);
}
.cap .val { position: relative; display: grid; align-content: start; }
.cap .val b { font-size: 22px; line-height: 1.1; font-weight: 600; letter-spacing: -.03em; }
.cap .val small { font-size: 12px; color: var(--cap-soft); }
.cap .badge { position: relative; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--badge); box-shadow: inset 0 0 0 2px var(--faint), 0 2px 4px var(--shade); color: #fff; font-weight: 700; font-size: 16px; line-height: 1; }
.cap .badge svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.macro.done .cap { box-shadow: 0 0 0 1.5px var(--c), 0 4px 0 0 color-mix(in srgb, var(--c) 75%, #000), 0 16px 20px -12px color-mix(in srgb, var(--c) 60%, transparent); }
.macro.done .badge { background: var(--c); box-shadow: none; }
.macro.over { --c: var(--over); }
.macro.over .cap { box-shadow: 0 0 0 1.5px var(--over), 0 4px 0 0 color-mix(in srgb, var(--over) 70%, #000), 0 16px 20px -12px color-mix(in srgb, var(--over) 50%, transparent); }
.macro.over .badge { background: var(--over); box-shadow: none; }
.macro .n { margin-top: 14px; font-size: 15px; font-weight: 500; }
.macro .note { font-size: 13px; color: var(--ink-soft); }
.macro.over .note { color: var(--over); font-weight: 500; }

/* ---------- meals ---------- */
#meal-list { padding: 4px 16px; }
#meal-list:empty { display: none; }
.meal { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; width: 100%; padding: 10px 0; background: none; border: 0; text-align: start; overflow-wrap: break-word; color: inherit; }
.meal + .meal { border-top: 1px solid var(--mist); }
.plate { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--mist); }
.plate.empty { display: grid; place-items: center; box-shadow: inset 0 0 0 6px var(--mist), inset 0 0 0 7px var(--line); background: var(--card); font-weight: 600; font-size: 15px; color: var(--ink-soft); }
.meal .t { font-size: 16px; font-weight: 500; line-height: 1.2; letter-spacing: -.01em; }
.meal .s { font-size: 14px; color: var(--ink-soft); margin-top: 3px; }
.meal .k { font-size: 18px; font-weight: 600; letter-spacing: -.02em; text-align: end; white-space: nowrap; }
.meal .k small { display: block; font-size: 12px; font-weight: 400; color: var(--ink-soft); letter-spacing: 0; }
.meal::after { content: ""; width: 8px; height: 8px; border: solid var(--faint); border-width: 2px 2px 0 0; rotate: 45deg; margin-inline: -4px 4px; }
[dir="rtl"] .meal::after { rotate: -135deg; }
.nothing { color: var(--ink-soft); padding: 14px 0; }
.meal.first .t { color: var(--ink-soft); }
.meal.first { grid-template-columns: 44px minmax(0, 1fr) auto; }
.meal:active .plate { transform: scale(.96); }
.plate { transition: transform .2s var(--ease); }

/* ---------- editor ---------- */
/* the photo: a viewfinder card with two keys, camera or library */
.shot { display: grid; grid-template-columns: 104px minmax(0, 1fr); align-items: center; gap: 14px; margin: 4px 0 12px; padding: 14px 12px; border-radius: 28px; background: var(--card); box-shadow: var(--card-shadow); }
/* a small tilted print with a soft wash of the app's colours; the photo replaces the wash */
.finder { position: relative; justify-self: center; width: 84px; aspect-ratio: 1; rotate: -6deg; border-radius: 20px; padding: 5px; background: var(--key-face); box-shadow: 0 0 0 1px var(--rim), 0 3px 0 0 var(--lip), 0 16px 20px -10px var(--shade); transition: rotate .4s var(--ease); display: grid; }
.finder::before { content: ""; grid-area: 1 / 1; border-radius: 15px; background: radial-gradient(circle at 25% 20%, color-mix(in srgb, var(--good) 55%, transparent), transparent 60%), radial-gradient(circle at 85% 90%, color-mix(in srgb, var(--carbs) 60%, transparent), transparent 65%), var(--mist); }
.finder img { grid-area: 1 / 1; position: relative; width: 100%; height: 100%; border-radius: 15px; object-fit: cover; }
.finder svg { grid-area: 1 / 1; position: relative; place-self: center; width: 28px; height: 28px; fill: none; stroke: #fff; stroke-width: 1.800; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 2px rgba(20, 26, 38, .25)); }
.finder .plus { position: absolute; right: -8px; bottom: -8px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; rotate: 6deg; background: var(--ink); color: var(--paper); font-style: normal; font-size: 18px; font-weight: 500; line-height: 1; box-shadow: 0 0 0 3px var(--card), 0 6px 10px -4px var(--shade); }
.shot.has-photo .finder { rotate: -3deg; }
.shot.has-photo .finder svg, .shot.has-photo .plus { display: none; }
.shot-actions { display: grid; gap: 10px; }
.key { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 12px; border-radius: 25px; font-size: 16px; font-weight: 500; cursor: pointer; background: var(--key-face); box-shadow: var(--key-shadow); transition: transform .12s var(--ease), box-shadow .12s var(--ease); }
.key:active { transform: translateY(2px); box-shadow: var(--key-pressed); }
.key:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.key svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.700; stroke-linecap: round; stroke-linejoin: round; }
.name { width: 100%; min-height: 56px; margin-bottom: 12px; padding: 0 18px; border: 0; outline: 0; border-radius: 22px; background: var(--card); box-shadow: var(--card-shadow); font-size: 17px; font-weight: 500; }
.name::placeholder { color: var(--faint); font-weight: 400; }
.name, .ing, .field, .ing .grams, #ask-answer, .ing .manual input { transition: box-shadow .2s var(--ease); }
.name:focus { box-shadow: var(--halo); }
.ing:has(.ing-top input:focus) { box-shadow: var(--halo); }
.ing .manual input:focus { box-shadow: var(--halo); }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--mist); box-shadow: inset 0 1px 3px var(--shade), inset 0 0 0 1px var(--card-ring); border-radius: 24px; padding: 4px; }
.seg button { min-height: 40px; border: 0; background: none; border-radius: 20px; font-size: 14px; font-weight: 500; }
.seg button[aria-checked="true"] { background: var(--key-face); box-shadow: var(--hi), 0 0 0 1px var(--rim), 0 2px 0 0 var(--lip), 0 6px 10px -6px var(--shade); font-weight: 600; }

/* a two-way switch with a thumb that slides */
.seg.mode { grid-template-columns: repeat(2, 1fr); position: relative; margin: 14px 0 6px; }
.seg.mode::before { content: ""; position: absolute; inset-block: 4px; inset-inline-start: 4px; width: calc(50% - 4px); border-radius: 20px; background: var(--key-face); box-shadow: var(--hi), 0 0 0 1px var(--rim), 0 2px 0 0 var(--lip), 0 6px 10px -6px var(--shade); transition: translate .35s var(--ease); }
.seg.mode[data-mode="hand"]::before { translate: 100% 0; }
[dir="rtl"] .seg.mode[data-mode="hand"]::before { translate: -100% 0; }
.seg.mode button { position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; font-size: 15px; color: var(--ink-soft); transition: color .2s; }
.seg.mode button[aria-checked="true"] { background: none; box-shadow: none; color: var(--ink); }
.seg.mode svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.800; stroke-linecap: round; stroke-linejoin: round; }
.ing { background: var(--card); box-shadow: var(--card-shadow); border-radius: 22px; padding: 6px 6px 10px 16px; margin-top: 10px; }
.ing-top { display: grid; grid-template-columns: minmax(0, 1fr) 40px; align-items: center; gap: 6px; }
.ing-top input { font-weight: 500; }
.ing-bottom { display: grid; grid-template-columns: minmax(0, 1fr) 104px; align-items: center; gap: 12px; padding-inline-end: 10px; }
.ing input { border: 0; background: none; outline: 0; min-height: 48px; min-width: 0; font-size: 17px; }
.ing .grams { display: flex; align-items: center; background: var(--mist); border-radius: 14px; padding: 0 12px; }
.ing .grams input { width: 100%; text-align: end; font-weight: 600; }
.ing .grams em { font-style: normal; color: var(--ink-soft); margin-inline-start: 4px; }
.ing .grams:focus-within { box-shadow: var(--halo); }
.ing .rm { width: 40px; height: 44px; background: none; border: 0; color: var(--ink-soft); font-size: 22px; line-height: 1; }
.ing .res { display: block; width: 100%; background: none; border: 0; padding: 0; text-align: start; font-size: 14px; line-height: 1.3; color: var(--ink-soft); min-height: 44px; }
.ing .res.missing { color: var(--ink); text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 3px; }
.ing .manual { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 2px; margin-inline-end: 10px; }
.ing .manual label { display: grid; gap: 2px; font-size: 12px; color: var(--ink-soft); }
.ing .manual input { background: var(--mist); border-radius: 10px; padding: 0 8px; min-height: 40px; font-size: 15px; }
.add-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.add-row .ghost { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 10px; font-size: 16px; }
.add-row svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.700; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 360px) { .add-row svg { display: none; } .add-row .ghost { font-size: 15px; } }
#pick { min-height: 60dvh; }
#pick .name { margin: 6px 0 4px; }

.totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 26px; }
.totals p { display: grid; }
.totals b { font-size: 22px; font-weight: 600; letter-spacing: -.03em; }
.totals span { font-size: 13px; color: var(--ink-soft); }
.form-error { display: flex; align-items: flex-start; gap: 8px; margin: 20px 0 0; padding-inline: 6px; color: var(--over); font-size: 14px; font-weight: 500; line-height: 1.35; animation: appear .25s ease-out; }
.form-error::before { content: "!"; flex: none; width: 16px; height: 16px; margin-top: 1.500px; border-radius: 50%; display: grid; place-items: center; background: var(--over); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; }
.field-error { margin: 10px 0 14px; }
.name.invalid { margin-bottom: 0; }
.name.invalid, .ing.invalid { box-shadow: inset 0 0 0 1.500px var(--over); }
@keyframes appear { from { opacity: 0; } }

/* ---------- targets ---------- */
.field { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto; align-items: center; gap: 8px; background: var(--card); box-shadow: var(--card-shadow); border-radius: 22px; padding: 4px 16px; margin-top: 10px; min-height: 60px; }
.field span { font-weight: 500; }
.field input { border: 0; background: none; outline: 0; text-align: end; font-size: 22px; font-weight: 600; min-width: 0; width: 100%; }
.field em { font-style: normal; color: var(--ink-soft); min-width: 30px; }
.field:focus-within { box-shadow: var(--halo); }
#targets-form .primary { margin-top: 18px; }
#targets-hint { margin-top: 12px; }
#export { margin-top: 20px; }

/* ---------- sheets ---------- */
dialog.sheet {
  width: 100%; max-width: 460px; max-height: 92dvh; margin: auto auto 0; border: 0; overflow-y: auto;
  padding: 8px var(--pad) calc(24px + env(safe-area-inset-bottom)); background: var(--card); color: var(--ink);
  border-radius: 28px 28px 0 0;
}
dialog.sheet[open] { animation: up .3s var(--ease); }
dialog.sheet::backdrop { background: rgba(20, 26, 38, .4); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; min-height: 56px; }
.sheet-head h2 { margin: 0; }
.cal-days, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); justify-items: center; }
.cal-days { font-size: 12px; color: var(--ink-soft); margin: 4px 0 6px; }
.cal-grid { row-gap: 4px; }
.cal-grid button { position: relative; width: 44px; height: 44px; border: 0; background: none; border-radius: 50%; font-size: 16px; font-weight: 500; }
.cal-grid button::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; }
.cal-grid button.good::after { background: var(--good); }
.cal-grid button.logged::after { background: var(--faint); }
.cal-grid button.over::after { background: var(--over); }
.cal-grid button[aria-current="date"] { background: var(--key-face); box-shadow: var(--key-shadow); }
.cal-grid button.today { font-weight: 800; }
.cal-grid button:disabled { color: var(--faint); }
.cal-key { display: flex; gap: 16px; align-items: center; margin: 16px 0 6px; font-size: 13px; color: var(--ink-soft); }
.cal-key .k { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: -10px; }
.cal-key .good { background: var(--good); }
.cal-key .logged { background: var(--faint); }
.cal-key .over { background: var(--over); }
#cal-today { margin-top: 16px; }

.steps { list-style: none; counter-reset: s; display: grid; gap: 22px; margin-top: 18px; }
.steps li { counter-increment: s; display: grid; gap: 10px; padding-inline-start: 40px; position: relative; }
.steps li::before { color: var(--ink); content: counter(s); position: absolute; inset-inline-start: 0; top: -2px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--good-tint); font-weight: 700; }
#ask-answer { width: 100%; border: 0; border-radius: 18px; background: var(--mist); padding: 12px 14px; outline: 0; resize: vertical; font-size: 15px; }
#ask-answer:focus { box-shadow: var(--halo); }
#lock-form { display: grid; gap: 12px; padding-top: 14px; }

.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; padding: 12px 18px; background: var(--ink); color: var(--card); border-radius: 22px; font-size: 15px; font-weight: 500; width: max-content; max-width: calc(100% - 32px); text-align: center; }

@keyframes up { from { transform: translateY(48px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* keep focused controls clear of the fixed bottom button */
.view :is(input, button, textarea) { scroll-margin-bottom: 128px; }

input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* very narrow screens and 200% zoom: drop decoration before anything overlaps */
@media (max-width: 300px) {
  :root { --pad: 12px; }
  .week { gap: 0; margin-inline: 0; }
  .week .wd { font-size: 10px; }
  .gauge-mid span { font-size: 12px; }
  #flame { width: 32px; height: 38px; }
  .macros { padding-inline: 4px; column-gap: 4px; }
  .cap .val b { font-size: 17px; }
  .macro .note { font-size: 12px; }
  #meal-list { padding-inline: 12px; }
  .meal { grid-template-columns: minmax(0, 1fr) auto; }
  .meal .plate, .meal::after { display: none; }
}

/* ---------- groceries ---------- */
.dock.duo { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.icon.big { width: 58px; height: 58px; }
.icon.big svg { width: 24px; height: 24px; }
#pantry-search { margin-top: 16px; }
.gro-card { margin-top: 8px; }
.gro-card { padding: 4px 16px; background: var(--card); border-radius: 28px; box-shadow: var(--card-shadow); }
.gro { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px; width: 100%; padding: 12px 0; background: none; border: 0; text-align: start; color: inherit; overflow-wrap: break-word; }
.gro + .gro { border-top: 1px solid var(--mist); }
.gro .t { display: block; font-size: 16px; font-weight: 500; line-height: 1.25; }
.gro .s { display: block; margin-top: 3px; font-size: 13px; color: var(--ink-soft); }
.gro .k { font-size: 17px; font-weight: 600; letter-spacing: -.02em; text-align: end; white-space: nowrap; }
.gro .k small { display: block; font-size: 12px; font-weight: 400; color: var(--ink-soft); letter-spacing: 0; }
.gro::after { content: ""; width: 8px; height: 8px; border: solid var(--faint); border-width: 2px 2px 0 0; rotate: 45deg; margin-inline: -4px 4px; }
.key.wide { width: 100%; min-height: 56px; margin-top: 6px; }
#grocery h2 { margin: 26px 0 12px; }
#grocery .sheet-head h2 { margin: 0; }
#grocery .name { margin-bottom: 0; }
#grocery-save { margin-top: 20px; }
#grocery-delete { margin-top: 10px; color: var(--over); }
#label-answer { width: 100%; border: 0; border-radius: 18px; background: var(--mist); padding: 12px 14px; outline: 0; resize: vertical; font-size: 15px; transition: box-shadow .2s var(--ease); }
#label-answer:focus { box-shadow: var(--halo); }
