/* =====================================================================
   Coach Kooom — UI language
   Clean & native (Strong / Hevy family) with one ember accent.
   Every page is built from the tokens and components below; see DESIGN.md.
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
/* Manrope (SIL OFL), loaded from Google Fonts in index.html: one variable family, weights 200–800. */

:root {
  /* colour — light */
  --bg: #F2F2F7;            /* grouped page background */
  --surface: #FFFFFF;       /* cells, cards, sheets */
  --fill: #E9E9EE;          /* segmented track, quiet buttons, inputs */
  --fill-strong: #DCDCE2;
  --label: #0B0B0C;         /* primary text */
  --label-2: #56565C;       /* secondary text */
  --label-3: #6B6B71;       /* tertiary text + placeholders */
  --separator: #D8D8DE;     /* hairlines between cells */
  --edge: #8A8A92;          /* input + control edges */
  --edge-soft: #C7C7CC;     /* quiet edges on the logging sheet */
  --accent: #C4421A;        /* ember */
  --on-accent: #FFFFFF;
  --primary-bg: #C4421A;    /* ember button, white text */
  --primary-fg: #FFFFFF;
  --done-bg: #FCEBE4;
  --done-fg: #8A2A0C;
  --danger: #C4151C;
  --success: #178A3E;       /* met — green check */
  --on-success: #FFFFFF;
  --danger-bg: #FDE7E7;
  --tone-good: #E6F6EC; --tone-ok: #FDF4D8; --tone-bad: #FDE7E7;   /* scan traffic lights, very light */
  --selected: #FFFFFF;      /* selected segment */
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 1px 1px rgba(0, 0, 0, .04);
  --overlay: rgba(11, 11, 12, .92);

  /* type */
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* type — body is 14.4px; each heavier level up is one full point (1pt = 1.333px) larger.
     Page titles are the one exception, kept clearly bigger so every page has a headline. */
  --pt: .09259rem;                                              /* 1pt at the reference size */
  --t-large: 700 calc(1rem + 6 * var(--pt))/1.15 var(--font);   /* 22.4px on a 14 Pro Max */
  --t-title: 700 calc(1rem + 2 * var(--pt))/1.25 var(--font);   /* 17.07px */
  --t-headline: 600 calc(1rem + 1 * var(--pt))/1.3 var(--font); /* 15.73px */
  --t-body: 400 1rem/1.4 var(--font);                           /* 14.4px */
  --t-sub: 400 calc(1rem - 1 * var(--pt))/1.4 var(--font);      /* 13.07px */
  --t-foot: 400 .8333rem/1.35 var(--font);                      /* 12px */

  /* space + shape */
  /* space + shape in rem so they scale with the screen (px values are at the 14 Pro Max) */
  --s1: .2778rem; --s2: .5556rem; --s3: .8333rem; --s4: 1.1111rem; --s5: 1.3889rem; --s6: 1.6667rem; --s7: 2.2222rem; /* 4 8 12 16 20 24 32 */
  --r-sm: .5556rem; --r: .8333rem;
  --tap: 44px;              /* touch floor: never scaled down */
  --box: 2.5rem;            /* logging boxes: 36px at reference */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --surface: #1C1C1E; --fill: #2C2C2E; --fill-strong: #3A3A3C;
    --label: #FFFFFF; --label-2: #C7C7CC; --label-3: #B8B8BE;
    --separator: #38383A; --edge: #7C7C82; --edge-soft: #545458; --edge-soft: #545458;
    --accent: #FF8A5C; --on-accent: #0B0B0C; --primary-bg: #FF8A5C; --primary-fg: #0B0B0C;
    --done-bg: #3A1A0E; --done-fg: #FFC4AC;
    --danger: #FF958F; --danger-bg: #3A1614; --tone-good: #10301D; --tone-ok: #332A0C; --tone-bad: #3A1614; --success: #3DDC84; --on-success: #0B0B0C;
    --selected: #4A4A4E; --shadow: none; --overlay: rgba(44, 44, 46, .96);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1C1C1E; --fill: #2C2C2E; --fill-strong: #3A3A3C;
  --label: #FFFFFF; --label-2: #C7C7CC; --label-3: #B8B8BE;
  --separator: #38383A; --edge: #7C7C82;
  --accent: #FF8A5C; --on-accent: #0B0B0C; --primary-bg: #FF8A5C; --primary-fg: #0B0B0C;
  --done-bg: #3A1A0E; --done-fg: #FFC4AC;
  --danger: #FF958F; --danger-bg: #3A1614; --tone-good: #10301D; --tone-ok: #332A0C; --tone-bad: #3A1614; --success: #3DDC84; --on-success: #0B0B0C;
  --selected: #4A4A4E; --shadow: none; --overlay: rgba(44, 44, 46, .96);
  color-scheme: dark;
}

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }
/* touch-action: manipulation turns off double-tap zoom (pinch zoom still works, for accessibility). */
/* Scaling (see SCALING.md): 1rem = 14.4px on the reference phone (iPhone 14 Pro Max, 430px wide) and
   shrinks in step with the screen: 14.4 × width ÷ 430 = 3.3488vw, never below 12.4px, never above 14.4px. */
html { font-size: clamp(12.4px, 3.3488vw, 14.4px); -webkit-text-size-adjust: 100%; scrollbar-width: none; touch-action: manipulation; overflow-x: clip; }
/* Pages only ever scroll up and down: nothing can push the page sideways (rows like chips still scroll inside themselves). */
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; }
body { margin: 0; background: var(--bg); color: var(--label); font: var(--t-body); -webkit-font-smoothing: antialiased; overflow-x: clip; overscroll-behavior-x: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
/* iPhone zooms when a focused field's text is under 16px; keep every field at 16px or more. */
input:not([type=checkbox]):not([type=radio]), select, textarea { font-size: max(16px, 1em); }
button { cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, h3, p { margin: 0; }
.num, input, .set-table, .table { font-variant-numeric: tabular-nums; }
::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--label); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg { flex: none; }

/* ---------- 3. Page layout ---------- */
.page { max-width: 600px; margin: 0 auto; padding: var(--s2) clamp(12px, 4vw, var(--s4)) 120px; min-height: 100vh; }
.page.wide { max-width: 760px; }

/* navigation bar */
.nav { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); min-height: var(--tap); margin-bottom: var(--s1); }
.nav-back { display: inline-flex; align-items: center; min-height: var(--tap); font: var(--t-body); margin-left: -8px; padding-right: var(--s2); }
.nav-back svg { width: 26px; height: 26px; }
.nav-brand { display: inline-flex; align-items: center; gap: var(--s2); font: var(--t-headline); font-weight: 700; letter-spacing: -0.01em; }
.nav-brand svg { width: 28px; height: 28px; color: var(--accent); }
/* Sign-in: the plate logo, large */
.signin-logo { display: flex; align-items: center; gap: var(--s3); color: var(--accent); margin-bottom: var(--s5); }
.signin-logo svg { width: 64px; height: 64px; }
.signin-logo span { font: var(--t-title); font-weight: 800; letter-spacing: -.01em; color: var(--label); }
.nav-actions { display: flex; align-items: center; gap: var(--s2); }
.nav-status { font: var(--t-foot); color: var(--label-2); }
.nav-status[data-state="error"] { color: var(--danger); text-align: right; max-width: 60vw; }

/* title block */
.title { margin: var(--s1) 0 var(--s5); }
.title h1 { font: var(--t-large); letter-spacing: -0.02em; }
.title p { font: var(--t-sub); color: var(--label-2); margin-top: var(--s1); }
.title-input {
  width: 100%; font: var(--t-large); letter-spacing: -0.02em; color: var(--label);
  border: 0; border-bottom: 1.5px solid var(--edge); background: transparent; padding: 0 0 2px; border-radius: 0; outline: none;
}
.title-input:focus { border-bottom-color: var(--label); }

/* sections */
.section { margin-top: var(--s7); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); padding: 0 var(--s4) var(--s2); }
.section-title { font: var(--t-foot); font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: .04em; }
.section-foot { font: var(--t-foot); color: var(--label-2); padding: var(--s2) var(--s4) 0; }
.stack > * + * { margin-top: var(--s3); }

/* ---------- 4. Components ---------- */

/* 4.1 grouped list + cell */
.group { background: var(--surface); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.cell { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); min-height: var(--tap); padding: 10px var(--s4); position: relative; }
.cell + .cell::before { content: ""; position: absolute; top: 0; left: var(--s4); right: 0; border-top: 1px solid var(--separator); }
a.cell:active, button.cell:active { background: var(--fill); }
@media (hover: hover) { a.cell:hover, button.cell:hover { background: var(--fill); } }
button.cell { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; }
.cell-lead { flex: none; display: flex; flex-direction: column; width: 92px; }
.cell-lead b { font: var(--t-headline); }
.cell-lead span { font: var(--t-foot); color: var(--label-2); }
.cell-main { flex: 1 1 120px; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cell-title { font: var(--t-body); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-title.strong { font: var(--t-headline); }
.cell-sub { font: var(--t-foot); color: var(--label-2); }
.cell-sub.bad { color: var(--danger); }
.cell-trail { flex: 0 1 auto; margin-left: auto; max-width: 100%; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: var(--s2); color: var(--label-2); font: var(--t-sub); }
.chevron { width: 16px; height: 16px; color: var(--label-3); }
.cell.action { font: var(--t-body); gap: var(--s2); }
.cell.action svg { width: 20px; height: 20px; }
.cell.danger .cell-title { color: var(--danger); }

/* 4.2 card */
.card { background: var(--surface); border-radius: var(--r); padding: var(--s4); box-shadow: var(--shadow); }

/* 4.3 buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 50px; padding: 0 var(--s5); border: 0; border-radius: var(--r);
  background: var(--primary-bg); color: var(--primary-fg); font: var(--t-headline); text-align: center;
}
.btn svg { width: 18px; height: 18px; }
.btn-block { display: flex; width: 100%; }
.btn-secondary { background: var(--fill); color: var(--label); }
.btn-plain { background: transparent; color: var(--label); padding: 0 var(--s2); min-height: var(--tap); font-weight: 600; }
.btn-sm { min-height: 36px; padding: 0 var(--s3); font: var(--t-sub); font-weight: 600; border-radius: var(--r-sm); }
.btn:disabled { opacity: .45; }
.btn-row { display: flex; gap: var(--s2); }
.btn-row > * { flex: 1; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--box); height: var(--box);
  border: 0; border-radius: var(--r-sm); background: var(--fill); color: var(--label);
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:disabled { color: var(--label-3); opacity: .5; }
.icon-btn.danger { color: var(--danger); background: var(--danger-bg); }
.icon-btn.bare { background: transparent; width: var(--tap); height: var(--tap); }
.icon-btn.bare svg { width: 24px; height: 24px; }
.edit-btn { font: var(--t-body); color: var(--label); background: transparent; border: 0; min-height: var(--tap); padding: 0 var(--s1); }
.edit-btn[aria-pressed="true"] { font-weight: 700; }

/* 4.4 segmented control — every tab bar and two-way choice */
.segmented { display: flex; gap: 2px; padding: 2px; background: var(--fill); border-radius: 10px; }
.segmented button {
  flex: 1; min-height: 34px; padding: 0 var(--s3); border: 0; border-radius: 8px; background: transparent;
  font: var(--t-sub); font-weight: 500; color: var(--label); white-space: nowrap;
}
.segmented button[aria-selected="true"], .segmented button[aria-pressed="true"] {
  background: var(--selected); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.segmented.scroll { overflow-x: auto; scrollbar-width: none; }
.segmented.scroll::-webkit-scrollbar { display: none; }
.segmented.scroll button { flex: 1 0 auto; padding: 0 9px; }

/* 4.5 chips — many options */
.chips { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--edge); background: transparent; font: var(--t-sub); font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--label); border-color: var(--label); color: var(--bg); }

/* 4.6 form fields */
/* Fields are soft filled shapes (the segmented control's look); focus turns them white with an ember ring. */
.field {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1.5px solid transparent; border-radius: var(--r-sm);
  background: var(--fill); color: var(--label); font: var(--t-body); outline: none; transition: background .15s, border-color .15s, box-shadow .15s;
}
.field:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.field-lg { min-height: 56px; font-size: 20px; font-weight: 600; }
.field-code { letter-spacing: .08em; text-transform: uppercase; }
textarea.field { min-height: 96px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: var(--label-3); opacity: 1; font-weight: 400; }
.field-label { display: block; font: var(--t-foot); font-weight: 600; color: var(--label-2); margin-bottom: 6px; }
.inline-input {
  width: 120px; max-width: 100%; min-height: 36px; padding: 0 10px; text-align: right; border: 1.5px solid transparent; border-radius: var(--r-sm);
  background: var(--fill); color: var(--label); font: var(--t-body); font-weight: 600; outline: none; transition: background .15s, border-color .15s, box-shadow .15s;
}
.inline-input.wide { width: 100%; text-align: left; }
.inline-input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.select {
  -webkit-appearance: none; appearance: none; min-height: 36px; width: 160px; max-width: 100%; padding: 0 30px 0 12px;
  border: 0; border-radius: var(--r-sm); color: var(--label);
  background: var(--fill) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A8A92' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 8px center / 14px;
  font: var(--t-sub); font-weight: 600;
}
.stepper { display: inline-flex; align-items: center; border-radius: var(--r-sm); background: var(--fill); }
.stepper button { width: 36px; height: 34px; border: 0; background: transparent; font-size: 20px; line-height: 1; color: var(--label); }
.stepper button:disabled { color: var(--label-3); }
.stepper output { min-width: 26px; text-align: center; font: var(--t-headline); }

/* 4.7 switch */
.switch { display: inline-flex; align-items: center; gap: var(--s3); cursor: pointer; font: var(--t-sub); color: var(--label-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 51px; height: 31px; border-radius: 999px; background: var(--fill-strong); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch input:checked + .track { background: var(--primary-bg); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--label); outline-offset: 2px; }

/* 4.8 badges */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 999px; font: var(--t-foot); font-weight: 600; white-space: nowrap; }
.badge svg { width: 13px; height: 13px; }
.badge-done { background: var(--done-bg); color: var(--done-fg); }
.badge-miss { background: var(--danger-bg); color: var(--danger); }
.badge-today { background: var(--label); color: var(--bg); }
.badge-neutral { background: var(--fill); color: var(--label-2); }
.badge-accent { background: var(--accent); color: var(--on-accent); }

/* 4.9 stats */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); }
.stat { background: var(--surface); border-radius: var(--r); padding: var(--s3) var(--s4); box-shadow: var(--shadow); min-width: 0; }
.stat b { display: block; font: var(--t-title); }
.stat span { font: var(--t-foot); color: var(--label-2); }
.stat .bad { color: var(--danger); }

/* 4.10 avatar */
.avatar { width: var(--box); height: var(--box); border-radius: 50%; display: grid; place-items: center; background: var(--fill); font: var(--t-foot); font-weight: 700; flex: none; color: var(--label); }

/* 4.11 progress */
.progress { position: relative; height: 6px; border-radius: 999px; background: var(--fill); margin: var(--s3) 0 var(--s6); }
.progress-fill { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--label); }
.progress-mark { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--edge); }
.progress-mark span { background: var(--surface); padding: 0 2px; position: absolute; top: 15px; left: 50%; transform: translateX(-50%); font: var(--t-foot); color: var(--label-2); white-space: nowrap; }
.progress-mark:last-child span { left: auto; right: 0; transform: none; }

/* 4.12 week navigator */
.week-nav { display: grid; grid-template-columns: var(--tap) 1fr var(--tap); align-items: center; margin-bottom: var(--s3); }
.week-today { text-align: center; font: var(--t-sub); font-weight: 600; color: var(--label-2); margin-bottom: var(--s1); }
.week-nav .label { text-align: center; }
.week-nav .label b { display: block; font: var(--t-title); }
.week-nav .label span { font: var(--t-foot); color: var(--label-2); }
.day-step { margin: 0 0 var(--s2); }
.day-step .label b { font: var(--t-headline); }

/* 4.13 exercise + set table — the logging surface */
.exercise { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow), inset 0 0 0 1px var(--separator); padding: var(--s4) var(--s4) var(--s2); }
.exercise + .exercise { margin-top: var(--s3); }
.exercise-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s3); }
.exercise-name { font: var(--t-headline); font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere; }
.exercise-note { font: var(--t-foot); color: var(--label-2); margin-top: 2px; }
.exercise-target { font: var(--t-sub); font-weight: 600; color: var(--label-2); white-space: nowrap; }
.set-head, .set-row { display: grid; grid-template-columns: 1.75rem minmax(0, 1fr) 3.5rem minmax(0, 1fr) var(--box) 2.75rem; align-items: center; gap: var(--s2); }
.set-head { font: var(--t-foot); font-weight: 600; color: var(--label); padding-bottom: var(--s1); }
.set-head span:nth-child(3), .set-head span:nth-child(4), .set-head span:nth-last-child(2) { text-align: center; }
.set-row { min-height: 3.25rem; margin: 0 calc(var(--s2) * -1); padding: 0 var(--s2); border-radius: var(--r-sm); }
.set-row.is-done { background: var(--done-bg); }
.set-num { font: var(--t-headline); text-align: center; color: var(--label-2); }
.set-prev { font: var(--t-sub); color: var(--label-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-input {
  width: 100%; height: var(--box); padding: 0 4px; text-align: center; border: 1.5px solid transparent; border-radius: var(--r-sm);
  background: var(--fill); color: var(--label); font: var(--t-headline); outline: none; transition: background .15s, border-color .15s, box-shadow .15s;
}
.set-input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.set-input.fail { color: var(--danger); }
.set-input:disabled { -webkit-text-fill-color: var(--label); opacity: 1; }
.set-row.is-done .set-input { background: color-mix(in srgb, var(--surface) 60%, transparent); }
.set-row.is-done .set-input:focus { background: var(--surface); }
/* F (failure) and RPE sit between Reps and the check */
.set-fail { width: var(--box); height: var(--box); border: 1.5px solid transparent; border-radius: var(--r-sm); background: var(--fill); color: var(--label-2); font: var(--t-headline); font-weight: 800; }
.set-fail[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.set-rpe { padding: 0 2px; }
.fail-line { display: flex; align-items: center; gap: var(--s2); font: var(--t-sub); color: var(--label-2); margin-bottom: var(--s2); }
.set-table.no-prev .set-head, .set-table.no-prev .set-row { grid-template-columns: 1.75rem minmax(0, 1fr) minmax(0, 1fr) var(--box) 2.75rem; }
.set-table.no-prev .set-head span:nth-child(2), .set-table.no-prev .set-head span:nth-child(3) { text-align: center; }
.exercise-actions { display: flex; gap: var(--s4); align-items: center; padding-top: var(--s1); }
.exercise-actions .icon-btn { margin-left: auto; }
.exercise-actions .btn-plain.muted { color: var(--label-2); }
.exercise-actions .btn-plain { font: var(--t-sub); font-weight: 600; padding: 0 var(--s1); gap: 6px; }
.exercise-actions .btn-plain svg { width: 18px; height: 18px; }

/* edit mode — the coach session is always editable but reads as plain text until touched */
.exercise.editing .edit-fields > .inline-input.wide { font: var(--t-title); font-weight: 700; letter-spacing: -.01em; background: transparent; border-color: transparent; padding-left: 0; }
.exercise.editing .edit-fields > .inline-input.wide:focus { background: var(--fill); border-color: var(--edge); padding-left: var(--s2); }
.edit-top { display: flex; align-items: center; gap: var(--s1); }
.edit-top .inline-input.wide { flex: 1; min-width: 0; font: var(--t-headline); font-weight: 700; letter-spacing: -.01em; background: transparent; border-color: transparent; padding-left: 0; }
.ex-name-edit { resize: none; overflow: hidden; line-height: 1.3; padding-top: 6px; padding-bottom: 6px; max-height: calc(2 * 1.3em + 14px); field-sizing: content; text-align: left; }
.edit-top .inline-input.wide:focus { background: var(--fill); border-color: var(--edge); padding-left: var(--s2); }
.edit-top .icon-btn { background: transparent; width: 40px; height: 40px; }
.edit-top .icon-btn:not(.danger) { color: var(--label-2); }
.edit-top .icon-btn:disabled { opacity: .3; }
.edit-specs { display: flex; align-items: center; gap: var(--s2); margin-bottom: var(--s1); }
.edit-specs .stepper { border: 0; background: var(--fill); border-radius: var(--r-sm); }
.edit-specs .stepper button { width: 40px; height: 40px; }
.edit-specs .spec-in { border: 0; background: var(--fill); height: 40px; font: var(--t-headline); }
.edit-specs .spec-in:focus { box-shadow: 0 0 0 2px var(--label); background: var(--surface); }
/* Skipped exercise: the switch under the note; the sets fade so the day still reads at a glance */
.ex-skip { margin: 0 0 var(--s2); }
.exercise.is-skipped .set-table, .exercise.is-skipped .set-add { opacity: .35; }
.ex-note-theirs { margin-top: var(--s2); font: var(--t-sub); color: var(--label-2); }
.ex-note-theirs b { color: var(--label); font-weight: 600; }
.set-add { display: inline-flex; align-items: center; gap: var(--s1); min-height: var(--tap); padding: 0; border: 0; background: transparent; color: var(--accent); font: var(--t-sub); font-weight: 600; }
.set-add svg { width: 1.1rem; height: 1.1rem; }
.edit-fields > .exercise-target { margin: 0; text-align: left; }
textarea.field.ex-note { min-height: 2.75rem; margin: var(--s1) 0 var(--s2); padding: var(--s2) var(--s3); resize: none; border-color: var(--edge-soft); font: var(--t-sub); field-sizing: content; max-height: 8rem; }
.spec-x { color: var(--label-2); font: var(--t-sub); }
.spec-in { width: 56px; text-align: center; }
.spec-rest { margin-left: auto; display: flex; align-items: center; gap: 4px; font: var(--t-sub); color: var(--label-2); }
.edit-fields { display: grid; gap: var(--s2); margin-bottom: var(--s3); }
.edit-line { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.edit-line .label { font: var(--t-sub); color: var(--label-2); }
.edit-tools { display: flex; gap: var(--s1); }
.plan-summary { font: var(--t-sub); color: var(--label-2); }

/* 4.14 checklist */
.check-cell { cursor: pointer; }
.checkbox { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--edge); display: grid; place-items: center; flex: none; color: var(--on-accent); }
.checkbox svg { width: 14px; height: 14px; opacity: 0; }
.check-cell[aria-checked="true"] .checkbox { background: var(--accent); border-color: var(--accent); }
.check-cell[aria-checked="true"] .checkbox svg { opacity: 1; }

/* 4.15 calendar */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--s3); }
.cal-head b { font: var(--t-headline); display: block; }
.cal-head span { font: var(--t-foot); color: var(--label-2); }
.cal-head .bad { color: var(--danger); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-dow { font: var(--t-foot); font-weight: 600; color: var(--label-2); padding-bottom: 4px; }
.cal-day { aspect-ratio: 1; width: 100%; max-width: 42px; margin: 0 auto; display: grid; place-items: center; border-radius: 50%; font: var(--t-sub); color: var(--label-2); }
.cal-day.sched { color: var(--label); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--edge); }
.cal-day.done { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.cal-day.miss { background: var(--danger-bg); color: var(--danger); }
.cal-day.miss svg { width: 18px; height: 18px; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--label); color: var(--label); font-weight: 700; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s4); margin-top: var(--s3); font: var(--t-foot); color: var(--label-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.legend .done { background: var(--accent); }
.legend .miss { background: var(--danger); }
.legend .sched { box-shadow: inset 0 0 0 1.5px var(--edge); }

/* 4.16 chart */
.chart svg { width: 100%; height: auto; display: block; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s2); }
.chart-head b { font: var(--t-headline); }
.chart-head span { font: var(--t-foot); color: var(--label-2); }

/* 4.17 data table (history, assessments) */
.table-wrap { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow-x: auto; }
.table { border-collapse: separate; border-spacing: 0; min-width: 100%; font: var(--t-sub); }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--separator); white-space: nowrap; }
.table tr:last-child > * { border-bottom: 0; }
.table thead th { font: var(--t-foot); font-weight: 600; color: var(--label-2); }
.table tbody th { font-weight: 600; }
.table th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; box-shadow: 1px 0 0 var(--separator); }
.table td span { display: block; line-height: 1.6; }
.table .fail { color: var(--danger); }
.table .muted { color: var(--label-3); }
.table .col-btn { border: 0; background: transparent; padding: 0; text-align: left; font: var(--t-foot); font-weight: 700; color: var(--label); min-height: 36px; }
.table .col-btn small { display: block; font-weight: 400; color: var(--label-2); }
.table input { width: 72px; min-height: 36px; text-align: center; border: 1px solid var(--edge); border-radius: var(--r-sm); background: var(--surface); color: var(--label); font: var(--t-sub); }
.table input[type="date"] { width: 146px; text-align: left; padding: 0 6px; font: var(--t-foot); }

/* 4.18 notes */
.note-from { font: var(--t-foot); font-weight: 600; color: var(--label-2); margin-bottom: 4px; }
.note-text { font: var(--t-body); }
.note-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s3); flex-wrap: wrap; }

/* 4.19 empty state + notice */
.empty { text-align: center; padding: var(--s7) var(--s4); color: var(--label-2); font: var(--t-sub); }
.empty .btn { margin-top: var(--s3); }
.notice { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--surface); box-shadow: var(--shadow); font: var(--t-sub); }

/* 4.20 coach/client preview bar — static, never overlaps content */
.view-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s1) 0 var(--s2); }
.view-bar > span { font: var(--t-foot); color: var(--label-2); }
.view-bar .segmented { width: 176px; }

/* 4.21 theme toggle */
.theme { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px; border-radius: 999px; border: 0; background: var(--fill); font: var(--t-foot); font-weight: 600; }
.theme svg { width: 16px; height: 16px; }

/* 4.22 sticky footer action */
.sticky-foot { position: fixed; left: 0; right: 0; bottom: 0; padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, transparent); z-index: 5; }
.sticky-foot .btn { max-width: 568px; margin: 0 auto; }

/* ---------- 5. Page compositions ---------- */
.signin { min-height: calc(100vh - 140px); display: flex; flex-direction: column; justify-content: center; }
.signin .title h1 { font-size: clamp(24px, 6.5vw, 30px); line-height: 1.1; }
.signin .stack { margin-top: var(--s2); }
.pw-wrap { position: relative; }
.pw-wrap .field { padding-right: 84px; }
.pw-wrap .btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }
.error { color: var(--danger); font: var(--t-sub); }
.hint { font: var(--t-foot); color: var(--label-2); }
.center { text-align: center; }
.code { font: var(--t-title); letter-spacing: .06em; }
.weigh-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: var(--s2); align-items: center; }
@media (max-width: 420px) { .weigh-form { grid-template-columns: 1fr 1fr; } .weigh-form .btn { grid-column: 1 / -1; } }

/* ---------- 6. Prototype screen switcher (not part of the product) ---------- */
.proto { position: fixed; right: var(--s3); bottom: calc(var(--s3) + env(safe-area-inset-bottom)); z-index: 20; display: flex; flex-direction: column; align-items: flex-end; gap: var(--s2); }
.proto-toggle { min-height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--overlay); color: #fff; font: var(--t-foot); font-weight: 600; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.proto-menu { display: none; flex-direction: column; min-width: 200px; padding: 6px; border-radius: var(--r); background: var(--overlay); box-shadow: 0 8px 28px rgba(0, 0, 0, .3); }
.proto.open .proto-menu { display: flex; }
.proto-menu a { color: #fff; padding: 10px 12px; border-radius: var(--r-sm); font: var(--t-sub); }
.proto-menu a.on { background: rgba(255, 255, 255, .18); font-weight: 600; }
.sticky-foot ~ .proto, body.has-foot .proto { bottom: calc(84px + env(safe-area-inset-bottom)); }

/* ---------- 7. Motion ---------- */
.fade { animation: fade .2s ease-out; }
.no-anim .fade, .no-anim .sheet { animation: none; }
.no-anim .sheet.sheet-in { animation: sheet-up .22s cubic-bezier(.25, 1, .5, 1); }
.no-anim .chart-sheet { animation: none; }
.no-anim .chart-sheet.in { animation: sheet-full .3s cubic-bezier(.25, 1, .5, 1); }
@keyframes sheet-full { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { transform: scale(.85); } to { transform: scale(1); } }
.focus-set.just-done .btn-done, .set-card.just-done .btn-done { animation: pop .25s cubic-bezier(.25, 1, .5, 1); }
.met-btn.just-set { animation: metpop .32s cubic-bezier(.25, 1, .5, 1); }
@keyframes metpop { 0% { transform: scale(.7); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .sheet, .no-anim .sheet.sheet-in, .chart-sheet, .no-anim .chart-sheet.in, .fade, .focus-set.just-done .btn-done, .set-card.just-done .btn-done, .met-btn.just-set { animation: none; }
  .switch .track, .switch .track::after, .rest-fill, .met-btn { transition: none; }
}
.mode-bar { margin-top: var(--s5); }

/* ---------- 8. Client workout styles (coach picks one) ---------- */
.style-bar { display: grid; gap: var(--s3); margin-bottom: var(--s4); box-shadow: inset 0 0 0 1.5px var(--edge); }
.style-bar b { display: block; font: var(--t-headline); }
.style-bar span { font: var(--t-foot); color: var(--label-2); }
.btn-done { background: var(--accent); color: var(--on-accent); }

/* Focus: one exercise per screen */
.focus-top { display: grid; gap: var(--s2); font: var(--t-foot); font-weight: 600; color: var(--label-2); }
.progress.thin { height: 4px; margin: 0; }
.focus-name { font: var(--t-title); }
.focus-set { padding: var(--s3); border-radius: var(--r); background: var(--bg); }
.focus-set.is-done { background: var(--done-bg); }
.focus-set-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s3); }
.focus-set-head b { font: var(--t-headline); }
.focus-set-head span { font: var(--t-foot); color: var(--label-2); }
.focus-controls { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-bottom: var(--s3); }
.big-stepper { display: grid; grid-template-columns: 40px 1fr 40px; align-items: center; background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r); overflow: hidden; }
.big-stepper button { height: 56px; border: 0; background: transparent; color: var(--label); display: grid; place-items: center; }
.big-stepper button svg { width: 20px; height: 20px; }
.big-stepper button:active { background: var(--fill); }
.big-stepper label { display: flex; flex-direction: column; align-items: center; }
.big-value { width: 100%; border: 0; background: transparent; text-align: center; font: 700 24px/1.1 var(--font); color: var(--label); outline: none; padding: 0; }
.big-value.fail { color: var(--danger); }
.big-stepper small { font: var(--t-foot); color: var(--label-2); }
.big-stepper:focus-within { border-color: var(--label); }
.focus-nav { margin-top: var(--s4); }

/* Cards: each set is a card */
.set-card { padding: var(--s3); border-radius: var(--r); background: var(--bg); }
.set-card.is-done { background: var(--done-bg); }
.set-card-head { display: flex; justify-content: space-between; align-items: center; min-height: 24px; margin-bottom: var(--s2); }
.set-card-head b { font: var(--t-headline); }
.set-card-fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); margin-bottom: var(--s3); }
.big-box { display: flex; flex-direction: column; gap: 2px; padding: var(--s2) var(--s3); background: var(--surface); border: 1px solid var(--edge); border-radius: var(--r); }
.big-box span { font: var(--t-foot); font-weight: 600; color: var(--label-2); }
.big-box input { border: 0; background: transparent; padding: 0; font: 700 24px/1.1 var(--font); color: var(--label); outline: none; width: 100%; }
.big-box input.fail { color: var(--danger); }
.big-box small { font: var(--t-foot); color: var(--label-2); }
.big-box:focus-within { border-color: var(--label); }

/* ---------- 9. Client profile form ---------- */
img.avatar { object-fit: cover; padding: 0; }
.avatar-xl { width: 88px; height: 88px; font: var(--t-title); }
.photo-picker { display: flex; align-items: center; gap: var(--s4); }
.photo-picker .btn-row { flex-wrap: wrap; }
.profile-head { display: flex; align-items: center; gap: var(--s4); margin: var(--s1) 0 var(--s5); }
.cell-trail:has(.inline-input.form) { flex: 1; justify-content: flex-end; min-width: 0; }
.inline-input.form { width: 100%; max-width: 240px; }
.cell-trail > span:not(.stepper):not(.chevron):not(.badge) { font: var(--t-sub); color: var(--label-2); }
.day-chips { margin-top: var(--s2); flex-wrap: wrap; overflow: visible; }
.day-chips .chip { min-width: 52px; padding: 0 10px; }
.lift-row { gap: var(--s2); }
.lift-row .lift-name { flex: 1; width: auto; min-width: 0; text-align: left; }
.lift-row .lift-num { width: 64px; text-align: center; padding: 0 4px; }
.day-plan { gap: var(--s2); flex-wrap: wrap; }
.day-plan .cell-lead { width: 44px; }
.day-plan .inline-input.wide { flex: 1; width: auto; min-width: 120px; }
.day-plan .segmented { flex: none; }
.day-plan .segmented button { min-height: 32px; padding: 0 10px; font: var(--t-foot); font-weight: 600; }
.section-head .btn-sm { min-height: 32px; }
.unit-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) 0 var(--s2); }
.unit-head .section-foot { padding: 0 var(--s4); }
.unit-seg { width: 116px; }
.unit-seg button { min-height: 30px; font: var(--t-foot); font-weight: 600; }

/* ---------- 10. Program builder ---------- */
.day-badge { display: inline-grid; place-items: center; width: 48px; height: 32px; border-radius: 8px; font: var(--t-foot); font-weight: 700; letter-spacing: .04em; flex: none; }
.day-coach { background: var(--accent); color: var(--on-accent); }
.day-solo { background: var(--label); color: var(--bg); }
.day-off { box-shadow: inset 0 0 0 1.5px var(--edge); color: var(--label-2); }
.cell.rest .cell-title { color: var(--label-2); }
.cell.rest .cell-sub { color: var(--label-2); }
.loading { padding: var(--s7) 0; text-align: center; color: var(--label-2); font: var(--t-sub); }

.sec-empty { display: flex; }
.item-row { gap: var(--s2); }
.item-row .num-idx { width: 22px; text-align: center; font: var(--t-headline); color: var(--label-2); flex: none; }
.item-row .inline-input.wide { flex: 1; min-width: 0; }
.item-row .detail { width: 110px; flex: none; }
.item-tools { display: flex; gap: 2px; flex: none; }
.item-tools .icon-btn { width: 32px; height: 32px; }
.add-row { display: flex; gap: var(--s2); padding: var(--s3) var(--s4); }
.add-row .field { flex: 1; }
.suggest { display: grid; }
.suggest button { text-align: left; border: 0; background: transparent; padding: 10px var(--s4); font: var(--t-body); border-top: 1px solid var(--separator); }
.suggest button small { color: var(--label-2); font: var(--t-foot); margin-left: 6px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 30; display: flex; align-items: center; gap: var(--s3); padding: 10px 10px 10px 16px; border-radius: var(--r); background: var(--overlay); color: #fff; font: var(--t-sub); box-shadow: 0 8px 28px rgba(0,0,0,.3); }
.toast .btn { background: var(--accent); color: var(--on-accent); }
@media (min-width: 900px) { .page.builder { max-width: 1100px; } .builder-grid { display: grid; grid-template-columns: 320px 1fr; gap: var(--s6); align-items: start; } .builder-grid > aside { position: sticky; top: var(--s4); } }

.ex-panel { padding: var(--s3) var(--s4) var(--s4); background: var(--bg); border-top: 1px solid var(--separator); display: grid; gap: var(--s3); }
.ex-panel .edit-line { justify-content: flex-start; }
.set-grid { display: grid; grid-template-columns: 40px 1fr 1fr; gap: var(--s2); align-items: center; }
.set-grid span { font: var(--t-foot); color: var(--label-2); }
.set-grid input { min-height: 40px; text-align: center; }
.rest-presets { display: flex; gap: var(--s1); flex-wrap: wrap; }
.alt-list { display: flex; flex-wrap: wrap; gap: var(--s2); }
.alt-list .chip { display: inline-flex; align-items: center; gap: 4px; }

/* =====================================================================
   11. Sessions — add row, swap chips, rest timer
   ===================================================================== */
.s-add { display: flex; gap: var(--s2); }
.s-add .field { flex: 1; min-width: 0; }
.swap-chips { margin: 0 0 var(--s3); }
.exercise-target small { display: block; margin-top: 2px; font: var(--t-foot); color: var(--label-2); text-align: right; }
.exercise-note.link { display: inline-block; color: var(--label); text-decoration: underline; text-underline-offset: 2px; }

.rest-bar {
  position: fixed; left: var(--s4); right: var(--s4); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 30;
  max-width: 568px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--s2) var(--s3);
  padding: 12px 12px 12px 16px; border-radius: var(--r); background: var(--overlay); color: #fff; box-shadow: 0 8px 28px rgba(0,0,0,.3);
}
.rest-main { display: flex; flex-direction: column; min-width: 0; }
.rest-label { font: var(--t-sub); opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rest-time { font-size: 28px; line-height: 1.1; font-weight: 700; }
.rest-track { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: rgba(255,255,255,.22); overflow: hidden; }
.rest-fill { height: 100%; background: var(--accent); transform-origin: left center; transition: transform .25s linear; }
.rest-bar .btn { background: var(--accent); color: var(--on-accent); min-height: 44px; }
.rest-bar .btn.btn-secondary { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.5); }
.rest-bar.is-done { background: var(--accent); color: var(--on-accent); }
.rest-bar.is-done .rest-fill { background: var(--on-accent); }
.rest-bar.is-done .btn, .rest-bar.is-done .btn.btn-secondary { background: var(--on-accent); color: var(--accent); border-color: transparent; }

/* =====================================================================
   12. Simple pages — program week legend, mode button
   ===================================================================== */
.legend-dot { display: inline-block; width: 10px; height: 10px; margin: 0 4px 0 10px; border-radius: 3px; vertical-align: -1px; }
.legend-dot:first-child { margin-left: 0; }
.legend-dot.coach { background: var(--accent); box-shadow: inset 0 0 0 1px var(--edge); }
.legend-dot.solo { background: var(--label); }
.day-time { white-space: nowrap; }
.day-time.unset { color: var(--label-2); font-weight: 500; }
/* Bottom sheet (in-app picker) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-width: 600px; margin: 0 auto; padding: var(--s5) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom));
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: 0 -8px 32px rgba(0, 0, 0, .2); animation: sheet-up .22s cubic-bezier(.25, 1, .5, 1); }
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s3); }
.sheet-head b { font: var(--t-headline); }
.sheet-now { font: var(--t-title); color: var(--accent); }
.sheet-label { margin: var(--s3) 0 var(--s2); font: var(--t-foot); font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: .04em; }
.sheet-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: var(--s2); }
.sheet-grid .chip { padding: 0; min-height: var(--tap); }
.sheet-grid .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.sheet-ap { margin: var(--s4) 0; }
.day-add { gap: 4px; color: var(--accent); }
.day-add svg { width: 16px; height: 16px; }
.mode-btn { white-space: nowrap; }
.cell-link { display: flex; align-items: center; gap: 4px; min-height: 44px; color: inherit; font-weight: 600; text-decoration: none; }
.cell-link svg { width: 16px; height: 16px; color: var(--label-2); }
.day-row { align-items: flex-start; }
.day-row .day-badge { margin-top: var(--s1); }
.day-exs { display: grid; gap: 3px; margin-top: 2px; }
.day-ex { font: var(--t-sub); color: var(--label-2); }
.day-ex b { font-weight: 600; color: var(--label); }
.day-ex .num { white-space: nowrap; }
.day-ex-fin { color: var(--label-3); }

/* =====================================================================
   13. Progress cards, weigh-in, quick add
   ===================================================================== */
.chart-foot { margin: var(--s2) 0 0; font: var(--t-sub); color: var(--label-2); }
.chart-foot b { color: var(--label); }
.measure-diff { min-width: 48px; text-align: right; margin-left: var(--s3); color: var(--label); }
.s-weigh-row { display: flex; gap: var(--s2); align-items: center; }
.s-weigh-row .field { flex: 1; min-width: 0; }
.s-weigh-row .btn { flex: none; }
.s-weigh-row .s-date { flex: none; width: 150px; }
.saved-ok { color: var(--success); font-weight: 600; }
.unit-lock { flex: none; width: 112px; text-align: center; font: var(--t-sub); font-weight: 600; color: var(--label-2); }
.quick-box { display: grid; gap: var(--s2); align-items: stretch; }
.quick-box textarea { min-height: 120px; font-family: inherit; }
.quick-preview { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; font: var(--t-sub); }
.quick-preview li { display: flex; justify-content: space-between; gap: var(--s3); }
.quick-preview li span { color: var(--label-2); text-align: right; }
.quick-preview li.bad { color: var(--danger); }

/* Client home: their program as its own card */
.program-card { display: block; }
.program-card-name { display: block; font: var(--t-title); letter-spacing: -.01em; margin-bottom: var(--s3); }
.next-up { display: grid; gap: 2px; margin-bottom: var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r-sm); background: var(--bg); }
.next-up > span:first-child { font: var(--t-foot); font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: .04em; }
.next-up b { font: var(--t-headline); }
.next-up > span:last-child { font: var(--t-sub); color: var(--label-2); }
.next-up .with-coach-text { color: var(--done-fg); font-weight: 600; }
.program-card .progress { margin-bottom: var(--s7); }
a.program-card:active { background: var(--fill); }

/* Client home: a gentle "finish your profile" nudge (accent tint, not an error) */
.nudge { display: flex; align-items: center; gap: var(--s3); background: var(--done-bg); color: var(--done-fg); box-shadow: none; border: 1.5px solid var(--accent); }
.nudge-dot { flex: none; width: .75rem; height: .75rem; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 .3rem color-mix(in srgb, var(--accent) 22%, transparent); }
.nudge-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.nudge-text b { font: var(--t-headline); }
.nudge-text span { font: var(--t-sub); }
.nudge .chevron { color: var(--done-fg); }
a.nudge:active { filter: brightness(.97); }

/* Nutrition: the calorie number is the hero */
.nu-label { display: block; font: var(--t-foot); font-weight: 600; color: var(--label-2); }
.nu-hero b { display: block; font: var(--t-large); font-size: clamp(28px, 8vw, 36px); letter-spacing: -.02em; margin: var(--s1) 0; }
.nu-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: var(--s3); }
.nu-pair b { display: block; font: var(--t-title); margin-top: var(--s1); }

/* Client week list: days with the coach get the accent tint */
.cell.with-coach { background: var(--done-bg); }
.cell.with-coach .cell-sub { color: var(--done-fg); font-weight: 600; }

/* =====================================================================
   14. Client page — profile sheet, chart grid, week rows
   ===================================================================== */
.profile-head .title { margin: 0; min-width: 0; }
.measure-val { color: var(--label); font-weight: 600; }
.danger-text { color: var(--danger); }
.profile-goal { margin-bottom: var(--s4); }
.profile-goal textarea { resize: none; }
.client-goal { margin-top: var(--s3); font: var(--t-sub); color: var(--label-2); }
.client-goal b { color: var(--label); font-weight: 600; }

/* Client name with their login code beside it — tap to copy */
.name-code { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.code-chip { min-height: var(--tap); padding: 0 var(--s4); border: 1px solid var(--edge); border-radius: 999px; background: var(--surface); color: var(--label); font: var(--t-headline); letter-spacing: .06em; user-select: all; -webkit-user-select: all; }

/* Last workout / weigh-in / calories: three circles at the top of the coach's client page */
.rings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); margin-top: var(--s2); }
.ring-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; min-width: 0; }
.ring { width: 88px; height: 88px; border-radius: 50%; display: grid; place-content: center; justify-items: center; margin-bottom: var(--s2);
  background: var(--surface); box-shadow: inset 0 0 0 3px var(--accent), var(--shadow); font: var(--t-title); line-height: 1.05; }
.ring small { font: var(--t-foot); color: var(--label-2); }
.ring-stat > b { font: var(--t-foot); font-weight: 600; }
.ring-stat > span:last-child { font: var(--t-foot); color: var(--label-2); }
a.ring-stat:active .ring { background: var(--fill); }

/* Strength, Weight, Calories, Measurements: two charts per row */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4) var(--s3); }
.chart-grid > div { min-width: 0; }
.chart-grid .section-head { padding: 0 0 var(--s2); }
.chart-grid .card { padding: var(--s3); }
.chart-grid .chart-foot { font-size: 12px; }

/* Week row: note, met (check) and missed (X) buttons */
.week-row .cell-trail { gap: var(--s1); }
.met-btn { width: var(--box); height: var(--box); flex: none; border: 0; border-radius: var(--r-sm); background: var(--fill); color: var(--label-3); display: grid; place-items: center; transition: background-color .2s ease-out, color .2s ease-out; }
.met-btn svg { width: 18px; height: 18px; }
.met-yes[aria-pressed="true"] { background: var(--success); color: var(--on-success); }
.met-no[aria-pressed="true"] { background: var(--danger); color: var(--surface); }
.note-btn.has-note { background: var(--accent); color: var(--on-accent); }
.week-note { padding: 0 var(--s4) var(--s3); }
.week-title { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.week-title .cell-link { flex: none; }
.week-note-preview { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--t-sub); color: var(--label-2); }
.week-note textarea { resize: none; }
.note-status { margin: 6px 0 0; font: var(--t-foot); color: var(--label-2); min-height: 1.2em; }
.note-status.saved { color: var(--success); font-weight: 600; }

/* =====================================================================
   14b. Assessment — coach form groups and the client's assessment sheet
   ===================================================================== */
.as-test-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.as-test-head b { font: var(--t-headline); }
.as-test-head span { font: var(--t-sub); color: var(--label-2); }
.as-max { margin: var(--s2) 0 var(--s3); font: var(--t-sub); color: var(--label-2); }
.as-max b { display: block; font: var(--t-large); color: var(--label); letter-spacing: -.02em; }
.as-table { width: 100%; border-collapse: collapse; font: var(--t-sub); }
.as-table th, .as-table td { padding: 10px var(--s2); text-align: left; border-bottom: 1px solid var(--separator); }
.as-table thead th { font: var(--t-foot); font-weight: 600; color: var(--label-2); }
.as-table tbody th { font-weight: 600; }
.as-table tr:last-child > * { border-bottom: 0; }
.as-pick { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.as-table .pass { color: var(--success); font-weight: 600; }
.as-table .bad { color: var(--danger); font-weight: 600; }
.as-num { width: 72px; text-align: center; }
/* Birthday: one MM / DD / YYYY field with three borderless parts. */
.date-field { display: inline-flex; align-items: center; gap: 2px; min-height: 36px; padding: 0 var(--s2); border: 1.5px solid transparent; border-radius: var(--r-sm); background: var(--fill); transition: background .15s, border-color .15s, box-shadow .15s; }
.date-field:focus-within { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent); }
.date-part { width: 2.2rem; padding: 0; border: 0; background: none; color: var(--label); text-align: center; font: var(--t-body); font-size: max(16px, 1em); font-weight: 600; outline: none; }
.date-part.yyyy { width: 3.4rem; }
.date-sep { color: var(--label-3); }
.as-pf { width: 88px; }
.as-lr-head { width: 72px; text-align: center; font: var(--t-foot); font-weight: 600; color: var(--label-2); }
.as-note { margin-top: var(--s1); font: var(--t-sub); color: var(--label-2); }
.as-pct tbody tr { cursor: pointer; }
.as-pct tbody tr.is-picked > * { background: var(--done-bg); color: var(--done-fg); font-weight: 700; }
.as-pct tbody tr.is-picked > :first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.as-pct tbody tr.is-picked > :last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.as-range { display: grid; gap: 2px; padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--done-bg); color: var(--done-fg); }
.as-range > span:first-child { font: var(--t-foot); font-weight: 600; }
.as-range b { font: var(--t-title); }
.as-range > span:last-child { font: var(--t-sub); }
/* Assessment form: one block per strength test — name, weight × reps, note */
.as-test-row { display: grid; gap: var(--s2); padding: var(--s3) var(--s4); position: relative; }
.as-test-row + .as-test-row, .as-test-row + .cell { border-top: 1px solid var(--separator); }
.as-test-top { display: flex; align-items: center; gap: var(--s2); }
.as-test-name { flex: 1; min-width: 0; font-weight: 600; }
.as-test-del { color: var(--label-3); flex: none; }
.as-test-nums { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: var(--s2); }
.as-test-nums label { display: grid; gap: 4px; min-width: 0; }
.as-test-nums label > span { font: var(--t-foot); font-weight: 600; color: var(--label-2); }
.as-test-nums .field { text-align: center; }
.as-test-x { padding-bottom: .7rem; color: var(--label-3); font: var(--t-headline); }
.as-test-note { font: var(--t-sub); min-height: 2.75rem; }

/* Body composition scan */
.synopsis ul { list-style: none; margin: var(--s3) 0; padding: 0; display: grid; gap: var(--s3); }
.synopsis li { display: grid; gap: 2px; padding-left: var(--s4); position: relative; }
.synopsis li::before { content: ""; position: absolute; left: 0; top: .45em; width: .55rem; height: .55rem; border-radius: 50%; background: var(--label-3); }
.synopsis li.syn-good::before { background: var(--success); }
.synopsis li.syn-watch::before { background: var(--accent); }
.synopsis li.syn-plan::before { background: var(--label); }
.synopsis li b { font: var(--t-headline); }
.synopsis li span { font: var(--t-sub); color: var(--label-2); }
.synopsis-lead { font: var(--t-body); font-weight: 600; }
.synopsis-note { font: var(--t-foot); color: var(--label-2); padding-top: var(--s3); border-top: 1px solid var(--separator); }
.scan-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: var(--s2); }
.scan-stat { background: var(--surface); border-radius: var(--r); padding: var(--s3); box-shadow: var(--shadow); display: grid; gap: 2px; min-width: 0; }
.scan-stat b { font: var(--t-title); }
.scan-stat span { font: var(--t-foot); color: var(--label-2); }
.scan-stat.tone-good, .cell.tone-good, .as-table tr.tone-good > * { background: var(--tone-good); }
.scan-stat.tone-ok, .cell.tone-ok, .as-table tr.tone-ok > * { background: var(--tone-ok); }
.scan-stat.tone-bad, .cell.tone-bad, .as-table tr.tone-bad > * { background: var(--tone-bad); }
.scan-photo-card { padding: var(--s2); }
.scan-photo { display: block; width: 100%; height: auto; border-radius: var(--r-sm); }
.scan-actions { margin-top: var(--s3); }
.scan-actions .btn { gap: var(--s1); }
.as-rom-card { padding: var(--s2) var(--s3); }

/* =====================================================================
   16. Session book (coach only): bottom tabs, calendar, totals
   ===================================================================== */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--separator); padding-bottom: env(safe-area-inset-bottom); }
.tabbar-in { display: flex; max-width: 760px; margin: 0 auto; }
.tab { flex: 1; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font: var(--t-foot); font-weight: 600; color: var(--label-2); }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent); }
/* 7.5px tighter than the usual section gap (7.5 / 14.4 rem) between the cards on the book page */
.book-body .section { margin-top: calc(var(--s7) - .5208rem); }
.book-today { display: flex; justify-content: center; margin-top: var(--s3); }
.book-today + .week-nav { margin-top: var(--s2); }
.book-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.stat small { display: block; margin-top: 2px; font: var(--t-foot); color: var(--label-3); }
.book-card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.book-legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3); padding: var(--s3) var(--s1) 0; font: var(--t-foot); color: var(--label-2); }
.sw { display: inline-block; width: .8333rem; height: .8333rem; margin-right: calc(-1 * var(--s2)); border-radius: 4px; background: var(--accent); }
.sw.up { background: var(--done-bg); box-shadow: inset 0 0 0 1.5px var(--accent); }
.sw.floor { background: var(--label); }
.sw.none { background: none; box-shadow: inset 0 0 0 1.5px var(--edge-soft); }
.sw.cancelled { background: var(--fill); box-shadow: inset 0 0 0 1px var(--edge-soft); }
/* week */
.wk { --hr: 3rem; --gutter: 2.6rem; }
.wk-head, .wk-body { display: grid; grid-template-columns: var(--gutter) repeat(7, minmax(0, 1fr)); }
.wk-head { border-bottom: 1px solid var(--separator); }
.wk-day { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: var(--tap); padding: var(--s2) 0; border: 0; background: none; font: var(--t-foot); color: var(--label-2); }
.wk-day b { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%; font: var(--t-headline); color: var(--label); }
.wk-day.today b { background: var(--fill); box-shadow: inset 0 0 0 2px var(--label); }
.wk-body { background: repeating-linear-gradient(to bottom, var(--fill) 0 1px, transparent 1px var(--hr)); }
.wk-hours div { height: var(--hr); padding: 2px var(--s1) 0 0; text-align: right; font: var(--t-foot); font-size: .75rem; color: var(--label-3); }
.wk-col { position: relative; height: calc(var(--hr) * var(--rows)); border-left: 1px solid var(--fill); }
.wk-col.today { background: color-mix(in srgb, var(--label) 4%, transparent); }
.wk-blk { position: absolute; top: calc(var(--hr) * var(--top) + 1px); height: calc(var(--hr) - 2px);
  left: calc(100% * var(--lane) / var(--lanes) + 2px); width: calc(100% / var(--lanes) - 4px);
  display: flex; flex-direction: column; gap: 1px; padding: 4px 5px; overflow: hidden; border: 0; border-radius: 4px; text-align: left;
  background: var(--accent); color: var(--on-accent); font-size: .75rem; line-height: 1.15; }
.wk-blk b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.wk-blk span { font-size: .6667rem; opacity: .8; }
.wk-blk.floor { background: var(--label); color: var(--bg); }
.wk-blk.chk { padding-right: 1.15rem; }
.wk-blk svg { position: absolute; top: 4px; right: 4px; width: .8333rem; height: .8333rem; }
.wk-blk.cancelled { background: var(--fill); color: var(--label-3); text-decoration: line-through; }
/* month */
.mo-head, .mo-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.mo-head span { padding: var(--s2) 0; text-align: center; font: var(--t-foot); font-weight: 600; color: var(--label-2); }
.mo-day { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 4.4rem; padding: 6px 2px; border: 0; border-top: 1px solid var(--separator); background: none; color: var(--label); }
.mo-day b { display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; font: var(--t-sub); font-weight: 600; }
.mo-day.today b { background: var(--fill); box-shadow: inset 0 0 0 2px var(--label); font-weight: 700; }
.mo-day.out { color: var(--label-3); }
.mo-chip { min-width: 1.6rem; padding: 0 5px; border-radius: 4px; background: var(--accent); color: var(--on-accent); text-align: center; font: var(--t-foot); font-weight: 700; line-height: 1.5; }
.mo-chip.floor { background: var(--label); color: var(--bg); }
.mo-day.out .mo-chip { opacity: .5; }
/* client calendar tab */
.cc-grid .mo-day { min-height: 3.6rem; border-radius: var(--r-sm); }
.cc-grid .mo-day[aria-pressed="true"] { background: var(--fill); }
.cc-dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); }
.cc-dot.own { background: var(--label); }
.cc-dot.big { width: .75rem; height: .75rem; flex: none; }
.cc-mark { display: grid; place-items: center; width: 1rem; height: 1rem; border-radius: 50%; background: var(--accent); color: var(--on-accent); }
.cc-mark.own { background: var(--label); color: var(--bg); }
.cc-mark.miss { background: none; color: var(--danger); }
.cc-mark svg { width: .7rem; height: .7rem; }
.sw.miss { background: none; box-shadow: inset 0 0 0 1.5px var(--danger); }
/* rates */
.dollar { color: var(--label-2); }
.chart.tap { position: relative; cursor: pointer; }
.chart-controls { display: grid; gap: var(--s2); margin-top: var(--s2); }
.chart-controls .chips { padding: 2px 0; }
.chart-sheet .chart-controls { margin: var(--s2) 0 var(--s3); }
.chart-expand { position: absolute; right: var(--s3); bottom: var(--s3); width: 1rem; height: 1rem; color: var(--label-3); }
.chart-expand svg { width: 100%; height: 100%; }
.chart-sheet { position: fixed; inset: 0; z-index: 60; overflow-y: auto; padding: var(--s2) clamp(12px, 4vw, var(--s4)) var(--s7); background: var(--bg); animation: sheet-full .3s cubic-bezier(.25, 1, .5, 1); }
.chart-sheet-head { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); }
.chart-sheet-head b { font: var(--t-title); }
.fc-summary { margin: var(--s2) 0 var(--s3); font: var(--t-headline); font-weight: 500; }
.fc-row { width: 100%; border: 0; background: none; text-align: left; }
.fc-row[aria-pressed="true"] { background: var(--done-bg); }
.fc-main { font: var(--t-headline); }
.note-btn { background: none; color: var(--label-3); }
.note-btn.has { color: var(--accent); }
.note-btn svg { width: 1.2rem; height: 1.2rem; }
.note-prev { padding: var(--s3) var(--s4); border-radius: var(--r) var(--r) var(--r) 4px; background: var(--fill); }
.note-prev .note-from { margin-bottom: var(--s1); }
.note-line { font: var(--t-sub); color: var(--label); }
.note-line + .note-line { margin-top: 2px; }
.note-line b { font-weight: 600; }
.goal-row { flex-wrap: nowrap; }
.goal-row:focus-within { background: var(--fill); }
.goal-text { flex: 1; min-width: 0; border: 0; padding: var(--s2) 0; background: none; color: var(--label); font: var(--t-body); outline: none; }
.goal-text::placeholder { color: var(--label-3); }
.goal-row.done .goal-text { color: var(--label-3); text-decoration: line-through; }
.goal-del { color: var(--label-3); flex: none; }
.goal-add { width: 100%; border: 0; background: none; color: var(--accent); font-weight: 600; text-align: left; }
.chk-box { display: grid; place-items: center; flex: none; width: var(--tap); height: var(--tap); margin: -10px 0 -10px -12px; padding: 0; border: 0; background: none; color: var(--on-accent); }
.chk-mark { display: grid; place-items: center; width: 1.6667rem; height: 1.6667rem; border-radius: 6px; box-shadow: inset 0 0 0 1.5px var(--edge); }
.chk-mark svg { width: 1rem; height: 1rem; opacity: 0; }
.chk-box[aria-pressed="true"] .chk-mark { background: var(--accent); box-shadow: none; }
.chk-box[aria-pressed="true"] svg { opacity: 1; }
.inline-input.times { width: 3.4rem; text-align: center; }
.chart-tap { display: block; width: 100%; padding: var(--s3) var(--s3) var(--s2); border: 0; text-align: left; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.ch-grid { stroke: var(--separator); stroke-width: 1; }
.ch-lab { fill: var(--label-2); font: 500 10px var(--font); }
.ch-val { fill: var(--label); font: 700 12px var(--font); }
.bar-done { fill: var(--accent); }
.bar-up { fill: var(--done-bg); stroke: var(--accent); stroke-width: 1.5; }
.hit { fill: transparent; }
.bar-none { fill: none; stroke: var(--edge-soft); stroke-width: 1.5; stroke-dasharray: 3 3; }
.ch-val.none { fill: var(--label-3); font-weight: 500; }
.ch-bar.dim { opacity: .35; }
.ch-bar.sel .ch-val { fill: var(--accent); }
.chart.big .ch-val { font-size: 14px; }
.chart.big .ch-lab { font-size: 12px; }
.chart.big .ch-bar { cursor: pointer; }
.chart.big .ch-bar:focus-visible { outline: 2px solid var(--label); outline-offset: 2px; }
.chart-full { position: fixed; inset: 0; z-index: 50; overflow-y: auto; padding: var(--s2) clamp(12px, 4vw, var(--s4)) var(--s7); background: var(--bg); }
.chart-full-head { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); margin-bottom: var(--s3); }
.chart-full-head b { font: var(--t-title); }
.chart-detail { display: flex; flex-direction: column; gap: 2px; min-height: 3rem; margin-bottom: var(--s3); }
.chart-detail b { font: var(--t-headline); }
.chart-detail span { font: var(--t-sub); color: var(--label-2); }
.proj-n { font: var(--t-title); color: var(--label); }
.book-sheet { max-height: 90vh; overflow-y: auto; }
.day-sheet { max-height: 80vh; overflow-y: auto; }
.day-sheet .group { margin-bottom: var(--s3); }
.book-sheet > .segmented, .book-sheet .bk-name, .book-sheet > .group { margin-bottom: var(--s3); }
.book-sheet[data-kind="floor"] .bk-name { display: none; }
.book-sheet .error { margin-bottom: var(--s3); }
.bk-actions { margin-top: var(--s3); }
.bk-del { margin-top: var(--s2); }

/* =====================================================================
   15. States that must win — keep these last
   ===================================================================== */
/* iPhone zooms into any field whose text is under 16px. Every field, everywhere, stays at 16px or more. */
:is(input, select, textarea):not([type=checkbox]):not([type=radio]):not([type=range]) { font-size: max(16px, 1em); }
/* Tap-twice confirm (A.confirmTap): the armed button turns red and asks again. */
.btn.armed, .icon-btn.armed { background: var(--danger); color: var(--surface); width: auto; padding: 0 10px; font: var(--t-foot); font-weight: 700; white-space: nowrap; }

/* Thumb-sized targets on touch screens, without changing the desktop look. */
@media (pointer: coarse) {
  .btn-sm, .theme, .segmented button { min-height: 44px; }
  .stepper button { width: 44px; height: 44px; }
  .edit-specs .stepper button { width: 40px; height: 40px; }
  .set-fail, .met-btn { width: 40px; height: 40px; }
}
