/*
 * Nzh.fit — a quiet, athletic interface with purposeful neon accents.
 * Dark is the fallback. Only the system light preference changes the palette.
 */
:root {
  color-scheme: dark;
  --bg: #090d12;
  --paper: #111820;
  --raised: #18222d;
  --subtle: #0e141c;
  --ink: #eaf0f5;
  --muted: #97a6b5;
  --faint: #7f91a2;
  --line: #26313d;
  --control-border: #52697c;
  --accent: #c8ff45;
  --accent-hover: #d5ff76;
  --accent-ink: #101709;
  --accent-text: #c8ff45;
  --accent-soft: #22351c;
  --cyan: #45e3ff;
  --cyan-text: #78eaff;
  --cyan-soft: #12303b;
  --data-primary: #c8ff45;
  --data-secondary: #45e3ff;
  --purple: #c1adff;
  --purple-soft: #241f36;
  --green: #b0ed88;
  --green-soft: #1a3025;
  --warning: #d4c8ff;
  --warning-soft: #241f36;
  --error: #ffb4b8;
  --error-soft: #351d27;
  --feature: #172119;
  --feature-line: #34452b;
  --nav-bg: #111820f5;
  --backdrop: #020509b3;
  --toast-bg: #eaf0f5;
  --toast-ink: #15212c;
  --focus: #c8ff4599;
  --shadow: 0 24px 70px #00000035;
  --sheet-shadow: 0 -10px 24px #090d121f;
  --orbit-line: #c8ff453d;
  --orbit-glow: #c8ff4512;
  --radius: 18px;
  --mobile-nav-height: 76px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color: var(--ink);
  background: var(--bg);
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f6f8;
    --paper: #ffffff;
    --raised: #edf2f6;
    --subtle: #f7f9fb;
    --ink: #15212c;
    --muted: #5b6c79;
    --faint: #5e7280;
    --line: #d6dfe7;
    --control-border: #80909b;
    --accent: #c8ff45;
    --accent-hover: #b8ef31;
    --accent-ink: #101709;
    --accent-text: #466700;
    --accent-soft: #edf8d5;
    --cyan: #45e3ff;
    --cyan-text: #006779;
    --cyan-soft: #e4f9ff;
    --data-primary: #466700;
    --data-secondary: #006779;
    --purple: #67508f;
    --purple-soft: #f3edff;
    --green: #32683c;
    --green-soft: #e6f3e9;
    --warning: #67508f;
    --warning-soft: #f3edff;
    --error: #a02938;
    --error-soft: #fff0f1;
    --feature: #eaf2df;
    --feature-line: #c9dcb0;
    --nav-bg: #fffffff5;
    --backdrop: #12202d70;
    --toast-bg: #15212c;
    --toast-ink: #f3f6f8;
    --focus: #527e00;
    --shadow: 0 24px 70px #14212d12;
    --sheet-shadow: 0 -10px 24px #14212d08;
    --orbit-line: #537e0038;
    --orbit-glow: #c8ff452b;
  }
}

/* Foundations and type. */
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
a { color: var(--accent-text); -webkit-tap-highlight-color: transparent; }
button:disabled { opacity: .5; cursor: wait; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, .serif { font-family: inherit; }
h1, h2 { letter-spacing: -.045em; font-weight: 570; }
h1 { font-size: clamp(36px, 4.2vw, 56px); line-height: 1.08; }
h2 { font-size: 27px; line-height: 1.2; }
h3 { font-size: 16px; line-height: 1.4; font-weight: 570; }
p { line-height: 1.65; }
small { font-size: 12px; }
svg { width: 20px; height: 20px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 10px; line-height: 1.6; font-weight: 650; }
.mono, .number { font-variant-numeric: tabular-nums; }
.wordmark { font-size: 36px; font-weight: 650; line-height: 1; letter-spacing: -.065em; white-space: nowrap; }
.wordmark span { color: var(--accent-text); font-weight: 430; letter-spacing: -.055em; }
.auth-brand-panel .wordmark, .boot .wordmark { font-size: 46px; }
.boot { min-height: 100dvh; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 28px; padding: 24px; }
.boot p { font-size: 14px; color: var(--muted); text-align: center; }
.skip-link { position: fixed; top: -80px; left: 20px; padding: 12px; z-index: 99; background: var(--paper); }
.skip-link:focus { top: 15px; }
.divider { height: 1px; background: var(--line); margin: 22px 0; }
.stack { display: grid; gap: 16px; }
.spaced { margin-top: 20px; }
.nowrap { white-space: nowrap; }
.danger { color: var(--error); }
.warning-text { font-size: 12px; color: var(--warning); line-height: 1.6; }

/* Shell and desktop navigation. */
.shell { max-width: 1600px; margin: 0 auto; display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { padding: 44px 25px 28px 35px; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; }
.brand-caption { display: block; margin-top: 16px; font-size: 10px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; line-height: 1.6; }
.nav { margin-top: 62px; display: grid; gap: 8px; }
.nav button { border: 1px solid transparent; background: transparent; display: flex; gap: 13px; align-items: center; text-align: left; padding: 13px 14px; border-radius: 13px; color: var(--muted); font-size: 13px; font-weight: 550; min-height: 48px; }
.nav button.active { background: var(--accent-soft); color: var(--accent-text); }
.nav button:hover { color: var(--ink); background: var(--raised); }
.nav button.active:hover { color: var(--accent-text); background: var(--accent-soft); }
.sidebar-footer { margin-top: auto; padding-top: 32px; }
.profile { display: flex; gap: 12px; align-items: center; padding: 18px 0; border-top: 1px solid var(--line); }
.avatar { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--raised); color: var(--cyan-text); font-size: 15px; font-weight: 550; }
.profile strong { display: block; font-size: 13px; font-weight: 550; }
.profile small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.sidebar-footer .text-button { font-size: 12px; color: var(--muted); padding-left: 0; }
.workspace { padding: 0 54px 54px; min-width: 0; }
.topbar { height: 93px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); gap: 20px; }
.topbar-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.topbar-date { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.topbar-date svg { width: 15px; height: 15px; }
.mobile-brand, .mobile-nav { display: none; }
.page { padding-top: 38px; animation: reveal .2s ease; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 30px; }
.page-heading p { font-size: 13px; margin-top: 12px; color: var(--muted); max-width: 540px; }

/* Controls: neon is reserved for primary actions and the current destination. */
.btn { display: inline-flex; justify-content: center; align-items: center; gap: 9px; min-height: 48px; border: 1px solid var(--control-border); padding: 12px 18px; border-radius: 13px; background: var(--raised); color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.4; text-decoration: none; white-space: normal; }
.btn:hover { background: var(--paper); border-color: var(--muted); }
.btn.accent, .btn.light { border-color: transparent; background: var(--accent); color: var(--accent-ink); }
.btn.accent:hover, .btn.light:hover { background: var(--accent-hover); }
.btn.secondary { border-color: var(--line); background: var(--paper); color: var(--ink); }
.btn.secondary:hover { border-color: var(--control-border); background: var(--raised); }
.btn.small { min-height: 40px; padding: 9px 13px; font-size: 12px; }
.btn.full { width: 100%; }
.btn svg { width: 17px; height: 17px; }
.text-button { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 8px 0; border: 0; background: transparent; color: var(--accent-text); font-size: 12px; font-weight: 550; line-height: 1.4; }
.text-button svg { width: 15px; height: 15px; }
.text-button.danger { color: var(--error); }
.icon-button { height: 42px; width: 42px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 13px; background: transparent; }
.icon-button:hover { background: var(--raised); border-color: var(--control-border); }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 7px; background: var(--raised); color: var(--muted); padding: 6px 8px; font-size: 10px; line-height: 1.3; font-weight: 570; letter-spacing: .01em; white-space: nowrap; }
.badge.orange { background: var(--purple-soft); color: var(--purple); }
.badge.green { background: var(--green-soft); color: var(--green); }
.dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* Overview. */
.hero { position: relative; padding: 35px 0 40px; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(150px, .7fr); gap: 30px; align-items: center; }
.hero .eyebrow { color: var(--accent-text); margin-bottom: 20px; }
.hero h1 { max-width: 620px; }
.hero p { max-width: 440px; margin: 20px 0 26px; font-size: 13px; color: var(--muted); }
.hero-art { display: flex; justify-content: center; align-items: center; position: relative; min-height: 255px; overflow: hidden; }
.orbit { width: 226px; height: 226px; position: relative; border-radius: 50%; border: 1px solid var(--orbit-line); display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, var(--orbit-glow), transparent 70%); }
.orbit::before, .orbit::after { content: ""; position: absolute; inset: 14px; border: 1px solid var(--line); border-radius: 50%; }
.orbit::after { inset: 30px; border-style: dashed; }
.orbit-big { font-size: 65px; font-weight: 500; letter-spacing: -.065em; color: var(--accent-text); line-height: 1; }
.orbit-big small { display: block; text-align: center; font-size: 10px; color: var(--muted); letter-spacing: .08em; font-weight: 400; margin-top: 15px; }
.orbit-label { position: absolute; background: var(--bg); padding: 5px 10px; text-transform: uppercase; letter-spacing: .13em; font-size: 9px; color: var(--cyan-text); top: 5px; }
.orbit-star { position: absolute; right: -4px; bottom: 26px; font-size: 25px; color: var(--cyan-text); background: var(--bg); padding: 0 6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 24px 0; margin-bottom: 30px; }
.stat { padding: 0 25px; border-right: 1px solid var(--line); }
.stat:first-child { padding-left: 0; }
.stat:last-child { border-right: 0; }
.stat-label { color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 8px; }
.stat-value { font-size: 33px; font-weight: 530; margin-top: 10px; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 11px; font-weight: 400; letter-spacing: 0; color: var(--muted); margin-left: 6px; }
.two-col { display: grid; grid-template-columns: 1.15fr 1fr; gap: 24px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); padding: 25px; }
.panel.dark { background: var(--feature); color: var(--ink); border-color: var(--feature-line); }
.panel.dark .muted { color: var(--muted); }
.panel-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 22px; }
.panel-head h2 { font-size: 23px; }
.panel-head h3 { font-size: 14px; }
.panel-label { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.dark .panel-label { color: var(--muted); }
.workout-label { font-size: 64px; font-weight: 530; letter-spacing: -.055em; line-height: 1; color: var(--accent-text); }
.workout-title { margin-top: 12px; font-size: 19px; line-height: 1.4; }
.workout-sub { font-size: 12px; margin-top: 10px; color: var(--muted); }
.dark .workout-sub { color: var(--muted); }
.workout-line { display: flex; align-items: center; gap: 10px; font-size: 12px; padding: 22px 0; margin-top: 2px; border-bottom: 1px solid var(--feature-line); }
.workout-line svg { width: 16px; height: 16px; color: var(--accent-text); }
.dark .btn { margin-top: 20px; }
.cycle-description { font-size: 13px; }
.cycle-strip { display: flex; gap: 8px; margin-top: 22px; }
.cycle-step { flex: 1; text-align: center; position: relative; padding: 14px 5px; border: 1px solid var(--line); border-radius: 11px; background: var(--subtle); font-size: 13px; font-weight: 600; }
.cycle-step.current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.cycle-step small { display: block; font-size: 9px; line-height: 1.4; font-weight: 400; margin-top: 7px; }
.review-note { display: flex; gap: 12px; background: var(--warning-soft); border-radius: 13px; padding: 16px 18px; font-size: 13px; line-height: 1.65; color: var(--warning); }
.review-note svg { width: 18px; height: 18px; margin-top: 2px; }
.review-note strong { font-weight: 600; }
.notice { padding: 15px 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--cyan-soft); font-size: 13px; line-height: 1.65; color: var(--cyan-text); }
.section-label { display: flex; justify-content: space-between; align-items: center; margin: 32px 0 16px; gap: 15px; }
.section-label h2 { font-size: 26px; }
.section-label small { color: var(--muted); }
.empty-small { padding: 23px 0 13px; }
.empty-small h3 { font-size: 16px; margin-bottom: 10px; }
.empty-small p { font-size: 13px; color: var(--muted); }
.empty-state { padding: 54px 25px; text-align: center; max-width: 550px; margin: auto; }
.empty-state .empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; background: var(--accent-soft); border: 1px solid var(--line); margin: 0 auto 20px; color: var(--accent-text); }
.empty-state .empty-icon svg { width: 25px; height: 25px; }
.empty-state h2 { font-size: 28px; }
.empty-state p { font-size: 14px; color: var(--muted); margin: 14px 0 24px; }

/* Program, versions, and exercise catalog. */
.program-intro { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 24px; }
.program-intro h2 { font-size: 30px; margin-top: 10px; }
.program-intro p { max-width: 570px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.program-metrics { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 25px; padding-top: 23px; border-top: 1px solid var(--line); }
.program-metrics strong { display: block; font-size: 26px; font-weight: 530; letter-spacing: -.04em; }
.program-metrics small { display: block; font-size: 11px; color: var(--muted); margin-top: 6px; }
.template-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 22px; }
.template-card { padding: 23px; }
.template-card .template-code { font-size: 37px; font-weight: 530; letter-spacing: -.045em; line-height: 1; }
.template-card .panel-head { align-items: flex-start; }
.template-card .template-focus { font-size: 12px; color: var(--muted); margin-top: 9px; }
.template-slot { display: flex; gap: 12px; font-size: 12px; line-height: 1.6; padding: 11px 0; border-top: 1px solid var(--line); }
.template-slot .slot-num { color: var(--muted); width: 16px; flex-shrink: 0; font-size: 11px; padding-top: 1px; }
.template-slot .slot-text { flex: 1; min-width: 0; }
.template-slot .slot-target { font-size: 11px; color: var(--muted); white-space: nowrap; }
.template-slot .alternative { color: var(--cyan-text); }
.version-list { display: grid; gap: 10px; }
.version-item { display: flex; justify-content: space-between; align-items: center; border: 1px solid var(--line); border-radius: 13px; padding: 16px 18px; gap: 15px; background: var(--paper); }
.version-item h3 { font-size: 13px; }
.version-item small { font-size: 11px; color: var(--muted); display: block; margin-top: 6px; }
.toolbar { display: flex; align-items: center; gap: 13px; margin: 24px 0 20px; flex-wrap: wrap; }
.search { position: relative; flex: 1; min-width: 200px; }
.search svg { position: absolute; left: 15px; top: 15px; width: 18px; height: 18px; color: var(--muted); }
.search input { width: 100%; padding-left: 43px; }
.filter-select { max-width: 220px; }
.catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.exercise-card { display: flex; align-items: flex-start; gap: 17px; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); text-align: left; width: 100%; transition: border-color .15s, background .15s; min-height: 131px; }
.exercise-card:hover { border-color: var(--control-border); background: var(--raised); }
.group-icon { width: 42px; height: 42px; border-radius: 13px; background: var(--cyan-soft); color: var(--cyan-text); display: grid; place-items: center; flex-shrink: 0; }
.exercise-card:nth-child(3n) .group-icon { background: var(--purple-soft); color: var(--purple); }
.exercise-card-text { flex: 1; min-width: 0; }
.exercise-card h3 { font-size: 14px; font-weight: 550; }
.exercise-card .en { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.exercise-card .group-line { font-size: 10px; color: var(--muted); margin-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.exercise-card > svg { width: 16px; height: 16px; color: var(--muted); align-self: center; }
.filters-count { font-size: 12px; color: var(--muted); }

/* Workout session and saved history. */
.workout-header { display: flex; align-items: flex-start; gap: 24px; }
.workout-header .workout-label { font-size: 72px; flex-shrink: 0; }
.workout-header h1 { font-size: 38px; }
.workout-header p { font-size: 13px; color: var(--muted); margin-top: 9px; }
.workout-progress { display: flex; align-items: center; gap: 20px; margin: 28px 0; }
.progress-track { height: 6px; flex: 1; background: var(--raised); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--data-primary); border-radius: 6px; }
.workout-progress small { color: var(--muted); white-space: nowrap; font-size: 11px; }
.workout-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.exercise-list { display: grid; gap: 12px; }
.workout-exercise { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 17px; align-items: center; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); padding: 20px; }
.workout-exercise.saved { border-left: 3px solid var(--green); padding-left: 18px; }
.workout-exercise .index { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.workout-exercise .index svg { color: var(--green); width: 21px; height: 21px; }
.workout-exercise h3 { font-size: 15px; font-weight: 550; }
.workout-exercise .en { display: block; font-size: 11px; color: var(--muted); margin-top: 5px; }
.workout-exercise .exercise-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 11px; font-size: 11px; color: var(--muted); }
.workout-exercise .result-inline { color: var(--green); font-weight: 550; }
.workout-exercise .btn { min-width: 100px; }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 18px 0; border-top: 1px solid var(--line); }
.history-row:first-child { border-top: 0; }
.history-row-main { display: flex; align-items: center; gap: 15px; min-width: 0; }
.session-code { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; background: var(--raised); color: var(--cyan-text); flex-shrink: 0; font-size: 19px; font-weight: 550; letter-spacing: -.03em; }
.history-row strong { display: block; font-size: 13px; font-weight: 550; line-height: 1.4; }
.history-row small { display: block; font-size: 11px; color: var(--muted); margin-top: 5px; }
.history-row .text-button { flex-shrink: 0; }
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table th { text-align: left; text-transform: uppercase; letter-spacing: .07em; font-size: 10px; color: var(--muted); padding: 14px 12px; border-bottom: 1px solid var(--line); font-weight: 500; }
.history-table td { padding: 18px 12px; border-bottom: 1px solid var(--line); line-height: 1.6; }
.history-table th:first-child, .history-table td:first-child { padding-left: 0; }
.history-table th:last-child, .history-table td:last-child { padding-right: 0; }
.history-table tbody tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }
.history-table .date-cell { white-space: nowrap; }
.history-table td small { font-size: 10px; color: var(--muted); }
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 110px; margin: 25px 0 10px; border-bottom: 1px solid var(--line); padding: 0 6px; }
.chart-bar { flex: 1; max-width: 55px; background: var(--data-secondary); border-radius: 6px 6px 0 0; min-height: 4px; position: relative; }
.chart-bar:last-child { background: var(--data-primary); }
.chart-bar span { position: absolute; top: -20px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }
.chart-caption { font-size: 11px; color: var(--muted); line-height: 1.6; }

/* Input, result, and assessment forms. */
.field { display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.field > span { font-weight: 550; color: var(--muted); }
.field input, .field select, .field textarea, input.input, select.input { min-height: 48px; border: 1px solid var(--control-border); border-radius: 11px; background: var(--subtle); color: var(--ink); padding: 11px 13px; max-width: 100%; width: 100%; }
input.input, select.input { font-size: 13px; }
.field textarea { resize: vertical; min-height: 80px; }
.field input::placeholder, .field textarea::placeholder, input.input::placeholder { color: var(--faint); opacity: 1; }
.field input[readonly] { background: var(--raised); color: var(--muted); }
.field small { font-size: 11px; line-height: 1.5; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-grid.three { grid-template-columns: repeat(3, 1fr); }
.form-stack { display: grid; gap: 20px; }
.last-result { padding: 15px 17px; background: var(--raised); border-radius: 12px; display: flex; justify-content: space-between; align-items: center; gap: 14px; font-size: 13px; }
.last-result strong { display: block; font-weight: 600; margin-top: 6px; }
.last-result small { font-size: 11px; color: var(--muted); }
.last-result .text-button { flex-shrink: 0; }
.set-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.set-grid .field { text-align: center; }
.set-grid input { text-align: center; font-size: 26px; padding: 12px 4px; height: 66px; font-weight: 550; font-variant-numeric: tabular-nums; }
.set-grid .field > span { font-size: 11px; color: var(--muted); font-weight: 450; }
.weight-entry { display: grid; grid-template-columns: 1fr 1.6fr; gap: 16px; align-items: start; }
.weight-entry input { font-size: 24px; font-weight: 530; min-height: 56px; }
.weight-entry select { min-height: 56px; font-size: 13px; }
.form-section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.form-section-title h3 { font-size: 14px; font-weight: 550; }
.form-section-title small { font-size: 11px; color: var(--muted); }
details.advanced { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 15px 0; }
details.advanced summary { cursor: pointer; font-size: 13px; color: var(--muted); list-style: none; display: flex; align-items: center; gap: 7px; min-height: 28px; }
details.advanced summary::after { content: "+"; margin-left: auto; font-size: 20px; color: var(--accent-text); }
details.advanced[open] summary::after { content: "−"; }
details.advanced[open] summary { margin-bottom: 18px; }
.per-set-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 14px; }
.per-set-grid .field > span { font-size: 10px; }
.per-set-grid input { padding: 10px 6px; text-align: center; font-size: 14px; }
.checkbox-row { display: flex; align-items: flex-start; gap: 10px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.checkbox-row input { accent-color: var(--accent-text); width: 18px; height: 18px; margin: 1px 0 0; flex-shrink: 0; }
.warmup-list { display: grid; gap: 10px; margin-top: 15px; }
.warmup-row { display: grid; grid-template-columns: 1fr 1fr 40px; gap: 10px; align-items: end; }
.warmup-row .icon-button { width: 40px; height: 48px; border: 0; border-radius: 10px; color: var(--error); }
.draft-status { font-size: 11px; color: var(--muted); line-height: 1.6; min-height: 16px; }
.form-error { padding: 13px 15px; border-radius: 11px; background: var(--error-soft); color: var(--error); font-size: 13px; line-height: 1.6; display: none; }
.form-error:not(:empty) { display: block; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding-top: 3px; }
.form-actions .spacer { flex: 1; }
.assessment { padding: 18px; border: 1px solid var(--line); border-radius: 13px; font-size: 13px; line-height: 1.6; background: var(--subtle); }
.assessment.eligible { border-color: var(--green); background: var(--green-soft); }
.assessment h3 { font-size: 15px; margin-bottom: 8px; }
.assessment ul { padding-left: 18px; margin: 10px 0 0; }
.assessment .muted { margin-top: 10px; font-size: 12px; }
.metadata-list { display: grid; gap: 18px; }
.metadata-list dt { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.metadata-list dd { margin: 0; font-size: 14px; line-height: 1.6; }
.choice-list { display: grid; gap: 10px; }
.choice-item { display: flex; align-items: center; gap: 12px; padding: 17px; border: 1px solid var(--control-border); border-radius: 12px; cursor: pointer; font-size: 13px; line-height: 1.5; }
.choice-item input { accent-color: var(--accent-text); width: 18px; height: 18px; flex-shrink: 0; }
.choice-item:has(input:checked) { background: var(--accent-soft); border-color: var(--accent-text); }
.choice-item strong { font-size: 22px; letter-spacing: -.04em; width: 42px; flex-shrink: 0; font-weight: 530; }
.timer-value { font-size: 84px; font-weight: 500; text-align: center; letter-spacing: -.06em; margin: 20px 0 25px; font-variant-numeric: tabular-nums; }
.timer-presets { display: flex; gap: 8px; justify-content: center; margin-bottom: 25px; }
.timer-presets .btn { min-width: 65px; }

/* Account, login, notifications, and dialogs share the same palette. */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.settings-grid .panel h2 { font-size: 25px; margin-bottom: 10px; }
.settings-grid .panel p { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.settings-grid .panel .btn { margin-top: 5px; }
.auth-layout { min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; max-width: 1600px; margin: auto; }
.auth-brand-panel { background: var(--subtle); border-right: 1px solid var(--line); padding: 55px 65px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth-brand-panel .brand-caption { margin-top: 18px; }
.auth-statement { margin: auto 0; padding: 75px 0; }
.auth-statement .eyebrow { color: var(--accent-text); margin-bottom: 20px; }
.auth-statement h1 { font-size: clamp(46px, 5.5vw, 72px); line-height: 1.07; max-width: 530px; }
.auth-statement p { font-size: 14px; max-width: 320px; color: var(--muted); margin-top: 25px; }
.auth-cycle { display: flex; gap: 15px; font-size: 17px; font-weight: 530; color: var(--cyan-text); align-items: center; }
.auth-cycle i { width: 24px; height: 1px; background: var(--control-border); }
.auth-footer { font-size: 11px; color: var(--muted); line-height: 1.6; }
.auth-main { display: flex; flex-direction: column; justify-content: center; padding: 60px 70px; max-width: 580px; margin: auto; width: 100%; }
.auth-main .eyebrow { color: var(--muted); margin-bottom: 16px; }
.auth-main h2 { font-size: 39px; }
.auth-main > p { font-size: 14px; color: var(--muted); margin: 15px 0 30px; }
.auth-main .field { font-size: 13px; }
.auth-main .btn { min-height: 50px; }
.auth-note { margin-top: 25px; font-size: 12px !important; color: var(--muted); }
.auth-main .mobile-brand { margin-bottom: 45px; }
.toast { position: fixed; bottom: 30px; left: 50%; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--toast-bg); color: var(--toast-ink); padding: 14px 20px; border-radius: 13px; font-size: 13px; line-height: 1.6; max-width: min(600px, calc(100% - 32px)); width: max-content; z-index: 80; box-shadow: var(--shadow); transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--error-soft); color: var(--error); border: 1px solid var(--error); }
dialog { border: 1px solid var(--line); border-radius: 22px; padding: 0; max-width: 620px; width: calc(100% - 32px); max-height: calc(100dvh - 50px); background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
dialog::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
.modal-head { padding: 24px 28px 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); z-index: 2; }
.modal-head h2 { font-size: 26px; line-height: 1.2; }
.modal-head .eyebrow { color: var(--accent-text); margin-bottom: 9px; }
.modal-head p { font-size: 11px; color: var(--muted); margin-top: 8px; }
.modal-head .icon-button { flex-shrink: 0; width: 36px; height: 36px; }
.modal-head svg { width: 17px; height: 17px; }
.modal-body { padding: 25px 28px 28px; }
.modal-body > p { font-size: 14px; color: var(--muted); margin-bottom: 20px; }
.modal-body .review-note { margin-bottom: 22px; }
.modal-body .section-label { margin-top: 24px; }
.modal-body .section-label h2 { font-size: 23px; }
@keyframes reveal { from { opacity: .3; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* Wide and intermediate desktop widths. */
@media (min-width: 1400px) {
  .workspace { padding-left: 70px; padding-right: 70px; }
  .hero { padding-top: 45px; padding-bottom: 45px; }
  .hero h1 { font-size: 59px; }
}
@media (max-width: 1100px) {
  .shell { grid-template-columns: 190px minmax(0, 1fr); }
  .sidebar { padding-left: 25px; padding-right: 18px; }
  .workspace { padding-left: 30px; padding-right: 30px; }
  .nav button { font-size: 12px; padding: 12px 10px; }
  .hero-art .orbit { width: 190px; height: 190px; }
  .orbit-big { font-size: 56px; }
  .two-col { gap: 16px; }
  .panel { padding: 21px; }
  .auth-brand-panel, .auth-main { padding: 45px; }
  .catalog-grid { gap: 10px; }
  .exercise-card { padding: 16px; gap: 12px; }
  .group-icon { width: 34px; height: 34px; }
  .program-intro { grid-template-columns: 1fr; }
  .template-grid { gap: 13px; }
}

/* Touch layout, including phones held in landscape. */
@media (max-width: 900px), (max-width: 1200px) and (pointer: coarse) {
  html { scroll-padding-bottom: calc(var(--mobile-nav-height) + 24px); }
  body { -webkit-text-size-adjust: 100%; }
  body:has(dialog[open]) { overflow: hidden; }
  .shell { display: block; }
  .sidebar { display: none; }
  .workspace { width: 100%; max-width: 900px; margin-inline: auto; padding: 0 max(22px, env(safe-area-inset-right)) calc(var(--mobile-nav-height) + 30px + env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left)); }
  .topbar { height: 76px; gap: 12px; }
  .topbar-label { display: none; }
  .mobile-brand { display: block; font-size: 32px; }
  .topbar-date { gap: 8px; font-size: 12px; line-height: 1.4; }
  .topbar-date > svg { display: none; }
  .topbar-date .icon-button { margin-left: 3px; }
  .page { padding-top: 26px; }
  .page-heading { align-items: flex-start; margin-bottom: 24px; }
  .page-heading > div { min-width: 0; }
  .page-heading h1 { font-size: clamp(31px, 5vw, 42px); }
  .page-heading h1.spaced { margin-top: 13px; }
  .page-heading p { font-size: 14px; line-height: 1.65; margin-top: 13px; }
  h1, h2, h3, p, dd, .slot-text { overflow-wrap: anywhere; }
  .eyebrow { font-size: 11px; letter-spacing: .09em; }
  .section-label { gap: 12px; margin: 28px 0 16px; flex-wrap: wrap; }
  .section-label h2 { font-size: 26px; }
  .section-label > small { font-size: 12px; }

  /* Fixed five-tab bar and home-indicator space. */
  .mobile-nav { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; position: fixed; inset: auto 0 0; z-index: 30; min-height: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom)); padding: 8px max(8px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); background: var(--nav-bg); border-top: 1px solid var(--line); box-shadow: var(--sheet-shadow); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
  .mobile-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 56px; min-width: 0; padding: 7px 2px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.15; letter-spacing: -.02em; }
  .mobile-nav button svg { width: 22px; height: 22px; }
  .mobile-nav button.active { background: var(--accent); color: var(--accent-ink); }
  .mobile-nav button.active svg { stroke-width: 2; }
  .mobile-nav button span { max-width: 100%; }

  /* Minimum touch areas and 16px inputs prevent iOS focus zoom. */
  .btn, .btn.small, .version-item .btn, .workout-actions .btn { min-height: 48px; padding: 12px 16px; font-size: 14px; line-height: 1.4; border-radius: 14px; }
  .btn svg { width: 18px; height: 18px; }
  .text-button, .history-row .text-button, .last-result .text-button { min-height: 48px; padding: 10px 4px; font-size: 14px; line-height: 1.4; }
  .icon-button, .modal-head .icon-button, .warmup-row .icon-button { width: 48px; height: 48px; min-width: 48px; min-height: 48px; }
  .icon-button svg { width: 20px; height: 20px; }
  .field { font-size: 14px; gap: 8px; }
  .field input, .field select, .field textarea, input.input, select.input { min-height: 52px; min-width: 0; padding: 13px 12px; font-size: 16px; line-height: 1.4; border-radius: 12px; scroll-margin-block: 100px; }
  .field textarea { min-height: 100px; }
  .field small { font-size: 12px; line-height: 1.6; }
  .checkbox-row { font-size: 14px; line-height: 1.6; min-height: 48px; align-items: flex-start; padding-block: 6px; }
  .checkbox-row input { width: 22px; height: 22px; margin-top: 1px; }
  .choice-item { min-height: 64px; padding: 16px; font-size: 14px; }
  .choice-item input { width: 22px; height: 22px; }
  .choice-item small { font-size: 12px; }
  .badge { font-size: 11px; line-height: 1.4; white-space: normal; }
  .panel { padding: 22px; }
  .panel-head { align-items: flex-start; }
  .panel-head h2 { font-size: 25px; }
  .panel-label { font-size: 11px; letter-spacing: .09em; }

  /* The next workout is the focus; decoration stays off phone screens. */
  .hero { grid-template-columns: 1fr; gap: 0; padding: 5px 0 25px; }
  .hero-art { display: none; }
  .hero .eyebrow { margin-bottom: 14px; font-size: 11px; max-width: none; }
  .hero h1 { font-size: clamp(33px, 5.6vw, 47px); line-height: 1.08; }
  .hero p { max-width: 570px; margin: 16px 0 20px; font-size: 14px; line-height: 1.65; }
  .hero .btn { min-height: 52px; }
  .stats { padding: 20px 0; margin-bottom: 24px; }
  .stat { padding-inline: 17px; min-width: 0; }
  .stat-label { font-size: 12px; line-height: 1.5; }
  .stat-value { font-size: 31px; margin-top: 9px; }
  .stat-value small { display: block; font-size: 12px; line-height: 1.5; margin: 3px 0 0; }
  .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .cycle-description { font-size: 14px; line-height: 1.65; }
  .cycle-strip { gap: 7px; }
  .cycle-step { padding: 14px 5px; font-size: 15px; }
  .cycle-step small { font-size: 11px; line-height: 1.4; margin-top: 7px; }
  .workout-title { font-size: 20px; }
  .workout-sub, .workout-line { font-size: 14px; line-height: 1.6; }
  .workout-line { padding: 18px 0; }
  .empty-small h3 { font-size: 18px; }
  .empty-small p, .empty-state p { font-size: 14px; line-height: 1.65; }
  .empty-state { padding: 35px 10px; }
  .empty-state h2 { font-size: 29px; }
  .review-note, .notice, .warning-text { font-size: 14px; line-height: 1.65; }
  .review-note, .notice { padding: 16px; }

  .workout-header { gap: 20px; }
  .workout-header > div { min-width: 0; }
  .workout-header .workout-label { font-size: 63px; }
  .workout-header h1 { font-size: 32px; line-height: 1.15; }
  .workout-header p { font-size: 14px; line-height: 1.6; }
  .workout-progress { margin: 24px 0; gap: 15px; }
  .progress-track { height: 7px; }
  .workout-progress small { font-size: 12px; }
  .workout-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .workout-actions .accent { grid-column: 1 / -1; }
  .workout-actions .text-button { font-size: 14px; }
  .exercise-list { gap: 14px; }
  .workout-exercise { grid-template-columns: 28px minmax(0, 1fr); gap: 14px; padding: 20px; }
  .workout-exercise.saved { padding-left: 18px; }
  .workout-exercise .index { align-self: start; padding-top: 3px; font-size: 14px; }
  .workout-exercise h3 { font-size: 17px; line-height: 1.4; }
  .workout-exercise .en { font-size: 13px; line-height: 1.5; margin-top: 6px; }
  .workout-exercise .exercise-meta { font-size: 14px; line-height: 1.6; gap: 6px 12px; }
  .workout-exercise .exercise-meta > span { display: block; width: 100%; }
  .workout-exercise .btn { grid-column: 1 / -1; width: 100%; justify-self: stretch; min-height: 50px; margin-top: 2px; }

  /* Catalog and history wrap in their own containers, never the page. */
  .toolbar { gap: 12px; }
  .search { min-width: 0; flex-basis: 100%; }
  .search input { padding-left: 44px; }
  .search svg { top: 17px; }
  .filter-select { max-width: none; flex: 1; }
  .filters-count { font-size: 12px; }
  .catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .exercise-card { min-height: 138px; padding: 20px; gap: 14px; }
  .exercise-card h3 { font-size: 16px; line-height: 1.4; }
  .exercise-card .en { display: block; font-size: 13px; line-height: 1.5; }
  .exercise-card .group-line { font-size: 12px; line-height: 1.5; }
  .exercise-card > svg { width: 18px; height: 18px; }
  .history-row { gap: 12px; }
  .history-row strong { font-size: 15px; line-height: 1.5; }
  .history-row small { font-size: 12px; line-height: 1.6; }
  .history-row-main { gap: 12px; }
  .session-code { width: 46px; height: 46px; font-size: 21px; }
  .table-scroll { max-width: 100%; -webkit-overflow-scrolling: touch; }
  .history-table { min-width: 0; table-layout: fixed; font-size: 14px; }
  .history-table th { font-size: 11px; padding-inline: 7px; overflow-wrap: anywhere; }
  .history-table td { padding: 15px 7px; overflow-wrap: anywhere; }
  .history-table td small { font-size: 12px; line-height: 1.5; }
  .history-table .date-cell { white-space: normal; }
  .history-table .text-button { min-width: 0; font-size: 13px; padding-inline: 0; }
  .program-intro { grid-template-columns: 1fr; gap: 16px; }
  .program-intro p { font-size: 14px; line-height: 1.65; }
  .program-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 16px; }
  .program-metrics small { font-size: 12px; line-height: 1.5; }
  .template-grid { gap: 16px; }
  .template-card .template-focus { font-size: 14px; line-height: 1.5; }
  .template-slot { gap: 10px; padding-block: 13px; font-size: 14px; line-height: 1.6; }
  .template-slot .slot-num, .template-slot .slot-target, .template-slot small { font-size: 12px; }
  .version-item h3 { font-size: 15px; }
  .version-item small { font-size: 12px; line-height: 1.6; }
  .metadata-list dt { font-size: 12px; }
  .metadata-list dd { font-size: 14px; line-height: 1.65; }
  .settings-grid .panel p { font-size: 14px; line-height: 1.65; }

  /* The sheet follows visualViewport when the phone keyboard is visible. */
  dialog { width: min(680px, calc(100% - 24px)); max-width: none; max-height: calc(var(--visual-viewport-height, 100dvh) - 24px - env(safe-area-inset-top)); border-radius: 22px; overscroll-behavior: contain; scroll-padding-block: 100px; }
  .modal-head { gap: 12px; align-items: flex-start; padding: 20px 24px; }
  .modal-head > div { min-width: 0; }
  .modal-head h2 { font-size: 26px; line-height: 1.2; }
  .modal-head .eyebrow { font-size: 11px; }
  .modal-head p { font-size: 13px; line-height: 1.5; }
  .modal-head .icon-button { margin-top: -3px; }
  .modal-body { padding: 24px; }
  .modal-body > p { font-size: 14px; line-height: 1.65; }
  .modal-body .form-stack { gap: 22px; }
  .modal-body .form-actions { position: sticky; bottom: 0; z-index: 3; display: flex; gap: 10px; flex-wrap: wrap; margin: 4px -24px -1px; padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); box-shadow: var(--sheet-shadow); }
  .modal-body .form-actions .spacer { display: none; }
  .modal-body .form-actions .btn { flex: 1 1 180px; min-width: 0; min-height: 52px; }
  .modal-body .form-actions .text-button { flex: 1 1 120px; min-width: 0; justify-content: center; font-size: 14px; }
  .modal-body .form-actions:has(> .btn:only-child) > .btn { width: 100%; }
  .field-grid, .field-grid.three { gap: 16px; }
  .weight-entry { grid-template-columns: minmax(110px, .8fr) minmax(0, 1.3fr); gap: 16px; }
  .weight-entry input { min-height: 60px; font-size: 27px; }
  .weight-entry select { min-height: 60px; font-size: 16px; padding: 12px; }
  .form-section-title { flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin-bottom: 14px; }
  .form-section-title h3 { font-size: 15px; }
  .form-section-title small { font-size: 12px; }
  .set-grid { gap: 10px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .set-grid .field > span { font-size: 12px; }
  .set-grid input { height: 70px; padding: 12px 3px; font-size: 30px; text-align: center; border-width: 1.5px; }
  .set-grid input:focus { border-color: var(--accent-text); background: var(--accent-soft); }
  .per-set-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
  .per-set-grid .field > span { font-size: 11px; line-height: 1.5; }
  .per-set-grid input { min-height: 52px; padding: 12px 3px; font-size: 16px; }
  .warmup-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 48px; gap: 10px; }
  details.advanced { padding-block: 12px; }
  details.advanced summary { min-height: 48px; font-size: 14px; line-height: 1.5; }
  .last-result { padding: 16px; align-items: flex-start; flex-wrap: wrap; font-size: 14px; }
  .last-result > div { min-width: 0; flex: 1 1 160px; }
  .last-result strong { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; }
  .last-result small { font-size: 12px; line-height: 1.5; }
  .last-result .text-button { padding-block: 4px; }
  .draft-status { font-size: 12px; line-height: 1.65; }
  .form-error { padding: 14px; font-size: 14px; line-height: 1.6; }
  .assessment { font-size: 14px; line-height: 1.6; }
  .assessment h3 { font-size: 16px; }
  .assessment .muted, .chart-caption { font-size: 12px; line-height: 1.6; }
  .chart-bar span { font-size: 12px; }
  #performance-form > small { font-size: 12px; line-height: 1.6; }
  .timer-presets { flex-wrap: wrap; gap: 10px; }
  .timer-presets .btn { flex: 1; min-width: 58px; }

  .auth-layout { display: block; min-height: 100dvh; }
  .auth-brand-panel { display: none; }
  .auth-main { min-height: 100dvh; max-width: 500px; margin: auto; padding: 40px 28px; }
  .auth-main .mobile-brand { display: block; margin-bottom: 36px; font-size: 42px; }
  .auth-main h2 { font-size: 38px; }
  .auth-main > p, .auth-main .field { font-size: 14px; line-height: 1.65; }
  .auth-main .eyebrow { font-size: 11px; }
  .auth-main .btn { min-height: 52px; }
  .auth-note { font-size: 12px !important; line-height: 1.6; }
  .auth-note svg { width: 15px; height: 15px; vertical-align: -3px; }
  .toast { bottom: calc(var(--mobile-nav-height) + 16px + env(safe-area-inset-bottom)); font-size: 14px; max-width: calc(100% - 32px); padding: 14px 18px; }
}

/* Phone portrait: single-column content and an edge-to-edge bottom sheet. */
@media (max-width: 600px) {
  .workspace { padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
  .topbar { height: 70px; gap: 8px; }
  .mobile-brand { font-size: 29px; }
  .topbar-date { font-size: 11px; gap: 5px; }
  .topbar-date .icon-button { margin-left: 0; }
  .page { padding-top: 23px; }
  .page-heading { display: block; }
  .page-heading > .btn { width: 100%; margin-top: 18px; }
  .page-heading > .badge { margin-top: 14px; }
  .hero h1 { font-size: clamp(31px, 8.5vw, 39px); }
  .hero .btn { width: 100%; }
  .hero p { margin-bottom: 18px; }
  .stats { padding-block: 18px; }
  .stat { padding-inline: 12px; }
  .stat-label { font-size: 11px; }
  .stat-value { font-size: 29px; }
  .stat-value small { font-size: 11px; }
  .two-col, .template-grid, .catalog-grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 20px; }
  .dark-workout-body { display: flex; align-items: center; gap: 22px; }
  .panel.dark .workout-label { font-size: 57px; flex-shrink: 0; }
  .panel.dark .workout-title { margin-top: 0; font-size: 19px; }
  .panel.dark .workout-sub { margin-top: 8px; }
  .panel.dark .btn { margin-top: 18px; }
  .cycle-strip { gap: 6px; }
  .cycle-step small { font-size: 11px; }
  .workout-header { gap: 14px; }
  .workout-header .workout-label { font-size: 53px; }
  .workout-header h1 { font-size: 28px; margin-top: 10px; }
  .workout-header .eyebrow { font-size: 10px; }
  .workout-header p { font-size: 14px; }
  .workout-progress { flex-wrap: wrap; row-gap: 9px; margin-block: 21px; }
  .workout-progress .progress-track { flex-basis: 100%; }
  .workout-progress small { width: 100%; text-align: right; }
  .workout-actions .btn { padding-inline: 10px; font-size: 13px; }
  .workout-actions .accent { font-size: 14px; }
  .workout-exercise { padding: 18px; gap: 12px; grid-template-columns: 24px minmax(0, 1fr); }
  .workout-exercise.saved { padding-left: 16px; }
  .workout-exercise h3 { font-size: 16px; }
  .workout-exercise .btn { min-height: 52px; }
  .exercise-card { padding: 18px; min-height: 126px; }
  .group-icon { width: 38px; height: 38px; }
  .exercise-card .group-line { gap: 6px; }
  .history-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .history-row > .text-button { justify-self: stretch; justify-content: flex-end; padding: 7px 0; min-height: 48px; }
  .version-item { flex-wrap: wrap; padding: 17px; }
  .version-item > div { flex: 1 1 180px; }
  .version-item .btn { width: 100%; }
  .program-intro h2 { font-size: 27px; }
  .template-card .template-code { font-size: 36px; }
  .template-card .panel-head { gap: 12px; }
  .template-card .panel-head .badge { max-width: 115px; font-size: 11px; }
  .template-slot .slot-num { width: 17px; }
  .empty-state .btn, .settings-grid .btn { width: 100%; }

  dialog { position: fixed; inset: auto 0 max(0px, calc(100dvh - var(--visual-viewport-height, 100dvh) - var(--visual-viewport-top, 0px))); width: 100%; max-width: 100%; margin: 0; max-height: calc(var(--visual-viewport-height, 100dvh) - max(8px, env(safe-area-inset-top))); border: 0; border-top: 1px solid var(--line); border-radius: 22px 22px 0 0; }
  .modal-head { padding: 18px 20px 16px; gap: 10px; }
  .modal-head h2 { font-size: 25px; }
  .modal-head .eyebrow { font-size: 10px; }
  .modal-head p { font-size: 12px; }
  .modal-body { padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); }
  .modal-body .form-actions { bottom: 0; margin-inline: -20px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); }
  .modal-body .form-actions .btn { flex-basis: 150px; }
  .modal-body .form-actions .text-button { flex-basis: 110px; font-size: 13px; }
  #performance-form .form-actions .btn { flex: 1 1 150px; }
  #performance-form .form-actions .text-button { flex: 1 1 110px; }
  .field-grid, .field-grid.three { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .weight-entry { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .weight-entry input { font-size: 28px; min-height: 62px; }
  .weight-entry select { min-height: 52px; font-size: 16px; }
  .set-grid { gap: 8px; }
  .set-grid .field { gap: 9px; }
  .set-grid .field > span { font-size: 11px; }
  .set-grid input { height: 66px; font-size: 29px; }
  .per-set-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .per-set-grid .field > span { font-size: 12px; }
  .last-result { gap: 4px 12px; }
  .last-result .text-button { min-height: 48px; }
  .timer-value { font-size: 78px; margin-block: 16px 24px; }
  .auth-main { padding: 32px 24px max(36px, env(safe-area-inset-bottom)); min-height: 100dvh; }
  .auth-main .mobile-brand { font-size: 38px; margin-bottom: 32px; }
  .auth-main h2 { font-size: 35px; }
  .auth-main > p { margin: 15px 0 26px; }
}

/* Short viewports and open keyboards prioritize the active form. */
@media (max-height: 540px) and (pointer: coarse) {
  .hero h1 { font-size: 31px; }
  .hero p { margin-block: 12px; }
  .auth-main { justify-content: flex-start; padding-top: 24px; }
  .auth-main .mobile-brand { margin-bottom: 20px; }
  dialog { max-height: var(--visual-viewport-height, 100dvh); border-radius: 0; }
  .modal-head { padding-block: 12px; }
  .modal-head h2 { font-size: 22px; }
  .modal-head p { display: none; }
  .modal-body .form-actions { padding-top: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
}

/* Compact labels on narrow phones; the full touch target stays unchanged. */
@media (max-width: 360px) {
  .mobile-nav { grid-template-columns: .8fr 1.2fr 1.2fr .9fr .9fr; }
  .mobile-nav button { padding-inline: 0; }
  .mobile-nav button span { font-size: 10px; letter-spacing: -.02em; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
