/* =============================================================================
   Deggendorf Dominators Gym — мини-приложение Telegram.
   Цвета поверхностей и текста берутся из темы Telegram (--tg-theme-*), поэтому
   приложение выглядит «родным» и в светлой, и в тёмной теме. Свой здесь только
   фирменный оранжевый и цвета графиков (палитра проверена на различимость
   при дальтонизме — см. js/charts.js).
   ============================================================================= */

:root {
  color-scheme: light;
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --text: var(--tg-theme-text-color, #0b0b0b);
  --hint: var(--tg-theme-hint-color, #8a8a8e);
  --link: var(--tg-theme-link-color, #2a78d6);
  --sep: var(--tg-theme-section-separator-color, rgba(60, 60, 67, 0.13));
  --danger: var(--tg-theme-destructive-text-color, #d03b3b);

  --accent: #eb6834;
  --accent-2: #f5873f;
  --accent-soft: rgba(235, 104, 52, 0.13);
  --on-accent: #ffffff;
  --good: #0ca30c;
  --good-text: #006300;
  --good-soft: rgba(12, 163, 12, 0.12);
  --warn: #fab219;
  --warn-text: #8a5a00;
  --warn-soft: rgba(250, 178, 25, 0.18);
  --critical: #d03b3b;
  --critical-soft: rgba(208, 59, 59, 0.12);
  --gold: #eda100;

  --fill: rgba(118, 118, 128, 0.12);
  --fill-2: rgba(118, 118, 128, 0.2);
  --heat-0: rgba(118, 118, 128, 0.14);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 6px 20px rgba(0, 0, 0, 0.05);
  --radius: 18px;
  --radius-sm: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --safe-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
  --tabbar-h: 60px;
}

html[data-scheme="dark"] {
  color-scheme: dark;
  --bg: var(--tg-theme-secondary-bg-color, #0f0f10);
  --surface: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #1c1c1e));
  --text: var(--tg-theme-text-color, #f0efec);
  --hint: var(--tg-theme-hint-color, #8d8d93);
  --sep: var(--tg-theme-section-separator-color, rgba(255, 255, 255, 0.09));
  --accent: #f07033;
  --accent-2: #ff9147;
  --accent-soft: rgba(240, 112, 51, 0.2);
  --good-text: #3cc13c;
  --warn-text: #fab219;
  --fill: rgba(118, 118, 128, 0.24);
  --fill-2: rgba(118, 118, 128, 0.34);
  --heat-0: rgba(118, 118, 128, 0.22);
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; user-select: none; -webkit-user-select: none; }
input, textarea { font-size: 16px; } /* iOS не зумит поля от 16px */
a { color: var(--link); text-decoration: none; }
svg.icon { width: 22px; height: 22px; flex: none; display: block; }
svg.icon.sm { width: 18px; height: 18px; }
svg.icon.xs { width: 15px; height: 15px; }
.muted { color: var(--hint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ каркас */
.splash { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.splash-logo { font-size: 56px; animation: pop 0.6s ease both; }
.splash-title { font-weight: 700; font-size: 18px; letter-spacing: 0.2px; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--fill-2); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeUp { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes loadbar { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ВАЖНО: у .page и её предков не должно оставаться transform/filter/opacity —
   иначе шторки (position: fixed) окажутся под нижним меню. Поэтому анимация
   только прозрачностью и без fill-mode: после неё от анимации ничего не остаётся. */
.page {
  padding: 12px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
  max-width: 640px;
  margin: 0 auto;
  animation: fadeIn 0.2s ease;
}
.page.no-tabbar { padding-bottom: calc(var(--safe-bottom) + 28px); }
/* Данные обновляются: тонкая полоска сверху, графики чуть приглушены (кадр не прыгает). */
.page.stale::before {
  content: ""; position: fixed; z-index: 100; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: loadbar 0.9s linear infinite;
}
.stale .chart-box, .stale .heat { opacity: 0.6; transition: opacity 0.2s; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin: 6px 0 14px; }
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -0.4px; line-height: 1.15; margin: 0; }
.page-sub { color: var(--hint); font-size: 14px; margin-top: 2px; }
.section-title {
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--tg-theme-section-header-text-color, var(--hint));
  margin: 22px 4px 8px; display: flex; align-items: center; justify-content: space-between;
}
.section-title button { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--link); font-size: 14px; }

/* ------------------------------------------------------------------ карточки */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 10px; }
.card.tight { padding: 12px 14px; }
.card.flush { padding: 0; overflow: hidden; }
.card-title { font-weight: 700; font-size: 16px; margin: 0 0 4px; }
.hero {
  position: relative; overflow: hidden; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, var(--accent-2) 0%, var(--accent) 45%, #c2410c 100%);
}
html[data-scheme="dark"] .hero { background: radial-gradient(120% 140% at 100% 0%, #ff9147 0%, #e8601f 45%, #9a3412 100%); }
.hero .muted { color: rgba(255, 255, 255, 0.82); }
.hero-emoji { position: absolute; right: -6px; bottom: -16px; font-size: 84px; opacity: 0.22; transform: rotate(-12deg); pointer-events: none; }
.hero-big { font-size: 26px; font-weight: 800; letter-spacing: -0.3px; line-height: 1.2; }

.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; position: relative; min-height: 52px; width: 100%; text-align: left; }
.list-item + .list-item::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--sep); transform: scaleY(0.5); }
.list-item.tap:active { background: var(--fill); }
.list-item .chev { color: var(--hint); opacity: 0.6; }
.item-title { font-weight: 600; }
.item-sub { color: var(--hint); font-size: 13px; margin-top: 1px; }

/* ------------------------------------------------------------------ кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 18px; border-radius: 14px; font-weight: 650; font-size: 16px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: var(--on-accent);
  transition: transform 0.08s ease, opacity 0.15s; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.45; pointer-events: none; }
.btn.block { width: 100%; }
.btn.sm { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 11px; }
.btn.xs { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 9px; gap: 5px; }
.btn.secondary { background: var(--fill); color: var(--text); }
.btn.soft { background: var(--accent-soft); color: var(--accent); }
.btn.ghost { background: transparent; color: var(--link); }
.btn.danger { background: var(--critical-soft); color: var(--danger); }
.btn.good { background: var(--good); color: #fff; }
.btn.white { background: rgba(255, 255, 255, 0.95); color: #c2410c; }
.btn.glass { background: rgba(255, 255, 255, 0.2); color: #fff; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); flex: none;
}
.icon-btn:active { transform: scale(0.94); }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }

/* ------------------------------------------------------------------ чипы, сегменты */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 18px;
  background: var(--fill); color: var(--text); font-size: 14px; font-weight: 550; white-space: nowrap; flex: none;
  transition: background 0.15s, color 0.15s, transform 0.08s;
}
.chip:active { transform: scale(0.96); }
.chip.active { background: var(--accent); color: var(--on-accent); }
.chip.disabled { opacity: 0.4; pointer-events: none; text-decoration: line-through; }
.chip.warn:not(.active) { box-shadow: inset 0 0 0 1.5px var(--warn); }
.chip .badge { font-size: 12px; opacity: 0.8; }
.chip-col { flex-direction: column; height: auto; padding: 8px 12px; gap: 0; line-height: 1.2; border-radius: 14px; min-width: 64px; }
.chip-col small { font-size: 11px; opacity: 0.75; font-weight: 500; }

.seg { display: flex; background: var(--fill); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { flex: 1; height: 34px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--hint); transition: background 0.15s, color 0.15s; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--fill); color: var(--text); white-space: nowrap; }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.good { background: var(--good-soft); color: var(--good-text); }
.pill.warn { background: var(--warn-soft); color: var(--warn-text); }
.pill.bad { background: var(--critical-soft); color: var(--danger); }
.pill.gold { background: rgba(237, 161, 0, 0.16); color: #a46f00; }
html[data-scheme="dark"] .pill.gold { color: #f3b52b; }

/* ------------------------------------------------------------------ аватары */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px; flex: none; letter-spacing: 0.3px;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }
.avatars { display: inline-flex; }
.avatars .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatars .avatar + .avatar { margin-left: -8px; }
.avatars .more { background: var(--fill-2); color: var(--text); }

/* ------------------------------------------------------------------ поля, степперы, переключатели */
.field { display: block; }
.field-label { font-size: 13px; color: var(--hint); margin: 0 2px 6px; font-weight: 550; }
.input {
  width: 100%; height: 46px; border-radius: 12px; border: 0; padding: 0 14px;
  background: var(--fill); outline: none; transition: box-shadow 0.15s;
}
.input:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.input::placeholder { color: var(--hint); }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 52px; height: 52px; border-radius: 14px; background: var(--fill); display: flex; align-items: center; justify-content: center; flex: none;
}
.stepper button:active { background: var(--fill-2); transform: scale(0.95); }
.stepper input {
  flex: 1; min-width: 0; height: 52px; border: 0; border-radius: 14px; background: var(--fill); text-align: center;
  font-size: 24px; font-weight: 750; outline: none; font-variant-numeric: tabular-nums;
}
.stepper input:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.stepper .unit { position: relative; }

.toggle-row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 52px; }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 16px; background: var(--fill-2); transition: background 0.2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); transition: transform 0.2s; }
.switch input:checked + span { background: var(--good); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ------------------------------------------------------------------ нижнее меню */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around; align-items: flex-start;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding: 6px 4px var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: 0.5px solid var(--sep);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--hint); font-size: 10.5px; font-weight: 600; padding-top: 3px; transition: color 0.15s; }
.tab.active { color: var(--accent); }
.tab .icon { width: 24px; height: 24px; }
.tab-dot { position: absolute; margin-left: 18px; margin-top: -2px; width: 8px; height: 8px; border-radius: 50%; background: var(--critical); box-shadow: 0 0 0 2px var(--surface); }

/* ------------------------------------------------------------------ шторки (bottom sheet) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.42); animation: fade 0.2s ease both; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--tg-theme-bg-color, var(--surface)); border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(var(--safe-bottom) + 18px); animation: slideUp 0.26s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  max-width: 640px; margin: 0 auto;
}
.sheet.full { height: 92vh; }
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--fill-2); margin: 0 auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.sheet-title { font-size: 20px; font-weight: 800; letter-spacing: -0.2px; }
.sheet-close { width: 32px; height: 32px; border-radius: 50%; background: var(--fill); display: flex; align-items: center; justify-content: center; color: var(--hint); }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ------------------------------------------------------------------ тосты и таймер */
.toast-wrap { position: fixed; left: 0; right: 0; top: calc(var(--tg-content-safe-area-inset-top, 0px) + 10px); z-index: 90; display: flex; justify-content: center; pointer-events: none; padding: 0 16px; }
.toast {
  max-width: 520px; background: rgba(28, 28, 30, 0.94); color: #fff; padding: 11px 16px; border-radius: 14px; font-weight: 550; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); animation: toastIn 0.25s ease both; text-align: center;
}
.toast.error { background: #b42318; }
@keyframes toastIn { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }

.rest {
  position: fixed; z-index: 45; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px);
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 14px; border-radius: 999px;
  background: rgba(28, 28, 30, 0.94); color: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); animation: toastIn 0.25s ease both;
}
.rest.done { background: var(--good); }
.rest-time { font-weight: 800; font-size: 17px; min-width: 52px; font-variant-numeric: tabular-nums; }
.rest button { white-space: nowrap; height: 32px; padding: 0 11px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); color: #fff; font-weight: 650; font-size: 13px; }
.rest svg.ring { width: 22px; height: 22px; transform: rotate(-90deg); }

.fab {
  position: fixed; z-index: 44; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  height: 54px; padding: 0 20px 0 16px; border-radius: 27px; display: flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; font-weight: 750; font-size: 16px;
  box-shadow: 0 10px 24px rgba(235, 104, 52, 0.38);
}
.fab:active { transform: scale(0.96); }
.with-rest .fab { bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 66px); }

/* ------------------------------------------------------------------ статы и графики */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border-radius: 16px; padding: 13px 14px; box-shadow: var(--shadow); min-width: 0; }
.stat-label { font-size: 13px; color: var(--hint); }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; margin-top: 2px; line-height: 1.15; }
.stat-value small { font-size: 14px; font-weight: 650; color: var(--hint); margin-left: 3px; letter-spacing: 0; }
.stat-delta { font-size: 12.5px; font-weight: 650; margin-top: 3px; display: flex; align-items: center; gap: 3px; }
.stat-delta.up { color: var(--good-text); }
.stat-delta.down { color: var(--danger); }
.stat-delta.flat { color: var(--hint); }

.chart-box { width: 100%; position: relative; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--hint); margin: 4px 0 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-empty { height: 180px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--hint); text-align: center; font-size: 14px; padding: 0 20px; }
.chart-empty .big { font-size: 34px; }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(70px, 34%) 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.hbar-track { height: 10px; border-radius: 5px; background: var(--fill); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--accent); transition: width 0.6s cubic-bezier(0.2, 0.8, 0.2, 1); min-width: 3px; }
.hbar-fill.muted-fill { background: color-mix(in srgb, var(--accent) 38%, var(--fill-2)); }
.hbar-value { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 36px; text-align: right; }

.week { display: flex; justify-content: space-between; gap: 6px; }
.week-day { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--hint); font-weight: 600; }
.week-dot { width: 100%; max-width: 38px; aspect-ratio: 1; border-radius: 12px; background: var(--fill); display: flex; align-items: center; justify-content: center; font-size: 16px; }
.week-dot.on { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; box-shadow: 0 4px 12px rgba(235, 104, 52, 0.3); }
.week-dot.today { box-shadow: inset 0 0 0 2px var(--accent); }
.week-dot.on.today { box-shadow: 0 4px 12px rgba(235, 104, 52, 0.3); }

.meter { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; }
.meter > div { height: 100%; border-radius: 4px; background: var(--accent); transition: width 0.6s ease; }

.heat-wrap { overflow-x: auto; scrollbar-width: none; margin: 0 -4px; padding: 0 4px; }
.heat-wrap::-webkit-scrollbar { display: none; }
.heat-months { display: grid; grid-auto-flow: column; grid-auto-columns: var(--cell); gap: 3px; margin-left: 22px; font-size: 11px; color: var(--hint); height: 16px; }
.heat-body { display: flex; gap: 4px; }
.heat-days { display: grid; grid-template-rows: repeat(7, var(--cell)); gap: 3px; font-size: 10px; color: var(--hint); width: 18px; }
.heat-days span { line-height: var(--cell); }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, var(--cell)); grid-auto-columns: var(--cell); gap: 3px; }
.heat-cell { width: var(--cell); height: var(--cell); border-radius: 3px; background: var(--heat-0); }
.heat-cell.l1 { background: color-mix(in srgb, var(--accent) 28%, transparent); }
.heat-cell.l2 { background: color-mix(in srgb, var(--accent) 50%, transparent); }
.heat-cell.l3 { background: color-mix(in srgb, var(--accent) 75%, transparent); }
.heat-cell.l4 { background: var(--accent); }
.heat-cell.future { background: transparent; }
.heat-cell.sel { outline: 2px solid var(--text); outline-offset: 1px; }
.heat-legend { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--hint); justify-content: flex-end; margin-top: 8px; }
.heat-legend .heat-cell { --cell: 11px; }

.spark { width: 72px; height: 26px; display: block; }

/* графики упражнений: карточка = упражнение, линия по тренировкам (точка — тренировка) */
.lift-card { display: block; width: 100%; text-align: left; background: var(--surface); border-radius: var(--radius); padding: 14px 16px 12px; box-shadow: var(--shadow); }
.lift-card + .lift-card { margin-top: 10px; }
.lift-card:active { background-image: linear-gradient(var(--fill), var(--fill)); } /* затемнение поверх фона карточки */
.lift-head { display: flex; align-items: center; gap: 12px; }
.lift-head .chev { color: var(--hint); opacity: 0.6; }
.lift-now { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; margin-top: 12px; }
.lift-value { font-size: 26px; font-weight: 850; letter-spacing: -0.5px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.lift-value small { font-size: 14px; font-weight: 650; color: var(--hint); margin-left: 3px; letter-spacing: 0; }
.lift-extra { color: var(--hint); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lift-delta { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; }
.lift-delta .stat-delta { margin-top: 0; }
.lift-card .mini-line { margin-top: 6px; }
.mini-line { width: 100%; position: relative; }
.mini-line svg { display: block; overflow: visible; }
.mini-line text { font-family: var(--font); font-variant-numeric: tabular-nums; }
/* Линия «рисуется» при появлении. Пунктир — только внутри анимации (backwards): если анимация
   не сработает, линия всё равно видна целиком. */
.mini-path { animation: mini-draw 0.7s cubic-bezier(0.33, 1, 0.68, 1) backwards; }
.mini-area, .mini-dot { animation: mini-fade 0.35s ease-out 0.35s backwards; }
@keyframes mini-draw {
  from { stroke-dasharray: 1 1; stroke-dashoffset: 1; }
  to { stroke-dasharray: 1 1; stroke-dashoffset: 0; }
}
@keyframes mini-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .mini-path, .mini-area, .mini-dot { animation: none; }
}
.stale .mini-line { opacity: 0.6; transition: opacity 0.2s; }
.chip.sm { height: 30px; padding: 0 12px; font-size: 13px; }

/* ------------------------------------------------------------------ дневник */
.day-nav { display: flex; align-items: center; gap: 8px; }
.day-nav .icon-btn { width: 36px; height: 36px; }
.day-label { position: relative; font-weight: 700; font-size: 15px; padding: 8px 12px; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); display: inline-flex; align-items: center; gap: 4px; }
.day-label input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }

.ex-block { padding: 14px 14px 10px; }
.ex-head { display: flex; align-items: flex-start; gap: 10px; }
.ex-name { font-weight: 750; font-size: 16px; line-height: 1.25; }
.ex-prev { color: var(--hint); font-size: 12.5px; margin-top: 2px; }
.sets { margin-top: 8px; }
.set-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-radius: 10px; width: 100%; text-align: left; }
.set-row:active { background: var(--fill); }
.set-no { width: 24px; height: 24px; border-radius: 8px; background: var(--fill); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; color: var(--hint); flex: none; }
.set-main { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; }
.set-x { color: var(--hint); font-weight: 500; margin: 0 3px; }
.ex-actions { display: flex; gap: 8px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--sep); }
.ex-actions .btn { flex: 1; }

.suggest {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px; width: 100%; text-align: left;
  background: linear-gradient(135deg, rgba(237, 161, 0, 0.14), rgba(235, 104, 52, 0.12));
}
.suggest b { font-size: 16px; }

.pr-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 750; padding: 2px 7px; border-radius: 999px; background: rgba(237, 161, 0, 0.18); color: #a46f00; }
html[data-scheme="dark"] .pr-badge { color: #f3b52b; }

.ex-pick { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-radius: 12px; width: 100%; text-align: left; }
.ex-pick:active { background: var(--fill); }
.group-dot { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 17px; background: var(--fill); flex: none; }

/* ------------------------------------------------------------------ замеры тела */
.measure-head { display: flex; align-items: center; gap: 12px; }
.measure-now { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.measure-value { font-size: 32px; font-weight: 850; letter-spacing: -0.6px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.measure-value small { font-size: 15px; font-weight: 650; color: var(--hint); margin-left: 4px; letter-spacing: 0; }
.measure-delta { font-size: 14px; font-weight: 650; text-align: center; min-height: 20px; }
.measure-delta.flat { color: var(--hint); }
.measure-delta.up { color: var(--good-text); }
.measure-delta.down { color: var(--danger); }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.mini-stats > div { background: var(--fill); border-radius: 12px; padding: 8px 10px; min-width: 0; }
.mini-stats span { display: block; font-size: 12px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-stats b { font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.measure-history { border-top: 1px solid var(--sep); padding-top: 4px; }
.measure-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.measure-row .sheet-close { width: 28px; height: 28px; }
.tip { font-size: 13px; color: var(--hint); background: var(--fill); border-radius: 12px; padding: 10px 12px; line-height: 1.35; }
.note { font-size: 13px; border-radius: 12px; padding: 10px 12px; background: var(--warn-soft); line-height: 1.35; }
.chips.center { justify-content: center; }
.chart-empty.short { height: 92px; font-size: 13px; }
.empty.compact { padding: 16px 8px 4px; }
.empty.compact .big { font-size: 34px; }
.link-btn { color: var(--link); font-size: 14px; font-weight: 550; padding: 8px 0 2px; }
.link-row { display: block; width: 100%; text-align: center; color: var(--hint); font-size: 12.5px; padding: 6px 0; }
.link { color: var(--link); }

/* ------------------------------------------------------------------ сборы */
.w-card { display: block; width: 100%; text-align: left; }
.w-card:active { background: color-mix(in srgb, var(--surface) 92%, var(--text)); }
.w-time { font-size: 30px; font-weight: 850; letter-spacing: -0.8px; line-height: 1; }
.w-type { font-size: 13px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.6px; color: var(--accent); }
.w-date { font-weight: 650; }
.vote-row { display: flex; gap: 8px; margin-top: 12px; }
.vote-row .btn { flex: 1; }
.btn.vote-yes.on { background: var(--good); color: #fff; }
.btn.vote-no.on { background: var(--critical); color: #fff; }
.people { display: flex; flex-direction: column; gap: 2px; }
.person { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.reason { color: var(--hint); font-size: 13px; }

/* ------------------------------------------------------------------ лента */
.feed-item { display: flex; gap: 12px; padding: 12px 16px; position: relative; }
.feed-item + .feed-item::before { content: ""; position: absolute; top: 0; left: 64px; right: 0; height: 1px; background: var(--sep); transform: scaleY(0.5); }
.feed-emoji { position: relative; flex: none; }
.feed-emoji .em { position: absolute; right: -5px; bottom: -4px; font-size: 14px; line-height: 1; }
.feed-title { font-weight: 600; font-size: 14.5px; line-height: 1.3; }
.feed-sub { color: var(--hint); font-size: 13px; margin-top: 1px; }
.feed-time { color: var(--hint); font-size: 12px; white-space: nowrap; }

.insight { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); font-size: 14.5px; line-height: 1.35; }
.insight + .insight { margin-top: 8px; }

.empty { text-align: center; padding: 28px 16px; color: var(--hint); }
.empty .big { font-size: 44px; margin-bottom: 6px; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

.locked { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 10px; }
.locked .big { font-size: 64px; }
.locked h1 { font-size: 24px; margin: 0; }

.skeleton { background: linear-gradient(90deg, var(--fill) 25%, var(--fill-2) 50%, var(--fill) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 14px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

canvas.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 95; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------------------ отчёт за месяц (PDF) */
.month-list { display: flex; flex-direction: column; gap: 6px; }
.month-opt {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 11px 14px;
  border-radius: 14px; background: var(--fill); transition: background 0.15s, box-shadow 0.15s;
}
.month-opt:active { transform: scale(0.99); }
.month-opt.on { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.month-opt .pill { padding: 1px 7px; font-size: 11px; vertical-align: 1px; }
.month-opt .radio { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--fill-2); flex: none; position: relative; }
.month-opt.on .radio { background: var(--accent); box-shadow: none; }
.month-opt.on .radio::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: #fff; }
.report-row .group-dot { color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------------ секретное сравнение (только админ) */
.nom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nom { background: var(--surface); border-radius: 16px; padding: 12px 13px; box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.nom-emoji { font-size: 24px; line-height: 1; }
.nom-title { font-size: 13px; color: var(--hint); line-height: 1.25; }
.nom-who { display: flex; align-items: center; gap: 6px; font-weight: 700; min-width: 0; }
.nom-value { font-size: 12.5px; font-weight: 600; color: var(--accent); }

.cmp-wrap { overflow-x: auto; scrollbar-width: none; }
.cmp-wrap::-webkit-scrollbar { display: none; }
.cmp { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.cmp th, .cmp td { padding: 9px 4px; text-align: center; border-top: 0.5px solid var(--sep); }
.cmp thead th { border-top: 0; padding-top: 12px; font-size: 12px; font-weight: 600; color: var(--hint); max-width: 72px; }
.cmp thead th .avatar { margin: 0 auto 4px; }
.cmp tbody th { text-align: left; font-weight: 500; padding-left: 14px; min-width: 96px; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.cmp tbody th small { display: block; font-size: 11px; color: var(--hint); font-weight: 400; line-height: 1.2; }
.cmp td { font-weight: 600; white-space: nowrap; min-width: 52px; }
.cmp td:last-child { padding-right: 12px; }
.cmp td.text { white-space: normal; font-weight: 500; font-size: 12px; line-height: 1.25; max-width: 76px; overflow-wrap: anywhere; }
.cmp td.lead { color: var(--accent); font-weight: 800; background: var(--accent-soft); }
.cmp tr.cmp-group th { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--hint); background: var(--fill); padding-top: 7px; padding-bottom: 7px; }

.board-notes { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.board-note { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.board-note .stat-delta { margin: 0; font-size: 12px; }

.heat-table td { padding: 5px 3px; min-width: 0; }
.heat-table tbody th { min-width: 0; white-space: nowrap; font-size: 13.5px; }
.heat-chip { position: relative; display: flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; border-radius: 8px; background: var(--fill); overflow: hidden; font-size: 12.5px; font-weight: 650; }
.heat-chip i { position: absolute; inset: 0; background: var(--accent); }
.heat-chip span { position: relative; }
.heat-chip.hot { color: #1f0e05; } /* на насыщенном оранжевом тёмный текст читается лучше белого */

/* ------------------------------------------------------------------ калькулятор блинов (запись подхода) */
.plates { margin-top: 10px; padding: 8px 12px 10px; border-radius: 14px; background: var(--fill); }
.plates svg { display: block; width: 100%; height: 64px; }
.plates-info { margin-top: 4px; }
.plates-near { margin-top: 2px; }
.plates-near .link-btn { padding: 0 2px; font-size: 13px; font-weight: 700; }

/* ------------------------------------------------------------------ калькулятор блинов: выбор грифа */
.plates-bars { display: flex; align-items: center; gap: 5px; margin-top: 8px; flex-wrap: wrap; }
.plates-bars .muted { margin-right: 2px; }
.plates-bars .chip { height: 28px; padding: 0 9px; font-size: 12.5px; background: var(--surface); }
.plates-bars .chip.active { background: var(--accent); color: var(--on-accent); }

/* ------------------------------------------------------------------ ачивки */
svg.badge-logo { display: block; flex: none; overflow: visible; }
svg.badge-logo.badge-off { filter: grayscale(1) contrast(0.85); opacity: 0.38; }

.ach-summary .ach-count { font-size: 30px; font-weight: 800; letter-spacing: -0.4px; line-height: 1.1; }
.ach-summary .ach-count small { font-size: 16px; color: var(--hint); font-weight: 650; }
.fresh-logos { display: inline-flex; flex: none; }
.fresh-logos svg + svg { margin-left: -12px; }

.ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ach-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0;
  padding: 12px 6px 10px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); text-align: center;
}
.ach-tile:active { transform: scale(0.97); }
.ach-name { font-size: 12.5px; font-weight: 650; line-height: 1.2; overflow-wrap: anywhere; }
.ach-tile:not(.earned) .ach-name { color: var(--hint); }
.ach-prog { font-size: 11px; color: var(--hint); font-variant-numeric: tabular-nums; line-height: 1.2; }
.ach-tile.mystery { border: 1.5px dashed var(--fill-2); box-shadow: none; background: transparent; }
.ach-tile.mystery .ach-name { color: var(--text); }
.ach-new {
  position: absolute; top: 6px; right: 6px; z-index: 1; font-size: 9.5px; font-weight: 800; padding: 2px 6px;
  border-radius: 999px; background: var(--accent); color: var(--on-accent); text-transform: uppercase; letter-spacing: 0.3px;
}

.fresh-ach {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: linear-gradient(135deg, rgba(237, 161, 0, 0.16), rgba(235, 104, 52, 0.12)), var(--surface);
}
.fresh-ach .chev { color: var(--hint); opacity: 0.6; }

.ach-detail { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 8px; }
.ach-hero { position: relative; padding: 18px; animation: pop 0.35s ease both; }
.ach-hero.earned::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, rgba(237, 161, 0, 0.32) 0%, rgba(237, 161, 0, 0) 68%);
}
.ach-hero svg { position: relative; }
.ach-cat { margin-top: 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--hint); }
.ach-title { font-size: 26px; font-weight: 800; letter-spacing: -0.3px; line-height: 1.15; margin: 4px 0 10px; }
.ach-joke { margin-top: 14px; font-size: 16px; line-height: 1.4; font-style: italic; max-width: 92%; }
.ach-how { width: 100%; margin-top: 18px; text-align: left; }
.ach-how-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--hint); }
.ach-how-text { margin-top: 4px; font-size: 16px; font-weight: 600; line-height: 1.35; }
.ach-detail .btn.block { width: 100%; }

.unlock-wrap {
  position: fixed; left: 0; right: 0; top: calc(var(--tg-content-safe-area-inset-top, 0px) + 10px); z-index: 92;
  display: flex; justify-content: center; padding: 0 12px; pointer-events: none;
}
.unlock {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; width: 100%; max-width: 520px; text-align: left;
  padding: 12px 14px; border-radius: 18px; color: #fff; animation: unlockIn 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
  background: linear-gradient(135deg, #2b2b33, #141418); box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35), inset 0 0 0 1.5px rgba(255, 196, 0, 0.45);
}
.unlock-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px; color: #ffc94a; }
.unlock-title { font-size: 17px; font-weight: 800; margin-top: 1px; }
.unlock-joke { font-size: 13px; opacity: 0.85; line-height: 1.3; margin-top: 2px; }
@keyframes unlockIn { from { transform: translateY(-24px) scale(0.92); opacity: 0; } to { transform: none; opacity: 1; } }
/* четыре вкладки в переключателе (Прогресс): «Упражнения» должны влезть и на узком экране */
.seg button { min-width: 0; padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg:has(> button:nth-child(4)) button { font-size: 13px; }
.ach-hero svg.badge-logo.badge-off { opacity: 0.55; } /* на странице ачивки серый значок — главный, пусть читается */
