/* Apple Music look: SF Pro (system font on iPhone), Apple Music red, black/white surfaces, album-art gradients,
   edge-to-edge lists, glass tab bar + mini-player timer. Nothing is ever wider than the screen. */
:root {
  --bg: #FFFFFF; --bg2: #F2F2F7; --bg3: #E5E5EA; --ink: #000; --muted: rgba(60,60,67,.6); --line: rgba(60,60,67,.18);
  --red: #FA243C; --red-soft: rgba(250,36,60,.12); --on-red: #fff; --green: #30B24F; --green-soft: rgba(48,178,79,.16);
  --fill: rgba(120,120,128,.14); --glass: rgba(246,246,248,.78); --glass-edge: rgba(255,255,255,.7); --glass-shadow: 0 8px 30px rgba(0,0,0,.14);
  --tab-h: 62px; --gutter: 20px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000; --bg2: #1C1C1E; --bg3: #2C2C2E; --ink: #fff; --muted: rgba(235,235,245,.6); --line: rgba(84,84,88,.6);
    --red: #FA2D48; --red-soft: rgba(250,45,72,.18); --green: #30D158; --green-soft: rgba(48,209,88,.2);
    --fill: rgba(120,120,128,.3); --glass: rgba(38,38,40,.72); --glass-edge: rgba(255,255,255,.14); --glass-shadow: 0 8px 30px rgba(0,0,0,.6);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { overflow-x: hidden; -webkit-text-size-adjust: 100%; background: var(--bg); }
html, body { margin: 0; max-width: 100%; color: var(--ink); background: var(--bg);
  font: 400 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-left) 0 env(safe-area-inset-right); min-height: 100vh; min-height: 100dvh; }
#app { width: 100%; max-width: 600px; margin: 0 auto; padding: 6px var(--gutter) calc(var(--tab-h) + env(safe-area-inset-bottom) + 48px); overflow-x: clip; }
body.has-timer #app { padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 124px); }
#app, #app * { min-width: 0; }
img, svg { max-width: 100%; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; font-size: 17px; color: var(--ink); max-width: 100%; }
.ic { width: 24px; height: 24px; fill: currentColor; flex: none; }

/* type: SF Pro, bold large titles */
h1 { font-size: 34px; line-height: 1.12; font-weight: 700; letter-spacing: -.026em; margin: 2px 0 14px; overflow-wrap: anywhere; }
h2 { font-size: 22px; line-height: 1.2; font-weight: 700; letter-spacing: -.02em; margin: 30px 0 8px; }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: .01em; color: var(--muted); text-transform: uppercase; margin-top: 14px; }
.sub { color: var(--muted); margin: 0 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 15px; line-height: 1.3; }
.tnum { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--bg2); border-radius: 30px; padding: 18px; margin-bottom: 12px; position: relative; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.75); } 55% { transform: scale(1.14); } 100% { transform: scale(1); } }
#app.enter > * { animation: rise .38s cubic-bezier(.2,.8,.2,1) both; }
#app.enter > *:nth-child(2) { animation-delay: .03s; } #app.enter > *:nth-child(3) { animation-delay: .06s; }
#app.enter > *:nth-child(4) { animation-delay: .09s; } #app.enter > *:nth-child(n+5) { animation-delay: .12s; }
@media (prefers-reduced-motion: reduce) { #app.enter > * { animation: none; } .ck.pop { animation: none; } * { transition: none !important; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 48px; padding: 0 24px; border-radius: 999px;
  background: var(--red); color: var(--on-red); font-weight: 600; font-size: 17px; letter-spacing: -.01em; white-space: nowrap; transition: transform .12s, opacity .12s; }
.btn .ic { width: 18px; height: 18px; }
.btn.block { display: flex; width: 100%; }
.btn.play { border-radius: 999px; background: var(--fill); color: var(--red); }     /* Apple Music "Play" button */
.btn.play .ic { width: 20px; height: 20px; }
.btn.soft { background: var(--fill); color: var(--red); }
.btn.ghost { background: var(--fill); color: var(--ink); }
.btn.danger { background: var(--fill); color: var(--red); }
.btn.sm { height: 34px; padding: 0 14px; font-size: 15px; }
.btn:active { transform: scale(.97); opacity: .8; }
.btn[disabled] { opacity: .4; }
.linkbtn { display: block; margin: 16px auto 0; padding: 10px 12px; color: var(--red); font-size: 15px; text-align: center; }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--red); flex: none; margin-left: -10px; }
.iconbtn .ic { width: 26px; height: 26px; }
.navbtn { height: 44px; padding: 0 4px; color: var(--red); font-size: 17px; font-weight: 600; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; max-width: 100%; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 34px; padding: 0 16px; border-radius: 999px; background: var(--fill); font-weight: 600; font-size: 15px; transition: background .15s; }
.chip.on { background: var(--red); color: var(--on-red); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--red-soft); color: var(--red); font-size: 12px; font-weight: 700; letter-spacing: .02em; vertical-align: 2px; }
.pill.ok { background: var(--green-soft); color: var(--green); }
.seg { display: flex; background: var(--fill); border-radius: 999px; padding: 2px; margin-bottom: 12px; }
.seg button { flex: 1; height: 32px; border-radius: 999px; font-weight: 600; font-size: 14px; transition: background .15s; }
.seg button.on { background: var(--bg); box-shadow: 0 2px 6px rgba(0,0,0,.2); }
@media (prefers-color-scheme: dark) { .seg button.on { background: #636366; } }
.stepper { display: inline-flex; align-items: center; background: var(--fill); border-radius: 999px; height: 48px; padding: 0 4px; flex: none; }
.stepper b { min-width: 62px; text-align: center; font-weight: 600; font-size: 15px; }
.stepper button { width: 36px; height: 40px; display: grid; place-items: center; color: var(--red); }
.stepper button .ic { width: 20px; height: 20px; }

/* nav bar (glass) */
.top { display: flex; align-items: center; gap: 4px; min-height: 48px; }
.top.sticky { position: sticky; top: env(safe-area-inset-top); z-index: 12; margin: 0 calc(var(--gutter) * -1); padding: 2px var(--gutter) 8px;
  background: var(--glass); -webkit-backdrop-filter: blur(26px) saturate(1.8); backdrop-filter: blur(26px) saturate(1.8); border-bottom: .5px solid var(--line); }
.ttl { text-align: center; line-height: 1.2; }
.ttl b { font-size: 17px; font-weight: 600; }
.ttl > span { color: var(--muted); font-size: 17px; }
.ttl .small { font-size: 12px; color: var(--muted); }
.top .iconbtn + .ttl { padding-right: 34px; }
.pbar { position: absolute; left: 0; right: 0; bottom: -.5px; height: 2px; background: transparent; overflow: hidden; }
.pbar i { display: block; height: 100%; background: var(--red); transition: width .35s cubic-bezier(.2,.8,.2,1); }

/* home: album-art hero */
.summary { margin-bottom: 4px; }
.art { position: relative; display: flex; flex-direction: column; justify-content: space-between; aspect-ratio: 16 / 11; border-radius: 36px; padding: 20px; color: #fff; overflow: hidden;
  box-shadow: 0 14px 34px rgba(0,0,0,.28); }
.art::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 90% at 0 0, rgba(255,255,255,.28), transparent 55%), linear-gradient(to top, rgba(0,0,0,.42), transparent 55%); pointer-events: none; }
.art > * { position: relative; z-index: 1; }
.art-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.art-k { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; opacity: .9; }
.art-n { font-size: 40px; line-height: 1.05; font-weight: 800; letter-spacing: -.03em; text-shadow: 0 2px 14px rgba(0,0,0,.25); }
.art-m { font-size: 15px; opacity: .9; margin-top: 4px; }
.ring { position: relative; width: 64px; height: 64px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .rt { stroke: rgba(255,255,255,.3); }
.ring .rp { stroke: #fff; stroke-linecap: round; transition: stroke-dashoffset .9s cubic-bezier(.2,.8,.2,1); }
.ring b { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; font-size: 18px; font-weight: 700; line-height: 1; }
.ring b small { font-size: 9px; font-weight: 600; opacity: .85; margin-top: 2px; display: block; }
.playrow { display: flex; gap: 10px; margin-top: 12px; }
.playrow .btn { flex: 1 1 auto; width: auto; padding: 0 14px; }
@media (max-width: 380px) { .playrow { flex-direction: column; } .playrow .stepper { width: 100%; justify-content: space-between; } .playrow .stepper b { flex: 1; } }

/* album-cover gradients (one per training day) */
.d1 { background: linear-gradient(135deg, #FA243C 0%, #FF8A3D 100%); }
.d2 { background: linear-gradient(135deg, #5E5CE6 0%, #BF5AF2 100%); }
.d3 { background: linear-gradient(135deg, #FF2D55 0%, #AF52DE 100%); }
.d4 { background: linear-gradient(135deg, #0A84FF 0%, #30D5C8 100%); }

/* lists: edge-to-edge rows with artwork */
.group { margin: 0; }
.item { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 8px 0; min-height: 76px; position: relative; }
.item + .item::before { content: ""; position: absolute; top: 0; left: 72px; right: 0; border-top: .5px solid var(--line); }
.item:active { opacity: .6; }
.item .n { width: 58px; height: 58px; border-radius: 22px; color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 24px; flex: none; position: relative; overflow: hidden; box-shadow: 0 3px 10px rgba(0,0,0,.2); }
.item .n::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 100% at 0 0, rgba(255,255,255,.3), transparent 60%); }
.btn.stop { background: var(--red-soft); color: var(--red); flex: none; width: auto; }
.item .t { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.chev { color: var(--muted); opacity: .6; display: grid; }
.chev .ic { width: 20px; height: 20px; }

/* workout */
.card.complete { background: color-mix(in srgb, var(--green) 14%, var(--bg2)); }
.ex-h { display: flex; gap: 12px; align-items: flex-start; }
.ex-l { width: 32px; height: 32px; border-radius: 50%; background: var(--red-soft); color: var(--red); font-weight: 800; display: grid; place-items: center; flex: none; font-size: 15px; }
.complete .ex-l { background: var(--green); color: #fff; }
.ex-n { font-weight: 700; font-size: 18px; letter-spacing: -.015em; line-height: 1.2; overflow-wrap: anywhere; }
.count { margin-top: 3px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.complete .count { color: var(--green); }
.ex-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.hint { font-size: 14px; line-height: 1.3; color: var(--muted); margin: 12px 0; padding: 11px 16px; background: var(--bg3); border-radius: 20px; overflow-wrap: anywhere; }
.hint b { color: var(--ink); font-weight: 600; }
.sets { display: grid; grid-template-columns: 24px minmax(36px,1fr) 58px 50px 44px 40px; gap: 6px; align-items: center; width: 100%; }
.sets .hd { font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; text-align: center; }
.sets .sn { text-align: center; font-weight: 600; color: var(--muted); }
.sets .prev { font-size: 12px; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sets input { width: 100%; height: 44px; border-radius: 18px; border: 0; background: var(--bg3); text-align: center; padding: 0; font-weight: 600; -webkit-appearance: none; appearance: none; }
.sets input:focus { outline: 2px solid var(--red); }
.sets .ck { width: 32px; height: 32px; justify-self: center; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--line); display: grid; place-items: center; color: transparent; transition: background .15s, box-shadow .15s; }
.sets .ck .ic { width: 19px; height: 19px; }
.sets .done input { background: var(--red-soft); color: var(--red); }
.sets .done .ck { background: var(--red); box-shadow: none; color: #fff; }
.ck.pop { animation: pop .36s cubic-bezier(.2,.9,.3,1.4); }
@media (max-width: 350px) {   /* small phones: drop the "previous" column rather than overflow */
  .sets { grid-template-columns: 22px minmax(0,1fr) minmax(0,1fr) 40px 34px; gap: 5px; }
  .sets .pv, .sets .prev { display: none; }
}
.note { width: 100%; margin-top: 12px; border: 0; border-radius: 22px; background: var(--bg3); padding: 12px 16px; resize: none; }
.note:focus { outline: 2px solid var(--red); }
.cardio { text-align: center; padding: 8px 0 2px; }
.cardio .big { font-size: 50px; font-weight: 700; letter-spacing: -.03em; }

/* progress */
.stat { flex: 1 1 0; background: var(--bg3); border-radius: 22px; padding: 10px 12px; }
.stat b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); }
.row.stats { align-items: stretch; gap: 8px; }
.up { color: var(--green); } .down { color: var(--red); }
svg.chart { width: 100%; height: auto; display: block; }
.li { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 0; border-bottom: .5px solid var(--line); }
.li:last-child { border-bottom: 0; }

/* timer tab */
.dial { text-align: center; padding: 28px 0 18px; }
.dial .big { font-size: clamp(60px, 21vw, 88px); font-weight: 700; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1; }
.presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 14px 0; }
.sel { height: 38px; border-radius: 999px; border: 0; background: var(--bg3); padding: 0 10px; max-width: 60%; }
.pwin { display: block; width: 100%; height: 48px; border-radius: 22px; border: 0; background: var(--bg3); padding: 0 14px; margin-bottom: 8px; }
.pwin:focus { outline: 2px solid var(--red); }
.secform { margin-top: 14px; padding-top: 14px; border-top: .5px solid var(--line); }
.secform .row { margin-top: 4px; }
.lockmsg { min-height: 20px; font-size: 14px; color: var(--red); margin: 2px 2px 8px; }

/* rest timer = Apple Music mini player */
#timerbar { position: fixed; left: 0; right: 0; z-index: 20; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 18px); padding: 0 12px; pointer-events: none; }
.tb { pointer-events: auto; max-width: 576px; margin: 0 auto; position: relative; overflow: hidden; display: flex; align-items: center; gap: 6px;
  background: var(--glass); -webkit-backdrop-filter: blur(28px) saturate(1.8); backdrop-filter: blur(28px) saturate(1.8);
  border: .5px solid var(--glass-edge); border-radius: 34px; padding: 10px 8px 12px 68px; min-height: 66px; box-shadow: var(--glass-shadow); }
.tb::before { content: ""; position: absolute; left: 10px; top: 10px; width: 46px; height: 46px; border-radius: 18px; background: linear-gradient(135deg, #FA243C, #FF8A3D); box-shadow: 0 3px 8px rgba(0,0,0,.25); }
.tb .p { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--red); transition: width .25s linear; }
.tb .t { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; min-width: 68px; }
.tb .l { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb button { height: 34px; min-width: 38px; padding: 0 8px; border-radius: 999px; background: var(--fill); font-weight: 600; font-size: 14px; }
.tb.over { background: color-mix(in srgb, var(--green) 28%, var(--glass)); }
.tb.over .t { color: var(--green); } .tb.over .p { background: var(--green); }

/* tab bar (glass, red tint) */
#tabs { position: fixed; left: 14px; right: 14px; bottom: calc(env(safe-area-inset-bottom) + 8px); z-index: 30; max-width: 572px; margin: 0 auto;
  display: flex; align-items: stretch; height: var(--tab-h); padding: 4px; background: var(--glass);
  -webkit-backdrop-filter: blur(28px) saturate(1.8); backdrop-filter: blur(28px) saturate(1.8); border: .5px solid var(--glass-edge); border-radius: 999px; box-shadow: var(--glass-shadow); }
#tabs:empty { display: none; }
#tabs button { flex: 1 1 0; min-width: 0; border-radius: 999px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; color: var(--muted); transition: background .2s, color .2s; }
#tabs .ind { display: grid; place-items: center; height: 28px; }
#tabs .ic { width: 25px; height: 25px; }
#tabs .lbl { font-size: 10px; font-weight: 600; letter-spacing: .01em; }
#tabs button.on { color: var(--red); background: var(--fill); }

/* lock screen */
#lock { display: none; }
body.locked #app, body.locked #tabs, body.locked #timerbar { display: none; }
body.locked #lock { display: grid; place-items: center; min-height: calc(100dvh - env(safe-area-inset-top)); padding: 24px var(--gutter); }
.lockbox { width: 100%; max-width: 360px; text-align: center; }
.lockbox h1 { margin-top: 14px; }
#pass { display: block; width: 100%; height: 52px; border-radius: 24px; border: 0; background: var(--bg2); padding: 0 16px; text-align: center; margin: 0 0 8px; font-size: 19px; }
#pass:focus { outline: 2px solid var(--red); }
.lock-ic { width: 88px; height: 88px; margin: 0 auto; border-radius: 50%; background: linear-gradient(135deg, #FA243C, #FF5E7A); color: #fff; display: grid; place-items: center; box-shadow: 0 12px 28px rgba(250,36,60,.4); }
.lock-ic .ic { width: 42px; height: 42px; }

/* HUD-style toast */
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 20px); transform: translate(-50%, 160%); opacity: 0; background: var(--glass);
  -webkit-backdrop-filter: blur(28px) saturate(1.8); backdrop-filter: blur(28px) saturate(1.8); border: .5px solid var(--glass-edge);
  padding: 12px 20px; border-radius: 999px; z-index: 50; transition: transform .3s cubic-bezier(.2,.9,.3,1.2), opacity .2s; font-weight: 600; font-size: 15px; width: max-content; max-width: calc(100vw - 32px); box-shadow: var(--glass-shadow); }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
.empty { text-align: center; color: var(--muted); padding: 32px 10px; }
