:root {
  --bg: var(--tg-theme-bg-color, #0f1410);
  --card-bg: var(--tg-theme-secondary-bg-color, #1b231c);
  --text: var(--tg-theme-text-color, #eafbe9);
  --muted: var(--tg-theme-hint-color, #8fae8c);
  --accent: var(--tg-theme-button-color, #3fbf5f);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-tap-highlight-color: transparent; }
.app { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; display: flex; flex-direction: column; gap: 14px; }
.head { text-align: center; padding: 6px 0 0; }
.head h1 { margin: 0; font-size: 26px; }
.status { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.card { background: var(--card-bg); border-radius: 16px; padding: 16px; }
.totals { display: flex; align-items: baseline; justify-content: space-between; }
.totals .kcal { font-size: 34px; font-weight: 700; }
.totals .kcal span { font-size: 15px; font-weight: 400; color: var(--muted); }
.totals .macros { display: flex; gap: 10px; color: var(--muted); font-size: 14px; }
.row { margin-bottom: 10px; }
.row.btns { display: flex; gap: 8px; align-items: stretch; }
input, select { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); background: var(--bg); color: var(--text); font-size: 16px; }
.primary { padding: 13px 16px; border: none; border-radius: 13px; background: var(--accent); color: var(--accent-text); font-size: 16px; font-weight: 600; cursor: pointer; flex: 1; }
.primary:disabled { opacity: 0.6; }
.photo-btn { display: flex; align-items: center; justify-content: center; padding: 0 16px; border-radius: 13px; border: 1px solid rgba(255,255,255,0.14); cursor: pointer; font-size: 15px; }
.muted { color: var(--muted); font-size: 14px; }
.draft h2, .list h2, .pro h2 { margin: 0 0 10px; font-size: 17px; }
.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.item.editing { display: block; }
.item-main { flex: 1; font-size: 15px; }
.item-main.editable { cursor: pointer; }
.item-kcal { font-weight: 600; }
.ghost { padding: 13px 16px; border-radius: 13px; border: 1px solid rgba(255,255,255,0.14); background: transparent; color: var(--text); font-size: 16px; cursor: pointer; flex: 1; }
.period-row { display: flex; gap: 6px; margin-bottom: 10px; }
.period-btn { flex: 1; padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.14); background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; }
.period-btn.active { background: var(--accent); color: var(--accent-text); border-color: transparent; }
.stat-row { display: flex; align-items: baseline; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-size: 15px; }
.stat-row .stat-kcal { font-weight: 600; margin-left: auto; }
#statsBox { margin-top: 12px; }
#statsNote { margin-bottom: 0; }
#reportBox { margin-top: 12px; }
.report-h { margin: 0 0 8px; font-size: 16px; }
.report-tips { margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.4; }
.report-tips li { color: var(--text); }
.meal-mix { margin-top: 12px; }
.meal-mix-h { font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.meal-mix-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 14px; }
.meal-mix-label { flex: 0 0 78px; color: var(--text); text-transform: capitalize; }
.meal-mix-track { flex: 1; height: 8px; border-radius: 6px; background: rgba(255,255,255,0.08); overflow: hidden; }
.meal-mix-fill { display: block; height: 100%; border-radius: 6px; background: var(--accent); }
.meal-mix-pct { flex: 0 0 36px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
/* Экран статистики (Pro): графики динамики + достижения + CTA на Pro */
.stats-bars { display: block; width: 100%; height: 180px; margin-top: 6px; }
.stats-trend { margin: 8px 0 2px; font-weight: 600; }
.stats-ach { margin-top: 12px; }
.stats-ach-h { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.stats-cta { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.stats-cta .muted { margin-bottom: 8px; }
#statsBox .meal-mix-pct { flex: 0 0 auto; min-width: 64px; }
/* Мед-дисклеймер плашкой под результатом карточки (stats/тренд/вес), а не только в футере */
.card-disclaimer { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; line-height: 1.4; }
.card-disclaimer:empty { display: none; } /* пустой текст (нет канонического дисклеймера) — не рисуем плашку/границу */
/* Разговорный AI-нутрициолог (Pro) */
#coachBox { margin-top: 12px; }
.coach-thread { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; max-height: 360px; overflow-y: auto; }
.coach-msg { padding: 9px 12px; border-radius: 13px; font-size: 14px; line-height: 1.4; max-width: 88%; white-space: pre-wrap; word-wrap: break-word; }
.coach-msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.coach-msg.coach { align-self: flex-start; background: rgba(255,255,255,0.06); border-bottom-left-radius: 4px; }
.coach-msg.typing { color: var(--muted); font-style: italic; }
.coach-input { display: flex; gap: 8px; align-items: stretch; margin-bottom: 8px; }
.coach-input #coachSend { flex: 0 0 auto; }
.coach-disclaimer { font-size: 12px; }
.del { background: transparent; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.plan { position: relative; width: 100%; text-align: left; display: flex; flex-direction: column; gap: 3px; padding: 12px; margin-top: 8px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); background: var(--bg); color: var(--text); cursor: pointer; }
.plan-title { font-weight: 600; }
.plan-desc { font-size: 13px; color: var(--muted); }
.plan-price { font-weight: 600; color: var(--accent); }
/* Иерархия пейволла: «★ Популярный» выделяет рекомендованный тариф, «−N%» — выгоду годового. */
.plan-popular { border-color: var(--accent); border-width: 2px; background: rgba(63,191,95,0.08); }
.plan-badge { position: absolute; top: -9px; right: 12px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-text); }
.plan-save { display: inline-block; margin-left: 6px; font-size: 12px; font-weight: 700; color: var(--accent); }
/* Разделитель «Разовые покупки» между подписочными и pay-per-use SKU — снимает кашу выбора. */
.plans-divider { margin: 16px 0 2px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
/* «🎁 Подарить Pro другу» — вторичный вход в подарочную оплату; отделён от тарифов воздухом сверху. */
.gift-pro { margin-top: 14px; text-align: center; }
.demo-example { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: var(--bg); border: 1px dashed rgba(255,255,255,0.12); }
.full { width: 100%; flex: none; margin-top: 6px; }
.goal-empty { margin: 0; }
.goal-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 14px; }
.goal-eaten { font-size: 15px; }
.goal-eaten b { font-size: 20px; }
.goal-left { color: var(--muted); }
.goal-left.over { color: #e06a5a; }
.bar { height: 10px; border-radius: 8px; background: rgba(255,255,255,0.08); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 8px; transition: width 0.3s ease; }
.bar-fill.over { background: #e06a5a; }
.profile .grid { margin-bottom: 4px; }
#p_hint { margin: 8px 0 0; }
.streak { margin: 6px 0 0; font-size: 14px; font-weight: 600; color: #f0a94b; display: flex; align-items: center; gap: 8px; }
.streak-share { background: transparent; border: none; cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; }
.macro-bars { margin-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.macro { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 8px; font-size: 13px; }
.macro-label { font-weight: 600; color: var(--muted); }
.macro-track { height: 8px; border-radius: 6px; background: rgba(255,255,255,0.08); overflow: hidden; }
.macro-track > i { display: block; height: 100%; border-radius: 6px; transition: width 0.3s ease; }
.macro-track > i.over { background: #e06a5a; }
.macro-val { color: var(--muted); white-space: nowrap; font-size: 12px; }
.macro.p .macro-track > i { background: #5aa9e0; }
.macro.f .macro-track > i { background: #e0b85a; }
.macro.c .macro-track > i { background: #7fcf6a; }

/* Трекинг воды (седьмая волна): дневной питьевой режим + быстрый +стакан + Pro неделя/AI-совет */
.water-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.water-title { margin: 0; font-size: 17px; }
.water-amount { font-variant-numeric: tabular-nums; }
.water-amount.reached { color: #5aa9e0; font-weight: 600; }
.water-bar { height: 12px; }
.water-fill { background: #5aa9e0; }
.water-fill.reached { background: #3f9fdf; }
.water-glasses { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 2px; }
.water-glass { font-size: 18px; line-height: 1; filter: grayscale(1) opacity(0.35); transition: filter 0.2s ease; }
.water-glass.on { filter: none; }
.water-btns { margin-top: 12px; }
.water-minus { flex: 0 0 52px; font-size: 20px; }
.water-details { margin-top: 12px; }
.water-spark { display: block; width: 100%; height: 64px; }
.water-tip { margin: 8px 0 0; padding: 9px 11px; border-radius: 10px; background: rgba(90,169,224,0.1); border-left: 3px solid #5aa9e0; line-height: 1.4; color: var(--text); }
.water-tip.ai::before { content: "🤖 "; }
.water-tip.cta { background: rgba(63,191,95,0.08); border-left-color: var(--accent); }

/* Пометка фолбэк-черновика (распознавание не удалось) */
.draft.fallback { border: 1px solid #e0b85a; }
.draft-warn { margin: 0 0 10px; padding: 8px 10px; border-radius: 10px; background: rgba(224,184,90,0.14); color: #e0b85a; font-size: 13px; line-height: 1.4; }
.draft-item { padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.draft-item:first-of-type { padding-top: 2px; }
.draft-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.draft-item-head .di-name { flex: 1; }
.draft-sum { margin: 12px 0; font-size: 15px; font-weight: 600; }

/* Советы нутрициолога */
.tips { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.tips-title { font-size: 13px; font-weight: 600; color: var(--muted); }
.tip { font-size: 13px; line-height: 1.4; padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,0.05); border-left: 3px solid var(--accent); }
.tip-fat { border-left-color: #e0b85a; }
.tip-carbs { border-left-color: #7fcf6a; }
.tip-calories { border-left-color: #e06a5a; }
.tip-ok { border-left-color: var(--accent); }
.tip-profile { border-left-color: var(--muted); }
.trend #trendBox { margin-top: 12px; }
.trend canvas { width: 100%; height: auto; display: block; }

/* Лента приёмов пищи (ctx.history kind="meal"): спарклайн калорий + карточки приёмов */
.history #historyBox { margin-top: 12px; }
.history-spark { width: 100%; height: 64px; display: block; margin-bottom: 4px; }
.history-spark-note { margin: 0 0 10px; font-size: 12px; }
.history-feed { display: flex; flex-direction: column; gap: 0; }
.history-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.history-item:last-child { border-bottom: none; }
.history-when { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 0 0 46px; }
.history-src { font-size: 18px; line-height: 1; }
.history-date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.history-body { flex: 1; min-width: 0; }
.history-dishes { font-size: 15px; line-height: 1.35; word-break: break-word; }
.history-meta { margin-top: 3px; font-size: 13px; }
.history-kcal { font-weight: 600; color: var(--accent); }
.history-empty { margin: 6px 0; line-height: 1.45; }

/* Недельный рекап КБЖУ (вторая волна): спарклайн калорий 7 дней + дельта веса; раскрытие — БЖУ */
.recap { padding: 14px 16px; }
.recap-head { display: block; width: 100%; padding: 0; border: none; background: transparent; color: inherit; text-align: left; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.recap-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.recap-title { margin: 0; font-size: 17px; font-weight: 700; }
.recap-weight { font-size: 14px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.recap-weight-down { color: var(--accent); }
.recap-weight-up { color: #e3a14a; }
.recap-spark { width: 100%; height: 72px; display: block; margin: 2px 0 6px; }
.recap-summary { margin: 0; line-height: 1.4; }
.recap-details { margin-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); padding-top: 10px; }
.recap-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.recap-table th { color: var(--muted); font-weight: 500; text-align: right; padding: 4px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.recap-table th:first-child { text-align: left; }
.recap-table td { padding: 7px 0; border-bottom: 1px solid rgba(255,255,255,0.06); font-variant-numeric: tabular-nums; }
.recap-table tr:last-child td { border-bottom: none; }
.recap-name { color: var(--text); }
.recap-num { text-align: right; color: var(--muted); }
.recap-avg { color: var(--text); font-weight: 600; }
.recap-unit { color: var(--muted); font-size: 12px; font-weight: 400; }

/* Трекинг веса */
.weight #weightBox { margin-top: 12px; }
.weight canvas { width: 100%; height: auto; display: block; }
.weight-summary { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.weight-current { font-size: 22px; font-weight: 700; }
.weight-summary .down { color: #7fcf6a; }
.weight-summary .up { color: #e0b85a; }
.weight #weightBox .row { display: flex; gap: 8px; margin-top: 8px; }
.weight #weightBox .row input { flex: 1; }
#trendNote { margin: 8px 0 0; }
.day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.day-head h2 { margin: 0; flex: 1; text-align: center; }
.day-nav { width: 40px; min-width: 40px; padding: 4px 0; font-size: 20px; line-height: 1; }
.day-nav:disabled { opacity: 0.35; }
.referral h2 { margin: 0 0 8px; font-size: 17px; }
.referral { border: 1px solid rgba(63,191,95,0.35); }
.referral .row { display: flex; gap: 8px; margin: 12px 0 8px; }
.referral #referralStats { margin: 0; }

/* Кросс-промо (ЗАДАЧА B): смежные боты пула */
.suggest h2 { margin: 0 0 10px; font-size: 17px; }
#suggestList { display: flex; flex-direction: column; gap: 8px; }
.suggest-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 12px; background: rgba(127,127,127,0.08); color: inherit; text-decoration: none; font-size: 15px; }
.suggest-item:active { background: rgba(127,127,127,0.16); }
.suggest-nolink { opacity: 0.7; }
.suggest-go { opacity: 0.5; }

/* Онбординг-квиз с персональным планом ДО paywall */
.onboarding { position: fixed; inset: 0; z-index: 50; background: var(--bg); overflow-y: auto; display: flex; flex-direction: column; padding: 16px; }
body.onb-open { overflow: hidden; }
.onb-card { max-width: 460px; width: 100%; margin: auto; display: flex; flex-direction: column; gap: 14px; padding: 8px 4px 24px; position: relative; }
.onb-emoji { font-size: 46px; text-align: center; line-height: 1; margin-top: 8px; }
.onb-card h2 { margin: 0; font-size: 23px; text-align: center; line-height: 1.25; }
.onb-q { text-align: center; }
.onb-lead { margin: 0; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.45; }
.onb-hint { margin: -6px 0 0; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.4; }
.onb-progress { height: 6px; border-radius: 6px; background: rgba(255,255,255,0.08); overflow: hidden; margin-bottom: 4px; }
.onb-progress-fill { height: 100%; background: var(--accent); border-radius: 6px; transition: width 0.25s ease; }
.onb-back { align-self: flex-start; background: transparent; border: none; color: var(--muted); font-size: 15px; cursor: pointer; padding: 2px 0; }
.onb-skip { background: transparent; border: none; color: var(--muted); font-size: 14px; cursor: pointer; padding: 8px; text-decoration: underline; }
.onb-options { display: flex; flex-direction: column; gap: 10px; }
.onb-opt { text-align: left; padding: 15px 16px; border-radius: 14px; border: 1.5px solid rgba(255,255,255,0.12); background: var(--card-bg); color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 3px; font-size: 16px; }
.onb-opt:hover { border-color: rgba(63,191,95,0.5); }
.onb-opt.selected { border-color: var(--accent); background: rgba(63,191,95,0.12); }
.onb-opt-label { font-weight: 600; }
.onb-opt-hint { font-size: 13px; color: var(--muted); }
.onb-number { display: flex; align-items: center; gap: 10px; }
.onb-number input { flex: 1; font-size: 20px; text-align: center; padding: 14px; }
.onb-unit { color: var(--muted); font-size: 16px; min-width: 36px; }
.onb-card .primary { margin-top: 4px; }

/* Согласие на обработку ПДн (152-ФЗ): чекбокс + ссылка на политику */
.consent-check { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px; border-radius: 14px; border: 1.5px solid rgba(255,255,255,0.12); background: var(--card-bg); color: var(--text); font-size: 14px; line-height: 1.45; cursor: pointer; text-align: left; }
.consent-check input { margin-top: 3px; width: 18px; height: 18px; flex: 0 0 auto; accent-color: var(--accent); }
.consent-check a { color: var(--accent); }

/* Экран «вот твой план» */
.onb-plan { gap: 12px; }
.plan-kcal { text-align: center; padding: 14px 0 6px; }
.plan-kcal-num { font-size: 52px; font-weight: 800; color: var(--accent); line-height: 1; }
.plan-kcal-unit { color: var(--muted); font-size: 15px; margin-top: 4px; }
.plan-macros { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.plan-macro { background: var(--card-bg); border-radius: 12px; padding: 12px 8px; text-align: center; display: flex; flex-direction: column; gap: 3px; border-top: 3px solid var(--muted); }
.plan-macro.p { border-top-color: #5aa9e0; }
.plan-macro.f { border-top-color: #e0b85a; }
.plan-macro.c { border-top-color: #7fcf6a; }
.pm-val { font-size: 18px; font-weight: 700; }
.pm-lab { font-size: 12px; color: var(--muted); }
.plan-bmi { text-align: center; font-size: 15px; color: var(--text); background: var(--card-bg); border-radius: 12px; padding: 10px; }
.plan-forecast { background: var(--card-bg); border-radius: 14px; padding: 14px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.plan-forecast-big { font-size: 30px; font-weight: 800; color: var(--accent); }
.plan-forecast-sub { font-size: 13px; color: var(--muted); }
.plan-forecast-eta { font-size: 14px; color: var(--text); margin-top: 4px; }
.plan-pro { background: rgba(63,191,95,0.10); border: 1px solid rgba(63,191,95,0.3); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.plan-pro p { margin: 0; font-size: 14px; color: var(--text); line-height: 1.45; }
.onb-disclaimer { margin: 0; text-align: center; font-size: 12px; color: var(--muted); line-height: 1.4; }
.onb-loading { align-items: center; }

/* «Часто едите»: чипы повторяемых блюд для добавления в один тап. */
.favorites h2 { margin: 0 0 4px; font-size: 17px; }
.fav-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.fav-chip { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 9px 12px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.14); background: var(--bg); color: var(--text); cursor: pointer; text-align: left; max-width: 100%; }
.fav-chip:active { border-color: var(--accent); }
.fav-chip:disabled { opacity: 0.5; }
.fav-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.fav-kcal { font-size: 12px; }

.hidden { display: none; }
