:root {
  --accent: #ff6b35;
  --bg: #f2f2f7;
  --card: #ffffff;
  --fill: #e9e9ee;
  --text: #1c1c1e;
  --text-2: #6b6b73;
  --text-3: #a1a1a8;
  --line: #dedee3;
  --green: #28a745;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --fill: #2c2c2e;
    --text: #f2f2f7;
    --text-2: #a1a1a8;
    --text-3: #6b6b73;
    --line: #38383a;
    --green: #32d74b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.4;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input { font: inherit; }
h1, h2, h3, p { margin: 0; }

#view {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px);
  outline: none;
}

/* ---------- headers ---------- */
.page-title { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 4px; }
.subtle { color: var(--text-2); font-size: 15px; }
.section-title { font-size: 20px; font-weight: 700; margin: 22px 0 10px; }
.topbar { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; min-height: 40px; }
.topbar .title { font-weight: 700; font-size: 17px; flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .spacer { width: 40px; }
.back { color: var(--accent); font-size: 17px; display: inline-flex; align-items: center; gap: 2px; min-width: 40px; }
.back svg { width: 22px; height: 22px; }

/* ---------- cards ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card h3 { font-size: 17px; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px; background: color-mix(in srgb, var(--c, var(--accent)) 15%, transparent); color: var(--c, var(--accent)); }
.chip.white { --c: #fff; background: rgba(255, 255, 255, .22); color: #fff; }

/* ---------- hero ---------- */
.hero { color: #fff; border-radius: 22px; padding: 18px; background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 68%, #000 0%)); background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 70%, transparent)); display: flex; flex-direction: column; gap: 12px; }
.hero .row { display: flex; gap: 12px; align-items: flex-start; }
.hero .eyebrow { font-size: 12px; font-weight: 800; opacity: .9; letter-spacing: .04em; }
.hero h2 { font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0; }
.hero p { opacity: .95; font-size: 15px; }
.hero .fig { width: 76px; height: 76px; flex: none; background: rgba(255,255,255,.18); border-radius: 18px; padding: 6px; }
.btn-primary { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 14px; border-radius: 14px; background: #fff; color: var(--c); font-weight: 700; font-size: 17px; }
.btn-primary svg { width: 18px; height: 18px; }
.done-label { font-weight: 600; display: flex; align-items: center; gap: 6px; }

/* ---------- week strip ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.wd { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--text-2); }
.wd .dot { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 14%, transparent); border: 2px solid transparent; }
.wd .dot svg.figure { width: 28px; height: 28px; }
.wd.done .dot { background: var(--c); color: #fff; }
.wd.today .dot { border-color: var(--c); }
.wd.today .num { color: var(--c); font-weight: 700; }

/* ---------- stats ---------- */
.stats { display: flex; gap: 18px; align-items: center; }
.ring { position: relative; width: 88px; height: 88px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring .label b { font-size: 18px; }
.ring .label span { font-size: 11px; color: var(--text-2); }
.stat-list { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.stat { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.stat .ico { width: 20px; text-align: center; }
.stat .k { color: var(--text-2); flex: 1; }
.stat .v { font-weight: 600; }

/* ---------- exercise rows ---------- */
.block-head { display: flex; align-items: center; justify-content: space-between; }
.block-head h3 { margin: 0; }
.block-sub { font-size: 13px; color: var(--text-2); margin: 4px 0 8px; }
.ex-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.ex-row + .ex-row { border-top: 1px solid var(--line); }
.thumb { width: 56px; height: 56px; flex: none; border-radius: 12px; padding: 3px; background: color-mix(in srgb, var(--accent) 9%, transparent); }
.thumb svg { width: 100%; height: 100%; display: block; }
.ex-row .txt { flex: 1; min-width: 0; }
.ex-row .name { font-weight: 600; font-size: 15px; }
.ex-row .meta { font-size: 13px; color: var(--text-2); }
.chev { color: var(--text-3); width: 14px; height: 14px; flex: none; }

/* ---------- plan list ---------- */
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.list-head { font-size: 13px; font-weight: 600; text-transform: uppercase; color: var(--text-2); margin: 22px 4px 6px; letter-spacing: .03em; }
.day-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.day-row + .day-row { border-top: 1px solid var(--line); }
.day-row .date { width: 46px; height: 46px; border-radius: 10px; background: var(--fill); display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none; }
.day-row .date small { font-size: 10px; font-weight: 700; text-transform: uppercase; }
.day-row .date b { font-size: 19px; line-height: 1.1; }
.day-row.today .date { background: var(--c); color: #fff; }
.day-row .txt { flex: 1; min-width: 0; }
.day-row .t1 { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.day-row .t1 i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); display: inline-block; flex: none; }
.day-row .t2 { font-size: 13px; color: var(--text-2); }
.day-row .t2 .deload { color: #ff9500; }
.check { width: 24px; height: 24px; flex: none; }
.check.done { color: var(--green); }
.check.missed { color: var(--text-3); }

.phase { display: flex; gap: 12px; align-items: flex-start; }
.phase + .phase { margin-top: 12px; }
.phase .n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); flex: none; }
.phase .top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 15px; }
.phase .top span { font-weight: 400; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.phase p { font-size: 13px; color: var(--text-2); }
.phase .rpe { font-size: 12px; font-weight: 700; color: var(--accent); }
.fine { font-size: 12px; color: var(--text-2); margin-top: 12px; }

/* ---------- toggles / forms ---------- */
.row-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.row-toggle + .row-toggle { border-top: 1px solid var(--line); }
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--fill); border-radius: 999px; transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--fill); border-radius: 10px; padding: 2px; }
.segmented button { padding: 8px; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--text-2); }
.segmented button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 16px; border-radius: 12px; background: var(--fill); font-weight: 600; }
.btn.danger { color: #ff3b30; }
.btn.accent { background: var(--accent); color: #fff; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.search { width: 100%; padding: 10px 14px; border-radius: 12px; border: 0; background: var(--fill); color: var(--text); font-size: 16px; margin: 8px 0 4px; }
.search:focus { outline: 2px solid var(--accent); }

/* ---------- exercise detail ---------- */
.big-fig { background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 22px; padding: 16px; display: grid; place-items: center; }
.big-fig svg { width: min(100%, 300px); height: auto; aspect-ratio: 1; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.steps li { display: flex; gap: 12px; align-items: flex-start; }
.steps li b { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 14px; flex: none; }

/* ---------- tab bar ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--line);
}
#tabbar .inner { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; max-width: 640px; height: var(--tabbar-h); }
#tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--text-3); }
#tabbar a svg { width: 26px; height: 26px; }
#tabbar a.on { color: var(--accent); }
body.playing #tabbar { display: none; }

/* ---------- player ---------- */
#overlay:empty { display: none; }
.player { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; align-items: center; overflow-y: auto; }
.player .wrap { width: 100%; max-width: 520px; min-height: 100%; display: flex; flex-direction: column; gap: 14px; padding: calc(env(safe-area-inset-top) + 12px) 18px calc(env(safe-area-inset-bottom) + 18px); }
.pbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pbar .mid { text-align: center; flex: 1; }
.pbar .mid b { display: block; font-size: 17px; }
.pbar .mid span { font-size: 13px; color: var(--text-2); }
.circle-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--fill); display: grid; place-items: center; flex: none; }
.circle-btn svg { width: 18px; height: 18px; }
.progress { height: 6px; border-radius: 999px; background: var(--fill); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--c); border-radius: inherit; }
.ptimes { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; margin-top: 4px; }
.stage { position: relative; width: min(78vw, 320px); aspect-ratio: 1; margin: 6px auto 0; }
.stage svg.ringsvg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.stage .figwrap { position: absolute; inset: 13%; }
.stage .figwrap svg { width: 100%; height: 100%; }
.plabel { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.plabel .rest { color: var(--green); font-weight: 800; letter-spacing: .05em; }
.plabel h2 { font-size: 28px; font-weight: 800; letter-spacing: -.01em; }
.plabel .next { font-size: 19px; font-weight: 600; }
.clock { font-size: 68px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--c); line-height: 1; letter-spacing: -.02em; }
.controls { display: flex; align-items: center; justify-content: center; gap: 44px; margin-top: 4px; }
.controls .side svg { width: 30px; height: 30px; }
.controls .play { width: 80px; height: 80px; border-radius: 50%; background: var(--c); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 40%, transparent); }
.controls .play svg { width: 32px; height: 32px; }
.hint { text-align: center; font-size: 13px; color: var(--text-2); }
.flex1 { flex: 1; }

.sheet-back { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 88vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 12px 16px calc(env(safe-area-inset-bottom) + 20px); }
.dialog { background: var(--card); border-radius: 16px; margin: auto; width: min(92vw, 360px); padding: 18px; display: flex; flex-direction: column; gap: 10px; text-align: center; }
.dialog h3 { font-size: 17px; }
.dialog .btn { width: 100%; }
.center-back { align-items: center; }

.finish { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; }
.finish .seal { width: 110px; height: 110px; color: var(--green); }
.finish h2 { font-size: 34px; font-weight: 800; }
.finish .nums { display: flex; gap: 36px; }
.finish .nums b { font-size: 28px; display: block; }
.finish .nums span { font-size: 13px; color: var(--text-2); }

@media (min-width: 700px) {
  .page-title { font-size: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ================= v2: personalisation, account ================= */
.rest-card { display: flex; gap: 14px; align-items: center; }
.rest-fig { width: 64px; height: 64px; flex: none; border-radius: 14px; background: var(--fill); padding: 4px; }
.rest-fig svg { width: 100%; height: 100%; }
.rest-card h3 { margin-bottom: 4px; }
.day-row.rest { padding-top: 6px; padding-bottom: 6px; opacity: .6; }
.day-row.rest .date { width: 46px; height: 34px; background: transparent; }
.day-row.rest.today .date { background: var(--fill); color: var(--text); }
.wd.rest .dot { background: var(--fill); }
.plan-sum { display: flex; gap: 12px; align-items: center; }
.goal-mini { width: 54px; height: 54px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 10%, transparent); padding: 4px; flex: none; }
.goal-mini svg { width: 100%; height: 100%; }

.goal-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.goal-card { text-align: left; background: var(--card); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 4px; border: 2px solid transparent; box-shadow: var(--shadow); }
.goal-card .gfig { width: 44px; height: 44px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 10%, transparent); padding: 3px; }
.goal-card .gfig svg { width: 100%; height: 100%; }
.goal-card b { font-size: 15px; line-height: 1.25; }
.goal-card small { font-size: 12px; color: var(--text-2); line-height: 1.3; }
.goal-card.on, .opt-card.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--card)); }
.opt-card { text-align: left; background: var(--card); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; border: 2px solid transparent; box-shadow: var(--shadow); width: 100%; }
.opt-card b { font-size: 17px; }
.opt-card small { color: var(--text-2); font-size: 14px; }
.opt-card .rpe { font-size: 12px; font-weight: 700; color: var(--accent); margin-left: 6px; }

.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 2px 8px; text-transform: uppercase; letter-spacing: .03em; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tchip { padding: 9px 13px; border-radius: 999px; background: var(--card); font-weight: 600; font-size: 14px; border: 1.5px solid var(--line); min-width: 44px; }
.tchip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 520px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.input, .select { width: 100%; padding: 11px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card); color: var(--text); font-size: 16px; }
.input:focus, .select:focus { outline: 2px solid var(--accent); border-color: transparent; }
.inline { display: flex; gap: 8px; }
.input.num { max-width: 110px; }
.select.small { width: auto; flex: 1; }
.sticky-cta { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px); margin-top: 18px; z-index: 5; }
body.wizard .sticky-cta { bottom: calc(env(safe-area-inset-bottom) + 12px); }
body.wizard #tabbar { display: none; }
body.wizard #view { padding-bottom: calc(env(safe-area-inset-bottom) + 24px); }
.btn.big { width: 100%; padding: 16px; font-size: 17px; border-radius: 14px; box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent); }
.steps-dots { display: inline-flex; gap: 6px; }
.steps-dots i { width: 22px; height: 5px; border-radius: 3px; background: var(--fill); }
.steps-dots i.on { background: var(--accent); }

.btn.google { background: var(--card); border: 1.5px solid var(--line); color: var(--text); gap: 10px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.user-row { display: flex; gap: 12px; align-items: center; }
.user-row img, .user-row .avatar { width: 44px; height: 44px; border-radius: 50%; flex: none; }
.user-row .avatar { display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 700; text-transform: uppercase; }
.sync-ok { margin: 0; color: var(--green); font-weight: 600; font-size: 14px; }
a.btn { text-align: center; }

/* ---------- multiple plans ---------- */
.plan-block + .plan-block { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.plan-switch { margin-bottom: 12px; }
.hero-link { align-self: center; color: #fff; opacity: .9; font-weight: 600; font-size: 14px; text-decoration: underline; padding: 2px 6px; }
/* Shown instead of the start button on a day that is not today. */
.hero-note { margin: 0; color: #fff; opacity: .85; font-size: 14px; line-height: 1.45; }
.eyebrow.dark { font-size: 12px; font-weight: 800; color: var(--text-2); letter-spacing: .04em; margin-bottom: 4px; }
a.plan-link { display: block; color: inherit; }
a.plan-link + a.plan-link { border-top: 1px solid var(--line); padding-top: 12px; }
a.plan-link .chev { color: var(--text-3); display: flex; }
a.plan-link .chev svg { width: 18px; height: 18px; }
label.block { display: block; }

/* ---------- voice picker ---------- */
input.range { width: 100%; accent-color: var(--accent); margin-top: 4px; }
.plan-switch select { font-weight: 600; padding: 13px 12px; }
