/* ============================================================
   Дизайн-система мини-приложения.
   Поверхности и текст — из темы Telegram (переменные --tg-theme-*,
   их выставляет telegram-web-app.js), поэтому приложение светлое или
   тёмное вместе с Telegram. Цвета данных — проверенная категориальная
   палитра (калории, белок, жиры, углеводы, тело), у каждой свой оттенок
   для тёмной темы.
   ============================================================ */
:root {
  --page: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --card: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #0c0c10);
  --hint: var(--tg-theme-hint-color, #8d8d94);
  --accent: var(--tg-theme-button-color, #2a78d6);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --danger: var(--tg-theme-destructive-text-color, #e5484d);

  --kcal: #eb6834;   --kcal-2: #f59e3d;
  --protein: #2a78d6;
  --carbs: #1baf7a;
  --fat: #eda100;
  --body: #4a3aa7;   --body-2: #7a6cf0;
  --good: #1f9d55;
  --ghost: rgba(120, 120, 140, 0.22);

  --sep: rgba(120, 120, 140, 0.16);
  --track: rgba(120, 120, 140, 0.13);
  --press: rgba(120, 120, 140, 0.10);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.06);
  --shadow-up: 0 -8px 30px rgba(16, 24, 40, 0.10);
  --radius: 22px;
  --radius-sm: 14px;
  --num: ui-rounded, "SF Pro Rounded", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --tab-h: 64px;
}
:root[data-scheme="dark"] {
  --kcal: #d95926;   --kcal-2: #e88a2a;
  --protein: #3987e5;
  --carbs: #199e70;
  --fat: #c98500;
  --body: #9085e9;   --body-2: #b3a9ff;
  --good: #2bb36a;
  --ghost: rgba(200, 200, 220, 0.16);
  --sep: rgba(255, 255, 255, 0.08);
  --track: rgba(255, 255, 255, 0.08);
  --press: rgba(255, 255, 255, 0.06);
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-up: 0 -1px 0 rgba(255, 255, 255, 0.06);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font: 15px/1.42 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body { padding-bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.view { max-width: 560px; margin: 0 auto; padding: 14px 16px 8px; }
.view.enter > * { animation: rise .42s cubic-bezier(.2, .8, .2, 1) both; }
.view.enter > *:nth-child(2) { animation-delay: .03s; }
.view.enter > *:nth-child(3) { animation-delay: .06s; }
.view.enter > *:nth-child(4) { animation-delay: .09s; }
.view.enter > *:nth-child(5) { animation-delay: .12s; }
.view.enter > *:nth-child(n+6) { animation-delay: .15s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- заголовки ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 2px 14px; }
.top h1 { margin: 0; font-size: 28px; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em; }
.top .sub { color: var(--hint); font-size: 14px; margin-top: 3px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px;
  background: var(--card); box-shadow: var(--shadow); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip.fire { color: var(--kcal); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 4px 10px; }
.section-title h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.section-title span { color: var(--hint); font-size: 13px; }

/* ---------- карточки ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card.tight { padding: 12px 14px; }
.label { font-size: 12px; font-weight: 600; color: var(--hint); text-transform: uppercase; letter-spacing: .05em; }
.hint { color: var(--hint); font-size: 13px; }
.muted { color: var(--hint); }
.pressable { transition: transform .12s ease, background-color .12s ease; }
.pressable:active { transform: scale(.975); }

/* ---------- кнопки ---------- */
.btn {
  border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-text);
  padding: 13px 18px; font-weight: 650; font-size: 15px; transition: transform .12s ease, opacity .12s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { transform: scale(.97); }
.btn.block { width: 100%; }
.btn.soft { background: var(--track); color: var(--text); }
.btn.small { padding: 8px 13px; font-size: 14px; border-radius: 12px; font-weight: 600; }
.btn.danger { background: transparent; color: var(--danger); }
.btn.kcal { background: linear-gradient(135deg, var(--kcal-2), var(--kcal)); color: #fff; }
.btn:disabled, .btn.busy { opacity: .5; pointer-events: none; }
.icon { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.sm { width: 18px; height: 18px; }

/* ---------- полоска недели ---------- */
.week {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 12px;
  background: var(--card); border-radius: var(--radius); padding: 8px 6px; box-shadow: var(--shadow);
}
.wday { border: 0; background: none; border-radius: 14px; padding: 6px 0 7px; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: background-color .2s; }
.wday .wd { font-size: 11px; color: var(--hint); font-weight: 600; text-transform: uppercase; }
.wday .dn { font-size: 15px; font-weight: 700; }
.wday svg { width: 26px; height: 26px; }
.wday .r-bg { fill: none; stroke: var(--track); stroke-width: 4; }
.wday .r-fg { fill: none; stroke: var(--kcal); stroke-width: 4; stroke-linecap: round; }
.wday .r-fg.over { stroke: var(--danger); }
.wday .r-ok { fill: var(--good); }
.wday.sel { background: var(--text); }
.wday.sel .wd, .wday.sel .dn { color: var(--card); }
.wday.sel .r-bg { stroke: rgba(127, 127, 127, .35); }
.wday:disabled { opacity: .35; }
.wday.today .dn { color: var(--kcal); }
.wday.sel.today .dn { color: var(--card); }

/* ---------- главная карточка дня ---------- */
.hero { position: relative; overflow: hidden; padding: 18px 16px 16px; }
.hero::before {
  content: ""; position: absolute; inset: -40% -20% auto auto; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--kcal) 18%, transparent), transparent 70%);
  pointer-events: none;
}
.hero-main { display: flex; align-items: center; gap: 18px; }
.ring-wrap { position: relative; width: 148px; height: 148px; flex: none; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--track); stroke-width: 13; }
.ring-fg { fill: none; stroke: url(#kcalGrad); stroke-width: 13; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.2, .8, .2, 1); }
.ring-fg.over { stroke: var(--danger); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring-center .big { font-size: 34px; font-weight: 800; line-height: 1; }
.ring-center .cap { font-size: 12px; color: var(--hint); margin-top: 4px; font-weight: 600; }
.hero-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.hero-total { font-size: 14px; color: var(--hint); }
.hero-total b { color: var(--text); font-size: 20px; font-family: var(--num); }
.macro .mrow { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.macro .mrow span:first-child { font-weight: 600; }
.macro .mrow span:last-child { color: var(--hint); font-family: var(--num); }
.macro .mrow b { color: var(--text); }
.mbar { height: 7px; border-radius: 4px; background: var(--track); overflow: hidden; margin-top: 5px; }
.mbar i { display: block; height: 100%; border-radius: 4px; transition: width .9s cubic-bezier(.2, .8, .2, 1); }
.hero-foot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; background: var(--track); font-size: 13px; font-weight: 600; }
.pill.good { color: var(--good); }
.pill.warn { color: var(--danger); }

/* ---------- задачи дня ---------- */
.quests { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quest { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 16px; background: var(--track); font-size: 13.5px; font-weight: 600; border: 0; text-align: left; }
.quest .qi { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--card); flex: none; font-size: 14px; }
.quest.done { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.quest.done .qi { background: var(--good); color: #fff; }
.quest.fail { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.quest small { display: block; font-weight: 500; color: var(--hint); font-size: 12px; }
.quest.done small, .quest.fail small { color: inherit; opacity: .8; }
.quests-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.quests-head .bar { flex: 1; margin-left: 12px; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.quests-head .bar i { display: block; height: 100%; background: var(--good); border-radius: 3px; transition: width .8s ease; }

/* ---------- лента еды ---------- */
.timeline { position: relative; }
.meal { display: flex; gap: 12px; align-items: center; padding: 12px; margin-bottom: 10px; border: 0; width: 100%; text-align: left; background: var(--card); border-radius: 20px; box-shadow: var(--shadow); }
.thumb { width: 58px; height: 58px; border-radius: 16px; flex: none; background: var(--track); display: grid; place-items: center; font-size: 26px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.meal-info { flex: 1; min-width: 0; }
.meal-type { font-size: 12px; color: var(--hint); font-weight: 600; }
.meal-title { font-weight: 650; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 1px 0 4px; }
.macro-dots { display: flex; gap: 10px; font-size: 12px; color: var(--hint); font-family: var(--num); }
.macro-dots span::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; background: currentColor; vertical-align: 1px; }
.macro-dots .p::before { background: var(--protein); }
.macro-dots .f::before { background: var(--fat); }
.macro-dots .c::before { background: var(--carbs); }
.meal-kcal { text-align: right; flex: none; }
.meal-kcal b { display: block; font-size: 18px; font-family: var(--num); }
.meal-kcal small { color: var(--hint); font-size: 11px; }

.empty-state { text-align: center; padding: 26px 16px; }
.empty-state .e-ico { font-size: 40px; margin-bottom: 6px; }
.empty-state p { margin: 4px 0 14px; color: var(--hint); }

/* ---------- частое и запас ---------- */
/* scroll-padding — иначе привязка прокрутки прижимает первую карточку к краю экрана */
.hscroll { display: flex; gap: 10px; overflow-x: auto; padding: 2px 16px 6px; margin: 0 -16px; scroll-snap-type: x proximity; scroll-padding-inline: 16px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.qcard { scroll-snap-align: start; flex: none; width: 148px; border: 0; text-align: left; background: var(--card); border-radius: 18px; padding: 12px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.qcard .qn { font-weight: 650; font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 35px; }
.qcard .qk { font-family: var(--num); font-weight: 700; }
.qcard .qk small { color: var(--hint); font-weight: 500; font-family: inherit; }
.qcard .qadd { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 650; font-size: 13px; }
.stash { width: 210px; }
.stash .row { display: flex; gap: 6px; margin-top: 2px; }
.stash .row button { flex: 1; border: 0; border-radius: 10px; padding: 7px 0; font-size: 13px; font-weight: 650; background: var(--track); display: grid; place-items: center; }
.stash .row button.main { flex: 2.2; }
.stash .row button.main { background: var(--accent); color: var(--accent-text); }

.close-day { display: flex; align-items: center; gap: 12px; }
.close-day .cd-text { flex: 1; font-weight: 600; }
.close-day .cd-text small { display: block; color: var(--hint); font-weight: 500; }

/* ---------- путь: фигура ---------- */
.journey-hero { padding: 16px 16px 14px; position: relative; overflow: hidden; }
.journey-hero::before {
  content: ""; position: absolute; left: 50%; top: 30px; width: 300px; height: 300px; transform: translateX(-50%);
  border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--body) 16%, transparent), transparent 68%);
  pointer-events: none;
}
.figure-wrap { position: relative; display: flex; justify-content: center; }
.figure-wrap svg { width: 100%; max-width: 300px; height: auto; display: block; overflow: visible; }
.fig-ghost { fill: var(--ghost); }
.fig-goal { fill: none; stroke: var(--good); stroke-width: 1.6; stroke-dasharray: 4 3; }
.fig-legend { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.fig-legend .lg { display: flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 6px 10px; border-radius: 999px; background: var(--track); font-weight: 600; }
.fig-legend .lg i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.fig-legend .lg.start i { background: var(--ghost); }
.fig-legend .lg.now i { background: linear-gradient(180deg, var(--body-2), var(--body)); }
.fig-legend .lg.goal i { border: 1.6px dashed var(--good); }
.fig-legend .lg b { font-family: var(--num); }
.lost-big { text-align: center; margin: 6px 0 2px; }
.lost-big .v { font-size: 40px; font-weight: 800; line-height: 1; font-family: var(--num); letter-spacing: -0.03em; }
.lost-big .v.good { color: var(--good); }
.lost-big .v.bad { color: var(--danger); }
.lost-big .s { color: var(--hint); font-size: 13px; margin-top: 4px; }
.scrub { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.scrub .play { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--track); display: grid; place-items: center; flex: none; }
.scrub .play .icon { width: 18px; height: 18px; }
.scrub input[type="range"] { flex: 1; accent-color: var(--body); height: 28px; }
.scrub-label { text-align: center; font-size: 12.5px; color: var(--hint); margin-top: 2px; min-height: 18px; }

/* шкала пути */
.path-bar { position: relative; height: 12px; border-radius: 6px; background: var(--track); margin: 16px 0 8px; }
.path-bar .fill { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: linear-gradient(90deg, var(--body), var(--body-2)); transition: width 1s cubic-bezier(.2, .8, .2, 1); }
.path-bar .ms { position: absolute; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: var(--card); opacity: .9; }
.path-bar .me { position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%; background: var(--card); box-shadow: 0 2px 8px rgba(0, 0, 0, .18); display: grid; place-items: center; font-size: 12px; transition: left 1s cubic-bezier(.2, .8, .2, 1); }
.path-ends { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--hint); }
.path-ends b { color: var(--text); font-family: var(--num); }

/* награды */
.badges { display: flex; gap: 10px; overflow-x: auto; padding: 2px 16px 6px; margin: 0 -16px; scrollbar-width: none; }
.badges::-webkit-scrollbar { display: none; }
.badge { flex: none; width: 104px; text-align: center; background: var(--card); border-radius: 18px; padding: 12px 8px 10px; box-shadow: var(--shadow); }
.badge .bi { width: 52px; height: 52px; margin: 0 auto 8px; border-radius: 50%; display: grid; place-items: center; font-size: 25px; background: linear-gradient(135deg, var(--kcal-2), var(--kcal)); box-shadow: 0 4px 14px color-mix(in srgb, var(--kcal) 35%, transparent); }
.badge .bt { font-size: 12.5px; font-weight: 700; line-height: 1.2; }
.badge .bs { font-size: 11px; color: var(--hint); margin-top: 3px; }
.badge.locked .bi { background: var(--track); box-shadow: none; filter: grayscale(1); opacity: .55; }
.badge.locked .bt { color: var(--hint); }

/* плитки */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tile { background: var(--card); border-radius: 18px; padding: 13px 14px; box-shadow: var(--shadow); }
.tile .tv { font-size: 24px; font-weight: 800; font-family: var(--num); line-height: 1.15; margin-top: 4px; letter-spacing: -0.02em; }
.tile .ts { font-size: 12px; color: var(--hint); margin-top: 2px; }

/* ---------- графики ---------- */
.seg { display: flex; background: var(--track); border-radius: 13px; padding: 3px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 0; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--hint); transition: background-color .2s, color .2s; }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.chart-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--hint); margin: 2px 0 6px; flex-wrap: wrap; }
.legend i { display: inline-block; vertical-align: 1px; margin-right: 5px; }
.legend .k-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--body); opacity: .45; }
.legend .k-line { width: 14px; height: 3px; border-radius: 2px; background: var(--body); vertical-align: 3px; }
.legend .k-dash { width: 14px; height: 0; border-top: 2px dashed var(--good); vertical-align: 3px; }
.legend .k-bar { width: 9px; height: 9px; border-radius: 2px; background: var(--kcal); }
.legend .k-norm { width: 14px; height: 0; border-top: 1.5px dashed var(--text); opacity: .7; vertical-align: 3px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; overflow: visible; }
.chart .grid { stroke: var(--sep); stroke-width: 1; }
.chart .ax { fill: var(--hint); font-size: 10px; font-family: var(--num); }
.chart .dot { fill: var(--body); opacity: .4; }
.chart .trend { fill: none; stroke: var(--body); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: url(#bodyArea); }
.chart .proj { fill: none; stroke: var(--body); stroke-width: 2; stroke-dasharray: 5 4; opacity: .55; }
.chart .goal { stroke: var(--good); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .goal-l { fill: var(--good); font-size: 10px; font-weight: 700; }
.chart .bar { fill: var(--kcal); }
.chart .bar.part { opacity: .4; }
.chart .norm { stroke: var(--text); stroke-width: 1.2; stroke-dasharray: 4 3; opacity: .6; }
.chart .end-l { fill: var(--text); font-size: 11px; font-weight: 800; font-family: var(--num); }
.chart .tip-line { stroke: var(--hint); stroke-width: 1; }
.chart .tip-dot { fill: var(--card); stroke: var(--body); stroke-width: 2.5; }
.chart-tip { min-height: 19px; font-size: 13px; color: var(--hint); margin-top: 6px; }
.chart-tip b { color: var(--text); }

/* ---------- тренер ---------- */
.coach-head { display: flex; align-items: center; gap: 12px; }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; background: linear-gradient(135deg, var(--body-2), var(--body)); flex: none; box-shadow: 0 4px 14px color-mix(in srgb, var(--body) 35%, transparent); }
.review { margin-top: 12px; font-size: 14.5px; line-height: 1.5; }
.review p { margin: 0 0 10px; }
.review .rp { display: flex; gap: 10px; }
.review .re { flex: none; width: 24px; font-size: 17px; line-height: 1.35; }
.review.collapsed { max-height: 230px; overflow: hidden; -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent); mask-image: linear-gradient(180deg, #000 70%, transparent); }
.suggest { display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 8px; margin: 0 -16px; scrollbar-width: none; }
.suggest::-webkit-scrollbar { display: none; }
.suggest button { flex: none; border: 0; background: var(--card); box-shadow: var(--shadow); padding: 9px 13px; border-radius: 999px; font-size: 13.5px; font-weight: 600; }
.chat { display: flex; flex-direction: column; gap: 8px; padding-bottom: 76px; }
.bubble { max-width: 86%; padding: 10px 13px; border-radius: 18px; font-size: 14.5px; line-height: 1.45; white-space: pre-wrap; box-shadow: var(--shadow); }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 6px; }
.bubble.bot { align-self: flex-start; background: var(--card); border-bottom-left-radius: 6px; }
.bubble.typing { color: var(--hint); }
.composer {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 6;
  padding: 8px 12px; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.composer .in { max-width: 560px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; border: 0; border-radius: 20px; background: var(--card); padding: 11px 14px; resize: none; max-height: 120px; outline: none; box-shadow: var(--shadow); line-height: 1.35; }
.composer .send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; flex: none; }

/* ---------- план ---------- */
.goal-card { color: #fff; background: linear-gradient(140deg, var(--body-2), var(--body)); position: relative; overflow: hidden; }
.goal-card::after { content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.goal-card .label { color: rgba(255, 255, 255, .8); }
.goal-card .gv { font-size: 34px; font-weight: 800; font-family: var(--num); letter-spacing: -0.03em; margin: 4px 0; }
.goal-card .gs { opacity: .9; font-size: 14px; }
.norm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.norm-grid .nv { font-size: 28px; font-weight: 800; font-family: var(--num); letter-spacing: -0.02em; }
.norm-grid .nv small { font-size: 14px; font-weight: 600; color: var(--hint); }
.badge-line { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 6px 10px; border-radius: 10px; background: var(--track); font-size: 12.5px; font-weight: 600; }
.rates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.rate { border: 1.5px solid transparent; background: var(--track); border-radius: 16px; padding: 12px 8px; text-align: center; }
.rate .rn { font-weight: 700; font-size: 14px; }
.rate .rk { font-family: var(--num); font-weight: 800; font-size: 18px; margin-top: 4px; }
.rate .rs { font-size: 11.5px; color: var(--hint); }
.rate.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.bmi-scale { position: relative; height: 12px; border-radius: 6px; margin: 28px 0 24px; background: linear-gradient(90deg, #4aa3df 0%, #1baf7a 22%, #eda100 45%, #eb6834 65%, #d14b4b 82%, #a3324a 100%); }
.bmi-scale .mk { position: absolute; top: -26px; transform: translateX(-50%); font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.bmi-scale .mk::after { content: ""; position: absolute; left: 50%; top: 18px; width: 3px; height: 20px; margin-left: -1.5px; border-radius: 2px; background: var(--text); }
.bmi-scale .mk.goal { top: auto; bottom: -24px; color: var(--good); }
.bmi-scale .mk.goal::after { top: auto; bottom: 16px; background: var(--good); }
.bmi-zones { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--hint); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--sep); }
.kv:last-child { border-bottom: 0; padding-bottom: 2px; }
.kv span:first-child { color: var(--hint); }
.kv span:last-child { text-align: right; font-weight: 600; }
.leg { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--sep); font-size: 14px; }
.leg:last-of-type { border-bottom: 0; }
.leg .li { width: 30px; height: 30px; border-radius: 10px; background: var(--track); display: grid; place-items: center; flex: none; }
.leg .lt { flex: 1; min-width: 0; }
.leg .lk { font-family: var(--num); font-weight: 700; }

/* ---------- нижнее меню ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 8; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow-up);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
}
.tab { border: 0; background: none; color: var(--hint); display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 600; height: 100%; justify-content: center; transition: color .2s; }
.tab .icon { width: 24px; height: 24px; transition: transform .2s; }
.tab.on { color: var(--text); }
.tab.on .icon { transform: translateY(-1px); stroke-width: 2.3; }
.fab-slot { display: flex; justify-content: center; }
.fab {
  width: 58px; height: 58px; border-radius: 20px; border: 0; margin-top: -26px; color: #fff; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--kcal-2), var(--kcal)); box-shadow: 0 8px 22px color-mix(in srgb, var(--kcal) 45%, transparent);
  transition: transform .15s ease;
}
.fab:active { transform: scale(.92); }
.fab .icon { width: 28px; height: 28px; stroke-width: 2.6; }

/* ---------- шторка снизу ---------- */
.sheet-back { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .38); opacity: 0; transition: opacity .25s ease; }
.sheet-back.on { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--page); border-radius: 26px 26px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .34s cubic-bezier(.2, .9, .25, 1);
  max-width: 600px; margin: 0 auto;
}
.sheet.on { transform: none; }
.sheet .grip { width: 38px; height: 5px; border-radius: 3px; background: var(--sep); margin: 2px auto 12px; }
.sheet h2 { margin: 0 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.sheet .photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 20px; display: block; margin-bottom: 12px; background: var(--track); }
.sheet textarea { width: 100%; border: 0; border-radius: 18px; background: var(--card); padding: 14px; resize: none; outline: none; box-shadow: var(--shadow); font-size: 16px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 14px; }
.sheet .actions .btn { flex: 1; }
.big-kcal { font-size: 36px; font-weight: 800; font-family: var(--num); letter-spacing: -0.03em; }
.big-kcal small { font-size: 16px; color: var(--hint); font-weight: 600; }
.items { background: var(--card); border-radius: 20px; padding: 4px 14px; box-shadow: var(--shadow); margin-top: 12px; }
.item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--sep); }
.item:last-child { border-bottom: 0; }
.item .in { flex: 1; min-width: 0; }
.item .in b { display: block; font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.item .in small { color: var(--hint); font-size: 12.5px; font-family: var(--num); }
.stepper { display: flex; align-items: center; gap: 2px; background: var(--track); border-radius: 12px; padding: 2px; flex: none; }
.stepper button { width: 32px; height: 32px; border: 0; background: none; border-radius: 10px; font-size: 19px; font-weight: 600; line-height: 1; }
.stepper button:active { background: var(--press); }
.stepper input { width: 46px; border: 0; background: none; text-align: center; font-family: var(--num); font-weight: 700; padding: 0; outline: none; }
.item .rm { border: 0; background: none; color: var(--hint); width: 28px; height: 28px; flex: none; display: grid; place-items: center; }
.portion { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.portion button { flex: none; border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: 12px; padding: 8px 13px; font-weight: 700; font-family: var(--num); }
.weight-dial { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 18px 0 6px; }
.weight-dial button { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--card); box-shadow: var(--shadow); font-size: 26px; font-weight: 600; }
.weight-dial input { width: 150px; text-align: center; border: 0; background: none; outline: none; font-size: 48px; font-weight: 800; font-family: var(--num); letter-spacing: -0.03em; color: var(--text); padding: 0; }
.weight-dial + .hint { text-align: center; }
.sheet-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.sheet-tile { border: 0; background: var(--card); border-radius: 18px; padding: 14px; text-align: left; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; }
.sheet-tile .st-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; background: var(--track); }
.sheet-tile b { font-size: 15px; }
.sheet-tile small { color: var(--hint); font-size: 12.5px; }

/* ---------- загрузка, всплывашки ---------- */
.skeleton { border-radius: var(--radius); background: linear-gradient(90deg, var(--track) 25%, var(--press) 37%, var(--track) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; margin-bottom: 12px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.toast {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translate(-50%, -160%); z-index: 40;
  opacity: 0; pointer-events: none;
  max-width: calc(100% - 32px); background: var(--text); color: var(--card); padding: 11px 16px; border-radius: 16px;
  font-size: 14px; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); transition: transform .35s cubic-bezier(.2, .9, .25, 1);
  display: flex; gap: 8px; align-items: center;
}
.toast.on { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--danger); color: #fff; }
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.notice { border-left: 4px solid var(--accent); white-space: pre-wrap; }
.notice .x { float: right; border: 0; background: none; color: var(--hint); font-size: 20px; line-height: 1; padding: 0 0 6px 10px; }

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