:root {
  color-scheme: light;
  --bg: #FFF9F2;
  --card: #ffffff;
  --ink: #292638;
  --muted: #756E7B;
  --muted2: #837B87;
  --berry: #D9432E;      /* коралловый акцент */
  --amber: #C28A1D;      /* углеводы */
  --mint: #278568;       /* жиры */
  --leaf: #4FB98E;       /* листики клубники / знак */
  --track: #EEE8E5;
  --c: var(--amber);     /* углеводы */
  --p: #8973CA;     /* белки */
  --f: var(--mint);      /* жиры */
  --sh-card: 0 3px 0 rgba(41,38,56,.035);
  --sh-soft: 0 2px 6px rgba(41,38,56,.04);
  --sh-meal: none;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Курсор и выделение во всех полях ввода: без этого в системной тёмной теме
   WebView Telegram рисует их своим цветом поверх светлого поля — не видно */
input, textarea, select { caret-color: var(--berry); }
input::selection, textarea::selection { background: var(--berry); color: #fff; }
input::-moz-selection, textarea::-moz-selection { background: var(--berry); color: #fff; }

body {
  margin: 0;
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 520px; margin: 0 auto; padding: calc(18px + env(safe-area-inset-top)) 20px calc(112px + env(safe-area-inset-bottom)); }

.hidden { display: none !important; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; min-height: 78vh; gap: 12px; }
.muted { color: var(--muted); }

h1 { font-size: 26px; font-weight: 800; margin: 4px 0; letter-spacing: -0.02em; }
.emoji { font-size: 60px; line-height: 1; }

/* Кастомные иконки Ням (SVG-спрайт, см. #ic-sprite в index.html).
   Размер наследуется от font-size контекста через 1em. */
.ic { width: 1em; height: 1em; display: inline-block; vertical-align: -0.14em; flex: 0 0 auto; }
.ic-l { margin-right: 6px; }        /* иконка перед текстом в кнопке/строке */
.streak .ic { color: var(--berry); }   /* огонёк-стрик — всегда акцент */

/* Знак «ням.» (AppMark из спеки иконок). Размер задаётся через --am. */
.appmark { --am: 64px; width: var(--am); height: var(--am); border-radius: calc(var(--am) * .31);
  background: var(--berry); display: inline-flex; align-items: flex-end; justify-content: center;
  gap: calc(var(--am) * .03); }
.appmark .am-n { font-weight: 800; color: #fff; line-height: .9; letter-spacing: -0.06em;
  font-size: calc(var(--am) * .47); }
.appmark .am-dot { width: calc(var(--am) * .092); height: calc(var(--am) * .092); border-radius: 50%;
  background: #fff; margin-bottom: calc(var(--am) * .064); }

/* Кнопки */
.btn {
  border: none; border-radius: 16px; padding: 16px 18px; font-size: 17px; font-weight: 800;
  cursor: pointer; width: 100%; transition: filter .15s, transform .05s; letter-spacing: -0.01em;
  font-family: inherit;
}
.btn:active { transform: scale(0.99); }
.btn-primary { background: var(--berry); color: #fff; box-shadow: none; }
.btn-primary:active { filter: brightness(0.96); }
.btn-primary:disabled { opacity: .5; box-shadow: none; }
.link { background: none; border: none; color: var(--berry); font-size: 15px; font-weight: 800;
  cursor: pointer; padding: 0; font-family: inherit; }

/* Верхняя строка дашборда (стрик + календарь) */
.dash-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 2px 0; }
.dash-date { padding: 11px 15px; border-radius: 14px; background: var(--card); box-shadow: var(--sh-soft);
  font-size: 15px; font-weight: 800; color: var(--ink); line-height: 1; display: flex; align-items: center; }
.add-head { justify-content: space-between; }
.head-icon { width: 42px; height: 42px; border-radius: 13px; border: none; background: var(--card);
  box-shadow: var(--sh-soft); color: var(--berry); font-size: 22px; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.head-icon:active { transform: scale(0.96); }
.streak { display: flex; align-items: center; gap: 7px; background: var(--card); border-radius: 999px;
  padding: 8px 14px; box-shadow: var(--sh-soft); font-size: 17px; font-weight: 800; cursor: pointer;
  border: none; color: var(--ink); font-family: inherit; }
.streak:active { transform: scale(0.97); }

/* Экран стрика */
.streak-hero { text-align: center; padding: 20px 0 6px; }
.streak-flame { font-size: 66px; line-height: 1; color: var(--berry); }
.streak-big { font-size: 66px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin-top: 4px; }
.streak-milestone { background: linear-gradient(135deg, var(--berry), var(--amber)); color: #fff;
  border-radius: 20px; padding: 16px 18px; font-weight: 800; text-align: center; margin: 16px 0; }
.streak-week { display: flex; justify-content: space-between; gap: 6px; margin-top: 6px; }
.sw-day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.sw-dot { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--track);
  display: flex; align-items: center; justify-content: center; font-size: 15px; font-weight: 800; color: var(--muted2); }
.sw-dot.active { background: var(--berry); border-color: var(--berry); color: #fff; }
.sw-dot.today { box-shadow: 0 0 0 3px rgba(232, 78, 107, 0.25); }
.sw-lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.dash-cal { width: 44px; height: 44px; border-radius: 14px; background: var(--card);
  display: flex; align-items: center; justify-content: center; box-shadow: var(--sh-soft); font-size: 20px; }

/* Заголовок */
.topbar { display: flex; align-items: center; gap: 12px; margin: 20px 0 16px; }
.topbar-title { font-size: 36px; font-weight: 800; letter-spacing: -0.045em; line-height: 1.12; }
.topbar-title.sm { font-size: 24px; }
.topbar-sub { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; margin-top: 7px; }

/* Карточка */
.card { background: var(--card); border: 1px solid #EEE8E5; border-radius: 24px; padding: 20px; box-shadow: var(--sh-card); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-title { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }

/* Кольцо калорий (полное) */
/* Баланс: крупное кольцо справа, вторичные показатели слева. */
.balance-card { background: #FFE1D5; border-color: transparent; padding: 20px; box-shadow: none; }
.balance-card .card-title { font-size: 17px; }
.balance-unit { font-size: 10px; font-weight: 800; letter-spacing: .1em; color: #865044; }
.gauge-row { display: grid; grid-template-columns: 1fr 160px; grid-template-rows: 1fr 1fr; gap: 0 8px; align-items: center; margin: 6px 0; }
.gauge { position: relative; width: 160px; height: 160px; grid-column: 2; grid-row: 1 / 3; }
.gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: #FFF5EE; stroke: #F5C8BA; stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--berry); stroke-width: 10; stroke-linecap: round;
  stroke-dasharray: 395.84; stroke-dashoffset: 395.84; transition: stroke-dashoffset .7s ease; }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge-num { font-size: 40px; font-weight: 800; letter-spacing: -.05em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.gauge-label { font-size: 12px; font-weight: 600; margin-top: 5px; color: #79574F; }
.side-stat { text-align: left; min-width: 0; grid-column: 1; }
.side-stat:first-child { align-self: end; padding-bottom: 13px; }
.side-stat:last-child { align-self: start; padding-top: 10px; border-top: 1px solid #EEC3B5; }
.side-num { font-size: 26px; font-weight: 800; letter-spacing: -.035em; }
.side-label { font-size: 12px; font-weight: 600; margin-top: 1px; color: #79574F; }
.balance-note:empty { display: none; }
.balance-note { margin: 12px 0 0; font-size: 12px; line-height: 1.5; color: #79574F; }
.over-budget .ring-fg { stroke: #94523F; }

/* Цвет всегда соответствует одному и тому же макронутриенту. */
.macros { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.macro { min-width: 0; padding: 14px 12px; border-radius: 19px; }
.macro-carbs { background: #F8EBC4; }
.macro-protein { background: #EBE3FA; }
.macro-fat { background: #DDEFE5; }
.macro-name { font-size: 12px; font-weight: 800; margin-bottom: 10px; }
.bar { height: 5px; background: rgba(41,38,56,.09); border-radius: 99px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; border-radius: 99px; transition: width .7s ease; }
.bar-fill.p { background: var(--p); }
.bar-fill.f { background: var(--f); }
.bar-fill.c { background: var(--c); }
.macro-val { font-size: 11px; font-weight: 600; margin-top: 8px; color: #595261; white-space: nowrap; }

/* Секции */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 4px 12px; }
.section-title { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.meals-toggle { background: none; border: none; color: var(--berry); font-size: 14px; font-weight: 800;
  cursor: pointer; padding: 4px 2px; white-space: nowrap; }
.meals-toggle:active { opacity: .6; }

/* Приёмы */
.meals-box { border: 1px solid var(--track); background: var(--card); border-radius: 22px; padding: 0 14px; overflow: hidden; }
.meals-list { display: flex; flex-direction: column; gap: 0; }
.meal { background: transparent; border: 0; border-bottom: 1px solid var(--track); border-radius: 0; padding: 17px 0; box-shadow: none; width: 100%; text-align: left; font-family: inherit; color: var(--ink); display: flex; align-items: center; gap: 11px; }
.meal:last-child { border-bottom: 0; }
.meal-ic { width: 48px; height: 48px; border-radius: 50%; flex: 0 0 auto;
  background: #F5EFE7; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.meal-body { flex: 1; min-width: 0; }
.meal-desc { font-size: 14px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meal-sub { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.meal-kcal { font-weight: 800; white-space: nowrap; font-size: 17px; text-align: right; }
.meal-kcal span { display: block; font-size: 11px; font-weight: 600; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; font-weight: 600; text-align: center; padding: 22px; }

/* Добавление */
.phrase { width: 100%; border: none; border-radius: 18px; padding: 16px 16px 56px; font-size: 16px;
  font-family: inherit; font-weight: 600; resize: none; margin-bottom: 12px; background: var(--card); color: var(--ink);
  box-shadow: var(--sh-card); }
.phrase:focus { outline: 2px solid var(--berry); }

/* Голосовой ввод: кнопки в углах поля фразы (скрепка · камера · микрофон) */
.phrase-wrap { position: relative; }
.field-btn { position: absolute; bottom: 22px; width: 40px; height: 40px;
  border: none; border-radius: 12px; background: var(--track); color: var(--berry);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform .12s, background .12s; }
.field-btn:active { transform: scale(0.94); }
.field-btn .ic { width: 22px; height: 22px; }
.attach-btn { left: 10px; }
.cam-btn { right: 58px; }
.mic-btn { position: absolute; right: 10px; bottom: 22px; width: 40px; height: 40px; z-index: 3;
  border: none; border-radius: 12px; background: var(--track); color: var(--berry);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  touch-action: none; transition: transform .12s, background .12s; }
.mic-btn:active { transform: scale(0.94); }
.mic-btn .ic { width: 22px; height: 22px; }
.mic-btn.recording { background: var(--berry); color: #fff; animation: mic-pulse 1s ease-in-out infinite; }
.mic-btn:disabled { opacity: .5; }
.mic-btn.hidden { display: none; }
@keyframes mic-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(232,78,107,.45); } 50% { box-shadow: 0 0 0 8px rgba(232,78,107,0); } }
.mic-hint { font-size: 13px; font-weight: 600; color: var(--berry); text-align: center; margin-bottom: 12px; }
.mic-hint.hidden { display: none; }

/* Оверлей записи: перекрывает текстовое поле (блокирует ввод) + анимированный эквалайзер */
.rec-overlay { position: absolute; inset: 0 0 12px 0; z-index: 2; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: rgba(255,255,255,.93); color: var(--berry); font-weight: 800; font-size: 15px;
  animation: rec-fade .18s ease-out; }
.rec-overlay.hidden { display: none; }
.rec-eq { display: inline-flex; align-items: center; gap: 4px; height: 26px; }
.rec-eq i { width: 4px; height: 100%; border-radius: 2px; background: var(--berry);
  transform: scaleY(.3); transform-origin: center; animation: rec-eq .9s ease-in-out infinite; }
.rec-eq i:nth-child(2) { animation-delay: .18s; }
.rec-eq i:nth-child(3) { animation-delay: .36s; }
.rec-eq i:nth-child(4) { animation-delay: .12s; }
.rec-eq i:nth-child(5) { animation-delay: .30s; }
@keyframes rec-eq { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }
@keyframes rec-fade { from { opacity: 0; } to { opacity: 1; } }

.draft { margin-top: 18px; }

/* Итоговая карточка (ккал + плитки БЖУ) */
.draft-total-card { margin-bottom: 6px; }
.dt-kcal { display: flex; align-items: baseline; gap: 8px; }
.dt-kcal span:first-child { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; }
.dt-unit { font-size: 16px; font-weight: 800; color: var(--muted); }
.dt-tiles { display: flex; gap: 10px; margin-top: 14px; }
.dt-tile { flex: 1; text-align: center; border-radius: 14px; padding: 10px 4px; }
.dt-tile.c { background: #FDF3E7; }
.dt-tile.p { background: #EBE3FA; }
.dt-tile.f { background: #E7F6F1; }
.dt-val { font-size: 18px; font-weight: 800; }
.dt-tile.c .dt-val { color: #D68A22; }
.dt-tile.p .dt-val { color: #7055AA; }
.dt-tile.f .dt-val { color: #33A385; }
.dt-lbl { font-size: 12px; font-weight: 800; margin-top: 2px; }
.dt-tile.c .dt-lbl { color: #B08A4E; }
.dt-tile.p .dt-lbl { color: #7055AA; }
.dt-tile.f .dt-lbl { color: #6AAE9A; }

.draft-sub { font-size: 15px; font-weight: 800; color: var(--ink); margin: 20px 2px 12px; }

/* Редактируемые строки продуктов */
.draft-items { display: flex; flex-direction: column; gap: 10px; }
.draft-item { background: var(--card); border-radius: 18px; padding: 13px 15px; box-shadow: var(--sh-meal);
  display: flex; align-items: center; gap: 12px; }
.di-emoji { font-size: 24px; flex: 0 0 auto; width: 26px; text-align: center; }
.di-info { flex: 1; min-width: 0; }
.di-name { font-size: 16px; font-weight: 800; display: flex; align-items: baseline; min-width: 0; }
.di-name-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.di-kcal { font-size: 13px; font-weight: 800; color: var(--ink); margin-top: 2px; white-space: nowrap; }
.di-macros { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.di-grams-static { font-size: 14px; font-weight: 800; color: var(--muted); }
.tag { font-size: 10px; padding: 2px 6px; border-radius: 6px; margin-left: 6px; font-weight: 800;
  flex: 0 0 auto; letter-spacing: .03em; }
.tag.ai { background: #7B61FF; color: #fff; }

/* Степпер порции в строке продукта */
.stepper-sm { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.step-sm { width: 30px; height: 30px; border-radius: 9px; border: none; font-size: 18px; font-weight: 800;
  cursor: pointer; font-family: inherit; display: flex; align-items: center; justify-content: center; line-height: 1; }
.step-sm.minus { background: var(--track); color: var(--muted); }
.step-sm.plus { background: var(--berry); color: #fff; }
.step-sm:active { transform: scale(0.92); }
.di-grams { font-size: 14px; font-weight: 800; min-width: 48px; text-align: center; }

/* Нижняя навигация */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around; align-items: center;
  max-width: 520px; margin: 0 auto; padding: 12px 12px calc(18px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid #EAE2DE; }
.tab { background: none; border: none; cursor: pointer; flex: 1; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 800; color: var(--muted); padding: 6px 0; }
.tab.active { color: var(--berry); }
.tab.active .tab-ic { background: #FFE1D5; }
.tab-ic { padding: 6px 22px; border-radius: 14px; }
.tab-ic { font-size: 24px; display: inline-flex; }   /* цвет наследуется от .tab (muted2 / berry в active) */

/* График калорий */
.chart { display: flex; flex-direction: column; gap: 8px; }
.chart-plot { position: relative; height: 140px; display: flex; align-items: flex-end;
  justify-content: space-between; gap: 8px; }
.chart-bar { flex: 1; border-radius: 7px 7px 3px 3px; background: var(--berry);
  min-height: 3px; transition: height .5s ease; }
.chart-bar.over { background: var(--amber); }
.chart-labels { display: flex; justify-content: space-between; gap: 8px; }
.chart-labels > div { flex: 1; text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.chart-normline { position: absolute; left: 0; right: 0; border-top: 1.5px dashed #D8CFD1; pointer-events: none; }
.chart-normcap { position: absolute; right: 0; transform: translateY(-100%);
  font-size: 10px; font-weight: 600; color: var(--muted); background: var(--card); padding: 0 4px; }

/* Средние */
.avg-big { font-size: 36px; font-weight: 800; letter-spacing: -0.03em; margin: 4px 0 10px; }
.avg-macros { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; gap: 8px; flex-wrap: wrap; }
.avg-macros b { font-weight: 800; }

/* Профиль */
.profile-head { display: flex; align-items: center; gap: 16px; padding: 4px 4px 16px; }
.prof-avatar { width: 66px; height: 66px; border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--berry), var(--amber)); display: flex; align-items: center;
  justify-content: center; font-size: 26px; font-weight: 800; color: #fff; }
.prof-name { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.prow { display: flex; justify-content: space-between; align-items: center; padding: 13px 0;
  border-bottom: 1px solid var(--track); font-size: 15px; font-weight: 600; }
.prow:first-child { padding-top: 2px; }
.prow:last-child { border-bottom: none; padding-bottom: 2px; }
.prow .k { color: var(--muted); }
.prow .v { font-weight: 800; }
.prow-edit { cursor: pointer; }
.prow-edit .v::after { content: ' ›'; color: var(--muted2); font-weight: 800; }
.prow-edit:active { opacity: .6; }

/* Тёмная карточка нормы */
.norm-card { background: var(--ink); color: #fff; border-radius: 24px; padding: 20px 22px; margin-top: 14px;
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; border: none; font-family: inherit; text-align: left; cursor: pointer;
  transition: transform .12s; }
.norm-card:active { transform: scale(0.985); }
.norm-lbl { font-size: 14px; font-weight: 800; color: rgba(255,255,255,.6); }
.norm-big { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; margin-top: 2px; }
.norm-unit { font-size: 16px; font-weight: 800; color: rgba(255,255,255,.6); }
.norm-macros { text-align: right; font-size: 13px; font-weight: 600; line-height: 1.9; color: rgba(255,255,255,.75); }
.norm-macros b { color: #fff; }

/* Запись веса */
.weight-form { display: flex; gap: 10px; }
.weight-input { flex: 1; min-width: 0; border: none; border-radius: 14px; padding: 15px; font-size: 16px; font-weight: 600;
  font-family: inherit; background: var(--bg); color: var(--ink); }
.weight-input:focus { outline: 2px solid var(--berry); }

/* Цель по весу (Фаза 4) */
.goal-block { margin-bottom: 18px; }
.wg-top { display: flex; align-items: baseline; justify-content: space-between; }
.wg-current { font-size: 32px; font-weight: 800; letter-spacing: -0.03em; }
.wg-unit { font-size: 16px; font-weight: 800; color: var(--muted); }
.wg-delta { font-size: 14px; font-weight: 800; color: var(--muted); }
.wg-delta.good { color: #33A385; }
.wg-ends { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600;
  color: var(--muted); margin: 14px 0 6px; }
.wg-bar { height: 9px; border-radius: 99px; background: var(--track); overflow: hidden; }
.wg-fill { height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--berry), var(--amber)); transition: width .7s ease; }
.wg-pct { text-align: center; font-size: 13px; font-weight: 800; color: var(--muted); margin-top: 12px; }
.goal-btn { width: 100%; margin-top: 14px; border: none; border-radius: 14px; padding: 14px;
  background: var(--bg); color: var(--ink); font-size: 15px; font-weight: 800; font-family: inherit;
  cursor: pointer; transition: filter .15s; }
.goal-btn:active { filter: brightness(0.97); }

/* Онбординг */
.onb-head { display: flex; align-items: center; gap: 14px; padding: 10px 2px 20px; }
.onb-progress { flex: 1; height: 8px; background: var(--track); border-radius: 99px; overflow: hidden; }
#onb-bar { height: 100%; width: 0; background: var(--berry); border-radius: 99px; transition: width .3s ease; }
.onb-title { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; margin: 8px 2px 24px; line-height: 1.15; }
.onb-body { display: flex; flex-direction: column; gap: 12px; }
.onb-choice { background: var(--card); border: none; border-radius: 18px; padding: 20px 18px; font-size: 17px;
  font-weight: 800; text-align: left; cursor: pointer; box-shadow: var(--sh-meal); color: var(--ink);
  font-family: inherit; transition: transform .05s; }
.onb-choice:active { transform: scale(0.99); }
.onb-input { width: 100%; border: none; border-radius: 18px; padding: 22px; font-size: 30px; font-weight: 800;
  text-align: center; background: var(--card); color: var(--ink); box-shadow: var(--sh-card); font-family: inherit; }
.onb-input:focus { outline: 2px solid var(--berry); }
#onb-controls { margin-top: 16px; }

/* «Составляем твой план» */
.plan-ring { position: relative; width: 220px; height: 220px; }
.plan-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.plan-track { fill: none; stroke: var(--track); stroke-width: 18; }
.plan-fg { fill: none; stroke: var(--berry); stroke-width: 18; stroke-linecap: round;
  stroke-dasharray: 640.9; stroke-dashoffset: 640.9; }
.plan-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 56px; font-weight: 800; letter-spacing: -0.03em; }
.plan-title { font-size: 32px; font-weight: 800; text-align: center; line-height: 1.15; margin-top: 12px; }
.plan-list { display: flex; flex-direction: column; gap: 20px; margin-top: 36px; width: 100%; max-width: 320px; }
.plan-item { display: flex; align-items: center; gap: 16px; font-size: 19px; font-weight: 800; color: var(--muted2);
  transition: color .3s; }
.plan-item.done { color: var(--ink); }
.plan-check { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--track); flex: none;
  display: flex; align-items: center; justify-content: center; transition: background .3s, border-color .3s; }
.plan-item.done .plan-check { background: var(--berry); border-color: var(--berry); }
.plan-item.done .plan-check::after { content: '✓'; color: #fff; font-size: 15px; font-weight: 800; }

/* Переключатель метода добавления (Фразой / Поиск) */
.segment { display: flex; gap: 6px; background: var(--track); border-radius: 16px; padding: 5px; margin-bottom: 18px; }
.seg-btn { flex: 1; border: none; background: transparent; border-radius: 12px; padding: 11px 8px;
  font-size: 15px; font-weight: 800; color: var(--muted); cursor: pointer; font-family: inherit;
  transition: background .15s, color .15s, box-shadow .15s; letter-spacing: -0.01em; }
.seg-btn.active { background: var(--card); color: var(--ink); box-shadow: var(--sh-soft); }

/* Строка поиска */
.search-bar { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 16px;
  padding: 4px 14px; box-shadow: var(--sh-meal); }
.search-ic { color: var(--muted2); flex: 0 0 auto; }
.search-input { flex: 1; border: none; background: transparent; padding: 13px 0; font-size: 17px;
  font-weight: 600; font-family: inherit; color: var(--ink); min-width: 0; }
.search-input:focus { outline: none; }
.search-input::placeholder { color: var(--muted2); font-weight: 600; }
.food-clear { border: none; background: var(--track); color: var(--muted); width: 26px; height: 26px;
  border-radius: 50%; font-size: 14px; font-weight: 800; cursor: pointer; flex: 0 0 auto; font-family: inherit;
  display: flex; align-items: center; justify-content: center; }

/* Бейдж «скоро» (в фото-карточке) */
.soon { font-size: 9px; font-weight: 800; background: var(--muted2); color: #fff; border-radius: 5px;
  padding: 2px 5px; letter-spacing: .02em; text-transform: uppercase; }

/* Карточка-кнопка «Сфотографировать блюдо» → открывает AI-камеру */
.scan-cta { display: flex; align-items: center; gap: 12px; background: #FFE1D5; border-radius: 18px;
  padding: 13px 15px; margin-top: 16px; width: 100%; border: none; text-align: left; cursor: pointer;
  font-family: inherit; transition: transform .05s, filter .15s; }
.scan-cta:active { transform: scale(0.99); filter: brightness(0.98); }
.scan-ic { width: 42px; height: 42px; border-radius: 12px; background: var(--berry); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; color: #fff; }
.scan-txt { flex: 1; min-width: 0; }
.scan-title { font-size: 15px; font-weight: 800; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.scan-sub { font-size: 13px; font-weight: 600; color: #865044; margin-top: 1px; }
.scan-arrow { color: var(--berry); flex: 0 0 auto; }

/* Список результатов поиска */
.results-head { font-size: 13px; font-weight: 800; color: var(--muted); margin: 20px 4px 10px; letter-spacing: .02em; }
.food-list { display: flex; flex-direction: column; gap: 1px; background: var(--card); border-radius: 20px;
  overflow: hidden; box-shadow: var(--sh-meal); }
.food-list:empty { display: none; }
.food-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; cursor: pointer;
  border-bottom: 1px solid var(--track); transition: background .1s; background: var(--card); text-align: left;
  border-left: none; border-right: none; border-top: none; width: 100%; font-family: inherit; }
.food-row:last-child { border-bottom: none; }
.food-row:active { background: var(--track); }
.food-emoji { font-size: 24px; flex: 0 0 auto; width: 26px; text-align: center; }
.food-info { flex: 1; min-width: 0; }
.food-name { font-size: 16px; font-weight: 800; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.food-brand { font-size: 13px; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.food-kcal { text-align: right; flex: 0 0 auto; }
.food-kcal-n { font-size: 16px; font-weight: 800; color: var(--ink); }
.food-kcal-u { font-size: 12px; font-weight: 600; color: var(--muted); }
.food-plus { width: 32px; height: 32px; border-radius: 50%; background: var(--track); flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; color: var(--ink); }

/* Лист выбора порции (bottom sheet) */
.sheet { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20,12,16,.42); }
.sheet-card { position: relative; width: 100%; max-width: 520px; background: var(--card);
  border-radius: 28px 28px 0 0; padding: 12px 22px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 50px -20px rgba(40,20,30,.5); animation: sheet-up .25s ease; }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grip { width: 40px; height: 5px; border-radius: 99px; background: var(--track); margin: 2px auto 16px; }
.sheet-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.sheet-emoji { width: 52px; height: 52px; border-radius: 50%; background: #FCE9ED; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 26px; }
.sheet-head-txt { flex: 1; min-width: 0; }
.sheet-name { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.sheet-sub { font-size: 13px; font-weight: 600; margin-top: 2px; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 4px 0 18px; }
.step-btn { width: 52px; height: 52px; border-radius: 50%; border: none; background: var(--track);
  font-size: 28px; font-weight: 800; color: var(--ink); cursor: pointer; flex: 0 0 auto; font-family: inherit;
  display: flex; align-items: center; justify-content: center; line-height: 1; }
.step-btn:active { transform: scale(0.94); }
.step-field { display: flex; align-items: baseline; gap: 6px; min-width: 120px; justify-content: center; }
.step-input { width: 92px; border: none; background: transparent; text-align: right; font-size: 40px;
  font-weight: 800; color: var(--ink); font-family: inherit; letter-spacing: -0.03em; padding: 0; }
.step-input:focus { outline: none; }
.step-unit { font-size: 20px; font-weight: 800; color: var(--muted); }
.portion-kcal { text-align: center; font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
.portion-kcal span { color: var(--berry); }
.portion-macros { text-align: center; font-size: 14px; font-weight: 600; margin: 4px 0 20px; }

/* Редактирование приёма пищи */
.meal { cursor: pointer; transition: transform .05s; }
.meal:active { transform: scale(0.99); }
.ms-title { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; text-align: center; margin-bottom: 16px; }
.ms-input { width: 100%; border: none; border-radius: 14px; padding: 15px; font-size: 16px; font-weight: 600;
  font-family: inherit; background: var(--bg); color: var(--ink); margin-bottom: 12px; }
.ms-input:focus { outline: 2px solid var(--berry); }
.ms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.ms-field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 800; color: var(--muted); }
.ms-field input { border: none; border-radius: 12px; padding: 13px; font-size: 17px; font-weight: 800;
  font-family: inherit; background: var(--bg); color: var(--ink); width: 100%; }
.ms-field input:focus { outline: 2px solid var(--berry); }
.btn-delete { width: 100%; margin-top: 10px; border: none; border-radius: 14px; padding: 14px;
  background: #FCE9ED; color: var(--berry); font-size: 15px; font-weight: 800; font-family: inherit; cursor: pointer; }
.btn-delete:active { filter: brightness(0.97); }

/* Тренд веса */
.wt-empty { color: var(--muted); font-size: 14px; font-weight: 600; padding: 8px 2px; }
.wt-svg { width: 100%; height: 90px; display: block; }
.wt-line { fill: none; stroke: var(--berry); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.wt-dot { fill: var(--berry); }
.wt-cur { font-size: 16px; font-weight: 800; margin-bottom: 6px; }

/* ===== AI-камера (тёмный полноэкранный слой) ===== */
/* Экран съёмки перекрывает светлый #app целиком, поэтому fixed inset:0. */
.screen-camera { position: fixed; inset: 0; z-index: 60; background: #141017; color: #fff;
  display: flex; flex-direction: column;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 22px calc(env(safe-area-inset-bottom, 0px) + 20px); }
.screen-camera.hidden { display: none !important; }

.cam-head { display: flex; align-items: center; justify-content: space-between; }
.cam-icon-btn { width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.1); color: #fff; font-size: 22px; display: flex; align-items: center;
  justify-content: center; flex: 0 0 auto; font-family: inherit; }
.cam-icon-btn:active { transform: scale(0.94); }
.cam-wordmark { display: flex; align-items: flex-end; gap: 3px; }
.cam-wordmark .cam-n { font-size: 26px; font-weight: 800; letter-spacing: -.055em; line-height: .9; color: #fff; }
.cam-wordmark .cam-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--berry); margin-bottom: 4px; }

.cam-viewfinder { position: relative; margin-top: 22px; flex: 1 1 auto; min-height: 0; border-radius: 26px;
  overflow: hidden; background: linear-gradient(150deg, #3a2f28, #241c22 60%, #171018); }
.cam-vf-ph { position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,.04) 0 12px, rgba(255,255,255,0) 12px 24px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.cam-vf-emoji { font-size: 54px; line-height: 1; opacity: .9; }
.cam-vf-cap { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: rgba(255,255,255,.5); }
.cam-frame { position: absolute; inset: 0; width: 100%; height: 100%; }

.cam-tips { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 20px 8px 4px; }
.cam-tip { font-size: 16px; font-weight: 600; color: rgba(255,255,255,.82); line-height: 1.35; max-width: 320px; }
.cam-tip-accent { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 800;
  color: #fff; background: rgba(232,78,107,.16); border: 1px solid rgba(232,78,107,.4); border-radius: 14px;
  padding: 10px 14px; }
.cam-tip-accent .ic { color: var(--berry); font-size: 20px; }

.cam-controls { display: flex; align-items: center; justify-content: space-between; padding: 18px 8px 4px; }
.cam-side-btn { display: flex; flex-direction: column; align-items: center; gap: 7px; width: 68px;
  background: none; border: none; cursor: pointer; font-family: inherit; }
.cam-side-spacer { visibility: hidden; }
.cam-side-ic { width: 48px; height: 48px; border-radius: 14px; background: rgba(255,255,255,.12);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 24px; }
.cam-side-btn:active .cam-side-ic { transform: scale(0.94); }
.cam-side-lbl { font-size: 12px; font-weight: 600; color: rgba(255,255,255,.7); }
.cam-shutter { width: 84px; height: 84px; border-radius: 50%; border: none; cursor: pointer; color: #fff;
  background: var(--berry); font-size: 36px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 6px rgba(232,78,107,.28), 0 16px 34px -10px rgba(232,78,107,.7); }
.cam-shutter:active { transform: scale(0.96); }

.cam-loading { position: fixed; inset: 0; z-index: 70; background: rgba(20,16,23,.86);
  backdrop-filter: blur(3px); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; }
.cam-spinner { width: 52px; height: 52px; border-radius: 50%; border: 5px solid rgba(255,255,255,.18);
  border-top-color: var(--berry); animation: cam-spin .8s linear infinite; }
@keyframes cam-spin { to { transform: rotate(360deg); } }
.cam-loading-txt { font-size: 17px; font-weight: 800; color: #fff; }

/* Экран согласия (строгий гейт ПДн). Прокручиваемая шапка + кнопка «Принять» снизу. */
#screen-consent { display: flex; flex-direction: column; min-height: 82vh; padding-top: 24px; }
#screen-consent.hidden { display: none !important; }
.consent-wrap { flex: 1; }
.consent-docs { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.consent-doc { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--card); border-radius: 16px; padding: 15px 17px; box-shadow: var(--sh-soft);
  color: var(--ink); font-weight: 800; font-size: 15px; text-decoration: none; }
.consent-doc .ic { color: var(--muted); font-size: 18px; }
.consent-doc:active { transform: scale(0.99); }
.consent-fine { font-size: 13px; line-height: 1.5; text-align: center; margin: 4px 4px 20px; }

/* Ссылки-документы в профиле (строки внутри карточки с шевроном). */
.doc-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 2px; color: var(--ink); font-weight: 800; font-size: 15px; text-decoration: none;
  border-top: 1px solid var(--track); }
.doc-row:first-of-type { border-top: none; }
.doc-row .ic { color: var(--muted); font-size: 18px; }
.doc-row:active { opacity: .6; }

/* Характер бренда и быстрый вход в запись еды. */
.wordmark { display: flex; align-items: center; gap: 5px; font-size: 34px; font-weight: 900; letter-spacing: -.065em; line-height: 1; }
.wordmark-dot { width: 9px; height: 9px; flex: 0 0 9px; align-self: flex-end; margin-bottom: 5px; border-radius: 50%; background: var(--berry); }
.streak { background: #F8EBC4; box-shadow: none; padding: 10px 13px; font-size: 15px; }
.streak .ic { color: #AD601C; }
.streak-caption { font-size: 11px; font-weight: 700; }
.date-divider { color: #C4B8B3; }
.add-meal-cta { display: flex; align-items: center; gap: 13px; width: 100%; margin-top: 20px; padding: 16px; border: none; border-radius: 21px; background: var(--ink); color: #fff; text-align: left; font-family: inherit; cursor: pointer; }
.add-meal-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; background: #FF9C7E; color: var(--ink); font-size: 23px; flex: 0 0 auto; }
.add-meal-copy { display: flex; flex: 1; flex-direction: column; gap: 3px; }
.add-meal-copy strong { font-size: 19px; font-weight: 800; }
.add-meal-copy > span { font-size: 11px; color: #D4CCD9; }
.add-meal-cta > .ic { font-size: 20px; color: #D4CCD9; }
.add-meal-cta:active { transform: scale(.99); }
.meal-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 10px; font-size: 13px; line-height: 1.5; }
.meal-empty strong { color: var(--ink); font-size: 16px; }
.empty-icon { display: grid; place-items: center; width: 46px; height: 46px; background: #F8EBC4; border-radius: 16px; font-size: 25px; color: #91651B; margin-bottom: 3px; }
.eyebrow { font-size: 10px; font-weight: 800; color: var(--berry); letter-spacing: .1em; margin-bottom: 10px; }
.add-intro { font-size: 14px; font-weight: 600; margin: 10px 0 4px; }
.phrase { border: 1px solid var(--track); line-height: 1.6; font-weight: 600; }
.phrase::placeholder { color: var(--muted); opacity: 1; }
.parse-note { margin: 12px 14px 0; text-align: center; font-size: 12px; line-height: 1.5; }
.segment { background: #EFE9E3; }
.seg-btn { font-weight: 700; }
.sheet-card { max-height: 90dvh; overflow-y: auto; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid #8064B4; outline-offset: 3px; }
button, input, textarea { touch-action: manipulation; }
.mic-btn { touch-action: none; }
.link, .meals-toggle { min-height: 44px; }
@media (max-width: 360px) {
  #app { padding-left: 14px; padding-right: 14px; }
  .balance-card { padding: 16px; }
  .gauge-row { grid-template-columns: 1fr 148px; }
  .gauge { width: 148px; height: 148px; }
  .gauge-num { font-size: 33px; }
  .side-num { font-size: 24px; }
  .macro { padding: 13px 9px; }
  .macro-val { font-size: 10px; }
  .section-title { font-size: 17px; }
  .meal-ic { width: 38px; height: 38px; font-size: 21px; }
  .meal-sub { font-size: 10px; }
  .stepper-sm { gap: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.draft-tools { display: flex; justify-content: flex-end; margin: -10px 2px 8px; }
.draft-tools:has(.link.hidden) { display: none; }
.draft-tools .link { color: var(--muted); font-size: 12px; font-weight: 600; min-height: 36px; padding: 0 6px; }
