/* ─── Токены ──────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;

  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f2ee;
  --surface-3: #e9e9e4;

  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;

  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  /* Категориальные слоты — фиксированный порядок, проверен валидатором */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;

  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;

  --heat-0: #eceae4;
  --heat-1: #b7d3f6;
  --heat-2: #6da7ec;
  --heat-3: #2a78d6;
  --heat-4: #184f95;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 4px 16px rgba(11, 11, 11, 0.04);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --surface-3: #2c2c2a;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --good-text: #0ca30c;
    --heat-0: #232322;
    --heat-1: #184f95;
    --heat-2: #256abf;
    --heat-3: #3987e5;
    --heat-4: #86b6ef;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.25);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --surface-3: #2c2c2a;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --good-text: #0ca30c;
  --heat-0: #232322;
  --heat-1: #184f95;
  --heat-2: #256abf;
  --heat-3: #3987e5;
  --heat-4: #86b6ef;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.25);
}

/* ─── База ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }

/* Браузерное правило [hidden]{display:none} слабее любого селектора по классу.
   Из-за этого .chart-tip с display:flex не прятался, и под каждым графиком
   висела пустая рамка поверх подписи. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--page);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ─── Каркас ──────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 9px; padding: 0 10px 18px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(135deg, var(--series-1), var(--series-3));
}
.brand-name { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  border: none; background: none; width: 100%; text-align: left; cursor: pointer;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.is-active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.nav-icon { width: 17px; height: 17px; flex: none; opacity: 0.8; }
.nav-spacer { flex: 1; }

.main { padding: 28px 32px 64px; max-width: 1180px; width: 100%; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-title { font-size: 24px; letter-spacing: -0.02em; }
.page-sub { color: var(--text-2); margin-top: 3px; font-size: 13.5px; }

/* ─── Карточки и сетки ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 0;
  box-shadow: var(--shadow);
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-tight { display: flex; gap: 6px; align-items: center; }
.spacer { flex: 1; }
.section-title { font-size: 15px; margin-bottom: 2px; }
.section-sub { color: var(--text-2); font-size: 13px; margin-bottom: 12px; }

/* ─── Показатели ──────────────────────────────────────────────────────── */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-label { color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.stat-value { font-size: 27px; font-weight: 620; letter-spacing: -0.025em; line-height: 1.1; }
.stat-unit { font-size: 15px; font-weight: 500; color: var(--text-2); margin-left: 3px; }
.stat-note { color: var(--muted); font-size: 12px; }
.delta { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.delta.is-up { color: var(--good-text); }
.delta.is-down { color: var(--critical); }
.delta.is-flat { color: var(--muted); }

.hero-figure { font-size: 40px; font-weight: 650; letter-spacing: -0.03em; line-height: 1; }

/* ─── Графики ─────────────────────────────────────────────────────────── */
.chart-card { padding: 18px 18px 14px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.chart-title { font-size: 14.5px; }
.chart-sub { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.chart-body { min-height: 60px; }
.chart-plot { position: relative; width: 100%; }
.chart-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 34px 0; text-align: center; }
.chart-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }
.chart-note { color: var(--muted); font-size: 12px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

.grid-line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.axis-line { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.axis-label { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.axis-caption { fill: var(--muted); font-size: 11px; }
.series-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.series-area { opacity: 0.09; }
.series-dot { stroke: var(--surface); stroke-width: 2; }
.series-bar { transition: opacity 0.12s ease; }
.series-bar.is-active { opacity: 0.78; }
.series-end-label { fill: var(--text-2); font-size: 11.5px; font-weight: 600; }
.scatter-dot { stroke: var(--surface); stroke-width: 2; }
.fit-line { stroke-width: 2; stroke-dasharray: 6 5; opacity: 0.6; }
.cursor-line { stroke: var(--axis); stroke-width: 1; }
.cursor-dot { stroke: var(--surface); stroke-width: 2; }
.annotation-line { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.7; }
.target-line { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 5 4; }
.target-label { fill: var(--muted); font-size: 11px; }

.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12.5px; min-width: 122px;
  display: flex; flex-direction: column; gap: 3px;
}
.tip-title { font-weight: 600; font-size: 12px; color: var(--text-2); }
.tip-row { display: flex; align-items: center; gap: 6px; color: var(--text-2); white-space: nowrap; }
.tip-row i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.tip-row b { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; }

/* ─── Горизонтальные полосы ──────────────────────────────────────────── */
.row-chart { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.row-chart-item { display: grid; grid-template-columns: 96px 1fr 62px; gap: 10px; align-items: center; font-size: 13px; }
.row-chart-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-chart-track { background: var(--surface-2); border-radius: 4px; height: 9px; overflow: hidden; }
.row-chart-fill { display: block; height: 100%; border-radius: 4px; }
.row-chart-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); font-weight: 550; }

/* ─── Календарь активности ───────────────────────────────────────────── */
.heatmap-wrap { display: flex; flex-direction: column; gap: 9px; }
.heatmap { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 3px; }
.heatmap-week { display: flex; flex-direction: column; gap: 3px; }
.heatmap-cell { width: 12px; height: 12px; border-radius: 3px; background: var(--heat-0); flex: none; }
.heatmap-cell.is-empty { background: transparent; }
.heatmap-cell[data-level="1"] { background: var(--heat-1); }
.heatmap-cell[data-level="2"] { background: var(--heat-2); }
.heatmap-cell[data-level="3"] { background: var(--heat-3); }
.heatmap-cell[data-level="4"] { background: var(--heat-4); }
.heatmap-legend { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--muted); }

/* ─── Прогресс-полосы ────────────────────────────────────────────────── */
.macro { display: flex; flex-direction: column; gap: 5px; }
.macro-head { display: flex; justify-content: space-between; font-size: 12.5px; }
.macro-name { color: var(--text-2); font-weight: 500; }
.macro-value { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 550; }
.macro-track { height: 7px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.macro-fill { display: block; height: 100%; border-radius: 4px; transition: width 0.2s ease; }
.macro-over { color: var(--critical); }

/* ─── Формы ───────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  width: 100%;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--series-1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--series-1) 16%, transparent);
}
input[type="number"] { font-variant-numeric: tabular-nums; }
textarea { resize: vertical; min-height: 62px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  font-size: 13.5px; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--series-1); border-color: transparent; color: #fff; }
.btn-primary:hover { background: var(--series-1); opacity: 0.9; }
.btn-danger { color: var(--critical); }
.btn-danger:hover { background: color-mix(in srgb, var(--critical) 10%, transparent); }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-icon { padding: 5px 7px; color: var(--muted); }
.btn-icon:hover { color: var(--text); }
.link-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--text-2); font-size: 12.5px; font-weight: 550; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: var(--border);
}
.link-btn:hover { color: var(--text); }

.chip-group { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 2px; gap: 2px; flex-wrap: wrap; }
.chip {
  border: none; background: none; cursor: pointer;
  padding: 5px 11px; border-radius: 6px;
  font-size: 12.5px; font-weight: 550; color: var(--text-2);
}
.chip:hover { color: var(--text); }
.chip.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ─── Таблицы и списки ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; max-height: 340px; overflow-y: auto; margin-top: 6px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { color: var(--text-2); font-weight: 550; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
.data-table td { font-variant-numeric: tabular-nums; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; }

.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 550; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { color: var(--text-2); font-size: 12.5px; }
.list-value { font-variant-numeric: tabular-nums; font-weight: 600; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 11.5px; font-weight: 600;
}
.badge.is-pr { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good-text); }
.badge.is-warn { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--text); }

.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 28px 12px; }
.empty-cta { margin-top: 10px; }

/* ─── Выбор периода ──────────────────────────────────────────────────── */
.period-control { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.period-range { display: flex; align-items: center; gap: 8px; }
.period-range input { width: 148px; }
.period-dash { color: var(--muted); }

/* ─── Фотогалерея ────────────────────────────────────────────────────── */
.photo-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  max-height: 520px; overflow-y: auto; padding-right: 4px;
}
.photo-tile {
  margin: 0; cursor: pointer; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface-2);
  border: 1px solid var(--border); transition: transform 0.12s ease;
}
.photo-tile:hover { transform: translateY(-2px); }
.photo-img { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.photo-caption { display: flex; justify-content: space-between; gap: 6px; padding: 7px 9px; font-size: 12px; }
.photo-date { color: var(--text-2); }
.photo-weight { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
dialog.photo-modal { max-width: min(560px, calc(100vw - 32px)); }
.photo-full { display: block; width: 100%; border-radius: var(--radius-sm); }

/* ─── Неделя программы ───────────────────────────────────────────────── */
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.week-day {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: 9px 10px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid transparent;
  min-width: 0; text-align: left; font: inherit; color: inherit;
}
.week-day.is-busy { background: color-mix(in srgb, var(--series-1) 10%, var(--surface)); border-color: color-mix(in srgb, var(--series-1) 28%, transparent); }
.week-day.is-clickable { cursor: pointer; }
.week-day.is-clickable:hover { border-color: var(--series-1); }
.week-day:disabled { cursor: default; }
.week-day-name { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.week-day-title { font-size: 12.5px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.week-day-count { font-size: 11px; color: var(--muted); }

/* ─── Редактор программы ─────────────────────────────────────────────── */
.day-editor { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; }
.day-badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.plan-row { display: grid; grid-template-columns: 1fr 84px 96px 104px; gap: 8px; align-items: center; }
.plan-row-head { font-size: 11.5px; color: var(--muted); font-weight: 550; padding: 0 2px; }

/* ─── Тренировка: блоки упражнений ───────────────────────────────────── */
.ex-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.ex-block.is-open { border-color: color-mix(in srgb, var(--series-1) 40%, var(--border)); }
.ex-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 16px; background: none; border: none; cursor: pointer; text-align: left;
}
.ex-head:hover { background: var(--surface-2); }
.ex-arrow { color: var(--text-2); font-size: 16px; line-height: 1; transition: transform 0.15s ease; flex: none; width: 14px; text-align: center; }
.ex-arrow.is-open { transform: rotate(90deg); }
.ex-head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ex-name { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.ex-plan { font-size: 12.5px; color: var(--text-2); }
.ex-progress {
  flex: none; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums;
  color: var(--text-2); background: var(--surface-2);
  padding: 3px 10px; border-radius: 20px;
}
.ex-progress.is-done { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good-text); }
.ex-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }

.session-row { display: grid; grid-template-columns: 28px 1fr 1fr 52px auto; gap: 8px; align-items: center; }
.session-row-head { font-size: 11.5px; color: var(--muted); font-weight: 550; }
.session-index {
  font-size: 12px; font-weight: 650; color: var(--muted);
  text-align: center; font-variant-numeric: tabular-nums;
}
.session-e1rm { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }

.ex-history { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 2px; }
.ex-history-head { font-size: 12px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; }
.ex-history-scroll { max-height: 220px; overflow-y: auto; }
.ex-history-row {
  display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 12.5px;
}
.ex-history-row:last-child { border-bottom: none; }
.ex-history-date { color: var(--muted); white-space: nowrap; }
.ex-history-sets { color: var(--text); font-variant-numeric: tabular-nums; }
.ex-history-best { color: var(--text-2); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ─── Состояние синхронизации ────────────────────────────────────────── */
.sync-badge {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; margin-bottom: 4px;
  border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--text-2); font-size: 12px; text-align: left; cursor: pointer;
}
.sync-badge:hover { background: color-mix(in srgb, var(--warning) 18%, transparent); }
.sync-badge.is-offline {
  border-color: color-mix(in srgb, var(--critical) 40%, transparent);
  background: color-mix(in srgb, var(--critical) 12%, transparent);
}
.sync-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--warning); animation: sync-pulse 1.8s ease-in-out infinite;
}
.sync-badge.is-offline .sync-dot { background: var(--critical); }
.sync-text { line-height: 1.35; }
@keyframes sync-pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .sync-dot { animation: none; } }

/* ─── Вход ────────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px calc(16px + env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom));
  background: var(--page);
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 26px 24px;
}
.auth-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 22px; }
.auth-title { font-size: 20px; letter-spacing: -0.02em; margin-bottom: 4px; }
.auth-lead { color: var(--text-2); font-size: 13px; line-height: 1.5; margin-bottom: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-submit { width: 100%; justify-content: center; margin-top: 2px; }
.auth-switch { color: var(--text-2); font-size: 12.5px; text-align: center; }
.auth-error {
  color: var(--critical); font-size: 13px; line-height: 1.45;
  background: color-mix(in srgb, var(--critical) 12%, transparent);
  border-radius: var(--radius-sm); padding: 9px 11px;
}

.invite-code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 14px; letter-spacing: 0.06em;
  background: var(--surface-2); border-radius: 6px; padding: 3px 8px;
}
.invite-used { color: var(--muted); text-decoration: line-through; }

/* ─── План на сегодня ────────────────────────────────────────────────── */
.plan-card { border-left: 3px solid var(--series-1); }
.plan-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.plan-chip {
  padding: 3px 10px; border-radius: 20px; background: var(--surface-2);
  font-size: 12px; color: var(--text-2);
}

/* ─── Модальное окно ─────────────────────────────────────────────────── */
dialog.modal {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 0; max-width: min(620px, calc(100vw - 32px)); width: 100%;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.22);
}
dialog.modal::backdrop { background: rgba(0, 0, 0, 0.42); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-title { font-size: 15.5px; }
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; max-height: 68vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--page);
  padding: 9px 16px; border-radius: 20px; font-size: 13px; font-weight: 550;
  box-shadow: var(--shadow); z-index: 60;
  animation: toast-in 0.18s ease;
}
.toast.is-error { background: var(--critical); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ─── Строки подходов ────────────────────────────────────────────────── */
.set-row { display: grid; grid-template-columns: 1fr 84px 74px 66px 32px; gap: 8px; align-items: center; }
.set-row-head { font-size: 11.5px; color: var(--muted); font-weight: 550; padding: 0 2px; }
.set-hint { font-size: 11.5px; color: var(--muted); }
.exercise-group { color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 20;
    height: auto; flex-direction: row; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--border); align-items: center;
    /* Отступы под чёлку и «шторку» телефона */
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    -webkit-overflow-scrolling: touch;
  }
  .brand { padding: 0 12px 0 4px; }
  .nav-spacer { display: none; }
  .nav-link { width: auto; white-space: nowrap; }
  .main {
    padding: 20px 16px calc(56px + env(safe-area-inset-bottom));
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }
  .set-row { grid-template-columns: 1fr 1fr; }
  .plan-row { grid-template-columns: 1fr 1fr; }
  .period-control { align-items: flex-start; }
  .week-strip { grid-template-columns: repeat(4, 1fr); }
  .ex-history-row { grid-template-columns: 1fr auto; }
  .ex-history-date { grid-column: 1 / -1; }

  /* Safari на iPhone увеличивает страницу, когда фокус попадает в поле
     мельче 16px. Пальцем и так неудобно — тут крупнее и по размеру пальца. */
  input, select, textarea { font-size: 16px; padding: 10px 12px; }
  .btn { padding: 10px 16px; min-height: 42px; }
  .btn-sm { padding: 7px 12px; min-height: 36px; }
  .btn-icon { min-width: 38px; min-height: 38px; }
  .chip { padding: 8px 13px; }
  .ex-head { padding: 16px 14px; }
  .list-item { padding: 13px 0; }
}
