/* Total Carbs & Sugar Counter — Preview v3
 * Design follows the owner's clean masters (concept kit, 2026-11-19):
 * near-white background, white cards with soft shadows and big radii,
 * light type scale, green accents, ring + slim bars on Today,
 * green-caps chain cards with a round green + on Eat Out. */
:root {
  --green: #059669;
  --green-d: #047857;
  --ink: #17251f;
  --muted: #68766e;
  --line: #e4eae6;
  --bg: #f6f8f6;
  --card: #ffffff;
  --radius: 22px;
  --tabbar-h: 64px;
  --shadow: 0 6px 24px rgba(23, 37, 31, .07);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: calc(var(--tabbar-h) + 18px);
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(246, 248, 246, .94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brandmark {
  width: 36px; height: 36px; border-radius: 11px; flex: none;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; letter-spacing: .02em;
}
.brandtext { flex: 1; min-width: 0; }
.brandtext h1 { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-tag { margin: 1px 0 0; font-size: 11px; color: var(--green-d); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.plan-badge {
  flex: none; border: 1.5px solid #f2c14e; background: #fff8e1; color: #7a5b00;
  border-radius: 999px; padding: 6px 10px; font-size: 12px; font-weight: 700;
}
.plan-badge.pro { border-color: var(--green); background: #e7f7f0; color: var(--green-d); }

/* ---------- layout ---------- */
main { max-width: 560px; margin: 0 auto; padding: 10px 12px 4px; }
.view { display: none; }
.view.active { display: block; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 12px 0; box-shadow: var(--shadow);
}
.card-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.card-head-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 6px 0; }
.biglabel { display: block; font-size: 19px; font-weight: 700; margin: 8px 0 8px; }
.biglabel.small { font-size: 15px; margin-top: 14px; }

/* ---------- today summary (master: floats on the background) ---------- */
.summary-block {
  display: flex; gap: 14px; align-items: center;
  padding: 8px 4px 2px; margin-top: 2px;
}
.bars { flex: 1; min-width: 0; }
.bar-row { margin-bottom: 9px; }
.bar-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.bar-head span:first-child { font-weight: 600; }
.bar-ref { color: var(--muted); font-size: 12px; }
.bar-track { height: 7px; background: #e7ede9; border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; border-radius: 99px; }
.fill-carbs { background: #38bdf8; }
.fill-sugar { background: #f472b6; }
.fill-kcal { background: #34d399; }
.fill-fiber { background: #fbbf24; }
.ref-note { color: var(--muted); font-size: 11px; margin: 2px 0 0; }
.ring-wrap { position: relative; width: 138px; height: 138px; flex: none; }
.ring { width: 138px; height: 138px; transform: rotate(-90deg); filter: drop-shadow(0 4px 10px rgba(16, 185, 129, .25)); }
.ring circle { fill: none; stroke-width: 9; }
.ring-bg { stroke: #e7ede9; }
.ring-fg { stroke: url(#ringGrad); stroke-linecap: round; stroke-dasharray: 263.9; stroke-dashoffset: 263.9; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-num { font-size: 31px; font-weight: 800; line-height: 1; }
.ring-unit { font-size: 12px; color: var(--ink); margin-top: 2px; }
.ring-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ---------- plate card (master) ---------- */
.plate-card { padding: 14px; }
.plate-label { margin: 0 2px 10px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.estchip { background: #e7f7f0; color: var(--green-d); border-radius: 999px; padding: 2px 8px; font-size: 11px; letter-spacing: 0; text-transform: none; }
.photo-stage {
  position: relative; border-radius: 18px; overflow: hidden;
  background: linear-gradient(135deg, #e9f5ee, #fdf3e3);
  min-height: 190px; display: flex;
}
.photo-stage img { width: 100%; height: auto; max-height: 340px; object-fit: cover; display: block; }
.photo-prompt {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 26px 18px; text-align: center; cursor: pointer; color: var(--green-d);
}
.pp-icon { font-size: 34px; }
.pp-title { font-size: 17px; font-weight: 700; }
.pp-sub { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.photo-tags { position: absolute; inset: 0; pointer-events: none; }
.photo-tag {
  position: absolute; transform: translate(-50%, -100%);
  background: rgba(255, 255, 255, .96); color: var(--ink);
  border-radius: 999px; padding: 4px 10px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .22);
}
.photo-tag::after { /* pin dot under the tag, like the master */
  content: ""; position: absolute; left: 50%; bottom: -13px; transform: translateX(-50%);
  width: 7px; height: 7px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.green-pill {
  width: 100%; margin-top: 12px; border: none; border-radius: 999px;
  background: var(--green); color: #fff; min-height: 52px;
  font-size: 16.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 8px 0 18px;
}
.green-pill .pill-plus {
  margin-left: auto; width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: rgba(255, 255, 255, .28); display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600;
}
.green-pill:disabled { opacity: .65; }
.plate-caption { text-align: center; color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.notice {
  margin-top: 12px; background: #fffbeb; border: 1px solid #fde68a; color: #713f12;
  border-radius: 14px; padding: 10px 12px; font-size: 13px; line-height: 1.5;
}

/* ---------- ask bar + soft pills (master) ---------- */
.askbar {
  margin: 14px 0 10px; background: #fff; border: 1px solid var(--line); border-radius: 999px;
  min-height: 52px; display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 18px;
  box-shadow: var(--shadow); cursor: pointer;
}
.askbar-text { flex: 1; color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.askbar-mic {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: #eef2ee; display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.pillrow { display: flex; gap: 8px; }
.soft-pill {
  flex: 1; border: none; background: #edf2ed; color: var(--ink); border-radius: 999px;
  min-height: 46px; padding: 6px 8px; font-size: 12.5px; font-weight: 600; line-height: 1.2;
  display: flex; align-items: center; justify-content: center; gap: 7px; text-align: left;
}
.sp-icon { font-size: 16px; }

/* ---------- quick repeat ---------- */
.quick-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.quick-chip {
  border: 1.5px solid var(--green); color: var(--green-d); background: #f2fbf7;
  border-radius: 999px; padding: 8px 12px; font-size: 13.5px; font-weight: 600;
}

/* ---------- search ---------- */
.searchrow { display: flex; gap: 8px; }
.searchrow input[type="search"], .searchrow input[type="text"] {
  flex: 1; min-width: 0; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 14px; background: #fff; font-size: 16px;
}
#restSearch { border-radius: 999px; padding-left: 18px; }
.textin { width: 100%; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 12px; font-size: 16px; background: #fff; }
button.primary {
  background: var(--green); color: #fff; border: none; border-radius: 14px;
  padding: 12px 18px; font-weight: 700; min-height: 48px;
}
button.primary:disabled { opacity: .6; }
button.wide { width: 100%; margin-top: 10px; }
button.ghost {
  background: #fff; color: var(--ink); border: 1.5px solid var(--line);
  border-radius: 14px; padding: 12px 16px; min-height: 48px; font-weight: 600;
}
button.ghost.danger { color: #b91c1c; border-color: #fecaca; }
button.disabled-look { opacity: .55; }
.linklike { background: none; border: none; color: var(--green-d); font-weight: 700; padding: 2px 1px; text-decoration: underline; font-size: inherit; }

/* ---------- food cards (search / barcode) ---------- */
.results { margin-top: 6px; }
.food-card {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 13px 14px; margin: 8px 0; box-shadow: var(--shadow);
}
.fc-main { flex: 1; min-width: 0; }
.fc-name { font-weight: 700; font-size: 15.5px; line-height: 1.25; }
.fc-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.fc-nums { text-align: right; flex: none; }
.fc-carbs { font-size: 19px; font-weight: 800; color: var(--green-d); line-height: 1.1; }
.fc-carbs small { font-size: 11px; font-weight: 600; color: var(--muted); display: block; }
.fc-kcal { font-size: 12px; color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; font-size: 14px; line-height: 1.5; }
.empty .primary { margin-top: 10px; }

/* ---------- eat out (restaurant master) ---------- */
.chips-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.pill {
  border: 1.5px solid #9fc3ae; background: #fff; color: var(--green-d);
  border-radius: 999px; padding: 8px 14px; font-size: 13.5px; font-weight: 700; min-height: 38px;
}
.pill.active { background: #1f2937; border-color: #1f2937; color: #fff; }
.rest-card {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 16px; margin: 10px 0; box-shadow: var(--shadow);
}
.rest-main { flex: 1; min-width: 0; }
.rest-chain {
  color: var(--green-d); font-weight: 800; font-size: 12.5px;
  letter-spacing: .07em; text-transform: uppercase; margin-bottom: 3px;
}
.rest-name { font-weight: 700; font-size: 18px; line-height: 1.25; }
.rest-macros { color: #5b6b62; font-size: 13.5px; margin-top: 5px; }
.plus-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: none;
  background: var(--green); color: #fff; font-size: 24px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(5, 150, 105, .35);
}

/* ---------- scanner ---------- */
.mode-toggle { display: flex; gap: 8px; margin: 4px 0 12px; }
.mode-btn {
  flex: 1; border: 1.5px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 10px 8px; font-weight: 700; font-size: 14px; min-height: 44px;
}
.mode-btn.active { background: var(--green); border-color: var(--green); color: #fff; }
.scan-card { margin-top: 0; }
.qr-reader { width: 100%; border-radius: 14px; overflow: hidden; background: #0c1512; min-height: 0; }
.qr-reader:empty { background: transparent; }
.btnrow { display: flex; gap: 8px; margin-top: 8px; }
.btnrow .grow { flex: 1; }
.filelabel { display: block; text-align: center; border-radius: 14px; padding: 13px; font-weight: 700; }
#ocrPreview { width: 100%; border-radius: 14px; margin-top: 10px; }
.ocr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 2px; }
.ocr-grid label { font-size: 13px; font-weight: 600; color: var(--muted); display: block; }
.ocr-grid input {
  width: 100%; margin-top: 4px; padding: 11px; font-size: 17px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
}
#ocrResult select, #detailOverlay select, .sheet select, .analyze-card select {
  width: 100%; padding: 11px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; font-size: 16px; margin: 4px 0 6px;
}

/* ---------- coach ---------- */
.coach-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.coach-head .biglabel { margin: 4px 0; }
.voice-btn {
  flex: none; border: 1.5px solid var(--green); background: #e7f7f0; color: var(--green-d);
  border-radius: 999px; padding: 9px 14px; font-weight: 700; font-size: 14px; min-height: 42px;
}
.voice-btn.off { border-color: var(--line); background: #fff; color: var(--muted); }
.chat-box { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.bubble {
  max-width: 88%; padding: 11px 13px; border-radius: 16px;
  font-size: 15px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.bubble.user { align-self: flex-end; background: var(--green); color: #fff; border-bottom-right-radius: 5px; }
.bubble.ai { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; box-shadow: var(--shadow); }
.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input {
  flex: 1; min-width: 0; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 14px; font-size: 16px; background: #fff;
}
.mic { padding: 0 14px; font-size: 18px; }
.mic.listening { background: #fee2e2; border-color: #fca5a5; }
.match-hint { color: var(--muted); font-size: 13px; margin: 10px 0 2px; }
.confirm-row {
  display: flex; gap: 10px; align-items: center; margin: 10px 0 4px;
  background: #e7f7f0; border: 1px solid #a7e3c8; border-radius: 16px; padding: 12px;
}
.confirm-row .cf-text { flex: 1; font-weight: 600; font-size: 15px; }
.confirm-row button { border: none; border-radius: 999px; padding: 11px 20px; font-weight: 800; min-height: 46px; }
.confirm-row .cf-yes { background: var(--green); color: #fff; }
.confirm-row .cf-no { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }

/* ---------- log ---------- */
.daytotal {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; text-align: center; box-shadow: var(--shadow); margin-bottom: 6px;
}
.daytotal-label { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
.daytotal-num { display: block; font-size: 40px; font-weight: 800; color: var(--green-d); line-height: 1.15; }
.daytotal-num small { font-size: 20px; }
.daytotal-sub { color: var(--muted); font-size: 13px; }
.log-item {
  display: flex; gap: 10px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 11px 13px; margin: 8px 0; box-shadow: var(--shadow);
}
.li-main { flex: 1; min-width: 0; }
.li-name { font-weight: 600; font-size: 15px; }
.li-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.li-carbs { font-weight: 800; color: var(--green-d); font-size: 16px; flex: none; text-align: right; }
.li-carbs small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; }
.li-del {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid #fecaca; background: #fff; color: #b91c1c; font-size: 15px;
}

/* ---------- overlays / sheets ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(12, 21, 17, .55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: #fff; width: 100%; max-width: 560px; max-height: 92vh;
  border-radius: 24px 24px 0 0; padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  position: relative;
  display: flex; flex-direction: column; overflow: hidden;
}
.sheet.paywall { display: block; overflow-y: auto; }
/* v3.2: the detail sheet scrolls its body; the servings stepper + Add
 * stay pinned in a bottom bar (DoorDash pattern). */
.sheet-scroll { overflow-y: auto; min-height: 0; }
.sheet-bar {
  flex: none; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px;
  background: #fff;
}
.sheet-bar .stepper { margin: 2px 0 10px; }
.sheet-bar-row { display: flex; gap: 8px; align-items: stretch; }
.sheet-bar-row select {
  flex: 1; width: auto; margin: 0; padding: 11px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 16px;
}
.sheet-bar-row .primary { flex: 1.35; border-radius: 12px; }
.sheet h2 { margin: 0 34px 2px 0; font-size: 20px; line-height: 1.25; }
.closebtn {
  position: absolute; top: 12px; right: 12px; width: 38px; height: 38px;
  border-radius: 50%; border: 1.5px solid var(--line); background: #fff; font-size: 15px;
}
.bignum { text-align: center; margin: 14px 0 6px; }
.bignum-label { display: block; font-size: 12px; font-weight: 800; letter-spacing: .09em; color: var(--muted); }
.bignum-num { font-size: 46px; font-weight: 800; color: var(--green-d); line-height: 1.1; }
.bignum-num small { font-size: 22px; }
.bignum-sub { display: block; color: var(--muted); font-size: 13px; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 10px 0; font-size: 16px; font-weight: 600; }
.stepper button {
  width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--green);
  background: #fff; color: var(--green-d); font-size: 22px; font-weight: 700;
}
table.panel { width: 100%; border-collapse: collapse; margin: 8px 0 4px; font-size: 14.5px; }
table.panel th, table.panel td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; }
table.panel th:first-child, table.panel td:first-child { text-align: left; font-weight: 600; }
table.panel th { color: var(--muted); font-size: 12.5px; }

/* ---------- paywall ---------- */
.paywall { text-align: center; }
.paywall h2 { margin-right: 0; }
.crown { font-size: 40px; color: #d97706; }
.pro-list { list-style: none; padding: 0; margin: 14px 0; text-align: left; font-size: 15px; line-height: 1.5; }
.pro-list li { padding: 5px 0; border-bottom: 1px solid var(--line); }
.price-box {
  display: flex; justify-content: space-between; align-items: center;
  border: 1.5px solid var(--green); border-radius: 16px; padding: 12px 14px; margin: 12px 0; text-align: left;
}
.price-name { display: block; font-weight: 700; }
.price-sub { display: block; color: var(--muted); font-size: 12px; }
.price-num { font-size: 26px; font-weight: 800; color: var(--green-d); }
.price-num small { font-size: 13px; color: var(--muted); font-weight: 600; }
.preview-note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 10px 12px; font-size: 13px; color: #713f12; text-align: left; line-height: 1.5; }

/* ---------- tab bar / footer / toast ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line);
  display: flex;
}
.tabbar button {
  flex: 1; border: none; background: none; color: var(--muted);
  font-size: 11.5px; font-weight: 600; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; padding: 6px 0;
}
.tabbar button span { font-size: 19px; line-height: 1; }
.tabbar button.active { color: var(--green-d); }
.appfooter {
  max-width: 560px; margin: 14px auto 0; padding: 0 16px;
  color: var(--muted); font-size: 11.5px; line-height: 1.55; text-align: center;
}
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px); transform: translateX(-50%);
  z-index: 60; background: #17251f; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); max-width: 92vw; text-align: center;
}
/* ---------- log meal headings / scan items / detector ---------- */
.mealhead { font-size: 14px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 16px 2px 2px; }
.scanitem {
  border: 1px solid var(--line); border-radius: 16px; padding: 12px; margin: 10px 0;
  background: #fbfdfb;
}
.scanitem .sname { font-weight: 700; font-size: 15.5px; margin: 6px 0 2px; }
.scanitem .srow { margin-top: 8px; }
.scanitem .srow label { font-size: 13px; font-weight: 600; color: var(--muted); }
.scanitem .srow input {
  width: 110px; margin-left: 8px; padding: 9px; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
.scanitem.flash { outline: 3px solid var(--green); outline-offset: 1px; }
.detector-video { width: 100%; display: block; }
.photo-tag { border: none; cursor: pointer; pointer-events: auto; }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}

/* ---------- v3.1: in-place analysis card ----------
 * Appears the instant a photo/barcode flow starts, at the top of the
 * flow, auto-scrolled into view. A shimmer sweeps the photo thumbnail
 * and the step lines tick over as stages finish; results (or an honest
 * failure) then replace the card's contents IN THE SAME SPOT, with the
 * analyzed photo rendered BELOW the results. */
#plateFlow:empty, #ocrAnalysis:empty { display: none; }
.analyze-card {
  border: 1.5px solid var(--line); border-radius: 18px; background: #fbfdfb;
  padding: 14px; margin: 0 0 12px; box-shadow: var(--shadow);
}
.analyze-card.done { background: #fff; }
.ac-top { display: flex; gap: 12px; }
.ac-thumb {
  position: relative; width: 84px; height: 84px; border-radius: 14px;
  overflow: hidden; flex: none; background: #e7ede9;
}
.ac-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ac-shimmer {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, rgba(16, 185, 129, .30) 44%, rgba(255, 255, 255, .75) 50%, rgba(16, 185, 129, .30) 56%, transparent 100%);
  background-size: 100% 240%;
  animation: acscan 1.5s linear infinite;
}
@keyframes acscan { 0% { background-position: 0 -130%; } 100% { background-position: 0 130%; } }
.ac-main { flex: 1; min-width: 0; }
.ac-title { font-weight: 800; font-size: 16px; margin: 2px 0 6px; }
.ac-steps { list-style: none; margin: 0; padding: 0; }
.ac-steps li {
  display: flex; gap: 8px; align-items: center;
  font-size: 14px; color: var(--muted); padding: 3px 0;
}
.ac-dot {
  width: 19px; height: 19px; border-radius: 50%; flex: none;
  border: 2px solid var(--line); background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
}
.ac-steps li.active { color: var(--ink); font-weight: 700; }
.ac-steps li.active .ac-dot { border-color: var(--green); animation: acpulse 1s ease-in-out infinite; }
.ac-steps li.done { color: var(--green-d); }
.ac-steps li.done .ac-dot { border-color: var(--green); background: var(--green); }
.ac-steps li.done .ac-dot::after { content: "✓"; }
@keyframes acpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, .35); }
  50% { box-shadow: 0 0 0 5px rgba(5, 150, 105, 0); }
}
.ac-detail { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; min-height: 1em; line-height: 1.4; }
.ac-result-title { font-weight: 800; font-size: 16px; margin: 0 0 4px; }
.ac-fail { font-size: 14.5px; line-height: 1.55; margin: 2px 0 4px; }
.result-photo { position: relative; margin-top: 12px; border-radius: 16px; overflow: hidden; }
.result-photo > img { width: 100%; height: auto; max-height: 300px; object-fit: cover; display: block; }
.ac-newphoto { margin-top: 12px; }
@media (prefers-reduced-motion: reduce) {
  .ac-shimmer { animation: none; }
  .ac-steps li.active .ac-dot { animation: none; }
}

/* ---------- v3.2: pictures + Browse shelves (DoorDash pattern) ----------
 * Photo cards scrolling sideways under a bold category header. The
 * picture and ONE big number (total carbs) carry the card; the round +
 * sits ON the photo and turns into a count badge (1×, 2×…) of today's
 * logs. Foods without a clean licensed photo get a colored letter
 * tile — never an emoji. */
.thumb-img { object-fit: cover; display: block; background: #e7ede9; }
.letter-tile {
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; flex: none;
}
.thumb-img.fc-thumb, .letter-tile.fc-thumb { width: 52px; height: 52px; border-radius: 13px; font-size: 22px; }
.shelf { margin: 20px 0 2px; }
.shelf-head { display: flex; align-items: center; gap: 9px; margin: 0 2px 9px; }
.shelf-thumb { width: 34px; height: 34px; border-radius: 10px; object-fit: cover; flex: none; }
.shelf-title { margin: 0; font-size: 19px; font-weight: 800; flex: 1; min-width: 0; }
.shelf-count { color: var(--muted); font-size: 12.5px; font-weight: 600; flex: none; }
.shelf-row {
  display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 12px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.browse-card { flex: 0 0 128px; scroll-snap-align: start; cursor: pointer; }
.bc-photo { position: relative; }
.thumb-img.bc-thumb, .letter-tile.bc-thumb {
  width: 128px; height: 104px; border-radius: 16px; font-size: 42px;
}
.bc-plus {
  position: absolute; right: 7px; bottom: 7px;
  min-width: 38px; height: 38px; padding: 0 9px;
  border: none; border-radius: 999px;
  background: var(--green); color: #fff;
  font-size: 21px; font-weight: 700; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(5, 150, 105, .4);
}
.bc-plus.has-count { background: #1f2937; font-size: 15px; box-shadow: 0 4px 12px rgba(23, 37, 31, .35); }
.bc-num { font-size: 21px; font-weight: 800; color: var(--green-d); line-height: 1.1; margin-top: 7px; }
.bc-num small { font-size: 11px; font-weight: 600; color: var(--muted); }
.bc-name {
  font-size: 13.5px; font-weight: 600; line-height: 1.25; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bc-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- v3.3: fast food chains A–Z directory ----------
 * A–Z directory shape, our rules: plain text rows — a colored letter
 * tile with the chain's initial, the chain name, its item count. No
 * chain logos, no menu photos. A chain opens its full menu as
 * search-style rows with the face's big number and a quick-log +. */
.chaindir-entry {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 13px 14px; margin: 8px 0 4px; box-shadow: var(--shadow);
}
.cde-tile {
  width: 52px; height: 52px; border-radius: 13px; flex: none;
  background: var(--green); color: #fff; font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.cde-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cde-name { font-weight: 700; font-size: 16px; }
.cde-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.cde-arrow, .cr-arrow { color: var(--muted); font-size: 24px; font-weight: 700; flex: none; }
.backbtn {
  background: none; border: none; color: var(--green-d);
  font-weight: 700; font-size: 15px; padding: 8px 2px; margin-top: 2px;
}
.chain-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 12px 14px; margin: 8px 0; box-shadow: var(--shadow);
}
.cr-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cr-name { font-weight: 700; font-size: 16px; }
.cr-count { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.chain-menu-row { cursor: pointer; }
.chain-menu-row .plus-btn { width: 40px; height: 40px; font-size: 22px; }
