/* ============================================================
   Sugar Scan - tokens
   ============================================================ */
:root {
  --bg: #f8f2e6;
  --bg-2: #efe4cf;
  --surface: #fffaf1;
  --surface-2: #f3e9d8;
  --text: #2f2620;
  --muted: #6f5f52;
  --line: #e2d3bb;
  --accent: #5f8f5a;
  --accent-2: #a7c99a;
  --accent-ink: #ffffff;
  --straw: #f3d38a;
  --terracotta: #d98a5b;
  --wood: #8a5a3c;
  --ok: #4f8c4a;
  --warn: #d08a2e;
  --high: #c9483f;
  --sugar: #ff3d7f;
  --sugar-2: #ff8fb4;
  --carb: #ff9b3d;
  --fibre: #34c27a;
  --protein: #4f86ff;
  --fat: #f4cf3c;
  --other: #b5c0bb;
  --glass: rgba(74,59,48,.07);
  --radius: 18px;
  --shadow: 0 2px 6px rgba(74,59,48,.07), 0 14px 40px rgba(74,59,48,.10);
  --spring: cubic-bezier(.2, 1.4, .4, 1);
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1a15;
    --bg-2: #27211b;
    --surface: #2c251f;
    --surface-2: #362e27;
    --text: #f4ece0;
    --muted: #b8a897;
    --line: #4a3f35;
    --accent: #8fbf86;
    --accent-2: #5f8f5a;
    --accent-ink: #14200f;
    --straw: #d9b45c;
    --terracotta: #c9784b;
    --wood: #a9755a;
    --ok: #86c77d;
    --warn: #e2a23c;
    --high: #e2665c;
    --sugar: #ff4f8b;
    --sugar-2: #ff9ec2;
    --carb: #ffa64f;
    --fibre: #4ade80;
    --protein: #7aa2ff;
    --fat: #f7d84f;
    --other: #3d4f4a;
    --glass: rgba(255,255,255,.06);
    --shadow: 0 2px 6px rgba(0,0,0,.35), 0 16px 40px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
html { font-size: 17px; }
@media (min-width: 700px) { html { font-size: 18px; } }
html.big { font-size: 20px; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: "Segoe UI Variable Display", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45; -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1, h2, h3 { margin: 0; line-height: 1.15; }
h1, h2, .slide h2, .tip-name, .reel-name, .welcome-body h3, .kitchen-result h2, .kitchen-result h3, .meal-result h2, .recipe-body h2, .recipe-body h3, .shelf-name, .card3d-name { font-family: "Fraunces", Georgia, "Times New Roman", serif; letter-spacing: 0; }
p { margin: 0 0 .6rem; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.row.gap { gap: .5rem; }
.row.center { justify-content: center; }
.tight { padding-left: 1.1rem; margin: .2rem 0 .8rem; }
.tight li { margin-bottom: .25rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .75rem 1.2rem; min-height: 48px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 700; font-size: 1.02rem;
  transition: transform .12s var(--spring), background .15s, opacity .15s;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--accent), #0b6f67); color: #fff; border-color: transparent; box-shadow: 0 8px 24px rgba(15,148,136,.35); }
.btn.big { padding: 1rem 1.6rem; font-size: 1.15rem; min-height: 56px; }
.btn.small { padding: .5rem .9rem; font-size: .95rem; min-height: 42px; }
.btn.ghost { background: transparent; border-color: var(--line); }
.x-btn { width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--glass); cursor: pointer; font-size: 1rem; display: grid; place-items: center; }

/* ============================================================
   Screens
   ============================================================ */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ---------- Menu button + drawer ---------- */
.menu-btn {
  position: fixed; top: max(14px, env(safe-area-inset-top)); left: 14px; z-index: 40;
  width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--glass); cursor: pointer;
  display: grid; place-items: center; gap: 0; backdrop-filter: blur(8px);
}
.menu-btn span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; margin: 2px auto; transition: transform .25s var(--ease), opacity .2s; }
body.drawer-open .menu-btn span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.drawer-open .menu-btn span:nth-child(2) { opacity: 0; }
body.drawer-open .menu-btn span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; opacity: 0; transition: opacity .25s; }
.scrim.show { opacity: 1; }
.drawer {
  position: fixed; top: 0; bottom: 0; left: 0; width: min(360px, 88vw); z-index: 35;
  background: var(--surface); box-shadow: var(--shadow);
  transform: translateX(-104%); transition: transform .32s var(--ease);
  display: flex; flex-direction: column; overflow: hidden;
  padding-top: env(safe-area-inset-top);
}
body.drawer-open .drawer { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .5rem 4.2rem; }
.drawer-title { font-weight: 800; font-size: 1.1rem; }
.drawer-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: .3rem; padding: .3rem .6rem .6rem; border-bottom: 1px solid var(--line); }
.tab { min-width: 0; padding: .45rem .3rem; border: none; background: transparent; border-radius: 12px; font-weight: 800; font-size: .95rem; line-height: 1.1; color: var(--muted); cursor: pointer; min-height: 60px; display: grid; justify-items: center; align-content: center; gap: .15rem; white-space: normal; overflow-wrap: anywhere; }
.tab-ico { font-size: 1.35rem; line-height: 1; }
.tab.active { background: var(--surface-2); color: var(--text); }
.tabpanel { padding: 1rem; overflow-y: auto; flex: 1; }
.tabpanel h3 { font-size: .95rem; margin: .6rem 0 .25rem; }
.field { display: grid; gap: .3rem; margin-bottom: 1.1rem; }
.field > span { font-weight: 700; font-size: .95rem; }
.field small { color: var(--muted); font-size: .92rem; }
.field-row { display: flex; align-items: center; gap: .5rem; }
.field-row em { font-style: normal; color: var(--muted); font-size: .85rem; }
.field input[type=number] { width: 7rem; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.2rem; font-weight: 700; }
.field.toggle { grid-template-columns: auto 1fr; align-items: center; column-gap: .6rem; }
.field.toggle small { grid-column: 2; }
.field.toggle input { width: 26px; height: 26px; accent-color: var(--accent); }
.field select { max-width: 100%; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.1rem; font-weight: 700; }
.saved-note { font-size: .8rem; color: var(--muted); opacity: 0; transition: opacity .3s; }
.saved-note.show { opacity: 1; }

.history-list { display: grid; gap: .5rem; margin-bottom: .6rem; }
.hist { display: flex; align-items: center; gap: .6rem; padding: .45rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); cursor: pointer; }
.hist img, .hist .noimg { width: 44px; height: 44px; object-fit: cover; border-radius: 9px; background: var(--other); flex: none; }
.hist .meta { flex: 1 1 0; min-width: 0; }
.hist .name { font-weight: 700; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .when { color: var(--muted); font-size: .85rem; }
.hist .stats { flex: none; display: flex; flex-direction: column; gap: .2rem; align-items: flex-end; }
.hist input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.pill { font-size: .8rem; padding: .12rem .45rem; border-radius: 999px; font-weight: 700; color: #fff; }
.pill.ok { background: var(--ok); } .pill.warn { background: var(--warn); } .pill.high { background: var(--high); }
.compare { margin-top: .8rem; overflow-x: auto; }
.compare table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.compare th, .compare td { padding: .35rem .4rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.compare td.best { color: var(--ok); font-weight: 700; }

/* ---------- Home ---------- */
.home { align-items: center; justify-content: flex-start; overflow-y: auto; -webkit-overflow-scrolling: touch; background: linear-gradient(#f4ecdc, var(--bg) 40%, #eef0dd); }
.countryside { position: fixed; left: 0; right: 0; bottom: 0; width: 100%; height: 34vh; pointer-events: none; opacity: .85; z-index: 0; }
.home-inner { position: relative; z-index: 1; }
.hero .landing-video { border: 5px solid var(--surface); box-shadow: 0 10px 30px rgba(74,59,48,.18); }
.blobs { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }
.blobs i {
  position: absolute; width: 46vmax; height: 46vmax; border-radius: 50%; filter: blur(60px); opacity: .35;
  animation: drift 18s ease-in-out infinite alternate;
}
.blobs i:nth-child(1) { background: var(--accent-2); top: -20vmax; left: -10vmax; }
.blobs i:nth-child(2) { background: var(--sugar-2); bottom: -22vmax; right: -12vmax; animation-duration: 23s; animation-delay: -6s; }
.blobs i:nth-child(3) { background: var(--fat); bottom: 10vmax; left: -22vmax; width: 30vmax; height: 30vmax; animation-duration: 27s; animation-delay: -12s; opacity: .2; }
@keyframes drift { from { transform: translate(0,0) scale(1); } to { transform: translate(8vmax, 6vmax) scale(1.15); } }

.home-inner { position: relative; margin: auto 0; text-align: center; padding: 4.2rem 1.5rem max(2.5rem, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: .4rem; width: 100%; max-width: 420px; }
.hero { width: min(320px, 84vw); animation: rise .7s var(--ease) both; }
.landing { width: 100%; height: auto; display: block; color: var(--text); overflow: hidden; }
.landing[hidden], .landing-lottie[hidden] { display: none; }
.landing-video { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 22px; box-shadow: var(--shadow); background: #e3ece8; }
.landing-video[hidden] { display: none; }
.landing-lottie { width: 100%; aspect-ratio: 320 / 250; }
.landing-lottie svg { display: block; width: 100%; height: 100%; }
.home h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; animation: rise .6s var(--ease) both .1s; }
.tagline { color: var(--muted); font-size: 1.2rem; line-height: 1.4; margin-bottom: 1.1rem; animation: rise .6s var(--ease) both .18s; }

.scan-btn {
  position: relative; width: 170px; height: 170px; border-radius: 50%; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  background: linear-gradient(145deg, #b9d1a9, var(--accent) 55%, #3f6b3b);
  color: #fff; box-shadow: 0 18px 50px rgba(95,143,90,.45), inset 0 -6px 14px rgba(0,0,0,.18), inset 0 4px 10px rgba(255,255,255,.35);
  animation: pop .8s var(--spring) both .25s; transition: transform .15s var(--spring);
  user-select: none;
}
.scan-btn:active { transform: scale(.94); }
.scan-text { font-weight: 800; font-size: 1.3rem; letter-spacing: .02em; }
.scan-ring { position: absolute; inset: -10px; border-radius: 50%; border: 2px solid var(--accent); opacity: .5; animation: pulse 2.4s ease-out infinite; }
@keyframes pulse { 0% { transform: scale(.9); opacity: .6; } 100% { transform: scale(1.35); opacity: 0; } }
.home-links { margin-top: 1.4rem; display: flex; flex-direction: column; gap: .6rem; align-items: center; animation: rise .6s var(--ease) both .4s; }
.link { background: none; border: none; color: var(--muted); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--line); padding: .3rem; }

.staging { margin-top: 1rem; display: flex; flex-direction: column; align-items: center; gap: .7rem; animation: rise .4s var(--ease) both; }
.thumbs { display: flex; gap: .5rem; }
.thumb { position: relative; width: 96px; height: 96px; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); animation: pop .5s var(--spring) both; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: .75rem; }
.status { min-height: 1.3rem; font-size: 1rem; color: var(--muted); margin-top: .6rem; max-width: 34ch; }
.status.error { color: var(--high); }

/* ---------- Webcam ---------- */
.webcam { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
.webcam video { flex: 1; width: 100%; object-fit: contain; }
.webcam-actions { display: flex; gap: .6rem; justify-content: center; padding: 1rem; padding-bottom: max(1rem, env(safe-area-inset-bottom)); }

/* ---------- Scanning ---------- */
.scanning { align-items: center; justify-content: center; gap: 1.2rem; background: var(--bg); padding: 1.5rem; }
.scan-stage { position: relative; width: min(78vw, 320px); aspect-ratio: 3/4; border-radius: 22px; overflow: hidden; background: var(--surface-2); box-shadow: var(--shadow); color: var(--accent); }
.scan-stage img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(.8) brightness(.9); }
.scan-corners { position: absolute; inset: 10px; width: calc(100% - 20px); height: calc(100% - 20px); opacity: .9; }
.scan-beam {
  position: absolute; left: 0; right: 0; height: 36%; top: -40%;
  background: linear-gradient(to bottom, transparent, rgba(45,212,191,.28) 70%, var(--accent) 100%);
  animation: beam 1.8s ease-in-out infinite;
}
.scan-beam::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent-2); box-shadow: 0 0 14px 3px var(--accent); }
@keyframes beam { 0% { top: -40%; } 50% { top: 100%; } 100% { top: -40%; } }
.lottie-slot { position: absolute; inset: 0; display: grid; place-items: center; }
.scan-caption { text-align: center; }
.scan-title { font-weight: 800; font-size: 1.3rem; }
.scan-title::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

/* ============================================================
   Results deck
   ============================================================ */
.results { background: var(--bg); }
.deck-head { display: flex; align-items: center; justify-content: space-between; padding: max(12px, env(safe-area-inset-top)) 14px 6px 66px; z-index: 3; }
.home-btn { min-height: 46px; padding: 0 14px; border-radius: 999px; border: none; background: var(--glass); color: var(--text); font: inherit; font-weight: 800; font-size: 1.05rem; cursor: pointer; }
.dots { display: flex; gap: 6px; }
.dots button { width: 9px; height: 9px; border-radius: 999px; border: none; padding: 0; background: var(--line); cursor: pointer; transition: width .25s var(--ease), background .25s; }
.dots button.active { width: 28px; background: var(--accent); }

.deck {
  flex: 1; display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
.deck::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%; width: 100%; scroll-snap-align: start; scroll-snap-stop: always;
  overflow-y: auto; overflow-x: hidden; padding: .4rem 1.2rem 1rem;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .6rem;
}
.slide-inner { width: 100%; max-width: 460px; margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.kicker { text-transform: uppercase; letter-spacing: .1em; font-size: .9rem; font-weight: 800; color: var(--muted); }
.slide h2 { font-size: 1.8rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.slide .lead { color: var(--text); font-size: 1.2rem; max-width: 30ch; line-height: 1.4; }
.slide .fine { color: var(--muted); font-size: 1rem; max-width: 34ch; line-height: 1.4; }

/* staggered entrance: elements with data-a animate when the slide has .in */
[data-a] { opacity: 0; transform: translateY(18px); }
.slide.in [data-a] { animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 90ms); }
.slide.in [data-a="pop"] { animation-name: pop; animation-timing-function: var(--spring); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }

.nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--glass); font-size: 1.6rem; cursor: pointer; display: none; place-items: center; z-index: 3; }
.nav.prev { left: 10px; } .nav.next { right: 10px; }
@media (hover: hover) and (min-width: 700px) { .nav { display: grid; } }
.deck-foot { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .5rem 1rem max(.8rem, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); z-index: 3; }
.deck-foot .btn { flex: 1 1 0; min-width: 0; white-space: nowrap; padding-left: .8rem; padding-right: .8rem; }
.page-count { color: var(--muted); font-weight: 700; font-size: .95rem; white-space: nowrap; flex: none; }

/* colour helpers */
.ok { --tone: var(--ok); } .warn { --tone: var(--warn); } .high { --tone: var(--high); }
.tone { color: var(--tone); }
.stamp {
  display: inline-block; padding: .35rem 1rem; border: 3px solid var(--tone); color: var(--tone); border-radius: 10px;
  font-weight: 900; letter-spacing: .12em; text-transform: uppercase; font-size: 1.35rem; transform: rotate(-6deg); opacity: 0; margin-top: .5rem; background: var(--bg);
}
.slide.in .stamp { animation: stamp .55s var(--spring) both .55s; }
@keyframes stamp { from { opacity: 0; transform: rotate(-6deg) scale(2.2); } to { opacity: 1; transform: rotate(-6deg) scale(1); } }

/* ---------- Verdict ring ---------- */
.ring { width: min(62vw, 230px); aspect-ratio: 1; position: relative; display: grid; place-items: center; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring .glow { fill: none; stroke: var(--tone); stroke-width: 22; opacity: .18; stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset 1.3s var(--ease) .25s; }
.slide.in .ring .glow { stroke-dashoffset: var(--off); }
.ring .track { fill: none; stroke: var(--surface-2); stroke-width: 12; }
.ring .bar { fill: none; stroke: var(--tone); stroke-width: 12; stroke-linecap: round; stroke-dasharray: 327; stroke-dashoffset: 327; transition: stroke-dashoffset 1.3s var(--ease) .25s; }
.slide.in .ring .bar { stroke-dashoffset: var(--off); }
.ring .center { position: relative; text-align: center; }
.ring .big { font-size: 3rem; font-weight: 900; line-height: 1; color: var(--tone); letter-spacing: -.03em; }
.ring .small { font-size: 1rem; color: var(--muted); margin-top: .2rem; }

/* ---------- Jar (sugar / carbs) ---------- */
.jar { width: min(46vw, 180px); overflow: visible; }
.jar .glass { fill: var(--glass); stroke: var(--muted); stroke-width: 2.5; }
.jar .lid { fill: var(--muted); opacity: .6; }
.jar .liquid { transform: translateY(160px); transition: transform 1.4s var(--ease) .3s; }
.slide.in .jar .liquid { transform: translateY(var(--y)); }
.jar .wave { animation: wave 2.6s linear infinite; }
.jar .wave.back { animation-duration: 3.8s; opacity: .55; }
@keyframes wave { from { transform: translateX(0); } to { transform: translateX(-80px); } }
.jar .limit { stroke: var(--text); stroke-width: 2; stroke-dasharray: 4 4; }
.jar .limit-label { font-size: 10px; fill: var(--text); font-weight: 700; }
.jar .shine { fill: #fff; opacity: .18; }
.bignum { font-size: 4rem; font-weight: 900; letter-spacing: -.04em; line-height: 1; color: var(--tone); }
.bignum small { font-size: 1.6rem; font-weight: 700; color: var(--muted); letter-spacing: 0; }
.xline { font-weight: 800; font-size: 1.4rem; color: var(--tone); }

/* ---------- Cubes ---------- */
.cube-scene { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.spoon { width: 120px; height: auto; color: var(--muted); margin-bottom: 18px; }
.slide.in .spoon { animation: tip .9s var(--spring) both .2s; transform-origin: 90% 50%; }
@keyframes tip { from { transform: rotate(0); } 60% { transform: rotate(-28deg); } to { transform: rotate(-22deg); } }
.cubes { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 40px; max-width: 320px; }
.cube {
  width: 26px; height: 26px; border-radius: 6px; opacity: 0;
  background: linear-gradient(145deg, #ffffff 0%, #f1f4f6 55%, #d3dae0 100%);
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.12), inset 2px 2px 0 rgba(255,255,255,.9), 0 2px 4px rgba(0,0,0,.2);
}
.cube.partial { background: linear-gradient(90deg, #ffffff var(--p), transparent var(--p)); box-shadow: none; border: 1px dashed var(--muted); }
.slide.in .cube { animation: drop .55s var(--spring) both; animation-delay: calc(var(--i) * 28ms + 500ms); }
@keyframes drop { from { opacity: 0; transform: translateY(-140px) rotate(25deg); } to { opacity: 1; transform: none; } }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: center; }
.chip { padding: .55rem 1rem; min-height: 44px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 700; font-size: 1rem; cursor: pointer; }
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ---------- Stacked composition ---------- */
.stack { width: 100%; height: 52px; display: flex; border-radius: 12px; overflow: hidden; background: var(--surface-2); }
.stack > div { height: 100%; width: 0; transition: width 1.1s var(--ease); display: grid; place-items: center; font-size: .95rem; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); overflow: hidden; white-space: nowrap; }
.slide.in .stack > div { width: var(--w); transition-delay: var(--d); }
.bg-sugar { background: linear-gradient(180deg, var(--sugar-2), var(--sugar)); }
.bg-carb { background: linear-gradient(180deg, #ffc48a, var(--carb)); }
.bg-fibre { background: linear-gradient(180deg, #86efac, var(--fibre)); }
.bg-protein { background: linear-gradient(180deg, #a5bfff, var(--protein)); }
.bg-fat { background: linear-gradient(180deg, #fbe58a, var(--fat)); }
.bg-other { background: var(--other); }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: 1rem; justify-content: center; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; background: var(--c); vertical-align: -1px; }
.c-sugar { --c: var(--sugar); } .c-carb { --c: var(--carb); } .c-fibre { --c: var(--fibre); } .c-protein { --c: var(--protein); } .c-fat { --c: var(--fat); } .c-other { --c: var(--other); }

/* ---------- Ingredients ---------- */
.ingr { width: 100%; list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.ingr li { display: flex; align-items: center; gap: .6rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .7rem .8rem; font-size: 1.05rem; text-align: left; box-shadow: var(--shadow); opacity: 0; transform: translateX(40px); }
.slide.in .ingr li { animation: slidein .6s var(--spring) both; animation-delay: calc(var(--i) * 110ms + 300ms); }
@keyframes slidein { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
.pos { flex: none; width: 2.5rem; height: 2.5rem; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: .95rem; color: #fff; background: var(--other); }
.pos.hot { background: var(--high); } .pos.warm { background: var(--warn); }
.ingr .nm { font-weight: 700; }
.ingr .kd { margin-left: auto; font-size: .85rem; color: var(--muted); white-space: nowrap; }
details.ingr-text { width: 100%; font-size: 1rem; color: var(--muted); text-align: left; }
details.ingr-text summary { cursor: pointer; text-align: center; font-weight: 600; }
details.ingr-text mark { background: color-mix(in srgb, var(--sugar) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }
.empty-art { width: 120px; color: var(--ok); }

/* ---------- Portion ---------- */
.portion { width: 100%; display: grid; gap: .6rem; }
.portion input[type=range] { width: 100%; accent-color: var(--accent); height: 36px; }
.portion .readout { font-size: 2rem; font-weight: 900; }
.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .6rem .4rem; box-shadow: var(--shadow); }
.stat .l { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.stat .v { font-size: 1.7rem; font-weight: 900; letter-spacing: -.02em; }
.stat .v small { font-size: .95rem; color: var(--muted); font-weight: 600; }

/* ---------- Claims ---------- */
.claim { position: relative; display: inline-block; font-size: 1.5rem; font-weight: 800; padding: .3rem .9rem; border: 2px dashed var(--line); border-radius: 12px; margin: .2rem; }
.claim::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 4px; background: var(--high); border-radius: 2px; transform: scaleX(0); transform-origin: left; }
.claim.noline::after { display: none; }
.slide.in .claim::after { animation: strike .5s var(--ease) both; animation-delay: calc(var(--i) * 250ms + 900ms); }
@keyframes strike { to { transform: scaleX(1); } }

/* ---------- Data ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 1rem; text-align: left; }
.data-table th, .data-table td { padding: .4rem .25rem; border-bottom: 1px solid var(--line); }
.data-table th { font-weight: 700; color: var(--muted); font-size: .9rem; }
.data-table input { width: 5.6rem; max-width: 100%; padding: .45rem .5rem; font-size: 1.05rem; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.data-table input.derived { opacity: .65; font-style: italic; }
.conf { width: 100%; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.conf i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 1s var(--ease) .3s; }
.slide.in .conf i { width: var(--w); }
.warnings { text-align: left; font-size: 1rem; color: var(--warn); padding-left: 1.1rem; margin: 0; width: 100%; }
.sizes { display: flex; gap: .8rem; justify-content: center; flex-wrap: wrap; font-size: 1rem; }
.sizes input { width: 5rem; padding: .45rem .5rem; font-size: 1.05rem; min-height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }

/* ---------- Done ---------- */
.done-art { width: 130px; }
.slide.in .done-art .check { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw .7s var(--ease) both .5s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done-actions { display: grid; gap: .6rem; width: 100%; max-width: 300px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  [data-a], .stamp, .cube, .food-wrap, .ingr li { opacity: 1; transform: none; }
}

/* ---------- Dialog ---------- */
.dialog { border: none; border-radius: var(--radius); padding: 0; margin: auto; max-height: calc(100vh - 2rem); max-height: calc(100dvh - 2rem); width: min(420px, calc(100% - 2rem)); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(0,0,0,.5); }
.dialog-body { padding: 1.3rem; display: grid; gap: .8rem; }
.dialog-body h3 { font-size: 1.15rem; font-weight: 800; }
.dialog-body input { padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.05rem; }
.row.end { justify-content: flex-end; }

/* ---------- Landing loop (10 s) ----------
   0-10%  box picked up      12-22% box turned to show the label   22-32% phone slides in
   32-56% scanning beam      56-64% result ring draws              64-84% hold   84-94% leave */
.lp-box { animation: lpBox 10s var(--ease) infinite; }
@keyframes lpBox {
  0% { transform: translateY(40px) rotate(3deg); opacity: 0; }
  10% { transform: none; opacity: 1; }
  15% { transform: translateY(-6px) rotate(-4deg); }
  22% { transform: none; }
  90% { transform: none; opacity: 1; }
  97%, 100% { transform: translateY(40px) rotate(3deg); opacity: 0; }
}
.lp-face { transform-box: fill-box; transform-origin: center; }
.lp-front { animation: lpFront 10s ease-in infinite; }
@keyframes lpFront { 0%, 12% { transform: scaleX(1); } 17%, 100% { transform: scaleX(0); } }
.lp-back { animation: lpBack 10s ease-out infinite; }
@keyframes lpBack { 0%, 17% { transform: scaleX(0); } 22%, 100% { transform: scaleX(1); } }
.lp-phone { animation: lpPhone 10s var(--ease) infinite; }
@keyframes lpPhone {
  0%, 22% { transform: translate(90px, 70px) rotate(8deg); opacity: 0; }
  32% { transform: none; opacity: 1; }
  84% { transform: none; opacity: 1; }
  94%, 100% { transform: translate(90px, 70px) rotate(8deg); opacity: 0; }
}
.lp-cam { animation: lpCam 10s linear infinite; }
@keyframes lpCam { 0%, 56% { opacity: 1; } 59%, 100% { opacity: 0; } }
.lp-corners { animation: lpCorners 1.2s ease-in-out infinite alternate; }
@keyframes lpCorners { from { opacity: .55; } to { opacity: 1; } }
.lp-beam { animation: lpBeam 10s linear infinite; }
@keyframes lpBeam {
  0%, 33% { transform: translateY(0); opacity: 0; }
  34% { opacity: 1; }
  44% { transform: translateY(172px); opacity: 1; }
  45% { transform: translateY(0); opacity: 0; }
  46% { opacity: 1; }
  56% { transform: translateY(172px); opacity: 1; }
  57%, 100% { transform: translateY(0); opacity: 0; }
}
.lp-result { animation: lpResult 10s var(--ease) infinite; transform-box: fill-box; transform-origin: center; }
@keyframes lpResult {
  0%, 56% { opacity: 0; transform: scale(.7); }
  62% { opacity: 1; transform: scale(1); }
  86% { opacity: 1; }
  90%, 100% { opacity: 0; }
}
.lp-ring { stroke-dasharray: 138.3; animation: lpRing 10s var(--ease) infinite; }
@keyframes lpRing { 0%, 58% { stroke-dashoffset: 138.3; } 68%, 100% { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  .lp-box, .lp-face, .lp-phone, .lp-cam, .lp-corners, .lp-beam, .lp-result, .lp-ring { animation: none !important; }
  .lp-box, .lp-phone { opacity: 1; transform: none; }
  .lp-front { transform: scaleX(0); } .lp-back { transform: scaleX(1); }
  .lp-cam { opacity: 0; } .lp-result { opacity: 1; transform: none; } .lp-ring { stroke-dashoffset: 0; }
}

/* ---------- Big, easy slider ---------- */
input[type=range] { -webkit-appearance: none; appearance: none; height: 48px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); margin-top: -13px; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
input[type=range]::-moz-range-track { height: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
input[type=range]::-moz-range-thumb { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.35); }

/* ---------- How-to button + modal ---------- */
.btn.howto { background: var(--surface); border: 2px solid var(--accent); color: var(--accent); gap: .5rem; }
.howto-dialog { width: min(440px, calc(100% - 1.5rem)); max-height: calc(100vh - 1.5rem); }
.howto-dialog { width: min(440px, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); }
.howto-body { padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom)); display: grid; gap: .8rem; justify-items: center; }
.howto-title { font-size: 1.4rem; font-weight: 800; }
.howto-video { width: 100%; max-height: 62vh; aspect-ratio: 9 / 16; border-radius: 14px; background: #000; object-fit: contain; }
.howto-steps { color: var(--muted); font-size: 1rem; text-align: center; margin: 0; }
.howto-steps b { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .95rem; margin-right: .2rem; }
.howto-close { width: 100%; max-width: 320px; }

/* ---------- Photo quality warning ---------- */
.quality { width: 100%; max-width: 360px; background: var(--warn-bg, #fdf1dc); color: var(--text); border: 2px solid var(--warn); border-radius: 16px; padding: 1rem; display: grid; gap: .5rem; justify-items: center; text-align: center; }
.quality-title { font-size: 1.25rem; font-weight: 800; color: var(--warn); }
.quality-tip { font-size: 1rem; line-height: 1.4; }
.thumb.bad { outline: 3px solid var(--warn); }
.quality-badge { width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; font-size: 3.2rem; font-weight: 900; background: var(--warn); color: #fff; }
.btn.speak { gap: .4rem; font-size: 1.05rem; }
:root { --warn-bg: #fdf1dc; }
@media (prefers-color-scheme: dark) { :root { --warn-bg: #3a2c0c; } }

/* ---------- Language switch ---------- */
.lang-btn { gap: .35rem; font-weight: 800; background: var(--surface); }
.home-lang { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 6; padding: .5rem .9rem; min-height: 44px; }
.lang-body { gap: .5rem; }
.lang-row { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 60px; padding: .8rem 1.1rem; border-radius: 14px; border: 2px solid var(--line); background: var(--surface-2); font-size: 1.25rem; font-weight: 800; cursor: pointer; text-align: left; }
.lang-row.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.lang-row.active::after { content: "✓"; color: var(--accent); font-size: 1.4rem; }

/* ---------- Daily tally ---------- */
.today-strip { width: 100%; max-width: 360px; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: .6rem .9rem; margin: -.4rem 0 .9rem; cursor: pointer; text-align: left; display: grid; gap: .4rem; box-shadow: var(--shadow); color: var(--text); font-weight: 700; font-size: 1rem; }
.today-bar { display: block; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.today-bar b { display: block; height: 100%; width: 0; background: var(--ok); transition: width .6s var(--ease); }
.today-bar b.warn { background: var(--warn); } .today-bar b.high { background: var(--high); }
.tally { width: 100%; display: grid; gap: .7rem; }
.tally .ring { width: min(48vw, 180px); margin: 0 auto; }
.tally .ring .big { font-size: 2.2rem; }
.tally-entries { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; width: 100%; }
.tally-entries li { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: .6rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .5rem .7rem; text-align: left; }
.tally-entries .nm { grid-column: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally-entries .sm { grid-column: 1; color: var(--muted); font-size: .9rem; }
.tally-entries button { grid-column: 2; grid-row: 1 / span 2; width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 1rem; }
.tally-add { width: 100%; display: grid; gap: .5rem; }
.tally-add .readout { font-size: 1.7rem; font-weight: 900; text-align: center; }
.today-panel-sum { text-align: center; margin-bottom: .8rem; }
.today-panel-sum .big { font-size: 2rem; font-weight: 900; }

/* ---------- Barcode ---------- */
.barcode { background: var(--bg); overflow-y: auto; }
.barcode-stage { position: relative; width: 100%; max-height: 42vh; aspect-ratio: 4 / 3; background: #000; display: grid; place-items: center; }
.barcode-stage video { width: 100%; height: 100%; object-fit: cover; }
.barcode-frame { position: absolute; left: 12%; right: 12%; top: 28%; bottom: 28%; border: 3px solid var(--accent-2); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.barcode-frame::after { content: ""; position: absolute; left: 4%; right: 4%; top: 50%; height: 2px; background: var(--high); opacity: .8; animation: barline 1.4s ease-in-out infinite alternate; }
@keyframes barline { from { transform: translateY(-38px); } to { transform: translateY(38px); } }
.barcode-body { padding: 1rem 1.2rem max(1.2rem, env(safe-area-inset-bottom)); display: grid; gap: .7rem; justify-items: center; text-align: center; max-width: 480px; margin: 0 auto; width: 100%; }
.scan-title-plain { font-weight: 800; font-size: 1.3rem; }
.barcode-form { display: grid; gap: .5rem; width: 100%; }
.barcode-form input { width: 100%; padding: .8rem 1rem; font-size: 1.6rem; font-weight: 800; letter-spacing: .08em; text-align: center; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); min-height: 60px; }
.barcode-stage.off { display: none; }
.barcode-body .status { min-height: 2.8rem; }

/* ---------- Family sharing ---------- */
.fam { display: grid; gap: .8rem; }
.fam-code { font-size: 2.6rem; font-weight: 900; letter-spacing: .18em; text-align: center; background: var(--surface-2); border: 2px dashed var(--accent); border-radius: 16px; padding: .8rem; }
.fam-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.fam-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem .6rem; align-items: center; background: var(--surface-2); border-radius: 12px; padding: .5rem .7rem; }
.fam-list .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fam-list .when { grid-column: 1; color: var(--muted); font-size: .85rem; }
.fam-list .pill { grid-column: 2; grid-row: 1 / span 2; }
.fam-form { display: grid; gap: .6rem; }
.fam-form label { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem; font-weight: 700; }
.fam-form input { width: 6rem; padding: .55rem .6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.1rem; font-weight: 700; text-align: right; }
.fam-code-input { width: 100%; padding: .8rem; font-size: 1.8rem; font-weight: 800; letter-spacing: .25em; text-align: center; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); }
.fam-badge { display: inline-block; background: var(--ok); color: #fff; font-weight: 800; border-radius: 999px; padding: .2rem .7rem; font-size: .9rem; }

/* ---------- Picture foods (meal plate, fructose apples) ---------- */
.slide .lead.strong { font-weight: 800; }
.foods-wrap { width: 100%; display: flex; justify-content: center; }
.foods { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; min-height: 48px; max-width: 330px; }
.food-wrap { position: relative; width: 48px; height: 48px; opacity: 0; }
.foods.few .food-wrap { width: 78px; height: 78px; }
.foods.some .food-wrap { width: 60px; height: 60px; }
.food-wrap .food { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 2px 3px rgba(0,0,0,.18)); }
.food-wrap.partial .food:first-child { opacity: .3; filter: grayscale(1); }
.food-wrap.partial .food:last-child { clip-path: inset(0 calc(100% - var(--p)) 0 0); }
.slide.in .food-wrap { animation: drop .6s var(--spring) both; animation-delay: calc(var(--i) * 70ms + 450ms); }

.plate-scene { width: 100%; display: flex; justify-content: center; }
.plate { width: min(78vw, 300px); position: relative; display: grid; place-items: center; }
.plate svg { width: 100%; height: auto; overflow: visible; }
.plate .cutlery { fill: none; stroke: var(--muted); stroke-width: 5; opacity: .55; }
.plate .rim { fill: var(--surface); stroke: var(--line); stroke-width: 3; filter: drop-shadow(0 6px 10px rgba(0,0,0,.14)); }
.plate .dish { fill: var(--surface-2); }
.plate .edge { fill: none; stroke: var(--line); stroke-width: 2; }
.plate .pie { fill: none; stroke: var(--tone); stroke-width: 54; opacity: .92; stroke-dasharray: var(--c); stroke-dashoffset: var(--c); transition: stroke-dashoffset 1.4s var(--ease) .35s; }
.slide.in .plate .pie { stroke-dashoffset: var(--off); }
.plate-x { position: absolute; font-size: 2.4rem; font-weight: 900; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.45); opacity: 0; }
.slide.in .plate-x { animation: pop .5s var(--spring) both 1.5s; }
.slide.in .plate { animation: rise .7s var(--ease) both; }

.curve { width: 100%; max-width: 360px; overflow: visible; }
.curve .ax { stroke: var(--line); stroke-width: 2; }
.curve .ghost { fill: none; stroke: var(--muted); stroke-width: 3; opacity: .22; stroke-linecap: round; }
.curve .live { fill: none; stroke: var(--tone); stroke-width: 7; stroke-linecap: round; stroke-dasharray: 720; stroke-dashoffset: 720; filter: drop-shadow(0 3px 6px rgba(0,0,0,.18)); }
.slide.in .curve .live { animation: drawcurve 1.7s var(--ease) both .3s; }
@keyframes drawcurve { to { stroke-dashoffset: 0; } }
.curve .peak { fill: var(--tone); stroke: var(--surface); stroke-width: 3; opacity: 0; transform-box: fill-box; transform-origin: center; }
.slide.in .curve .peak { animation: peakpop .6s var(--spring) both 1.6s, throb 1.6s ease-in-out infinite 2.2s; }
@keyframes peakpop { from { opacity: 0; transform: scale(0); } to { opacity: 1; transform: scale(1); } }
@keyframes throb { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.35); } }
.curve .lbl { font-size: 11px; font-weight: 800; fill: var(--muted); letter-spacing: .04em; }

/* ---------- Today page: three big choices, then a tick ---------- */
.portions { width: 100%; display: grid; gap: .6rem; }
.btn.portion { display: grid; gap: .15rem; text-align: left; padding: .9rem 1.1rem; min-height: 64px; border-width: 2px; }
.portion-name { font-size: 1.3rem; font-weight: 800; }
.portion-sub { font-size: .95rem; color: var(--muted); font-weight: 600; }
.portion-carbs { font-size: .95rem; color: var(--accent); font-weight: 700; }
.row.wrap { flex-wrap: wrap; justify-content: center; }
.stepper-wrap { width: 100%; display: grid; gap: .6rem; justify-items: center; }
.stepper { display: flex; align-items: center; gap: .8rem; }
.stepper .readout { font-size: 1.5rem; font-weight: 900; min-width: 7ch; text-align: center; }
.stepper .step { width: 60px; height: 60px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); color: var(--text); font-size: 2rem; font-weight: 800; cursor: pointer; }

/* ---------- Tip of the day ---------- */
.tip-btn { position: absolute; right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); z-index: 5; touch-action: none; transition: left .25s var(--ease), right .25s var(--ease), top .25s var(--ease); min-height: 52px; padding: 0 1rem 0 .8rem; border-radius: 999px; border: none; background: var(--surface); color: var(--text); font: inherit; font-weight: 800; font-size: 1.05rem; box-shadow: var(--shadow); cursor: pointer; display: flex; align-items: center; gap: .35rem; }
.tip-btn span[aria-hidden] { font-size: 1.4rem; }
.tip-btn.dragging { transition: none; opacity: .9; transform: scale(1.06); }
.home-inner { padding-bottom: max(5rem, calc(env(safe-area-inset-bottom) + 4.2rem)); }
.tip-dialog { width: min(460px, calc(100% - 1.5rem)); max-height: calc(100vh - 1.5rem); }
.tip-dialog { width: min(460px, calc(100% - 1.5rem)); max-height: calc(100dvh - 1.5rem); }
.tip-body { display: flex; flex-direction: column; max-height: calc(100vh - 1.5rem); gap: .6rem; }
.tip-body { display: flex; flex-direction: column; max-height: calc(100dvh - 1.5rem); gap: .6rem; }
.tip-card { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; gap: .6rem; align-content: start; padding-right: .2rem; }
.tip-name { font-size: 1.35rem; font-weight: 800; }
.tip-meals { list-style: none; padding: 0; margin: 0; display: grid; gap: .55rem; }
.tip-meals li { display: grid; gap: .1rem; background: var(--surface-2); border-radius: 14px; padding: .6rem .8rem; }
.tip-meal { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.tip-dish { font-size: 1.1rem; font-weight: 700; line-height: 1.3; }
.tip-carbs { font-size: .95rem; color: var(--accent); font-weight: 700; }
.tip-total { font-weight: 800; font-size: 1.05rem; }
.tip-total.ok { color: var(--ok); } .tip-total.warn { color: var(--warn); }
.tip-tip { font-size: 1.05rem; line-height: 1.4; background: var(--bg-2); border-radius: 12px; padding: .6rem .8rem; }
.tip-actions { display: grid; gap: .5rem; }

/* ---------- Kitchen: build a plate ---------- */
.kitchen { background: var(--bg); overflow-y: auto; }
.kitchen-body { padding: .2rem 1.2rem max(1.5rem, env(safe-area-inset-bottom)); display: grid; gap: .7rem; justify-items: center; text-align: center; max-width: 480px; margin: 0 auto; width: 100%; }
.kitchen-body .lead { font-size: 1.15rem; max-width: 32ch; }
.kitchen .plate-scene { position: relative; }
.kitchen .plate .pie { stroke-dashoffset: var(--off); }
.plate-food { position: absolute; inset: 0; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 2px; padding: 22% 26%; pointer-events: none; }
.plate-emoji { font-size: 1.9rem; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
#plate-rows { width: 100%; display: grid; gap: .8rem; }
.plate-row-title { text-align: left; font-weight: 800; font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: .35rem; }
.plate-items { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.plate-item { display: grid; justify-items: center; gap: .1rem; padding: .55rem .3rem; min-height: 88px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.plate-item.active { border-color: var(--accent); background: var(--bg-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.plate-item-emoji { font-size: 2rem; line-height: 1.1; }
.plate-item-name { font-weight: 700; font-size: .92rem; line-height: 1.15; }
.plate-item-carbs { font-size: .8rem; color: var(--muted); font-weight: 700; }
.kitchen-notes { width: 100%; }
.kitchen-notes textarea { width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.05rem; resize: vertical; }
.kitchen-result { width: 100%; text-align: left; display: grid; gap: .7rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.kitchen-result h2 { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.kitchen-result h3 { font-size: 1.25rem; font-weight: 800; }
.kitchen-result .lead { max-width: none; }
.kitchen-swap { background: var(--bg-2); border-radius: 12px; padding: .6rem .8rem; font-size: 1.05rem; line-height: 1.4; }
.recipe { display: grid; gap: .6rem; }
.recipe-part ul, .recipe-part ol { margin: .3rem 0 0 1.3rem; padding: 0; display: grid; gap: .35rem; font-size: 1.08rem; line-height: 1.4; }
.recipe-part ol li::marker { font-weight: 800; color: var(--accent); }
.kitchen-result .done-actions { max-width: none; }

/* ---------- Market basket ---------- */
.basket { position: relative; width: 200px; margin: 0 auto; }
.basket.small { width: 96px; }
.basket.tiny { width: 76px; }
.basket-svg { display: block; width: 100%; height: auto; }
.basket-foods { position: absolute; left: 12%; right: 12%; top: -14%; height: 46%; display: flex; justify-content: center; align-items: flex-end; }
.basket-food { width: 26%; margin: 0 -4%; }
.basket-food .food { width: 100%; height: auto; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); }
.basket-food.over .food { filter: grayscale(.5) drop-shadow(0 2px 2px rgba(0,0,0,.25)); opacity: .85; }
.basket-food { animation: drop .6s var(--spring) both; animation-delay: calc(var(--i) * 90ms); }
.basket-strip { display: flex; align-items: center; gap: .6rem; width: 100%; max-width: 360px; padding: .5rem .8rem; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-align: left; }
.basket-strip .basket { margin: 0; flex: none; }
.basket-text { font-weight: 700; font-size: 1rem; line-height: 1.3; }
.basket-panel { margin-top: 1rem; display: grid; gap: .6rem; }
.basket-panel h3 { font-size: 1.05rem; font-weight: 800; }
.basket-weeks { display: flex; flex-wrap: wrap; gap: .8rem; }
.basket-week { display: grid; justify-items: center; gap: .2rem; width: 76px; }
.basket-week .basket { margin: 0; }
/* ---------- A word from the family ---------- */
.cheer-card { width: 100%; max-width: 360px; background: var(--surface); border: 2px solid var(--accent); border-radius: 18px; padding: .8rem 1rem; display: grid; gap: .4rem; text-align: center; box-shadow: var(--shadow); }
.cheer-from { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 800; }
.cheer-text { font-size: 1.25rem; font-weight: 700; line-height: 1.35; }
.cheer-card .btn { justify-self: center; }
.cheer-list { display: grid; gap: .3rem; margin-top: .8rem; }
.cheer-list h3 { font-size: 1.05rem; font-weight: 800; }
.cheer-line { font-size: 1rem; line-height: 1.4; }
.cheer-form { display: grid; gap: .5rem; }
.cheer-form input { width: 100%; padding: .7rem .8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.05rem; }

/* ---------- Trends ---------- */
.trends { display: grid; gap: .6rem; margin-top: 1rem; }
.trends h3, .trends-panel h3 { font-size: 1.05rem; font-weight: 800; }
.trend { display: grid; gap: .4rem; }
.trend-chart { width: 100%; height: auto; overflow: visible; }
.trend-budget { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: .7; }
.trend-lbl { font-size: 11px; font-weight: 700; fill: var(--muted); }
.trend-lbl.today { fill: var(--accent); font-size: 8px; }
.trend-num { font-size: 12px; font-weight: 800; fill: var(--text); }
.trend-day { cursor: pointer; outline: none; }
.trend-day .bar { fill: var(--muted); }
.trend-day.ok .bar { fill: var(--ok); } .trend-day.warn .bar { fill: var(--warn); } .trend-day.high .bar { fill: var(--high); }
.trend-day .bar.empty { fill: var(--line); }
.trend-day.active .bar, .trend-day:focus-visible .bar { stroke: var(--text); stroke-width: 2; }
.trend-chart.weeks .bar.track { fill: var(--surface-2); }
.trend-chart.weeks .bar.within { fill: var(--ok); }
.trend-chart.weeks .bar.over { fill: var(--warn); }
.trend-detail { display: grid; gap: .3rem; }
.trend-detail-title { font-weight: 800; }
.trend-detail ul { margin: 0 0 0 1.2rem; padding: 0; display: grid; gap: .2rem; font-size: 1rem; line-height: 1.35; }

/* ---------- Daily reminder ---------- */
#set-reminder-time { padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--text); font: inherit; font-size: 1.15rem; font-weight: 700; }
#reminder-extra .field-row { flex-wrap: wrap; gap: .6rem; }
#reminder-status { display: block; margin-top: .3rem; }

/* ---------- My meal (photo or spoken) and voice input ---------- */
.meal-row { width: 100%; max-width: 360px; }
.meal-row .btn { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: .1rem; padding: .7rem .4rem; font-size: 1rem; line-height: 1.15; text-align: center; }
.meal-row .btn span[aria-hidden] { font-size: 1.5rem; }
.meal-photo { width: min(100%, 300px); aspect-ratio: 4 / 3; object-fit: cover; border-radius: 18px; box-shadow: var(--shadow); }
.meal-say { width: 100%; display: grid; gap: .6rem; justify-items: center; }
.meal-say h2 { font-size: 1.5rem; font-weight: 800; }
.meal-say textarea { width: 100%; padding: .8rem; border: 2px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--text); font: inherit; font-size: 1.15rem; resize: vertical; }
.btn.mic.listening { background: var(--high); color: #fff; border-color: transparent; animation: micpulse 1.2s ease-in-out infinite; }
@keyframes micpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(224,52,75,.45); } 50% { box-shadow: 0 0 0 10px rgba(224,52,75,0); } }
#btn-kitchen-mic { justify-self: start; margin-top: .4rem; }
.meal-result { width: 100%; display: grid; gap: .7rem; justify-items: center; text-align: center; }
.meal-result h2 { font-size: 1.6rem; font-weight: 800; line-height: 1.2; }
.meal-items { list-style: none; padding: 0; margin: 0; width: 100%; display: grid; gap: .4rem; }
.meal-items li { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--warn); border-radius: 12px; padding: .5rem .8rem; text-align: left; }
.meal-items li.fast { border-left-color: var(--high); } .meal-items li.slow, .meal-items li.low { border-left-color: var(--ok); }
.meal-items .nm { font-weight: 700; font-size: 1.05rem; }
.meal-items .sm { color: var(--muted); font-size: .95rem; white-space: nowrap; }
.meal-kind { width: 100%; display: grid; gap: .3rem; justify-items: center; }
.meal-kind .curve { max-width: 300px; }
.meal-kind .curve .live { animation: none; stroke-dashoffset: 0; }
.meal-kind .curve .peak { opacity: 1; animation: none; }
.meal-result .portions { max-width: 420px; }

/* ---------- Thinking, offline, saved ---------- */
.thinking { display: grid; justify-items: center; gap: .5rem; padding: .6rem 0; width: 100%; }
.thinking .pot { width: 110px; height: auto; overflow: visible; }
.thinking .steam { fill: none; stroke: var(--muted); stroke-width: 4; stroke-linecap: round; opacity: 0; animation: steam 1.8s ease-in-out infinite; }
.thinking .steam.s2 { animation-delay: .5s; } .thinking .steam.s3 { animation-delay: 1s; }
@keyframes steam { 0% { opacity: 0; transform: translateY(6px); } 40% { opacity: .8; } 100% { opacity: 0; transform: translateY(-14px); } }
.thinking .pot rect:first-of-type { transform-origin: 60px 88px; animation: potwobble 2.4s ease-in-out infinite; }
@keyframes potwobble { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(1.5deg); } }
.thinking-line { font-size: 1.15rem; font-weight: 700; text-align: center; min-height: 1.5em; }
.thinking-bar { width: min(100%, 260px); height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.thinking-bar i { display: block; width: 40%; height: 100%; border-radius: 999px; background: var(--accent); animation: slidebar 1.4s ease-in-out infinite; }
@keyframes slidebar { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
.offline-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 60; background: var(--high); color: #fff; font-weight: 700; text-align: center; padding: .55rem 1rem calc(.55rem); padding-top: max(.55rem, env(safe-area-inset-top)); font-size: 1rem; }
.saved-recipes { width: 100%; display: grid; gap: .5rem; text-align: left; margin-top: .4rem; }
.saved-recipes h3 { font-size: 1.05rem; font-weight: 800; }
.saved-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.saved-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .5rem; align-items: center; }
.saved-open { text-align: left; padding: .7rem .9rem; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; font-size: 1.05rem; line-height: 1.25; cursor: pointer; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.saved-x { width: 44px; height: 44px; border-radius: 50%; border: none; background: var(--surface-2); color: var(--text); cursor: pointer; font-size: 1rem; }
@media (prefers-reduced-motion: reduce) { .thinking .steam, .thinking-bar i, .thinking .pot rect { animation: none !important; opacity: 1; } }

/* ---------- Everyone's kitchen: the spinning shelf ---------- */
.seg { display: flex; width: 100%; background: var(--surface-2); border-radius: 999px; padding: 4px; gap: 4px; }
.seg-btn { flex: 1; min-height: 48px; border: none; border-radius: 999px; background: transparent; color: var(--text); font: inherit; font-weight: 800; font-size: 1.02rem; cursor: pointer; }
.seg-btn.active { background: var(--surface); box-shadow: var(--shadow); color: var(--accent); }
#everyone-panel { width: 100%; display: grid; gap: .6rem; justify-items: center; }
.shelf-stage { width: 100%; height: 330px; perspective: 1100px; perspective-origin: 50% 40%; touch-action: pan-y; overflow: hidden; border-radius: 22px; background: radial-gradient(120% 90% at 50% 100%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%); position: relative; }
.shelf-stage::after { content: ""; position: absolute; left: 6%; right: 6%; bottom: 26px; height: 10px; border-radius: 999px; background: #b9782f; box-shadow: 0 10px 20px rgba(0,0,0,.22); }
.shelf { position: absolute; left: 50%; top: 24px; width: 220px; height: 250px; margin-left: -110px; transform-style: preserve-3d; transition: transform .7s var(--ease); }
.card3d { position: absolute; inset: 0; border-radius: 20px; background: var(--surface); border: 2px solid var(--line); box-shadow: 0 14px 28px rgba(0,0,0,.18); display: grid; align-content: center; justify-items: center; gap: .3rem; padding: 1rem; text-align: center; cursor: pointer; transition: opacity .5s, filter .5s; backface-visibility: hidden; }
.card3d.plan { background: linear-gradient(160deg, var(--surface), var(--bg-2)); }
.card3d.front { border-color: var(--accent); }
.card3d.near { opacity: .8; filter: saturate(.8); }
.card3d.far { opacity: .35; filter: blur(1px) saturate(.6); }
.card3d-emoji { font-size: 2.3rem; line-height: 1; letter-spacing: .05em; white-space: nowrap; }
.card3d-name { font-weight: 800; font-size: 1.1rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card3d-stars { color: #f59e0b; font-size: 1.3rem; letter-spacing: .05em; }
.card3d-count { color: var(--muted); font-size: .9rem; font-weight: 700; }
.shelf-nav { width: 100%; }
.shelf-nav .btn { flex: 1 1 0; min-width: 0; }
.shelf-nav .btn:first-child, .shelf-nav .btn:last-child { flex: 0 0 64px; font-size: 1.8rem; }
.shelf-caption { text-align: center; min-height: 3rem; }
.shelf-name { font-weight: 800; font-size: 1.2rem; }
.rate-box { display: grid; gap: .4rem; justify-items: center; width: 100%; }
.stars { display: flex; gap: .35rem; }
.star { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--line); background: var(--surface); color: var(--line); font-size: 1.8rem; line-height: 1; cursor: pointer; }
.star.on { color: #f59e0b; border-color: #f59e0b; background: color-mix(in srgb, #f59e0b 12%, var(--surface)); }
.saved-list li.wide { grid-template-columns: minmax(0, 1fr) auto auto; }
.recipe-body { display: grid; gap: .7rem; width: 100%; text-align: left; }
#recipe-detail .recipe-body h2 { font-size: 1.5rem; font-weight: 800; }
@media (prefers-reduced-motion: reduce) { .shelf { transition: none; } }

/* ---------- Home groups and welcome ---------- */
.home-group { width: 100%; max-width: 360px; display: grid; gap: .45rem; }
.group-title { text-align: left; font-size: .85rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding-left: .2rem; }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.btn.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem; min-height: 104px; padding: .7rem .5rem; border-radius: 20px; border: 1px solid #e0cfb3; background: linear-gradient(#fffbf3, #f6ecd9); box-shadow: inset 0 1px 0 #fff, 0 6px 16px rgba(90,60,30,.12); font-size: 1rem; line-height: 1.15; text-align: center; color: var(--text); }
.btn.tile:active { transform: translateY(1px); box-shadow: inset 0 1px 0 #fff, 0 3px 8px rgba(90,60,30,.12); }
.tile-ico { display: grid; place-items: center; height: 52px; }
.tile-ico svg { width: 52px; height: 52px; overflow: visible; }
.group-title { color: var(--wood); }
.howto-ico { width: 26px; height: 26px; vertical-align: middle; }
.tip-ico { width: 28px; height: 28px; }
.tab-ico svg { width: 30px; height: 30px; }
@media (prefers-color-scheme: dark) { .btn.tile { background: linear-gradient(#3a3129, #2c251f); border-color: #4a3f35; box-shadow: none; } .home { background: linear-gradient(#241e18, var(--bg) 40%, #1f2318); } .countryside { opacity: .35; } }
.welcome-dialog { width: min(420px, calc(100% - 1.5rem)); }
.welcome-body { text-align: center; gap: .9rem; grid-template-columns: minmax(0, 1fr); }
.welcome-step, .welcome-body > * { min-width: 0; max-width: 100%; }
.welcome-step { display: grid; gap: .8rem; justify-items: center; }
.welcome-img { display: block; width: min(100%, 300px); height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 18px; box-shadow: var(--shadow); }
.welcome-body h3 { font-size: 1.5rem; }
.welcome-body .lead { max-width: 30ch; margin: 0 auto; }
.btn.choice { width: 100%; max-width: 320px; justify-content: flex-start; gap: .6rem; }
.btn.choice.on { border-color: var(--accent); background: var(--bg-2); }
.welcome-dots { display: flex; gap: .4rem; justify-content: center; }
.welcome-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.welcome-dots i.on { width: 26px; background: var(--accent); }
#wl-next { width: 100%; max-width: 320px; margin: 0 auto; }

html.big .card3d-name { font-size: .95rem; }
html.big .card3d-emoji { font-size: 2rem; }

/* ---------- Cooking show ---------- */
#show-panel { width: 100%; display: grid; gap: .7rem; justify-items: center; }
.show-feed { width: 100%; display: grid; gap: 1.2rem; }
.show-item { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.show-item video { display: block; width: 100%; aspect-ratio: 9 / 16; max-height: 72vh; object-fit: cover; background: #000; }
.show-body { padding: 1rem 1.1rem 1.1rem; display: grid; gap: .7rem; text-align: left; }
.show-body .recipe-body h2 { font-size: 1.35rem; }

/* ---------- Cooking show reel (Shorts style) ---------- */
.showfeed { background: #000; color: #fff; }
.reel-top { position: absolute; top: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: max(12px, env(safe-area-inset-top)) 14px 8px; background: linear-gradient(rgba(0,0,0,.55), transparent); }
.reel-top .home-btn { background: rgba(255,255,255,.18); color: #fff; white-space: nowrap; }
.reel-title { font-weight: 800; font-size: 1rem; white-space: nowrap; text-shadow: 0 1px 4px rgba(0,0,0,.6); }
.reel-top .btn { white-space: nowrap; }
.reel { position: absolute; inset: 0; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; }
.reel::-webkit-scrollbar { display: none; }
.reel-item { position: relative; height: 100%; scroll-snap-align: start; scroll-snap-stop: always; background: #000; }
.reel-item video { display: block; width: 100%; height: 100%; object-fit: cover; }
.reel-overlay { position: absolute; left: 0; right: 92px; bottom: 0; padding: 2.2rem 1rem calc(.9rem + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.6) 60%); display: grid; gap: .25rem; }
.reel-name { font-size: 1.25rem; font-weight: 800; line-height: 1.15; text-shadow: 0 1px 6px rgba(0,0,0,.7); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reel-carbs { font-weight: 700; font-size: .95rem; color: #9be7d9; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.reel-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.reel-actions .btn { color: #fff; border-color: rgba(255,255,255,.35); background: rgba(255,255,255,.14); }
.reel-actions .btn.primary { background: var(--accent); border-color: transparent; }
.reel-hint { font-size: .8rem; opacity: .75; }
.reel-rail { position: absolute; right: 10px; bottom: calc(1.4rem + env(safe-area-inset-bottom)); display: grid; gap: .6rem; justify-items: center; z-index: 3; }
.rail-btn { width: 66px; min-height: 66px; padding: .35rem 0; border-radius: 18px; border: none; background: rgba(0,0,0,.45); color: #fff; font: inherit; font-weight: 800; font-size: .78rem; line-height: 1.1; display: grid; justify-items: center; gap: .15rem; cursor: pointer; backdrop-filter: blur(4px); }
.rail-btn.primary { background: var(--accent); }
.rail-ico { font-size: 1.55rem; line-height: 1; }
.rail-lbl { max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reel-side { position: absolute; right: 14px; top: calc(max(12px, env(safe-area-inset-top)) + 58px); z-index: 4; display: grid; gap: .5rem; justify-items: end; }
.sound-btn { min-height: 46px; padding: 0 14px; border-radius: 999px; border: none; background: rgba(0,0,0,.45); color: #fff; font: inherit; font-weight: 800; white-space: nowrap; cursor: pointer; }
.sound-btn.make-btn { background: var(--accent); }
.reel-status { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 1rem; padding: 2rem; text-align: center; z-index: 3; }
.reel-msg { font-size: 1.2rem; font-weight: 700; max-width: 28ch; }
.sheet { width: min(520px, 100%); max-height: 88vh; margin-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
.sheet-body { max-height: 88vh; overflow-y: auto; }
@media (min-width: 560px) { .sheet { margin-bottom: auto; border-radius: var(--radius); } }
.showfeed .home-btn { min-height: 44px; }

/* ---------- What's inside facts ---------- */
.facts { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.facts li { display: flex; justify-content: space-between; gap: .8rem; padding: .45rem 0; border-top: 1px solid var(--line); font-size: 1rem; }
.facts li b { text-align: right; }

.says { margin: 1rem 0 0; padding: .8rem 1rem; border-left: 4px solid var(--accent); background: var(--straw, #f6f1e4); border-radius: 0 12px 12px 0; font-size: 1.05rem; }
.says p { margin: .3rem 0 0; }

.show-ico { width: 30px; height: 30px; vertical-align: middle; overflow: visible; margin-top: -3px; }
.reel-title .show-ico { width: 26px; height: 26px; }

.cube-row { display: flex; flex-wrap: wrap; gap: 4px; margin: .25rem 0; }
.cube-row i { display: block; width: 16px; height: 16px; border-radius: 4px; background: #fff; border: 1.5px solid #c9b99a; box-shadow: inset 0 -4px 0 #ece3d0, 0 1px 3px rgba(0,0,0,.35); }
.cube-row i.half { width: 8px; }
.cube-row b { color: #fff; font-size: 1rem; line-height: 16px; }
.reel-overlay .cube-row i { border-color: rgba(0,0,0,.25); }

.show-card { margin-top: .9rem; width: 100%; max-width: 320px; padding: .8rem .9rem; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); display: grid; gap: .45rem; justify-items: center; text-align: center; }
.show-card-head { display: flex; align-items: center; gap: .4rem; font-size: 1.05rem; }
.show-card .fine { margin: 0; }
.show-card .btn { width: 100%; }

.glucose-panel { margin-top: 1rem; }
.glu-input { width: 6.5em; font: inherit; font-size: 1.35rem; font-weight: 800; padding: .5rem .7rem; border-radius: 14px; border: 2px solid #e2d3bb; background: #fff; }
.glu-unit { font: inherit; font-size: 1rem; padding: .35rem .5rem; border-radius: 10px; border: 1.5px solid #e2d3bb; background: #fff; }
.glu-list { list-style: none; padding: 0; margin: .6rem 0 0; }
.glu-list li { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; padding: .35rem 0; border-bottom: 1px solid #e2d3bb; }
.glu-chart { width: 100%; height: auto; display: block; margin-top: .3rem; }
.glu-lbl { font-size: 10px; fill: var(--muted); }
.check-list { text-align: left; max-width: 34ch; padding-left: 1.2rem; font-size: 1.1rem; line-height: 1.4; }
.check-list li { margin: .3rem 0; }
.clips-list { display: grid; gap: .6rem; }
.clip-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: .5rem .7rem; align-items: center; background: var(--surface); border-radius: 16px; padding: .7rem .8rem; box-shadow: var(--shadow); }
.clip-row .row { grid-column: 2; }
.clip-ico { font-size: 1.6rem; display: grid; place-items: center; }
.clip-ico .show-ico { width: 34px; height: 34px; margin: 0; }
.clip-main { min-width: 0; overflow-wrap: anywhere; }

.meal-log { margin-top: 1.4rem; }
.meal-log-list { display: grid; gap: .6rem; }
.meal-card { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: .45rem .7rem; align-items: center; background: var(--surface); border-radius: 16px; padding: .6rem .7rem; box-shadow: var(--shadow); text-align: left; }
.meal-card img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; }
.meal-card-main { min-width: 0; overflow-wrap: anywhere; }
.meal-card .row { grid-column: 2; }

.btn.howto.install { margin-top: .6rem; }
.install-ico { width: 30px; height: 30px; border-radius: 8px; }
.install-dialog { width: min(440px, calc(100% - 1.5rem)); }
.install-steps { list-style: none; padding: 0; margin: .8rem 0; display: grid; gap: .7rem; counter-reset: step; }
.install-steps li { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: .7rem; align-items: center; font-size: 1.1rem; line-height: 1.35; }
.install-steps li::before { counter-increment: step; content: counter(step); grid-row: 1 / span 1; display: none; }
.step-ico { width: 44px; height: 44px; border-radius: 14px; background: var(--surface-2); color: var(--wood); display: grid; place-items: center; }

.welcome-icon { width: 96px; height: 96px; border-radius: 22px; box-shadow: var(--shadow); }
.welcome-step .btn.install { width: 100%; }
.welcome-dots i[hidden] { display: none; }
