/* Colors measured from the School UI mockup; type and states from the UI Kit. */
:root {
  color-scheme: light;
  --primary: #07332f;      /* header, buttons, active switch */
  --primary-hover: #0b4640;
  --on-primary: #fff;
  --brand-surface: #07332f;
  --on-brand: #fff;
  --on-brand-muted: rgba(255,255,255,.8);
  --brand-line: rgba(255,255,255,.35);
  --brand-track: rgba(255,255,255,.2);
  --brand-button: #fff;
  --brand-button-text: #07332f;
  --nav: #1d322f;          /* bottom bar, dark image panels */
  --nav-text: rgba(234,245,246,.82);
  --nav-active: #fff;
  --splash: #023330;
  --bg: #f9f5f0;           /* page */
  --card: #fcf8f3;         /* cards */
  --raised: #fffdf9;
  --input-bg: #fff;
  --light-gray: #eae6e0;   /* switch track, image placeholders */
  --line: #e4e0d8;         /* borders, dividers */
  --track: #d1cac6;        /* progress track */
  --text: #0e1412;
  --text-2: #55574f;
  --success: #2e8b57;
  --success-soft: #e6f1ea;
  --warning: #e4a11b;
  --warning-text: #94650a;
  --warning-soft: #f8ecd3;
  --error: #d9534f;
  --error-text: #9b2c28;
  --error-soft: #f8e6e4;
  --info: #2f5f8f;
  --info-soft: #e5eef7;
  --checked-bg: #e9f2ec;
  --check-border: #8fa39c;
  --check-icon: #b4c2bc;
  --disabled-bg: #a7b6b2;
  --switch-knob: #fff;
  --drag-bg: rgba(7,51,47,.05);
  --overlay: rgba(7,51,47,.45);
  --shadow: rgba(7,51,47,.14);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --tabbar-h: 64px;
  --gutter: 16px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #80d8bd;
  --primary-hover: #a0e8d2;
  --on-primary: #10221d;
  --brand-surface: #22332f;
  --on-brand: #edf4f1;
  --on-brand-muted: #b4c4be;
  --brand-line: #536c63;
  --brand-track: #41574f;
  --brand-button: #80d8bd;
  --brand-button-text: #10221d;
  --nav: #182320;
  --nav-text: #b4c4be;
  --nav-active: #80d8bd;
  --splash: #101817;
  --bg: #101817;
  --card: #182320;
  --raised: #22332f;
  --input-bg: #22332f;
  --light-gray: #22332f;
  --line: #3c5149;
  --track: #657c72;
  --text: #edf4f1;
  --text-2: #b4c4be;
  --success: #88d4a3;
  --success-soft: #203c2d;
  --warning: #ecc36d;
  --warning-text: #ecc36d;
  --warning-soft: #3e321d;
  --error: #f09b92;
  --error-text: #f4b2aa;
  --error-soft: #432825;
  --info: #a0c9ee;
  --info-soft: #21394b;
  --checked-bg: #203c2d;
  --check-border: #88a397;
  --check-icon: #b4c4be;
  --disabled-bg: #42564e;
  --switch-knob: #edf4f1;
  --drag-bg: rgba(128,216,189,.08);
  --overlay: rgba(0,0,0,.65);
  --shadow: rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--bg); }
button, input, select, textarea { color-scheme: inherit; }
input::placeholder, textarea::placeholder { color: var(--text-2); opacity: .85; }
input, select, textarea { accent-color: var(--primary); }
input:disabled, select:disabled, textarea:disabled { opacity: 1; color: var(--text-2); -webkit-text-fill-color: var(--text-2); }
button:focus-visible, summary:focus-visible { outline: 3px solid var(--success); outline-offset: 2px; }

body {
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

a { color: var(--primary); }
img { max-width: 100%; }

/* ---------- Opening screen ---------- */
.splash {
  position: fixed; inset: 0; z-index: 100;
  background: var(--splash);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  transition: opacity .35s ease;
}
.splash.is-hidden { opacity: 0; pointer-events: none; }
.splash-lockup { display: flex; align-items: center; gap: 18px; }
.splash-mark { width: 88px; height: 88px; border-radius: 50%; display: block; }
.wordmark {
  color: #f3f0ea; font-weight: 800; text-transform: uppercase;
  font-size: 17px; line-height: 1.25; letter-spacing: .16em;
}
.splash-bar { width: 120px; height: 5px; border-radius: 99px; background: rgba(255,255,255,.15); overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 0; background: #f3f0ea; border-radius: 99px; animation: load 1.1s ease forwards; }
@keyframes load { to { width: 100%; } }

/* ---------- Page & type ---------- */
.page { max-width: 480px; margin: 0 auto; padding: calc(24px + env(safe-area-inset-top)) var(--gutter) 28px; }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -.4px; line-height: 1.2; margin: 6px 4px 18px; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -.1px; margin: 0; }
h3 { font-size: 15px; font-weight: 600; margin: 0; line-height: 1.3; }
.lead { color: var(--text-2); margin: -10px 4px 18px; font-size: 14px; }
.muted { color: var(--text-2); margin: 3px 0; font-size: 13px; }
.tiny { font-size: 12px; color: var(--text-2); margin: 2px 0; }
.center { text-align: center; margin-top: 24px; }
.state-msg { color: var(--text-2); }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.section-title { display: flex; justify-content: space-between; align-items: baseline; margin: 26px 4px 10px; }
.section-title > span { color: var(--text-2); font-size: 12px; }
.view-all { font-size: 13px; font-weight: 500; color: var(--text); text-decoration: none; }

/* Top app bar (detail screens) */
.appbar { display: flex; align-items: center; gap: 6px; margin: -10px -6px 10px; min-height: 48px; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%;
  color: var(--text); text-decoration: none; flex: none;
}
.icon-btn:hover { background: var(--light-gray); }
.icon-btn svg, .ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.appbar-title { font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Switch tabs (Modules / Completed …) ---------- */
.segmented {
  display: flex; gap: 4px; padding: 3px; margin: 0 0 6px;
  background: var(--light-gray); border-radius: var(--radius-sm);
}
.seg {
  flex: 1; font: inherit; font-size: 14px; font-weight: 500; color: var(--text);
  height: 34px; border: 0; border-radius: var(--radius-xs); background: transparent; cursor: pointer;
  padding: 0 6px; white-space: nowrap; min-width: 0;
}
.segmented .seg:first-child:nth-last-child(3), .segmented .seg:first-child:nth-last-child(3) ~ .seg { font-size: 13px; flex: 1 1 auto; padding: 0 8px; }
.seg.is-active { background: var(--primary); color: var(--on-primary); font-weight: 600; }

/* ---------- Cards ---------- */
.card {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); margin-bottom: 12px; overflow: hidden;
}
.state-card { padding: 24px 20px; text-align: center; }
.state-card .ic { width: 36px; height: 36px; color: var(--text-2); margin-bottom: 6px; }
.state-card .btn { margin-top: 10px; }

.stats { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; padding: 0; list-style: none; color: var(--text); font-size: 13px; }
.stats li { display: inline-flex; align-items: center; gap: 6px; }
.stats .ic { width: 16px; height: 16px; }

/* Featured workout (Train) */
.feature { padding: 10px; }
.feature-top { display: flex; gap: 16px; text-decoration: none; color: inherit; }
.feature-thumb {
  flex: none; width: 104px; height: 136px; border-radius: var(--radius-xs); overflow: hidden;
  background: var(--light-gray); display: grid; place-items: center; color: var(--text-2);
}
.feature-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feature-info { min-width: 0; padding-top: 14px; }
.feature-info h2 { font-size: 19px; margin: 6px 0 2px; }
.feature-actions { display: flex; gap: 10px; margin-top: 12px; }
.feature-actions .btn-primary { flex: 1; }

/* Today's Workout (Home) */
.today-card { display: flex; padding: 0; }
.today-thumb { flex: none; width: 92px; background: var(--nav); overflow: hidden; }
.today-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: .9; }
.today-body { flex: 1; min-width: 0; padding: 14px 14px 12px 18px; }
.today-body h2 { font-size: 17px; }
.today-body .btn { width: 100%; margin-top: 12px; }

/* Continue Learning (Home) */
.continue-card { display: flex; gap: 14px; padding: 8px; text-decoration: none; color: inherit; box-shadow: 0 8px 24px var(--shadow); }
.continue-thumb { flex: none; width: 150px; height: 154px; border-radius: var(--radius-xs); overflow: hidden; background: var(--light-gray); }
.continue-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.continue-body { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 10px 6px 4px 0; }
.continue-body h3 { font-size: 16px; line-height: 1.3; }
.continue-body .tiny { margin: 6px 0; }
.continue-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 8px; }
.mini-track { flex: 1; max-width: 80px; height: 4px; border-radius: 99px; background: var(--track); overflow: hidden; }
.mini-track span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.continue-foot .play-dot { margin-left: auto; }

/* Lesson list (Learn) */
.lesson-list { padding: 0; }
.lesson-row {
  display: flex; gap: 16px; align-items: center; padding: 6px 12px 6px 6px;
  text-decoration: none; color: inherit; border: 1px solid transparent; border-radius: var(--radius);
}
.lesson-row + .lesson-row { border-top-color: var(--line); border-radius: 0; }
.lesson-row.is-next { border: 1px solid var(--text); border-radius: var(--radius); margin: -1px; }
.lesson-thumb { flex: none; width: 90px; height: 100px; border-radius: var(--radius-xs); overflow: hidden; background: var(--light-gray); }
.lesson-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lesson-body { flex: 1; min-width: 0; }
.lesson-body .muted { font-size: 12.5px; }
.status-icon { flex: none; width: 26px; height: 26px; color: var(--text); }
.play-dot {
  flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--primary);
  display: grid; place-items: center;
}
.play-dot svg { width: 12px; height: 12px; fill: var(--on-primary); }

.done-line { display: flex; align-items: center; gap: 6px; color: var(--success); font-weight: 600; font-size: 13px; margin: 8px 0 0; }
.done-line .ic { width: 18px; height: 18px; }

.crosslink {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 16px; padding: 14px 16px; border-radius: var(--radius); background: var(--light-gray);
  font-weight: 600; font-size: 14px; text-decoration: none; color: var(--primary);
}

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; line-height: 1.6;
}
.chip-level { background: var(--success-soft); color: var(--success); }
.chip-intermediate { background: var(--warning-soft); color: var(--warning-text); }
.chip-advanced { background: var(--error-soft); color: var(--error-text); }
.chip-sample { background: var(--warning-soft); color: var(--warning-text); }
.chip-progress { background: var(--info-soft); color: var(--info); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 600; font-size: 15px;
  min-height: 46px; padding: 0 20px; border-radius: var(--radius-xs);
  border: 1px solid transparent; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  transition: background .15s;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: var(--disabled-bg); color: var(--text-2); cursor: not-allowed; }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--primary); }
.btn-secondary:hover { background: var(--light-gray); }
.btn-block { width: 100%; margin: 14px 0; }
.btn-sm { min-height: 30px; font-size: 13px; padding: 0 14px; }
.btn-danger { background: var(--card); color: var(--error); border-color: var(--error); }
.btn-danger:hover { background: var(--error-soft); }
.btn-danger .ic { width: 18px; height: 18px; }
.btn:focus-visible, .tab:focus-visible, .seg:focus-visible, a:focus-visible { outline: 3px solid var(--success); outline-offset: 2px; }

/* ---------- Video ---------- */
.video { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; margin: 4px 0 8px; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-fallback { font-size: 13px; color: var(--text-2); margin: 0 0 8px; }
.demo-missing {
  border: 1px dashed var(--line); border-radius: var(--radius); background: var(--bg);
  color: var(--text-2); font-size: 13px; text-align: center; padding: 28px 12px;
}

/* ---------- Workout session ---------- */
.session-bar {
  position: sticky; top: 8px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--brand-surface); color: var(--on-brand); border-radius: var(--radius);
  padding: 8px 8px 8px 14px; margin: 14px 0; font-size: 13px; font-weight: 600;
}
.session-bar .progress { flex: 1; }
.progress-track { height: 4px; border-radius: 99px; background: var(--brand-track); margin-top: 6px; overflow: hidden; }
.progress-track span { display: block; height: 100%; background: var(--on-brand); border-radius: 99px; transition: width .3s; }
.session-bar .btn { background: var(--brand-button); color: var(--brand-button-text); }

.exercises { list-style: none; padding: 0; margin: 0; }
.exercise {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 12px 8px 8px; margin-bottom: 8px; scroll-margin-top: 80px;
}
.exercise.is-current { border-color: var(--text); }
.ex-row { display: flex; gap: 14px; align-items: center; }
.ex-thumb {
  flex: none; width: 72px; height: 72px; border-radius: var(--radius-xs); background: var(--light-gray);
  display: grid; place-items: center; color: var(--text-2); font-weight: 700; overflow: hidden;
}
.ex-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ex-text { flex: 1; min-width: 0; }
.ex-rx { margin: 3px 0 0; font-size: 13px; color: var(--text); }
.ex-rest { margin: 0; font-size: 12px; color: var(--text-2); }
.ex-check { flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--track); display: grid; place-items: center; }
.ex-check.is-done { background: var(--primary); border-color: var(--primary); }
.ex-check.is-done svg { width: 13px; height: 13px; fill: none; stroke: var(--on-primary); stroke-width: 2.5; }
.ex-detail { margin-top: 10px; }
.ex-detail > img { border-radius: var(--radius-sm); width: 100%; display: block; }
.ex-notes { margin: 10px 0 0; font-size: 13px; color: var(--text-2); }
.ex-nav { display: flex; gap: 10px; margin-top: 12px; }
.ex-nav .btn { flex: 1; }

.complete-box {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--success-soft); border-radius: var(--radius); padding: 10px 12px; margin: 14px 0;
}
.complete-box .done-line { margin: 0; }

.warn { background: var(--error-soft); color: var(--error-text); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; }

/* ---------- Home ---------- */
.hero {
  background: var(--brand-surface); color: var(--on-brand);
  margin: calc(-24px - env(safe-area-inset-top)) calc(-1 * var(--gutter)) 0;
  padding: calc(34px + env(safe-area-inset-top)) 26px 92px;
}
.hero-hello { font-size: 18px; margin: 0; }
.hero-name { font-size: 31px; font-weight: 700; letter-spacing: -.5px; line-height: 1.15; margin: 0; }
.hero-add {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px;
  color: var(--on-brand); font-weight: 700; font-size: 16px; text-decoration: none;
  border-bottom: 1px solid var(--brand-line);
}
.hero-add .ic { width: 18px; height: 18px; }
.hero .section-title { margin: 30px 0 0; }
.hero .section-title h2, .hero .view-all { color: var(--on-brand); }
.hero-overlap { margin-top: -78px; position: relative; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat-card { padding: 14px 12px 14px 16px; margin-bottom: 0; min-height: 72px; }
.stat-num { display: flex; align-items: center; gap: 8px; }
.stat-num strong { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-num .ic { width: 22px; height: 22px; color: var(--primary); }
.stat-num .spark { width: 56px; height: 24px; margin-left: auto; color: var(--text); stroke-width: 1.2; }
.stat-card .muted { font-size: 13px; color: var(--text); margin-top: 4px; white-space: nowrap; }
.flame { width: 22px; height: 22px; fill: var(--primary); }

.recent-list { padding: 2px 10px; }
.recent-item { display: flex; align-items: center; gap: 14px; padding: 6px 0; text-decoration: none; color: inherit; }
.recent-item + .recent-item { border-top: 1px solid var(--line); }
.recent-thumb { flex: none; width: 64px; height: 46px; border-radius: var(--radius-xs); overflow: hidden; background: var(--light-gray); display: grid; place-items: center; color: var(--text-2); }
.recent-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.recent-body { flex: 1; min-width: 0; }
.recent-body h3 { font-size: 13.5px; font-weight: 600; }
.recent-check { width: 24px; height: 24px; color: var(--text); flex: none; }

/* ---------- Progress ---------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; padding: 14px 12px; text-align: center; }
.week-day { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.week-dot { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--track); display: grid; place-items: center; }
.week-dot.is-done { background: var(--primary); border-color: var(--primary); }
.week-dot.is-done svg { width: 14px; height: 14px; fill: none; stroke: var(--on-primary); stroke-width: 2.5; }
.week-day.is-today { color: var(--text); font-weight: 700; }

/* ---------- Profile ---------- */
.profile-card { display: flex; align-items: center; gap: 16px; padding: 14px; }
.avatar {
  flex: none; width: 60px; height: 60px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary); display: grid; place-items: center;
  font-size: 24px; font-weight: 700;
}
.avatar .ic { width: 28px; height: 28px; }
.name-form { flex: 1; min-width: 0; }
.name-row { display: flex; gap: 8px; margin-top: 4px; }
.input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--text);
  height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg);
}
.input:focus { outline: 2px solid var(--success); outline-offset: 1px; border-color: transparent; }
.name-row .btn { min-height: 38px; }
.link-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-decoration: none; color: inherit;
}
.link-row .ic { color: var(--primary); }
.link-row span { flex: 1; font-weight: 600; }
.settings { padding: 14px 16px; }
.settings .muted { margin: 0 0 12px; }

/* ---------- Version 2: shared form pieces ---------- */
.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; }
.form-card { padding: 14px 16px; }
.form-card legend, .choice-set legend { font-weight: 600; font-size: 15px; padding: 0; margin-bottom: 8px; }
fieldset.form-card, .choice-set { border: 1px solid var(--line); min-width: 0; }
/* Keep fieldset titles inside the card instead of on its border. */
fieldset.form-card > legend, .choice-set > legend { float: left; width: 100%; }
fieldset.form-card > legend + *, .choice-set > legend + * { clear: both; }
.choice-set:not(.card) { border: 0; padding: 0; margin: 10px 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: var(--text); margin: 10px 0; }
.field .input { font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-error { color: var(--error); font-size: 13px; margin: 4px 0 0; min-height: 0; }
.field-error:empty { display: none; }
.full { grid-column: 1 / -1; flex-basis: 100%; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
select.input { appearance: auto; }
.note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-2); background: var(--light-gray); border-radius: var(--radius); padding: 10px 12px; }
.note .ic { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.pad { padding: 0 4px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.row-actions .btn { min-height: 40px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 8px 4px; min-height: 40px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--primary); cursor: pointer; text-decoration: none;
}
.link-btn .ic { width: 16px; height: 16px; }
.link-btn.danger { color: var(--error); }
.link-btn.small { min-height: 32px; padding: 4px; font-size: 12px; }
.center-btn { display: flex; margin: 18px auto 0; }
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; font-size: 14px; }
.sum-row + .sum-row { border-top: 1px solid var(--line); }
.sum-ex + .sum-ex { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.sum-ex h3 { margin-bottom: 2px; }
.input.small { width: 84px; height: 36px; text-align: center; flex: none; }
details.fix { margin: 4px 0; }
details.fix summary { font-size: 13px; color: var(--primary); font-weight: 600; cursor: pointer; padding: 6px 0; }

.choice {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: 48px; margin-top: 8px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); cursor: pointer; font-weight: 600; font-size: 14px;
}
.choice input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.choice.is-selected { border-color: var(--primary); background: var(--card); box-shadow: inset 0 0 0 1px var(--primary); }

/* ---------- Active exercise ---------- */
.session-top { display: flex; align-items: center; gap: 8px; margin: -10px -6px 4px; }
.session-meta { flex: 1; display: flex; flex-direction: column; align-items: center; line-height: 1.2; }
.elapsed { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ex-title { margin: 6px 4px 14px; }
.demo-img { width: 100%; max-height: 220px; object-fit: cover; border-radius: var(--radius); display: block; margin: 6px 0; }
.set-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.set-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 4px; }
.set-card.is-done { border-color: var(--success); background: var(--success-soft); }
.set-card.is-skipped { opacity: .7; }
.set-head { display: flex; align-items: center; gap: 8px; }
.set-head strong { font-size: 16px; }
.set-status { margin-left: auto; font-size: 12px; color: var(--text-2); font-weight: 600; }
.is-done .set-status { color: var(--success); }
.set-info { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: 13px; color: var(--text-2); margin: 4px 0 10px; }
.set-info strong { color: var(--text); }
.set-entry { display: flex; gap: 10px; }
.input.big { height: 52px; font-size: 22px; font-weight: 700; text-align: center; flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.set-entry .btn { min-height: 52px; flex: none; min-width: 120px; }
.btn-done { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.btn-done .ic { width: 18px; height: 18px; stroke-width: 2.4; }
.set-foot { display: flex; justify-content: space-between; }
.input[aria-invalid="true"] { border-color: var(--error); }
.btn-finish { background: var(--card); color: var(--primary); border-color: var(--primary); margin-top: 6px; }
.ex-nav .btn .ic { width: 18px; height: 18px; }
.ex-nav > span { flex: 1; }
.exercise.is-link { display: block; text-decoration: none; color: inherit; }
.exercise.is-link .ex-row > .ic { width: 18px; height: 18px; color: var(--text-2); }

/* Rest timer */
.rest-panel {
  position: fixed; left: 0; right: 0; z-index: 20;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 8px 12px; background: transparent; pointer-events: none;
}
.rest-panel[hidden] { display: none; }
.rest-inner {
  pointer-events: auto; max-width: 448px; margin: 0 auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--brand-surface); color: var(--on-brand); border-radius: 12px; padding: 8px 8px 8px 14px;
  box-shadow: 0 8px 24px var(--shadow);
}
.rest-inner > .ic { width: 24px; height: 24px; flex: none; }
.rest-text { flex: 1; display: flex; flex-direction: column; line-height: 1.15; }
.rest-text .tiny { color: var(--on-brand-muted); margin: 0; }
.rest-time { font-size: 24px; font-variant-numeric: tabular-nums; }
.rest-adj {
  min-width: 48px; height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--brand-line);
  background: transparent; color: var(--on-brand); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer;
}
.rest-btn { background: var(--brand-button); color: var(--brand-button-text); min-height: 44px; }
.rest-inner.is-finished { background: var(--success-soft); color: var(--text); border: 1px solid var(--success); }
.rest-inner.is-finished .tiny, .rest-inner.is-finished .rest-adj { color: var(--text-2); }
body.has-rest .page { padding-bottom: 110px; }

/* Feedback */
.fb-q { font-size: 17px !important; }
.effort { display: grid; grid-template-columns: 1fr; gap: 8px; }
.effort-opt {
  display: flex; align-items: center; justify-content: center; min-height: 48px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); font-weight: 600; cursor: pointer; position: relative;
}
.effort-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
/* Difficulty scale: green (very easy) → red (very hard). Text stays the main meaning. */
.lvl-very-easy { --lvl: #2e8b57; --lvl-soft: #e3f1e8; }
.lvl-easy      { --lvl: #6a9a3a; --lvl-soft: #edf3e1; }
.lvl-moderate  { --lvl: #c98a12; --lvl-soft: #faf0d7; }
.lvl-hard      { --lvl: #d8692c; --lvl-soft: #fbe7da; }
.lvl-very-hard { --lvl: #c8413c; --lvl-soft: #f8e1df; }
.effort-opt { border-left: 6px solid var(--lvl, var(--line)); background: var(--lvl-soft, var(--bg)); }
.effort-opt.is-selected { background: var(--lvl, var(--primary)); color: #fff; border-color: var(--lvl, var(--primary)); box-shadow: 0 4px 12px rgba(0,0,0,.12); }
.effort-chip { font-size: 13px; font-weight: 700; padding: 3px 12px; border-radius: 999px; background: var(--lvl-soft); color: var(--lvl); }
.effort-opt:focus-within { outline: 3px solid var(--success); outline-offset: 2px; }
.saved-banner { display: flex; align-items: center; gap: 12px; background: var(--success-soft); color: var(--success); border-radius: var(--radius); padding: 14px 16px; margin: 4px 0 14px; }
.saved-banner .ic { width: 28px; height: 28px; flex: none; }
.saved-banner div { display: flex; flex-direction: column; }
.saved-banner span { color: var(--text-2); font-size: 13px; }
.confirm-card { border-color: var(--warning); background: var(--warning-soft); }

/* Progress */
.week-note { font-size: 13px; color: var(--text-2); margin: 10px 4px 12px; }
.stat-num small { font-size: 15px; color: var(--text-2); font-weight: 600; }
.best-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; }
.best-row + .best-row { border-top: 1px solid var(--line); }
.best-row .right { text-align: right; }
.best-row .right .tiny, .best-row p.tiny { margin: 0; }
.bench-card { padding: 14px 16px; text-decoration: none; color: inherit; }
.bench-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.bench-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.bench-stats div { display: flex; flex-direction: column; }
.bench-stats strong { font-size: 18px; }
.chart { width: 100%; height: auto; margin-top: 12px; display: block; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2; }
.chart .dot { fill: var(--primary); }
.chart .lbl { font-size: 10px; fill: var(--text-2); font-family: inherit; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.inline-form .field { flex: 1 1 120px; margin: 0; }
.inline-form .btn { min-height: 38px; }

/* Learn v2 */
.lesson-progress { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: 8px 0; }
.watch-line { display: flex; align-items: center; gap: 10px; font-size: 14px; flex-wrap: wrap; }
.mini-track.wide { max-width: 120px; width: 120px; }
.complete-box > div { flex: 1; }
.complete-box .done-line + .done-line { margin-top: 4px; }

/* Profile v2 */
.avatar-wrap { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.avatar { overflow: hidden; }
.import-preview { background: var(--light-gray); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; font-size: 13px; }
.import-preview p { margin: 4px 0; }
.btn-danger { margin-top: 8px; }

/* =====================================================================
   Version 3 workout trial
   ===================================================================== */

/* Train → Workouts */
.resume-strip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; margin-top: 12px; text-decoration: none; color: var(--on-brand); background: var(--brand-surface); border-color: var(--primary); }
.resume-strip span { flex: 1; display: flex; flex-direction: column; }
.resume-strip .tiny { color: var(--on-brand-muted); }
.resume-strip .ic { color: var(--on-brand); }
.under-card { margin-top: -6px; margin-bottom: 14px; }
.custom-card { padding: 12px; }
.custom-card.is-archived { opacity: .75; }
.custom-top { display: flex; gap: 12px; text-decoration: none; color: inherit; }
.custom-icon { flex: none; width: 52px; height: 52px; border-radius: var(--radius-sm); background: var(--light-gray); display: grid; place-items: center; color: var(--primary); }
.custom-info { flex: 1; min-width: 0; }
.custom-info h2 { font-size: 17px; }
.custom-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.custom-actions .btn { min-height: 40px; }
details.archived > summary { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 8px 4px; cursor: pointer; }

/* Builder */
.save-status { font-size: 13px; font-weight: 600; margin: -4px 4px 10px; display: flex; align-items: center; gap: 6px; }
.save-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.save-status.is-saved { color: var(--success); }
.save-status.is-unsaved { color: var(--warning-text); }
.save-status.is-error { color: var(--error); }
.warn ul { margin: 6px 0 0; padding-left: 18px; }
.build-section { margin-top: 6px; border-radius: var(--radius); padding: 2px 0 6px; }
.build-section.drop-into { outline: 2px dashed var(--primary); outline-offset: 2px; }
.drop-empty { font-size: 13px; color: var(--text-2); border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 8px; text-align: center; }
.add-ex { margin: 2px 0 8px; }
.builder-actions { margin-top: 18px; }
.builder-actions .btn-block { margin: 8px 0; }
.occ-edit { padding: 10px 12px; position: relative; }
.occ-edit.is-dragging { opacity: .45; }
.occ-edit.drop-before { box-shadow: 0 -3px 0 var(--primary); }
.occ-edit.drop-after { box-shadow: 0 3px 0 var(--primary); }
.occ-head { display: flex; align-items: center; gap: 6px; }
.drag-handle {
  flex: none; width: 36px; height: 44px; border: 0; background: transparent; color: var(--text-2);
  display: grid; place-items: center; cursor: grab; touch-action: none; border-radius: var(--radius-sm);
}
.drag-handle:active { cursor: grabbing; background: var(--light-gray); }
.occ-title { flex: 1; min-width: 0; }
.occ-title .tiny { margin: 0; }
.icon-btn.sm { width: 40px; height: 40px; border: 0; background: transparent; cursor: pointer; }
.icon-btn.sm:disabled { opacity: .3; cursor: default; }
.icon-btn.sm .ic { width: 20px; height: 20px; }
.occ-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 6px 0; }
.mini-seg { display: inline-flex; background: var(--light-gray); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.mini-seg button { font: inherit; font-size: 13px; font-weight: 600; border: 0; background: transparent; padding: 0 12px; height: 34px; border-radius: var(--radius-xs); cursor: pointer; color: var(--text); }
.mini-seg button.is-on { background: var(--primary); color: var(--on-primary); }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; min-height: 40px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; accent-color: var(--primary); }
.quick-fill { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: var(--bg); border-radius: var(--radius-sm); padding: 6px 8px; margin: 6px 0; }
.quick-fill .tiny { margin: 0 4px 0 0; font-weight: 600; }
.quick-fill .input.small { width: 64px; }
.pset-head, .pset { display: grid; grid-template-columns: 24px 1fr 1fr 40px; gap: 6px; align-items: center; }
.occ-edit:has(.pset input[data-b="tload"]) .pset-head, .occ-edit:has(.pset input[data-b="tload"]) .pset { grid-template-columns: 24px 1fr 1fr 1fr 40px; }
.pset-head { font-size: 11px; font-weight: 600; color: var(--text-2); margin-top: 6px; }
.pset { margin: 4px 0; }
.pset .input.small { width: 100%; }
.pset-n { font-size: 13px; font-weight: 700; text-align: center; color: var(--text-2); }
.occ-foot { display: flex; justify-content: space-between; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 6px; }

/* Picker */
.input.search { height: 44px; margin: 0 0 10px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; }
.pick-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px 6px 6px; min-height: 56px; cursor: pointer;
}
.pick-item[hidden] { display: none; }
.pick-item:hover { border-color: var(--primary); }
.pick-thumb { flex: none; width: 44px; height: 44px; border-radius: var(--radius-xs); overflow: hidden; background: var(--light-gray); display: grid; place-items: center; color: var(--text-2); }
.pick-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pick-text { flex: 1; display: flex; flex-direction: column; }
.pick-text .tiny { margin: 0; }
button.link-row { width: 100%; font: inherit; text-align: left; cursor: pointer; }

/* One-page session */
body.in-session .page { padding-top: calc(8px + env(safe-area-inset-top)); }
.sess-head {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 8px;
  margin: 0 calc(-1 * var(--gutter)) 10px; padding: calc(8px + env(safe-area-inset-top)) var(--gutter) 8px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.sess-head .btn { min-height: 40px; flex: none; }
.sess-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.sess-title strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sess-title .elapsed { font-size: 20px; }
.sec-jump { display: flex; gap: 8px; margin: 0 0 6px; }
.chip-btn { font: inherit; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 0 14px; min-height: 36px; cursor: pointer; color: var(--text); }
.sess-section { scroll-margin-top: 76px; }
.sess-sec-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); margin: 16px 4px 8px; }
.ex-card { padding: 10px 10px 4px; margin-bottom: 10px; scroll-margin-top: 76px; }
.ex-card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 10px; margin-bottom: 6px; }
.ex-card-head h3 { font-size: 16px; }
.ex-card-head .tiny { margin: 0; }
.ex-media { margin: 0 0 6px; }
.ex-media > summary { font-size: 12px; font-weight: 600; color: var(--text-2); cursor: pointer; padding: 2px 0 4px; list-style-position: inside; }
.ex-media img { display: block; width: 100%; height: 132px; object-fit: cover; border-radius: var(--radius-sm); }
.video.compact { aspect-ratio: auto; height: 140px; margin: 0; border-radius: var(--radius-sm); }
.no-demo { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); background: var(--bg); border-radius: var(--radius-sm); padding: 8px 10px; margin: 0 0 6px; }
.no-demo .ic { width: 16px; height: 16px; }
.ex-card .ex-notes { font-size: 13px; color: var(--text-2); margin: 0 0 2px; white-space: pre-line; }
.ex-notes.is-clamped { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.set-table { margin-top: 4px; }
.set-tr {
  display: grid; align-items: center; gap: 6px;
  grid-template-columns: 22px minmax(40px, 1fr) 62px 34px 44px 30px;
  padding: 3px 0; border-radius: var(--radius-sm);
}
.has-load .set-tr { grid-template-columns: 22px minmax(40px, 1fr) 54px 58px 34px 44px 30px; }
.set-th { font-size: 11px; font-weight: 600; color: var(--text-2); padding: 0; }
/* Small phones (e.g. 320px wide): tighter columns so weighted rows never overflow (UI 05). */
@media (max-width: 360px) {
  .set-tr { gap: 4px; grid-template-columns: 16px minmax(32px, 1fr) 56px 28px 44px 26px; }
  .has-load .set-tr { grid-template-columns: 16px minmax(32px, 1fr) 48px 50px 28px 44px 26px; }
  .set-tr .rest-mini { width: 28px; }
  .set-tr .menu-btn { width: 26px; }
  .c-target { font-size: 12px; }
  .ex-card { padding-left: 8px; padding-right: 8px; }
}
.set-tr.is-done { background: var(--success-soft); }
.set-tr.is-skipped { opacity: .6; }
.set-tr.is-skipped .input.cell { text-decoration: line-through; }
.c-set { font-weight: 700; font-size: 14px; text-align: center; }
.c-target { font-size: 13px; color: var(--text-2); font-weight: 600; line-height: 1.2; }
.input.cell { width: 100%; height: 44px; padding: 0 4px; text-align: center; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--input-bg); }
.input.cell:disabled { background: transparent; }
.rest-mini { width: 34px; height: 44px; border: 0; background: transparent; color: var(--primary); display: grid; place-items: center; cursor: pointer; border-radius: var(--radius-sm); }
.rest-mini .ic { width: 20px; height: 20px; }
.rest-mini:disabled, .check-btn:disabled { opacity: .35; cursor: not-allowed; }
.check-btn {
  width: 44px; height: 44px; border-radius: var(--radius-sm); border: 2px solid var(--track); background: var(--card);
  display: grid; place-items: center; cursor: pointer; color: transparent;
}
.check-btn .ic { width: 22px; height: 22px; stroke-width: 2.6; }
.check-btn:not(.is-checked):hover { border-color: var(--primary); color: var(--track); }
.check-btn.is-checked { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.skipped-tag { font-size: 11px; font-weight: 700; color: var(--text-2); }
.c-menu { position: relative; }
.menu-btn { width: 30px; height: 44px; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.row-menu {
  position: absolute; right: 0; top: 44px; z-index: 12; min-width: 190px; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 24px var(--shadow); padding: 4px;
}
.row-menu[hidden] { display: none; }
.row-menu button { display: flex; align-items: center; gap: 8px; font: inherit; font-size: 14px; font-weight: 600; text-align: left; border: 0; background: transparent; min-height: 44px; padding: 0 10px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text); }
.row-menu button:hover { background: var(--light-gray); }
.row-menu button.danger { color: var(--error); }
.row-menu .ic { width: 18px; height: 18px; }
.row-err { grid-column: 1 / -1; margin: 0; color: var(--error); font-size: 12px; }
.row-err:empty { display: none; }
.ex-card-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--line); margin-top: 4px; }
.last-panel { background: var(--bg); border-radius: var(--radius-sm); padding: 4px 10px; margin: 0 0 8px; font-size: 13px; }
.last-panel[hidden] { display: none; }
.finish-bottom { margin-top: 14px; }
body.has-rest .page { padding-bottom: 120px; }

.sum-sec { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); margin: 10px 0 4px; }
.sum-inputs { display: inline-flex; gap: 6px; align-items: center; }

/* Dialog + toast undo */
.dialog-actions.stack { flex-direction: column; }
.dialog-actions.stack .btn { width: 100%; }
.dialog h2 { font-size: 18px; margin: 0 0 6px; }
.toast-undo { font: inherit; font-weight: 700; color: var(--primary); background: transparent; border: 0; padding: 4px 8px; cursor: pointer; text-decoration: underline; }
.readonly-banner { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }

/* =====================================================================
   Version 3.1 refinements
   ===================================================================== */

/* CHECK 01–02: flat 32px circle inside a 44px hit area (overrides the V3 square). */
.check-btn {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: inherit;
}
.check-btn .check-circle {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--raised); border: 2px solid var(--check-border); color: var(--check-icon);
  transition: background-color .15s, border-color .15s, color .15s;
}
.check-btn .check-circle .ic { width: 18px; height: 18px; stroke-width: 2.6; }
.check-btn:not(.is-checked):hover .check-circle { border-color: var(--primary); color: var(--primary); }
.check-btn.is-checked .check-circle { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.check-btn:focus-visible { outline: none; }
.check-btn:focus-visible .check-circle { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--success); }
.check-btn:disabled { opacity: 1; cursor: not-allowed; }
.check-btn:disabled .check-circle { border-style: dashed; background: transparent; color: transparent; opacity: .6; }
.set-tr.is-done { background: var(--checked-bg); }
.skipped-btn {
  font: inherit; font-size: 11px; font-weight: 700; color: var(--text-2); background: var(--light-gray);
  border: 0; border-radius: 999px; min-height: 32px; padding: 0 6px; cursor: pointer; display: inline-flex; align-items: center; gap: 2px;
}
@media (prefers-reduced-motion: reduce) { .check-btn .check-circle { transition: none; } }

/* Switch (Uses weights, alerts) */
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; font-weight: 600; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 44px; height: 26px; margin: 0; cursor: pointer; }
.switch-track { width: 44px; height: 26px; border-radius: 999px; background: var(--track); position: relative; flex: none; transition: background-color .15s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--switch-knob); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--success); outline-offset: 2px; }
.switch.is-disabled { opacity: .5; cursor: not-allowed; }
.form-card .switch { display: flex; }

/* Rest picker + builder rows */
.input.select { padding: 0 8px; background: var(--input-bg); }
.rest-pick { display: flex; gap: 4px; min-width: 0; width: 100%; }
.rest-pick .input.select { flex: 1 1 auto; width: auto; min-width: 0; font-size: 13px; }
.rest-pick .input.small:not(.select) { width: 56px; flex: none; }
.occ-edit .pset-head, .occ-edit .pset { grid-template-columns: 22px 72px minmax(0, 1fr) 40px; }
.occ-edit .pset-head.has-load, .occ-edit .pset-list.has-load .pset,
.occ-edit:has(.pset input[data-b="tload"]) .pset-head, .occ-edit:has(.pset input[data-b="tload"]) .pset { grid-template-columns: 22px 64px 54px minmax(0, 1fr) 40px; }
.quick-fill { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.quick-fill > .tiny { grid-column: 1 / -1; margin: 0; }
.quick-fill .input.small { width: 100%; }
.quick-fill .rest-pick { grid-column: 1 / 3; }
.quick-fill .btn { grid-column: 3; grid-row: 2 / 4; align-self: stretch; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; margin: 4px 0; }
.field.inline .select { flex: 1; min-width: 0; }

/* DRAG 01–03: the handle owns the gesture; nothing else on the page loses selection. */
.drag-handle {
  width: 44px; height: 44px; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.drag-handle * { user-select: none; -webkit-user-select: none; pointer-events: none; }
body.is-sorting, body.is-sorting * { user-select: none; -webkit-user-select: none; cursor: grabbing; }
.drag-preview {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60; pointer-events: none;
  width: min(420px, calc(100vw - 32px)); display: flex; align-items: center; gap: 10px;
  background: var(--brand-surface); color: var(--on-brand); border-radius: var(--radius); padding: 10px 14px; box-shadow: 0 12px 28px var(--shadow);
}
.drag-preview span { display: flex; flex-direction: column; line-height: 1.2; }
.drag-preview .tiny { color: var(--on-brand-muted); margin: 0; }
.occ-edit[hidden], .drop-empty[hidden] { display: none; }
.drag-placeholder {
  height: 64px; border: 2px dashed var(--primary); border-radius: var(--radius); background: var(--drag-bg);
  display: grid; place-items: center; margin-bottom: 12px; color: var(--primary);
}
.occ-thumb { flex: none; width: 36px; height: 36px; border-radius: var(--radius-xs); overflow: hidden; background: var(--light-gray); }
.occ-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Photos */
.photo-field { margin: 10px 0; }
.photo-preview { width: 120px; height: 120px; border-radius: var(--radius); border: 1px dashed var(--line); background: var(--bg); display: grid; place-items: center; overflow: hidden; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 4px; }
.pick-row { display: flex; align-items: center; gap: 4px; }
.pick-row[hidden] { display: none; }
.pick-row .pick-item { flex: 1; min-width: 0; }
.media-btn { display: block; width: 100%; padding: 0; border: 0; background: var(--bg); border-radius: var(--radius-sm); cursor: zoom-in; }
.ex-media img.contain, .media-btn img { width: 100%; height: 132px; object-fit: contain; border-radius: var(--radius-sm); display: block; background: var(--bg); }
.media-missing { display: block; font-size: 12px; color: var(--text-2); padding: 10px; }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 16px; }
.lightbox img { max-width: 100%; max-height: 80vh; object-fit: contain; border-radius: var(--radius-sm); }

/* Finishing banner */
.note.finishing { flex-wrap: wrap; background: var(--warning-soft); color: var(--text); margin-bottom: 10px; }
.note.finishing .row-actions { margin: 6px 0 0; width: 100%; }

/* Import from ChatGPT */
.instr { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; margin-top: 10px; height: 96px; }
#pack-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.pack-ex { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.pack-ex .select { max-width: 100%; flex: 1 1 200px; }
.pack-w { padding: 8px 0; border-top: 1px solid var(--line); }
.pack-w .sum-row { align-items: flex-start; }
.pack-w .sum-row > span:last-child { text-align: right; }

/* ---------- Bottom navigation ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 6px 8px env(safe-area-inset-bottom);
  background: var(--nav);
}
.tab {
  flex: 1; max-width: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  text-decoration: none; color: var(--nav-text); font-size: 11px; font-weight: 500;
}
.tab svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tab.is-active { color: var(--nav-active); font-weight: 700; }
.tab.is-active svg { fill: currentColor; stroke-width: 1.5; }
.tab.is-active svg .no-fill { fill: none; }

/* ---------- Toast & dialog ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 30;
  display: flex; align-items: center; gap: 10px;
  background: var(--card); color: var(--text); border: 1px solid var(--success); border-radius: var(--radius);
  padding: 12px 16px; font-weight: 600; font-size: 14px; width: max-content; max-width: calc(100% - 32px);
  box-shadow: 0 8px 24px var(--shadow);
}
.toast svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--success); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.toast.is-error { border-color: var(--error); }
.toast.is-error svg { stroke: var(--error); }
.toast[hidden], .dialog-backdrop[hidden] { display: none; }

.dialog-backdrop {
  position: fixed; inset: 0; z-index: 40; background: var(--overlay);
  display: grid; place-items: center; padding: 16px;
}
.dialog { background: var(--card); border-radius: 12px; padding: 22px; width: 100%; max-width: 360px; }
.dialog p { color: var(--text-2); }
.dialog-actions { display: flex; gap: 10px; margin-top: 18px; }
.dialog-actions .btn { flex: 1; }

/* ---------- Version 3.3: appearance, profile summaries and workout library ---------- */
:root[data-theme="dark"] .lvl-very-easy { --lvl: #88d4a3; --lvl-soft: #203c2d; }
:root[data-theme="dark"] .lvl-easy { --lvl: #b0d485; --lvl-soft: #2d3c23; }
:root[data-theme="dark"] .lvl-moderate { --lvl: #ecc36d; --lvl-soft: #3e321d; }
:root[data-theme="dark"] .lvl-hard { --lvl: #f4b389; --lvl-soft: #432d21; }
:root[data-theme="dark"] .lvl-very-hard { --lvl: #f09b92; --lvl-soft: #432825; }
:root[data-theme="dark"] .effort-opt.is-selected { color: var(--on-primary); }
:root[data-theme="dark"] .switch input:checked + .switch-track::after { background: var(--on-primary); }
.check-btn.is-checked { background: transparent; color: inherit; }
.tabbar { border-top: 1px solid var(--brand-line); }
.dialog { max-height: calc(100dvh - 32px); overflow-y: auto; }
.dialog-actions .btn { min-width: 0; padding-left: 12px; padding-right: 12px; }

/* Menus stay outside their card bounds and retain native details keyboard behavior. */
.profile-section { overflow: visible; position: relative; }
.profile-section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.profile-section-head h2 { min-width: 0; }
.profile-summary { margin: 0; min-width: 0; }
.profile-summary .sum-row { align-items: flex-start; }
.profile-summary .sum-row > :last-child { max-width: 65%; text-align: right; overflow-wrap: anywhere; }
.profile-summary .sum-row:first-child { padding-top: 4px; }
.profile-identity { display: flex; align-items: center; gap: 14px; padding: 4px 0 10px; min-width: 0; }
.profile-identity > :last-child { min-width: 0; overflow-wrap: anywhere; }
.profile-identity h3 { font-size: 18px; }
.profile-menu, .section-menu { position: relative; flex: none; }
.profile-menu > summary, .section-menu > summary {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius-sm);
  list-style: none; cursor: pointer; color: var(--text-2);
}
.profile-menu > summary::-webkit-details-marker, .section-menu > summary::-webkit-details-marker { display: none; }
.profile-menu > summary:hover, .profile-menu[open] > summary,
.section-menu > summary:hover, .section-menu[open] > summary { color: var(--primary); background: var(--light-gray); }
.profile-menu > button, .profile-menu > .menu-content, .section-menu > div {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 25;
  min-width: 150px; max-width: calc(100vw - 64px); padding: 6px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--raised); box-shadow: 0 8px 24px var(--shadow);
}
.profile-menu > button {
  min-height: 44px; padding: 8px 14px; display: flex; align-items: center; gap: 8px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer;
}
.profile-menu > button:hover { background: var(--light-gray); }
.menu-content > button, .section-menu > div > button {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 8px 10px;
  border: 0; border-radius: var(--radius-sm); text-align: left; background: transparent;
  color: var(--text); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.menu-content > button:hover, .section-menu > div > button:hover { background: var(--light-gray); }
.menu-content > button.danger, .section-menu > div > button.danger { color: var(--error); }
.profile-edit-form { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.profile-edit-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.profile-edit-actions .btn { min-height: 44px; }
.profile-section .btn, .profile-section .link-btn, .profile-edit-form .input { min-height: 44px; }
.in-profile #app .btn, .in-profile #app .link-btn, .in-profile #app summary, .in-profile #app .input { min-height: 44px; }
.form-card label.btn:focus-within { outline: 3px solid var(--success); outline-offset: 2px; }
.profile-draft-notice { background: var(--warning-soft); color: var(--warning-text); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; }
.appearance-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-width: 0; }
.appearance-row > div { min-width: 0; }
.appearance-row .switch { flex-shrink: 0; }
.appearance-row .tiny { margin-top: 4px; }

/* Covers and photo edits remain small; full photos open only on request. */
.workout-cover {
  flex: none; width: 64px; height: 64px; border-radius: var(--radius-sm); overflow: hidden;
  display: grid; place-items: center; background: var(--light-gray); color: var(--text-2);
  border: 1px solid var(--line); padding: 0;
}
.workout-cover img, .custom-icon img { display: block; width: 100%; height: 100%; object-fit: cover; }
.workout-cover .media-missing { padding: 4px; font-size: 10px; text-align: center; }
button.workout-cover, .photo-view { cursor: zoom-in; }
.workout-heading { display: flex; align-items: center; gap: 12px; margin: 12px 4px 18px; }
.workout-heading h1 { flex: 1; min-width: 0; margin: 0; overflow-wrap: anywhere; }
.draft-photo-field { margin: 12px 0; }
.draft-photo-field > h3 { font-size: 13px; }
.draft-photo-field .photo-actions { gap: 8px; }
.draft-photo-field .photo-actions .btn, .draft-photo-field .photo-actions .link-btn { min-height: 44px; }
.draft-photo-field .photo-actions label:focus-within { outline: 3px solid var(--success); outline-offset: 2px; }
.draft-photo-field .photo-view {
  width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); background: var(--light-gray);
}
.draft-photo-field[data-photo-key="cover"] .photo-view { width: 64px; height: 64px; }
.draft-photo-field .photo-view .media-missing { padding: 3px; font-size: 9px; }
.custom-icon { overflow: hidden; }
.custom-card { overflow: visible; }
.custom-card[data-workout][hidden] { display: none; }
.custom-info h2 { overflow-wrap: anywhere; }
.custom-actions .section-menu { margin-left: auto; }
.workout-reorder-controls { display: flex; align-items: center; gap: 4px; margin: -4px -4px 8px; }
.workout-reorder-controls .icon-btn, .workout-drag-handle {
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); display: grid; place-items: center; cursor: pointer;
}
.workout-reorder-controls .icon-btn:hover:not(:disabled), .workout-drag-handle:hover { background: var(--light-gray); color: var(--primary); }
.workout-reorder-controls .icon-btn:disabled { opacity: .35; cursor: default; }
.workout-drag-handle {
  margin-right: auto; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.workout-drag-handle:active { cursor: grabbing; }
.workout-drag-handle * { user-select: none; -webkit-user-select: none; pointer-events: none; }
.workout-drag-placeholder {
  min-height: 84px; margin-bottom: 12px; border: 2px dashed var(--primary); border-radius: var(--radius);
  background: var(--drag-bg); display: grid; place-items: center; color: var(--primary); font-weight: 600;
}
.workout-drag-preview {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 60; pointer-events: none;
  width: min(420px, calc(100vw - 32px)); display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--brand-line); border-radius: var(--radius);
  background: var(--brand-surface); color: var(--on-brand); box-shadow: 0 12px 28px var(--shadow);
}
.workout-drag-preview .ic { flex: none; }
.workout-drag-preview strong { min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 375px) {
  .profile-summary .sum-row { gap: 8px; font-size: 13px; }
  .profile-summary .sum-row > :last-child { max-width: 60%; }
  .appearance-row { flex-wrap: wrap; gap: 4px 12px; }
  .draft-photo-field .photo-actions { gap: 4px; }
  .draft-photo-field .photo-actions .btn { padding-left: 10px; padding-right: 10px; }
  .custom-actions { gap: 6px; }
  .custom-actions .btn { padding-left: 12px; padding-right: 12px; }
  .rest-inner { gap: 6px; padding-left: 10px; }
  .rest-inner > .ic { display: none; }
  .rest-adj { min-width: 44px; }
  .rest-btn { padding-left: 12px; padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .splash, .splash-bar span, .progress-track span, .switch-track, .switch-track::after { transition: none; animation-duration: .01s; }
}
