:root {
  --bg: #F3F5F1;
  --surface: #FFFFFF;
  --surface-2: #E8ECE5;
  --surface-3: #DCE2D8;
  --ink: #1C2420;
  --ink-2: #56625B;
  --ink-3: #85918A;
  --line: #D5DCD2;
  --primary: #2D6A4F;
  --on-primary: #FFFFFF;
  --primary-soft: #D3EADC;
  --on-primary-soft: #133A29;
  --tomato: #C8432C;
  --tomato-soft: #F7DCD4;
  --protein: #3B6DB3;
  --carbs: #CF9220;
  --fat: #BF4D6B;
  --shadow: 0 1px 2px rgba(28, 36, 32, .06), 0 6px 20px rgba(28, 36, 32, .07);
  --font: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111613;
    --surface: #1A201C;
    --surface-2: #232B26;
    --surface-3: #2E3832;
    --ink: #E3E9E4;
    --ink-2: #A1ADA5;
    --ink-3: #74807A;
    --line: #2E3832;
    --primary: #84CDA7;
    --on-primary: #0B2A1B;
    --primary-soft: #1F4433;
    --on-primary-soft: #CFEBDB;
    --tomato: #F08A72;
    --tomato-soft: #4A231B;
    --protein: #86A9E0;
    --carbs: #E8B65A;
    --fat: #E58AA2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 var(--font);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }

#view {
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 12px) 16px calc(var(--safe-b) + 108px);
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 8px;
  min-height: 48px; margin-bottom: 4px;
}
.topbar h1 { font-size: 22px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -.01em; }
.daynav { display: flex; align-items: center; justify-content: space-between; flex: 1; }
.daynav h1 { text-align: center; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: transparent; color: var(--ink-2);
  display: grid; place-items: center; flex: none;
}
.iconbtn:active { background: var(--surface-2); }
.iconbtn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn:disabled { opacity: .3; }

/* ---------- the plate ---------- */
.plate-wrap { display: grid; place-items: center; padding: 8px 0 4px; }
.plate { width: min(72vw, 260px); aspect-ratio: 1; position: relative; }
.plate svg { width: 100%; height: 100%; display: block; }
.plate .rim { fill: var(--surface); }
.plate .well { fill: var(--surface-2); }
.plate .track { fill: none; stroke: var(--surface-3); stroke-width: 10; }
.plate .arc { fill: none; stroke: var(--primary); stroke-width: 10; stroke-linecap: round; transition: stroke-dashoffset .6s cubic-bezier(.2, .8, .2, 1); }
.plate.over .arc { stroke: var(--tomato); }
.plate-center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.plate-num { font-size: clamp(40px, 13vw, 54px); font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.plate.over .plate-num { color: var(--tomato); }
.plate-label { color: var(--ink-2); font-size: 15px; margin-top: 6px; }
.plate-sub {
  display: flex; justify-content: center; gap: 28px;
  margin: 10px 0 18px; color: var(--ink-2); font-size: 14px; text-align: center;
}
.plate-sub b { display: block; color: var(--ink); font-size: 18px; font-weight: 700; }

/* ---------- macros ---------- */
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.macro { background: var(--surface); border-radius: 16px; padding: 12px 12px 14px; box-shadow: var(--shadow); }
.macro-name { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.macro-val { font-size: 17px; font-weight: 700; margin: 2px 0 8px; white-space: nowrap; }
.macro-val small { color: var(--ink-3); font-weight: 500; font-size: 13px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: currentColor; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.m-protein { color: var(--protein); }
.m-carbs { color: var(--carbs); }
.m-fat { color: var(--fat); }

/* ---------- fibre, sugars, salt ---------- */
.extras { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 14px 16px; margin-top: -8px; }
.extras > p { grid-column: 1 / -1; }
.extra-top span { display: block; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.extra-top b { display: block; font-size: 15px; font-weight: 700; margin: 1px 0 6px; white-space: nowrap; }
.extra-top small { color: var(--ink-3); font-weight: 500; font-size: 12px; }
.x-min { color: var(--primary); }
.x-max { color: var(--ink-3); }
.extra.over .x-max { color: var(--tomato); }
.extra.over b { color: var(--tomato); }

/* ---------- activity ---------- */
.act { padding: 14px 16px; }
.act-row { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.act-row b { display: block; font-size: 20px; font-weight: 700; }
.act-row span { font-size: 13px; color: var(--ink-2); }
.act-credit { color: var(--primary); }
.act .act-item { padding: 10px 2px; margin-top: 8px; }

/* ---------- meals ---------- */
.meal { background: var(--surface); border-radius: 20px; margin-bottom: 12px; box-shadow: var(--shadow); overflow: hidden; }
.meal-head { display: flex; align-items: center; padding: 6px 6px 6px 18px; min-height: 56px; }
.meal-head h2 { font-size: 17px; font-weight: 700; margin: 0; flex: 1; }
.meal-head .kcal { color: var(--ink-2); font-size: 15px; margin-right: 2px; }
.mealmore { width: 36px; height: 40px; }
.mealmore svg { fill: currentColor; stroke: none; }
.addbtn {
  width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: var(--primary-soft); color: var(--on-primary-soft);
  display: grid; place-items: center; margin-left: 8px;
}
.addbtn svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; fill: none; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 18px; border: 0; border-top: 1px solid var(--line);
  background: transparent; text-align: left;
}
.item:active { background: var(--surface-2); }
.item-main { flex: 1; min-width: 0; }
.item-name, .item-meta { display: block; }
.item-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { font-size: 13px; color: var(--ink-3); }
.item-kcal { font-weight: 600; white-space: nowrap; }
.ai-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--protein); margin-left: 6px; vertical-align: middle; }

/* ---------- cards & forms ---------- */
.card { background: var(--surface); border-radius: 20px; padding: 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { font-size: 17px; margin: 0 0 4px; }
.card p { margin: 0 0 12px; color: var(--ink-2); font-size: 15px; }
.callout { background: var(--primary-soft); color: var(--on-primary-soft); box-shadow: none; }
.callout p { color: inherit; opacity: .85; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 6px 2px; }
.input, select.input {
  width: 100%; height: 50px; padding: 0 14px;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
  font-size: 17px; appearance: none;
}
.input:focus { border-color: var(--primary); outline: none; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.with-unit { position: relative; }
.with-unit .input { padding-right: 46px; }
.with-unit em { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--ink-3); pointer-events: none; }

.btn {
  height: 52px; padding: 0 22px; border-radius: 26px; border: 0;
  background: var(--primary); color: var(--on-primary);
  font-weight: 700; font-size: 16px; width: 100%;
}
.btn:disabled { opacity: .5; }
.btn.tonal { background: var(--primary-soft); color: var(--on-primary-soft); }
.btn.text { background: transparent; color: var(--primary); }
.btn.danger { background: transparent; color: var(--tomato); }
.btn + .btn { margin-top: 8px; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 4px; margin-bottom: 12px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 36px; padding: 0 14px; border-radius: 18px;
  border: 1.5px solid var(--line); background: transparent; color: var(--ink-2);
  font-size: 15px; font-weight: 600;
}
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface-2); border-radius: 14px; padding: 4px; margin-bottom: 14px;
}
.seg button { height: 40px; border: 0; border-radius: 10px; background: transparent; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.empty { text-align: center; color: var(--ink-2); padding: 28px 12px; }
.error { color: var(--tomato); font-size: 14px; margin: -4px 0 12px 2px; }

/* ---------- lists (search results) ---------- */
.list { background: var(--surface); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); }
.list .item:first-child { border-top: 0; }
.list.flat { box-shadow: none; background: var(--surface-2); border-radius: 16px; }
.list.flat .item { border-top-color: var(--surface-3); padding: 10px 14px; }
.hint-card { background: var(--surface-2); border-radius: 16px; padding: 14px 16px; color: var(--ink-2); font-size: 14px; margin: 0; }
.seg button { font-size: 14px; }
.list-title { font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 16px 4px 8px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--surface-3); border-top-color: var(--primary); animation: spin .8s linear infinite; margin: 14px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- scanner ---------- */
.scanner {
  position: relative; border-radius: 24px; overflow: hidden; background: #000;
  aspect-ratio: 3 / 4; max-height: 56vh; width: 100%; margin-bottom: 14px;
}
#scanvideo { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-torch {
  position: absolute; top: 12px; right: 12px; height: 36px; padding: 0 14px; border-radius: 18px; border: 0;
  background: rgba(0, 0, 0, .45); color: #fff; font-weight: 600; font-size: 14px;
}
.scan-torch[aria-pressed="true"] { background: #fff; color: #000; }
.scan-frame {
  position: absolute; left: 10%; right: 10%; top: 36%; height: 26%;
  border: 3px solid rgba(255, 255, 255, .9); border-radius: 18px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); pointer-events: none;
}
.scan-hint { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; color: #fff; font-weight: 600; text-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.scan-msg { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; color: #fff; padding: 24px; }

/* ---------- weight ---------- */
.big { font-size: 48px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.big small { font-size: 20px; font-weight: 600; color: var(--ink-2); letter-spacing: 0; }
.chart { width: 100%; height: 170px; display: block; margin-top: 8px; }
.chart .ln { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .ar { fill: var(--primary); opacity: .1; }
.chart .gl { stroke: var(--ink-3); stroke-dasharray: 4 5; stroke-width: 1.5; }
.chart .pt { fill: var(--primary); }
.chart .raw { fill: none; stroke: var(--ink-3); stroke-width: 1; opacity: .5; }
.chart .dot { fill: var(--ink-3); opacity: .7; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.lg-avg { background: var(--primary); }
.lg-raw { background: var(--ink-3); opacity: .6; height: 1px !important; }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.progress { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; margin: 12px 0 6px; }
.progress i { display: block; height: 100%; background: var(--primary); border-radius: 5px; }

.kv { display: grid; grid-template-columns: 1fr auto; row-gap: 8px; font-size: 15px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; text-align: right; }
.token { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; background: var(--surface-2); padding: 12px; border-radius: 12px; margin-bottom: 10px; user-select: all; }

/* ---------- tab bar & fab ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 4px;
  padding: 8px 12px calc(var(--safe-b) + 8px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  flex: 1; max-width: 120px; display: grid; justify-items: center; gap: 2px;
  text-decoration: none; color: var(--ink-3); font-size: 12px; font-weight: 600; padding: 4px 0;
}
.tabbar svg { width: 26px; height: 26px; padding: 2px 14px; box-sizing: content-box; border-radius: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a[aria-current="page"] { color: var(--ink); }
.tabbar a[aria-current="page"] svg { background: var(--primary-soft); color: var(--on-primary-soft); }
.fab {
  position: fixed; right: max(16px, calc(50vw - 244px)); bottom: calc(var(--safe-b) + 84px); z-index: 21;
  width: 60px; height: 60px; border-radius: 20px; border: 0;
  background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; box-shadow: 0 6px 20px rgba(45, 106, 79, .35);
}
.fab svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.fab:active { transform: scale(.96); }
.fab-cam {
  bottom: calc(var(--safe-b) + 156px); width: 52px; height: 52px; border-radius: 18px;
  right: max(20px, calc(50vw - 240px));
  background: var(--primary-soft); color: var(--on-primary-soft); box-shadow: 0 4px 14px rgba(45, 106, 79, .22);
}
.fab-cam svg { width: 26px; height: 26px; stroke-linejoin: round; }

/* ---------- bottom sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 16, 12, .4); z-index: 40; animation: fade .2s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  max-width: 560px; margin: 0 auto; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 28px 28px 0 0;
  padding: 10px 20px calc(var(--safe-b) + 20px);
  animation: rise .28s cubic-bezier(.2, .8, .2, 1);
}
.sheet::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--surface-3); margin: 0 auto 14px; }
.sheet h2 { font-size: 21px; margin: 0; line-height: 1.25; }
.sheet .brand { color: var(--ink-2); margin: 2px 0 14px; }
.sheet .field .input { background: var(--surface-2); border-color: transparent; }
.sheet .field .input:focus { border-color: var(--primary); }
.nutri { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; background: var(--surface-2); border-radius: 16px; padding: 12px 6px; margin: 4px 0 16px; }
.nutri b { display: block; font-size: 19px; }
.nutri span { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.qty { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.qty .with-unit { flex: 1; }
.sheet .qty .input { background: var(--surface-2); border-color: transparent; text-align: center; font-weight: 700; font-size: 20px; padding: 0 40px; }
.sheet .qty .input:focus { border-color: var(--primary); }
.qty .iconbtn { background: var(--surface-2); color: var(--ink); width: 50px; height: 50px; border-radius: 14px; }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 96px); transform: translateX(-50%);
  z-index: 60; background: var(--ink); color: var(--bg);
  padding: 12px 20px; border-radius: 14px; font-weight: 600; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: rise .25s ease; max-width: calc(100vw - 32px);
}

/* ---------- login ---------- */
.login { min-height: calc(100dvh - 140px); display: grid; align-content: center; }
.login-mark { width: 84px; height: 84px; margin: 0 auto 16px; }
.login h1 { text-align: center; font-size: 30px; margin: 0 0 4px; letter-spacing: -.02em; }
.login p.lede { text-align: center; color: var(--ink-2); margin: 0 0 28px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- accuracy ---------- */
.acc { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .02em; padding: 1px 6px; border-radius: 6px; margin-right: 6px; vertical-align: 1px; }
.acc-pesato { background: var(--primary-soft); color: var(--on-primary-soft); }
.acc-porzione { background: color-mix(in srgb, var(--protein) 16%, transparent); color: var(--protein); }
.acc-stima, .acc-foto { background: color-mix(in srgb, var(--carbs) 18%, transparent); color: color-mix(in srgb, var(--carbs) 75%, var(--ink)); }

/* ---------- switches ---------- */
.switch-row { display: flex; align-items: center; gap: 14px; margin: 4px 0 16px; cursor: pointer; }
.switch-row > span { flex: 1; }
.switch-row b { display: block; font-size: 15px; font-weight: 600; }
.switch-row small { display: block; font-size: 13px; color: var(--ink-2); line-height: 1.35; margin-top: 1px; }
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 50px; height: 30px; border-radius: 15px; background: var(--surface-3); position: relative; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(20px); }

/* ---------- water ---------- */
.water { padding: 12px 14px 14px; margin-top: -2px; }
.water-head { display: flex; align-items: center; gap: 8px; }
.water-foot { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.water-foot .glasses { flex: 1; margin: 0; }
.water-num { white-space: nowrap; }
.water-ico svg { width: 26px; height: 26px; fill: color-mix(in srgb, var(--protein) 22%, transparent); stroke: var(--protein); stroke-width: 1.8; }
.water-num { flex: 1; }
.water-num b { font-size: 20px; font-weight: 700; }
.water-num small { color: var(--ink-3); font-size: 14px; }
.water .iconbtn { width: 38px; height: 38px; }
.water .iconbtn svg { width: 20px; height: 20px; }
.water .chip { height: 32px; padding: 0 12px; font-size: 14px; margin: 0; flex: none; }
.wplus { height: 44px; padding: 0 16px; border: 0; border-radius: 22px; background: var(--protein); color: #fff; font-weight: 700; font-size: 15px; flex: none; }
.wplus:active, .water .chip:active { transform: scale(.96); }
.glasses { display: flex; gap: 5px; margin-top: 10px; }
.glasses i { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); transition: background .25s; }
.glasses i.on { background: var(--protein); }
.water.done .glasses i.on { background: var(--primary); }

.ideabtn { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 14px; }
.ideabtn svg, .iconlabel svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.iconlabel { display: flex; align-items: center; justify-content: center; gap: 8px; }
.checkin-banner { display: block; width: 100%; text-align: left; border: 0; font: inherit; }
.checkin-banner b { display: block; font-size: 16px; margin-bottom: 2px; }
.checkin-banner span { font-size: 14px; opacity: .85; }
textarea.input.area { height: auto; min-height: 92px; padding: 12px 14px; line-height: 1.4; resize: vertical; font-size: 16px; }
.seg { grid-auto-columns: minmax(0, 1fr); }
.seg button { padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- AI review ---------- */
.review { display: grid; gap: 10px; margin-bottom: 14px; }
.ritem { background: var(--surface); border-radius: 18px; padding: 10px 8px 12px 16px; box-shadow: var(--shadow); }
.sheet .ritem { background: var(--surface-2); box-shadow: none; }
.ritem.off { opacity: .55; padding-bottom: 10px; }
.ritem-top { display: flex; align-items: center; gap: 6px; }
.ritem-top .item-name { flex: 1; white-space: normal; font-weight: 600; }
.ritem-top .iconbtn { width: 36px; height: 36px; }
.ritem-top .iconbtn svg { width: 18px; height: 18px; }
.ritem-qty { display: flex; align-items: center; gap: 8px; margin: 4px 8px 6px 0; }
.ritem-qty .iconbtn { width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); color: var(--ink); }
.sheet .ritem-qty .iconbtn { background: var(--surface); }
.ritem-qty .with-unit { width: 110px; }
.ritem-qty .input { height: 42px; text-align: center; font-weight: 700; padding: 0 30px 0 8px; }
.ritem-qty .with-unit em { right: 10px; }
.ritem-kcal { margin-left: auto; color: var(--ink-2); }
.ritem-kcal b { color: var(--ink); font-size: 17px; }
.ritem-meta { font-size: 13px; color: var(--ink-3); display: flex; align-items: center; gap: 10px; padding-right: 8px; }
.mini-check { margin-left: auto; display: flex; align-items: center; gap: 5px; color: var(--ink-2); font-weight: 600; }
.mini-check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }

/* ---------- ideas ---------- */
.idea { background: var(--surface-2); border-radius: 18px; padding: 14px 16px; margin-top: 12px; }
.idea-top { display: flex; align-items: baseline; gap: 10px; }
.idea-top h3 { flex: 1; margin: 0; font-size: 17px; line-height: 1.25; }
.idea-kcal { white-space: nowrap; color: var(--ink-2); }
.idea-kcal b { color: var(--ink); }
.macro-line { margin: 0 0 6px; font-weight: 600; }
.ings { margin: 4px 0 4px; padding-left: 18px; font-size: 14px; }
.ings li { margin: 2px 0; }
.idea details summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 14px; margin-top: 6px; }
.steps { padding-left: 18px; font-size: 14px; margin: 6px 0 0; }
.idea .btn { height: 44px; font-size: 15px; }
.idea .row .btn + .btn, .row3 .btn + .btn { margin-top: 0; }
.row .btn + .btn, .row3 .btn + .btn { margin-top: 0; }

/* ---------- progressi ---------- */
.today-score { display: flex; align-items: center; gap: 16px; }
.ring-wrap { position: relative; width: 112px; height: 112px; flex: none; }
.ring { width: 100%; height: 100%; }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 10; }
.ring-arc { fill: none; stroke: var(--primary); stroke-width: 10; stroke-linecap: round; }
.ring-num { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring-num b { font-size: 34px; font-weight: 800; line-height: 1; }
.ring-num span { font-size: 13px; color: var(--ink-3); }
.ts-side { flex: 1; min-width: 0; }
.pts { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.pt { font-size: 12px; padding: 3px 8px; border-radius: 8px; background: var(--surface-2); color: var(--ink-3); }
.pt.on { background: var(--primary-soft); color: var(--on-primary-soft); }
.pt b { font-weight: 700; }
.streak { position: relative; }
.streak .big { font-size: 40px; }
.freeze { position: absolute; top: 18px; right: 18px; display: flex; gap: 6px; }
.freeze span svg { width: 26px; height: 26px; fill: none; stroke: var(--surface-3); stroke-width: 1.8; stroke-linecap: round; }
.freeze span.on svg { stroke: var(--protein); }
.goal { margin-top: 12px; }
.goal-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.goal-top span { color: var(--ink-2); }
.goal .bar { color: var(--carbs); }
.goal.ok .bar { color: var(--primary); }
.d7s { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 16px; }
.d7 { display: grid; justify-items: center; gap: 4px; font-size: 11px; color: var(--ink-3); }
.d7-bar { width: 100%; max-width: 30px; height: 56px; border-radius: 8px; background: var(--surface-2); display: flex; align-items: flex-end; overflow: hidden; }
.d7-bar i { display: block; width: 100%; background: var(--carbs); border-radius: 8px; }
.d7-bar i.hit { background: var(--primary); }
.narr { color: var(--ink) !important; line-height: 1.55; margin: 10px 0 10px !important; }
.tip { font-size: 14px !important; background: var(--surface-2); border-radius: 14px; padding: 10px 12px; margin: 0 !important; }
.hl { margin: 8px 0 0; padding-left: 18px; color: var(--ink); }
.hl li { margin: 5px 0; }
.stack { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.stack i { display: block; height: 100%; }
.legend.wrap { flex-wrap: wrap; row-gap: 4px; margin-top: 8px; }
.legend.wrap i { width: 10px; height: 10px; border-radius: 3px; }
.s-carbs { background: var(--carbs); } .s-protein { background: var(--protein); } .s-fat { background: var(--fat); }
.s-pesato { background: var(--primary); } .s-porzione { background: var(--protein); } .s-stima { background: var(--carbs); }
.srcs { display: grid; gap: 6px; }
.src { display: grid; grid-template-columns: minmax(0, 1fr) 90px 38px; align-items: center; gap: 8px; font-size: 14px; }
.src span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src i { display: block; height: 8px; border-radius: 4px; background: var(--fat); justify-self: start; max-width: 100%; min-width: 4px; }
.src b { text-align: right; font-weight: 600; }
.badges { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.badge { background: var(--surface); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow); opacity: .5; border: 1.5px dashed var(--line); }
.badge.done { opacity: 1; border: 1.5px solid var(--primary); background: var(--primary-soft); color: var(--on-primary-soft); }
.badge b { display: block; font-size: 14px; }
.badge span { font-size: 12px; color: inherit; opacity: .75; }
.care { background: var(--tomato-soft); box-shadow: none; }
.care p { color: var(--ink) !important; margin: 0 !important; }
.rules summary { font-weight: 600; cursor: pointer; }
.rules p { margin: 10px 0 0 !important; }

/* ---------- dispensa ---------- */
.actions4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 14px; }
.actions4 button { display: grid; justify-items: center; gap: 6px; padding: 12px 4px 10px; border: 0; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; color: var(--ink); }
.actions4 button:disabled { opacity: .4; }
.actions4 svg { width: 26px; height: 26px; fill: none; stroke: var(--primary); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.exp-soon { color: var(--tomato); font-weight: 600; }
label.item { cursor: pointer; }
label.item input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); flex: none; }

/* five tabs */
.tabbar a { max-width: 96px; font-size: 11px; }
.tabbar svg { padding: 2px 10px; }

/* ---------- the little plate on Oggi ---------- */
.daytitle-wrap { display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; flex: 1; }
.daytitle-text { display: grid; justify-items: start; min-width: 0; }
.daytitle-wrap:has(.buddy[hidden]) .daytitle-text, .daytitle-wrap:not(:has(.buddy)) .daytitle-text { justify-items: center; }
.daytitle-text h1 { line-height: 1.1; }
.buddy-line { display: block; font-size: 12.5px; color: var(--ink-2); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 62vw; }
.buddy-line:empty { display: none; }
.buddy { display: block; width: 44px; height: 44px; flex: none; }
.buddy-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.b-rim { fill: var(--surface); filter: drop-shadow(0 1px 2px rgba(28, 36, 32, .12)); }
.b-track { fill: none; stroke: var(--surface-3); stroke-width: 3; }
.b-arc { fill: none; stroke: var(--primary); stroke-width: 3; stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.b-well { fill: var(--surface-2); }
.bf { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.bf-fill { fill: var(--ink); }
.bf-mouth { fill: var(--tomato); stroke: var(--ink); }
.cheek { fill: var(--tomato); opacity: .22; }
.bz { font: 700 8px var(--font); fill: var(--ink-3); }
.bz2 { font-size: 6px; }
.heart { fill: var(--tomato); opacity: .85; }
.conf { opacity: .9; }
.c1 { fill: var(--carbs); } .c2 { fill: var(--protein); } .c3 { fill: var(--fat); } .c4 { fill: var(--primary); }
.mood-assonnato .b-well { fill: var(--surface-3); }
.buddy.bounce .buddy-svg { animation: buddy-hop .9s cubic-bezier(.3, 1.6, .5, 1) 2; transform-origin: 50% 90%; }
@keyframes buddy-hop { 0%, 100% { transform: translateY(0) rotate(0); } 40% { transform: translateY(-5px) rotate(-6deg); } 70% { transform: translateY(0) rotate(4deg); } }
