:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --card-2: #eef1f5;
  --line: #e6eaf0;
  --text: #232a33;
  --hint: #939dab;
  --accent: #34b27b;
  --accent-2: #2aa06d;
  --on-accent: #ffffff;
  --protein: #5b8def;
  --carbs: #e9a23b;
  --fat: #e87aa8;
  --danger: #e5564b;
  --shadow: 0 1px 3px rgba(20,40,60,0.05);
  --radius: 16px;
  --tabbar-h: 68px;
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent;
  /* snappier taps: no 300ms delay, no accidental double-tap zoom */
  touch-action: manipulation; }

/* hidden must always win over flex/block display rules below */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body { background: var(--bg); color: var(--text); min-height: 100vh; -webkit-font-smoothing: antialiased;
  /* stop rubber-band / pull-to-refresh bounce that looks like "jumping" */
  overscroll-behavior-y: none; }
body.splash-active { overflow: hidden; }
/* when a sheet/overlay is open, freeze the page behind it */
body.no-scroll { overflow: hidden; }

#app { max-width: 520px; margin: 0 auto; padding: 0 14px calc(var(--tabbar-h) + 26px); }

/* opacity-only fade — no vertical shift, so nothing visibly "jumps" on tab switch */
.screen { animation: none; }

h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; }
h2 { font-size: 15px; font-weight: 700; }
.muted { color: var(--hint); font-size: 13px; }

/* ---------- Icons ---------- */
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.xl { width: 40px; height: 40px; stroke-width: 1.7; }
.icon.flame { stroke: var(--accent); width: 24px; height: 24px; }

/* ---------- Header ---------- */
.hero-top { display: flex; justify-content: space-between; align-items: center; padding: 16px 2px 12px; }
.greeting { color: var(--hint); font-size: 13px; font-weight: 600; }
.hero-title { font-size: 23px; font-weight: 800; letter-spacing: -0.5px; margin-top: 2px; }
.page-head { padding: 18px 2px 12px; }
.page-head.row { display: flex; align-items: center; justify-content: space-between; }
.add-btn { display: flex; align-items: center; gap: 5px; border: none; cursor: pointer;
  background: var(--accent); color: var(--on-accent); font-family: inherit; font-weight: 800;
  font-size: 13px; padding: 9px 14px; border-radius: 999px; box-shadow: 0 4px 12px rgba(52,178,123,.28); }
.add-btn .icon { width: 16px; height: 16px; stroke-width: 2.4; }
.add-home { margin: 4px 0 8px; }

.chip { display: flex; align-items: center; gap: 5px; cursor: pointer;
  background: rgba(52,178,123,.12); color: var(--accent); font-weight: 800; font-size: 14px;
  padding: 8px 13px; border-radius: 999px; border: 1px solid rgba(52,178,123,.22); }
.chip .icon { width: 16px; height: 16px; stroke-width: 2.2; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 15px;
  margin-bottom: 11px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.center { text-align: center; }
.card-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-title .icon { width: 18px; height: 18px; color: var(--accent); }

/* ---------- Summary ring ---------- */
.summary-card { padding-top: 18px; }
.ring-wrap { position: relative; width: 180px; height: 180px; margin: 0 auto 4px; }
.ring { width: 100%; height: 100%; }
.ring-bg { fill: none; stroke: rgba(20,40,60,0.07); stroke-width: 13; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 13; stroke-linecap: round;
  stroke-dasharray: 578; stroke-dashoffset: 578; transition: stroke-dashoffset .9s cubic-bezier(.2,.8,.2,1); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; }
.ring-big { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.ring-unit { color: var(--hint); font-size: 12px; font-weight: 600; margin-top: 3px; }

.ring-legend { display: flex; justify-content: center; gap: 24px; margin: 6px 0 14px; }
.leg { display: flex; align-items: center; gap: 7px; }
.leg-dot { width: 9px; height: 9px; border-radius: 50%; }
.leg-dot.goal { background: #cfd6df; }
.leg-dot.eaten { background: var(--accent); }
.leg b { display: block; font-size: 15px; font-weight: 800; line-height: 1.1; }
.leg span { color: var(--hint); font-size: 11px; }

/* ---------- Macro bars ---------- */
.macro-bars { display: flex; flex-direction: column; gap: 11px; padding-top: 12px;
  border-top: 1px solid var(--line); }
.macro-bars-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 2px; }
.macro-bars-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.macro-bars-title > span:first-child { font-size: 12px; font-weight: 800; color: var(--text); }
.macro-mode-badge { font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 999px;
  background: rgba(77,142,247,.12); color: #3f6fd6; }
.macro-edit-btn { display: inline-flex; align-items: center; gap: 5px; border: none; background: transparent;
  color: var(--accent-2); font-family: inherit; font-size: 11px; font-weight: 800; cursor: pointer;
  padding: 4px 2px; flex: none; }
.macro-edit-btn .icon { width: 14px; height: 14px; }
.macro-kcal-hint { text-align: center; margin-top: 4px; }
.macro-head { display: flex; justify-content: space-between; font-size: 12px; font-weight: 600;
  margin-bottom: 5px; color: var(--hint); }
.bar { height: 7px; border-radius: 999px; background: rgba(20,40,60,0.06); overflow: hidden; }
.fill { display: block; height: 100%; width: 0; border-radius: 999px; transition: width .8s cubic-bezier(.2,.8,.2,1); }
.fill.p { background: var(--protein); }
.fill.c { background: var(--carbs); }
.fill.f { background: var(--fat); }

/* ---------- Meal sections ---------- */
.meal { margin-bottom: 6px; }
.meal-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 2px 8px; }
.meal-title { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 15px; }
.meal-ico { width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center;
  justify-content: center; background: var(--card-2); color: var(--hint); }
.meal-ico .icon { width: 16px; height: 16px; }
.meal-kcal { color: var(--hint); font-weight: 700; font-size: 12px; }
.meal-kcal b { color: var(--accent); }

.entry-list { display: flex; flex-direction: column; gap: 8px; }
.entry { display: flex; align-items: center; gap: 11px; background: var(--card); border-radius: 13px;
  padding: 11px 12px; border: 1px solid var(--line); box-shadow: var(--shadow); }
.e-ico { width: 40px; height: 40px; flex: none; border-radius: 11px; display: flex;
  align-items: center; justify-content: center; overflow: hidden; }
.e-img { width: 40px; height: 40px; flex: none; border-radius: 11px; object-fit: cover;
  background: var(--card-2); border: 1px solid var(--line); }
.e-ico .icon { width: 20px; height: 20px; }
.e-body { flex: 1; min-width: 0; }
.e-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.e-macros { color: var(--hint); font-size: 11px; margin-top: 2px; }
.e-kcal { font-weight: 800; font-size: 14px; white-space: nowrap; }
.e-kcal small { color: var(--hint); font-weight: 600; font-size: 10px; display: block; text-align: right; }
.e-del { border: none; background: transparent; color: #c2cad4; cursor: pointer;
  padding: 6px 2px 6px 4px; display: flex; }
.e-del .icon { width: 16px; height: 16px; }

.empty-meal { color: var(--hint); font-size: 12px; padding: 11px 12px; border: 1px dashed var(--line);
  border-radius: 12px; text-align: center; }
button.empty-meal-tap {
  width: 100%; font-family: inherit; cursor: pointer;
  color: var(--accent-2); font-weight: 800; background: rgba(52,178,123,.05);
  border-color: rgba(52,178,123,.25); transition: background .15s;
}
button.empty-meal-tap:active { background: rgba(52,178,123,.12); }

/* category colors */
.c-veg { background: rgba(52,178,123,.13); color: #2aa06d; }
.c-meat { background: rgba(229,86,75,.12); color: #e0584d; }
.c-fish { background: rgba(91,141,239,.13); color: #5b8def; }
.c-fruit { background: rgba(232,122,168,.13); color: #e07aa6; }
.c-drink { background: rgba(45,191,180,.13); color: #21ab9f; }
.c-sweet { background: rgba(233,162,59,.14); color: #d68f24; }
.c-bowl { background: rgba(150,110,230,.13); color: #8a63d6; }
.c-def { background: var(--card-2); color: var(--hint); }

.empty-state { text-align: center; color: var(--hint); padding: 36px 16px; }
.empty-state .icon.xl { color: #c2cad4; margin-bottom: 10px; }

/* ---------- Buttons ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; border: none;
  border-radius: 13px; padding: 13px 16px; font-weight: 800; font-size: 14px; cursor: pointer;
  font-family: inherit; transition: transform .08s ease, opacity .2s; }
.btn .icon { width: 18px; height: 18px; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 12px rgba(52,178,123,.28); }
.btn.ghost { flex: 1; background: var(--card-2); color: var(--text); }
.btn.full { width: 100%; margin-top: 4px; }

/* ---------- Scan / preview ---------- */
.scan-card .actions { display: flex; gap: 9px; margin-bottom: 9px; }
.scan-pane .scan-card { margin-top: 0; }
.scan-pane { padding-bottom: 80px; }
.bc-preview { min-height: 70px; }

/* Bottom mode switcher — fixed above tab bar, outside animated sections */
.scan-mode-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  width: calc(100% - 28px); max-width: 492px;
  bottom: calc(var(--tabbar-h) + 10px + env(safe-area-inset-bottom));
  z-index: 45; display: flex; gap: 8px; padding: 5px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 4px 20px rgba(20,40,60,0.12);
}
.scan-mode-btn {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; border: none; background: transparent; color: var(--hint);
  cursor: pointer; font-family: inherit; font-weight: 700; font-size: 11px;
  padding: 10px 6px; border-radius: 12px; transition: background .18s, color .18s;
  -webkit-appearance: none; appearance: none; box-sizing: border-box;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.scan-mode-btn .icon { width: 22px; height: 22px; flex: none; }
.scan-mode-btn span { line-height: 1.1; }
.scan-mode-btn.active {
  background: rgba(52,178,123,.12); color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(52,178,123,.22);
}
.preview { width: 100%; aspect-ratio: 8/3; border-radius: 10px; overflow: hidden; display: flex;
  align-items: center; justify-content: center; background: var(--card-2);
  border: 2px dashed #d5dce4; margin-bottom: 8px; }
.preview.empty .preview-hint { text-align: center; color: var(--hint); padding: 0 12px; }
.scan-card .preview-hint .icon.xl { width: 28px; height: 28px; margin-bottom: 4px; stroke-width: 1.8; }
.scan-card .preview-hint p { font-size: 12px; line-height: 1.35; margin: 0; font-weight: 600; }
.preview-hint .icon { margin-bottom: 8px; }
#preview-img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Result ---------- */
.result-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.result-icon { width: 46px; height: 46px; border-radius: 13px; flex: none; display: flex;
  align-items: center; justify-content: center; background: rgba(52,178,123,.13); color: var(--accent); }
.result-icon .icon { width: 24px; height: 24px; }
.result-title h2 { font-size: 18px; font-weight: 800; }
.badge { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 800; padding: 3px 9px;
  border-radius: 999px; background: rgba(91,141,239,.14); color: var(--protein); }
.result-kcal { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.result-kcal b { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.result-kcal span { color: var(--hint); font-weight: 700; }
.result-macros { display: flex; gap: 9px; margin-bottom: 12px; }
.rm { flex: 1; min-width: 0; background: var(--card-2); border-radius: 12px; padding: 11px; text-align: center; }
.rm b { display: block; font-size: 18px; font-weight: 800; }
.rm span { color: var(--hint); font-size: 11px; }
.items { list-style: none; margin-bottom: 10px; }
.items li { display: flex; align-items: center; gap: 8px; padding: 10px 0;
  border-bottom: 1px solid var(--line); font-size: 13px; }
.items li:last-child { border-bottom: none; }
.items .it-main { flex: 1; min-width: 0; }
.items .it-name { font-weight: 700; display: block; margin-bottom: 3px; }
.items .it-src { font-size: 10px; font-weight: 800; padding: 2px 6px; border-radius: 6px;
  display: inline-block; margin-top: 2px; }
.items .it-src.src-ai { background: rgba(239,68,68,.1); color: #dc2626; }
.items .it-src.src-base { background: rgba(52,178,123,.12); color: var(--accent-2); }
.items .it-src.src-off { background: rgba(59,130,246,.12); color: #2563eb; }
.items .it-src.src-you { background: rgba(168,85,247,.12); color: #7c3aed; }
.items .it-g { width: 52px; text-align: center; padding: 8px 4px; flex-shrink: 0; }
.items .it-cal { color: var(--accent); font-weight: 800; white-space: nowrap; min-width: 52px; text-align: right; flex-shrink: 0; }
.items-head {
  display: flex; align-items: center; gap: 6px;
  padding: 0 0 4px; margin-bottom: 2px;
  font-size: 10px; font-weight: 800; color: var(--hint); text-transform: uppercase; letter-spacing: .03em;
}
.items-head .ih-name { flex: 1; min-width: 0; }
.items-head .ih-g { width: 52px; text-align: center; flex-shrink: 0; }
.items-head .ih-k { min-width: 52px; text-align: right; flex-shrink: 0; }
.portion-total { margin-top: 10px; }
.portion-total .field-label { margin-bottom: 6px; }
.tip { background: rgba(52,178,123,.1); color: var(--accent-2); padding: 12px; border-radius: 12px;
  font-size: 13px; margin-bottom: 10px; line-height: 1.45; }
.result-note { display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--accent); font-weight: 700; font-size: 12px; margin-bottom: 10px; }
.result-note .icon { width: 15px; height: 15px; }

/* ---------- Scan result (compact) ---------- */
.scan-pane.has-result .scan-card .preview {
  aspect-ratio: 16/9; max-height: 55px; margin-bottom: 6px; border-radius: 8px;
}
.scan-pane.has-result .scan-card .actions,
.scan-pane.has-result .scan-card #analyze-btn,
.scan-pane.has-result .scan-card .scan-tip-line,
.scan-pane.has-result .scan-card label[for="scan-hint"],
.scan-pane.has-result .scan-card #scan-hint { display: none; }
.scan-pane.has-result .scan-card { padding-bottom: 10px; margin-bottom: 8px; }

.scan-result { padding: 12px 14px; margin-top: 0; }
.sr-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sr-icon { width: 36px; height: 36px; border-radius: 10px; flex: none; display: flex;
  align-items: center; justify-content: center; background: rgba(52,178,123,.13); color: var(--accent); }
.sr-icon .icon { width: 18px; height: 18px; }
.sr-title h2 { font-size: 15px; font-weight: 800; line-height: 1.25; }
.badge.sm { font-size: 10px; padding: 2px 7px; margin-top: 2px; }
.sr-stats {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card-2); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px;
}
.sr-kcal { display: flex; align-items: baseline; gap: 4px; min-width: 0; }
.sr-kcal b { font-size: 24px; font-weight: 800; letter-spacing: -.5px; color: var(--accent-2); }
.sr-kcal > span { color: var(--hint); font-size: 12px; font-weight: 700; }
.sr-kcal .kcal-range { font-size: 10px; font-weight: 700; color: var(--hint); margin-left: 2px; }
.sr-macros { display: flex; gap: 8px; flex-shrink: 0; font-size: 12px; color: var(--hint); font-weight: 700; }
.sr-macros b { color: var(--text); font-size: 14px; }

.portion-compact { margin-bottom: 8px; }
.portion-compact .portion-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.portion-compact .portion-lbl { margin: 0; flex-shrink: 0; font-size: 11px; }
.portion-compact .portion-btns { flex: 1; min-width: 0; }
.portion-compact .portion-b { padding: 7px 4px; font-size: 12px; border-radius: 8px; }
.portion-compact .portion-total { display: flex; align-items: center; gap: 8px; margin-top: 0; }
.portion-compact .portion-total .field-label { margin: 0; flex-shrink: 0; font-size: 11px; }
.portion-compact .portion-total .text-input { flex: 1; min-width: 0; max-width: 100px; margin-left: auto; }

.scan-view-toggle.compact { margin: 8px 0 6px; padding: 3px; border-radius: 10px; }
.scan-view-toggle.compact .svt { padding: 6px 8px; font-size: 12px; border-radius: 7px; }

.scan-result .step-hint.sm { font-size: 11px; margin: 0 0 6px; line-height: 1.35; }

#scan-detail-block .items-head,
#scan-detail-block .items li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px 58px;
  column-gap: 8px;
  align-items: center;
}
#scan-detail-block .items li {
  align-items: start;
  padding: 8px 0;
  gap: 0;
}
#scan-detail-block .items-head {
  padding-bottom: 4px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--line);
}
#scan-detail-block .it-main { min-width: 0; }
#scan-detail-block .it-name {
  font-size: 12px;
  line-height: 1.3;
  word-break: break-word;
}
#scan-detail-block .it-src { margin-top: 3px; }
#scan-detail-block .it-g.text-input.mini {
  width: 100%;
  min-width: 0;
  padding: 6px 4px;
  font-size: 14px;
  box-sizing: border-box;
}
#scan-detail-block .it-cal {
  font-size: 12px;
  font-weight: 800;
  text-align: right;
  min-width: 0;
  line-height: 1.25;
  padding-top: 7px;
}
#scan-detail-block .items-head .ih-g { width: auto; text-align: center; }
#scan-detail-block .items-head .ih-k { min-width: 0; text-align: right; }

.items-compact li { padding: 7px 0; font-size: 12px; }
.tip-compact { padding: 8px 10px; font-size: 12px; margin-bottom: 8px; border-radius: 10px; line-height: 1.35; }

.sr-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.scan-added-note {
  text-align: center; color: var(--accent); font-size: 12px; font-weight: 700;
  margin: 0; padding: 6px 8px; background: rgba(52,178,123,.1); border-radius: 9px;
}
.btn-sm { padding: 10px 14px; font-size: 13px; }

/* ---------- Diary ---------- */
.day-block { margin-bottom: 18px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0 2px 9px; }
.day-head .d-date { font-weight: 800; font-size: 15px; }
.day-head .d-total { color: var(--accent); font-weight: 800; font-size: 13px; }
.day-head .d-total span { color: var(--hint); font-weight: 600; }

/* ---------- Profile ---------- */
.profile-row { display: flex; align-items: center; gap: 13px; }
.avatar { width: 50px; height: 50px; border-radius: 14px; flex: none; display: flex;
  align-items: center; justify-content: center; color: var(--accent); background: rgba(52,178,123,.13); }
.avatar .icon { width: 24px; height: 24px; }
.profile-name { font-weight: 800; font-size: 16px; }

/* Profile form */
.field-label { display: block; color: var(--hint); font-size: 12px; font-weight: 700; margin: 13px 2px 7px; }
.field-label:first-of-type { margin-top: 2px; }

.segmented { display: flex; gap: 5px; background: var(--card-2); border-radius: 12px; padding: 4px; }
.seg { flex: 1; min-width: 0; border: none; background: transparent; color: var(--hint); cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 13px; padding: 10px 6px; border-radius: 9px;
  transition: all .18s; }
.seg.active { background: var(--accent); color: var(--on-accent); box-shadow: 0 2px 6px rgba(52,178,123,.3); }

.field-grid { display: flex; gap: 10px; }
.field-grid .num-field { flex: 1; min-width: 0; }
.num-row { display: flex; align-items: center; gap: 5px; background: var(--card-2); border-radius: 12px; padding: 5px; }
.num-step { width: 36px; height: 36px; flex: none; border: none; border-radius: 9px; background: var(--card);
  color: var(--text); cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow); }
.num-step .icon { width: 16px; height: 16px; }
.num-step:active { transform: scale(.92); }
.num-input { flex: 1; width: 100%; min-width: 0; background: transparent; border: none; outline: none;
  color: var(--text); font-family: inherit; font-weight: 800; font-size: 17px; text-align: center; }
.num-input::-webkit-outer-spin-button, .num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input[type=number] { -moz-appearance: textfield; }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-opt { border: 1px solid var(--line); background: var(--card); color: var(--hint); cursor: pointer;
  font-family: inherit; font-weight: 700; font-size: 12px; padding: 8px 12px; border-radius: 999px; transition: all .18s; }
.chip-opt.active { background: rgba(52,178,123,.13); color: var(--accent-2); border-color: rgba(52,178,123,.4); }

.reco { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 8px;
  padding: 13px 15px; border-radius: 12px; background: rgba(52,178,123,.1); }
.reco span { color: var(--hint); font-size: 12px; font-weight: 700; }
.reco b { font-size: 17px; font-weight: 800; color: var(--accent-2); }
.reco-macros {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px;
}
.reco-macros span {
  flex: 1; min-width: 72px; text-align: center; font-size: 11px; font-weight: 700;
  color: var(--hint); padding: 8px 6px; border-radius: 10px; background: var(--card-2);
}
.reco-macros b { display: block; font-size: 15px; font-weight: 800; margin-top: 2px; }
.reco-macros .rm-p b { color: var(--protein); }
.reco-macros .rm-c b { color: var(--carbs); }
.reco-macros .rm-f b { color: var(--fat); }
.reco-hint {
  font-size: 11px; font-weight: 600; color: var(--hint); line-height: 1.45;
  margin-bottom: 12px;
}
.macro-goals-hint { color: var(--accent-2); font-weight: 700; }

.two-col { display: flex; gap: 12px; }
.two-col > div { flex: 1; min-width: 0; }
.two-col .card-title { margin-bottom: 10px; }
.mini-btn { margin-top: 8px; padding: 10px; font-size: 13px; }
.goal-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.step { width: 48px; height: 48px; border-radius: 13px; border: none; cursor: pointer; background: var(--card-2);
  color: var(--text); display: flex; align-items: center; justify-content: center; }
.step:active { transform: scale(.95); }
.goal-value { flex: 1; min-width: 0; text-align: center; }
.goal-value b { display: block; font-size: 27px; font-weight: 800; }
.goal-value span { color: var(--hint); font-size: 12px; }

/* ---------- Stats chart ---------- */
.chart { display: flex; align-items: flex-end; justify-content: space-between; gap: 7px;
  height: 150px; padding: 6px 2px 0; }
.chart-col { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px;
  height: 100%; justify-content: flex-end; }
.chart-val { font-size: 9px; font-weight: 700; color: var(--hint); }
.chart-bar-wrap { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.chart-bar { width: 100%; border-radius: 7px 7px 3px 3px; background: var(--accent); min-height: 4px;
  transition: height .7s cubic-bezier(.2,.8,.2,1); }
.chart-bar.over { background: var(--danger); }
.chart-bar.empty { background: var(--card-2); }
.chart-day { font-size: 10px; font-weight: 700; color: var(--hint); }
.stats-grid { display: flex; gap: 9px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.stat-box { flex: 1; min-width: 0; text-align: center; }
.stat-box b { display: block; font-size: 20px; font-weight: 800; }
.stat-box span { color: var(--hint); font-size: 10px; }

/* ---------- Packs ---------- */
.packs { display: flex; flex-direction: column; gap: 9px; margin-top: 10px; }
.pack { display: flex; align-items: center; justify-content: space-between; cursor: pointer;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 13px; padding: 13px 15px; }
.pack:active { transform: scale(.98); }
.pack b { font-size: 15px; font-weight: 800; }
.pack .price { display: flex; align-items: center; gap: 5px; background: var(--accent); color: var(--on-accent);
  padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 13px; }
.pack .price .icon { width: 14px; height: 14px; stroke-width: 2.2; }

/* ---------- Hero chips / streak / banner ---------- */
.hero-chips { display: flex; align-items: center; gap: 7px; }
.chip.streak { background: rgba(233,162,59,.14); color: #d6891f; border-color: rgba(233,162,59,.28); }
.banner { display: flex; align-items: center; gap: 10px; width: 100%; cursor: pointer; text-align: left;
  background: rgba(91,141,239,.1); border: 1px solid rgba(91,141,239,.22); color: #3f6fd6;
  border-radius: 13px; padding: 12px 14px; margin-bottom: 11px; font-family: inherit;
  font-weight: 700; font-size: 13px; }
.banner .icon { width: 19px; height: 19px; flex: none; }
.banner span { flex: 1; }
.banner .chev { width: 16px; height: 16px; opacity: .6; }

/* ---------- Water card ---------- */
.water-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.water-ttl { margin-bottom: 0; }
.water-ttl .icon { color: #4aa3e8; }
.water-amount b { font-size: 17px; font-weight: 800; }
.water-amount span { color: var(--hint); font-size: 12px; font-weight: 600; }
.water-bar { height: 9px; margin-bottom: 12px; }
.fill.water { background: #4aa3e8; }
.water-actions { display: flex; gap: 8px; }
.water-btn { flex: 1; border: none; cursor: pointer; font-family: inherit; font-weight: 800; font-size: 14px;
  padding: 11px; border-radius: 11px; background: rgba(74,163,232,.13); color: #2e86cf; transition: transform .08s; }
.water-btn.ghost { background: var(--card-2); color: var(--hint); }
.water-btn:active { transform: scale(.96); }

/* ---------- Weight chart (sparkline) ---------- */
.chart.line { height: 120px; padding: 4px 0; }
.weight-meta { display: flex; gap: 10px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.weight-meta > div { flex: 1; text-align: center; }
.weight-meta b { display: block; font-size: 19px; font-weight: 800; }
.weight-meta span { color: var(--hint); font-size: 11px; }

/* ---------- Bottom sheet (edit) ---------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(20,30,45,0.4);
  display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease;
  overscroll-behavior: contain; }
.overlay.cam { z-index: 70; align-items: center; background: rgba(10,15,25,.85); }
.overlay.confirm { z-index: 90; align-items: center; background: rgba(20,30,45,0.45); }
.confirm-box {
  width: calc(100% - 32px); max-width: 340px; background: var(--bg);
  border-radius: 18px; padding: 20px 18px 16px; animation: fade .18s ease;
  box-shadow: 0 12px 40px rgba(20,30,45,.18);
}
.confirm-box h3 { font-size: 18px; font-weight: 800; margin-bottom: 8px; }
.confirm-box p { color: var(--hint); font-size: 14px; line-height: 1.45; margin-bottom: 18px; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; margin: 0; }
.btn.confirm-danger { background: #ef4444; color: #fff; box-shadow: 0 4px 12px rgba(239,68,68,.25); }

/* ---------- Overage warning modal ---------- */
.overlay.overage { z-index: 92; align-items: center; padding: 16px; }
.overage-box {
  width: 100%; max-width: 340px; background: var(--card);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 16px 48px rgba(20,30,45,.22);
  animation: ov-pop .22s cubic-bezier(.2,.8,.2,1);
}
@keyframes ov-pop {
  from { opacity: 0; transform: scale(.94) translateY(8px); }
  to { opacity: 1; transform: none; }
}
.ov-head {
  padding: 18px 18px 14px; text-align: center;
  background: linear-gradient(165deg, rgba(233,162,59,.14) 0%, rgba(229,86,75,.08) 100%);
  border-bottom: 1px solid rgba(233,162,59,.18);
}
.ov-icon-wrap {
  width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 14px;
  display: grid; place-items: center;
  background: rgba(233,162,59,.18); color: #d97706;
}
.ov-icon-wrap .icon { width: 22px; height: 22px; }
.ov-title { font-size: 17px; font-weight: 800; margin: 0 0 4px; color: var(--text); }
.ov-lead { font-size: 12px; font-weight: 600; color: var(--hint); margin: 0; line-height: 1.4; }
.ov-list { padding: 14px 16px 6px; display: flex; flex-direction: column; gap: 11px; }
.ov-row {
  padding: 10px 11px; border-radius: 12px; background: var(--bg);
  border: 1px solid var(--line);
}
.ov-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.ov-row-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; }
.ov-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ov-row-val { font-size: 11px; font-weight: 700; color: var(--hint); white-space: nowrap; }
.ov-row-val b { color: var(--text); font-weight: 800; }
.ov-row-val .ov-plus { color: #dc2626; font-weight: 800; margin-left: 4px; }
.ov-bar { height: 7px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.ov-bar-fill { height: 100%; border-radius: 999px; min-width: 4px; transition: width .3s ease; }
.ov-row.kcal .ov-dot, .ov-row.kcal .ov-bar-fill { background: var(--accent); }
.ov-row.protein .ov-dot, .ov-row.protein .ov-bar-fill { background: var(--protein); }
.ov-row.carbs .ov-dot, .ov-row.carbs .ov-bar-fill { background: var(--carbs); }
.ov-row.fat .ov-dot, .ov-row.fat .ov-bar-fill { background: var(--fat); }
.ov-foot {
  padding: 4px 18px 14px; text-align: center;
  font-size: 13px; font-weight: 700; color: var(--text); margin: 0;
}
.ov-actions { display: flex; gap: 9px; padding: 0 16px 16px; }
.ov-actions .btn { flex: 1; margin: 0; font-size: 13px; padding: 12px 10px; }
.ov-actions .btn.primary { box-shadow: 0 4px 14px rgba(52,178,123,.28); }

.sheet { width: 100%; max-width: 520px; background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); animation: slideup .26s cubic-bezier(.2,.8,.2,1);
  /* scroll inside the sheet (not the page) so tall content + keyboard never clips the top */
  max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch; }
@keyframes slideup { from { transform: translateY(100%);} to { transform: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sheet-head h2 { font-size: 18px; font-weight: 800; }
.icon-btn { border: none; background: var(--card-2); color: var(--hint); cursor: pointer;
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.text-input { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; font-family: inherit; font-weight: 700; font-size: 16px; color: var(--text); outline: none; }
.text-input:focus { border-color: var(--accent); }
.text-input.mini { padding: 11px; text-align: center; font-size: 16px; }
.ed-row2 { display: flex; gap: 9px; }
.ed-row2 > div { flex: 1; min-width: 0; }
.ed-macros { display: flex; gap: 9px; margin-bottom: 6px; }
.ed-macros > div { flex: 1; min-width: 0; }
.ed-macros .field-label, .ed-row2 .field-label { margin-top: 10px; }
.sheet-hint { color: var(--hint); font-size: 12px; margin: 8px 2px 12px; line-height: 1.4; }
.step-hint {
  background: rgba(52,178,123,.08); color: var(--accent-2); font-size: 12px; font-weight: 700;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; line-height: 1.45;
}
.entry-preview {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid rgba(52,178,123,.25); border-radius: 12px;
  padding: 11px 13px; margin: 4px 0 10px;
}
.entry-preview .ep-img {
  width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none;
  background: var(--card-2);
}
.entry-preview .ep-body { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.entry-preview .ep-label { color: var(--hint); font-size: 12px; font-weight: 700; }
.entry-preview #ep-kcal { color: var(--accent-2); font-size: 15px; font-weight: 800; }
.entry-preview .ep-macros { color: var(--hint); font-size: 12px; font-weight: 600; }
.entry-preview .ep-macros b { color: var(--text); }
.rc-status { min-height: 18px; margin-top: 4px; font-weight: 700; color: var(--accent-2); }

/* ---------- Micros strip (home) ---------- */
.micro-strip { display: flex; gap: 9px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.micro { flex: 1; min-width: 0; text-align: center; }
.micro b { display: block; font-size: 15px; font-weight: 800; }
.micro span { color: var(--hint); font-size: 10px; }

/* ---------- Home quick actions ---------- */
.home-actions { display: flex; gap: 9px; margin: 4px 0 8px; }
.home-actions .btn { flex: 1; }
.home-actions .btn.home-add { flex: 1.4; box-shadow: 0 6px 18px rgba(52,178,123,.32); }

/* ---------- Day insight ---------- */
.day-insight {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; margin-bottom: 12px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(52,178,123,.1) 0%, rgba(91,141,239,.08) 100%);
  border: 1px solid rgba(52,178,123,.18);
  animation: fade .25s ease;
}
.day-insight.warn {
  background: linear-gradient(135deg, rgba(239,68,68,.08) 0%, rgba(233,162,59,.1) 100%);
  border-color: rgba(239,68,68,.15);
}
.day-insight.neutral {
  background: var(--card);
  border-color: var(--line);
}
.day-insight-ico { font-size: 22px; line-height: 1; flex-shrink: 0; }
.day-insight p { margin: 0; font-size: 13px; font-weight: 700; line-height: 1.45; color: var(--text); }

/* ---------- Recent meals ---------- */
.recent-block { padding-bottom: 14px; }
.recent-head { margin-bottom: 10px; }
.recent-sub { margin-left: auto; color: var(--hint); font-size: 11px; font-weight: 700; }
.recent-row {
  display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
}
.recent-row::-webkit-scrollbar { display: none; }
.recent-chip {
  flex: 0 0 auto; scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-width: 118px; max-width: 148px; padding: 12px 13px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); cursor: pointer; text-align: left;
  font-family: inherit; transition: transform .1s, border-color .15s, box-shadow .15s;
}
.recent-chip:active { transform: scale(.97); }
.recent-chip:hover { border-color: rgba(52,178,123,.35); box-shadow: 0 4px 14px rgba(52,178,123,.12); }
.recent-chip .rc-name {
  font-size: 13px; font-weight: 800; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.recent-chip .rc-kcal { font-size: 15px; font-weight: 800; color: var(--accent-2); }
.recent-chip .rc-meta { font-size: 10px; font-weight: 700; color: var(--hint); }

/* ---------- Add sheet picks ---------- */
.add-picks { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.add-pick {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 16px;
  background: var(--card); cursor: pointer; text-align: left; font-family: inherit;
  transition: border-color .15s, background .15s, transform .08s;
}
.add-pick:active { transform: scale(.99); }
.add-pick.active { border-color: rgba(52,178,123,.45); background: rgba(52,178,123,.06); }
.add-pick-ico {
  width: 44px; height: 44px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.add-pick-ico .icon { width: 22px; height: 22px; }
.add-pick-ico.photo { background: rgba(91,141,239,.14); color: #5b8def; }
.add-pick-ico.barcode { background: rgba(52,178,123,.14); color: var(--accent-2); }
.add-pick-ico.search { background: rgba(233,162,59,.14); color: #d68f24; }
.add-pick-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.add-pick-body b { font-size: 14px; font-weight: 800; color: var(--text); }
.add-pick-body small { font-size: 11px; font-weight: 600; color: var(--hint); }
.add-pick .chev { width: 16px; height: 16px; color: #c2cad4; flex-shrink: 0; }
.add-pane { margin-bottom: 8px; }
.add-more { margin: 8px 0 12px; }
.add-more summary {
  cursor: pointer; font-size: 13px; font-weight: 800; color: var(--hint);
  padding: 10px 4px; list-style: none;
}
.add-more summary::-webkit-details-marker { display: none; }
.add-more-body { padding-top: 4px; }

/* ---------- Add sheet compact mode ---------- */
.sheet-add {
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
}
.sheet-add .sheet-head { margin-bottom: 4px; }
.sheet-add .sheet-head h2 { font-size: 16px; }
.sheet-add .icon-btn { width: 32px; height: 32px; border-radius: 9px; }
.sheet-add .add-picks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.sheet-add .add-pick {
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 9px 5px;
  border-radius: 12px;
  text-align: center;
}
.sheet-add .add-pick .chev { display: none; }
.sheet-add .add-pick-ico { width: 34px; height: 34px; border-radius: 10px; }
.sheet-add .add-pick-ico .icon { width: 18px; height: 18px; }
.sheet-add .add-pick-body { align-items: center; gap: 1px; }
.sheet-add .add-pick-body b { font-size: 11px; line-height: 1.2; }
.sheet-add .add-pick-body small { font-size: 9px; line-height: 1.2; }
.sheet-add .add-pane { margin-bottom: 6px; }
.sheet-add .add-pane > .text-input { padding: 10px 12px; font-size: 15px; border-radius: 10px; }
.sheet-add .search-results { max-height: 160px; margin-top: 6px; gap: 3px; }
.sheet-add .sr-item { padding: 7px 8px; border-radius: 9px; gap: 8px; }
.sheet-add .sr-img, .sheet-add .sr-img-ph { width: 34px; height: 34px; border-radius: 8px; }
.sheet-add .sr-name { font-size: 12px; }
.sheet-add .quick-block { margin-top: 8px; padding: 6px 7px 7px; border-radius: 10px; }
.sheet-add .quick-block.recipes { margin-top: 6px; }
.sheet-add .quick-head { margin-bottom: 5px; }
.sheet-add .quick-build-btn { margin-top: 6px; padding: 9px 12px; font-size: 12px; }
.sheet-add .add-more { margin: 6px 0 8px; }
.sheet-add .add-more summary { font-size: 12px; padding: 7px 2px; }
.sheet-add .text-input.area { min-height: 56px; padding: 10px 12px; font-size: 14px; }
.sheet-add .entry-preview { padding: 8px 10px; margin: 2px 0 8px; border-radius: 10px; gap: 8px; }
.sheet-add .entry-preview .ep-img { width: 36px; height: 36px; border-radius: 8px; }
.sheet-add .entry-preview #ep-kcal { font-size: 14px; }
.sheet-add .meal-banner { gap: 9px; padding: 9px 11px; margin: 4px 0 8px; border-radius: 11px; }
.sheet-add .meal-banner-ico { font-size: 20px; }
.sheet-add .meal-banner-text b { font-size: 14px; }
.sheet-add .meal-change { padding: 6px 10px; font-size: 11px; border-radius: 8px; }
.sheet-add .meal-chips { margin-bottom: 8px; }
.sheet-add .field-label { font-size: 11px; margin: 8px 2px 5px; }
.sheet-add .field-label:first-of-type { margin-top: 0; }
.sheet-add .ed-macros .field-label,
.sheet-add .ed-row2 .field-label { margin-top: 6px; margin-bottom: 4px; }
.sheet-add .text-input { padding: 10px 12px; font-size: 15px; border-radius: 10px; }
.sheet-add .text-input.mini { padding: 8px 6px; font-size: 14px; }
.sheet-add .ed-row2 { gap: 7px; }
.sheet-add .ed-macros { gap: 6px; margin-bottom: 4px; }
.sheet-add .micro-details { margin: 2px 0; }
.sheet-add .micro-details summary { font-size: 11px; padding: 6px 0; }
.sheet-add .sheet-hint { font-size: 11px; margin: 4px 2px 8px; }
.sheet-add .sheet-divider { margin: 8px 0; font-size: 10px; }
.sheet-add .sheet-actions { gap: 7px; margin-top: 4px; }
.sheet-add .sheet-actions .btn { padding: 11px 10px; font-size: 13px; }
.sheet-add #edit-fav .icon { width: 15px; height: 15px; }

/* ---------- Meal auto banner ---------- */
.meal-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; margin: 8px 0 12px;
  background: linear-gradient(135deg, rgba(52,178,123,.08), rgba(52,178,123,.03));
  border: 1px solid rgba(52,178,123,.2); border-radius: 14px;
}
.meal-banner-ico { font-size: 24px; line-height: 1; }
.meal-banner-text { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.meal-banner-label { font-size: 11px; font-weight: 700; color: var(--hint); }
.meal-banner-text b { font-size: 16px; font-weight: 800; color: var(--accent-2); }
.meal-change {
  border: none; background: #fff; color: var(--accent-2);
  font-family: inherit; font-size: 12px; font-weight: 800;
  padding: 8px 12px; border-radius: 10px; cursor: pointer;
  box-shadow: 0 1px 4px rgba(20,30,45,.06);
}
.meal-chips { margin-bottom: 12px; }

/* ---------- Scan view toggle ---------- */
.scan-view-toggle {
  display: flex; gap: 6px; margin: 14px 0 10px;
  padding: 4px; background: var(--card-2); border-radius: 12px;
}
.svt {
  flex: 1; border: none; background: transparent; color: var(--hint);
  font-family: inherit; font-size: 13px; font-weight: 800;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.svt.active {
  background: #fff; color: var(--text);
  box-shadow: 0 2px 8px rgba(20,30,45,.08);
}

/* ---------- Empty diary CTA ---------- */
.empty-diary { text-align: center; padding: 40px 20px; }
.empty-diary .icon.xl { color: #c2cad4; margin-bottom: 12px; }
.empty-diary h3 { font-size: 17px; font-weight: 800; margin: 0 0 6px; }
.empty-diary p { color: var(--hint); font-size: 13px; margin: 0 0 18px; line-height: 1.45; }
.empty-diary-actions { display: flex; flex-direction: column; gap: 8px; max-width: 280px; margin: 0 auto; }

/* ---------- Diary add bar ---------- */
.diary-add-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px);
  width: min(492px, calc(100% - 28px));
  z-index: 35;
}
#diary-list.has-entries { padding-bottom: 72px; }

.meal-add-more {
  width: 100%; margin-top: 4px; border: 1px dashed rgba(52,178,123,.35);
  background: rgba(52,178,123,.06); color: var(--accent-2); border-radius: 11px;
  padding: 10px 12px; font-family: inherit; font-size: 12px; font-weight: 800;
  cursor: pointer; touch-action: manipulation;
}
.meal-add-more:active { background: rgba(52,178,123,.14); }

/* ---------- Macro suggest (AI) ---------- */
.macro-suggest {
  background: linear-gradient(160deg, #fff 0%, rgba(91,141,239,.04) 100%);
  border: 1px solid rgba(91,141,239,.12);
}
.macro-suggest-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 10px;
}
.macro-ttl { margin: 0; flex: 1; min-width: 0; }
.macro-ai-badge {
  font-size: 10px; font-weight: 800; padding: 3px 7px; border-radius: 6px;
  background: rgba(91,141,239,.15); color: #5b8def; margin-left: 6px;
}
.macro-gaps {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
}
.macro-gap {
  font-size: 11px; font-weight: 800; padding: 5px 10px; border-radius: 999px;
  background: var(--card-2); color: var(--hint);
}
.macro-gap.need { background: rgba(52,178,123,.12); color: var(--accent-2); }
.macro-gap.ok { background: rgba(52,178,123,.08); color: var(--accent-2); }
.macro-gap.warn { background: rgba(239,68,68,.1); color: #dc2626; }
.macro-suggest-loading {
  color: var(--hint); font-size: 13px; font-weight: 700; margin: 4px 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.macro-suggest-loading::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(52,178,123,.25); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
.macro-suggest-lead {
  font-size: 13px; font-weight: 700; line-height: 1.45; color: var(--text);
  margin: 0 0 12px;
}
.macro-suggest-items { display: flex; flex-direction: column; gap: 8px; }
.macro-sug {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px; border-radius: 14px;
  background: #fff; border: 1px solid var(--line);
  transition: border-color .15s, box-shadow .15s;
}
.macro-sug:hover { border-color: rgba(52,178,123,.3); }
.macro-sug-ico {
  width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; background: var(--card-2);
}
.macro-sug-body { flex: 1; min-width: 0; }
.macro-sug-name { font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 2px; }
.macro-sug-meta { font-size: 11px; font-weight: 600; color: var(--hint); line-height: 1.35; }
.macro-sug-meta b { color: var(--accent-2); font-weight: 800; }
.macro-sug-add {
  border: none; background: var(--accent); color: var(--on-accent);
  font-family: inherit; font-size: 11px; font-weight: 800;
  padding: 9px 12px; border-radius: 10px; cursor: pointer; flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(52,178,123,.25);
}
.macro-sug-add:active { transform: scale(.96); }

/* ---------- Entry repeat button ---------- */
.e-repeat, .e-edit { border: none; background: transparent; color: #c2cad4; cursor: pointer;
  padding: 6px 2px; display: flex; }
.e-repeat .icon, .e-edit .icon { width: 16px; height: 16px; }
.e-edit { color: #aeb7c2; }

/* ---------- Portion control (scan result) ---------- */
.portion { margin-bottom: 12px; }
.portion-lbl { display: block; color: var(--hint); font-size: 12px; font-weight: 700; margin-bottom: 7px; }
.portion-btns { display: flex; gap: 6px; }
.portion-b { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--card); color: var(--hint);
  cursor: pointer; font-family: inherit; font-weight: 800; font-size: 14px; padding: 9px 0; border-radius: 10px;
  transition: all .16s; }
.portion-b.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent);
  box-shadow: 0 3px 8px rgba(52,178,123,.3); }

/* ---------- Quick-input tools (sheet) ---------- */
.seg-tabs { display: flex; gap: 5px; background: var(--card-2); border-radius: 12px; padding: 4px; margin-bottom: 10px; }
.seg-tab { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 5px;
  border: none; background: transparent; color: var(--hint); cursor: pointer; font-family: inherit;
  font-weight: 700; font-size: 12px; padding: 9px 4px; border-radius: 9px; transition: all .16s; }
.seg-tab .icon { width: 15px; height: 15px; }
.seg-tab.active { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.mode-pane { margin-bottom: 4px; }
.search-results { display: flex; flex-direction: column; gap: 4px; max-height: 240px; overflow-y: auto; margin-top: 8px; }
.sr-item { display: flex; align-items: center; gap: 10px; text-align: left;
  border: 1px solid var(--line); background: var(--card); border-radius: 11px; padding: 8px 10px; cursor: pointer;
  font-family: inherit; }
.sr-item:active { background: var(--card-2); }
.sr-img { width: 40px; height: 40px; border-radius: 9px; object-fit: cover; flex: none; background: var(--card-2); }
.sr-img-ph {
  display: grid; place-items: center; font-size: 16px; color: var(--hint);
  border: 1px solid var(--line);
}
.sr-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sr-name { font-weight: 700; font-size: 13px; color: var(--text); line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr-src { font-size: 10px; font-weight: 700; color: var(--hint); }
.sr-kcal { color: var(--hint); font-size: 11px; font-weight: 800; white-space: nowrap; text-align: right; flex: none; }
.sr-kcal span { display: block; font-size: 9px; font-weight: 700; opacity: 0.85; }
.search-empty { font-size: 12px; font-weight: 600; color: var(--hint); line-height: 1.45; padding: 8px 4px; }
.fav-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-content: flex-start; }

/* ---------- Quick blocks (избранное / мои блюда) ---------- */
.quick-block {
  margin-top: 10px;
  padding: 8px 9px 9px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.quick-block:empty { display: none; margin: 0; padding: 0; border: none; box-shadow: none; }
.quick-block.recipes { margin-top: 8px; }
.quick-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 7px; padding: 0 1px;
}
.quick-title { font-size: 11px; font-weight: 800; color: var(--text); letter-spacing: 0.02em; }
.quick-hint { font-size: 9px; font-weight: 700; color: var(--hint); white-space: nowrap; }
.quick-chips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}
.quick-build-btn { margin-top: 8px; padding: 11px 14px; font-size: 13px; }

.fav-chip {
  display: flex; align-items: stretch; width: 100%; min-width: 0;
  max-width: none;
  border: 1px solid rgba(52,178,123,.22); background: rgba(52,178,123,.07);
  color: var(--accent-2); border-radius: 9px;
  touch-action: manipulation; isolation: isolate;
  overflow: hidden;
}
.fav-chip-main {
  display: flex; align-items: center; gap: 4px; border: none; background: transparent;
  color: inherit; cursor: pointer; font-family: inherit; font-weight: 700; font-size: 10px;
  line-height: 1.15; padding: 5px 3px 5px 7px; touch-action: manipulation;
  min-width: 0; flex: 1 1 auto; overflow: hidden; text-align: left;
}
.fav-chip-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; flex: 1 1 auto;
}
.fav-chip-kcal {
  flex: none; font-size: 9px; font-weight: 800; line-height: 1;
  padding: 2px 5px; border-radius: 5px;
  background: rgba(255,255,255,.55); color: inherit;
}
.fav-chip-ico { width: 10px !important; height: 10px !important; flex: none; opacity: 0.8; }
.fav-del {
  border: none; border-left: 1px solid rgba(52,178,123,.16);
  background: rgba(255,255,255,.35); color: #94a3b3; cursor: pointer;
  width: 26px; min-height: 26px; padding: 0;
  display: flex; flex: none; align-items: center; justify-content: center;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
  position: relative; z-index: 3; flex-shrink: 0;
  -webkit-transform: translateZ(0); transform: translateZ(0);
}
.fav-del::after {
  content: ""; position: absolute; inset: -12px -10px -12px -4px;
}
.fav-del .icon { width: 11px; height: 11px; pointer-events: none; position: relative; z-index: 1; }
.fav-del:active { color: #ef4444; background: rgba(239,68,68,.1); }
.fav-label { font-size: 10px; font-weight: 700; color: var(--hint); margin: 6px 2px 2px; width: 100%; line-height: 1.35; }
.text-input.area { resize: none; line-height: 1.4; margin-bottom: 8px; }
.sheet-divider { display: flex; align-items: center; gap: 10px; color: var(--hint); font-size: 11px;
  font-weight: 700; margin: 12px 0 4px; }
.sheet-divider::before, .sheet-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.sheet-actions { display: flex; gap: 9px; margin-top: 6px; }
.sheet-actions .btn { flex: 1; }
.micro-details { margin: 4px 0; }
.micro-details summary { color: var(--accent-2); font-size: 12px; font-weight: 700; cursor: pointer;
  padding: 4px 2px; list-style: none; }
.micro-details summary::-webkit-details-marker { display: none; }
.micro-details summary::before { content: "+ "; }
.micro-details[open] summary::before { content: "− "; }

/* ---------- Forecast card ---------- */
.forecast { display: flex; align-items: center; gap: 8px; }
.fc-main { flex: 1; min-width: 0; text-align: center; }
.fc-main b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.fc-main span { color: var(--hint); font-size: 11px; }
.fc-arrow { color: #cdd4dd; flex: none; }
.fc-arrow .icon { width: 22px; height: 22px; }
#fc-note { margin-top: 12px; font-size: 12px; line-height: 1.4; }

/* ---------- Toggle switch ---------- */
.toggle-row { display: flex; align-items: center; gap: 12px; }
.toggle-info { flex: 1; min-width: 0; }
.toggle-info .muted { margin-top: 2px; }
.switch { flex: none; width: 48px; height: 28px; border-radius: 999px; border: none; cursor: pointer;
  background: #d4dae2; position: relative; transition: background .2s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(20,40,60,.25); transition: transform .2s; }
.switch.on { background: var(--accent); }
.switch.on .knob { transform: translateX(20px); }

/* ---------- Onboarding sheet ---------- */
#onb-sheet, #edit-sheet { max-height: 90vh; overflow-y: auto; }

/* ---------- Calorie range + scan tip ---------- */
.kcal-range { color: var(--hint); font-size: 13px; font-weight: 700; margin-left: 8px; }
.scan-tip-line { display: flex; align-items: flex-start; gap: 7px; color: var(--hint); font-size: 12px;
  line-height: 1.4; margin-top: 10px; }
.scan-tip-line .icon { width: 15px; height: 15px; flex: none; color: var(--accent); margin-top: 1px; }

/* ---------- Recipe chips ---------- */
.fav-chip.recipe { border-color: rgba(91,141,239,.22); background: rgba(91,141,239,.07); color: #3f6fd6; }
.fav-chip.recipe .fav-chip-kcal { background: rgba(255,255,255,.5); }
.fav-chip.recipe .fav-del { border-left-color: rgba(91,141,239,.16); }

/* ---------- Achievements badges ---------- */
.badges { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.badge { display: flex; align-items: center; gap: 8px; padding: 10px 11px; border-radius: 12px;
  background: var(--card-2); border: 1px solid var(--line); color: var(--hint); opacity: .65; }
.badge .icon { width: 18px; height: 18px; flex: none; }
.badge span { font-size: 12px; font-weight: 700; line-height: 1.2; }
.badge.earned { opacity: 1; background: rgba(233,162,59,.12); border-color: rgba(233,162,59,.3); color: #c47d18; }

/* ---------- Subscription / pass ---------- */
.pack.pass { border-color: rgba(52,178,123,.4); background: rgba(52,178,123,.08); }
.pack.pass b { color: var(--accent-2); }
.pack-sub { display: block; color: var(--hint); font-size: 11px; font-weight: 600; margin-top: 1px; }
.pass-active { display: flex; align-items: center; gap: 7px; padding: 11px 13px; border-radius: 12px;
  background: rgba(52,178,123,.1); color: var(--accent-2); font-size: 13px; font-weight: 700; }
.pass-active .icon { width: 15px; height: 15px; color: var(--accent); }

/* ---------- Camera scanner ---------- */
.cam-box { position: relative; width: 92%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
#cam-video { width: 100%; border-radius: 16px; background: #000; aspect-ratio: 3/4; object-fit: cover; }
.cam-frame { position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%); width: 70%; max-width: 300px;
  height: 110px; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; pointer-events: none; }
.cam-hint { color: #fff; font-size: 13px; font-weight: 700; }
.cam-capture {
  width: 68px; height: 68px; border-radius: 50%; border: 4px solid #fff;
  background: rgba(255,255,255,.25); cursor: pointer; flex: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,.35);
}
.cam-capture:active { transform: scale(.94); background: rgba(255,255,255,.4); }
.cam-box .btn.ghost { background: rgba(255,255,255,.18); color: #fff; }

/* ---------- Recipe builder ---------- */
#recipe-sheet { max-height: 90vh; overflow-y: auto; }
.rc-items { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.rc-item { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line);
  border-radius: 11px; padding: 8px 10px; }
.rc-iname { flex: 1; min-width: 0; font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-g { width: 60px; flex: none; background: var(--card-2); border: none; border-radius: 8px; padding: 7px 6px;
  text-align: center; font-family: inherit; font-weight: 700; font-size: 16px; color: var(--text); outline: none; }
.rc-ik { width: 42px; flex: none; text-align: right; color: var(--accent); font-weight: 800; font-size: 12px; }
.rc-del { border: none; background: transparent; color: #c2cad4; cursor: pointer; padding: 4px; display: flex; flex: none; }
.rc-del .icon { width: 15px; height: 15px; }
.rc-total { display: flex; align-items: center; justify-content: space-between; margin: 10px 0; padding: 12px 14px;
  border-radius: 12px; background: rgba(52,178,123,.1); }
.rc-total span { color: var(--hint); font-size: 12px; font-weight: 700; }
.rc-total b { font-size: 15px; font-weight: 800; color: var(--accent-2); }
.rc-manual { margin: 10px 0 4px; }
.rc-manual summary {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; box-sizing: border-box;
  color: var(--accent-2); font-size: 12px; font-weight: 800; cursor: pointer;
  padding: 10px 12px; list-style: none; text-align: center;
  background: rgba(52,178,123,.08);
  border: 1px dashed rgba(52,178,123,.35);
  border-radius: 11px;
  transition: background .15s, border-color .15s;
  touch-action: manipulation;
}
.rc-manual summary:active { background: rgba(52,178,123,.14); }
.rc-manual[open] summary {
  background: rgba(52,178,123,.12);
  border-color: rgba(52,178,123,.45);
  border-style: solid;
  margin-bottom: 8px;
}
.rc-manual summary::-webkit-details-marker { display: none; }
.rc-manual summary::before {
  content: "+";
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 6px;
  background: rgba(52,178,123,.18); font-size: 14px; font-weight: 800; line-height: 1;
  flex: none;
}
.rc-manual[open] summary::before { content: "−"; }
.rc-manual-form { padding: 2px 0 8px; }
.rc-man-add-btn { margin-top: 6px; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + 16px);
  background: var(--danger); color: #fff; padding: 11px 17px; border-radius: 12px; font-size: 13px;
  font-weight: 700; z-index: 50; max-width: 90%; text-align: center; box-shadow: 0 10px 30px rgba(20,40,60,.18); }

/* ---------- Spinner ---------- */
.spinner { width: 36px; height: 36px; margin: 6px auto 12px; border: 4px solid var(--card-2);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Bottom nav ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: flex; align-items: center; justify-content: space-around;
  background: rgba(255,255,255,0.94); backdrop-filter: blur(16px); border-top: 1px solid var(--line); }
.tab { flex: 1; min-width: 0; background: none; border: none; cursor: pointer; color: var(--hint);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10px; font-weight: 700;
  font-family: inherit; padding: 7px 0; transition: color .2s; }
.tab .icon { width: 22px; height: 22px; }
.tab.active { color: var(--accent); }
.scan-tab { flex: 0 0 auto; }
.scan-fab { width: 52px; height: 52px; border-radius: 16px; margin-top: -18px; display: flex;
  align-items: center; justify-content: center; background: var(--accent); color: var(--on-accent);
  box-shadow: 0 8px 18px rgba(52,178,123,.4); }
.scan-fab .icon { width: 24px; height: 24px; stroke-width: 2.2; }

/* ---------- Splash screen ---------- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(165deg, #f8fafb 0%, #eef8f2 45%, #f4f6f8 100%);
  transition: opacity 0.45s ease, visibility 0.45s ease;
}
.splash-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.splash-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  pointer-events: none;
}
.splash-blob-a {
  width: 220px;
  height: 220px;
  top: 8%;
  left: -12%;
  background: rgba(52, 178, 123, 0.22);
  animation: splash-drift 7s ease-in-out infinite;
}
.splash-blob-b {
  width: 180px;
  height: 180px;
  bottom: 10%;
  right: -10%;
  background: rgba(91, 141, 239, 0.14);
  animation: splash-drift 8s ease-in-out infinite reverse;
}
@keyframes splash-drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(12px, -10px) scale(1.06); }
}
.splash-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
  animation: splash-in 0.55s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}
@keyframes splash-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
.splash-logo-stage {
  position: relative;
  width: 104px;
  height: 104px;
  margin-bottom: 18px;
}
.splash-ring {
  position: absolute;
  inset: -6px;
  border-radius: 28px;
  border: 2px solid rgba(52, 178, 123, 0.35);
  animation: splash-ring 2s ease-in-out infinite;
}
@keyframes splash-ring {
  0%, 100% { transform: scale(1); opacity: 0.55; }
  50% { transform: scale(1.06); opacity: 1; }
}
.splash-logo {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  object-fit: cover;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 12px 32px rgba(52, 178, 123, 0.28);
  animation: splash-float 3s ease-in-out infinite;
}
@keyframes splash-float {
  0%, 100% { transform: translate(-50%, -50%); }
  50% { transform: translate(-50%, calc(-50% - 4px)); }
}
.splash-name {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--text);
  margin-bottom: 4px;
}
.splash-tag {
  font-size: 13px;
  font-weight: 700;
  color: var(--hint);
  margin-bottom: 28px;
}
.splash-bar {
  width: min(200px, 72vw);
  height: 4px;
  border-radius: 999px;
  background: rgba(20, 40, 60, 0.08);
  overflow: hidden;
}
.splash-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #5bda9e);
  transition: width 0.25s ease;
  position: relative;
}
.splash-bar i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: splash-shimmer 1.2s ease-in-out infinite;
}
@keyframes splash-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.scan-tab:active .scan-fab { transform: scale(.93); }
