:root {
  --bg: #14161a;
  --card: #1c1f25;
  --card2: #23272f;
  --line: #2c313a;
  --text: #e8ebf0;
  --muted: #8d96a5;
  --accent: #4da3ff;
  --good: #5ed17a;
  --warn: #ffb84d;
  --bad: #ff7a7a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: 84px;
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 16px 0 4px; }
h2 { font-size: 17px; margin: 22px 0 8px; color: var(--muted); font-weight: 600; }
h3 { font-size: 16px; margin: 12px 0 6px; }
h3.sub { margin-top: 18px; color: var(--muted); }
p { margin: 6px 0; }
main { padding: 0 14px; max-width: 780px; margin: 0 auto; }
ul { margin: 6px 0; padding-left: 20px; }
li { margin: 3px 0; }

.top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; color: var(--text); font-size: 17px; }
.who { color: var(--muted); font-size: 14px; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: flex;
  background: var(--card); border-top: 1px solid var(--line); z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; text-align: center; padding: 8px 2px 10px; color: var(--muted);
  font-size: 11px; display: flex; flex-direction: column; gap: 2px;
}
.tabs a span { font-size: 19px; }
.tabs a.on { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.latin { font-style: italic; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--good); }
.down { color: var(--bad); }
.live { color: var(--good); }

.card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; margin: 10px 0; color: var(--text);
}
.card + .card { margin-top: 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.active-card { border-color: var(--good); background: linear-gradient(180deg, #1c2a20, var(--card)); }
.spacer { height: 40px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prog-card { position: relative; }
.prog-card button {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--c);
  border-radius: 12px; padding: 14px 12px; color: var(--text); text-align: left;
  display: flex; flex-direction: column; gap: 3px; font-size: 16px;
}
.prog-card button b { font-size: 17px; }
.prog-card .prog-info { position: absolute; right: 10px; top: 12px; font-size: 12px; color: var(--muted); }

button, input, select, textarea {
  font: inherit; color: var(--text);
}
button { cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--card2); padding: 10px 14px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #07121f; font-weight: 600; }
button.big { width: 100%; padding: 14px; font-size: 17px; margin-top: 8px; }
button.ghost { background: transparent; }
button.danger { background: transparent; border-color: #5a2a2a; color: var(--bad); }
button.x { background: transparent; border: none; color: var(--muted); padding: 6px 8px; font-size: 15px; }
button.link-btn { background: none; border: none; color: var(--muted); padding: 4px 0; font-size: 13px; text-decoration: underline; }

label { display: block; margin: 8px 0; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%; margin-top: 4px; padding: 11px 12px; background: var(--card2);
  border: 1px solid var(--line); border-radius: 10px; font-size: 16px;
}
select[multiple] { padding: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline select { flex: 1; margin: 0; }

.alert { background: #3a2226; border: 1px solid #5a2a2a; color: #ffbcbc; padding: 10px 12px; border-radius: 10px; margin: 10px 0; }
.alert.ok { background: #1f3326; border-color: #2e5a3a; color: #b8f0c6; }
.hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.note-line { font-size: 13.5px; color: #cfd6e0; margin-top: 6px; }

.login-box { max-width: 380px; margin: 12vh auto; padding: 0 4px; }
.login-box h1 { font-size: 28px; }

/* тренировка */
.wk-head { border-left: 3px solid var(--c); padding-left: 10px; margin: 14px 0 6px; }
.wk-head h1 { margin: 0; }
.ex { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 10px 0; scroll-margin-top: 60px; }
.ex-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ex-name { font-size: 17px; font-weight: 600; color: var(--text); }
.chart-link { font-size: 18px; }

table.sets { width: 100%; border-collapse: collapse; margin: 8px 0; }
table.sets td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
table.sets tr:last-child td { border-bottom: none; }
table.sets .idx { color: var(--muted); width: 22px; font-variant-numeric: tabular-nums; }
table.sets .val b { font-size: 17px; }
table.sets .e1rm { width: 58px; text-align: right; font-size: 12.5px; }
table.sets .act { width: 34px; text-align: right; }
table.sets tr.warmup .val b { font-weight: 400; color: var(--muted); }
.tag { font-size: 11px; background: var(--card2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--muted); }
.pr { font-size: 11px; color: var(--warn); }

.add-set { display: grid; grid-template-columns: 1fr 1fr 60px; gap: 8px; align-items: end; margin-top: 6px; }
.add-set label.f { margin: 0; }
.add-set .chk { grid-column: 1 / 2; display: flex; align-items: center; gap: 6px; margin: 0; }
.add-set .chk input { width: auto; margin: 0; }
.add-set button { grid-column: 2 / 4; }

.prev { margin-top: 10px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.chip {
  display: inline-block; background: var(--card2); border: 1px solid var(--line);
  border-radius: 8px; padding: 2px 7px; margin: 2px 3px 2px 0; font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.chip.warm { opacity: .55; }
.chip.alt { border-color: #3b3350; background: #262233; }
.chip.link { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 2px; }

.setup { margin: 8px 0; background: var(--card2); border-radius: 10px; padding: 8px 10px; }
.setup summary { cursor: pointer; font-size: 14px; }
.setup-preview { color: var(--good); font-size: 13px; }
.setup-form label { margin: 6px 0; }
.setup-view { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; font-size: 14px; }
.finish { border-color: #3a4550; }
.rm-ex { margin-top: 6px; }

/* статистика */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.tile b { display: block; font-size: 20px; }
.tile span { font-size: 11.5px; color: var(--muted); }

table.vol { width: 100%; border-collapse: collapse; }
table.vol td { padding: 5px 4px; font-size: 14px; }
table.vol td:first-child { width: 34%; }
table.vol td.num { width: 44px; }
.bar-cell { padding-right: 8px !important; }
.bar { height: 9px; border-radius: 5px; background: var(--c); width: var(--w); max-width: 100%; min-width: 3px; }

table.progress { width: 100%; border-collapse: collapse; }
table.progress td, table.progress th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
table.progress th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.progress td.num { text-align: right; }

.chart-wrap { width: 100%; overflow-x: auto; }
.chart { width: 100%; height: 240px; display: block; }
.chart .grid { stroke: #2c313a; stroke-width: 1; }
.chart .axis { fill: #8d96a5; font-size: 11px; }
.legend-row { display: flex; gap: 12px; margin-top: 4px; }
.legend { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.switch { display: flex; gap: 6px; margin: 8px 0; }
.switch a, .switch span {
  padding: 7px 12px; border-radius: 20px; background: var(--card); border: 1px solid var(--line);
  color: var(--muted); font-size: 13px;
}
.switch .on { background: var(--accent); border-color: var(--accent); color: #07121f; }
.switch.small a, .switch.small span { padding: 5px 10px; font-size: 12.5px; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.filters input { grid-column: 1 / 3; margin: 0; }
.filters select { margin: 0; }
.filters button { grid-column: 1 / 3; }

.prog-list { margin: 6px 0; padding-left: 20px; font-size: 14px; }
.prog-item .item-actions { display: flex; gap: 2px; }
.foot-links { display: flex; gap: 16px; justify-content: center; margin: 24px 0 10px; font-size: 14px; }
.ex-card b { font-size: 15.5px; }
.muscle-card .small { margin-top: 4px; }
ul.bad li::marker { color: var(--bad); }

/* фото упражнений */
.ex-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.ex-photos figure { margin: 0; }
.ex-photos img { width: 100%; border-radius: 10px; display: block; background: #000; }
.ex-photos figcaption { font-size: 11.5px; color: var(--muted); text-align: center; margin-top: 3px; }
.ex-card.with-thumb { display: flex; gap: 10px; align-items: flex-start; }
.ex-card .ex-card-body { flex: 1; min-width: 0; }
.ex-thumb { width: 76px; height: 56px; object-fit: cover; border-radius: 8px; flex: 0 0 76px; background: #000; }
.ex-thumb.placeholder { display: flex; align-items: center; justify-content: center; background: var(--card2); font-size: 22px; }
.ex-head-thumb { flex: 0 0 52px; }
.ex-head-thumb img { width: 52px; height: 40px; object-fit: cover; border-radius: 7px; display: block; }
.ex-head-text { flex: 1; min-width: 0; }

/* атлас: схема тела */
.body-wrap { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.body-views { display: flex; gap: 6px; justify-content: center; }
.body-views figure { margin: 0; flex: 1; max-width: 220px; text-align: center; }
.body-views figcaption { font-size: 12px; color: var(--muted); margin-top: 2px; }
svg.body { width: 100%; height: auto; display: block; touch-action: manipulation; }
.body-outline { fill: #1b1f26; stroke: #39414d; stroke-width: 1.5; }
svg.body .m { stroke: #14161a; stroke-width: 0.8; cursor: pointer; transition: fill .12s, stroke .12s; }
svg.body .m:hover, svg.body .m:focus, svg.body .m.sel {
  fill: var(--accent) !important; stroke: #cfe6ff; stroke-width: 1.2; outline: none;
}
.body-thumb { display: block; }
.body-thumb .m.hl { fill: var(--accent); stroke: #cfe6ff; stroke-width: 1; }
.body-thumb .view-label { fill: #8d96a5; font-size: 18px; }
.muscle-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.muscle-head h1 { margin-top: 12px; }
.thumb-box { flex: 0 0 96px; }
.thumb-box svg { width: 96px; height: auto; }

#muscle-panel { min-height: 96px; }
#muscle-panel .panel-hint { color: var(--muted); font-size: 14px; }
#muscle-panel.has-sel .panel-hint { display: none; }
#muscle-panel b { font-size: 16px; }
.mp-link { display: inline-block; margin-top: 6px; }
.heat-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; font-size: 11.5px; color: var(--muted); }
.heat-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 4px; }

@media (min-width: 640px) {
  .body-wrap { flex-direction: row; align-items: flex-start; }
  .body-views { flex: 0 0 440px; }
  #muscle-panel { flex: 1; margin: 0; position: sticky; top: 60px; }
}

/* таймер отдыха */
#rest-bar[hidden] { display: none; }
#rest-bar {
  position: fixed; left: 8px; right: 8px; bottom: 68px; z-index: 40;
  background: var(--card2); border: 1px solid var(--accent); border-radius: 12px;
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
#rest-bar .rest-info { flex: 1; text-align: center; display: flex; flex-direction: column; }
#rest-bar #rest-label { font-size: 11px; color: var(--muted); }
#rest-bar #rest-time { font-size: 22px; font-variant-numeric: tabular-nums; }
#rest-bar button { padding: 8px 10px; }
#rest-bar.done { border-color: var(--good); }
#rest-bar.done #rest-time { color: var(--good); }
