/* ==========================================================================
   Токены. Светлая тема по умолчанию, тёмная — по системе или вручную (data-theme)
   ========================================================================== */
:root {
  --bg: #F3F4F6;
  --panel: #FFFFFF;
  --panel2: #E9ECF1;
  --ink: #161A21;
  --mute: #5E6672;
  --line: #DCE0E7;
  --accent: #C2410C;
  --accent-ink: #FFFFFF;
  --accent-soft: #FCE6DB;
  --warm: #2F6BD1;
  --warm-soft: #DCE7FA;
  --warn: #A86A00;
  --warn-soft: #FBEFD5;
  --neg: #B23A2C;
  --neg-soft: #F7DCD7;
  --pos: #1E8A4C;
  --pos-soft: #DDF2E5;
  --shadow: 0 1px 0 rgba(30, 26, 22, .04), 0 10px 28px -16px rgba(30, 26, 22, .28);
  --radius: 14px;
  --radius-sm: 9px;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Unbounded", "IBM Plex Sans", sans-serif;
  --nav-h: 62px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1217;
    --panel: #171B22;
    --panel2: #212630;
    --ink: #E9ECF2;
    --mute: #9AA2AF;
    --line: #2B313C;
    --accent: #FF8657;
    --accent-ink: #2B0C02;
    --accent-soft: #3A1D13;
    --warm: #7FA9F0;
    --warm-soft: #1B2740;
    --warn: #E8B85A;
    --warn-soft: #3A2E15;
    --neg: #F08A7B;
    --neg-soft: #3B1F1B;
    --pos: #5FCB8B;
    --pos-soft: #17301F;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0F1217;
  --panel: #171B22;
  --panel2: #212630;
  --ink: #E9ECF2;
  --mute: #9AA2AF;
  --line: #2B313C;
  --accent: #FF8657;
  --accent-ink: #2B0C02;
  --accent-soft: #3A1D13;
  --warm: #7FA9F0;
  --warm-soft: #1B2740;
  --warn: #E8B85A;
  --warn-soft: #3A2E15;
  --neg: #F08A7B;
  --neg-soft: #3B1F1B;
  --pos: #5FCB8B;
  --pos-soft: #17301F;
  --shadow: none;
  color-scheme: dark;
}

/* ==========================================================================
   База
   ========================================================================== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mute { color: var(--mute); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ==========================================================================
   Каркас: шапка, навигация, контент
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-in {
  max-width: 1280px;
  margin: 0 auto;
  height: 56px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--ink); font: 600 16px/1 var(--font-head); }
.brand:hover { text-decoration: none; }
.brand-logo { font-size: 22px; }
.topnav { display: none; gap: 4px; }
.topnav a {
  color: var(--mute);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 14px;
}
.topnav a:hover { text-decoration: none; color: var(--ink); background: var(--panel2); }
.topnav a.active { color: var(--accent-ink); background: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.bottomnav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}
.bottomnav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--mute);
  font-size: 11px;
  font-weight: 500;
}
.bottomnav a:hover { text-decoration: none; }
.bottomnav a .ico { font-size: 21px; line-height: 1; filter: grayscale(.9); opacity: .75; }
.bottomnav a.active { color: var(--accent); }
.bottomnav a.active .ico { filter: none; opacity: 1; }

main#view {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 16px 32px;
}
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { flex: 1; min-width: 0; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .bottomnav { display: none; }
  .topnav { display: flex; }
  main#view { padding: 24px 24px 48px; }
  h1 { font-size: 26px; }
}

/* ==========================================================================
   Компоненты
   ========================================================================== */
.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 16px;
}
.card.flat { box-shadow: none; }
.card h2 { margin-bottom: 10px; }
.section + .section { margin-top: 16px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 500;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; background: var(--panel2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--neg); }
/* Подтверждение удаления: красная заливка вместо красного текста на оранжевом */
.btn.primary.danger { background: var(--neg); border-color: var(--neg); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--panel2); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.icon { padding: 7px; min-width: 36px; }
.btn.block { width: 100%; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--panel2);
  color: var(--mute);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.neg { background: var(--neg-soft); color: var(--neg); }
.chip.warm { background: var(--warm-soft); color: var(--warm); }
.chip.pos { background: var(--pos-soft); color: var(--pos); }

/* Переключатели-«таблетки» (фильтры, вкладки, сегменты) */
.pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.pill:hover { background: var(--panel2); }
.pill.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.segmented {
  display: inline-flex;
  background: var(--panel2);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--mute);
  cursor: pointer;
}
.segmented button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* Формы */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--mute); }
.field > span { font-weight: 500; }
.input, .select, .textarea {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  color: var(--ink);
  font-size: 15px;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .form-grid.two { grid-template-columns: 1fr 1fr; }
  .form-grid.four { grid-template-columns: repeat(4, 1fr); }
}
.search {
  position: relative;
  flex: 1;
  min-width: 180px;
}
.search .input { padding-left: 34px; }
.search::before {
  content: "🔍";
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: .6;
}

.alert { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; }
.alert.err { background: var(--neg-soft); color: var(--neg); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--accent-soft); color: var(--accent); }
.alert.info { background: var(--warm-soft); color: var(--warm); }

.empty { text-align: center; color: var(--mute); padding: 40px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.grid > .empty { grid-column: 1 / -1; } /* пустой результат — по центру всей сетки, а не в первой колонке */

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Таблицы */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; color: var(--mute); font-weight: 500; font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table td.r, .table th.r { text-align: right; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--panel2); }

/* Модальное окно: снизу «шторкой» на телефоне, по центру на десктопе */
.modal-back {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, .45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .15s ease-out;
}
.modal {
  background: var(--panel);
  width: 100%;
  max-height: 92vh;
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  animation: rise .2s ease-out;
}
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; font-size: 16px; }
.modal-body { padding: 14px 16px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
@media (min-width: 640px) {
  .modal-back { align-items: center; padding: 24px; }
  .modal { max-width: 560px; border-radius: 18px; max-height: 86vh; }
  .modal.wide { max-width: 860px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: .6; } }

.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  animation: rise .2s ease-out;
}
.toast.err { background: var(--neg); color: #fff; }
@media (min-width: 900px) { .toasts { bottom: 24px; } }

/* Меню пользователя */
.menu { position: relative; }
.menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 200px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  padding: 6px;
  z-index: 50;
}
.menu-pop a, .menu-pop button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 9px 10px;
  border-radius: 8px;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--panel2); text-decoration: none; }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu-pop .who { padding: 8px 10px; font-size: 12px; color: var(--mute); }

/* Экран входа */
.auth-wrap { max-width: 380px; margin: 6vh auto 0; }
.auth-wrap .card { padding: 24px 20px; }
.auth-wrap h1 { font-size: 20px; margin-bottom: 4px; }

/* ==========================================================================
   Каталог
   ========================================================================== */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}
.rcard {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.rcard:hover { text-decoration: none; transform: translateY(-2px); }
.rcard-cover {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--panel2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  overflow: hidden;
}
.rcard-cover img { width: 100%; height: 100%; object-fit: cover; }
.rcard-badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; gap: 6px; align-items: flex-start; font-size: 12px; line-height: 1; }
.rcard-badges.bottom { top: auto; bottom: 8px; }
/* Длинный диапазон уровней («Продолжающий — Усложнённый») на узкой карточке переносится, а не обрезается */
.rcard-badges .chip { background: rgba(0, 0, 0, .55); color: #fff; backdrop-filter: blur(4px); white-space: normal; line-height: 1.25; max-width: 100%; }
.rcard-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.rcard-title { font-weight: 600; font-size: 15px; line-height: 1.3; }
.rcard-sub { font-size: 12px; color: var(--mute); margin-top: -4px; }
.rcard-desc { font-size: 13px; color: var(--mute); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rcard-stats { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; margin-top: auto; padding-top: 4px; }
.rcard-stats b { font-weight: 600; }

.fav-btn {
  border: 0;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  border-radius: 999px;
  width: 30px;
  height: 30px;
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: blur(4px);
}
.fav-btn.on { color: #FF6B81; }

/* Фильтры каталога */
.pills.wrap { flex-wrap: wrap; overflow: visible; }
.filters > .segmented { align-self: flex-start; }
.filter-panel { gap: 12px; }
.filter-label { font-size: 12px; font-weight: 600; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-row { display: flex; flex-direction: column; gap: 4px; }
.tag-row + .tag-row { margin-top: 10px; }

/* Карточка упражнения */
/* На телефоне длинное название — отдельной строкой, кнопки под ним */
@media (max-width: 640px) { .page-head.detail h1 { flex-basis: 100%; } }
.detail-layout { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 1000px) {
  .detail-layout { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .detail-side { position: sticky; top: 72px; }
}
/* Комплекс: в одну колонку уровень и итог — над составом (переключатель меняет всё ниже) */
@media (max-width: 999px) {
  .detail-layout.side-first > .detail-side { display: contents; }
  .detail-layout.side-first .side-top { order: -1; }
}
.hero {
  border-radius: var(--radius);
  background: var(--panel2);
  aspect-ratio: 16 / 8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
}
.gallery { overflow: hidden; }
.gallery-main {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--panel2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-main img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.gallery-main iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.gallery-play { position: absolute; right: 10px; bottom: 10px; background: rgba(0, 0, 0, .55); color: #fff; border-color: transparent; }
.gallery-play:hover { background: rgba(0, 0, 0, .7); }
.gallery-thumbs { display: flex; gap: 8px; padding: 8px; overflow-x: auto; border-top: 1px solid var(--line); }
.gallery-thumb {
  position: relative;
  flex: none;
  width: 84px;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  background: var(--panel2);
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gallery-thumb.on { border-color: var(--accent); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; }
.yt-ico { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 24px; border-radius: 7px; background: #E62117; color: #fff; font-size: 13px; }
.yt-start {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font: 600 15px/1 var(--font);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.yt-start .yt-ico { width: 64px; height: 44px; font-size: 22px; border-radius: 12px; }
.media-badge { position: absolute; left: 6px; top: 6px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; padding: 2px 7px; }
.media-badge.right { left: auto; right: 6px; }
.gallery-thumb .media-badge { left: 3px; top: 3px; font-size: 9px; padding: 1px 5px; }

.segmented.levels { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; }
.segmented.levels button { padding: 7px 2px; font-size: 12px; }
.segmented.levels button:disabled { opacity: .35; cursor: not-allowed; }
.level-title { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-family: var(--font-head); font-size: 15px; }
.params { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.param { background: var(--panel2); border-radius: 12px; padding: 10px 4px; text-align: center; min-width: 0; }
.param .v { font: 600 17px/1.1 var(--font-head); font-variant-numeric: tabular-nums; white-space: nowrap; }
.param .l { font-size: 11px; color: var(--mute); margin-top: 4px; }
.params + .alert { margin-top: 10px; }
@media (max-width: 420px) { .param .v { font-size: 14px; } }

/* Форма упражнения */
.media-edit { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.media-tile {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel2);
  border: 1px solid var(--line);
}
.media-tile img { width: 100%; height: 100%; object-fit: cover; }
.media-tile.add {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--mute);
  border-style: dashed;
  cursor: pointer;
}
.media-tile.add:hover { border-color: var(--accent); color: var(--accent); }
.media-tools { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; padding: 4px; background: linear-gradient(transparent, rgba(0, 0, 0, .45)); }
.media-tools .btn { min-width: 30px; padding: 4px; background: rgba(255, 255, 255, .9); color: #161A21; border-color: transparent; }
.level-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.level-box.base { border-color: var(--accent); }
.level-inputs { display: grid; gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.table tr.on td { background: var(--accent-soft); }

.md { line-height: 1.6; }
.md p { margin: 0 0 10px; }
.md ol, .md ul { margin: 0 0 10px; padding-left: 22px; }
.md li { margin-bottom: 6px; }
.md li::marker { color: var(--accent); font-weight: 600; }
.md :last-child { margin-bottom: 0; }

.stars { display: inline-flex; gap: 2px; }
.stars button { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--line); padding: 2px; }
.stars button.on { color: #F2B400; }

.bar { height: 6px; border-radius: 3px; background: var(--panel2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.entry { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; }
.entry .t { flex: 1; min-width: 0; }
.entry .t .n { font-weight: 500; }
.entry .k { text-align: right; font-size: 13px; white-space: nowrap; }
.entry.planned { opacity: .7; }
.entry .thumb { width: 48px; height: 48px; flex: none; border-radius: var(--radius-sm); object-fit: cover; background: var(--panel2); }
.entry .thumb.ph { display: grid; place-items: center; font-size: 22px; }
.rest-line { padding: 4px 0 4px 58px; font-size: 12px; color: var(--mute); border-bottom: 1px solid var(--line); }
.rest-line::before { content: "⏸ "; }
.witem { border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.witem:last-child { border-bottom: 0; }
/* Выбор упражнений в комплекс: отступ справа, чтобы полоса прокрутки не закрывала кнопку «＋» */
.pick-list { margin-top: 8px; max-height: 55vh; overflow-y: auto; padding-right: 8px; }
.entry.pick {
  width: 100%;
  text-align: left;
  color: var(--ink);
  font: inherit;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  border-radius: 0;
  cursor: pointer;
}
.entry.pick:hover { background: var(--panel2); }
.entry.pick:last-child { border-bottom: 0; }
.pick-mark {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
  font-weight: 600;
}
.entry.pick:hover .pick-mark { background: var(--accent); color: var(--accent-ink); }
.entry.pick.added .pick-mark { background: var(--accent); color: var(--accent-ink); }

/* Настройки упражнения в редакторе комплекса: строка «отдых после / подсказка» и «Свои параметры»
   по краям, под ней — панель своей базы */
.witem-set { padding-left: 58px; display: flex; flex-direction: column; gap: 8px; }
.witem-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; min-height: 42px; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.field.inline .input { width: 88px; }
.witem-base {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--panel2);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.witem-base > .tiny { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .witem-set { padding-left: 0; }
  .witem-base { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.two-col { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .two-col { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; } }

.chart-box { position: relative; height: 240px; }

/* Автодополнение */
.ac { position: relative; }
.ac-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18);
  max-height: 260px;
  overflow-y: auto;
  z-index: 60;
}
.ac-list button {
  display: flex;
  width: 100%;
  text-align: left;
  gap: 8px;
  border: 0;
  background: none;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 14px;
}
.ac-list button:hover, .ac-list button.hl { background: var(--panel2); }

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

/* На телефоне подпись периода в панели инструментов — отдельной строкой сверху */
@media (max-width: 640px) {
  .toolbar > b.grow { order: -1; flex-basis: 100%; }
  .page-head h1 { font-size: 20px; }
}
@media (max-width: 560px) { .wide-only { display: none; } }

/* Закреплённая панель «Сохранить» в длинных формах */
.save-bar {
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  z-index: 5;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
@media (min-width: 900px) { .save-bar { bottom: 12px; } }

/* ==========================================================================
   Плеер тренировки (views/player.js) и история. Во время тренировки навигация скрыта (body.playing),
   управление — крупными кнопками, «Пауза» и «Закончить» — внизу под большим пальцем
   ========================================================================== */
body.playing { padding-bottom: 0; }
body.playing .topbar, body.playing .bottomnav { display: none; }
body.playing main#view { padding-top: calc(10px + env(safe-area-inset-top)); }

.pl { max-width: 560px; margin: 0 auto; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.pl-top { display: flex; align-items: center; gap: 8px; }
.pl-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; line-height: 1.25; }
.pl-title b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-progress { margin: 8px 0 4px; }
.pl-progress > i { width: 0; transition: width .25s linear; }
.pl-times { display: flex; justify-content: space-between; margin-bottom: 12px; }

.pl-body { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 12px; text-align: center; }
.pl-stage {
  align-self: center;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.pl-media {
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  height: min(34vh, 320px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pl-media img { width: 100%; height: 100%; object-fit: contain; }
.pl-noimg { width: 100%; height: 100%; display: grid; place-items: center; font-size: 56px; background: var(--panel2); }
.pl-name { font-size: 22px; }
.pl-set { font-weight: 600; color: var(--mute); margin-top: -6px; }
.pl-goal { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pl-big { font: 600 clamp(56px, 18vw, 96px)/1 var(--font-head); font-variant-numeric: tabular-nums; }
.pl-big.count { color: var(--accent); animation: pl-pulse 1s ease-out infinite; }
.pl-rest .pl-big { font-size: clamp(64px, 22vw, 120px); }
.pl-label { color: var(--mute); font-size: 15px; font-weight: 500; }
@keyframes pl-pulse { from { transform: scale(1.12); } to { transform: scale(1); } }

.btn.pl-main { width: 100%; min-height: 56px; font-size: 18px; border-radius: 14px; }
.btn.pl-main:disabled { opacity: .4; }
.pl-next { margin-top: -4px; }
.pl-inputs { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 20px; }
.pl-field { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 13px; color: var(--mute); }
.pl-field .input { width: 96px; text-align: center; font-size: 18px; padding: 8px; }
.pl-stepper { display: flex; align-items: center; gap: 6px; }
.pl-stepper .btn { min-width: 44px; height: 44px; font-size: 20px; padding: 0; }
.pl-stepper .input { width: 72px; }
.pl-rest-btns { display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; }
.pl-rest-btns .btn { min-height: 52px; font-size: 16px; }
.pl-upnext, .pl-last, .pl-tech { text-align: left; }
.pl-upnext .row { margin-top: 6px; gap: 12px; }
.pl-thumb { width: 52px; height: 52px; flex: none; border-radius: var(--radius-sm); object-fit: cover; background: var(--panel2); }
.pl-thumb.ph { display: grid; place-items: center; font-size: 24px; }
.pl-tech summary { cursor: pointer; font-weight: 600; }
.pl-tech .md { margin-top: 10px; }
/* Пауза — плашка над шагом, страница остаётся читаемой (техника, анимация, «Дальше») */
.pl-paused {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-weight: 600;
}
.pl-paused[hidden] { display: none; }
.pl-paused .btn { min-height: 44px; }
.pl-big.stopped { opacity: .45; }
.pl-foot {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr 1fr auto;
  gap: 8px;
  padding: 10px max(16px, calc((100vw - 560px) / 2)) calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.btn.pl-ctl { min-height: 50px; font-size: 16px; }
.btn.pl-ctl.icon { min-width: 50px; padding: 0 12px; }
.btn.pl-ctl:disabled { opacity: .4; }

.pl-ready { max-width: 560px; margin: 0 auto; }
.pl-list { margin: 0; padding-left: 22px; }
.pl-list li { margin-bottom: 4px; }

.pl-done { max-width: 640px; margin: 0 auto; }
.pl-emoji { font-size: 56px; line-height: 1; }
.params.pl-sum { grid-template-columns: repeat(3, 1fr); }
.pl-of { font-size: 12px; color: var(--mute); font-family: var(--font); }
.pl-done-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
@media (max-width: 420px) { .params.pl-sum { grid-template-columns: repeat(2, 1fr); } }

.pl-hist-ico { font-size: 22px; width: 32px; text-align: center; flex: none; }
.entry.pl-hist:hover { text-decoration: none; background: var(--panel2); }

/* ==========================================================================
   Избранное, оценки, заметки, похожие (social.js)
   ========================================================================== */
.rating-stat { color: var(--ink); white-space: nowrap; }
.rating-stat .star { color: #F2B400; }
.fav-toggle.on { color: #E0435C; border-color: currentColor; }
.social-card .stars button { font-size: 26px; }
.social-card .stars button:disabled { cursor: default; }
/* Наведение подсвечивает звёзды до выбранной */
.social-card .stars:hover button:not(:disabled) { color: #F2B400; }
.social-card .stars button:not(:disabled):hover ~ button { color: var(--line); }
.note-state { min-height: 1.2em; }
.note-state.err { color: var(--neg); }
.similar { margin-top: 24px; }
.similar h2 { margin-bottom: 4px; }
.similar > p { margin: 0 0 12px; }

/* ==========================================================================
   Профиль и «Рекомендуем для вас» (этап 7a)
   ========================================================================== */
/* Лента прокручивается сама по себе: на телефоне не раздвигает страницу, видно край следующей карточки */
.recs { margin-bottom: 16px; min-width: 0; }
.recs-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.recs-head h2 { flex: 1; min-width: 0; font-size: 16px; }
.recs-head .row { gap: 4px; align-items: center; }
/* Четыре вкладки каталога («…, Рекомендации») на телефоне листаются, а не раздвигают страницу */
.filters > .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.filters > .segmented button { white-space: nowrap; }
.recs-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 250px);
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding: 2px 2px 8px;
}
.recs-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; scroll-snap-align: start; }
.recs-item .rcard { flex: 1; }
.recs-item .rcard:hover { transform: none; } /* подъём при наведении обрезался бы краем ленты */
.recs-why { font-size: 12px; color: var(--accent); line-height: 1.3; }
@media (max-width: 640px) { .recs-strip { grid-auto-columns: 72%; } }

.recs-invite {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.recs-invite a { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; color: var(--ink); }
.recs-invite a:hover { text-decoration: none; }
.recs-invite a > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.recs-invite-ico { font-size: 22px; flex: none; }

.profile-min { width: 96px; }

/* ==========================================================================
   План тренировок (views/plan.js, plan-dialog.js)
   ========================================================================== */
.plan-title { font-size: 15px; }
.plan-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--mute); }
.plan-dot.warm { background: var(--warm); }
.plan-dot.warn { background: var(--warn); }
.plan-dot.neg { background: var(--neg); }
.plan-dot.pos { background: var(--pos); }
.plan-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; }
.plan-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* День: строка пункта и действия под ней */
.plan-day { padding: 4px 16px; }
.plan-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.plan-item:last-child { border-bottom: 0; }
.plan-row { display: flex; align-items: flex-start; gap: 8px; }
.plan-head { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: var(--ink); }
.plan-head:hover { text-decoration: none; }
.plan-head .t { flex: 1; min-width: 0; }
.plan-head .n { font-weight: 500; }
.plan-head .thumb { width: 48px; height: 48px; flex: none; border-radius: var(--radius-sm); object-fit: cover; background: var(--panel2); }
.plan-head .thumb.ph { display: grid; place-items: center; font-size: 22px; }
.plan-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; padding-left: 58px; }
@media (max-width: 420px) { .plan-acts { padding-left: 0; } }

/* Неделя: дни списком, на широком экране — в две колонки */
.plan-week { display: grid; gap: 10px; grid-template-columns: 1fr; }
/* Две колонки на широком экране — колонками текста, а не сеткой: короткий день не оставляет пустоты рядом с длинным */
@media (min-width: 900px) {
  .plan-week { display: block; columns: 2; column-gap: 10px; }
  .plan-week > .plan-wday { break-inside: avoid; margin-bottom: 10px; }
}
.plan-wday { padding: 6px 14px 8px; }
.plan-wday.today { outline: 2px solid var(--warm); outline-offset: -2px; }
.plan-wday-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.plan-witem { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.plan-witem .t { flex: 1; min-width: 0; color: var(--ink); overflow-wrap: anywhere; }
.plan-witem .t:hover { text-decoration: none; }
.plan-witem .n { font-weight: 500; }
.plan-free { padding: 4px 0 2px; border-top: 1px solid var(--line); }

/* Месяц: на телефоне — число и точки-статусы, с 900px — и названия */
.plan-month { padding: 8px; }
.pm-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.pm-dow span { text-align: center; font-size: 12px; color: var(--mute); padding: 2px 0 4px; }
.pm-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  padding: 6px 2px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--panel2);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
}
.pm-cell:hover { border-color: var(--line); }
.pm-cell.out { background: transparent; color: var(--mute); }
.pm-cell.today { border-color: var(--warm); }
.pm-cell.today .pm-num { color: var(--warm); font-weight: 700; }
.pm-num { font-size: 14px; line-height: 1; font-variant-numeric: tabular-nums; }
.pm-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; min-height: 9px; }
.pm-dots small { font-size: 10px; line-height: 9px; color: var(--mute); }
.pm-names { display: none; }
@media (min-width: 900px) {
  .pm-cell { align-items: stretch; min-height: 96px; padding: 6px; }
  .pm-dots { justify-content: flex-start; }
  .pm-names { display: flex; flex-direction: column; gap: 2px; text-align: left; font-size: 11px; line-height: 1.25; }
  .pm-names span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ==========================================================================
   Популярность и оценка после тренировки (этап 6b)
   ========================================================================== */
.pop-stat { white-space: nowrap; }
.pl-rate { align-items: center; text-align: center; }
.pl-rate h2 { margin: 0; }
.pl-rate .stars button { font-size: 34px; padding: 2px 4px; }
.pl-rate .stars button:disabled { cursor: default; }
.pl-rate .stars:hover button:not(:disabled) { color: #F2B400; }
.pl-rate .stars button:not(:disabled):hover ~ button { color: var(--line); }

/* ============================================================================
   Автоплан на неделю (auto-plan.js): дни черновика в окне
   ============================================================================ */
/* Заголовок «Плана»: две кнопки; на узком экране — под заголовком во всю ширину, а не поверх него */
.plan-head-acts { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .plan-head h1 { flex-basis: 100%; }
  .plan-head-acts { width: 100%; }
  .plan-head-acts .btn { flex: 1 1 auto; justify-content: center; }
}
.ap-days { display: flex; flex-direction: column; margin-top: 4px; }
.ap-day { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ap-day:last-child { border-bottom: 0; }
.ap-date { flex: none; width: 52px; display: flex; flex-direction: column; font-size: 12px; color: var(--mute); line-height: 1.3; }
.ap-date b { font-size: 15px; color: var(--ink); }
.ap-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ap-day.rest .ap-main, .ap-day.busy .ap-main { padding-top: 2px; font-size: 14px; color: var(--mute); }
.ap-day.rest .ap-main .btn { margin-left: 8px; }
.ap-w { display: flex; align-items: flex-start; gap: 10px; }
.ap-w .thumb { width: 48px; height: 48px; flex: none; border-radius: var(--radius-sm); object-fit: cover; background: var(--panel2); }
.ap-w .thumb.ph { display: grid; place-items: center; font-size: 22px; }
.ap-w .t { flex: 1; min-width: 0; }
.ap-w .n { font-weight: 500; }
.ap-why { margin-top: 2px; color: var(--mute); }
.ap-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.ap-hints { margin: 6px 0 0; padding-left: 18px; }

/* ==========================================================================
   Статистика (этап 8): ударный режим, счётчики, диаграммы (charts.js), карта тела (bodymap.js), таймлайн
   ========================================================================== */
:root {
  /* Типы нагрузки — по месту в справочнике; порядок цветов проверен на различимость при дальтонизме */
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100;
  --c5: #e87ba4; --c6: #008300; --c7: #6250d6; --c8: #e34948;
  /* Карта тела: от холодного (мало) к горячему (много) */
  --heat-1: #7fb2ee; --heat-2: #9b8ae6; --heat-3: #e07bb0; --heat-4: #f08a4b; --heat-5: #e2412f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
    --c5: #d55181; --c6: #2f9a2f; --c7: #9085e9; --c8: #e66767;
    --heat-1: #3f7fd0; --heat-2: #7466d6; --heat-3: #c85a93; --heat-4: #e0742f; --heat-5: #ef4b3c;
  }
}
:root[data-theme="dark"] {
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500;
  --c5: #d55181; --c6: #2f9a2f; --c7: #9085e9; --c8: #e66767;
  --heat-1: #3f7fd0; --heat-2: #7466d6; --heat-3: #c85a93; --heat-4: #e0742f; --heat-5: #ef4b3c;
}

/* Подсказка диаграмм — одна на страницу, у курсора или над нажатым элементом */
.viz-tip {
  position: fixed;
  z-index: 60;
  max-width: min(300px, calc(100vw - 16px));
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.viz-tip b { font-weight: 600; }
[data-tip] { cursor: pointer; }

/* Ударный режим */
.st-hero { display: grid; gap: 12px; grid-template-columns: 1fr auto; align-items: center; overflow: hidden; }
.st-hero.is-record { background: linear-gradient(135deg, var(--panel) 55%, var(--accent-soft)); }
.st-hero-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.st-flame { font-size: 48px; line-height: 1; filter: drop-shadow(0 4px 10px color-mix(in srgb, var(--accent) 45%, transparent)); }
.st-flame.off { filter: grayscale(1); opacity: .45; }
.st-hero.is-record .st-flame { animation: st-flicker 1.6s ease-in-out infinite; }
.st-streak { font: 600 44px/1 var(--font-head); color: var(--accent); }
.st-streak-l { font-weight: 500; color: var(--mute); }
.st-record { display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--warn-soft); color: var(--warn); }
.st-record.new { background: linear-gradient(90deg, #F2B400, #FF8657, #F2B400); background-size: 200% 100%; color: #2B0C02; animation: st-shine 2.4s linear infinite; }
.st-hero-week { display: flex; align-items: center; gap: 10px; }
.st-ring-legend { display: flex; flex-direction: column; gap: 4px; white-space: nowrap; }
.st-ring-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.st-ring-legend i.r-days { background: var(--accent); }
.st-ring-legend i.r-min { background: var(--warm); }
.st-status, .st-strip, .st-hero > .tiny { grid-column: 1 / -1; margin: 0; }
.st-status { font-weight: 500; }
.st-strip { display: grid; grid-template-columns: repeat(12, 1fr); gap: 5px; }
.st-week { height: 10px; border-radius: 5px; background: var(--panel2); }
.st-week.met { background: var(--accent); }
.st-week.current { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 480px) {
  .st-hero { grid-template-columns: 1fr; }
}
@keyframes st-flicker { 0%, 100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.08) rotate(2deg); } }
@keyframes st-shine { to { background-position: -200% 0; } }

.rings { flex: none; }
.rings .ring-track { fill: none; stroke: var(--panel2); }
.rings .ring-val { fill: none; stroke-linecap: round; }
.rings .ring-val.r-days { stroke: var(--accent); }
.rings .ring-val.r-min { stroke: var(--warm); }

/* Период и счётчики */
.st-period { margin: 16px 0 12px; }
.st-period .segmented { max-width: 100%; }
.st-tiles { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .st-tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.st-tile { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; display: flex; flex-direction: column; min-width: 0; }
.st-tile-ico { font-size: 20px; line-height: 1; margin-bottom: 6px; }
.st-tile-v { font: 600 22px/1.15 var(--font-head); overflow-wrap: anywhere; }
.st-tile-l { font-size: 13px; font-weight: 500; }
.st-tile-s { font-size: 12px; color: var(--mute); margin-top: 2px; }

.st-grid { display: grid; gap: 16px; grid-template-columns: 1fr; margin-top: 16px; }
@media (min-width: 900px) { .st-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; } }
.st-grid + .st-card { margin-top: 16px; }
/* Левая колонка — «пончик» и недели друг под другом: под коротким кольцом нет пустоты рядом с высокой картой */
.st-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.st-card h2 { margin-bottom: 2px; }
.st-hint { margin: 0 0 10px; }
.st-credit { margin: 10px 0 0; }

/* «Пончик» и легенда */
.st-donut { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px; }
.st-donut .donut { flex: none; }
.donut-track { fill: none; stroke: var(--panel2); }
.donut-seg { fill: none; }
.donut-center { font: 600 26px var(--font-head); fill: var(--ink); }
.donut-sub { font-size: 12px; fill: var(--mute); }
.st-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 150px; font-size: 14px; }
.st-legend li { display: flex; align-items: center; gap: 8px; }
.st-legend i { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.donut-seg.c1 { stroke: var(--c1); } .st-legend i.c1 { background: var(--c1); }
.donut-seg.c2 { stroke: var(--c2); } .st-legend i.c2 { background: var(--c2); }
.donut-seg.c3 { stroke: var(--c3); } .st-legend i.c3 { background: var(--c3); }
.donut-seg.c4 { stroke: var(--c4); } .st-legend i.c4 { background: var(--c4); }
.donut-seg.c5 { stroke: var(--c5); } .st-legend i.c5 { background: var(--c5); }
.donut-seg.c6 { stroke: var(--c6); } .st-legend i.c6 { background: var(--c6); }
.donut-seg.c7 { stroke: var(--c7); } .st-legend i.c7 { background: var(--c7); }
.donut-seg.c8 { stroke: var(--c8); } .st-legend i.c8 { background: var(--c8); }

/* Карта тела */
.bodymap { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-width: 460px; margin: 0 auto; }
.bodymap-fig { margin: 0; text-align: center; }
.bodymap-fig figcaption { font-size: 12px; color: var(--mute); margin-top: 4px; }
.bodymap-svg { aspect-ratio: 650 / 1280; display: grid; place-items: center; }
.bodymap-svg svg { width: 100%; height: 100%; display: block; }
.bodymap .body-outline { fill: var(--panel2); stroke: var(--line); stroke-width: 3; }
.bodymap .body-base path { fill: var(--line); }
.bodymap .body-hair path { fill: var(--mute); opacity: .55; }
.bodymap .body-zone path { stroke: var(--panel); stroke-width: 2; transition: fill .3s; }
.bodymap .body-zone:hover path { stroke: var(--ink); }
.body-zone.heat-0 path, .heat-legend i.heat-0 { fill: color-mix(in srgb, var(--mute) 22%, var(--panel)); background: color-mix(in srgb, var(--mute) 22%, var(--panel)); }
.body-zone.heat-1 path, .heat-legend i.heat-1 { fill: var(--heat-1); background: var(--heat-1); }
.body-zone.heat-2 path, .heat-legend i.heat-2 { fill: var(--heat-2); background: var(--heat-2); }
.body-zone.heat-3 path, .heat-legend i.heat-3 { fill: var(--heat-3); background: var(--heat-3); }
.body-zone.heat-4 path, .heat-legend i.heat-4 { fill: var(--heat-4); background: var(--heat-4); }
.body-zone.heat-5 path, .heat-legend i.heat-5 { fill: var(--heat-5); background: var(--heat-5); }
/* Суставы: точки поверх силуэта, мышцы в этом режиме приглушены и не отвечают на наведение */
.bodymap .joint-layer { display: none; }
.bodymap.joints-mode .joint-layer { display: inline; }
.bodymap.joints-mode .body-zone { pointer-events: none; }
.bodymap.joints-mode .body-zone path { fill: color-mix(in srgb, var(--mute) 12%, var(--panel)); }
.bodymap .joint { stroke: var(--panel); stroke-width: 6; cursor: default; transition: fill .3s; }
.bodymap .joint:hover, .bodymap .joint.hl { stroke: var(--ink); }
.bodymap .joint.heat-0 { fill: color-mix(in srgb, var(--mute) 45%, var(--panel)); }
.bodymap .joint.heat-1 { fill: var(--heat-1); }
.bodymap .joint.heat-2 { fill: var(--heat-2); }
.bodymap .joint.heat-3 { fill: var(--heat-3); }
.bodymap .joint.heat-4 { fill: var(--heat-4); }
.bodymap .joint.heat-5 { fill: var(--heat-5); }
.heat-legend { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 10px 0 4px; font-size: 12px; color: var(--mute); }
.heat-legend i { display: block; width: 18px; height: 10px; border-radius: 3px; }
.heat-scale { display: flex; gap: 2px; }
.lagging { margin-top: 10px; }

/* Столбики по неделям */
.st-bars { max-width: 560px; }
.bars { width: 100%; height: auto; display: block; overflow: visible; }
.bars .hit { fill: transparent; }
.bars .bar { fill: color-mix(in srgb, var(--accent) 35%, var(--panel2)); }
.bars .bar.met { fill: var(--accent); }
.bars .bar-col:hover .bar { filter: brightness(1.08); }
.bars .bar-zero { fill: var(--line); }
.bars .axis { stroke: var(--line); stroke-width: 1; }
.bars .norm-line { stroke: var(--warm); stroke-width: 1.5; stroke-dasharray: 4 4; }
.bars .norm-label, .axis-label { font-size: 9px; fill: var(--mute); font-family: var(--font); }

/* Тепловой календарь: сетка года (SVG) и месяц (HTML) — общие уровни 0–4 */
.hm-0 { fill: var(--panel2); background: var(--panel2); }
.hm-1 { fill: color-mix(in srgb, var(--accent) 30%, var(--panel2)); background: color-mix(in srgb, var(--accent) 30%, var(--panel2)); }
.hm-2 { fill: color-mix(in srgb, var(--accent) 55%, var(--panel2)); background: color-mix(in srgb, var(--accent) 55%, var(--panel2)); }
.hm-3 { fill: color-mix(in srgb, var(--accent) 78%, var(--panel2)); background: color-mix(in srgb, var(--accent) 78%, var(--panel2)); }
.hm-4 { fill: var(--accent); background: var(--accent); }
.hm-scroll { overflow-x: auto; padding: 8px 0 4px; scrollbar-width: thin; }
.hm-year { display: block; }
.hm-year .axis-label { font-size: 10px; }
.hm-cell:hover { stroke: var(--ink); stroke-width: 1.5; }
.hm-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 8px 0; }
.hm-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; max-width: 420px; margin: 0 auto; }
.hm-months { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.hm-months .hm-month { max-width: none; }
.hm-cap { text-align: center; font-weight: 600; margin-bottom: 6px; }
.hm-dow { text-align: center; font-size: 12px; color: var(--mute); }
.hm-day { aspect-ratio: 1; display: grid; place-items: center; border-radius: 8px; font-size: 13px; font-variant-numeric: tabular-nums; }
.hm-day.hm-3, .hm-day.hm-4 { color: var(--accent-ink); font-weight: 600; }
.hm-day.out { background: transparent; }
.hm-day.future { background: transparent; color: var(--mute); border: 1px dashed var(--line); }
.hm-day.today { outline: 2px solid var(--warm); outline-offset: 1px; }
.hm-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 10px; }
.hm-legend i { display: block; width: 12px; height: 12px; border-radius: 3px; }

/* Таймлайн: вертикальная линия, точка-статус, карточка-событие */
.timeline { position: relative; }
.tl-day { font-size: 12px; font-weight: 600; color: var(--mute); text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 6px 36px; }
.tl-day:first-child { margin-top: 4px; }
.tl-item { position: relative; display: flex; gap: 12px; color: var(--ink); padding-bottom: 10px; }
.tl-item:hover { text-decoration: none; }
.tl-item::before { content: ""; position: absolute; left: 11px; top: 30px; bottom: 0; width: 2px; background: var(--line); }
.tl-dot { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; margin-top: 10px; position: relative; }
.tl-item.done .tl-dot { background: var(--pos); color: #fff; }
.tl-item.stopped .tl-dot { background: var(--warn-soft); color: var(--warn); font-size: 9px; }
.tl-card { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; transition: transform .15s, border-color .15s; }
.tl-item:hover .tl-card { border-color: var(--accent); transform: translateX(2px); }
.tl-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--mute); }
.tl-name { font-weight: 600; overflow-wrap: anywhere; }
.tl-meta { font-size: 13px; color: var(--mute); }
.tl-progress { margin: 2px 0; }
.tl-item.done .tl-progress > i { background: var(--pos); }
.tl-item.stopped .tl-progress > i { background: var(--warn); }
.tl-card .chips .chip { font-size: 12px; }
.tl-item:last-child::before { display: none; }

@media (prefers-reduced-motion: reduce) {
  .st-hero.is-record .st-flame, .st-record.new { animation: none; }
}
