/* IRONly Mini App. Цвета — токены, тёмная тема по системе или по VK. */
:root {
  --bg: #ebedf0;
  --card: #ffffff;
  --text: #000000;
  /* Вторичный текст: контраст ≥ 4.5:1 на карточке, фоне и кнопках (WCAG AA). */
  --muted: #5f6873;
  --line: #dce1e6;
  --accent: #2688eb;
  --accent-text: #ffffff;
  --accent-soft: #e5f0fc;
  --positive: #4bb34b;
  --negative: #e64646;
  --chip: #f2f3f5;
  --chart: #2688eb;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --card: #19191a;
    --text: #e1e3e6;
    --muted: #8f9399;
    --line: #2c2d2e;
    --accent: #529ef4;
    --accent-soft: #1e2b3b;
    --chip: #2c2d2e;
    --chart: #4a8fe0;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --card: #19191a;
  --text: #e1e3e6;
  --muted: #8f9399;
  --line: #2c2d2e;
  --accent: #529ef4;
  --accent-soft: #1e2b3b;
  --chip: #2c2d2e;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Roboto", "Helvetica Neue", Arial, sans-serif;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 12px calc(24px + env(safe-area-inset-bottom));
}

h1 { font-size: 24px; margin: 4px 4px 12px; }
h2 { font-size: 17px; margin: 0 0 8px; }
p { margin: 0 0 8px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; padding: 40px 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  min-height: 40px;
}
.topbar .title { font-size: 20px; font-weight: 600; flex: 1; }

/* Кнопки */
button, .btn {
  font: inherit;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  background: var(--chip);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-positive { background: var(--positive); color: #fff; font-weight: 600; }
.btn-negative { color: var(--negative); }
.btn-link { background: none; color: var(--accent); padding: 8px 4px; }
.btn-block { display: block; width: 100%; margin-top: 8px; }
.btn-big { padding: 15px; font-size: 17px; }
/* Зона нажатия не меньше 44×44, даже если значок маленький. */
.icon-btn {
  background: none;
  padding: 6px 8px;
  font-size: 20px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
}
.btn-link.btn-negative { color: var(--negative); }

/* Пикеры */
.picker { margin: 12px 0 4px; }
.picker-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 52px; height: 52px; font-size: 24px; padding: 0; flex: none; }
.stepper .value {
  flex: 1;
  /* Без min-width: 0 поле ввода в flex не сжимается и выталкивает «+» за край. */
  min-width: 0;
  width: 100%;
  text-align: center;
  font: inherit;
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: none;
  border: 0;
  border-radius: 10px;
  padding: 6px 0;
}
.stepper .value:focus { outline: 2px solid var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 20px;
  font-size: 15px;
  background: var(--chip);
}
.chip.active { background: var(--accent); color: var(--accent-text); }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll .chip { flex: none; white-space: nowrap; }
.chips.scroll::-webkit-scrollbar { display: none; }

.inputs { display: flex; gap: 10px; margin-top: 8px; }
.inputs label { flex: 1; }
input[type="text"], input[type="number"], input[type="search"], select {
  width: 100%;
  font: inherit;
  font-size: 18px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
}

/* Списки */
.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list .tap { flex: 1; min-width: 0; background: none; text-align: left; padding: 0; }
.list li.current, .list li.current .tap { color: var(--accent); font-weight: 600; }
.list li.divider { padding: 14px 0 4px; border-bottom: 0; }

/* Плитки групп мышц на стартовом экране каталога */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.tile {
  background: var(--card);
  border-radius: 12px;
  padding: 12px 4px;
  text-align: center;
  box-shadow: var(--shadow);
  font-size: 14px;
}
.tile-icon { font-size: 26px; line-height: 1.2; margin-bottom: 2px; }

.sets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.set {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--chip);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}
.set.best { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.stats { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--card); border-radius: 12px; padding: 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 22px; }

.banner {
  background: var(--accent-soft);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.banner b { color: var(--accent); }

.badge { font-size: 12px; color: var(--muted); }
.fav { color: #ffa000; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 15px;
  z-index: 10;
}
.toast.error { background: var(--negative); }

/* Главная: переходы */
.nav-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 24px; margin-bottom: 10px; }
.nav-tile span { font-size: 15px; }

/* История */
.history-item { display: block; width: 100%; text-align: left; color: inherit; font: inherit; }
.list li.col { flex-direction: column; align-items: stretch; gap: 0; }

/* Прогресс: показатели */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.kpis .stat { display: flex; flex-direction: column; gap: 2px; }
.good { color: var(--positive); }
.bad { color: var(--negative); }

/* Графики: один цвет, тонкие марки, волосяная ось */
.chart { position: relative; margin-top: 6px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .mark { fill: var(--chart); transition: opacity 0.1s; }
.chart .mark.hover { opacity: 0.75; }
.chart .line { fill: none; stroke: var(--chart); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--chart); fill-opacity: 0.1; }
.chart .dot { fill: var(--chart); stroke: var(--card); stroke-width: 2; }
.chart .dot.hover { r: 6; }
.chart .axis { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .value { font-size: 12px; font-weight: 600; fill: var(--text); }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit:focus-visible { stroke: var(--chart); stroke-width: 1; }
.chart-tip {
  position: absolute;
  top: -6px;
  pointer-events: none;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 8px;
}
.chart-table { margin-top: 6px; }
.chart-table summary { font-size: 13px; color: var(--muted); cursor: pointer; padding: 4px 0; }
.chart-table table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.chart-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 4px 0; }
.chart-table td { padding: 5px 0; border-top: 1px solid var(--line); }
.chart-table td:last-child, .chart-table th:last-child { text-align: right; }

/* Горизонтальные полосы: длина — величина, значение у конца */
.bar-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.bar-row { display: grid; grid-template-columns: 30% 1fr auto; align-items: center; gap: 8px; font-size: 14px; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { display: block; height: 10px; }
.bar-fill { display: block; height: 10px; background: var(--chart); border-radius: 0 4px 4px 0; }
.bar-value { color: var(--muted); font-variant-numeric: tabular-nums; }

/* «Прошлый раз» в карточке упражнения — главная подсказка во время подхода */
.ref { font-size: 17px; margin: 2px 0 6px; }
.ref b { font-variant-numeric: tabular-nums; }

/* Главная: прошлая тренировка и подсказка группы */
.overview { margin: 0 0 6px; }
.btn-block.suggest { text-align: left; background: var(--accent-soft); margin: 4px 0 8px; }
