/* Shared interface scale. Loaded after screen styles so labels and menus agree. */
:root {
  --font-page: 32px;
  --font-section: 20px;
  --font-row: 16px;
  --font-body: 14px;
  --font-control: 16px;
  --font-label: 13px;
  --font-small: 12px;
  --control-height: 44px;
  --section-gap: 20px;
}
body { font-size: var(--font-body); line-height: 1.5; }
.page-shell h1,
.page-shell .hero h1,
.page-shell .workout-header h1,
.page-shell .form-page h1,
.page-shell .training-home-heading h1 { font-size: var(--font-page); line-height: 1.15; letter-spacing: -.025em; overflow-wrap: anywhere; }
.page-shell h2,
.page-shell .section-heading h2,
.page-shell .quick-start-copy h2,
.page-shell .settings-card h2 { font-size: var(--font-section); line-height: 1.3; letter-spacing: -.015em; }
.page-shell h3 { font-size: var(--font-row); line-height: 1.35; }
.page-shell .hero-copy,
.page-shell .settings-description,
.page-shell .section-copy { font-size: var(--font-body); line-height: 1.5; }
.page-shell small,
.page-shell .eyebrow,
.page-shell .meta-row,
.page-shell .back-link,
.page-shell .status,
.page-shell .save-hint,
.page-shell .save-state { font-size: var(--font-small); line-height: 1.4; }
.page-shell .eyebrow { letter-spacing: .05em; }
.page-shell .field-group > label,
.page-shell .field-group > span:first-child,
.page-shell .duration-input-field,
.page-shell .quick-start-form label,
.page-shell .exercise-category-field > span,
.page-shell .template-start-form label,
.page-shell .library-add-form label,
.page-shell .library-search-field { font-size: var(--font-label); line-height: 1.4; }
.page-shell .field-group small,
.page-shell .settings-check-row small,
.page-shell .category-editor-banner small,
.page-shell .weight-review-note,
.page-shell .weight-review-targets small,
.page-shell .weight-source-options legend { font-size: var(--font-small); line-height: 1.4; }
.button, .page-shell .button-small { min-height: var(--control-height); font-size: var(--font-label); line-height: 1.3; padding: 9px 13px; }
.button, .text-link { overflow-wrap: anywhere; }
.page-shell input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.page-shell select,
.page-shell textarea { font-size: var(--font-control); line-height: 1.35; }
.page-shell input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.page-shell select { min-height: var(--control-height); }
.page-shell input[type="date"] { min-width: 0; max-width: 100%; }
.page-shell .text-link { font-size: var(--font-label); }
.focus-dialog .focus-dialog-header h2 { font-size: var(--font-section); line-height: 1.3; }
.focus-dialog label, .focus-dialog .field-group > label { font-size: var(--font-label); }
.focus-dialog .settings-description, .focus-dialog .weight-review-intro { font-size: var(--font-body); }
.focus-dialog-actions { gap: 8px; }

/* Navigation has one readable label per destination and one hit-area size. */
.desktop-nav a { display: flex; align-items: center; min-height: var(--control-height); padding: 8px 14px; font-size: var(--font-body); line-height: 1.3; }
.topbar .theme-toggle, .topbar .settings-button { min-height: var(--control-height); }
.topbar .settings-button-label { font-size: var(--font-body); }
.workout-subnav, .settings-subnav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; max-width: 720px; gap: 4px; margin: 0 0 var(--section-gap); padding: 4px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: 10px; }
.workout-subnav a, .settings-subnav a { display: flex; align-items: center; justify-content: center; min-width: 0; min-height: var(--control-height); gap: 0; padding: 8px 10px; border: 1px solid transparent; border-radius: 7px; color: var(--muted); font-size: var(--font-body); font-weight: 650; line-height: 1.3; text-align: center; text-decoration: none; }
.workout-subnav strong, .settings-subnav strong { font-size: inherit; font-weight: inherit; line-height: inherit; overflow: visible; white-space: normal; text-overflow: clip; }
.workout-subnav a.active, .settings-subnav a.active,
.workout-subnav a[aria-current="page"], .settings-subnav a[aria-current="page"] { color: var(--ink); background: var(--surface); border-color: var(--line); box-shadow: var(--elevation); }
.workout-subnav a:hover, .settings-subnav a:hover { color: var(--ink); background: var(--surface); }
.mobile-nav a { min-width: 0; min-height: 48px; font-size: var(--font-small); line-height: 1.25; }
.mobile-nav a > span { font-size: 18px; line-height: 1.2; }

/* The three setup pages share the same header, information order and action sizing. */
.page-shell .setup-page-heading { display: flex; align-items: flex-start; justify-content: space-between; flex-direction: row; gap: 18px; margin-bottom: var(--section-gap); }
.setup-page-heading > div:first-child { flex: 1; min-width: 0; }
.page-shell .setup-page-heading h1 { margin: 0 0 5px; }
.setup-page-heading .hero-copy { margin: 0; max-width: 700px; }
.setup-page-heading > .button,
.setup-page-heading .hero-actions { flex: 0 0 auto; margin: 0; width: auto; }
.setup-page-heading .hero-actions .button { width: auto; }
.setup-row-meta { margin: 4px 0 0; color: var(--muted); font-size: var(--font-small); line-height: 1.5; }
.setup-template-grid { gap: 14px; }
.setup-template-grid .template-card { gap: 16px; padding: 18px; }
.page-shell .setup-template-grid .template-card h2 { margin: 0; font-size: var(--font-section); line-height: 1.3; overflow-wrap: anywhere; }
.setup-template-grid .category-summary { gap: 7px; margin-top: 9px; }
.setup-template-grid .category-badge { padding: 0; color: var(--muted); background: transparent; border: 0; border-radius: 0; font-size: var(--font-small); }
.setup-template-grid .category-badge + .category-badge::before { content: '·'; margin-right: 7px; }
.setup-template-grid .category-summary:empty { display: none; }
.setup-template-grid .template-start-form { align-items: end; gap: 8px 10px; }
.setup-template-grid .template-start-form .template-start-weight-choice { display: flex; grid-column: 1 / -1; align-items: center; gap: 9px; min-height: 36px; margin: 0; font-size: var(--font-small); font-weight: 500; cursor: pointer; }
.template-start-weight-choice input { flex: 0 0 18px; width: 18px; height: 18px; min-height: 18px; margin: 0; padding: 0; accent-color: var(--primary); }
.setup-template-grid .template-card-actions { align-items: center; padding-top: 12px; border-top: 1px solid var(--line); }

.setup-list-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.setup-search-field { display: grid; flex: 1; max-width: 520px; min-width: 0; gap: 5px; color: var(--ink); font-size: var(--font-label); font-weight: 650; }
.setup-search-field input { width: 100%; padding: 10px 12px; background: var(--surface); }
.setup-list-count { flex-shrink: 0; padding-bottom: 11px; color: var(--muted); font-size: var(--font-small); }
.setup-exercise-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.setup-exercise-list .setup-exercise-row { display: block; min-width: 0; padding: 14px 16px; background: var(--surface); border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; }
.setup-exercise-list .setup-exercise-row:last-child { border-bottom: 0; }
.setup-exercise-list .setup-exercise-row:hover { box-shadow: none; }
.setup-exercise-list [data-library-option][hidden], [data-library-empty][hidden] { display: none; }
.setup-exercise-main { display: flex; align-items: center; gap: 14px; }
.setup-exercise-copy { flex: 1; min-width: 0; }
.page-shell .setup-exercise-copy h2 { margin: 0; font-size: var(--font-row); line-height: 1.35; overflow-wrap: anywhere; }
.setup-exercise-copy h2 a { color: var(--ink); text-decoration: none; }
.setup-exercise-copy h2 a:hover { color: var(--primary); }
.setup-exercise-main > .button { flex: 0 0 auto; }
.bodyweight-label { color: var(--ink); font-size: var(--font-small); font-weight: 600; }
.setup-row-details { margin-top: 6px; }
.setup-row-details > summary { display: flex; align-items: center; gap: 9px; width: fit-content; min-height: 40px; padding: 7px 0; color: var(--primary); font-size: var(--font-label); font-weight: 600; list-style: none; cursor: pointer; }
.setup-row-details > summary::-webkit-details-marker { display: none; }
.setup-row-details[open] > summary > span { transform: rotate(180deg); }
.setup-row-details-body { display: grid; gap: 10px; max-width: 700px; padding: 12px 0 0; border-top: 1px solid var(--line); }
.setup-row-details-body .library-meta, .setup-row-details-body .library-notes,
.setup-row-details-body .reference-weight { margin: 0; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: var(--font-small); line-height: 1.5; }
.setup-row-details-body .reference-weight strong { color: var(--ink); }
.setup-row-details-body .library-add-form { grid-template-columns: minmax(0, 1fr) auto; align-items: end; margin: 2px 0 0; padding: 0; border: 0; }
.setup-row-details-body .library-add-form select { background: var(--surface-subtle); }
.setup-row-details-body .library-card-actions { justify-content: flex-end; margin: 0; padding: 0; }
.setup-row-details-body .library-card-actions .button { color: var(--danger); }
.setup-search-empty { margin-top: 12px; }

.setup-help { margin: -4px 0 12px; }
.setup-help > summary { width: fit-content; min-height: 40px; padding: 8px 0; color: var(--muted); font-size: var(--font-label); cursor: pointer; }
.setup-help > summary:hover { color: var(--ink); }
.setup-help .category-management-guide { gap: 18px; margin: 0 0 14px; padding: 12px 0; border-block: 1px solid var(--line); }
.setup-help .category-management-guide > div { padding: 0; background: transparent; border: 0; border-radius: 0; }
.setup-help .category-management-guide strong { font-size: var(--font-label); }
.setup-help .category-management-guide small { font-size: var(--font-small); }
.page-shell .category-management-card > summary { min-height: 74px; }
.page-shell .category-management-card > summary h2 { font-size: var(--font-row); line-height: 1.3; }
.page-shell .category-management-card > summary p { overflow: visible; white-space: normal; font-size: var(--font-small); line-height: 1.4; }
.page-shell .category-summary-meta strong { font-size: var(--font-row); }
.page-shell .category-summary-meta small { font-size: var(--font-small); }
.page-shell .category-management-form .field-group small { font-size: var(--font-small); }

/* Workout metadata stays compact, but all labels remain readable. */
.page-shell .workout-header-compact { margin-bottom: 12px; }
.page-shell .workout-overview-compact { grid-template-columns: minmax(0, 1fr) 40px; gap: 6px 12px; padding: 8px 12px; }
.page-shell .workout-overview-compact .progress-copy { gap: 0; }
.page-shell .workout-overview-compact .progress-copy strong { line-height: 1.3; }
.page-shell .workout-overview-compact .progress-ring::before { width: 32px; height: 32px; }
.page-shell .workout-overview-compact .progress-ring span { font-size: var(--font-small); }
.page-shell .tracker-view-options { padding-block: 0; }
.page-shell .tracking-category-title h2 { font-size: var(--font-row); line-height: 1.3; }
.page-shell .tracking-exercise-copy > strong { font-size: var(--font-body); line-height: 1.35; }
.page-shell .tracking-exercise-copy > .tracking-plan-summary,
.page-shell .tracking-table thead th,
.page-shell .tracking-round-row th,
.page-shell .tracking-round-row small,
.page-shell .mobile-value-label,
.page-shell .table-done-surface b,
.page-shell .category-progress,
.page-shell .tracker-view-options,
.page-shell .tracker-next small,
.page-shell .tracking-context-line,
.page-shell .tracking-target-fields label > span { font-size: var(--font-small); line-height: 1.35; }
.page-shell .tracker-next strong { font-size: var(--font-body); }
.page-shell .tracker-toolbar .button { font-size: var(--font-small); }
.page-shell .tracking-input { font-size: 18px !important; }
.page-shell .table-done-surface { width: 44px !important; min-width: 44px !important; height: 44px !important; min-height: 44px !important; grid-template-rows: 22px 16px; }
.page-shell .table-done-surface i { width: 22px; height: 22px; }
.page-shell .table-done-surface b { line-height: 1.2; }
.page-shell .exercise-header p,
.page-shell .exercise-plan-main p,
.page-shell .reference-preview,
.page-shell .reference-scope-note,
.page-shell .template-exercise-count { font-size: var(--font-small); line-height: 1.4; }
.page-shell .training-summary span,
.page-shell .training-summary > div > small,
.page-shell .training-weight-choice small,
.page-shell .training-history-row .status,
.page-shell .training-history-row .date-badge small,
.page-shell .training-history-row .workout-card-copy p { font-size: var(--font-small); }
.page-shell .training-summary strong { font-size: 22px; }
.page-shell .training-summary strong small { font-size: var(--font-small); }

@media (max-width: 820px) {
  .desktop-nav { display: none; }
  .mobile-nav { gap: 2px; padding-inline: 8px; }
  .mobile-nav a { padding: 4px 2px; font-size: var(--font-small); }
}

@media (max-width: 620px) {
  :root { --font-page: 28px; --font-section: 18px; --section-gap: 18px; }
  .page-shell .setup-page-heading { flex-direction: column; align-items: stretch; gap: 12px; }
  .setup-page-heading > .button,
  .setup-page-heading .hero-actions,
  .setup-page-heading .hero-actions .button { width: 100%; }
  .workout-subnav, .settings-subnav { max-width: none; margin-bottom: var(--section-gap); }
  .workout-subnav a, .settings-subnav a { padding-inline: 5px; font-size: var(--font-label); }
  .setup-template-grid { grid-template-columns: minmax(0, 1fr); }
  .setup-template-grid .template-card { padding: 14px; gap: 13px; }
  .setup-template-grid .template-start-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .setup-template-grid .template-start-form > .button { width: 100%; }
  .setup-exercise-list .setup-exercise-row { padding: 12px; }
  .setup-exercise-main { gap: 10px; }
  .setup-exercise-main > .button { padding-inline: 11px; }
  .setup-list-toolbar { gap: 10px; }
  .setup-list-count { padding-bottom: 13px; }
  .setup-help .category-management-guide { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .page-shell .category-management-card > summary { grid-template-columns: 34px minmax(0, 1fr) auto 14px; gap: 8px; padding: 12px 10px; }
  .page-shell .category-management-card > summary .exercise-code { width: 30px; height: 34px; }
  .page-shell .tracking-category-title h2 { font-size: var(--font-body); }
  .page-shell .tracker-toolbar-actions { align-items: center; }
  .page-shell .tracker-toolbar-actions .button { padding-inline: 8px; }
  .page-shell .training-home-heading > .button { font-size: var(--font-small); }
}

/* Name and weight type come first; optional coaching details stay out of the way. */
.page-shell .library-exercise-editor { gap: 14px; }
.focus-dialog .library-exercise-editor { margin-top: 0; }
.library-exercise-editor .field-group { gap: 5px; min-width: 0; }
.library-exercise-editor .library-defaults-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.library-exercise-editor .bodyweight-option { margin: 0; padding: 10px 0; }
.library-exercise-editor .bodyweight-option:not(:has(input[name="bodyweight_included"]:checked)) > p { display: none; }
.library-exercise-editor .bodyweight-choice > span { gap: 3px; }
.library-exercise-editor .library-weight-scope { margin: -3px 0 0; color: var(--muted); font-size: var(--font-small); line-height: 1.4; }
.library-extra-fields { border-block: 1px solid var(--line); }
.library-extra-fields > summary { min-height: 44px; padding: 11px 0; color: var(--ink); font-size: var(--font-label); font-weight: 600; line-height: 1.5; cursor: pointer; }
.library-extra-fields > summary span { color: var(--muted); font-size: var(--font-small); font-weight: 400; }
.library-extra-fields-body { display: grid; gap: 12px; padding: 2px 0 14px; }
.library-extra-fields-body .library-tempo-field { max-width: 200px; }
.library-exercise-editor .focus-dialog-actions { margin-top: 0; }
@media (max-width: 620px) {
  .page-shell .library-exercise-editor { gap: 12px; }
  .library-exercise-editor .library-defaults-grid { gap: 10px 12px; }
  .library-exercise-editor input:not([type="checkbox"]):not([type="hidden"]),
  .library-exercise-editor select { padding: 9px 10px; }
  .library-exercise-editor .focus-dialog-actions .button { flex: 1; }
}

/* Inline feedback never covers the training controls, in either appearance. */
.page-shell .template-sort-card .exercise-category-field input,
.page-shell .template-sort-card .exercise-category-field select,
.page-shell .template-sort-card .exercise-actions > .button,
.page-shell .template-sort-card .exercise-order-buttons .button { height: var(--control-height); min-height: var(--control-height); }
.page-shell .template-sort-card .exercise-order-buttons .button { width: var(--control-height); min-width: var(--control-height); padding-inline: 8px; }

.flash-stack { position: static; margin-bottom: 14px; }
.flash { color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); box-shadow: none; font-size: var(--font-body); }
.flash-success { color: var(--success); background: var(--success-soft); border-color: var(--success); }
.flash-warning { color: var(--warning); background: var(--warning-soft); border-color: var(--warning); }
.flash-error { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }

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