:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #111214);
  --hint: var(--tg-theme-hint-color, #8a8d93);
  --link: var(--tg-theme-link-color, #2a7ae2);
  --btn: var(--tg-theme-button-color, #2a7ae2);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --sec: var(--tg-theme-secondary-bg-color, #f0f1f4);
  --card: var(--tg-theme-section-bg-color, var(--bg));
  --sep: var(--tg-theme-section-separator-color, rgba(128,128,128,.22));
  --danger: var(--tg-theme-destructive-text-color, #e5484d);
  --ok: #2fb35a;
  --ok-soft: rgba(47,179,90,.14);
  --accent-soft: color-mix(in srgb, var(--btn) 14%, transparent);
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tg]) { --bg:#17181b; --text:#eceef2; --sec:#0f1012; --card:#1f2125; --hint:#8f939b; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--sec); color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
body { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input { font: inherit; color: inherit; }
main { max-width: 560px; margin: 0 auto; padding: 12px 12px 0; }
.loading, .err { padding: 40px 16px; text-align: center; color: var(--hint); }

.h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.h2 { font-size: 18px; font-weight: 650; }
.hint { color: var(--hint); font-size: 14px; }
.sect { margin: 22px 4px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--hint); }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 4px 12px; }

.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.btn { background: var(--btn); color: var(--btn-text); border-radius: 12px; padding: 12px 16px; font-weight: 600; min-height: 46px; }
.btn.small { padding: 8px 14px; min-height: 38px; font-size: 15px; }
.btn.ghost { background: var(--accent-soft); color: var(--btn); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; }
.link { color: var(--link); padding: 8px 4px; }
.link.danger { color: var(--danger); }
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--btn); vertical-align: middle; margin-left: 6px; }

/* home */
.wk { display: grid; gap: 10px; }
.wk .card.rec { box-shadow: inset 0 0 0 2px var(--btn); }
.wk-names { color: var(--hint); font-size: 14px; margin: 6px 0 12px; }
.wk-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cont { background: var(--btn); color: var(--btn-text); }
.cont .hint { color: inherit; opacity: .8; }
.hist { background: var(--card); border-radius: var(--r); overflow: hidden; }
.hist button { display: flex; width: 100%; text-align: left; justify-content: space-between; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--sep); }
.hist button:last-child { border-bottom: 0; }

/* workout list */
.row { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: var(--r); padding: 10px 8px 10px 12px; margin-bottom: 8px; min-height: 58px; width: 100%; text-align: left; }
.num { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; background: var(--sec); color: var(--hint); }
.row.done .num, .card.done .num { background: var(--ok); color: #fff; }
.row.skip { opacity: .5; }
.row.skip .nm { text-decoration: line-through; }
.nm { flex: 1; min-width: 0; font-weight: 600; }
.nm .sub { font-weight: 400; font-size: 14px; color: var(--hint); margin-top: 1px; }
.st { font-size: 14px; color: var(--hint); font-variant-numeric: tabular-nums; }
.ord { display: flex; gap: 2px; }
.ord button { width: 36px; height: 40px; border-radius: 10px; background: var(--sec); color: var(--hint); font-size: 17px; }
.ord button:disabled { opacity: .3; }

.card.open { padding: 14px 12px; box-shadow: inset 0 0 0 2px var(--accent-soft); }
.card-h { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 2px; }
.chip { padding: 7px 12px; border-radius: 99px; background: var(--sec); font-size: 14px; }
.chip.on { background: var(--btn); color: var(--btn-text); }
.meta { margin-top: 10px; font-size: 15px; }
.prev, .warm, .note { font-size: 14px; color: var(--hint); margin-top: 6px; }
.prev b { color: var(--text); font-weight: 600; }

.sets { margin: 14px 0 6px; display: grid; gap: 8px; }
.set { display: flex; align-items: center; gap: 4px; padding: 5px; border-radius: 12px; background: var(--sec); }
.set .sn { width: 18px; text-align: center; color: var(--hint); font-size: 13px; font-weight: 700; flex: none; }
.set.ok { background: var(--ok-soft); }
.stp { display: flex; align-items: center; flex: 1; min-width: 0; }
.stp button { width: 34px; height: 44px; border-radius: 10px; background: var(--card); font-size: 20px; flex: none; }
.stp input { width: 100%; min-width: 34px; height: 44px; border: 0; background: transparent; text-align: center; font-size: 19px; font-weight: 650; font-variant-numeric: tabular-nums; padding: 0; outline: none; }
.set:not(.ok) .stp input { color: var(--hint); }
.stp .u { font-size: 12px; color: var(--hint); margin: 0 2px 0 -2px; flex: none; }
.chk { width: 46px; height: 44px; border-radius: 10px; flex: none; font-size: 20px; font-weight: 700; background: var(--card); color: var(--hint); }
.set.ok .chk { background: var(--ok); color: #fff; }
.play { width: 44px; height: 44px; border-radius: 10px; flex: none; background: var(--btn); color: var(--btn-text); font-size: 16px; }
.set-tools { display: flex; gap: 14px; }
.set-tools button { color: var(--link); font-size: 14px; padding: 6px 2px; }

.rir { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-size: 14px; color: var(--hint); }
.rir .chip { padding: 5px 10px; }
.decision { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); font-size: 15px; }
.decision.up { background: var(--ok-soft); }

.tech-t { margin-top: 10px; color: var(--link); font-size: 15px; padding: 6px 0; }
.tech { font-size: 14.5px; margin-top: 4px; }
.tech ol { margin: 6px 0; padding-left: 20px; }
.tech li { margin-bottom: 4px; }
.tech .dont { color: var(--danger); margin-top: 6px; }
.tech .tip { color: var(--hint); margin-top: 6px; }

.actions { display: flex; gap: 8px; margin-top: 14px; }
.actions .btn { flex: 1; }
.actions .ghost { flex: none; }

.pool ul { margin: 8px 0 0; padding-left: 18px; font-size: 14.5px; }
.pool li { margin-bottom: 4px; }
.foot { text-align: center; margin: 18px 0; }

/* results */
.res { padding: 10px 0; border-bottom: 1px solid var(--sep); }
.res:last-child { border-bottom: 0; }
.res .r2 { display: flex; justify-content: space-between; gap: 10px; font-size: 14.5px; color: var(--hint); margin-top: 2px; }
.res .nx { color: var(--text); font-weight: 600; white-space: nowrap; }
.res .nx.up { color: var(--ok); }
.res .nx.down { color: var(--danger); }

/* timer bar */
#timer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--card);
  box-shadow: 0 -6px 24px rgba(0,0,0,.12); }
#timer .in { max-width: 560px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
#timer .tt { flex: 1; min-width: 0; }
#timer .big { font-size: 30px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; }
#timer .lbl { font-size: 13px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#timer .bar { height: 4px; border-radius: 2px; background: var(--sec); margin-top: 6px; overflow: hidden; }
#timer .bar i { display: block; height: 100%; background: var(--btn); transition: width .25s linear; }
#timer button.tb { height: 44px; min-width: 50px; border-radius: 12px; background: var(--sec); font-weight: 600; font-size: 15px; }
#timer.end { background: var(--ok); color: #fff; }
#timer.end .lbl { color: rgba(255,255,255,.85); }
#timer.end button.tb { background: rgba(255,255,255,.22); }
#timer.work .bar i { background: var(--ok); }

#net { position: sticky; top: 0; z-index: 11; background: #f2a33a; color: #1b1300; text-align: center; font-size: 13px; padding: 6px; }

.set.head { background: none; padding: 0 5px; margin-bottom: -4px; }
.set.head .hc { flex: 1; text-align: center; font-size: 12px; color: var(--hint); }
.set.head .cc { width: 46px; flex: none; }
.set.head .pc { width: 44px; flex: none; }
.actions .btn { white-space: nowrap; padding-left: 12px; padding-right: 12px; }

/* картинка упражнения: ~1/4–1/5 экрана, по тапу — на весь экран */
.pic { display: block; width: 100%; margin-top: 10px; border-radius: 12px; overflow: hidden; background: #f5f6f8; }
.pic img { display: block; width: 100%; height: 22vh; min-height: 130px; max-height: 210px; object-fit: contain; }
#zoom { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.88); display: grid; place-items: center; padding: 12px; }
#zoom img { width: 100%; max-width: 720px; border-radius: 12px; background: #f5f6f8; }

/* этапы дня */
.stages { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.stg { background: var(--card); border-radius: 12px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; gap: 1px; min-height: 52px; }
.stg b { font-size: 15px; font-variant-numeric: tabular-nums; }
.stg span { font-size: 12px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stg.past { opacity: .55; }
.stg.past b::before { content: "✓ "; color: var(--ok); }
.stg.cur { background: var(--btn); color: var(--btn-text); }
.stg.cur span { color: inherit; opacity: .85; }
.plan-hint { font-size: 14px; color: var(--hint); margin: 0 4px 10px; }
.plan-hint b { color: var(--text); font-weight: 600; }
.stage-card .txt { margin-top: 8px; font-size: 15px; }
.stage-sect { display: flex; justify-content: space-between; align-items: center; text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 600; color: var(--text); margin-top: 16px; margin-bottom: 2px; }
.stage-sect .link { font-weight: 400; font-size: 14px; }
.stage-note { font-size: 14px; color: var(--hint); margin: 0 4px 10px; }
.tips { font-size: 14.5px; display: grid; gap: 8px; }
