:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --surface: rgba(255,255,255,.86);
  --surface-solid: #fff;
  --surface-2: #e9edf6;
  --text: #141821;
  --muted: #687083;
  --line: rgba(20,24,33,.10);
  --accent: #ff5e2f;
  --accent-2: #6c63ff;
  --accent-soft: rgba(255,94,47,.14);
  --success: #18a66a;
  --danger: #d84646;
  --shadow: 0 18px 50px rgba(35,38,54,.12);
  --radius: 26px;
  --header-h: 64px;
  --nav-h: 72px;
}

[data-theme="dark"] {
  --bg: #0c0f15;
  --surface: rgba(25,29,39,.88);
  --surface-solid: #181c26;
  --surface-2: #232936;
  --text: #f6f7fb;
  --muted: #a2aabc;
  --line: rgba(255,255,255,.10);
  --accent-soft: rgba(255,94,47,.18);
  --shadow: 0 18px 50px rgba(0,0,0,.28);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0f15; --surface: rgba(25,29,39,.88); --surface-solid: #181c26;
    --surface-2: #232936; --text: #f6f7fb; --muted: #a2aabc;
    --line: rgba(255,255,255,.10); --accent-soft: rgba(255,94,47,.18);
    --shadow: 0 18px 50px rgba(0,0,0,.28);
  }
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body {
  margin: 0; min-width: 280px; min-height: 100dvh; overflow-x: hidden;
  background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; transition: background .25s, color .25s;
}
.app-splash { position:fixed; inset:0; z-index:200; padding:env(safe-area-inset-top) 24px env(safe-area-inset-bottom); display:grid; place-content:center; justify-items:center; gap:10px; background:radial-gradient(circle at 50% 38%,#252b3a 0,#10131a 48%,#090b10 100%); color:white; text-align:center; animation:splash-failsafe .38s 3s ease forwards; }
.app-splash.leaving { animation:splash-out .42s cubic-bezier(.4,0,1,1) forwards; }
.app-splash strong { font-size:34px; letter-spacing:-.045em; animation:splash-copy .7s .2s cubic-bezier(.2,.8,.2,1) both; }
.app-splash small { color:rgba(255,255,255,.62); font-size:13px; letter-spacing:.04em; animation:splash-copy .7s .32s cubic-bezier(.2,.8,.2,1) both; }
.splash-logo { position:relative; width:104px; height:104px; margin-bottom:10px; display:grid; place-items:center; overflow:hidden; border-radius:31px; background:linear-gradient(145deg,#ff825d,#ff4e25); color:white; font-size:46px; font-weight:900; box-shadow:0 24px 70px rgba(255,78,37,.38); animation:splash-logo-in .8s cubic-bezier(.18,.9,.2,1.2) both,splash-logo-pulse 1.15s .85s ease-in-out infinite; }
.splash-logo i { position:absolute; left:15px; right:15px; bottom:22px; height:3px; border-radius:3px; background:white; transform-origin:left center; animation:splash-line 1s .5s cubic-bezier(.2,.8,.2,1) both; }
@keyframes splash-logo-in { from { opacity:0; transform:scale(.55) rotate(-12deg); } }
@keyframes splash-logo-pulse { 50% { transform:scale(1.045); box-shadow:0 28px 82px rgba(255,78,37,.5); } }
@keyframes splash-line { from { transform:scaleX(0); } }
@keyframes splash-copy { from { opacity:0; transform:translateY(9px); } }
@keyframes splash-out { to { opacity:0; visibility:hidden; transform:scale(1.025); } }
@keyframes splash-failsafe { to { opacity:0; visibility:hidden; pointer-events:none; } }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, white); outline-offset: 3px; }
.skip-link { position: fixed; left: 16px; top: -60px; z-index: 100; padding: 12px; background: var(--surface-solid); border-radius: 12px; }
.skip-link:focus { top: 16px; }
.hidden { display: none !important; }
.ambient { position: fixed; border-radius: 50%; filter: blur(80px); opacity: .16; pointer-events: none; animation: ambient-drift 10s ease-in-out infinite alternate; }
.ambient-one { width: 260px; height: 260px; background: var(--accent); top: -100px; right: -120px; }
.ambient-two { width: 220px; height: 220px; background: var(--accent-2); bottom: 15%; left: -160px; animation-delay: -4s; }
@keyframes ambient-drift { to { transform: translate3d(18px,24px,0) scale(1.08); } }

.app-header {
  position: sticky; top: 0; z-index: 20; height: calc(var(--header-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(16px,env(safe-area-inset-right)) 0 max(16px,env(safe-area-inset-left));
  display: grid; grid-template-columns: 48px minmax(0,1fr) 48px; grid-template-areas: "back brand theme"; align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(150%) blur(18px);
}
.app-header #backButton { grid-area: back; justify-self: start; }
.app-header #themeButton { grid-area: theme; justify-self: end; }
.app-header #backButton.hidden { display: grid !important; visibility: hidden; pointer-events: none; }
.brand { grid-area: brand; justify-self: center; min-width: 0; display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.brand-mark { width: 29px; height: 29px; flex: 0 0 29px; display: grid; place-items: center; border-radius: 9px; background: linear-gradient(135deg,var(--accent),#ff936f); color: white; font-size: 15px; box-shadow: 0 7px 18px rgba(255,94,47,.32); animation: brand-pulse 4s ease-in-out infinite; }
@keyframes brand-pulse { 50% { transform: rotate(-4deg) scale(1.06); box-shadow: 0 9px 24px rgba(255,94,47,.42); } }
.icon-button { width: 44px; height: 44px; border: 0; border-radius: 14px; background: var(--surface); display: grid; place-items: center; cursor: pointer; font-size: 22px; transition: transform .2s ease, background .2s ease, box-shadow .2s ease; }
.icon-button:active { transform: scale(.9); }
#themeIcon { display: block; transition: transform .4s cubic-bezier(.2,.8,.2,1); }
#themeButton.theme-flip #themeIcon { transform: rotate(180deg) scale(1.12); }
.install-banner { margin: 6px 16px 0; padding: 13px 13px 13px 16px; border: 1px solid var(--line); border-radius: 19px; background: var(--surface-solid); display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow); }
.install-banner div { display: grid; gap: 3px; }
.install-banner strong { font-size: 14px; }
.install-banner span { font-size: 12px; color: var(--muted); }

main { width: min(100%, 620px); min-height: calc(100dvh - var(--header-h)); margin: 0 auto; padding: 12px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 32px); }
.screen { animation: screen-in .38s cubic-bezier(.2,.8,.2,1) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(12px) scale(.992); } }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(31px, 9vw, 45px); line-height: .98; letter-spacing: -.05em; }
h2 { margin-bottom: 14px; font-size: 24px; letter-spacing: -.035em; }
h3 { margin-bottom: 8px; font-size: 17px; }
.muted { color: var(--muted); }
.lead { color: var(--muted); font-size: 16px; line-height: 1.5; }
.stack { display: grid; gap: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.hero { padding: 15px 2px 22px; }
.hero-controls { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
.date-control { display: inline-flex; position: relative; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--muted); font-weight: 650; }
.date-control input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.workout-card { position: relative; overflow: hidden; padding: 24px; border: 1px solid var(--line); border-radius: 31px; background: var(--surface); box-shadow: var(--shadow); animation: card-rise .55s .06s cubic-bezier(.2,.8,.2,1) both; }
@keyframes card-rise { from { opacity: 0; transform: translateY(18px); } }
.workout-card::after { content: ""; position: absolute; width: 170px; height: 170px; right: -65px; top: -65px; border-radius: 50%; background: var(--workout-accent,var(--accent)); opacity: .15; }
.workout-icon { width: 58px; height: 58px; display: grid; place-items: center; margin-bottom: 22px; border-radius: 19px; background: color-mix(in srgb,var(--workout-accent,var(--accent)) 16%,transparent); color: var(--workout-accent,var(--accent)); font-size: 27px; animation: icon-float 3.4s ease-in-out infinite; }
@keyframes icon-float { 50% { transform: translateY(-5px) rotate(3deg); } }
.workout-card h2 { font-size: 32px; margin-bottom: 7px; }
.stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 22px 0; }
.stat { padding: 12px 10px; border-radius: 16px; background: var(--surface-2); text-align: center; }
.stat strong { display: block; font-size: 17px; }
.stat span { color: var(--muted); font-size: 11px; }
.progress-track { overflow: hidden; height: 8px; border-radius: 8px; background: var(--surface-2); }
.progress-bar { height: 100%; width: var(--progress,0%); border-radius: inherit; background: linear-gradient(90deg,var(--workout-accent,var(--accent)),color-mix(in srgb,var(--workout-accent,var(--accent)) 55%,white)); transition: width .45s ease; }
.progress-label { margin-top: 8px; display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.progress-label + .button { margin-top:18px; }

.button { position: relative; overflow: hidden; min-height: 52px; width: 100%; border: 0; border-radius: 17px; padding: 0 18px; display:inline-flex; align-items:center; justify-content:center; text-align:center; line-height:1.2; cursor: pointer; font-weight: 800; transition: transform .14s, opacity .2s, background .2s, box-shadow .2s; }
.button:active { transform: scale(.98); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button-primary { background: linear-gradient(135deg,var(--accent),#ff815d); color: white; box-shadow: 0 12px 28px rgba(255,94,47,.25); }
.button-primary::after { content:""; position:absolute; inset:-80% auto -80% -35%; width:32%; transform:rotate(18deg); background:linear-gradient(90deg,transparent,rgba(255,255,255,.38),transparent); animation:button-shine 4.5s 1.2s ease-in-out infinite; }
@keyframes button-shine { 0%,68% { left:-40%; } 88%,100% { left:125%; } }
.button-secondary { background: var(--surface-2); }
.button-ghost { border: 1px solid var(--line); background: transparent; }
.button-danger { background: var(--danger); color: white; }
.button-small { width: auto; min-height: 44px; padding: 0 15px; border-radius: 14px; }
.button-row { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 10px; }
.button-row.three { grid-template-columns: repeat(3,minmax(0,1fr)); }
.button-row .button { min-width:0; padding-inline:12px; }
.button-row.three .button { padding-inline:8px; font-size:13px; }

.section-title { margin: 26px 2px 12px; display: flex; justify-content: space-between; align-items: end; }
.section-title h2 { margin: 0; }
.list-card, .info-card { padding: 17px; border: 1px solid var(--line); border-radius: 21px; background: var(--surface); }
.stage-list { display: grid; gap: 0; }
.stage-item { min-height: 60px; display: grid; grid-template-columns: 35px minmax(0,1fr) auto; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); animation:list-item-in .36s cubic-bezier(.2,.8,.2,1) both; }
.stage-item:nth-child(2) { animation-delay:.035s; }
.stage-item:nth-child(3) { animation-delay:.07s; }
.stage-item:nth-child(4) { animation-delay:.105s; }
.stage-item:nth-child(5) { animation-delay:.14s; }
.stage-item:nth-child(6) { animation-delay:.175s; }
.stage-item:nth-child(7) { animation-delay:.21s; }
@keyframes list-item-in { from { opacity:0; transform:translateX(-8px); } }
.stage-item:last-child { border-bottom: 0; }
.stage-number { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: var(--surface-2); font-size: 12px; font-weight: 800; }
.stage-item small { color: var(--muted); }

.timer-wrap { padding: 22px 0 14px; text-align: center; }
.timer-ring { --p:0deg; --timer-size:min(72vw,280px); width:var(--timer-size); min-width:var(--timer-size); max-width:var(--timer-size); height:var(--timer-size); min-height:var(--timer-size); max-height:var(--timer-size); aspect-ratio:auto; flex:0 0 var(--timer-size); margin:14px auto 24px; border-radius:999px; padding:12px; background:conic-gradient(var(--accent) var(--p),var(--surface-2) 0); box-shadow:0 20px 60px rgba(255,94,47,.14); animation:timer-breathe 2.5s ease-in-out infinite; }
@keyframes timer-breathe { 50% { box-shadow:0 20px 68px rgba(255,94,47,.25); } }
.timer-ring-inner { width:100%; height:100%; display:grid; place-content:center; border-radius:999px; background:var(--bg); }
.timer-time { font-size: clamp(54px,18vw,76px); font-variant-numeric: tabular-nums; font-weight: 850; letter-spacing: -.06em; }
.timer-caption { color: var(--muted); font-size: 13px; }
.instruction { max-width: 430px; margin: 0 auto 24px; color: var(--muted); line-height: 1.55; }

.exercise-visual { position: relative; min-height: 190px; margin-bottom: 18px; overflow: hidden; border-radius: 26px; background: linear-gradient(145deg,color-mix(in srgb,var(--workout-accent,var(--accent)) 18%,var(--surface-2)),var(--surface-2)); display: grid; place-items: center; }
.machine-glyph { width: 92px; height: 108px; position: relative; border: 8px solid currentColor; border-top-width: 15px; border-radius: 20px 20px 10px 10px; color: var(--workout-accent,var(--accent)); opacity: .8; }
.machine-glyph::before { content: ""; position: absolute; width: 45px; height: 45px; left: 16px; top: 24px; border-radius: 50%; background: currentColor; }
.machine-glyph::after { content: ""; position: absolute; width: 62px; height: 8px; left: 7px; bottom: 14px; border-radius: 6px; background: currentColor; }
.exercise-index { color: var(--workout-accent,var(--accent)); font-size: 12px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.pill { display: inline-flex; align-items: center; min-height: 32px; padding: 0 11px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 700; }
.details { display: grid; gap: 12px; margin: 18px 0; }
.details details { padding: 15px 16px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); transition:border-color .2s,transform .2s; }
.details details[open] { transform:translateY(-1px); }
.details summary { cursor: pointer; font-weight: 750; }
.details ol, .details ul { padding-left: 20px; margin-bottom: 0; color: var(--muted); line-height: 1.5; }
.safety { border-color: color-mix(in srgb,var(--danger) 30%,var(--line)) !important; }

.set-counter { margin: 16px 0 22px; display: flex; justify-content: center; gap: 9px; }
.set-dot { width: 42px; height: 8px; border-radius: 10px; background: var(--surface-2); transition:background .3s,box-shadow .3s,transform .3s; }
.set-dot.done { background: var(--success); }
.set-dot.current { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); transform:scaleX(1.08); }
.big-set { padding: 30px 18px; text-align: center; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); }
.big-set-number { font-size: 72px; line-height: 1; font-weight: 850; letter-spacing: -.07em; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 22px 0; }
.metric { padding: 17px; border-radius: 18px; background: var(--surface-2); }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 3px; font-size: 17px; }

.rest-screen { text-align: center; }
.rest-orb { width: 110px; height: 110px; margin: 24px auto; display: grid; place-items: center; border-radius: 36px; background: linear-gradient(145deg,rgba(77,182,172,.22),rgba(108,99,255,.18)); font-size: 48px; animation:rest-breathe 4s ease-in-out infinite; }
@keyframes rest-breathe { 50% { transform:scale(1.05) rotate(2deg); border-radius:50%; } }
.history-item { display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center; }
.history-icon { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 15px; background: rgba(24,166,106,.14); color: var(--success); font-weight: 900; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.settings-row { min-height: 68px; display: flex; justify-content: space-between; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.settings-row:last-child { border-bottom: 0; }
.settings-copy { min-width: 0; }
.settings-copy .muted { margin-top: 3px; font-size: 12px; line-height: 1.35; }
.schedule-card { padding: 19px; border: 1px solid var(--line); border-radius: 23px; background: linear-gradient(145deg,var(--surface),color-mix(in srgb,var(--accent-soft) 35%,var(--surface))); box-shadow: var(--shadow); }
.schedule-card-header { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:18px; }
.schedule-card-header h2 { margin:0 0 5px; }
.schedule-badge { flex:0 0 auto; }
.field-label { display:grid; gap:8px; margin-top:15px; color:var(--muted); font-size:12px; font-weight:700; }
.field-label input { width:100%; min-height:50px; padding:0 14px; border:1px solid var(--line); border-radius:15px; background:var(--surface-solid); color:var(--text); font-size:16px; font-weight:750; }
.schedule-type { width:100%; display:grid; grid-template-columns:1fr 1fr; }
.schedule-type button { min-height:44px; }
.segmented { display: flex; padding: 3px; border-radius: 13px; background: var(--surface-2); }
.segmented button { min-height: 38px; border: 0; padding: 0 10px; border-radius: 10px; background: transparent; cursor: pointer; }
.segmented button { transition: background .2s, color .2s, transform .2s; }
.segmented button:active { transform:scale(.96); }
.segmented button.active { background: var(--surface-solid); color:var(--accent); box-shadow: 0 3px 10px rgba(0,0,0,.08); }

.completion { position: relative; text-align: center; padding-top: 12px; }
.completed-card { border-color:color-mix(in srgb,var(--success) 28%,var(--line)); background:linear-gradient(145deg,var(--surface),color-mix(in srgb,rgba(24,166,106,.16) 45%,var(--surface))); }
.completed-card::after { background:var(--success); }
.completed-check { width:68px; height:68px; margin-bottom:22px; display:grid; place-items:center; border-radius:22px; background:rgba(24,166,106,.15); color:var(--success); font-size:34px; font-weight:900; animation:completed-check-in .6s cubic-bezier(.2,.8,.2,1.2) both; }
@keyframes completed-check-in { from { opacity:0; transform:scale(.45) rotate(-18deg); } }
.medal { width: 138px; height: 138px; margin: 20px auto 25px; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--success) 360deg,var(--surface-2) 0); box-shadow: 0 0 0 12px rgba(24,166,106,.11),0 20px 50px rgba(24,166,106,.2); animation: medal-in .7s cubic-bezier(.2,.8,.2,1) both; }
.medal-inner { width: 105px; height: 105px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-solid); color: var(--success); font-size: 54px; }
@keyframes medal-in { from { transform: scale(.4) rotate(-18deg); opacity: 0; } }
.confetti { position: fixed; top: -20px; left: var(--x); z-index: 40; width: 9px; height: 16px; border-radius: 2px; background: var(--c); animation: fall var(--d) linear var(--delay) forwards; pointer-events: none; }
@keyframes fall { to { transform: translate(var(--drift),110dvh) rotate(680deg); } }

.bottom-nav { position: fixed; z-index: 25; left: max(12px,env(safe-area-inset-left)); right: max(12px,env(safe-area-inset-right)); bottom: max(10px,env(safe-area-inset-bottom)); height: var(--nav-h); max-width: 570px; margin: auto; padding: 7px; display: grid; grid-template-columns: repeat(3,1fr); border: 1px solid var(--line); border-radius: 24px; background: color-mix(in srgb,var(--surface-solid) 88%,transparent); backdrop-filter: blur(18px); box-shadow: var(--shadow); }
.bottom-nav a { min-height: 52px; display: grid; place-content: center; gap: 1px; text-align: center; border-radius: 18px; color: var(--muted); }
.bottom-nav a span { font-size: 20px; line-height: 1; }
.bottom-nav a small { font-size: 10px; font-weight: 700; }
.bottom-nav a { transition:color .2s,background .2s,transform .2s; }
.bottom-nav a.active { background: var(--accent-soft); color: var(--accent); animation:nav-pop .28s ease both; }
@keyframes nav-pop { 50% { transform:scale(1.04); } }
.toast { position: fixed; z-index: 80; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); max-width: calc(100% - 32px); transform: translate(-50%,20px); padding: 12px 17px; border-radius: 14px; background: #222733; color: white; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; }
.toast.show { transform: translate(-50%,0); opacity: 1; }
.modal-backdrop { position: fixed; inset: 0; z-index: 90; padding: 20px; display: grid; place-items: center; background: rgba(0,0,0,.48); backdrop-filter: blur(8px); }
.modal { width: min(100%,420px); padding: 22px; border-radius: 24px; background: var(--surface-solid); box-shadow: var(--shadow); animation:modal-in .3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes modal-in { from { opacity:0; transform:translateY(18px) scale(.96); } }
.modal p { color: var(--muted); line-height: 1.5; white-space:pre-line; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 20px; }
.modal-actions.single { grid-template-columns:1fr; }

@media (max-width: 380px) { .settings-row { align-items:flex-start; flex-direction:column; padding:14px 0; } .settings-row .segmented { width:100%; display:grid; grid-template-columns:repeat(3,1fr); } }
@media (max-width: 360px) { .button-row.three { grid-template-columns: 1fr; } .stats { grid-template-columns: 1fr; } .stat { text-align: left; display: flex; justify-content: space-between; } .brand { gap:6px; font-size:15px; } }
@media (min-width: 700px) { main { padding-top: 28px; } }
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; } .confetti { display: none; } }
