/* Colors come from Telegram themeParams when opened inside Telegram. */
:root {
  --bg: var(--tg-theme-secondary-bg-color, #f2f3f0);
  --surface: var(--tg-theme-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #141a16);
  --hint: var(--tg-theme-hint-color, #6b746e);
  --accent: var(--tg-theme-button-color, #1f7a4d);
  --on-accent: var(--tg-theme-button-text-color, #ffffff);
  --link: var(--tg-theme-link-color, #1f7a4d);
  --danger: var(--tg-theme-destructive-text-color, #c0392b);
  --line: color-mix(in srgb, var(--text) 10%, transparent);
  --soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --radius: 16px;
  --tabbar: 64px;
  color-scheme: light dark;
  color: var(--text);
  background: var(--bg);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
main { max-width: 480px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar) + 96px); }
body.no-tabs main { padding-bottom: 110px; }
h1 { font-size: 26px; line-height: 1.15; margin: 4px 0 6px; letter-spacing: -0.02em; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--hint); margin: 22px 4px 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--hint); font-size: 14px; }
.error { color: var(--danger); font-size: 14px; }
.stack { display: grid; gap: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* Top bar with back action */
.topbar { display: flex; align-items: center; gap: 8px; min-height: 40px; margin-bottom: 4px; }
.topbar .back { background: none; color: var(--link); padding: 8px 4px; font-weight: 500; }
.eyebrow { color: var(--hint); font-size: 14px; }

/* Cards and lists */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; }
.hero { background: var(--accent); color: var(--on-accent); border-radius: 20px; padding: 20px; }
.hero .muted { color: color-mix(in srgb, var(--on-accent) 75%, transparent); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 24px; }
.list { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.item { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--soft); color: var(--accent); font-size: 14px; font-weight: 600; flex: none; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--soft); color: var(--accent); font-size: 13px; font-weight: 500; }

/* Progress bar across exercises */
.progress { display: flex; gap: 4px; margin: 6px 0 14px; }
.progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--line); }
.progress span.on { background: var(--accent); }

/* Buttons */
button { font: inherit; border: 0; cursor: pointer; border-radius: 14px; padding: 15px 16px; font-weight: 600; background: var(--accent); color: var(--on-accent); width: 100%; }
button:disabled { opacity: 0.5; }
button.secondary { background: var(--soft); color: var(--accent); }
button.link { background: none; color: var(--link); padding: 10px; font-weight: 500; }
.hero button { background: var(--on-accent); color: var(--accent); margin-top: 14px; }
.actionbar { position: fixed; left: 0; right: 0; bottom: var(--tabbar); padding: 10px 16px; background: linear-gradient(transparent, var(--bg) 30%); }
body.no-tabs .actionbar { bottom: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.actionbar > * { max-width: 448px; margin: 0 auto; }

/* Forms */
label { display: grid; gap: 6px; font-size: 14px; color: var(--hint); }
input, select, textarea { font: inherit; color: var(--text); padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices label { display: block; position: relative; color: var(--text); }
.choices input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.choices span { display: block; padding: 10px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 15px; }
.choices input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.choices.big { display: grid; gap: 10px; }
.choices.big span { padding: 16px 18px; border-radius: 14px; font-size: 16px; font-weight: 500; }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--text); }
label.check input { width: 22px; height: 22px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
button.chip { width: auto; background: var(--surface); color: var(--text); border: 1px solid var(--line); padding: 10px 14px; border-radius: 999px; font-weight: 500; }
button.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.set form label { min-width: 0; }

/* Set logging */
.set { display: flex; align-items: center; gap: 12px; }
.set.done { opacity: 0.75; }
.set.current { outline: 2px solid var(--accent); }
.set form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; flex: 1; }
.set form.solo { grid-template-columns: 1fr auto; }
.set form button { width: auto; padding: 12px 16px; }

/* Video */
details.video { margin-top: 10px; }
details.video summary { list-style: none; cursor: pointer; color: var(--link); font-weight: 500; font-size: 15px; }
details.video summary::-webkit-details-marker { display: none; }
details.video summary::before { content: "▶ "; font-size: 12px; }
details.video[open] summary::before { content: "▼ "; }
details.video video { display: block; width: 100%; min-height: 200px; max-height: 42vh; object-fit: contain; margin-top: 10px; border-radius: 12px; background: #000; }

/* Bottom tab bar */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--surface); border-top: 1px solid var(--line); z-index: 5; }
body.no-tabs .tabs { display: none; }
.tabs button { flex: 1; background: none; color: var(--hint); border-radius: 0; padding: 8px 0; display: grid; justify-items: center; gap: 2px; font-size: 12px; font-weight: 500; }
.tabs button.on { color: var(--accent); }
.tabs svg { width: 24px; height: 24px; }
