:root {
  --bg: #0a0c0f; --surface: #13161b; --surface-2: #1b1f26; --line: #262b34;
  --text: #f3f5f8; --muted: #8d96a5; --accent: #ff5a36; --accent-2: #ff8a3d; --good: #2fd38a; --warn: #ffc247;
  --radius: 18px; --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  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.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 21px; font-weight: 750; }
h3 { font-size: 17px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); }
#app { max-width: 640px; margin: 0 auto; padding: calc(16px + var(--safe-t)) 16px calc(var(--tab-h) + 24px + var(--safe-b)); }
.screen { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 12px; }
.section { margin-top: 28px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.tap { transition: transform .12s, background .12s; display: block; width: 100%; text-align: left; }
.card.tap:active { transform: scale(.985); background: var(--surface-2); }
.hero { position: relative; overflow: hidden; padding: 22px; border: 0;
  background: radial-gradient(120% 140% at 100% 0%, rgba(255,90,54,.55), rgba(255,90,54,0) 55%), linear-gradient(160deg, #1d2129, #121419); }
.hero .big { font-size: 34px; font-weight: 850; letter-spacing: -0.03em; line-height: 1.05; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 52px; padding: 0 22px; border-radius: 999px; font-weight: 750; font-size: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: 0; color: #fff; box-shadow: 0 8px 24px rgba(255,90,54,.35); }
.btn.block { width: 100%; }
.btn.sm { height: 38px; padding: 0 14px; font-size: 14px; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.chip { display: inline-flex; align-items: center; height: 34px; padding: 0 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--text); color: #0a0c0f; border-color: var(--text); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { height: 38px; border-radius: 9px; font-weight: 650; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--text); color: #0a0c0f; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat .v { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.pill { display: inline-block; font-size: 11px; font-weight: 750; padding: 3px 8px; border-radius: 999px; background: rgba(255,90,54,.16); color: var(--accent-2); letter-spacing: .02em; }
.pill.good { background: rgba(47,211,138,.15); color: var(--good); }
.pill.grey { background: var(--surface-2); color: var(--muted); }
/* exercise thumbnails (white studio background) */
.thumb { width: 64px; height: 64px; border-radius: 14px; background: #f4f4f4 center/cover no-repeat; flex: none; overflow: hidden; }
.thumb video, .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.demo { position: relative; background: #f3f3f3; border-radius: 22px; overflow: hidden; aspect-ratio: 4/3; }
.demo video, .demo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.demo .missing { position: absolute; inset: 0; display: grid; place-items: center; color: #777; font-weight: 600; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); width: 100%; text-align: left; }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 650; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { width: 100%; height: 46px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); padding: 0 16px; outline: none; }
.search:focus { border-color: #3a414d; }
input[type=number], input[type=time], input[type=text], input[type=date], select { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; height: 44px; padding: 0 12px; outline: none; min-width: 0; }
.switch { position: relative; width: 50px; height: 30px; border-radius: 999px; background: #3a404b; transition: background .15s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--good); }
.switch.on::after { transform: translateX(20px); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
/* tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b); display: flex; justify-content: center;
  background: rgba(10,12,15,.86); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px); border-top: 1px solid var(--line); }
.tabbar nav { display: grid; grid-template-columns: repeat(5, 1fr); width: 100%; max-width: 640px; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 650; color: var(--muted); }
.tabbar a.on { color: var(--text); }
.tabbar svg { width: 24px; height: 24px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; margin-bottom: 10px; height: 36px; }
/* program day grid */
.days { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.day { aspect-ratio: 1; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; font-weight: 750; font-size: 15px; border: 1px solid var(--line); position: relative; }
.day.done { background: rgba(47,211,138,.14); color: var(--good); border-color: rgba(47,211,138,.35); }
.day.next { background: var(--accent); color: #fff; border-color: var(--accent); }
.day.rest { color: var(--muted); font-size: 12px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; }
/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.cal .h { font-size: 11px; color: var(--muted); font-weight: 700; }
.cal .d { aspect-ratio: 1; display: grid; place-items: center; border-radius: 50%; font-size: 14px; font-weight: 600; }
.cal .d.has { background: var(--accent); color: #fff; }
.cal .d.today { outline: 2px solid var(--text); outline-offset: -2px; }
.cal .d.out { opacity: 0; }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b i { width: 100%; max-width: 28px; background: var(--accent); border-radius: 6px 6px 3px 3px; min-height: 3px; }
.bars .b span { font-size: 11px; color: var(--muted); font-weight: 600; }
/* modal sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; border-radius: 24px 24px 0 0; padding: 20px 16px calc(20px + var(--safe-b)); max-height: 88dvh; overflow: auto; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tab-h) + 20px + var(--safe-b)); background: var(--text); color: #0a0c0f; padding: 12px 18px; border-radius: 14px; font-weight: 650; z-index: 60; animation: fade .2s; max-width: calc(100% - 32px); }
/* ---------- player ---------- */
.player { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; padding: calc(10px + var(--safe-t)) 16px calc(16px + var(--safe-b)); }
.player .top { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.player .segs { display: flex; gap: 3px; margin: 6px 0 12px; }
.player .segs i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-2); }
.player .segs i.done { background: var(--accent); }
.player .segs i.cur { background: var(--text); }
.player .stage { flex: 1; display: flex; flex-direction: column; min-height: 0; max-width: 560px; width: 100%; margin: 0 auto; }
.player .demo { flex: 1; min-height: 180px; aspect-ratio: auto; }
.player .phase { font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.phase.work { color: var(--accent-2); } .phase.rest { color: var(--good); } .phase.warmup, .phase.cooldown { color: var(--warn); }
.player .name { font-size: 28px; font-weight: 850; letter-spacing: -0.02em; line-height: 1.1; margin-top: 4px; }
.player .timer { font-size: 84px; font-weight: 850; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; line-height: 1; }
.player .timer.small { font-size: 54px; }
.player .controls { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 12px; align-items: center; margin-top: 14px; }
.player .ctl { height: 60px; border-radius: 20px; background: var(--surface-2); display: grid; place-items: center; }
.player .ctl.main { background: var(--text); color: #0a0c0f; height: 68px; }
.player .ctl svg { width: 28px; height: 28px; }
.player .next { display: flex; align-items: center; gap: 12px; background: var(--surface); border-radius: 16px; padding: 10px; margin-top: 10px; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,12,15,.82); font-size: 160px; font-weight: 900; z-index: 3; border-radius: 22px; }
.ring { width: 100%; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.ring > i { display: block; height: 100%; background: var(--accent); transition: width .25s linear; }
.rest .ring > i { background: var(--good); }
.amrap-list { margin-top: 8px; }
.amrap-list .list-item { padding: 6px 0; }
.counter { display: flex; align-items: center; gap: 14px; }
.counter b { font-size: 34px; min-width: 44px; text-align: center; }
.rating { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rating button { padding: 16px 12px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); text-align: left; }
.rating button.on { border-color: var(--accent); background: rgba(255,90,54,.12); }
.chart { width: 100%; height: 180px; display: block; }
@media (min-width: 520px) { .days { grid-template-columns: repeat(10, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
