/* MAD client app, v3: three themes on one set of tokens.
 *   blue    - MAD Blue, from the app icon. The default, and what a page
 *             with no data-theme at all gets.
 *   light   - Kairos ivory with bronze (AA on white, ivory and the washes).
 *   classic - the v2 dark teal and gold (state colors lifted for AA).
 * v4 (R4 review): every text token is AA (4.5:1) on --bg, --card, --card-2
 * and on its own wash; --on-red is dark on the dark themes' lighter red.
 * Every color in the rules below is a token; the theme blocks are the only
 * place a color value is written. New rules use logical properties
 * (inline-start/end) so a right-to-left page mirrors cleanly.
 * v5 (W8, beta P11 low vision): every font size is in rem, so text follows
 * the phone's text size (Android font size; iOS Dynamic Type through
 * -apple-system-body), times --tx: 1, or 1.2 with Profile > Larger text
 * (class text-lg on html). Body text is at least 16px and short labels at
 * least 12px. Tap targets are at least 44 x 44 px. Long words wrap
 * instead of pushing the page sideways at large text sizes. The Today
 * strip's future days and done player rows no longer fade text below AA.
 * Versioned filename: module static files are cached for 7 days, so a
 * change ships as a new file name. */

/* ---------- theme swatches (the same in every theme) ---------- */
:root {
    --sw-blue-bg: #081A2F;
    --sw-blue-fg: #CDB779;
    --sw-light-bg: #F5F1E8;
    --sw-light-fg: #75591F;
    --sw-classic-bg: #071A20;
    --sw-classic-fg: #C7A25E;
    --radius: 18px;
    --pill: 999px;
    --tabbar: 68px;
    /* Profile > Larger text multiplies every font size (v5). */
    --tx: 1;
}
html.text-lg { --tx: 1.2; }

/* The root size is the phone's: 100% of the browser's (Android follows
 * the system font size), and on iOS the Dynamic Type body size. */
html { font-size: 100%; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@supports (font: -apple-system-body) {
    html { font: -apple-system-body; }
}

/* ---------- MAD Blue (default) ---------- */
:root,
html[data-theme="blue"] {
    --bg: #081A2F;
    --bg-2: #0D233B;
    --card: #102A45;
    --card-2: #1B2C41;
    --line: rgba(205, 183, 121, 0.14);
    --line-2: rgba(255, 255, 255, 0.08);
    --ink: #F4F1E6;
    --ink-2: #BFC8D2;
    --ink-3: #8E9BAA;
    --gold: #CDB779;
    --gold-2: #F9F1C6;
    --gold-wash: rgba(205, 183, 121, 0.14);
    --gold-wash-2: rgba(205, 183, 121, 0.08);
    --gold-ring: rgba(205, 183, 121, 0.35);
    --teal: #16365A;
    --ok: #4DB88E;
    --ok-wash: rgba(77, 184, 142, 0.10);
    --ok-line: rgba(77, 184, 142, 0.5);
    --ok-line-2: rgba(77, 184, 142, 0.35);
    --amber: #E3B05B;
    --amber-wash: rgba(227, 176, 91, 0.22);
    --amber-wash-2: rgba(227, 176, 91, 0.18);
    --amber-wash-3: rgba(227, 176, 91, 0.12);
    --amber-line: rgba(227, 176, 91, 0.35);
    --amber-line-2: rgba(227, 176, 91, 0.5);
    --red: #F27D85;
    --red-wash: rgba(242, 125, 133, 0.10);
    --red-wash-2: rgba(242, 125, 133, 0.08);
    --red-line: rgba(242, 125, 133, 0.45);
    --nrs-ok: #3FA37C;
    --nrs-mid: #E3B05B;
    --nrs-high: #E86A72;
    --on-gold: #081A2F;
    --on-ok: #052016;
    --on-red: #081A2F;
    --on-scale: #081A2F;
    --overlay: rgba(8, 26, 47, 0.96);
    --overlay-0: rgba(8, 26, 47, 0);
    --tabbar-bg: rgba(8, 26, 47, 0.94);
    --play-bg: rgba(8, 26, 47, 0.6);
    --play-ring: rgba(255, 255, 255, 0.5);
    --ph-1: #1C3D63;
    --ph-2: #11294A;
    --ph-3: #0A1D35;
    --ph-stripe: rgba(205, 183, 121, 0.04);
    --art-1: #1C3D63;
    --art-2: #0D233B;
    --path-end: #9A7A3A;
    --path-end-2: #D2A35A;
    --region-1: #F4F1E6;
    --region-2: #D8D4C8;
    --region-ink: #2E3E52;
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow: rgba(0, 0, 0, 0.45);
    --shadow-2: rgba(0, 0, 0, 0.4);
    --current-1: rgba(63, 163, 124, 0.16);
    --current-2: rgba(22, 54, 90, 0.55);
    --ctl-bg: #F4F1E6;
    --ctl-ink: #081A2F;
    --ctl-main-bg: #081A2F;
    --ctl-main-ink: #F9F1C6;
    color-scheme: dark;
}

/* ---------- Light (Kairos ivory) ---------- */
html[data-theme="light"] {
    --bg: #F5F1E8;
    --bg-2: #FAF7F0;
    --card: #FFFFFF;
    --card-2: #F1ECE0;
    --line: rgba(19, 41, 48, 0.10);
    --line-2: rgba(19, 41, 48, 0.18);
    --ink: #132930;
    --ink-2: #4A5A58;
    --ink-3: #5C6A68;
    --gold: #75591F;
    --gold-2: #6B4E17;
    --gold-wash: rgba(117, 89, 31, 0.10);
    --gold-wash-2: rgba(117, 89, 31, 0.06);
    --gold-ring: rgba(117, 89, 31, 0.30);
    --teal: #E6EFEC;
    --ok: #17694E;
    --ok-wash: rgba(23, 105, 78, 0.10);
    --ok-line: rgba(23, 105, 78, 0.45);
    --ok-line-2: rgba(23, 105, 78, 0.35);
    --amber: #7E5508;
    --amber-wash: rgba(126, 85, 8, 0.14);
    --amber-wash-2: rgba(126, 85, 8, 0.14);
    --amber-wash-3: rgba(126, 85, 8, 0.08);
    --amber-line: rgba(126, 85, 8, 0.35);
    --amber-line-2: rgba(126, 85, 8, 0.45);
    --red: #AE3540;
    --red-wash: rgba(174, 53, 64, 0.10);
    --red-wash-2: rgba(174, 53, 64, 0.06);
    --red-line: rgba(174, 53, 64, 0.40);
    --nrs-ok: #17694E;
    --nrs-mid: #7E5508;
    --nrs-high: #AE3540;
    --on-gold: #FFFFFF;
    --on-ok: #FFFFFF;
    --on-red: #FFFFFF;
    --on-scale: #FFFFFF;
    --overlay: rgba(245, 241, 232, 0.96);
    --overlay-0: rgba(245, 241, 232, 0);
    --tabbar-bg: rgba(250, 247, 240, 0.94);
    --play-bg: rgba(255, 255, 255, 0.75);
    --play-ring: rgba(117, 89, 31, 0.45);
    --ph-1: #FFFFFF;
    --ph-2: #F7F2E7;
    --ph-3: #EDE5D3;
    --ph-stripe: rgba(117, 89, 31, 0.05);
    --art-1: #FBF8F1;
    --art-2: #EDE5D3;
    --path-end: #8A5A1E;
    --path-end-2: #8A5A1E;
    --region-1: #FFFFFF;
    --region-2: #F1ECE0;
    --region-ink: #4A5A58;
    --scrim: rgba(19, 41, 48, 0.45);
    --shadow: rgba(19, 41, 48, 0.18);
    --shadow-2: rgba(19, 41, 48, 0.16);
    --current-1: rgba(23, 105, 78, 0.10);
    --current-2: rgba(241, 236, 224, 0.9);
    --ctl-bg: #132930;
    --ctl-ink: #FAF7F0;
    --ctl-main-bg: #FAF7F0;
    --ctl-main-ink: #75591F;
    color-scheme: light;
}

/* ---------- Classic (the v2 palette) ---------- */
html[data-theme="classic"] {
    --bg: #071A20;
    --bg-2: #0C2128;
    --card: #10282F;
    --card-2: #153139;
    --line: rgba(228, 203, 146, 0.12);
    --line-2: rgba(255, 255, 255, 0.08);
    --ink: #F2EEE6;
    --ink-2: #B8C2C2;
    --ink-3: #8C9A9B;
    --gold: #C7A25E;
    --gold-2: #E4CB92;
    --gold-wash: rgba(199, 162, 94, 0.14);
    --gold-wash-2: rgba(199, 162, 94, 0.08);
    --gold-ring: rgba(199, 162, 94, 0.35);
    --teal: #143A42;
    --ok: #4CBB90;
    --ok-wash: rgba(76, 187, 144, 0.10);
    --ok-line: rgba(76, 187, 144, 0.5);
    --ok-line-2: rgba(76, 187, 144, 0.35);
    --amber: #E0A43B;
    --amber-wash: rgba(224, 164, 59, 0.22);
    --amber-wash-2: rgba(224, 164, 59, 0.18);
    --amber-wash-3: rgba(224, 164, 59, 0.12);
    --amber-line: rgba(224, 164, 59, 0.35);
    --amber-line-2: rgba(224, 164, 59, 0.5);
    --red: #F2857B;
    --red-wash: rgba(242, 133, 123, 0.10);
    --red-wash-2: rgba(242, 133, 123, 0.08);
    --red-line: rgba(242, 133, 123, 0.45);
    --nrs-ok: #3FAE84;
    --nrs-mid: #E0A43B;
    --nrs-high: #E2655A;
    --on-gold: #0C2128;
    --on-ok: #06231A;
    --on-red: #071A20;
    --on-scale: #071A20;
    --overlay: rgba(7, 26, 32, 0.96);
    --overlay-0: rgba(7, 26, 32, 0);
    --tabbar-bg: rgba(7, 26, 32, 0.94);
    --play-bg: rgba(7, 26, 32, 0.6);
    --play-ring: rgba(255, 255, 255, 0.5);
    --ph-1: #1B4650;
    --ph-2: #0F2D35;
    --ph-3: #0A2127;
    --ph-stripe: rgba(228, 203, 146, 0.04);
    --art-1: #1B4650;
    --art-2: #0C2128;
    --path-end: #9A6B2F;
    --path-end-2: #C98A45;
    --region-1: #F4EEE2;
    --region-2: #D9D2C4;
    --region-ink: #4C5A5C;
    --scrim: rgba(0, 0, 0, 0.55);
    --shadow: rgba(0, 0, 0, 0.45);
    --shadow-2: rgba(0, 0, 0, 0.4);
    --current-1: rgba(63, 174, 132, 0.16);
    --current-2: rgba(20, 58, 66, 0.55);
    --ctl-bg: #F2EEE6;
    --ctl-ink: #0C2128;
    --ctl-main-bg: #0C2128;
    --ctl-main-ink: #E4CB92;
    color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: calc(1rem * var(--tx)); line-height: 1.45; -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
a { color: var(--gold-2); text-decoration: none; }
button { font: inherit; color: inherit; }
img, video { max-width: 100%; display: block; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); }
.page { padding-bottom: calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); }
.page.has-cta { padding-bottom: calc(var(--tabbar) + 100px + env(safe-area-inset-bottom)); }

/* ---------- top bars ---------- */
.top { padding: calc(14px + env(safe-area-inset-top)) 0 10px; background: var(--bg); position: sticky; top: 0; z-index: 20; }
.top .row { display: flex; align-items: center; gap: 12px; }
.top h1 { font-size: calc(1.5rem * var(--tx)); margin: 0; font-weight: 700; letter-spacing: -0.2px; flex: 1; min-width: 0; }
.top .title-sm { font-size: calc(1.0625rem * var(--tx)); font-weight: 700; text-align: center; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { color: var(--gold); font-weight: 700; letter-spacing: 3px; font-size: calc(0.75rem * var(--tx)); }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--card); border: 1px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--gold-wash); color: var(--gold-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; border: 1px solid var(--line); }
.hello { font-size: calc(1.3125rem * var(--tx)); line-height: 1.25; margin: 14px 0 4px; font-weight: 600; }
.hello em { font-style: normal; color: var(--gold-2); }

/* ---------- section heads ---------- */
.sec { margin: 26px 0 12px; display: flex; align-items: baseline; gap: 10px; }
.sec h2 { margin: 0; font-size: calc(1.1875rem * var(--tx)); font-weight: 700; padding-inline-start: 12px; border-inline-start: 3px solid var(--gold); line-height: 1.15; flex: 1; }
.sec a { font-size: calc(1rem * var(--tx)); color: var(--gold-2); text-decoration: underline; text-underline-offset: 3px; }
.sec-sub { color: var(--ink-3); font-size: calc(1rem * var(--tx)); margin-block: -6px 12px; margin-inline: 15px 0; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.gold { border-color: var(--line); }
.muted { color: var(--ink-3); font-size: calc(1rem * var(--tx)); }
.small { font-size: calc(0.875rem * var(--tx)); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: var(--pill); border: 1px solid var(--line); color: var(--ink-2); font-size: calc(0.8125rem * var(--tx)); background: var(--card); }
.chip.gold { border-color: var(--gold); color: var(--gold-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
/* A chip you can tap is a 44px target. */
a.chip, button.chip { min-height: 44px; padding-inline: 14px; cursor: pointer; justify-content: center; }
.pill { display: inline-block; padding: 2px 9px; border-radius: var(--pill); background: var(--gold-wash); color: var(--gold-2); font-size: calc(0.75rem * var(--tx)); font-weight: 600; letter-spacing: 0.3px; }
.pill.ok { background: var(--ok-wash); color: var(--ok); }
.pill.red { background: var(--red-wash); color: var(--red); }
/* Content still waiting for review, shown only in a clinician's preview. */
.pill.draft { background: var(--amber-wash-3); color: var(--amber); border: 1px solid var(--amber-line); vertical-align: middle; margin-inline-start: 4px; }
.article .pill.draft { margin-inline-start: 0; }

/* ---------- buttons ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; border-radius: var(--pill); padding: 15px 18px; font-size: calc(1rem * var(--tx)); font-weight: 700; cursor: pointer; text-align: center; background: var(--gold); color: var(--on-gold); }
.btn:active { transform: scale(0.99); }
.btn.ghost { background: transparent; color: var(--gold-2); border: 1.5px solid var(--gold); }
.btn.dark { background: var(--card-2); color: var(--ink); border: 1px solid var(--line-2); }
.btn[disabled] { opacity: 0.45; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- week strip ---------- */
.week { display: flex; justify-content: space-between; gap: 6px; margin: 16px 0 4px; }
.week .d { flex: 1 1 0; min-width: 0; text-align: center; }
.week .lbl { font-size: calc(0.75rem * var(--tx)); color: var(--ink-3); margin-bottom: 6px; }
.week .box { height: 34px; border-radius: 9px; border: 1.5px solid var(--line-2); display: flex; align-items: center; justify-content: center; font-size: calc(0.8125rem * var(--tx)); color: var(--ink-3); }
.week .box.full { background: var(--ok); border-color: var(--ok); color: var(--on-ok); }
.week .box.part { background: var(--amber-wash); border-color: var(--amber); color: var(--amber); }
.week .box.today { border-color: var(--gold); color: var(--gold-2); }
/* No fading: the day number keeps AA contrast (beta P11 P3). */
.week .box.future { opacity: 1; border-style: dashed; color: var(--ink-3); }
.week .d.is-today .lbl { color: var(--gold-2); font-weight: 700; }

/* ---------- hero / plan cards ---------- */
.hscroll { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin-block: 0; margin-inline: -16px; padding-block: 0 4px; padding-inline: 16px; scroll-padding-inline: 16px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.hscroll > * { scroll-snap-align: start; flex: none; }
.hero { position: relative; border-radius: 22px; overflow: hidden; background: var(--card); border: 1px solid var(--line); display: block; color: var(--ink); }
/* The title sits over the bottom of the media; a placeholder keeps its
 * ring in the top part so the two never meet (padding % = of the width). */
.hero .media { aspect-ratio: 4 / 3; }
.hero .ph { padding-block-end: 37%; }
.hero .ph .ring { width: 30%; max-width: 112px; }
.hero .has-play .play { top: 24.5%; }
.hero .over { position: absolute; inset: auto 0 0 0; padding: 16px; background: linear-gradient(to top, var(--overlay), var(--overlay-0)); }
.hero .over h3 { margin: 0 0 4px; font-size: calc(1.3125rem * var(--tx)); font-weight: 800; text-transform: uppercase; letter-spacing: 0.2px; line-height: 1.1; }
.hero .over .meta { color: var(--ink-2); font-size: calc(0.8125rem * var(--tx)); }
.hero.wide { width: 100%; }
.plan-card { width: 82%; max-width: 420px; }

/* ---------- media placeholder ---------- */
.ph { position: relative; width: 100%; height: 100%; background: radial-gradient(120% 90% at 20% 10%, var(--ph-1) 0%, var(--ph-2) 45%, var(--ph-3) 100%); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ph::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(135deg, var(--ph-stripe) 0 2px, transparent 2px 14px); }
.ph .ring { width: 38%; max-width: 120px; aspect-ratio: 1; border-radius: 50%; border: 2px solid var(--gold); display: flex; align-items: center; justify-content: center; background: var(--gold-wash-2); position: relative; z-index: 1; }
.ph .ring svg { width: 52%; height: 52%; color: var(--gold-2); }
.ph .mark { position: absolute; inset-inline-start: 12px; top: 10px; font-size: calc(0.75rem * var(--tx)); letter-spacing: 3px; color: var(--gold); font-weight: 700; z-index: 1; }
.ph .soon { position: absolute; inset-inline-end: 10px; bottom: 9px; font-size: calc(0.75rem * var(--tx)); color: var(--ink-3); z-index: 1; letter-spacing: 0.5px; }
.ph.sm .ring { width: 56%; }
.ph.sm .mark, .ph.sm .soon { display: none; }
.media { position: relative; overflow: hidden; background: var(--card-2); }
.media > img, .media > video { width: 100%; height: 100%; object-fit: cover; }
.play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 64px; height: 64px; border-radius: 50%; background: var(--play-bg); border: 1.5px solid var(--play-ring); display: flex; align-items: center; justify-content: center; z-index: 2; }
.play svg { width: 26px; height: 26px; margin-left: 4px; }
.has-play .ph .ring svg { visibility: hidden; }
.has-play .play { width: 72px; height: 72px; background: transparent; border: 0; color: var(--gold-2); }
.has-play .play svg { width: 34px; height: 34px; }

/* ---------- coach / score ---------- */
.coach-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.coach-top .brand { letter-spacing: 2px; }
.score { display: flex; align-items: center; gap: 16px; }
.score .big { font-size: calc(2.875rem * var(--tx)); font-weight: 800; letter-spacing: -1px; line-height: 1; }
.score .big small { font-size: calc(1.125rem * var(--tx)); color: var(--ink-3); font-weight: 600; }
.delta svg { width: 14px; height: 14px; }
.delta.down { color: var(--amber); }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 3px 9px; border-radius: var(--pill); background: var(--card-2); font-size: calc(0.75rem * var(--tx)); color: var(--ink-2); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 44px; margin-inline-start: auto; min-width: 0; }
.bars i { width: 6px; border-radius: 3px; background: var(--line-2); display: block; }
.bars i.on { background: var(--gold); }
.bars i.part { background: var(--amber); }
.alert { border-radius: 14px; padding: 14px; border: 1px solid var(--red-line); background: var(--red-wash-2); margin-top: 14px; }
.alert h4 { margin: 0 0 4px; font-size: calc(1rem * var(--tx)); display: flex; align-items: center; gap: 8px; }
.alert p { margin: 0; color: var(--ink-2); font-size: calc(1rem * var(--tx)); }

/* ---------- pain rule ---------- */
.card.pause { border-color: var(--red-line); background: linear-gradient(180deg, var(--red-wash-2), var(--card)); }
.card.pause h3 { margin-block: 0 6px; font-size: calc(1.125rem * var(--tx)); line-height: 1.25; }
.card.pause p { margin-block: 0 14px; color: var(--ink-2); font-size: calc(1rem * var(--tx)); }
/* "Message the clinic" lands on this card, clear of the sticky top bar. */
#contact { scroll-margin-block-start: 96px; }

/* ---------- pain scale (lo 0-3, mid 4-5, hi 6-10) ---------- */
.nrs { display: grid; grid-template-columns: repeat(11, 1fr); gap: 4px; margin: 10px 0 6px; }
.nrs button { min-height: 44px; border-radius: 10px; border: 1.5px solid; background: transparent; font-size: calc(0.9375rem * var(--tx)); font-weight: 700; cursor: pointer; padding: 0; }
.nrs button.lo { color: var(--nrs-ok); border-color: var(--nrs-ok); }
.nrs button.mid { color: var(--nrs-mid); border-color: var(--nrs-mid); }
.nrs button.hi { color: var(--nrs-high); border-color: var(--nrs-high); }
.nrs button.lo.sel { background: var(--nrs-ok); }
.nrs button.mid.sel { background: var(--nrs-mid); }
.nrs button.hi.sel { background: var(--nrs-high); }
.nrs button.sel { color: var(--on-scale); }
.nrs-legend { display: flex; justify-content: space-between; font-size: calc(0.75rem * var(--tx)); color: var(--ink-3); }
.saved-note { color: var(--ok); font-size: calc(1rem * var(--tx)); margin-top: 6px; display: none; }
.error-note { color: var(--red); font-size: calc(1rem * var(--tx)); margin-top: 6px; display: none; }
@media (max-width: 420px) { .nrs { grid-template-columns: repeat(6, 1fr); gap: 6px; } }

/* ---------- lists ---------- */
.ex-item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line-2); border-radius: 16px; padding: 8px; margin-bottom: 10px; color: var(--ink); }
.ex-item .thumb { width: 92px; height: 92px; border-radius: 12px; overflow: hidden; flex: none; }
.ex-item .txt { flex: 1; min-width: 0; padding-inline-end: 6px; }
.ex-item .nm { font-weight: 700; font-size: calc(1rem * var(--tx)); line-height: 1.25; overflow-wrap: anywhere; }
.ex-item .ds { color: var(--ink-3); font-size: calc(1rem * var(--tx)); margin-top: 4px; }
.ex-item .side { margin-top: 6px; }
.ex-item.done { border-color: var(--ok-line); }
.ex-item .tick { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: flex; align-items: center; justify-content: center; }
.ex-item.done .tick { background: var(--ok); border-color: var(--ok); }
.block-head { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 0 10px; }
.block-head h3 { margin: 0; font-size: calc(1.0625rem * var(--tx)); }
.block-head span { color: var(--ink-3); font-size: calc(0.75rem * var(--tx)); }

/* ---------- path ---------- */
.path { position: relative; display: flex; justify-content: space-between; padding: 6px 2px 0; }
.path::before { content: ""; position: absolute; left: 10%; right: 10%; top: 64px; height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--ok), var(--gold), var(--path-end)); }
[dir="rtl"] .path::before { background: linear-gradient(270deg, var(--ok), var(--gold), var(--path-end)); }
.path .stop { flex: 1 1 0; min-width: 0; text-align: center; position: relative; }
.path .nm { font-size: calc(0.75rem * var(--tx)); color: var(--ink-2); height: 44px; display: flex; align-items: center; justify-content: center; padding: 0 4px; line-height: 1.2; border: 1.5px solid transparent; border-radius: 10px; margin: 0 4px; }
.path .stop.cur .nm { border-color: var(--gold); color: var(--gold-2); font-weight: 700; }
.path .dot { width: 14px; height: 14px; border-radius: 50%; background: var(--ink-3); margin: 9px auto 0; position: relative; z-index: 1; border: 2px solid var(--bg); }
.path .stop.past .dot { background: var(--ok); }
.path .stop.cur .dot { background: var(--gold); box-shadow: 0 0 0 4px var(--gold-wash); }
.path-ends { display: flex; justify-content: space-between; font-size: calc(0.75rem * var(--tx)); margin-top: 10px; }
.path-ends .a { color: var(--ok); }
.path-ends .b { color: var(--path-end-2); }

/* ---------- stats row ---------- */
.stats { display: flex; align-items: center; justify-content: space-around; text-align: center; }
.stats .v { font-size: calc(1.25rem * var(--tx)); font-weight: 800; }
.stats .k { font-size: calc(0.75rem * var(--tx)); color: var(--ink-3); }
.stats .sep { width: 1px; height: 34px; background: var(--line-2); }
.progress-card { display: flex; gap: 14px; align-items: stretch; }
.streak { width: 96px; flex: none; border-radius: 14px; background: var(--card-2); border: 1px solid var(--line-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 10px 4px; }
.streak .n { font-size: calc(1.5rem * var(--tx)); font-weight: 800; }
.streak .k { font-size: calc(0.75rem * var(--tx)); color: var(--ink-3); text-align: center; }
.meter { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.meter .track { height: 8px; border-radius: 8px; background: var(--card-2); overflow: hidden; }
.meter .fill { height: 100%; border-radius: 8px; background: var(--ok); }
.meter .fill.gold { background: var(--gold); }
.meter .lbl { display: flex; justify-content: space-between; font-size: calc(0.75rem * var(--tx)); color: var(--ink-3); margin-top: 5px; }
.meter .lbl b { color: var(--ink); }

/* ---------- regions ---------- */
.region { width: 128px; text-align: center; }
.region .circ { width: 128px; height: 128px; border-radius: 22px; background: var(--card); border: 1px solid var(--line-2); display: flex; align-items: center; justify-content: center; }
.region .circ span { width: 98px; height: 98px; border-radius: 50%; border: 2px solid var(--gold); display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 40% 35%, var(--region-1), var(--region-2)); }
.region .circ svg { width: 62px; height: 62px; color: var(--region-ink); }
.region .nm { font-size: calc(0.8125rem * var(--tx)); margin-top: 8px; color: var(--ink-2); line-height: 1.25; }

/* ---------- calendar + pain chart ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .h { font-size: calc(0.75rem * var(--tx)); color: var(--ink-3); text-align: center; }
.cal .c { aspect-ratio: 1; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: calc(0.75rem * var(--tx)); background: var(--card-2); color: var(--ink-3); }
.cal .c.full { background: var(--ok); color: var(--on-ok); font-weight: 700; }
.cal .c.part { background: var(--amber-wash-2); color: var(--amber); }
.cal .c.future { background: transparent; border: 1px dashed var(--line-2); }
.cal .c.today { outline: 2px solid var(--gold); }
.chart { width: 100%; height: 120px; display: block; }
.chart .goal { stroke: var(--ok-line-2); }
.chart .trend { stroke: var(--gold); }
.chart .pt { fill: var(--gold-2); }

/* ---------- badges ---------- */
.badges { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.badge { text-align: center; }
.badge .b { width: min(58px, 100%); aspect-ratio: 1; height: auto; margin: 0 auto; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid var(--line-2); background: var(--card-2); color: var(--ink-3); }
.badge.on .b { border-color: var(--gold); color: var(--on-gold); background: radial-gradient(circle at 35% 30%, var(--gold-2), var(--gold)); }
.badge .b svg { width: 26px; height: 26px; }
.badge .t { font-size: calc(0.75rem * var(--tx)); color: var(--ink-3); margin-top: 6px; line-height: 1.2; }
.badge.on .t { color: var(--ink); }
.badge .pill.draft { margin: 4px 0 0; font-size: calc(0.75rem * var(--tx)); padding: 1px 6px; }
.badge-row { display: flex; align-items: center; gap: 14px; }
.badge-row .b { width: 52px; height: 52px; border-radius: 50%; border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--gold-2); flex: none; }

/* ---------- learn ---------- */
.learn-card { width: 76%; max-width: 360px; border-radius: 18px; overflow: hidden; background: var(--card); border: 1px solid var(--line-2); color: var(--ink); display: block; }
.learn-card .top-art { height: 116px; position: relative; background: linear-gradient(135deg, var(--art-1), var(--art-2) 70%); padding: 14px; display: flex; align-items: flex-end; }
.learn-card .top-art h3 { margin: 0; font-size: calc(1.125rem * var(--tx)); font-weight: 800; line-height: 1.15; position: relative; z-index: 1; }
.learn-card .top-art::after { content: ""; position: absolute; inset-inline-end: -24px; top: -24px; width: 120px; height: 120px; border-radius: 50%; border: 2px solid var(--gold-ring); }
.learn-card .foot { padding: 10px 14px; font-size: calc(0.75rem * var(--tx)); color: var(--ink-3); display: flex; justify-content: space-between; gap: 8px; }
.article p { font-size: calc(1rem * var(--tx)); line-height: 1.6; color: var(--ink-2); margin: 0 0 14px; }
.article h1 { font-size: calc(1.625rem * var(--tx)); line-height: 1.2; margin: 6px 0 14px; }
.tip { display: flex; gap: 12px; align-items: flex-start; }
.tip svg { width: 22px; height: 22px; color: var(--gold); flex: none; margin-top: 1px; }

/* ---------- exercise detail ---------- */
.detail-media { border-radius: 20px; overflow: hidden; aspect-ratio: 4 / 3; border: 1px solid var(--line); }
.ex-title { font-size: calc(1.375rem * var(--tx)); line-height: 1.2; margin: 14px 0 0; overflow-wrap: anywhere; }
.how h4 { margin: 18px 0 6px; color: var(--gold-2); font-size: calc(1rem * var(--tx)); letter-spacing: 1px; text-transform: uppercase; }
.how p { margin: 0; color: var(--ink-2); font-size: calc(1rem * var(--tx)); line-height: 1.55; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--tabbar-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line-2); padding-bottom: env(safe-area-inset-bottom); }
.tabbar .in { max-width: 640px; margin: 0 auto; display: flex; height: var(--tabbar); }
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--ink-3); font-size: calc(0.75rem * var(--tx)); font-weight: 600; position: relative; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.on { color: var(--gold-2); }
.tabbar a.on::before { content: ""; position: absolute; top: 0; width: 34px; height: 3px; border-radius: 0 0 3px 3px; background: var(--gold); }
.sticky-cta { position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); z-index: 30; padding: 10px 16px; background: linear-gradient(to top, var(--bg) 60%, var(--overlay-0)); }
.sticky-cta .btn { max-width: 608px; margin: 0 auto; }

/* ---------- banners ---------- */
.banner { border-radius: 14px; padding: 11px 14px; font-size: calc(1rem * var(--tx)); margin: 10px 0; }
.banner.ok { background: var(--ok-wash); color: var(--ok); border: 1px solid var(--ok-line-2); }
.banner.preview, .banner.amber { background: var(--amber-wash-3); color: var(--amber); border: 1px solid var(--amber-line); }

/* ---------- settings: theme switch ---------- */
.theme-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-block-start: 8px; }
.theme-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-block: 10px; padding-inline: 6px; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--card-2); color: var(--ink-2); font-size: calc(0.8125rem * var(--tx)); font-weight: 600; cursor: pointer; text-align: center; }
.theme-opt.sel { border-color: var(--gold); color: var(--ink); background: var(--gold-wash-2); }
.theme-opt .sw { width: 34px; height: 34px; border-radius: var(--pill); border: 3px solid; display: block; pointer-events: none; }
.sw-blue { background: var(--sw-blue-bg); border-color: var(--sw-blue-fg); }
.sw-light { background: var(--sw-light-bg); border-color: var(--sw-light-fg); }
.sw-classic { background: var(--sw-classic-bg); border-color: var(--sw-classic-fg); }

/* ---------- sheets (bottom drawers) ---------- */
.sheet-bg { position: fixed; inset: 0; background: var(--scrim); z-index: 80; display: none; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 81; background: var(--bg-2); border-radius: 24px 24px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; max-height: 88dvh; overflow-y: auto; transform: translateY(105%); visibility: hidden; transition: transform 0.25s ease, visibility 0s linear 0.25s; border-top: 1px solid var(--line); }
.sheet.open { transform: none; visibility: visible; transition: transform 0.25s ease, visibility 0s; }
.sheet .grab { width: 44px; height: 5px; border-radius: 5px; background: var(--line-2); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 4px; font-size: calc(1.3125rem * var(--tx)); }
.opt { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 16px; border: 1.5px solid var(--line-2); background: var(--card); margin-top: 10px; cursor: pointer; width: 100%; text-align: start; color: var(--ink); }
.opt.sel { border-color: var(--gold); background: var(--gold-wash-2); }
.opt .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--card-2); display: flex; align-items: center; justify-content: center; color: var(--gold-2); flex: none; }
.opt .ic svg { width: 22px; height: 22px; }
.opt .tx { flex: 1; }
.opt .tx b { display: block; font-size: calc(1rem * var(--tx)); }
.opt .tx span { color: var(--ink-3); font-size: calc(1rem * var(--tx)); display: block; }
.opt .rd { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ink-3); flex: none; }
.opt.sel .rd { border-color: var(--gold); background: radial-gradient(circle, var(--gold) 45%, transparent 50%); }
/* An on/off choice (hands-free, equipment-free) is a switch, not a radio,
 * so it never reads as a second pick in a group of radios. */
.opt.toggle .rd { width: 44px; height: 26px; border-radius: var(--pill); position: relative; background: var(--card-2); }
.opt.toggle .rd::after { content: ""; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-3); transition: inset-inline-start 0.15s ease; }
.opt.toggle.sel .rd { background: var(--gold); border-color: var(--gold); }
.opt.toggle.sel .rd::after { inset-inline-start: 21px; background: var(--on-gold); }
@media (prefers-reduced-motion: reduce) { .opt.toggle .rd::after { transition: none; } }

/* ---------- session player ---------- */
.player-top { position: sticky; top: 0; z-index: 30; background: var(--bg-2); padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line-2); }
.stop-btn { width: 44px; height: 44px; border-radius: 50%; background: var(--red); border: 0; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.stop-btn i { width: 14px; height: 14px; background: var(--on-red); border-radius: 2px; display: block; }
.elapsed { font-size: calc(1.625rem * var(--tx)); font-weight: 800; font-style: italic; font-variant-numeric: tabular-nums; flex: 1; }
.p-list { padding: 4px 0 140px; }
.p-block { margin: 18px 16px 8px; font-size: calc(1.0625rem * var(--tx)); font-weight: 700; }
.p-item { margin: 0 16px 10px; display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line-2); border-radius: 16px; padding: 8px; }
.p-item .thumb { width: 86px; height: 86px; border-radius: 12px; overflow: hidden; flex: none; }
.p-item .nm { font-weight: 700; font-size: calc(1rem * var(--tx)); }
.p-item .ds { color: var(--ink-3); font-size: calc(1rem * var(--tx)); margin-top: 3px; }
.p-item { cursor: pointer; }
/* Done rows: the picture fades, the text keeps AA contrast. */
.p-item.done .thumb { opacity: 0.55; }
.p-item.done .nm { color: var(--ink-2); }
.p-item.part { border-color: var(--amber-line-2); }
.p-item.done .nm::after { content: "  \2713"; color: var(--ok); }
.p-current { background: linear-gradient(180deg, var(--current-1), var(--current-2)); border-top: 2px solid var(--ok); border-bottom: 1px solid var(--line-2); padding: 18px 16px 22px; margin: 4px 0 12px; text-align: center; }
.p-current .tools { display: flex; justify-content: space-between; align-items: center; }
.p-current .tools button { background: transparent; border: 0; width: 44px; height: 44px; cursor: pointer; color: var(--ink-2); }
.p-current .tools svg { width: 26px; height: 26px; }
.p-current .med { width: 62%; max-width: 280px; aspect-ratio: 1; margin: -12px auto 10px; border-radius: 18px; overflow: hidden; }
.p-current .nm { font-size: calc(1.0625rem * var(--tx)); font-weight: 700; color: var(--ink); }
.p-current .note { font-size: calc(1rem * var(--tx)); color: var(--gold-2); margin-top: 4px; }
.p-current .clock { font-size: calc(4rem * var(--tx)); font-weight: 900; font-style: italic; letter-spacing: -1px; font-variant-numeric: tabular-nums; line-height: 1.05; margin-top: 8px; }
.p-current .clock.reps { font-style: normal; font-size: calc(3.5rem * var(--tx)); }
.p-current .clock.rest { color: var(--gold-2); }
.p-current .sub { color: var(--ink-2); font-size: calc(1rem * var(--tx)); font-weight: 600; margin-top: 4px; }
.p-current .done-set { margin: 16px auto 0; max-width: 260px; }
.controls { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 50; display: flex; align-items: center; gap: 6px; background: var(--ctl-bg); border-radius: var(--pill); padding: 8px 14px; box-shadow: 0 8px 30px var(--shadow); }
.controls button { width: 54px; height: 54px; border-radius: 50%; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ctl-ink); }
.controls button.main { background: var(--ctl-main-bg); color: var(--ctl-main-ink); }
.controls svg { width: 26px; height: 26px; }
.controls svg, .btn svg, .icon-btn svg, .tools svg { pointer-events: none; }
.finish { padding: 24px 16px 40px; }
.finish h1, .finish h2 { font-size: calc(1.625rem * var(--tx)); margin: 10px 0 6px; }
.big-check { width: 84px; height: 84px; border-radius: 50%; background: var(--ok); display: flex; align-items: center; justify-content: center; margin: 10px auto; }
.big-check svg { width: 44px; height: 44px; color: var(--on-ok); }
textarea { width: 100%; min-height: 76px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink); padding: 12px; font: inherit; font-size: calc(1rem * var(--tx)); }
.q { display: block; font-weight: 700; margin: 18px 0 2px; }
.check-list label { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line-2); }
.check-list label:first-child { border-top: 0; }
.check-list input { width: 24px; height: 24px; accent-color: var(--ok); flex: none; }
.foot-links { text-align: center; font-size: calc(1rem * var(--tx)); margin: 26px 0 8px; color: var(--ink-3); }
.foot-links a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
@media (min-width: 700px) { .plan-card { width: 60%; } }
/* The hero carries its own title; the placeholder caption would sit under it. */
.hero .ph .soon { display: none; }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet.open { transition: none; } }
:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
[dir="rtl"] svg.flip { transform: scaleX(-1); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(14px + env(safe-area-inset-top)); z-index: 90; background: var(--ok); color: var(--on-ok); font-weight: 700; font-size: calc(1rem * var(--tx)); padding: 10px 16px; border-radius: var(--pill); box-shadow: 0 6px 24px var(--shadow-2); }

/* ---------- v5: tap targets and large text (W8) ---------- */
/* Text links that stand on their own ("See program", "View all", "Sign
 * out", "My orders", "All my programs") get a 44 x 44 px target. Links
 * inside a sentence are left as they are. */
.sec a, .foot-links a, a.chip, button.chip, .top .chip {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; min-width: 44px; padding-inline: 6px;
}
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0 4px; }
/* Long names and addresses wrap instead of pushing the page sideways. */
.top h1, .top .title-sm, .ex-item .nm, .p-item .nm, .p-current .nm, .muted, .card { overflow-wrap: anywhere; }
.top .title-sm { white-space: normal; }
.top .row { flex-wrap: wrap; }
.p-item > div, .ex-item > div { min-width: 0; }
/* The tab bar keeps its five tabs on a narrow phone with large text:
 * the captions stay under the icons and wrap, never past the edge. */
.tabbar a { min-width: 0; padding-inline: 2px; text-align: center; line-height: 1.1;
            font-size: min(calc(0.75rem * var(--tx)), 15px); overflow-wrap: anywhere; }
.tabbar .in { height: auto; min-height: var(--tabbar); }
/* The pain scale 0-10: bigger buttons where the screen is narrow. */
@media (max-width: 360px) { .nrs { grid-template-columns: repeat(4, 1fr); } }
html.text-lg .nrs { grid-template-columns: repeat(4, 1fr); }
