/* Мобильный интерфейс (вариант A, 6.11). Подключается последним.
   Цвета — те же, что у виджетов приложения: калории — розовый, расход —
   оранжевый, вода — голубой, шаги — фиолетовый, акцент — лайм. */

/* ── Нижнее меню: 4 раздела и «+» по центру ─────────────────────────── */
html body #mainApp .bottom-nav.ng-bottom-nav {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) 72px repeat(2, minmax(0, 1fr)) !important;
  align-items: center !important;
  gap: 0 !important;
  overflow: visible !important;
}
.ng-bottom-nav .nav-item { min-width: 0 !important; width: 100% !important; }
.ng-bottom-nav .nav-item span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ng-bottom-nav .nav-add {
  justify-self: center;
  width: 60px; height: 60px; margin-top: -30px;
  display: grid; place-items: center;
  border: 4px solid #090d13; border-radius: 50%;
  color: #102000; background: #b7ff00;
  font-size: 24px; cursor: pointer;
  box-shadow: 0 10px 26px rgba(183, 255, 0, .32);
  -webkit-tap-highlight-color: transparent;
}
.ng-bottom-nav .nav-add:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.ng-bottom-nav .nav-add:active { transform: scale(.95); }

/* ── Верхняя панель ───────────────────────────────────────────────── */
.ng-topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1120px; margin: 0 auto; padding: 18px 18px 6px; box-sizing: border-box; }
.ng-topbar-text { min-width: 0; }
/* Общее правило «отступ под нижним меню» не должно растягивать саму панель. */
#screenContent > .ng-topbar { padding-bottom: 4px !important; }
.ng-topbar-date { display: block; color: #aab5bf; font-size: 13px; font-weight: 700; text-transform: capitalize; }
.ng-topbar-title { margin: 2px 0 0; color: #fff; font-size: 24px; font-weight: 900; letter-spacing: -.02em; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ng-topbar-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.ng-topbar-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .1); border-radius: 15px; color: #e8eef2; background: rgba(255, 255, 255, .06); font-size: 17px; font-weight: 900; cursor: pointer; }
.ng-topbar-btn:focus-visible { outline: 3px solid #b7ff00; outline-offset: 2px; }
/* На экранах с верхней панелью прежний крупный заголовок «достижений» лишний. */
#screenContent:has([data-ng-topbar]) .home-dashboard-intro { display: none; }

/* ── Главная ──────────────────────────────────────────────────────── */
html body #screenContent .home-dashboard-v2.ng-home { display: flex !important; flex-direction: column !important; align-items: stretch !important; gap: 12px !important; width: 100% !important; max-width: 720px !important; margin: 0 auto !important; padding-top: 6px !important; }
html body #screenContent .ng-home > * { width: auto !important; max-width: none !important; margin-left: 0 !important; margin-right: 0 !important; grid-column: auto !important; }
.ng-topbar[data-ng-topbar] { max-width: 720px; }
.ng-hero { padding: 18px; border: 1px solid rgba(255, 79, 154, .5); border-radius: 26px; background: linear-gradient(150deg, rgba(113, 24, 70, .6), rgba(37, 22, 42, .65) 60%, rgba(16, 24, 30, .7)); display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ng-hero-ring { position: relative; width: 200px; height: 200px; padding: 0; border: 0; background: none; cursor: pointer; }
.ng-hero-ring svg { width: 200px; height: 200px; display: block; }
.ng-hero-track { fill: none; stroke: rgba(255, 255, 255, .1); stroke-width: 16; }
.ng-hero-value { fill: none; stroke: #ff4f9a; stroke-width: 16; stroke-linecap: round; transition: stroke-dasharray .5s ease; }
.ng-hero-value.is-over { stroke: #ffa64c; }
.ng-hero-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ng-hero-center strong { color: #fff; font-size: 44px; font-weight: 950; letter-spacing: -.03em; line-height: 1; }
.ng-hero-center span { margin-top: 6px; color: #f3c9da; font-size: 14px; font-weight: 700; }
.ng-hero-sub { margin-top: 4px; color: #d8b9c6; font-size: 11px; font-weight: 700; }
/* БЖУ под кольцом: белки — розовый, жиры — оранжевый, углеводы — голубой
   (цвета существующих виджетов). */
.ng-macros { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ng-macro { min-height: 58px; padding: 9px 10px; border: 0; border-radius: 16px; background: rgba(255, 255, 255, .06); color: #fff; display: flex; flex-direction: column; justify-content: space-between; gap: 7px; text-align: left; cursor: pointer; }
.ng-macro-head { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ng-macro-head > span { color: #c8d2da; font-size: 11px; font-weight: 800; }
.ng-macro-head strong { font-size: 16px; font-weight: 900; white-space: nowrap; }
.ng-macro-head strong small { color: #9eabb5; font-size: 11px; font-weight: 700; }
.ng-macro-bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.ng-macro-bar i { display: block; height: 100%; border-radius: inherit; transform-origin: left center; animation: ngGrow .9s ease-out both; }
.ng-macro-protein .ng-macro-bar i { background: #ff4f9a; }
.ng-macro-fat .ng-macro-bar i { background: #ffa64c; }
.ng-macro-carbs .ng-macro-bar i { background: #45d6ff; }
@keyframes ngGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.ng-tile-bar i { transform-origin: left center; animation: ngGrow .9s ease-out both; }
.ng-hero-value { transition: stroke-dasharray 1s cubic-bezier(.2, .8, .2, 1) !important; }
@media (prefers-reduced-motion: reduce) { .ng-macro-bar i, .ng-tile-bar i { animation: none; } .ng-hero-value { transition: none !important; } }
/* Пустое состояние: иконка полупрозрачная, подсказка — как призыв к действию. */
.ng-tile.is-empty strong { color: rgba(255, 255, 255, .55); }
.ng-tile.is-empty .ng-tile-hint { color: #fff; font-weight: 800; }
.ng-tile.is-empty .ng-tile-label i { opacity: .6; }

.ng-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ng-tile { min-height: 118px; padding: 14px; border-radius: 22px; color: #fff; text-align: left; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.ng-tile-water { border: 1px solid rgba(69, 214, 255, .55); background: linear-gradient(145deg, rgba(19, 102, 121, .7), rgba(21, 53, 72, .7) 70%, rgba(16, 27, 34, .7)); }
.ng-tile-steps { border: 1px solid rgba(157, 126, 255, .55); background: linear-gradient(145deg, rgba(74, 47, 133, .72), rgba(42, 34, 82, .7) 70%, rgba(17, 24, 34, .7)); }
.ng-tile-label { display: flex; align-items: center; gap: 7px; color: #dfe9f0; font-size: 13px; font-weight: 800; }
.ng-tile-water .ng-tile-label i { color: #8beaff; }
.ng-tile-steps .ng-tile-label i { color: #c4b2ff; }
.ng-tile strong { font-size: 24px; font-weight: 950; }
.ng-tile strong small { color: #c8d2da; font-size: 13px; font-weight: 700; }
.ng-tile-hint { color: #c8d2da; font-size: 12px; }
.ng-tile-bar { margin-top: auto; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.ng-tile-bar i { display: block; height: 100%; border-radius: inherit; }
.ng-tile-water .ng-tile-bar i { background: #45d6ff; }
.ng-tile-steps .ng-tile-bar i { background: #9d7eff; }

.ng-workout { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid rgba(255, 166, 76, .55); border-radius: 22px; background: linear-gradient(145deg, rgba(126, 62, 25, .66), rgba(58, 33, 31, .66) 70%, rgba(18, 25, 31, .7)); }
.ng-workout-icon { width: 46px; height: 46px; flex: 0 0 46px; display: grid; place-items: center; border-radius: 15px; color: #ffc27d; background: rgba(255, 166, 76, .2); font-size: 19px; }
.ng-workout-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ng-workout-text strong { color: #fff; font-size: 15px; font-weight: 850; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ng-workout-text span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ng-workout-text span { color: #e3d2c4; font-size: 12px; }
.ng-workout-go { min-height: 44px; padding: 0 16px; border: 0; border-radius: 14px; color: #1c1004; background: linear-gradient(135deg, #ffad32, #ff8a00); font-size: 14px; font-weight: 950; cursor: pointer; }
.ng-workout-go.is-ghost { color: #ffd7a8; background: rgba(255, 166, 76, .16); border: 1px solid rgba(255, 166, 76, .45); }

.ng-coach-line { display: flex; flex-direction: column; gap: 10px; }
.ng-coach-tip { width: 100%; white-space: normal; display: flex; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid rgba(157, 126, 255, .4); border-radius: 20px; color: #ece6ff; background: rgba(74, 47, 133, .28); text-align: left; font-size: 14px; line-height: 1.4; cursor: pointer; }
.ng-coach-tip span { display: block; flex: 1 1 auto; min-width: 0; white-space: normal; text-align: left; }
.ng-coach-tip > i { flex: 0 0 auto; }
.ng-coach-tip i { color: #c4b2ff; font-size: 18px; margin-top: 1px; }
.ng-chip-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.ng-chip-row::-webkit-scrollbar { display: none; }
.ng-chip { flex: 0 0 auto; min-height: 40px; padding: 0 14px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 999px; color: #e8eef2; background: rgba(255, 255, 255, .04); font-size: 13px; font-weight: 700; cursor: pointer; }

/* ── Виджеты списком (без сворачивания) ──────────────────────────── */
.ng-widget-list { display: flex; flex-direction: column; gap: 12px; }
.ng-widget > section, .ng-widget > div > section { margin-top: 0 !important; margin-bottom: 0 !important; }

/* ── Лист «+» ─────────────────────────────────────────────────────── */
.ng-sheet { position: fixed; inset: 0; z-index: 400; display: flex; align-items: flex-end; justify-content: center; }
.ng-sheet-backdrop { position: absolute; inset: 0; background: rgba(3, 6, 10, .66); }
.ng-sheet-panel { position: relative; width: min(560px, 100%); box-sizing: border-box; padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); border-radius: 28px 28px 0 0; background: #121c28; box-shadow: 0 -16px 40px rgba(0, 0, 0, .45); animation: ngSheetIn .22s ease-out; }
@keyframes ngSheetIn { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .ng-sheet-panel { animation: none; } }
.ng-sheet-grip { width: 44px; height: 5px; margin: 0 auto 8px; border-radius: 3px; background: #2b3a4a; }
.ng-sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.ng-sheet-head h2 { margin: 0; color: #fff; font-size: 20px; font-weight: 900; }
.ng-sheet-close { width: 44px; height: 44px; border: 0; border-radius: 14px; color: #c8d2da; background: rgba(255, 255, 255, .06); font-size: 18px; cursor: pointer; }
.ng-sheet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.ng-sheet-action { min-height: 88px; padding: 10px 6px; border: 1px solid rgba(255, 255, 255, .08); border-radius: 20px; color: #fff; background: rgba(255, 255, 255, .05); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 13px; font-weight: 800; text-align: center; cursor: pointer; }
.ng-sheet-action i { color: var(--action-color, #b7ff00); font-size: 24px; }
.ng-sheet-action:focus-visible, .ng-sheet-coach:focus-visible { outline: 3px solid #b7ff00; outline-offset: 2px; }
.ng-sheet-coach { width: 100%; min-height: 54px; margin-top: 12px; padding: 0 16px; border: 1px solid rgba(157, 126, 255, .45); border-radius: 18px; color: #fff; background: rgba(74, 47, 133, .35); display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 800; cursor: pointer; }
.ng-sheet-coach span { flex: 1; text-align: left; }
.ng-sheet-coach i:first-child { color: #c4b2ff; }
body.ng-sheet-open { overflow: hidden; }

/* Кнопки «Ввести шаги» и «Подключить устройство» не вылезают за карточку. */
.workout-log-actions { flex-wrap: wrap; }
.workout-log-actions > .activity-action-button { flex: 1 1 140px; min-width: 0; white-space: normal; }

/* ── Текст не влезает в кнопку (класс ставит mobile-ui.js) ─────────── */
.ng-stack:not(#ng-m) { display: flex !important; flex-direction: column !important; flex-wrap: nowrap !important; align-items: stretch !important; justify-content: flex-start !important; gap: 8px !important; }
.ng-stack:not(#ng-m) > * { width: 100% !important; max-width: 100% !important; flex: 0 0 auto !important; margin-left: 0 !important; margin-right: 0 !important; }
.ng-wrap:not(#ng-m) { white-space: normal !important; text-overflow: clip !important; overflow-wrap: anywhere; height: auto !important; min-height: 44px; line-height: 1.25 !important; padding-top: 8px !important; padding-bottom: 8px !important; }
.ng-wrap:not(#ng-m) * { white-space: normal !important; text-overflow: clip !important; overflow: visible !important; max-width: 100%; }

/* ── Телефон: компактные виджеты ───────────────────────────────────
   Все карточки видны сразу; на узком экране они ниже: меньше отступов,
   заголовков и кнопок. Раскладка «по центру» и цвета из widgets.css
   не меняются. */
@media (max-width: 599px) {
  #screenContent :is(.activity-widget, .drinks-widget, .supplements-diary-section, .nutrition-plans-widget, .fasting-meals-widget, .challenge-widget, .home-meals-card, .home-recipe-card, .fasting-home-widget, .meals-section-wrap, .nutrition-hero-card):not(#ng-m) {
    padding: 16px !important; border-radius: 22px !important; min-height: 0 !important;
  }
  #screenContent :is(.home-plan-card, .home-coach-card):not(#ng-m) { min-height: 0 !important; border-radius: 22px !important; }
  #screenContent :is(.home-plan-content, .home-coach-content):not(#ng-m) { padding: 16px !important; }

  /* Заголовки и иконки виджетов меньше. */
  #screenContent :is(.activity-widget, .drinks-widget, .supplements-diary-section, .nutrition-plans-widget, .fasting-meals-widget, .challenge-widget, .home-meals-card, .home-recipe-card, .fasting-home-widget, .home-plan-content, .home-coach-content) :is(h2, h3):not(#ng-m) {
    font-size: 20px !important; line-height: 1.2 !important; margin-top: 2px !important; margin-bottom: 4px !important;
  }
  #screenContent :is(.activity-widget, .drinks-widget, .supplements-diary-section, .nutrition-plans-widget, .home-meals-card, .home-recipe-card, .fasting-home-widget, .home-plan-content, .home-coach-content) :is(.home-card-head p, .activity-widget-subtitle, .meals-screen-header p, .fasting-home-subtitle, .nutrition-plans-widget-head p, .home-plan-content > p, .home-coach-content > p, .supplements-diary-header p):not(#ng-m) {
    font-size: 13px !important; line-height: 1.4 !important; margin-top: 2px !important;
  }
  #screenContent :is(.activity-widget-icon, .drinks-widget-icon, .nutrition-plans-widget-icon, .home-diary-book-icon):not(#ng-m) { width: 36px !important; height: 36px !important; font-size: 16px !important; }
  #screenContent :is(.activity-widget-head, .drinks-widget-head, .supplements-diary-header, .nutrition-plans-widget-head, .fasting-section-head, .challenge-widget-head, .home-card-head, .home-meals-visual):not(#ng-m) { margin-bottom: 10px !important; min-height: 0 !important; gap: 6px !important; }
  #screenContent :is(.home-eyebrow, .supplements-diary-kicker, .fasting-kicker):not(#ng-m) { margin-bottom: 4px !important; font-size: 11px !important; }

  /* Кнопки: удобная высота для пальца, но без лишней массы. */
  #screenContent :is(.activity-action-button, .drinks-add-button, .home-meals-cta, .home-plan-button, .home-coach-action, .fasting-cta, .home-recipe-action, .supplement-add-button):not(#ng-m) { min-height: 46px !important; height: auto !important; font-size: 15px !important; margin-top: 8px !important; }
  #screenContent .activity-primary-stat strong { font-size: 34px !important; }

  /* Карточка NG Couch на главной: без декоративных знаков вопроса. */
  #screenContent .home-coach-question-field, #screenContent .home-coach-context { display: none !important; }
  #screenContent .home-coach-capabilities { margin: 8px auto !important; }
  #screenContent .home-coach-side { padding: 0 16px 16px !important; }
}

/* ── Телефон: меньше крупных отступов и повторов ──────────────────── */
@media (max-width: 360px) {
  .time-grid:not(#ng-m) { grid-template-columns: 1fr !important; }
}
@media (max-width: 599px) {
  .ng-home { padding-left: 16px !important; padding-right: 16px !important; }
  .ng-topbar { padding: 16px 16px 4px; }
  /* Заголовок «Мои достижения» дублирует верхнюю панель. */
  #mainApp #nutritionAchievementsTitle, #mainApp #activity-achievements-title { font-size: 19px !important; }
  .ng-topbar { padding-top: 10px; }
}

/* ── Сворачиваемые блоки тренировки: разминка, заминка, пересборка ─────
   (ТЗ 6.11 п.9 и п.16: одна строка «Разминка · 6 мин», раскрывается тапом) */
.ng-collapsible-block > summary { list-style: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ng-collapsible-block > summary::-webkit-details-marker { display: none; }
.ng-collapsible-block > summary:focus-visible { outline: 3px solid #b7ff00; outline-offset: 2px; border-radius: 16px; }
.ng-collapse-chevron { flex: 0 0 auto; margin-left: 8px; color: #9eabb5; transition: transform .2s ease; }
.ng-collapsible-block[open] > summary .ng-collapse-chevron { transform: rotate(180deg); }
.ng-collapsible-block:not([open]) > summary { margin-bottom: 0 !important; }
.ng-collapsible-block:not([open]) { padding-top: 14px !important; padding-bottom: 14px !important; }
.regen-summary { display: flex; align-items: center; gap: 12px; min-height: 48px; color: #fff; font-size: 16px; font-weight: 850; }
.regen-summary-title { flex: 1; }
.regen-summary-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: #b7ff00; background: rgba(183, 255, 0, .12); }
.regen-card[open] > .regen-body { margin-top: 12px; }

/* Калории в результате подсчёта еды не обрезаются («546 ккал», а не «46 кка»). */
.meal-kcal-badge { flex: 0 0 auto !important; white-space: nowrap !important; overflow: visible !important; max-width: none !important; }

/* План питания: «Приготовить» и корзина «в список покупок» в одном ряду. */
.meal-plan-cook-row { display: flex; gap: 8px; align-items: stretch; margin-top: 10px; }
.meal-plan-cook-row .meal-plan-cook-button { flex: 1 1 auto; margin-top: 0 !important; }
.meal-plan-shop-button { flex: 0 0 48px; min-height: 44px; border: 1px solid rgba(120, 184, 255, .45); border-radius: 14px; color: #9ccaff; background: rgba(120, 184, 255, .12); font-size: 17px; cursor: pointer; }
.meal-plan-shop-button:focus-visible { outline: 3px solid #b7ff00; outline-offset: 2px; }

/* Свайп по приёму пищи: влево — удалить, вправо — копия на сегодня. */
.meal-card[data-meal-id] { touch-action: pan-y; transition: transform .2s ease; position: relative; }
.meal-card.is-swiping { transition: none; }
.meal-card.swipe-left { box-shadow: inset -6px 0 0 #ff5a6b; }
.meal-card.swipe-right { box-shadow: inset 6px 0 0 #b7ff00; }

/* Шапка приложения закреплена и компактна (ТЗ UI/UX). overflow-x: hidden у
   body делал его отдельной прокручиваемой областью, и sticky не работал;
   clip обрезает так же, но не мешает закреплению. */
@media (max-width: 599px) {
  html body:not(#ng-m) { overflow-x: clip !important; overflow-y: visible !important; }
  #mainApp .app-header:not(#ng-m) { position: sticky !important; top: var(--ng-cms-banners-h, 0px) !important; min-height: 64px !important; padding-top: 10px !important; padding-bottom: 10px !important; z-index: 60 !important; background: #0b1017 !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
}

/* Плавная прокрутка на телефонах. Размытие фона (backdrop-filter) под
   карточками пересчитывается на каждом кадре прокрутки — на телефоне это
   главный источник рывков. Цвета карточек остаются, убирается только blur. */
@media (max-width: 599px) {
  #mainApp *:not(#ng-m), #mainApp .app-header *:not(#ng-m) { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
}
