/* Дневник тренировок — стили Mini App. Цвета и размеры — из эскиза. */

:root {
  --bg: #101214;          /* фон */
  --surface: #1a1d21;     /* карточки */
  --surface-2: #23272c;   /* поля, кнопки внутри карточек */
  --line: #2e3338;        /* разделители, неактивные полоски */
  --border: #3a3f45;      /* рамки кнопок */
  --text: #f2f3f5;
  --text-2: #c9cdd2;      /* второстепенный текст */
  --hint: #9aa0a6;        /* подписи */
  --accent: #d4ff3a;      /* главный цвет: кнопки, прогресс */
  --on-accent: #101214;   /* текст на акцентном фоне */
  --gold: #ffc24a;        /* рекорды */
  --warn-bg: #2a2312;     /* плашка «нет сети» */
  --warn: #ffd27a;
  --down: #ff9c7a;        /* снижение показателя */
  /* Акцент для текста, линий и рамок. В тёмной теме совпадает с заливкой,
     в светлой — темнее: салатовый текст на белом не прочитать. */
  --accent-ink: var(--accent);
  --gold-ink: var(--gold);
  --tabs-bg: #14171a;
  --badge-bg: #2e2614;
  --freeze: #8fd3ff;
  --podium-2: #c9cdd2;
  --podium-3: #d9925b;
  /* Лиги: Бронза, Серебро, Золото, Изумруд, Алмаз */
  --league-0: #d9925b;
  --league-1: #c9cdd2;
  --league-2: #ffc24a;
  --league-3: #3ddc97;
  --league-4: #7cc8ff;
  /* Тепловая карта нагрузки: от лёгкого дня к тяжёлому */
  --heat-1: #3a4419;
  --heat-2: #6b8a1f;
  --heat-3: #a6d12d;
  --heat-4: #d4ff3a;
  color-scheme: dark; /* чекбоксы и полосы прокрутки — тёмные */
  --radius: 16px;
  --font: "Onest", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

/* Светлая тема — когда в Telegram светлая (или светлая тема телефона вне Telegram).
   Тему выставляет app.js атрибутом data-theme на <html>. */
:root[data-theme="light"] {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-2: #eceef1;
  --line: #e0e3e7;
  --border: #c9ced5;
  --text: #15181c;
  --text-2: #3d434b;
  --hint: #646b74;
  --accent: #c6f02e;
  --on-accent: #15181c;
  --accent-ink: #3f6b00;
  --gold: #ffc24a;
  --gold-ink: #946200;
  --warn-bg: #fff3d1;
  --warn: #7a5200;
  --down: #b93815;
  --tabs-bg: #ffffff;
  --badge-bg: #fff1cc;
  --freeze: #0b6aa2;
  --podium-2: #6b7480;
  --podium-3: #a65a1f;
  --league-0: #a65a1f;
  --league-1: #6b7480;
  --league-2: #946200;
  --league-3: #0f8a57;
  --league-4: #1667b3;
  --heat-1: #e3f5b0;
  --heat-2: #c6f02e;
  --heat-3: #8cbf12;
  --heat-4: #3f6b00;
  color-scheme: light;
}

* { box-sizing: border-box; }
/* hidden должен прятать элемент, даже если у его класса задан display: flex */
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); }

/* Telegram сообщает настоящую высоту окна в --tg-viewport-stable-height. */
.app { min-height: var(--tg-viewport-stable-height, 100vh); display: flex; flex-direction: column; }
.screen { flex-grow: 1; display: flex; flex-direction: column; gap: 18px; padding: 20px 16px 24px; }
.screen.with-tabs { padding-bottom: 96px; }

/* Текст */
.h1 { font-size: 26px; font-weight: 700; margin: 0; }
.h2 { font-size: 17px; font-weight: 600; margin: 0; }
.hint { font-size: 13px; color: var(--hint); }
.muted { color: var(--hint); }
.num { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; }
.up { color: var(--accent-ink); }
.down { color: var(--down); }
.gold { color: var(--gold-ink); }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 4px; }
.grow { flex-grow: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

/* Карточки */
.card { background: var(--surface); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.tight { border-radius: var(--radius); padding: 14px; gap: 4px; }
.card.outline { background: transparent; border: 1px solid var(--accent-ink); }
.stat-value { font-family: var(--mono); font-weight: 700; font-size: 22px; }
.stat-unit { font-size: 14px; color: var(--hint); font-weight: 500; }

/* Кнопки: высота не меньше 44px — по ним попадают на ходу и мокрыми пальцами */
.btn { min-height: 44px; border-radius: 14px; border: 1px solid var(--border); background: transparent; padding: 0 16px; font-weight: 600; }
.btn-primary { min-height: 56px; border: none; border-radius: 18px; background: var(--accent); color: var(--on-accent); font-size: 18px; font-weight: 700; display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; }
.btn-primary:disabled { opacity: .5; }
.btn-ghost { border: none; background: transparent; color: var(--hint); }
.btn-danger { border: none; background: transparent; color: var(--down); min-height: 44px; font-weight: 600; }
.icon-btn { width: 44px; height: 44px; border: none; border-radius: 12px; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.icon-btn:disabled { opacity: .3; cursor: default; }
/* «?» рядом с непонятным термином. Кружок маленький, но нажимать можно по
   области 44×44: прозрачный ::after выходит за края кнопки на 11px. */
.help-btn { position: relative; width: 22px; height: 22px; padding: 0; border-radius: 11px; border: 1px solid var(--border); background: transparent; color: var(--hint); font-size: 13px; font-weight: 700; line-height: 1; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.help-btn::after { content: ""; position: absolute; inset: -11px; }
.help-btn[aria-expanded="true"] { border-color: var(--accent-ink); color: var(--accent-ink); }
.link-btn { border: none; background: none; padding: 8px 0; color: var(--accent-ink); font-weight: 600; text-align: left; }

/* Цель недели: полоски-сегменты */
.segments { display: grid; gap: 6px; }
.segment { height: 8px; border-radius: 4px; background: var(--line); }
.segment.done { background: var(--accent); }

/* Плитки шаблонов и упражнений */
.tile { text-align: left; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.tile-title { font-size: 15px; font-weight: 600; }
.list-item { text-align: left; width: 100%; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.list-item.active { border-color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--accent-ink); }
details > summary { list-style-position: inside; }

/* Нижнее меню */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--tabs-bg); border-top: 1px solid var(--line); padding: 8px 8px calc(14px + env(safe-area-inset-bottom)); z-index: 10; }
/* Шесть вкладок на экране 375px: подписи 11px, отступы поменьше. */
.tab { border: none; background: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px; color: var(--hint); font-size: 11px; white-space: nowrap; }
.tab.active { color: var(--accent-ink); }

/* Плашки */
.banner { border-radius: 12px; padding: 10px 14px; font-size: 13px; display: flex; align-items: center; gap: 10px; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.info { background: var(--surface-2); color: var(--text-2); }
.suggestion { border-radius: 12px; background: var(--surface-2); padding: 10px 12px; font-size: 13px; color: var(--text-2); display: flex; flex-direction: column; gap: 2px; }
/* План упражнения из шаблона или от тренера */
.plan-block { border-radius: 12px; border: 1px solid var(--accent); padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.plan-block.done { border-color: var(--line); color: var(--text-2); }
.plan-line { font-weight: 600; color: var(--text); }
.plan-block.done .plan-line { color: var(--text-2); }
.plan-note { color: var(--text-2); font-size: 13px; font-style: italic; }

/* Таблица подходов */
.sets { display: flex; flex-direction: column; gap: 8px; }
.set-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) 36px; gap: 8px; align-items: center; font-family: var(--mono); font-size: 15px; }
.set-row.head { font-family: var(--font); font-size: 12px; color: var(--hint); }
.set-row .warmup { color: var(--hint); }
/* Подход в таблице — кнопка «исправить». Пунктир снизу подсказывает, что на него можно нажать. */
.set-edit { border: none; background: none; padding: 0; min-height: 44px; display: flex; align-items: center; gap: 6px; text-align: left; font-family: var(--mono); font-size: 15px; text-decoration: underline dotted var(--border); text-underline-offset: 5px; }
.set-edit.warmup { color: var(--hint); }
.set-row.editing { background: var(--surface-2); border-radius: 10px; }
.set-del { width: 36px; height: 36px; border: none; background: none; color: var(--hint); display: flex; align-items: center; justify-content: center; }
.pending { opacity: .6; }

/* Поле «− 62,5 +» */
/* min-width: 0 разрешает полю сжиматься: иначе два поля в ряд не влезают в 375px */
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 4px; min-width: 0; background: var(--surface-2); border-radius: 14px; padding: 4px; }
.stepper .icon-btn { width: 40px; background: var(--line); }
.stepper-value { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.stepper-input { width: 100%; min-width: 0; border: none; background: transparent; text-align: center; font-family: var(--mono); font-size: 20px; font-weight: 700; padding: 0; }
.stepper-input:focus { outline: 2px solid var(--accent-ink); border-radius: 8px; }
/* Число между «−» и «+» — тоже поле ввода. Тёмная подложка показывает,
   что на него можно нажать и вписать своё значение с клавиатуры. */
.stepper-value .stepper-input { background: var(--bg); border-radius: 10px; padding: 4px 0; cursor: text; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent-ink); }

/* Таймер отдыха */
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress-bar { height: 6px; background: var(--accent); transition: width 1s linear; }

/* Обычное текстовое поле: название шаблона, своего упражнения, ник */
.text-input { width: 100%; box-sizing: border-box; min-height: 48px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); font-size: 16px; }
.text-input:focus { outline: 2px solid var(--accent-ink); border-color: transparent; }

/* Поиск и фильтры */
.search { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.search input::-webkit-search-cancel-button { filter: grayscale(1) brightness(1.6); }
.search input { flex-grow: 1; border: none; outline: none; background: transparent; font-size: 16px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip { flex-shrink: 0; height: 36px; padding: 0 14px; border: 1px solid var(--border); border-radius: 18px; background: transparent; font-size: 14px; }
.chip.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); }
.segmented button { height: 40px; border: none; border-radius: 11px; background: transparent; color: var(--hint); }
.segmented button.active { background: var(--line); color: var(--text); font-weight: 600; }

/* Календарь в «Истории»: 7 столбцов, дни с тренировкой залиты акцентом */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-head { text-align: center; font-size: 11px; color: var(--hint); padding-bottom: 2px; }
.cal-day { height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 10px; font-family: var(--mono); font-size: 14px; color: var(--text-2); border: none; background: none; padding: 0; }
.cal-day.trained { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--border); }
.cal-day.trained.today { box-shadow: inset 0 0 0 2px var(--text); }

/* Итоги */
.done-mark { width: 72px; height: 72px; border-radius: 36px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; align-self: center; }
.badge { width: 44px; height: 44px; border-radius: 14px; background: var(--badge-bg); color: var(--gold-ink); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.badge.off { background: var(--surface-2); color: var(--hint); } /* серии ещё нет — огонёк погашен */
.achievement { width: 52px; height: 52px; border-radius: 26px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.achievement.locked { filter: grayscale(1); opacity: .35; }

/* Загрузка и всплывающие сообщения */
.skeleton { background: var(--surface); border-radius: 20px; min-height: 96px; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(100px + env(safe-area-inset-bottom)); background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 16px; font-size: 14px; z-index: 20; }
.empty { text-align: center; color: var(--hint); padding: 32px 16px; }

/* Сканер штрихкода: видео с камеры на весь экран, рамка-прицел посередине */
.scanner { position: fixed; inset: 0; z-index: 40; background: #000; display: flex; align-items: center; justify-content: center; }
.scanner-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner-frame { position: relative; width: 82%; height: 26%; border: 3px solid var(--accent); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); overflow: hidden; }
.scanner-line { position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: var(--accent); opacity: .8; }
.scanner-close { position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 16px; background: rgba(0, 0, 0, .55); color: #fff; }
.scanner-hint { position: absolute; left: 16px; right: 16px; bottom: calc(40px + env(safe-area-inset-bottom)); text-align: center; color: #fff; font-size: 15px; text-shadow: 0 1px 3px #000; }

/* --- Программы и план недели ------------------------------------------------- */
.chips.wrap { flex-wrap: wrap; overflow: visible; }
details > summary { min-height: 32px; display: flex; align-items: center; cursor: pointer; }
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.week-cell { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 10px; background: var(--surface-2); color: var(--hint); font-size: 11px; }
.week-cell.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.week-name { max-width: 100%; padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.superset-mark { color: var(--accent-ink); font-weight: 700; }
.plan-row { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: center; gap: 10px; }
.plan-day { font-weight: 600; color: var(--text-2); }
.plan-select { min-height: 44px; }

/* --- «Прогресс»: подсказки ----------------------------------------------------- */
.insight { gap: 8px; }
.insight.active { border: 1px solid var(--accent-ink); }
.insight-title { font-size: 15px; font-weight: 600; }
.plateau-row { min-height: 40px; border: none; border-top: 1px solid var(--line); background: none; padding: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; font-size: 14px; }
.segmented.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.segmented.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.segmented.four button { font-size: 14px; padding: 0 2px; }
.icon-btn.bare { background: none; }
.list-item.static { cursor: default; }
.pill { border-radius: 10px; padding: 4px 10px; background: var(--accent); color: var(--on-accent); font-family: var(--mono); font-size: 15px; font-weight: 700; white-space: nowrap; }
.pill.down { background: var(--surface-2); color: var(--down); }
.chip.small { height: 30px; padding: 0 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; color: var(--hint); }
.chip.small.selected { border-color: var(--text-2); color: var(--text); font-weight: 600; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.swatch.cur { background: var(--accent); }
.swatch.base { background: var(--border); }
.swatch.zone { background: var(--heat-1); box-shadow: inset 0 0 0 1px var(--accent-ink); }
.pr-dot { width: 8px; height: 8px; border-radius: 4px; background: var(--gold); display: inline-block; }
/* Под графиком — подробности выбранной точки или дня */
.chart-detail { min-height: 52px; border-radius: 14px; background: var(--surface-2); padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }

/* --- Графики на SVG (web/js/charts.js) --------------------------------------- */
.chart { display: block; overflow: visible; touch-action: manipulation; cursor: pointer; }
.chart:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 4px; border-radius: 8px; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-label { fill: var(--hint); font-family: var(--mono); font-size: 11px; }
.ch-start { stroke: var(--border); stroke-width: 1; stroke-dasharray: 4 4; }
.ch-area { fill: var(--accent); fill-opacity: .14; }
.ch-line { fill: none; stroke: var(--accent-ink); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ch-forecast { stroke: var(--accent-ink); stroke-width: 2; stroke-dasharray: 5 5; stroke-linecap: round; opacity: .8; }
.ch-forecast-dot { fill: var(--surface); stroke: var(--accent-ink); stroke-width: 2; }
.ch-pr { fill: var(--gold); stroke: var(--surface); stroke-width: 2; }
.ch-pr-halo { fill: var(--gold); fill-opacity: .22; }
.ch-last { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.ch-trend { stroke: var(--text-2); stroke-opacity: .55; stroke-width: 1.5; stroke-dasharray: 2 4; stroke-linecap: round; }
.ch-band-forecast { fill: var(--accent); fill-opacity: .14; }
.ch-future { fill: var(--accent); fill-opacity: .04; }
.ch-forecast-label { fill: var(--accent-ink); font-family: var(--mono); font-size: 10px; font-weight: 700; }
.ch-value { fill: var(--text); font-family: var(--mono); font-size: 11px; font-weight: 700; }
.ch-month { fill: var(--hint); font-size: 10px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.legend-row > span { display: inline-flex; align-items: center; gap: 6px; }
.lg-line { width: 14px; height: 3px; border-radius: 2px; background: var(--accent-ink); }
.lg-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.lg-trend { width: 14px; border-top: 2px dotted var(--text-2); }
.lg-forecast { width: 14px; border-top: 2px dashed var(--accent-ink); }
.sessions-head, .session-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 44px 74px; gap: 8px; align-items: center; }
.sessions-head { font-size: 11px; color: var(--hint); padding: 4px 0; }
.session-row { min-height: 44px; border-top: 1px solid var(--line); font-size: 14px; border-left: none; border-right: none; border-bottom: none; background: none; color: inherit; font-family: inherit; text-align: left; padding: 0; width: 100%; }
.session-row .val { text-align: right; font-family: var(--mono); font-weight: 700; }
.ch-sel { stroke: var(--text); stroke-opacity: .22; stroke-width: 1; }
.ch-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 3; }
.ch-band { fill: var(--surface-2); }
.ch-bar { fill: var(--accent); }
.ch-bar-base { fill: var(--border); }
.ch-zone { fill: var(--accent); fill-opacity: .12; }
.ch-ring { fill: none; stroke: var(--line); stroke-width: 1; }
.ch-prev { fill: var(--hint); fill-opacity: .1; stroke: var(--hint); stroke-width: 1.5; stroke-dasharray: 4 3; }
.ch-cur { fill: var(--accent); fill-opacity: .28; stroke: var(--accent-ink); stroke-width: 2; stroke-linejoin: round; }
.ch-axis { fill: var(--text); font-size: 12px; font-weight: 600; }
.ch-axis-value { fill: var(--hint); font-family: var(--mono); font-weight: 500; }
.week-labels { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; font-size: 12px; color: var(--hint); }
.week-labels .today { color: var(--text); font-weight: 600; }

/* Подходы по мышцам: полоска этой недели и черта прошлой */
.mbar { display: grid; grid-template-columns: 64px minmax(0, 1fr) 72px; align-items: center; gap: 10px; min-height: 28px; font-size: 14px; }
.mbar > :last-child { text-align: right; font-size: 13px; }
.mbar-track { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); }
.mbar-fill { position: absolute; left: 0; top: 0; height: 10px; border-radius: 5px; background: var(--accent); }
.mbar-mark { position: absolute; top: -4px; width: 2px; height: 18px; margin-left: -1px; border-radius: 1px; background: var(--text); }

/* Уровни силы: 5 ступенек */
.level-track { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.level-step { height: 6px; border-radius: 3px; background: var(--line); }
.level-step.on { background: var(--accent); }

/* Тепловая карта: столбец — неделя, строка — день недели */
.heat-wrap { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 4px 6px; }
.heat-months { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); font-size: 11px; white-space: nowrap; }
.heat-days { display: grid; grid-template-rows: repeat(7, minmax(0, 1fr)); gap: 3px; font-size: 10px; align-items: center; }
.heat { display: grid; grid-template-rows: repeat(7, auto); grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; }
.heat-cell { display: block; width: 100%; aspect-ratio: 1; padding: 0; border: none; border-radius: 4px; background: var(--surface-2); }
.heat-cell.l1 { background: var(--heat-1); }
.heat-cell.l2 { background: var(--heat-2); }
.heat-cell.l3 { background: var(--heat-3); }
.heat-cell.l4 { background: var(--heat-4); }
.heat-cell.today { box-shadow: inset 0 0 0 2px var(--text-2); }
.heat-cell.selected { box-shadow: 0 0 0 2px var(--text); }
.heat-cell.future { visibility: hidden; }
.heat-legend { gap: 4px; font-size: 12px; justify-content: flex-end; }
.heat-legend .heat-cell { width: 12px; height: 12px; }

/* «Было → стало» */
.growth-row { width: 100%; border: none; border-top: 1px solid var(--line); background: none; padding: 10px 0 4px; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.growth-track { display: block; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.growth-fill { display: block; height: 6px; border-radius: 3px; background: var(--accent); }
.growth-fill.down { background: var(--down); }

/* --- Питание и здоровье -------------------------------------------------------- */
/* Распознанное по фото: продукт, граммы, калории */
.photo-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 52px; align-items: center; gap: 8px; }
.photo-row .check { min-height: 40px; font-size: 15px; color: var(--text); }
.photo-grams { min-height: 40px; padding: 0 8px; text-align: right; font-family: var(--mono); }
.photo-kcal { text-align: right; font-size: 14px; }
.recipe-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 44px 36px; align-items: center; gap: 6px; font-size: 14px; }
/* Вода: стаканы — залитые и пустые */
.glasses { display: flex; flex-wrap: wrap; gap: 6px; }
.glass { width: 22px; height: 28px; border: 2px solid var(--border); border-top: none; border-radius: 0 0 7px 7px; }
.glass.on { border-color: var(--freeze); background: linear-gradient(to top, var(--freeze) 75%, transparent 75%); }
.key-box { display: block; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; user-select: all; }
.steps-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-2); }
.btn.tight { padding: 0 6px; white-space: nowrap; }

/* --- Мотивация: реакции, задания недели, карточки -------------------------------- */
.reaction { min-height: 36px; padding: 0 12px; border-radius: 18px; border: 1px solid var(--border); background: transparent; font-size: 15px; }
.reaction.active { border-color: var(--accent-ink); background: var(--surface-2); font-weight: 600; }
.reaction.static { display: inline-flex; align-items: center; border: none; padding: 0 6px; color: var(--text-2); }
.quest { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; align-items: center; gap: 10px; font-size: 14px; }
.quest-check { width: 22px; height: 22px; border-radius: 11px; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--on-accent); }
.quest.done .quest-check { background: var(--accent); border-color: var(--accent); }
.quest.done .quest-title { color: var(--hint); text-decoration: line-through; }
.card-canvas { width: 100%; height: auto; border-radius: 16px; display: block; }
.achievement-season { font-size: 11px; color: var(--freeze); }

/* --- Пакет «Telegram»: полный экран и чат с тренером --------------------------------- */
/* В полном экране шапки Telegram нет: сверху — вырез камеры и кнопки Telegram.
   Telegram сам задаёт эти переменные; вне полного экрана они 0. */
html.fullscreen .screen { padding-top: calc(20px + var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)); }
.chat { display: flex; flex-direction: column; gap: 10px; flex-grow: 1; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 18px 18px 18px 6px; background: var(--surface); font-size: 15px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; border-radius: 18px 18px 6px 18px; background: var(--surface-2); }
.bubble.typing { color: var(--hint); animation: pulse 1.2s ease-in-out infinite; }
.chat-bar { position: sticky; bottom: 0; display: flex; gap: 8px; align-items: flex-end; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); background: var(--bg); }
.chat-input { min-height: 48px; padding: 12px 14px; resize: none; line-height: 1.35; font-family: var(--font); }
.chat-send { width: 48px; height: 48px; background: var(--accent); color: var(--on-accent); }

/* --- Удобство: крупный текст и знакомство ------------------------------------------ */
/* zoom масштабирует всё вместе: текст, кнопки и отступы — вёрстка не ломается. */
html[data-text-size="l"] body { zoom: 1.12; }
html[data-text-size="xl"] body { zoom: 1.25; }
.tour-ring { outline: 3px solid var(--accent-ink); outline-offset: 3px; border-radius: 14px; animation: tour-pulse 1.4s ease-in-out infinite; }
@keyframes tour-pulse { 50% { outline-color: transparent; } }
.tour-tip { position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 30; background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; box-shadow: 0 12px 32px rgba(0, 0, 0, .35); }
.tour-tip.top { bottom: auto; top: calc(16px + env(safe-area-inset-top) + var(--tg-content-safe-area-inset-top, 0px)); }
.analysis-text { white-space: pre-wrap; font-size: 15px; line-height: 1.45; color: var(--text); }

/* Программы: каталог, текущая программа, прогресс */
.program-row { align-items: flex-start; text-align: left; }
.program-emoji { font-size: 26px; line-height: 1; width: 36px; flex-shrink: 0; text-align: center; padding-top: 2px; }
.program-desc { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.program-hero { font-size: 44px; line-height: 1; }
.program-strip { align-items: center; }
.card.muted-card { opacity: .55; }
.progress-track { display: block; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.progress-fill { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.week-dots { display: inline-flex; gap: 5px; flex-shrink: 0; }
.week-dots .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); }
.week-dots .dot.on { background: var(--accent); border-color: var(--accent); }

/* Тренер: 1ПМ ученика и выполнение по неделям */
.lift-row { display: flex; align-items: center; gap: 10px; border: none; background: none; padding: 10px 0; border-top: 1px solid var(--line); color: inherit; font: inherit; width: 100%; min-height: 52px; }
.week-bars { position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; height: 120px; align-items: end; }
.week-bar { display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; }
.week-bar-num { font-size: 11px; color: var(--text-2); min-height: 14px; }
.week-bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.week-bar-fill { width: 100%; background: var(--line); border-radius: 4px; }
.week-bar-fill.done { background: var(--accent); }
.week-bar-label { font-size: 10px; color: var(--hint); min-height: 12px; white-space: nowrap; }
.week-goal-line { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--text-2); pointer-events: none; }
.lift-hint { font-size: 12px; color: var(--accent-ink); }

/* Тренировка: разница с прошлым разом и своя заметка к упражнению */
.delta { font-family: var(--mono); font-size: 11px; font-weight: 700; }
.delta.up { color: var(--accent-ink); }
.delta.down { color: var(--down); }
.exercise-note { align-self: flex-start; border: none; background: var(--surface-2); color: var(--text-2); border-radius: 8px; padding: 6px 10px; margin-top: 6px; font: 500 13px var(--font); text-align: left; min-height: 32px; }
.exercise-note.empty { background: none; padding: 6px 0; color: var(--hint); font-weight: 400; }
.wave-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 92px; gap: 10px; align-items: center; }

/* Прогресс: список упражнений (Б), объём по мышцам (В), сводка (Г) */
.lift-line { display: grid; grid-template-columns: minmax(0, 1fr) 96px 86px; gap: 10px; align-items: center; min-height: 64px; padding: 10px 0; border: none; border-top: 1px solid var(--line); background: none; color: inherit; font: inherit; width: 100%; }
.lift-line.first { border-top: none; }
.spark .spark-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark.up .spark-line { stroke: var(--accent-ink); }
.spark.flat .spark-line { stroke: var(--text-2); }
.spark.down .spark-line { stroke: var(--down); }
.spark.blue .spark-line { stroke: #6fb8ff; }
.spark .spark-dot { fill: currentColor; }
.spark.up .spark-dot { fill: var(--accent-ink); }
.spark.flat .spark-dot { fill: var(--text-2); }
.spark.down .spark-dot { fill: var(--down); }
.spark.blue .spark-dot { fill: #6fb8ff; }
.spark .spark-dot.gold { fill: var(--gold); }
.spark.wide { width: 100%; height: 24px; }
.vbars { position: relative; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 5px; height: 172px; align-items: end; }
.vbar { display: flex; flex-direction: column; align-items: stretch; height: 100%; gap: 2px; }
.vbar-num { font-family: var(--mono); font-size: 10px; color: var(--text-2); text-align: center; min-height: 14px; }
.vbar-track { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; padding-top: 16px; }
.vbar-stack { width: 100%; display: flex; flex-direction: column-reverse; border-radius: 4px; overflow: hidden; flex-shrink: 0; }
.vbar-part { display: block; width: 100%; flex-shrink: 0; }
.vbar-label { font-size: 10px; color: var(--hint); text-align: center; min-height: 12px; white-space: nowrap; }
.vbar-norm { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--hint); pointer-events: none; }
.bal-row { display: grid; grid-template-columns: 64px minmax(0, 1fr) 40px; gap: 10px; align-items: center; font-size: 13px; }
.bal-track { position: relative; height: 14px; border-radius: 7px; background: var(--surface-2); }
.bal-zone { position: absolute; top: 0; bottom: 0; background: var(--accent); opacity: .16; }
.bal-bar { position: absolute; left: 0; top: 3px; bottom: 3px; border-radius: 4px; }
.bal-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .6; }
.bal-mark-legend { width: 2px; height: 12px; background: var(--text); opacity: .6; }
.kpi-bars { display: flex; gap: 3px; align-items: flex-end; height: 24px; }
.kpi-bars > span { flex: 1; border-radius: 2px; }
.record-line { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 48px; border: none; border-top: 1px solid var(--line); background: none; color: inherit; font: inherit; width: 100%; padding: 0; }

/* Самочувствие перед тренировкой и переписка с тренером */
.checkin-scale { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.checkin-scale .chip { padding: 0; font-size: 20px; height: 42px; }
.comment { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); max-width: 88%; align-self: flex-start; }
.comment.mine { align-self: flex-end; background: var(--line); }
.comment-meta { font-size: 11px; color: var(--hint); display: flex; gap: 8px; align-items: center; }
.warn-text { color: var(--warn); }
textarea.text-input { font-family: inherit; line-height: 1.4; resize: vertical; padding-bottom: 10px; }

/* Челленджи */
.challenge-kinds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.challenge-kind { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); text-align: left; }
.challenge-kind.active { border-color: var(--accent); background: var(--surface-2); }
.challenge-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; }
.challenge-row + .challenge-row { border-top: 1px solid var(--line); }
.challenge-rank { width: 28px; text-align: center; font-weight: 700; color: var(--hint); }
.challenge-bar { display: block; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.challenge-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.challenge-row.me .challenge-bar > span { background: var(--accent-ink); }

/* Анализ дня в «Питании» */
.insight-row { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 10px; align-items: start; font-size: 14px; }
.insight-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--gold); }
.score-pill { font-size: 12px; padding: 4px 10px; border-radius: 12px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.score-pill.good { color: var(--accent-ink); }
