:root {
  --bg: #070b16;
  --panel: #0e1526;
  --card: #141c30;
  --card-2: #1a2440;
  --line: rgba(148, 163, 184, 0.14);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --dim: #64748b;
  --accent: #34d399;
  --accent-2: #22d3ee;
  --carb: #fbbf24;
  --prot: #818cf8;
  --fat: #38bdf8;
  --water: #22d3ee;
  --violet: #a78bfa;
  --danger: #f87171;
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden, [hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11px; }
.accent { color: var(--accent); font-weight: 600; }
.dot { opacity: 0.5; margin: 0 2px; }
.link { color: var(--accent); margin-left: 4px; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--panel);
  padding-bottom: calc(96px + var(--safe-b));
  position: relative;
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-t) + 12px) 16px 12px;
  background: rgba(14, 21, 38, 0.86);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 30px; height: 36px; padding: 4px; border-radius: 10px;
  background: #050812; border: 1px solid rgba(52, 211, 153, 0.35);
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px;
}
.logo i { border-radius: 3px; background: linear-gradient(135deg, #34d399, #14b8a6); }
.logo i:nth-child(n+3) { background: linear-gradient(135deg, #10b981, #0d9488); }
.logo i:nth-child(n+5) { background: linear-gradient(135deg, #059669, #0f766e); }
.brand-name { font-weight: 800; letter-spacing: 0.04em; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.daynav { display: flex; align-items: center; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.day-label { font-size: 13px; font-weight: 600; padding: 6px 4px; min-width: 76px; text-align: center; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 999px; color: var(--muted); }
.icon-btn:active { background: var(--card-2); }

/* Layout */
.view { padding: 14px 14px 0; display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 8px 4px -2px; font-weight: 700; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.big { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; margin: 2px 0 6px; font-variant-numeric: tabular-nums; }
.big.over { color: var(--danger); }
.mid { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.footnote { font-size: 11px; color: var(--dim); text-align: center; margin: 4px 0 8px; }

/* Hero */
.hero { background: linear-gradient(160deg, #18233d 0%, #131b2f 60%); }
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ring-wrap { position: relative; width: 112px; height: 112px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring-bg { stroke: rgba(148, 163, 184, 0.15); }
.ring-fg { stroke: url(#g1); stroke-linecap: round; stroke-dasharray: 263.89; stroke-dashoffset: 263.89; transition: stroke-dashoffset 0.6s cubic-bezier(.4,0,.2,1); }
.ring-fg.over { stroke: var(--danger); }
.ring-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-label b { font-size: 20px; font-variant-numeric: tabular-nums; }
.ring-label span { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.mrow { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; margin-bottom: 6px; }
.mname { font-weight: 700; }
.mval { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.mval b { color: var(--text); font-weight: 600; }
.macro[data-m="c"] .mname { color: var(--carb); }
.macro[data-m="p"] .mname { color: var(--prot); }
.macro[data-m="f"] .mname { color: var(--fat); }
.bar { height: 7px; background: rgba(148, 163, 184, 0.15); border-radius: 99px; overflow: hidden; }
.bar.thick { height: 9px; margin-top: 12px; }
.bar i { display: block; height: 100%; width: 100%; border-radius: inherit; transform: scaleX(0); transform-origin: left center; transition: transform 0.5s cubic-bezier(.4,0,.2,1); }
.macro[data-m="c"] .bar i { background: var(--carb); }
.macro[data-m="p"] .bar i { background: var(--prot); }
.macro[data-m="f"] .bar i { background: var(--fat); }
.bar i.over { background: var(--danger) !important; }

/* Tiles */
.tile { padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.tile-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13.5px; }
.tile-val { font-size: 13px; }
.tile-val b { font-size: 22px; font-variant-numeric: tabular-nums; }
.chip { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; }
.chip svg { width: 16px; height: 16px; }
.chip.teal { background: rgba(52, 211, 153, 0.14); color: var(--accent); }
.chip.cyan { background: rgba(34, 211, 238, 0.14); color: var(--water); }
.chip.violet { background: rgba(167, 139, 250, 0.16); color: var(--violet); }
.chip.amber { background: rgba(251, 191, 36, 0.14); color: var(--carb); }
.chip.orange { background: rgba(251, 146, 60, 0.14); color: #fb923c; }
.chip.indigo { background: rgba(129, 140, 248, 0.16); color: var(--prot); }
.water-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.pill-btn { width: 30px; height: 30px; border-radius: 10px; background: rgba(34, 211, 238, 0.14); color: var(--water); font-size: 18px; font-weight: 700; display: grid; place-items: center; flex: none; }
.pill-btn:active { transform: scale(0.92); }
.glasses { flex: 1; display: flex; gap: 3px; justify-content: center; }
.glasses i { width: 7px; height: 16px; border-radius: 2px 2px 3px 3px; background: rgba(148, 163, 184, 0.2); }
.glasses i.on { background: var(--water); }

/* Fasting */
.fast-head { display: flex; justify-content: space-between; align-items: center; }
.tag { font-size: 10.5px; font-weight: 700; color: var(--violet); background: rgba(167,139,250,.15); padding: 2px 7px; border-radius: 99px; }
.fast-body { margin-top: 10px; }
.fast-time { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
#fastBar { background: linear-gradient(90deg, #818cf8, #a78bfa); }
#fastBar.done { background: linear-gradient(90deg, #34d399, #22d3ee); }

/* Buttons */
.btn-sm { font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 12px; background: var(--card-2); border: 1px solid var(--line); }
.btn-sm:active { transform: scale(0.97); }
.btn-sm.on { background: rgba(52,211,153,.15); color: var(--accent); border-color: rgba(52,211,153,.3); }
.btn-primary { width: 100%; padding: 14px; border-radius: 14px; background: linear-gradient(135deg, #34d399, #14b8a6); color: #052e22; font-weight: 800; font-size: 15px; margin-top: 6px; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.4; }
.btn-danger { width: 100%; padding: 12px; border-radius: 14px; color: var(--danger); border: 1px solid rgba(248,113,113,.3); margin-top: 14px; font-weight: 600; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.file-btn { display: inline-flex; align-items: center; cursor: pointer; }

/* Meals */
.meal { padding: 0; overflow: hidden; }
.meal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 14px; }
.meal-title { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.meal-kcal { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.meal-right { display: flex; align-items: center; gap: 10px; }
.add-btn { width: 32px; height: 32px; border-radius: 10px; background: rgba(52,211,153,.15); color: var(--accent); display: grid; place-items: center; }
.add-btn:active { transform: scale(0.92); }
.add-btn svg { width: 18px; height: 18px; }
.entries { border-top: 1px solid var(--line); }
.entry { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; width: 100%; text-align: left; }
.entry + .entry { border-top: 1px solid rgba(148,163,184,.07); }
.entry:active { background: var(--card-2); }
.entry-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-sub { font-size: 11.5px; color: var(--muted); }
.entry-kcal { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.entry > div { min-width: 0; }

/* FAB + tabbar */
.fab {
  position: fixed; z-index: 30;
  right: max(16px, calc(50vw - 240px + 16px));
  bottom: calc(76px + var(--safe-b));
  width: 56px; height: 56px; border-radius: 18px;
  background: linear-gradient(135deg, #34d399, #14b8a6); color: #052e22;
  display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(20, 184, 166, 0.35);
}
.fab svg { width: 26px; height: 26px; stroke-width: 2.6; }
.fab:active { transform: scale(0.94); }
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); z-index: 25;
  width: 100%; max-width: 480px;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 6px 12px calc(6px + var(--safe-b));
  background: rgba(10, 15, 28, 0.9);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--dim); font-size: 10.5px; font-weight: 600; }
.tab.active { color: var(--accent); }
.tab svg { width: 22px; height: 22px; }

/* Sheet */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
.sheet {
  width: 100%; max-width: 480px; max-height: 92dvh;
  background: var(--panel); border-radius: 24px 24px 0 0; border: 1px solid var(--line); border-bottom: 0;
  display: flex; flex-direction: column;
  animation: up .28s cubic-bezier(.2,.8,.2,1);
  padding-bottom: var(--safe-b);
}
.grabber { width: 38px; height: 5px; border-radius: 9px; background: rgba(148,163,184,.3); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; gap: 4px; padding: 6px 10px 6px 16px; }
.sheet-head h3 { flex: 1; margin: 0; font-size: 17px; }
.sheet-body { overflow-y: auto; padding: 4px 16px 18px; -webkit-overflow-scrolling: touch; }
@keyframes up { from { transform: translateY(40%); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; margin-bottom: 12px; overflow-x: auto; }
.seg button { flex: 1; padding: 8px 6px; font-size: 12.5px; font-weight: 600; border-radius: 9px; color: var(--muted); white-space: nowrap; }
.seg button.on { background: var(--card-2); color: var(--text); }

.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 0 12px; }
.search svg { color: var(--muted); width: 18px; height: 18px; }
.search input { flex: 1; background: none; border: 0; outline: 0; padding: 13px 0; font-size: 16px; }
.results { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.result { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; text-align: left; width: 100%; }
.result:active { border-color: rgba(52,211,153,.5); }
.result .entry-name { font-weight: 600; }
.result .kc { color: var(--accent); font-weight: 700; font-size: 13px; flex: none; text-align: right; }
.result .kc small { display: block; color: var(--dim); font-weight: 500; font-size: 10.5px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 8px; }
.group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); font-weight: 700; margin: 10px 2px 2px; }

/* Forms */
.form h3 { margin: 4px 0 10px; font-size: 15px; }
.form h3:not(:first-child) { margin-top: 18px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.span2 { grid-column: span 2; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }
input[type=number], input[type=text], input[type=datetime-local], select {
  width: 100%; background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; font-size: 16px; color: var(--text); outline: none; -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
input:focus, select:focus { border-color: rgba(52,211,153,.6); }
.switch { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 14px; font-weight: 500; margin: 8px 0 12px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.calc { background: var(--card-2); border-radius: 14px; padding: 12px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.calc b { color: var(--text); }

/* Amount view */
.food-hero { padding: 4px 0 12px; }
.food-hero h4 { margin: 0; font-size: 18px; line-height: 1.25; }
.amount-row { display: flex; gap: 8px; align-items: stretch; }
.amount-row input { font-size: 22px; font-weight: 700; text-align: center; }
.unit { display: grid; place-items: center; padding: 0 14px; background: var(--card); border-radius: 12px; color: var(--muted); font-weight: 600; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 14px; }
.quick button { padding: 7px 11px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); font-size: 12.5px; font-weight: 600; }
.nutri { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; margin-bottom: 14px; }
.nutri div { background: var(--card); border-radius: 12px; padding: 10px 4px; }
.nutri b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.nutri span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.nutri .k b { color: var(--accent); }
.nutri .c span { color: var(--carb); } .nutri .p span { color: var(--prot); } .nutri .f span { color: var(--fat); }
.meal-pick { margin-bottom: 4px; }

/* Scanner */
.scanner { position: relative; border-radius: 18px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 28% 12%; border: 2px solid rgba(52,211,153,.9); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scan-line { position: absolute; left: 14%; right: 14%; top: 50%; height: 2px; background: var(--accent); opacity: .8; animation: scan 1.8s ease-in-out infinite; }
@keyframes scan { 0%,100% { transform: translateY(-36px); } 50% { transform: translateY(36px); } }

/* Charts */
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h3 { margin: 0; font-size: 15px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.chart svg { width: 100%; height: auto; display: block; stroke: none; stroke-width: 1; }
.chart text { fill: var(--dim); stroke: none; font-size: 10px; font-family: inherit; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); z-index: 60; background: #f1f5f9; color: #0f172a; font-weight: 600; font-size: 13.5px; padding: 10px 14px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.4); display: flex; gap: 12px; align-items: center; animation: fade .2s; }
.toast button { color: #047857; font-weight: 800; }

@media (min-width: 520px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Apple Health banner */
.health-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-color: rgba(52,211,153,.35); background: rgba(52,211,153,.08); }
.health-banner b { font-size: 14px; }
.btn-health { width: 100%; margin-top: 10px; padding: 12px; border-radius: 14px; background: #f1f5f9; color: #0f172a; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-health svg { color: #ef4444; fill: #ef4444; stroke: none; }

/* Account / sync */
.acct { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.acct b { font-size: 14px; word-break: break-all; }
.sync-dot { width: 10px; height: 10px; border-radius: 99px; background: var(--dim); flex: none; }
.sync-dot[data-s="synced"] { background: var(--accent); }
.sync-dot[data-s="syncing"], .sync-dot[data-s="pending"], .sync-dot[data-s="connecting"] { background: var(--carb); }
.sync-dot[data-s="error"], .sync-dot[data-s="signedout"] { background: var(--danger); }

.key-box { display: flex; gap: 8px; margin-bottom: 8px; }
.key-box input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* ---------- Full-screen add flow ---------- */
.sheet-backdrop.full { background: var(--panel); align-items: stretch; animation: none; }
.sheet-backdrop.full .sheet {
  height: 100dvh; max-height: none; border-radius: 0; border: 0;
  padding-top: var(--safe-t); animation: slideIn .24s cubic-bezier(.2,.8,.2,1);
}
.sheet-backdrop.full .grabber { display: none; }
.sheet-backdrop.full .sheet-head { padding: 8px 8px 4px 12px; }
.sheet-backdrop.full .sheet-body { flex: 1; padding-bottom: 90px; }
@keyframes slideIn { from { transform: translateX(24px); opacity: .5; } to { transform: none; opacity: 1; } }

.meal-switch { position: relative; display: inline-flex; flex-direction: row; align-items: center; gap: 4px; font-size: 17px; font-weight: 700; color: var(--text); }
.meal-switch svg { width: 16px; height: 16px; transform: rotate(90deg); color: var(--accent); }
.meal-switch select { position: absolute; inset: 0; opacity: 0; font-size: 16px; }

.bigsearch { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 0 6px 0 14px; position: sticky; top: 0; z-index: 2; box-shadow: 0 8px 20px rgba(0,0,0,.25); }
.bigsearch > svg { color: var(--muted); width: 20px; height: 20px; }
.bigsearch input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; padding: 15px 0; font-size: 17px; color: var(--text); }
.bigsearch input::-webkit-search-cancel-button { filter: invert(.7); }
.scan-btn { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgba(52,211,153,.14); color: var(--accent); flex: none; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 14px 0 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { padding: 8px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--muted); background: var(--card); border: 1px solid var(--line); white-space: nowrap; }
.tabs button.on { background: var(--text); color: #0b1120; border-color: var(--text); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.tile-btn { display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-weight: 600; font-size: 14px; }
.tile-btn svg { width: 18px; height: 18px; color: var(--accent); }

.flist { display: flex; flex-direction: column; }
#searchRes { margin-top: 10px; }
.frow { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.frow-main { flex: 1; min-width: 0; text-align: left; padding: 12px 2px; }
.frow-main:active { opacity: .6; }
.fname { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fname .star { color: var(--carb); }
.fsub { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fadd { width: 38px; height: 38px; border-radius: 999px; display: grid; place-items: center; background: var(--accent); color: #052e22; flex: none; transition: transform .15s, background .2s; }
.fadd svg { width: 20px; height: 20px; stroke-width: 2.8; }
.fadd:active { transform: scale(.88); }
.fadd.done { background: var(--accent-2); }

.added-bar { position: absolute; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 12px 12px 16px; border-radius: 16px; background: #f1f5f9; color: #0f172a; font-size: 14px; box-shadow: 0 12px 30px rgba(0,0,0,.45); animation: fade .2s; }
.added-bar button { background: #0f172a; color: #fff; font-weight: 700; padding: 8px 14px; border-radius: 10px; }
.sheet { position: relative; }

/* Food detail */
.fd-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 6px 0 4px; }
.fd-head h4 { margin: 0; font-size: 21px; line-height: 1.2; }
.fav-btn { font-size: 24px; line-height: 1; width: 44px; height: 44px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); color: var(--dim); flex: none; }
.fav-btn.on { color: var(--carb); border-color: rgba(251,191,36,.4); }
.fd-kcal { display: flex; align-items: baseline; gap: 6px; margin: 14px 0 10px; }
.fd-kcal b { font-size: 44px; font-weight: 800; letter-spacing: -.02em; color: var(--accent); font-variant-numeric: tabular-nums; }
.fd-kcal span { color: var(--muted); font-weight: 600; }
.units { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.units button { padding: 9px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 14px; }
.units button.on { border-color: var(--accent); color: var(--accent); background: rgba(52,211,153,.1); }
.stepper { display: grid; grid-template-columns: 52px 1fr auto 52px; gap: 8px; align-items: stretch; margin-bottom: 14px; }
.stepper button { border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-size: 24px; font-weight: 600; color: var(--accent); }
.stepper input { text-align: center; font-size: 24px; font-weight: 700; }
.sticky-cta { position: sticky; bottom: 0; padding: 12px 0 calc(8px + var(--safe-b)); background: linear-gradient(transparent, var(--panel) 30%); margin-top: 12px; }

.fgrid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
#pctBox, #gramFields { margin-bottom: 10px; }
form label + #pctBox { margin-top: 0; }
