/* FitCoach — тёмная тема по умолчанию, светлая по переключателю/системе.
   Все цвета текста проверены на контраст ≥ 4.5:1 к самому светлому фону,
   на котором встречаются (surface-2) — порог AA для мелкого текста.
   Палитра графиков проверена валидатором на различимость при дальтонизме. */

:root {
  color-scheme: dark;

  --bg: #0a0b0f;
  --surface-1: #13151c;
  --surface-2: #1b1e27;
  --surface-3: #252932;
  --surface-4: #323744;
  --border: #262a35;
  --border-strong: #363c4a;

  --text-primary: #f4f5f9;
  --text-secondary: #a8afc0;
  --text-muted: #8b93a6;          /* 5.1:1 на surface-2 */

  --accent: #8b7cff;              /* 5.09:1 на surface-2 */
  --accent-2: #5ec7ff;            /* второй тон градиента */
  --accent-soft: #1e1b3a;
  --accent-ink: #0a0b0f;          /* 6.02:1 на акценте */
  --accent-glow: rgba(139, 124, 255, .38);

  --danger: #ff7676;
  --danger-soft: #3a2027;
  --warn: #e0a33c;
  --warn-soft: #362a17;
  --success: #38d39a;
  --success-soft: #123028;

  --series-1: #8b7cff;
  --series-2: #d95926;
  --series-3: #199e70;
  --grid: #242833;

  --fs-display: 40px;
  --fs-h1: 23px;
  --fs-h2: 17px;
  --fs-body: 15px;
  --fs-sm: 13.5px;
  --fs-xs: 12.5px;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 22px;
  --sp-6: 30px;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-xs: 9px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 12px 36px rgba(0, 0, 0, .5);
  --shadow-accent: 0 8px 24px -6px var(--accent-glow);
  /* Тонкая светлая грань сверху — она и создаёт ощущение материала */
  --edge: inset 0 1px 0 rgba(255, 255, 255, .045);

  --tap: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 62px;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f2f2f4;
  --surface-1: #ffffff;
  --surface-2: #f7f7f5;
  --surface-3: #ecebe9;
  --surface-4: #dedcd8;
  --border: #e4e2de;
  --border-strong: #ccc9c3;

  --text-primary: #14161a;
  --text-secondary: #52514e;
  --text-muted: #6f6e69;          /* 4.8:1 на surface-2 */

  --accent: #5346c7;              /* 6.38:1 на surface-2 */
  --accent-2: #2a7fd6;
  --accent-soft: #eceafb;
  --accent-ink: #ffffff;          /* 6.84:1 на акценте */
  --accent-glow: rgba(83, 70, 199, .22);

  --danger: #c0392b;
  --danger-soft: #fbeae7;
  --warn: #8c5d00;
  --warn-soft: #fbf1dd;
  --success: #0d724f;
  --success-soft: #e2f3ec;

  --series-1: #5346c7;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --grid: #e4e2de;

  --shadow-1: 0 1px 2px rgba(20, 22, 26, .06);
  --shadow-2: 0 12px 32px rgba(20, 22, 26, .13);
  --shadow-accent: 0 8px 22px -8px var(--accent-glow);
  --edge: inset 0 1px 0 rgba(255, 255, 255, .8);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #f2f2f4;
    --surface-1: #ffffff;
    --surface-2: #f7f7f5;
    --surface-3: #ecebe9;
    --surface-4: #dedcd8;
    --border: #e4e2de;
    --border-strong: #ccc9c3;
    --text-primary: #14161a;
    --text-secondary: #52514e;
    --text-muted: #6f6e69;
    --accent: #5346c7;
    --accent-2: #2a7fd6;
    --accent-soft: #eceafb;
    --accent-ink: #ffffff;
    --accent-glow: rgba(83, 70, 199, .22);
    --danger: #c0392b;
    --danger-soft: #fbeae7;
    --warn: #8c5d00;
    --warn-soft: #fbf1dd;
    --success: #0d724f;
    --success-soft: #e2f3ec;
    --series-1: #5346c7;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --grid: #e4e2de;
    --shadow-1: 0 1px 2px rgba(20, 22, 26, .06);
    --shadow-2: 0 12px 32px rgba(20, 22, 26, .13);
    --shadow-accent: 0 8px 22px -8px var(--accent-glow);
    --edge: inset 0 1px 0 rgba(255, 255, 255, .8);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font: var(--fs-body)/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body { min-height: 100dvh; }

/* Мягкое свечение за верхом экрана — задаёт глубину и «дорогой» вид,
   но не мешает читать: оно ниже контента и почти прозрачно. */
body::before {
  content: '';
  position: fixed;
  top: -220px; left: 50%;
  width: 620px; height: 460px;
  transform: translateX(-50%);
  background: radial-gradient(50% 50% at 50% 50%, var(--accent-glow), transparent 72%);
  opacity: .5;
  pointer-events: none;
  z-index: 0;
}
#app, .tabbar { position: relative; z-index: 1; }

h1, h2, h3 { margin: 0; font-weight: 660; letter-spacing: -.02em; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-body); }
p { margin: 0 0 var(--sp-2); }

.muted { color: var(--text-secondary); font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.45; }
.center { text-align: center; }
.num, .stat-value, .hero, table.data td, .set-row .input, .rest-timer .t, .ring-value {
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* --- Каркас --- */

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: var(--sp-3) var(--sp-3) calc(var(--tabbar-h) + var(--sp-5) + var(--safe-bottom));
}
body.resting #app { padding-bottom: calc(var(--tabbar-h) + 78px + var(--safe-bottom)); }

.app-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: var(--sp-2) var(--sp-1) var(--sp-4);
}
.app-head h1 { flex: 1; min-width: 0; }
.app-head .date { color: var(--text-muted); font-size: var(--fs-xs); text-align: right; flex-shrink: 0; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-1), var(--edge);
}

/* Карточка главного действия: градиент и свечение выводят её из общего ряда */
.card-hero {
  position: relative;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
  background:
    radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 58%),
    var(--surface-1);
  box-shadow: var(--shadow-accent), var(--edge);
}
.card-hero::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(160deg, transparent 55%, color-mix(in srgb, var(--accent-2) 12%, transparent));
  pointer-events: none;
}

/* Медленный блик по карточке главного действия. Двигаем transform, а не
   background-position: последний вызывает перерисовку каждый кадр и на
   телефоне заметно ест батарею. Цикл длинный, амплитуда низкая — деталь
   должна ощущаться, а не мигать перед глазами. */
.card-hero::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: -45%;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .075), transparent);
  animation: sheen 7s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes sheen {
  0%, 58% { transform: translateX(0); }
  100% { transform: translateX(330%); }
}
.card-hero > * { position: relative; z-index: 1; }
.card-hero.tone-done {
  border-color: color-mix(in srgb, var(--success) 34%, var(--border));
  background:
    radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--success) 18%, transparent), transparent 58%),
    var(--surface-1);
  box-shadow: var(--shadow-1), var(--edge);
}
.card-hero.tone-done::after { background: none; }
.card-hero.tone-rest {
  background: var(--surface-1);
  border-color: var(--border);
  box-shadow: var(--shadow-1), var(--edge);
}
.card-hero.tone-rest::after { background: none; }

.card > h2:first-child { margin-bottom: var(--sp-3); }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-2); margin-bottom: var(--sp-3); min-height: 26px;
}
.card-head h2 { min-width: 0; }

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  font-weight: 640;
  margin: var(--sp-5) var(--sp-1) var(--sp-2);
}

.row { display: flex; align-items: center; }
.row.gap { gap: var(--sp-2); }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-2); }
.icon { flex-shrink: 0; }

/* --- Появление экрана: карточки всплывают каскадом --- */

@keyframes riseIn {
  from { opacity: 0; transform: translate(var(--enter-x, 0), 10px); }
  to { opacity: 1; transform: none; }
}
#app > * { animation: riseIn .34s cubic-bezier(.22, .8, .3, 1) backwards; }
#app > *:nth-child(1) { animation-delay: 0ms; }
#app > *:nth-child(2) { animation-delay: 40ms; }
#app > *:nth-child(3) { animation-delay: 80ms; }
#app > *:nth-child(4) { animation-delay: 120ms; }
#app > *:nth-child(5) { animation-delay: 150ms; }
#app > *:nth-child(6) { animation-delay: 175ms; }
#app > *:nth-child(n+7) { animation-delay: 200ms; }

/* Шаг мастера настройки: карточки внутри приезжают своей лесенкой */
.step-pane > * { animation: riseIn .32s cubic-bezier(.22, .8, .3, 1) backwards; }
.step-pane > *:nth-child(1) { animation-delay: 0ms; }
.step-pane > *:nth-child(2) { animation-delay: 60ms; }
.step-pane > *:nth-child(n+3) { animation-delay: 110ms; }

/* Строки списков подтягиваются следом за своей карточкой — короткая
   лесенка, не длиннее шести шагов, иначе нижние строки заметно опаздывают. */
@keyframes slideInRow {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: none; }
}
.list li { animation: slideInRow .3s ease backwards; }
.list li:nth-child(1) { animation-delay: 30ms; }
.list li:nth-child(2) { animation-delay: 65ms; }
.list li:nth-child(3) { animation-delay: 100ms; }
.list li:nth-child(4) { animation-delay: 130ms; }
.list li:nth-child(5) { animation-delay: 155ms; }
.list li:nth-child(n+6) { animation-delay: 175ms; }

/* Удаляемая строка сворачивается, а не исчезает рывком:
   так видно, что именно ушло. */
@keyframes collapseRow {
  to { opacity: 0; transform: translateX(24px); max-height: 0; padding-top: 0; padding-bottom: 0; }
}
.list li.removing {
  animation: collapseRow .26s cubic-bezier(.4, 0, .8, .4) forwards;
  max-height: 90px;
  overflow: hidden;
  pointer-events: none;
}

/* Блоки упражнений появляются той же лесенкой, что и карточки */
.ex-block { animation: riseIn .34s cubic-bezier(.22, .8, .3, 1) backwards; }
.ex-block:nth-of-type(1) { animation-delay: 20ms; }
.ex-block:nth-of-type(2) { animation-delay: 55ms; }
.ex-block:nth-of-type(3) { animation-delay: 90ms; }
.ex-block:nth-of-type(4) { animation-delay: 120ms; }
.ex-block:nth-of-type(n+5) { animation-delay: 145ms; }

/* Плитки показателей внутри карточки */
@keyframes popIn {
  from { opacity: 0; transform: scale(.94); }
  to { opacity: 1; transform: none; }
}
.stat { animation: popIn .32s cubic-bezier(.3, 1.2, .5, 1) backwards; }
.grid-3 > .stat:nth-child(1) { animation-delay: 60ms; }
.grid-3 > .stat:nth-child(2) { animation-delay: 105ms; }
.grid-3 > .stat:nth-child(3) { animation-delay: 150ms; }

/* Чипы вплывают по очереди */
.chip { animation: popIn .28s ease backwards; }
.row.wrap > .chip:nth-child(2) { animation-delay: 30ms; }
.row.wrap > .chip:nth-child(3) { animation-delay: 55ms; }
.row.wrap > .chip:nth-child(4) { animation-delay: 75ms; }
.row.wrap > .chip:nth-child(n+5) { animation-delay: 95ms; }

/* --- Плитки показателей --- */

.stat {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
  min-height: 78px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  border: 1px solid transparent;
  transition: border-color .2s ease;
}
.stat-value {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.12;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  margin-top: 3px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.stat-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; line-height: 1.3; }
.stat.good .stat-value { color: var(--success); }
.stat.bad .stat-value { color: var(--danger); }
.stat.warn .stat-value { color: var(--warn); }
.stat.good { border-color: color-mix(in srgb, var(--success) 26%, transparent); }

.hero {
  font-size: var(--fs-display);
  font-weight: 730;
  letter-spacing: -.045em;
  line-height: 1;
}
.hero-sub { color: var(--text-secondary); font-size: var(--fs-sm); margin-top: 4px; }

/* --- Кольцо прогресса --- */

.ring { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.ring svg { transform: rotate(-90deg); display: block; }
.ring-track { stroke: var(--surface-3); fill: none; }
.ring-bar {
  fill: none; stroke-linecap: round;
  stroke: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-glow));
  transition: stroke-dashoffset .9s cubic-bezier(.22, .8, .3, 1);
}
.ring-bar.over { stroke: var(--series-2); }
.ring-bar.tone-p { stroke: var(--series-1); }
.ring-bar.tone-f { stroke: var(--series-2); }
.ring-bar.tone-c { stroke: var(--series-3); }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; line-height: 1.1;
}
.ring-value { font-size: 25px; font-weight: 720; letter-spacing: -.035em; }
.ring-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

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

.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  min-height: var(--tap);
  padding: 11px var(--sp-4);
  font: inherit;
  font-weight: 570;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  transition: transform .1s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .42; cursor: default; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent-2) 55%, var(--accent)));
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 640;
  box-shadow: var(--shadow-accent);
}
.btn-primary:active:not(:disabled) { box-shadow: none; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-block { width: 100%; }
.btn-lg { min-height: 54px; font-size: 16px; border-radius: var(--radius); }

.icon-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--text-secondary);
  width: var(--tap); height: var(--tap); min-width: var(--tap);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-xs);
  transition: background .18s ease, color .18s ease;
  margin: -9px;
}
.icon-btn:active { background: var(--surface-3); }
.icon-btn.danger { color: var(--danger); }

/* --- Формы --- */

.field { display: block; margin-bottom: var(--sp-3); }
.field-label { display: block; font-size: var(--fs-sm); color: var(--text-secondary); margin-bottom: 6px; }
.field-hint { display: block; font-size: var(--fs-xs); color: var(--text-muted); margin-top: 5px; line-height: 1.4; }

.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  min-height: var(--tap);
  padding: 11px var(--sp-3);
  font: inherit;
  font-size: 16px;               /* < 16px заставляет iOS зумить при фокусе */
  transition: border-color .18s ease, box-shadow .18s ease;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.input { min-height: 80px; resize: vertical; }
select.input { appearance: none; background-image: none; padding-right: var(--sp-5); }
.select-wrap { position: relative; }
.select-wrap .chevron {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--text-muted); display: flex;
}
.select-wrap .chevron svg { transform: rotate(90deg); }

.segmented {
  display: flex; gap: 3px; background: var(--surface-2);
  padding: 3px; border-radius: var(--radius-sm); flex-wrap: wrap;
  border: 1px solid var(--border);
}
.seg {
  flex: 1; min-width: 62px; border: none; background: none; color: var(--text-secondary);
  min-height: 38px; padding: 8px 6px; border-radius: 9px;
  font: inherit; font-size: var(--fs-sm); cursor: pointer;
  transition: background .2s ease, color .2s ease;
}
.seg[aria-pressed='true'] {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent-2) 45%, var(--accent)));
  color: var(--accent-ink); font-weight: 640;
  box-shadow: 0 2px 10px -3px var(--accent-glow);
}

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-secondary);
  font-size: var(--fs-xs); line-height: 1.4;
}
.chip.on { background: var(--accent); color: var(--accent-ink); font-weight: 580; }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.success { background: var(--success-soft); color: var(--success); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
button.chip { border: none; font-family: inherit; cursor: pointer; min-height: 38px; padding: 8px 14px; transition: transform .1s ease; }
button.chip:active { transform: scale(.95); }

.bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent-2) 60%, var(--accent)));
  transition: width .7s cubic-bezier(.22, .8, .3, 1);
}
.bar-fill.over { background: var(--series-2); }
.bar-fill.tone-p { background: var(--series-1); }
.bar-fill.tone-f { background: var(--series-2); }
.bar-fill.tone-c { background: var(--series-3); }
.bar-lg { height: 11px; }

/* --- Списки --- */

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) 0; border-bottom: 1px solid var(--border);
  min-height: 54px;
}
.list li:first-child { padding-top: 0; }
.list li:last-child { border-bottom: none; padding-bottom: 0; }
.list .lead { flex: 1; min-width: 0; }
.list .lead b { display: block; font-weight: 570; }
.list .lead span { font-size: var(--fs-xs); color: var(--text-muted); display: block; margin-top: 1px; }
.list li.tappable { cursor: pointer; transition: opacity .15s ease; }
.list li.tappable:active { opacity: .55; }
.list .row-icon {
  width: 40px; height: 40px; flex-shrink: 0;
  border-radius: var(--radius-xs);
  background: var(--surface-2); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}

.empty {
  text-align: center; padding: var(--sp-5) var(--sp-3);
  color: var(--text-secondary);
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-3);
}
.empty .empty-icon {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  animation: float 3.4s ease-in-out infinite;
}
/* Медленное покачивание оживляет пустой экран, не отвлекая от текста */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
.empty p { margin: 0; font-size: var(--fs-sm); max-width: 34ch; }

/* --- Нижняя навигация --- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface-1) 86%, transparent);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + var(--safe-bottom));
}
.tab {
  flex: 1; background: none; border: none; cursor: pointer;
  color: var(--text-muted); font: inherit; font-size: 10.5px; font-weight: 540;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 5px 2px; min-height: 50px; border-radius: var(--radius-xs);
  transition: color .2s ease;
  position: relative;
}
.tab .ico { display: flex; transition: transform .25s cubic-bezier(.22,.8,.3,1); }
.tab[aria-current='page'] { color: var(--accent); }
.tab[aria-current='page'] .ico { transform: translateY(-1px) scale(1.08); }
/* Точка под активной вкладкой — вторая подсказка помимо цвета */
.tab[aria-current='page']::after {
  content: '';
  position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--accent);
}
.tab:active { opacity: .6; }

/* --- Модальные окна --- */

.overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.overlay.closing { opacity: 0; transition: opacity .15s ease; }
@keyframes fade { from { opacity: 0; } }

.sheet {
  width: 100%; max-width: 560px; max-height: 90dvh;
  background: var(--surface-1);
  border-radius: 24px 24px 0 0;
  border: 1px solid var(--border); border-bottom: none;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-2);
  animation: slide .26s cubic-bezier(.22, .9, .3, 1);
}
@keyframes slide { from { transform: translateY(40px); } }
.sheet-grip {
  width: 40px; height: 4px; border-radius: 99px;
  background: var(--surface-4); margin: 9px auto 0; flex-shrink: 0;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border);
}
.sheet-head h2 { min-width: 0; }
.sheet-body { padding: var(--sp-4) var(--sp-4) calc(var(--sp-5) + var(--safe-bottom)); overflow-y: auto; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px + var(--safe-bottom));
  transform: translate(-50%, 14px); z-index: 80;
  background: var(--surface-4); color: var(--text-primary);
  padding: 12px 18px; border-radius: 999px; font-size: var(--fs-sm);
  box-shadow: var(--shadow-2); opacity: 0; pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #06231a; font-weight: 560; }

/* --- Графики --- */

.chart-wrap { position: relative; width: 100%; }
.chart { width: 100%; display: block; height: 190px; touch-action: pan-y; }
.chart-empty, .spark-empty { padding: var(--sp-5); text-align: center; color: var(--text-muted); font-size: var(--fs-sm); }

.grid-line { stroke: var(--grid); stroke-width: 1; vector-effect: non-scaling-stroke; }
.axis-text { fill: var(--text-muted); font-size: 9px; }
.chart-line {
  fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.chart-line.dashed { stroke-dasharray: 5 4; }
.chart-dot { stroke: var(--surface-1); stroke-width: 2; }
.chart-area { opacity: .14; }
.chart-band { fill: var(--series-1); opacity: .12; }
.chart-cursor { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }

.slot-1 { stroke: var(--series-1); }
.slot-2 { stroke: var(--series-2); }
.slot-3 { stroke: var(--series-3); }
circle.slot-1, path.chart-area.slot-1 { fill: var(--series-1); }
circle.slot-2, path.chart-area.slot-2 { fill: var(--series-2); }
circle.slot-3, path.chart-area.slot-3 { fill: var(--series-3); }

.bar-mark { fill: var(--series-1); }
.bar-mark.tone-over { fill: var(--series-2); }
.bar-mark.tone-empty { fill: var(--surface-3); }
.target-line { stroke: var(--text-secondary); stroke-width: 1.5; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }

.chart-tip {
  position: absolute; top: 4px; pointer-events: none;
  background: var(--surface-4); border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs); padding: 8px 10px; font-size: var(--fs-xs); min-width: 112px;
  box-shadow: var(--shadow-2);
  opacity: 0; transform: translateY(-4px);
  transition: opacity .16s ease, transform .16s ease;
}
.chart-tip.show { opacity: 1; transform: none; }
.tip-head { color: var(--text-muted); margin-bottom: 4px; font-size: 11px; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-row b { margin-left: auto; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin-top: var(--sp-2); font-size: var(--fs-xs); color: var(--text-secondary); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 11px; height: 3px; border-radius: 2px; display: inline-block; }
.swatch.slot-1 { background: var(--series-1); }
.swatch.slot-2 { background: var(--series-2); }
.swatch.slot-3 { background: var(--series-3); }
.spark { width: 100%; height: 30px; }

/* --- Тренировка --- */

.session-head {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  margin: 0 calc(-1 * var(--sp-3)) var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  border-bottom: 1px solid var(--border);
}
.session-head .top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.session-head h1 { font-size: 19px; }
.session-meta { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }
.session-head .bar { margin-top: var(--sp-2); height: 4px; }

.ex-block {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--sp-4); margin-bottom: var(--sp-3); background: var(--surface-1);
  box-shadow: var(--shadow-1), var(--edge);
  transition: border-color .25s ease, opacity .25s ease, box-shadow .25s ease;
}
/* Завершённое упражнение отступает на второй план, но остаётся читаемым:
   гасим только рамку и фон, не текст — цифры подходов нужны для сверки. */
.ex-block.done {
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
  background: color-mix(in srgb, var(--success) 4%, var(--surface-1));
}
.ex-block.done .ex-head h3, .ex-block.done .ex-meta { opacity: .72; }
.ex-block.active {
  border-color: color-mix(in srgb, var(--accent) 65%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent), var(--shadow-accent);
}
.ex-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-2); margin-bottom: 3px; }
.ex-head h3 { font-size: 16px; }
.ex-meta { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--sp-3); line-height: 1.45; }

.set-row {
  display: grid; grid-template-columns: 22px 1fr 1fr 56px; gap: var(--sp-2);
  align-items: center; margin-bottom: var(--sp-2);
}
.set-row .idx { color: var(--text-muted); font-size: var(--fs-sm); text-align: center; }
.set-row .input { padding: 10px 6px; text-align: center; min-height: 46px; }
.set-row.done .input {
  background: transparent; border-color: transparent;
  color: var(--text-secondary);
}
.set-head { margin-bottom: 6px; }
.set-head span { font-size: 11px; color: var(--text-muted); text-align: center; }

.set-check {
  width: 100%; height: 46px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s ease, color .2s ease, transform .12s ease, box-shadow .2s ease;
}
.set-check:active { transform: scale(.9); }
.set-check[aria-pressed='true'] {
  background: var(--success); border-color: transparent; color: #06231a;
  box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--success) 60%, transparent);
  animation: pop .32s cubic-bezier(.3, 1.5, .5, 1);
}
@keyframes pop { 0% { transform: scale(.82); } 60% { transform: scale(1.07); } 100% { transform: scale(1); } }

.rest-timer {
  position: fixed; left: var(--sp-3); right: var(--sp-3);
  bottom: calc(var(--tabbar-h) + 10px + var(--safe-bottom));
  max-width: 536px; margin: 0 auto; z-index: 45;
  background: var(--surface-4); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 10px var(--sp-3) 10px var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-3);
  box-shadow: var(--shadow-2);
  animation: slide .22s cubic-bezier(.22,.8,.3,1);
  overflow: hidden;
}
.rest-timer .t { font-size: 22px; font-weight: 720; min-width: 60px; letter-spacing: -.03em; }
.rest-timer .label { font-size: var(--fs-xs); color: var(--text-secondary); }
.rest-timer .btn { min-height: 36px; padding: 6px 12px; font-size: var(--fs-xs); }
.rest-progress {
  position: absolute; left: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 1s linear;
}

/* --- Фото --- */

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); }
.photo-preview { width: 100%; max-height: 320px; object-fit: contain; border-radius: var(--radius-sm); background: var(--surface-2); }
.thumb { width: 40px; height: 52px; object-fit: cover; border-radius: var(--radius-xs); background: var(--surface-2); flex-shrink: 0; }

.spinner {
  width: 16px; height: 16px; border: 2px solid var(--surface-4);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.callout {
  background: var(--surface-2); border-left: 3px solid var(--accent);
  padding: 11px var(--sp-3); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: var(--fs-sm); color: var(--text-secondary); margin-bottom: var(--sp-3);
  line-height: 1.5;
}
.callout.warn { border-left-color: var(--warn); background: var(--warn-soft); color: var(--text-primary); }
.callout.danger { border-left-color: var(--danger); background: var(--danger-soft); color: var(--text-primary); }
.callout.success { border-left-color: var(--success); background: var(--success-soft); color: var(--text-primary); }

table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data th, table.data td { padding: 9px 6px; text-align: right; border-bottom: 1px solid var(--border); }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data th { color: var(--text-muted); font-weight: 500; font-size: var(--fs-xs); }
table.data tr:last-child td { border-bottom: none; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

input[type='range'] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 30px; background: transparent; cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: var(--surface-3); }
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface-1);
  box-shadow: 0 2px 10px -2px var(--accent-glow); margin-top: -9px;
}
input[type='range']::-moz-range-track { height: 6px; border-radius: 99px; background: var(--surface-3); }
input[type='range']::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface-1);
}

/* Движение — украшение, а не смысл: при системном запросе оно исчезает целиком,
   включая каскад появления и рост колец. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0ms !important;
    transition-duration: .01ms !important;
  }
  /* Бесконечные украшения выключаем совсем: с длительностью 0.01 мс они
     остались бы крутиться вхолостую и без толку греть процессор. */
  .card-hero::before, .empty .empty-icon { animation: none !important; }
  .card-hero::before { display: none; }
  body::before { display: none; }
}
