/* =========================================================================
   NOCTURNE — токены и компоненты дизайн-системы (адаптировано под приложение
   «Книга рецептов»). Акцент заменён на тёплый янтарь (см. design_ref/README.md,
   секция «Accent color change»). Без внешних CDN — шрифт грузится из системных
   фолбэков (Inter не забандлен локально).
   ========================================================================= */

:root {
  color-scheme: dark;

  /* — основа: тёмный, почти нейтральный сине-серый грунт, никогда не чёрный — */
  --color-bg: #161826;
  --color-surface: #232532;
  --color-surface-2: #2a2c3b;
  --color-text: #e9e9ed;
  --color-divider: color-mix(in srgb, #e9e9ed 16%, transparent);

  /* — нейтральная рампа — */
  --color-neutral-100: #f3f5fe;
  --color-neutral-200: #e4e7f5;
  --color-neutral-300: #cfd3e5;
  --color-neutral-400: #b2b6ca;
  --color-neutral-500: #9397ab;
  --color-neutral-600: #75798c;
  --color-neutral-700: #595d6c;
  --color-neutral-800: #3f424d;
  --color-neutral-900: #292b31;

  /* — акцент: тёплый янтарь (замена дефолтного blurple Nocturne) — */
  --color-accent: #d99a5b;
  --color-accent-100: #fdf3e7;
  --color-accent-200: #f9e3c9;
  --color-accent-300: #f0cd9e;
  --color-accent-400: #e6b378;
  --color-accent-500: #d99a5b;
  --color-accent-600: #b97d45;
  --color-accent-700: #8f6136;
  --color-accent-800: #614228;
  --color-accent-900: #3a281a;
  /* моно-акцентная схема: accent-2 зеркалит accent */
  --color-accent-2: var(--color-accent);
  --color-accent-2-100: var(--color-accent-100);
  --color-accent-2-800: var(--color-accent-800);

  --font-heading: -apple-system, "SF Pro Text", "Segoe UI", Roboto, Inter, sans-serif;
  --font-heading-weight: 500;
  --font-body: -apple-system, "SF Pro Text", "Segoe UI", Roboto, Inter, sans-serif;

  /* — плотный интервальный масштаб (density 0.7×) — */
  --space-1: 2.8px;
  --space-2: 5.6px;
  --space-3: 8.4px;
  --space-4: 11.2px;
  --space-6: 16.8px;
  --space-8: 22.4px;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  /* — хайрлайн-бордер + мягкая тень вместо тяжёлых drop-shadow — */
  --shadow-sm: 0 0 0 1px #3f424d;
  --shadow-md: 0 0 0 1px #595d6c, 0 6px 18px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 0 0 1px #9397ab, 0 16px 40px rgba(0, 0, 0, 0.65);

  --nav-h: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
}

a { color: var(--color-accent); text-decoration: none; text-underline-offset: 3px; }
button { font-family: inherit; }
img, video { display: block; max-width: 100%; }
::-webkit-scrollbar { width: 0; height: 0; }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-heading-weight);
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 6px;
}
/* Типографическая шкала приложения (компактнее дефолтного масштаба Nocturne) */
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; margin-bottom: 10px; }
h5 { font-size: 13px; }
h6 { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }

.text-muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--color-accent) 30%, transparent); }

.hr {
  height: 1px; border: 0; margin: var(--space-4) 0;
  background: linear-gradient(to right,
    transparent, var(--color-divider) 48px,
    var(--color-divider) calc(100% - 48px), transparent);
}

/* ================================ Кнопки ================================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; text-decoration: none;
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.2; color: var(--color-text);
  background: transparent; border: 1px solid transparent;
  padding: 10px calc(var(--space-3) * 1.4);
  border-radius: var(--radius-md);
  transition: background 0.12s ease, transform 0.1s ease, border-color 0.12s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn svg { display: block; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { color: var(--color-accent); border-color: var(--color-accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--color-accent) 12%, transparent); }
.btn-primary:active { background: color-mix(in srgb, var(--color-accent) 22%, transparent); }
.btn-primary.is-done { color: var(--color-neutral-400); border-color: var(--color-divider); }
.btn-secondary { border-color: var(--color-divider); }
.btn-secondary:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.btn-secondary:active { background: color-mix(in srgb, var(--color-text) 14%, transparent); }
.btn-ghost { color: var(--color-accent); padding-inline: var(--space-2); border: none; }
.btn-ghost:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); }
.btn-ghost:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.btn-icon {
  width: 36px; height: 36px; padding: 0; border-radius: 50%;
  border: 1px solid var(--color-divider); color: var(--color-text);
}
.btn-icon:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
/* Маленькая кнопка-иконка (обновить рецепт дня и т.п.) */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; padding: 0;
  border: 1px solid var(--color-divider); background: transparent;
  color: color-mix(in srgb, var(--color-text) 70%, transparent); cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.icon-btn:hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); color: var(--color-accent); }
.icon-btn:active { transform: rotate(-45deg); }
.btn-block { width: 100%; margin-top: var(--space-2); }

/* Плавающие круглые кнопки над фото (back/heart) */
.floating-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, #e9e9ed 25%, transparent);
  background: color-mix(in srgb, #161826 60%, transparent);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--color-text);
  transition: transform 0.12s ease, background 0.15s ease;
}
.floating-btn:active { transform: scale(0.92); }

/* Круглые ghost-степперы (норма ккал / порции) */
.stepper-btn {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--color-divider); background: transparent;
  color: var(--color-text); cursor: pointer; font-size: 14px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.stepper-btn:hover { border-color: var(--color-accent); color: var(--color-accent); }
.stepper-btn:active { transform: scale(0.9); background: color-mix(in srgb, var(--color-accent) 15%, transparent); }

/* ================================= Формы ================================= */

.field { margin-bottom: var(--space-4); }
.field > label {
  display: block; font-size: 12px; margin-bottom: 5px;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.input {
  width: 100%; min-height: 40px; padding: 8px 12px; font: inherit;
  font-size: 14px; color: var(--color-text); caret-color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-divider); border-radius: var(--radius-md);
  transition: border-color 0.12s ease;
}
.input::placeholder { color: color-mix(in srgb, var(--color-text) 40%, transparent); }
.input:hover { border-color: color-mix(in srgb, var(--color-text) 45%, transparent); }
.input:focus-visible { border-color: var(--color-accent); outline-offset: 0; }

.seg {
  display: flex; width: 100%; gap: 4px; padding: 4px;
  background: color-mix(in srgb, var(--color-text) 5%, transparent);
  border: 1px solid var(--color-divider); border-radius: 999px;
}
.seg-opt {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 6px; font-size: 12.5px; cursor: pointer; text-align: center;
  border-radius: 999px; color: color-mix(in srgb, var(--color-text) 65%, transparent);
  transition: background 0.18s ease, color 0.18s ease;
}
.seg-opt input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.seg-opt:has(input:checked) {
  background: color-mix(in srgb, var(--color-accent) 18%, transparent);
  color: var(--color-accent-200); font-weight: 500;
}
.seg-opt:not(:has(input:checked)):hover { background: color-mix(in srgb, var(--color-text) 7%, transparent); }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 1px; }

/* ================================= Карточки =============================== */

.card {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-3); border-radius: var(--radius-md); background: var(--color-surface);
}
.card-kicker { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-accent); }
.card-title { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 17px; line-height: 1.2; }
.card-body { margin: 0; font-size: 13px; opacity: 0.8; }
.card-meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: color-mix(in srgb, var(--color-text) 50%, transparent); }
.elev-sm { box-shadow: var(--shadow-sm); }
.elev-md { box-shadow: var(--shadow-md); }
.elev-lg { box-shadow: var(--shadow-lg); }

/* ================================== Теги =================================== */

.tag {
  display: inline-flex; align-items: center; font-size: 11px;
  letter-spacing: 0.02em; padding: 3px 10px; white-space: nowrap;
  border-radius: calc(var(--radius-md) * 0.75);
}
.tag-accent { background: var(--color-accent-800); color: var(--color-accent-100); }
.tag-neutral { background: var(--color-neutral-800); color: var(--color-neutral-100); }
.tag-outline {
  border: 1px solid var(--color-accent); color: var(--color-accent);
  background: transparent; cursor: pointer; transition: background 0.12s ease, transform 0.1s ease;
}
.tag-outline:active { transform: scale(0.95); background: color-mix(in srgb, var(--color-accent) 15%, transparent); }

/* ============================== Каркас приложения ========================== */

.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; position: relative; background: var(--color-bg); }

.app-view {
  flex: 1 1 auto;
  padding-top: calc(var(--safe-top) + 6px);
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  min-width: 0;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.16s ease, transform 0.16s ease;
  opacity: 1;
  transform: translateY(0);
}
.app-view.route-enter { opacity: 0; transform: translateY(8px); }

.screen { padding: 4px 20px 28px; }

/* ================================ Таб-бар ================================= */

.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex;
  padding: 8px 6px calc(8px + var(--safe-bottom));
  border-top: 1px solid var(--color-divider);
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(16px) saturate(1.3);
  z-index: 50;
}
.tab-item {
  flex: 1; background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 0; color: color-mix(in srgb, var(--color-text) 45%, transparent);
  transition: color 0.15s ease, transform 0.1s ease;
}
.tab-item:active { transform: scale(0.94); }
.tab-item svg { display: block; }
.tab-item span { font-size: 10px; }
.tab-item.active { color: var(--color-accent); }

/* ============================== Скролл-ряды ================================ */

.hscroll {
  display: flex; gap: 10px; overflow-x: auto;
  /* вертикальные отступы, чтобы тень-кольцо карточек (box-shadow 0 0 0 1px) не
     обрезалась неявным вертикальным клипом при overflow-x:auto */
  margin: 0 -20px; padding: 4px 20px;
  -webkit-overflow-scrolling: touch;
}
.hscroll::-webkit-scrollbar { display: none; }

/* ============================ Сетка карточек рецептов ======================= */

.recipe-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.recipe-card { display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.recipe-card-media {
  position: relative; width: 100%; aspect-ratio: 4/3;
  border-radius: var(--radius-lg); overflow: hidden; background: var(--color-surface);
}
.recipe-card-media img {
  width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity 0.35s ease;
}
.recipe-card-media img.loaded { opacity: 1; }
.recipe-card-media .placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 30px; background: linear-gradient(160deg, var(--color-surface-2), var(--color-surface));
  color: color-mix(in srgb, var(--color-text) 35%, transparent);
}
.recipe-card-fav {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid color-mix(in srgb, #e9e9ed 25%, transparent);
  background: color-mix(in srgb, #161826 55%, transparent);
  backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center;
  z-index: 2; cursor: pointer; padding: 0; transition: transform 0.12s ease;
}
.recipe-card-fav:active { transform: scale(0.85); }
.recipe-card-time {
  position: absolute; bottom: 8px; left: 8px; font-size: 11px; padding: 3px 8px; border-radius: 6px;
  background: color-mix(in srgb, #161826 60%, transparent); color: #e9e9ed;
  backdrop-filter: blur(6px); z-index: 2;
}
.recipe-card-video {
  position: absolute; bottom: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%;
  background: color-mix(in srgb, #161826 60%, transparent); color: var(--color-accent-300);
  backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center;
  font-size: 9px; z-index: 2;
}
.recipe-card-title {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 14px; line-height: 1.25; color: var(--color-text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.recipe-card-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; color: color-mix(in srgb, #e9e9ed 55%, transparent); }

/* Скелетон-карточка на время загрузки */
.skeleton { background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-surface-2) 37%, var(--color-surface) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-md); }
.skeleton-media { border-radius: var(--radius-lg); aspect-ratio: 4/3; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ================================ Пустые состояния ========================= */

.empty-state { text-align: center; padding: 48px 16px; color: color-mix(in srgb, var(--color-text) 60%, transparent); font-size: 13px; line-height: 1.6; }
.empty-state .emoji { font-size: 36px; display: block; margin-bottom: 10px; }

/* ================================ Прогресс-бары ============================ */

.progress-track { height: 6px; border-radius: 99px; background: var(--color-neutral-900); overflow: hidden; }
.progress-track.lg { height: 8px; }
.progress-track.sm { height: 5px; }
.progress-fill { height: 100%; border-radius: 99px; background: var(--color-accent); transition: width 0.3s ease; }
.progress-fill.macro { background: var(--color-accent-400); }
.progress-row + .progress-row { margin-top: var(--space-4); }
.progress-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 5px; }
.progress-head .val { opacity: 0.6; }

/* ============================== Оверлей рецепта ============================= */

.recipe-overlay {
  position: fixed; inset: 0; z-index: 200; background: var(--color-bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  transform: translateY(100%); opacity: 0;
  transition: transform 0.22s ease, opacity 0.22s ease;
  pointer-events: none;
}
.recipe-overlay.open { transform: translateY(0); opacity: 1; pointer-events: auto; }

.recipe-hero {
  position: relative; width: 100%; aspect-ratio: 4/3; background: var(--color-surface);
}
.recipe-hero img, .recipe-hero video { width: 100%; height: 100%; object-fit: cover; }
/* Видео у автора вертикальные (9:16) — контейнер точно под эту пропорцию,
   видео заполняет кадр без полос и без обрезки; фото остаются в 4:3 cover. */
.recipe-hero.is-video { aspect-ratio: 9/16; background: #000; }
.recipe-hero.is-video video { object-fit: cover; }
.recipe-hero .placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 60px; background: linear-gradient(160deg, var(--color-surface-2), var(--color-surface));
  color: color-mix(in srgb, var(--color-text) 35%, transparent);
}
.recipe-hero .floating-btn.back { position: absolute; top: calc(var(--safe-top) + 14px); left: 16px; z-index: 5; }
/* Кнопку избранного опускаем ниже системных кнопок Telegram (свернуть/⋯ вверху справа). */
.recipe-hero .floating-btn.fav { position: absolute; top: calc(var(--safe-top) + 24px); right: 16px; z-index: 5; }

.recipe-body { padding: 18px 20px 40px; }
.recipe-tags { display: flex; gap: 8px; margin-bottom: 10px; }

/* Сводная карточка КБЖУ */
:root {
  --macro-p: #db6c46; /* белки — тёпло-оранжевый */
  --macro-f: #e6c04e; /* жиры — золотой */
  --macro-c: #cba379; /* углеводы — песочный */
}
.nutri-card { padding: 16px; margin-bottom: 18px; }
.nutri-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.nutri-col .kicker { margin-bottom: 4px; }
.nutri-col.right { text-align: right; }
.nutri-kcal { display: flex; align-items: baseline; gap: 6px; }
.nutri-col.right .nutri-kcal { justify-content: flex-end; }
.nutri-kcal b { font-family: var(--font-heading); font-weight: 500; font-size: 30px; line-height: 1; letter-spacing: -0.5px; }
.nutri-kcal span { font-size: 13px; opacity: 0.55; }
.nutri-kcal.sm b { font-size: 19px; }

.macro-bar { display: flex; gap: 4px; height: 10px; margin-bottom: 14px; }
.macro-bar .seg { flex-basis: 0; min-width: 6px; border-radius: 99px; transition: flex-grow 0.25s ease; }
.macro-bar .seg.macro-p { background: var(--macro-p); }
.macro-bar .seg.macro-f { background: var(--macro-f); }
.macro-bar .seg.macro-c { background: var(--macro-c); }

.macro-basis { font-size: 11px; letter-spacing: 0.4px; text-transform: uppercase; opacity: 0.45; text-align: right; margin: -4px 0 8px; }
.macro-cells { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.macro-cell { padding: 12px; gap: 6px; }
.macro-label { display: flex; align-items: center; gap: 7px; font-size: 13px; opacity: 0.8; }
.macro-label .mdot { width: 8px; height: 8px; border-radius: 99px; flex: 0 0 auto; }
.mdot.macro-p { background: var(--macro-p); }
.mdot.macro-f { background: var(--macro-f); }
.mdot.macro-c { background: var(--macro-c); }
.macro-val { font-family: var(--font-heading); font-weight: 500; font-size: 22px; line-height: 1; }
.macro-val span { font-size: 12px; opacity: 0.5; margin-left: 2px; }

.nutri-foot { display: flex; justify-content: space-between; align-items: center; font-size: 14px; opacity: 0.85; }
.nutri-foot .foot-item { display: flex; align-items: center; gap: 6px; }
.nutri-foot b { font-family: var(--font-heading); font-weight: 500; }
.foot-clock { flex: 0 0 auto; }

.portion-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; margin-bottom: 16px; border-radius: var(--radius-md);
  background: var(--color-surface); border: 1px solid var(--color-divider);
}
.portion-row .label { font-size: 12px; opacity: 0.7; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper .value { font-size: 13px; min-width: 34px; text-align: center; }
.kcal-computed { font-family: var(--font-heading); font-weight: 500; font-size: 22px; color: var(--color-accent-300); }
.kcal-computed span { font-size: 12px; opacity: 0.6; }
.stepper.sm { gap: 6px; }
.stepper.sm .stepper-btn { width: 26px; height: 26px; font-size: 15px; }
.stepper.sm .value { font-size: 13px; min-width: 42px; }

/* Редактируемые цели по Б/Ж/У в профиле */
.macro-goal + .macro-goal { margin-top: 14px; }
.mg-head { display: flex; align-items: center; justify-content: space-between; }
.mg-name { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.mg-name .mdot { width: 8px; height: 8px; border-radius: 99px; flex: 0 0 auto; }
.progress-fill.macro-p { background: var(--macro-p); }
.progress-fill.macro-f { background: var(--macro-f); }
.progress-fill.macro-c { background: var(--macro-c); }

.ing-group-label { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; color: color-mix(in srgb, var(--color-text) 55%, transparent); margin: 14px 0 6px; }
.ing-group-label:first-child { margin-top: 0; }
.ing-line {
  display: flex; align-items: flex-start; gap: 10px; font-size: 13.5px;
  padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--color-divider);
}
.ing-line .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--color-accent); flex-shrink: 0; margin-top: 6px; }
.ing-line .text { flex: 1; }
.ing-line .hint { display: block; font-size: 11px; opacity: 0.5; margin-top: 2px; }

.step-row { display: flex; gap: 12px; margin-bottom: 10px; }
.step-num {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--color-accent);
  color: var(--color-accent-300); font-size: 11px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.step-text { font-size: 13.5px; line-height: 1.5; opacity: 0.9; padding-top: 1px; }
.step-text .title { font-weight: 500; opacity: 1; margin-bottom: 2px; }
.step-dur { font-size: 11px; opacity: 0.5; margin-top: 3px; }

.sticky-cta {
  /* sticky (не fixed): transform на .recipe-overlay.open ломает fixed-позиционирование,
     превращая его в относительное. sticky прилипает к низу скролл-контейнера оверлея. */
  position: sticky; bottom: 0; z-index: 3;
  padding: 14px 20px calc(20px + var(--safe-bottom));
  background: linear-gradient(to top, var(--color-bg) 72%, transparent);
}

.meal-picker {
  display: flex; gap: 8px; flex-wrap: wrap; overflow: hidden; max-height: 0; opacity: 0;
  padding: 0 2px; margin-bottom: 0; border-radius: var(--radius-md);
  background: var(--color-surface); box-shadow: var(--shadow-sm);
  transition: max-height 0.2s ease, opacity 0.2s ease, margin-bottom 0.2s ease, padding 0.2s ease;
}
.meal-picker.open { max-height: 120px; opacity: 1; padding: 10px; margin-bottom: 10px; }
.meal-picker .tag-outline { padding: 7px 14px; font-size: 12.5px; }

/* Инлайн-пикер «Подогнать порцию под цель» (пресеты ккал + свободный ввод) */
.fit-picker {
  display: flex; flex-direction: column; gap: 10px; overflow: hidden; max-height: 0; opacity: 0;
  border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-sm);
  transition: max-height 0.2s ease, opacity 0.2s ease, margin-bottom 0.2s ease, padding 0.2s ease;
}
.fit-picker.open { max-height: 160px; opacity: 1; padding: 12px; margin-bottom: 16px; }
.fit-presets { display: flex; gap: 8px; }
.fit-input-row { display: flex; gap: 8px; }
.fit-input-row .input { flex: 1; }

/* =============================== Профиль =================================== */

.profile-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0; object-fit: cover;
  background: var(--color-surface-2); display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--color-accent-300); border: 1px solid var(--color-divider);
}
.profile-name { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 17px; }

.day-switch {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 14px;
}
.day-switch .day-label { font-size: 13px; font-weight: 500; text-align: center; flex: 1; text-transform: capitalize; }

.plan-row { display: flex; flex-direction: row; align-items: center; padding: 10px 12px; gap: 10px; }
.plan-row-thumb { width: 38px; height: 38px; border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; background: var(--color-surface-2); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.plan-row-thumb img { width: 100%; height: 100%; object-fit: cover; }
.plan-row-info { flex: 1; min-width: 0; }
.plan-row-info .t { font-size: 13px; font-family: var(--font-heading); font-weight: var(--font-heading-weight); }
.plan-row-info .m { font-size: 11px; opacity: 0.6; }

.link-card {
  display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; cursor: pointer; margin-bottom: 10px;
  transition: background 0.12s ease;
}
.link-card:active { background: color-mix(in srgb, var(--color-text) 6%, var(--color-surface)); }
.link-card .chev { opacity: 0.4; }

/* ============================== Подстраницы (Рацион/Список) ================= */

.subpage-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.subpage-header h1 { margin: 0; }

.ration-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 18px; }
/* Компактная KPI-ячейка сводки (используется в Рационе, «Осталось сегодня», Трендах) */
.stat-cell { align-items: center; text-align: center; padding: 12px 6px; gap: 3px; }
.stat-cell .v { font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 18px; line-height: 1.15; }
.stat-cell .v.accent { color: var(--color-accent); }
.stat-cell .l { font-size: 10px; opacity: 0.6; text-align: center; }

/* ============================== Тренды за неделю ============================= */

.trend-chart { position: relative; height: 150px; margin: 8px 0 2px; padding-top: 14px; }
.trend-goal-line { position: absolute; left: 0; right: 0; height: 1px; background: var(--color-accent); opacity: 0.55; z-index: 1; }
.trend-goal-line::after {
  content: "цель"; position: absolute; right: 0; top: -13px; font-size: 9px;
  letter-spacing: 0.04em; color: var(--color-accent); opacity: 0.8;
}
.trend-bars { position: relative; z-index: 2; height: 100%; display: flex; align-items: flex-end; gap: 8px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.trend-bar {
  width: 100%; max-width: 26px; min-height: 2px; border-radius: 6px 6px 3px 3px;
  background: var(--color-accent-800); transition: height 0.3s ease;
}
.trend-bar.protein { background: color-mix(in srgb, var(--macro-p) 55%, var(--color-accent-800)); }
.trend-bar.hit { background: var(--color-accent); }
.trend-bar.protein.hit { background: var(--macro-p); }
.trend-day-label { font-size: 10px; opacity: 0.55; margin-top: 6px; text-transform: capitalize; }

.meal-card { margin-bottom: 12px; padding: 0; overflow: hidden; }
.meal-card-label {
  padding: 10px 14px 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--color-accent);
}
.meal-card-body { display: flex; gap: 12px; padding: 8px 14px 12px; cursor: pointer; }
.meal-card-thumb { width: 64px; height: 64px; border-radius: var(--radius-md); overflow: hidden; flex: 0 0 64px; background: var(--color-surface-2); display: flex; align-items: center; justify-content: center; font-size: 22px; }
.meal-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.meal-card-info { flex: 1; min-width: 0; }
.meal-card-info .t { font-weight: 500; font-size: 14px; margin-bottom: 4px; }
.meal-card-info .m { font-size: 11px; color: color-mix(in srgb, var(--color-text) 55%, transparent); display: flex; gap: 8px; flex-wrap: wrap; }
.meal-card-actions { display: flex; gap: 8px; padding: 0 14px 12px; }
.meal-card-actions .btn { flex: 1; font-size: 12px; padding: 8px 4px; }

.shop-group h6 { padding: 14px 0 6px; margin: 0; }
.shop-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 0;
  border-bottom: 1px solid var(--color-divider); cursor: pointer;
}
.shop-item .checkbox {
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--color-divider);
  flex: 0 0 20px; display: flex; align-items: center; justify-content: center; font-size: 12px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.shop-item.checked .checkbox { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-bg); }
.shop-item.checked .label { text-decoration: line-through; opacity: 0.5; }
.shop-item .label { flex: 1; font-size: 13.5px; }
.shop-item .qty { font-size: 12px; opacity: 0.6; font-weight: 500; }

.shop-recipes-row { margin-bottom: 6px; }
.shop-recipe-chip {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  background: var(--color-surface); border: 1px solid var(--color-divider);
  border-radius: 99px; padding: 5px 8px 5px 5px; font-size: 12px;
}
.shop-recipe-chip img, .shop-recipe-chip .ph {
  width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: var(--color-surface-2);
  display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.shop-recipe-chip .rm { border: none; background: none; color: color-mix(in srgb, var(--color-text) 50%, transparent); font-size: 14px; padding: 0 2px; cursor: pointer; }

/* ============================== Режим готовки (Cook Mode) ==================== */

.cook-overlay { z-index: 210; } /* поверх recipe-overlay (200) */

.cook-screen {
  min-height: 100%; display: flex; flex-direction: column;
  padding: calc(var(--safe-top) + 14px) 20px calc(var(--safe-bottom) + 20px);
}
.cook-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-shrink: 0; }
.cook-dots { display: flex; align-items: center; gap: 6px; }
.cook-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--color-divider); transition: all 0.2s ease; }
.cook-dot.active { background: var(--color-accent); width: 16px; }
.cook-dot.done { background: var(--color-accent-700); }

.cook-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 12px 0; }
.cook-num {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 56px;
  line-height: 1; color: var(--color-accent); margin-bottom: 14px;
}
.cook-title { font-size: 24px; margin-bottom: 14px; }
.cook-text { font-size: 17px; line-height: 1.55; opacity: 0.9; margin: 0; }

.cook-timer { margin-top: 32px; text-align: center; }
.cook-timer-val {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight); font-size: 46px;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em; margin-bottom: 14px;
}
.cook-timer-actions { display: flex; gap: 10px; justify-content: center; }
.cook-timer-actions .btn { min-width: 104px; }

.cook-nav { display: flex; gap: 10px; margin-top: 28px; flex-shrink: 0; }
.cook-nav .btn { flex: 1; height: 48px; }

/* ============================== Каталог / фильтры =========================== */

.cat-chip {
  flex: 0 0 auto; font-size: 12.5px; padding: 7px 14px; border-radius: 99px; cursor: pointer;
  background: transparent; color: var(--color-text); border: 1px solid var(--color-divider);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.1s ease;
}
.cat-chip:active { transform: scale(0.95); }
.cat-chip.active { background: var(--color-accent-800); color: var(--color-accent-100); border-color: var(--color-accent-800); }

.result-count { font-size: 13px; opacity: 0.65; margin: 0 0 16px; }

/* Режим поиска «Из моих продуктов» */
.ing-chip-wrap {
  display: flex; flex-wrap: wrap; gap: 8px; max-height: 190px; overflow-y: auto;
  padding: 2px 2px 4px; margin-bottom: 4px;
}
.ing-match { font-size: 11px; margin-top: -2px; color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.ing-match.ok { color: var(--color-accent); }

/* ================================= Разное =================================== */

.spacer-8 { height: 8px; }
.spacer-16 { height: 16px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 14px);
  transform: translate(-50%, 12px);
  background: var(--color-surface-2); border: 1px solid var(--color-divider); color: var(--color-text);
  padding: 11px 18px; border-radius: 99px; font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-md); opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease; z-index: 300; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 560px) {
  .recipe-grid { grid-template-columns: repeat(3, 1fr); }
}
