@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400..700;1,9..40,400..700&family=Manrope:wght@600;700;800&display=swap');

:root {
  --font-sans: 'DM Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Light Theme — Nordic Alpine Slate & Fjord Teal */
  --canvas: #f4f6f8;
  --surface: #ffffff;
  --surface-subtle: #edf1f5;
  --surface-hover: #e5ebf1;
  --ink: #13222e;
  --ink-secondary: #374a59;
  --muted: #5d7080;
  --line: #dce3ea;
  --line-strong: #c5d1dc;

  --accent: #0f766e;
  --accent-hover: #115e59;
  --accent-soft: #e6f6f4;
  --accent-ink: #ffffff;

  --success: #15803d;
  --success-soft: #e8f7ee;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;

  --chart-1: #0f766e;
  --chart-2: #2563eb;
  --chart-3: #d97706;
  --chart-4: #7c3aed;
  --peer-chart: #64748b;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 14px 36px rgba(15, 23, 42, 0.12);
  --dock-bg: rgba(255, 255, 255, 0.92);
  --nav-bg: rgba(255, 255, 255, 0.94);

  color-scheme: light;
}

[data-theme="dark"] {
  --canvas: #0d141c;
  --surface: #151f2b;
  --surface-subtle: #1d2a3a;
  --surface-hover: #25364a;
  --ink: #edf3f8;
  --ink-secondary: #c8d6e3;
  --muted: #93a7ba;
  --line: #273748;
  --line-strong: #374c62;

  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft: #133238;
  --accent-ink: #071f24;

  --success: #4ade80;
  --success-soft: #132f22;
  --warn: #fbbf24;
  --warn-soft: #332713;
  --danger: #f87171;
  --danger-soft: #35181b;

  --chart-1: #2dd4bf;
  --chart-2: #60a5fa;
  --chart-3: #fbbf24;
  --chart-4: #c084fc;
  --peer-chart: #94a3b8;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --dock-bg: rgba(21, 31, 43, 0.92);
  --nav-bg: rgba(21, 31, 43, 0.95);

  color-scheme: dark;
}

/* Base Reset */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; letter-spacing: -0.025em; color: var(--ink); }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a, input, select, summary { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; }

/* Buttons & Inputs */
button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  min-height: 44px;
  font-weight: 600;
  font-size: 0.9375rem;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, color 0.15s ease;
}
button:hover:not(:disabled) { background: var(--surface-subtle); border-color: var(--line-strong); }
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

button.btn-secondary, label.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  min-height: 44px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
button.btn-secondary:hover:not(:disabled), label.btn-secondary:hover { background: var(--surface-hover); border-color: var(--line-strong); }

button.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding: 8px 12px;
}
button.btn-ghost:hover:not(:disabled) { background: var(--surface-subtle); color: var(--ink); border-color: transparent; }

button.btn-xs { min-height: 34px; padding: 6px 10px; font-size: 0.8125rem; border-radius: var(--radius-sm); }
button.icon-btn { min-width: 40px; min-height: 40px; padding: 8px; border-radius: var(--radius-sm); }
button.full-width { width: 100%; }

input[type="text"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
  min-height: 42px;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
textarea { width: 100%; resize: vertical; line-height: 1.5; }
.muted { color: var(--muted); font-size: 0.875rem; line-height: 1.55; }
.error-text { color: var(--danger); font-size: 0.875rem; font-weight: 600; margin-top: 8px; }
.status-text { color: var(--accent); font-size: 0.875rem; font-weight: 600; }
.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.badge, .pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  white-space: nowrap;
}
.pill-accent { background: var(--accent-soft); color: var(--accent); }

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}
.mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #0f1e29;
  color: #2dd4bf;
  display: grid;
  place-items: center;
  flex: none;
}
.mark svg { width: 22px; height: 22px; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-wordmark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.brand-wordmark span { color: var(--accent); }
.program-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-pill {
  background: transparent;
  border-color: var(--line);
  min-height: 38px;
  padding: 7px 12px;
  font-size: 0.85rem;
  border-radius: 10px;
}

/* Main Container */
main {
  max-width: 1220px;
  margin: 0 auto;
  padding: 20px 20px 140px;
}
body[data-view="workout"] .heading,
body[data-view="progress"] .heading,
body[data-view="history"] .heading,
body[data-view="friends"] .heading,
body[data-view="programs"] .heading { display: none; }

/* Navigation (Desktop Top Bar) */
#viewNav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin-bottom: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}
#viewNav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
}
#viewNav button:hover { color: var(--ink); background: var(--surface-subtle); }
#viewNav button.active {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}
.nav-icon { width: 19px; height: 19px; flex: none; }
.nav-label-mobile { display: none; }

/* Floating Toast Notification */
.toast-banner {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(560px, calc(100vw - 32px));
  background: var(--ink);
  color: var(--surface);
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: toastIn 0.2s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Section Headers */
.section-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.section-top h2 { font-size: clamp(1.4rem, 2.4vw, 1.85rem); }

/* WORKOUT WORKSPACE */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 24px;
  align-items: start;
}
body.workout-focus:not(.workout-overview) .workspace {
  grid-template-columns: minmax(0, 1fr);
  max-width: 820px;
  margin: 0 auto;
}
body.workout-focus:not(.workout-overview) .workout-aside,
body.workout-focus:not(.workout-overview) #trainingPlan { display: none; }

.session {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}
.session-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.session-heading h2 { font-size: clamp(1.45rem, 2.5vw, 1.9rem); line-height: 1.15; }
.session-heading-pills { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

/* Today Card */
.today-card {
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line));
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.today-card[data-current="true"] {
  background: var(--surface-subtle);
  border-color: var(--line);
  padding: 12px 16px;
}
.today-card[data-current="true"] #todayTitle,
.today-card[data-current="true"] #todayDescription { display: none; }
.today-card h3 { font-size: 1.15rem; margin-bottom: 3px; }
.today-card p:not(.eyebrow) { font-size: 0.875rem; color: var(--ink-secondary); }
.today-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.today-alternative, .today-recovery { font-size: 0.875rem; }
.today-alternative summary, .today-recovery summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
  padding: 6px 0;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.today-alternative summary::-webkit-details-marker,
.today-recovery summary::-webkit-details-marker { display: none; }
.today-alternative summary::after,
.today-recovery summary::after { content: '▾'; font-size: 0.85em; }
.today-alternative[open] summary::after,
.today-recovery[open] summary::after { content: '▴'; }
.today-alternative[open], .today-recovery[open] {
  flex: 1 0 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-top: 4px;
}
.disclosure-body, .today-recovery-options { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.today-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.today-picker select { flex: 1 1 200px; }

/* Status & Meta */
.session-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 6px 0;
}
.storage-note {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.storage-note[data-status="saved"] { color: var(--success); }
.storage-note[data-status="error"] { color: var(--danger); }
.inline-retry-btn { min-height: 28px; padding: 3px 10px; font-size: 0.78rem; border-radius: 6px; }

.session-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0 14px;
}
.date-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}
.date-label input[type="date"] { min-height: 36px; padding: 5px 10px; font-size: 0.875rem; }
.set-count-pill {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--ink-secondary);
  background: var(--surface-subtle);
  padding: 5px 12px;
  border-radius: 999px;
}

/* Workout Live Tracking Banner */
.workout-tracking {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px 16px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  margin-bottom: 10px;
}
.workout-tracking[data-running="true"] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.workout-live { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.workout-kicker { display: block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.workout-tracking[data-running="true"] .workout-kicker { color: var(--accent); }
#workoutClock {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.workout-energy-live { text-align: right; }
#workoutKcal { display: block; font-family: var(--font-display); font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
#workoutEnergyHint { display: block; font-size: 0.75rem; color: var(--muted); }
.workout-start-actions { display: flex; flex-direction: column; gap: 6px; }
.workout-time-hint { grid-column: 1 / -1; font-size: 0.8rem; color: var(--warn); font-weight: 600; }

/* Session Energy Disclosure */
.session-energy {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  background: var(--surface);
}
.session-energy > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  cursor: pointer;
  font-size: 0.875rem;
  list-style: none;
}
.session-energy > summary::-webkit-details-marker { display: none; }
.session-energy > summary span { color: var(--muted); font-weight: 600; font-size: 0.825rem; }
.session-energy-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
}
.energy-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.energy-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.energy-explanation, .energy-hint { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }
.watch-energy, .energy-method { font-size: 0.825rem; color: var(--muted); }
.watch-energy summary, .energy-method summary { cursor: pointer; font-weight: 600; color: var(--ink-secondary); padding: 4px 0; }
.watch-energy label { display: flex; flex-direction: column; gap: 5px; margin: 8px 0; }

/* Progress Bar */
.progress-bar-wrap { margin: 4px 0 10px; }
.session-progress {
  display: block;
  appearance: none;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-subtle);
  overflow: hidden;
}
.session-progress::-webkit-progress-bar { background: var(--surface-subtle); border-radius: 999px; }
.session-progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; transition: width 0.25s ease; }
.session-progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* Exercise Cards */
.exercises-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.exercise {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  background: var(--surface);
  scroll-margin-top: 82px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.exercise.is-current {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}
.exercise.is-complete {
  border-color: color-mix(in srgb, var(--success) 35%, var(--line));
}
.exercise.is-complete:not(.is-current) {
  background: var(--surface-subtle);
}

.exercise-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}
.exercise-number {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 800;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--muted);
  display: grid;
  place-items: center;
  flex: none;
}
.exercise.is-current .exercise-number { background: var(--accent); color: var(--accent-ink); }
.exercise.is-complete .exercise-number { background: var(--success-soft); color: var(--success); }

.exercise-info { flex: 1; min-width: 0; }
.exercise-info h3 { font-size: 1.02rem; line-height: 1.3; margin-bottom: 3px; }
.exercise-toggle {
  all: unset;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}
.exercise-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.exercise-action {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  flex: none;
}
.exercise-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: 0.8rem; color: var(--muted); }
.exercise.is-complete .exercise-count { color: var(--success); font-weight: 700; }
.exercise-live-meta { font-size: 0.76rem; color: var(--ink-secondary); font-weight: 600; }

.exercise-guide {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--ink-secondary);
  display: grid;
  place-items: center;
  flex: none;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.exercise-guide:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

.exercise-body {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.variant-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--muted);
}
.variant-label select { flex: 1; max-width: 300px; min-height: 38px; padding: 6px 10px; }
.exercise-prescription { font-size: 0.875rem; font-weight: 600; color: var(--ink-secondary); margin-bottom: 8px; }
.technique-hint {
  font-size: 0.825rem;
  color: var(--ink-secondary);
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 10px;
}
.bodyweight-hint { font-size: 0.8rem; color: var(--muted); margin-bottom: 8px; }

/* Previous Values Bar */
.previous {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 12px;
}
.previous:empty { display: none; }
.copy-previous {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.8125rem;
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
  color: var(--accent);
}
.copy-previous:hover:not(:disabled) { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.copy-hint { font-size: 0.78rem; color: var(--muted); }

/* Personal Record Banner */
.record-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.72rem;
  font-weight: 800;
}
.record-details {
  background: var(--success-soft);
  border: 1px solid color-mix(in srgb, var(--success) 30%, var(--line));
  border-left: 4px solid var(--success);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.record-kicker { font-size: 0.8rem; font-weight: 800; color: var(--success); margin-bottom: 6px; }
.record-metrics { display: flex; flex-wrap: wrap; gap: 10px 24px; }
.record-metric { display: flex; flex-direction: column; }
.record-metric span { font-size: 0.75rem; color: var(--ink-secondary); }
.record-metric strong { font-family: var(--font-display); font-size: 1.05rem; font-weight: 800; }
.record-metric small { font-size: 0.74rem; color: var(--muted); }

/* Set Rows */
.set-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) minmax(0, 1fr) 48px;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease;
}
.set-row.column-labels {
  padding: 2px 6px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: center;
}
.set-row.column-labels span:first-child { text-align: left; }
.set-row.done { background: var(--success-soft); }

.set-index { display: flex; flex-direction: column; font-weight: 800; font-size: 0.9rem; line-height: 1.2; }
.set-index small { font-size: 0.7rem; font-weight: 500; color: var(--muted); }
.burn-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--warn-soft);
  color: var(--warn);
}

.step-field { display: flex; align-items: stretch; gap: 4px; min-width: 0; }
.step-field input {
  flex: 1;
  min-width: 0;
  width: 0;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  padding: 8px 4px;
  min-height: 42px;
}
.step-button {
  flex: 0 0 34px;
  min-width: 34px;
  min-height: 42px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-subtle);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
}

.set-complete {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  justify-self: center;
  cursor: pointer;
}
.set-complete input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.check-box {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  color: transparent;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  font-weight: 800;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.set-complete input:checked + .check-box {
  background: var(--success);
  border-color: var(--success);
  color: #ffffff;
}
.set-complete input:focus-visible + .check-box { outline: 2.5px solid var(--accent); outline-offset: 2px; }
.set-previous {
  grid-column: 2 / 4;
  justify-self: center;
  min-height: 26px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px dashed var(--line-strong);
  background: var(--surface-subtle);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  margin-top: -2px;
}
.set-previous:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* RPE Pills */
.session-rpe {
  margin-top: 22px;
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--surface-subtle);
  border: 1px solid var(--line);
}
.session-rpe-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.session-rpe-head label { font-family: var(--font-display); font-weight: 700; font-size: 0.95rem; }
.session-rpe-head label span { font-family: var(--font-sans); font-weight: 500; font-size: 0.8rem; color: var(--muted); margin-left: 4px; }
.rpe-selected-label { font-size: 0.825rem; font-weight: 700; color: var(--accent); }
.rpe-pills {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.rpe-pill {
  min-height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--ink-secondary);
}
.rpe-pill.active.tier-easy { background: #16a34a; border-color: #16a34a; color: #fff; }
.rpe-pill.active.tier-mid { background: #0f766e; border-color: #0f766e; color: #fff; }
.rpe-pill.active.tier-hard { background: #d97706; border-color: #d97706; color: #fff; }
.rpe-pill.active.tier-max { background: #dc2626; border-color: #dc2626; color: #fff; }
#sessionRpeHelp { font-size: 0.78rem; color: var(--muted); }

.notes-label { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; font-size: 0.875rem; font-weight: 600; color: var(--ink-secondary); }
.finish { width: 100%; margin-top: 16px; min-height: 50px; font-size: 1rem; border-radius: var(--radius-md); }
.finish.is-done { background: var(--success); border-color: var(--success); color: #ffffff; }

/* Sidebar Guide */
.workout-aside { position: sticky; top: 82px; }
.guide {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.guide h3 { font-size: 1.05rem; margin-bottom: 12px; }
.guide p { font-size: 0.86rem; color: var(--muted); margin-bottom: 12px; line-height: 1.55; }
.guide p:last-child { margin-bottom: 0; }
.guide b { color: var(--ink); }

/* Week Planner */
.training-plan {
  margin-top: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}
.training-plan > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  list-style: none;
}
.training-plan > summary::-webkit-details-marker { display: none; }
.plan-summary-title { display: inline-flex; align-items: center; gap: 8px; }
.plan-content { padding: 0 22px 22px; border-top: 1px solid var(--line); padding-top: 18px; }
.weekbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.week-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-controls { display: flex; align-items: center; gap: 6px; }
.week-controls select { min-height: 40px; padding: 6px 10px; }

.schedule {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.day {
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 5px;
  text-align: left;
}
.day span { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.day b { font-family: var(--font-display); font-size: 0.92rem; line-height: 1.25; }
.day small { font-size: 0.74rem; color: var(--muted); }
.day.rest { background: var(--surface-subtle); border-style: dashed; }
.day.recovery-day { background: var(--accent-soft); border-style: solid; }
.day.recovery-day b { color: var(--accent); }
.day.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.day.active span, .day.active small { color: color-mix(in srgb, var(--accent-ink) 80%, transparent); }
.day.done { box-shadow: inset 0 -4px 0 var(--success); }
.day.today { outline: 2px solid var(--accent); outline-offset: 2px; }

/* FLOATING TRAINING DOCK */
.training-dock {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  width: min(740px, calc(100vw - 24px));
  background: var(--dock-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 10px 14px 12px;
  box-shadow: var(--shadow-lg);
  overflow: visible;
}
.timer-progress-bar {
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 3px;
  border-radius: 999px;
  background: transparent;
  overflow: hidden;
}
.timer-progress-bar.is-active { background: var(--surface-subtle); }
.timer-progress-bar span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.25s linear;
}
.dock-overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.78rem;
}
#dockSession, #dockSave {
  background: transparent;
  border: 0;
  min-height: 24px;
  padding: 2px 6px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 6px;
}
#dockSession { color: var(--accent); font-variant-numeric: tabular-nums; white-space: nowrap; }
#dockProgress { color: var(--muted); font-weight: 600; text-align: center; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#dockSave { color: var(--muted); white-space: nowrap; }
#dockSave[data-status="saved"] { color: var(--success); }
#dockSave[data-status="error"] { color: var(--danger); }

.dock-controls { display: flex; align-items: center; gap: 8px; }
#dockPauseWorkout { flex: 0 0 44px; padding: 0; font-size: 1rem; background: var(--surface-subtle); }
#timerToggle {
  flex: 0 1 auto;
  min-width: 120px;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-subtle);
  font-size: 0.85rem;
}
#timerToggle.is-running {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
#clock { font-family: var(--font-display); font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer-chevron { font-size: 0.8rem; opacity: 0.7; }
#timerStart { flex: 0 1 auto; white-space: nowrap; }
#nextExercise { flex: 1; min-width: 100px; }

.timer-panel {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
}
.timer-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.timer-options { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.timer-options button { min-height: 36px; padding: 6px 12px; font-size: 0.85rem; border-radius: 999px; }
.timer-options button.selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.timer-panel-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  margin-bottom: 6px;
}
.timer-toggles { display: flex; flex-direction: column; gap: 6px; }
.auto-timer-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 0.825rem; font-weight: 600; cursor: pointer; }
.auto-timer-toggle input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.timer-extra-actions { display: flex; gap: 6px; }

/* PROGRESS VIEW */
.progress-intro { margin-bottom: 20px; }
.progress-intro h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); margin-bottom: 4px; }
.progress-intro p { color: var(--muted); font-size: 0.95rem; }

.progress-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.progress-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}
.progress-stat-volume { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); }
.progress-stat-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.progress-stat strong { font-family: var(--font-display); font-size: clamp(1.5rem, 2.8vw, 2.1rem); font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.progress-stat strong small { font-size: 0.55em; font-weight: 600; color: var(--muted); }
.progress-stat-detail { font-size: 0.78rem; color: var(--muted); }

.progress-volume-bars {
  grid-column: 1 / -1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 20px;
}
.volume-bar-meta { display: flex; justify-content: space-between; font-size: 0.82rem; margin-bottom: 5px; }
.volume-bar-meta span { color: var(--muted); font-weight: 600; }
.volume-bar-track { height: 7px; border-radius: 999px; background: var(--surface-subtle); overflow: hidden; }
.volume-bar-track i { display: block; height: 100%; border-radius: 999px; background: var(--accent); }

.progress-groups { display: flex; flex-direction: column; gap: 28px; margin-bottom: 24px; }
.progress-group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.progress-group-number {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-display); font-weight: 800; font-size: 0.9rem;
  display: grid; place-items: center; flex: none;
}
.progress-group-head h3 { font-size: 1.15rem; }
.progress-group-meta { font-size: 0.82rem; color: var(--muted); }

.progress-exercise-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.progress-exercise-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.progress-exercise-head { margin-bottom: 12px; }
.progress-exercise-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.progress-exercise-title h4 { font-size: 1rem; line-height: 1.35; }
.progress-exercise-main { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.progress-own-result { display: flex; flex-direction: column; min-width: 0; }
.progress-value-label { font-size: 0.74rem; color: var(--muted); }
.progress-value { font-family: var(--font-display); font-size: 1.85rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.progress-value small { font-size: 0.52em; font-weight: 600; color: var(--muted); }
.progress-own-result time { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.progress-delta { font-size: 0.78rem; font-weight: 700; margin-top: 5px; }
.progress-delta.is-up { color: var(--success); }
.progress-delta.is-down { color: var(--warn); }
.progress-delta.is-flat { color: var(--muted); }

.progress-chart { flex: 0 0 42%; min-width: 110px; color: var(--accent); }
.progress-chart-caption { display: block; font-size: 0.72rem; color: var(--muted); margin-bottom: 2px; text-align: right; }
.progress-sparkline { width: 100%; height: auto; aspect-ratio: 168 / 64; overflow: visible; }
.mini-chart-grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.mini-chart-area { fill: currentColor; opacity: 0.1; }
.mini-chart-line { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.mini-chart-point { fill: var(--surface); stroke: currentColor; stroke-width: 1.6; vector-effect: non-scaling-stroke; }
.mini-chart-point.is-latest { fill: currentColor; stroke: var(--surface); stroke-width: 2; }
.progress-chart-dates { display: flex; justify-content: space-between; font-size: 0.68rem; color: var(--muted); margin-top: 2px; }

.progress-exercise-volume {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
  color: var(--muted);
}
.progress-exercise-volume strong { color: var(--ink); font-variant-numeric: tabular-nums; margin-left: 4px; }

.progress-friends-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.progress-friends-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.progress-friends-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.progress-friend-overview { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-md); background: var(--surface-subtle); }
.progress-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: grid; place-items: center; flex: none; }
.progress-friend-overview small { display: block; font-size: 0.76rem; color: var(--muted); }
.progress-friend-list { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.progress-friend-kicker { font-size: 0.74rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.progress-friend-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.progress-peer-result { display: flex; flex-direction: column; min-width: 0; }
.progress-friend-name { font-size: 0.82rem; font-weight: 700; }
.progress-friend-value { font-family: var(--font-display); font-size: 1.05rem; font-weight: 800; }
.progress-friend-value time { font-family: var(--font-sans); font-size: 0.74rem; font-weight: 400; color: var(--muted); }
.progress-friend-row .progress-chart { flex: 0 0 36%; color: var(--peer-chart); }

/* Calories Overview */
.progress-calories {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 0 18px;
  margin-bottom: 18px;
}
.progress-calories > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 54px;
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}
.progress-calories > summary::-webkit-details-marker { display: none; }
.calorie-overview { padding: 10px 0 18px; border-top: 1px solid var(--line); }
.calorie-overview-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.calorie-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 12px; }
.calorie-total { background: var(--surface-subtle); border-radius: var(--radius-md); padding: 16px; }
.calorie-total-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.calorie-period-controls { display: flex; gap: 4px; }
.calorie-period-date { font-size: 0.8rem; color: var(--muted); }
.calorie-total-value { display: block; font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; margin: 6px 0; font-variant-numeric: tabular-nums; }
.calorie-total-value small { font-size: 0.55em; color: var(--muted); font-weight: 600; }
.calorie-coverage, .calorie-overview-note, .progress-note, .history-note, .competition-note { font-size: 0.82rem; color: var(--muted); line-height: 1.55; }

/* HISTORY VIEW */
.round-select-label { display: inline-flex; align-items: center; gap: 8px; font-size: 0.875rem; font-weight: 600; }
.history-note { margin-bottom: 16px; }
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.history-item-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 3px; }
.history-item h3 { font-size: 1.08rem; }
.history-status { font-size: 0.74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.history-status.is-complete { background: var(--success-soft); color: var(--success); }
.history-status.is-started { background: var(--warn-soft); color: var(--warn); }
.history-copy time { font-size: 0.85rem; color: var(--ink-secondary); display: block; text-transform: capitalize; }
.history-context { font-size: 0.78rem; color: var(--muted); margin: 2px 0 8px; }
.history-metrics { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; font-size: 0.84rem; color: var(--muted); }
.history-metrics strong { font-family: var(--font-display); font-size: 1.05rem; color: var(--ink); }
.history-rpe { font-size: 0.76rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.recovery-history { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 0 18px; }
.recovery-history > summary { display: flex; justify-content: space-between; align-items: center; min-height: 52px; cursor: pointer; font-weight: 700; list-style: none; }
.recovery-history-list { border-top: 1px solid var(--line); padding: 8px 0; }
.recovery-history-day { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.recovery-history-day:last-child { border: 0; }
.recovery-history-day strong { color: var(--accent); font-size: 0.84rem; }
.recovery-history-day small { grid-column: 1 / -1; font-size: 0.78rem; color: var(--muted); }

/* FRIENDS & PRIVACY VIEW */
.friend-profile, .privacy-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.friend-profile > summary, .friend-privacy > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
}
.friend-profile > summary::-webkit-details-marker,
.friend-privacy > summary::-webkit-details-marker { display: none; }
.friend-profile-summary { display: flex; flex-direction: column; }
.profile-visibility { font-size: 0.8rem; color: var(--muted); }
.friend-profile-editor, .privacy-card-body { padding: 14px 18px 18px; border-top: 1px solid var(--line); }
#profileForm { display: flex; flex-direction: column; gap: 10px; }
.share-label { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.share-label input { width: 20px; height: 20px; accent-color: var(--accent); }
.friend-account { margin-top: 14px; font-size: 0.82rem; color: var(--muted); }

dialog .privacy-card { padding: 16px; background: var(--surface-subtle); }
.privacy-card-heading { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.privacy-card-heading svg { width: 20px; height: 20px; color: var(--accent); }
.privacy-card h3 { font-size: 1rem; }
.privacy-card p { font-size: 0.84rem; color: var(--muted); margin-top: 6px; }
.privacy-card [data-privacy-status] { color: var(--accent); font-weight: 600; }
.privacy-switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 700; min-height: 40px; }
.privacy-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.privacy-switch-track {
  width: 46px; height: 26px; border-radius: 999px; padding: 3px;
  background: var(--line-strong); transition: background-color 0.18s ease;
}
.privacy-switch-track::before {
  content: ''; display: block; width: 20px; height: 20px; border-radius: 50%;
  background: #ffffff; transition: transform 0.18s ease;
}
.privacy-switch input:checked + .privacy-switch-track { background: var(--accent); }
.privacy-switch input:checked + .privacy-switch-track::before { transform: translateX(20px); }

.chart-card, .comparison-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.leader-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.leader-row.is-self { background: var(--accent-soft); margin: 0 -12px; padding: 12px; border-radius: var(--radius-md); border-top: 0; }
.leader-row .rank { font-size: 1.2rem; font-weight: 800; text-align: center; }
.score-track { height: 7px; border-radius: 999px; background: var(--surface-subtle); margin-top: 6px; overflow: hidden; }
.score-track i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.comparison-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 14px; margin-top: 10px; }
.comparison-group-title { font-size: 1.05rem; margin: 18px 0 6px; }
.comparison-card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.comparison-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.comparison-row.is-self { background: var(--accent-soft); margin: 0 -8px; padding: 8px; border-radius: 8px; border-top: 0; }
.comparison-person { display: flex; flex-direction: column; min-width: 0; }
.comparison-person strong { display: inline-flex; align-items: center; gap: 6px; font-size: 0.92rem; }
.comparison-person i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.comparison-person span { font-size: 0.8rem; color: var(--ink-secondary); }
.comparison-person small { font-size: 0.74rem; color: var(--muted); }
.comparison-score { font-family: var(--font-display); font-size: 1.15rem; font-weight: 800; }
.comparison-score.is-up { color: var(--success); }
.comparison-score.is-down { color: var(--warn); }
.comparison-chart svg { width: 100%; height: auto; margin-top: 12px; }
.chart-axis { font-size: 10px; fill: var(--muted); }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.comparison-chart-dates { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--muted); }
.comparison-table { margin-top: 10px; font-size: 0.825rem; }
.comparison-table summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.table-scroll { overflow-x: auto; margin-top: 8px; }
.chart-table { width: 100%; border-collapse: collapse; font-size: 0.825rem; }
.chart-table th, .chart-table td { padding: 8px; text-align: left; border-bottom: 1px solid var(--line); }
.manual-comparison { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 18px; }
.manual-comparison summary { cursor: pointer; font-weight: 700; }
.manual-comparison select { display: block; width: 100%; max-width: 360px; margin: 8px 0 14px; }

/* PROGRAMS BROWSER */
.program-scope { color: var(--muted); font-size: 0.9rem; margin-bottom: 16px; }
.active-program { margin-bottom: 20px; }
.program-browser-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.program-browser-controls label { display: flex; flex-direction: column; gap: 5px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.program-filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.program-categories { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.program-categories button { min-height: 38px; padding: 6px 12px; font-size: 0.84rem; border-radius: 999px; }
.program-categories button span { font-size: 0.75rem; background: var(--surface-subtle); padding: 1px 7px; border-radius: 999px; }
.program-categories button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.program-categories button[aria-pressed="true"] span { background: rgba(255, 255, 255, 0.22); color: inherit; }
.program-category-hint { font-size: 0.82rem; color: var(--muted); margin-bottom: 16px; }

.program-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); gap: 16px; }
.program-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.program-card[data-current="true"] {
  border-color: var(--accent);
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
}
.program-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.76rem; font-weight: 700; color: var(--muted); }
.program-card[data-current="true"] .program-card-status { color: var(--accent); }
.program-card h3 { font-size: 1.18rem; }
.program-card-description { font-size: 0.875rem; color: var(--ink-secondary); }
.program-facts { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 0.78rem; color: var(--muted); }
.program-facts span { display: inline-flex; align-items: center; gap: 5px; }
.program-facts svg { width: 15px; height: 15px; }
.program-details { border-top: 1px solid var(--line); padding-top: 8px; font-size: 0.84rem; }
.program-details summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 4px 0; }
.program-details-body { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; color: var(--ink-secondary); }
.program-details-body ol { margin: 0; padding-left: 20px; }
.program-details-body h4 { font-size: 0.85rem; margin-top: 4px; }
.program-source { font-size: 0.8rem; display: block; overflow-wrap: anywhere; }
.program-card-action {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.program-card-action:hover, .program-card-action.is-active { background: var(--accent); color: var(--accent-ink); }

/* Empty State */
.empty-state {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-state p { color: var(--muted); max-width: 440px; font-size: 0.9rem; }

/* Footer */
.app-footer {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}

/* DIALOGS */
dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--ink);
  padding: 0;
  max-width: 520px;
  width: calc(100vw - 28px);
  max-height: 88dvh;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(10, 18, 26, 0.62); backdrop-filter: blur(4px); }
.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.dialog-header h2 { font-size: 1.2rem; }
.dialog-body {
  padding: 18px 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field-stack { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; font-weight: 600; }
.day-settings-grid { display: flex; flex-direction: column; gap: 10px; }
.day-settings-grid label { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 0.9rem; font-weight: 600; }
.day-settings-grid select { min-width: 150px; }
.backup-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.sync-key-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sync-key-row input { flex: 1 1 180px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: 0.03em; }
.week-editor-actions { display: flex; gap: 10px; }
.week-editor-actions button { flex: 1; }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.archived-exercise { border-top: 1px solid var(--line); padding: 10px 0; }
.archived-exercise .exercise-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.archived-exercise p { font-size: 0.85rem; color: var(--muted); }
.archive-notes { white-space: pre-wrap; font-size: 0.875rem; background: var(--surface-subtle); padding: 12px; border-radius: var(--radius-md); }

/* BARBELL PLATE CALCULATOR */
.plate-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.plate-visual {
  padding: 20px 12px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  overflow-x: auto;
}
.barbell-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
}
.barbell-shaft { width: 52px; height: 10px; background: #94a3b8; border-radius: 4px 0 0 4px; }
.barbell-collar { width: 10px; height: 22px; background: #64748b; border-radius: 2px; }
.barbell-plates { display: flex; align-items: center; gap: 3px; padding: 0 2px; }
.barbell-sleeve { width: 32px; height: 12px; background: #94a3b8; border-radius: 0 4px 4px 0; }
.plate-chip {
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.72rem;
  color: #ffffff;
  min-width: 24px;
  padding: 0 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}
.plate-25 { height: 74px; background: #dc2626; }
.plate-20 { height: 70px; background: #2563eb; }
.plate-15 { height: 62px; background: #eab308; color: #1e293b; }
.plate-10 { height: 54px; background: #16a34a; }
.plate-5 { height: 46px; background: #e2e8f0; color: #0f172a; }
.plate-2-5 { height: 38px; background: #334155; }
.plate-1-25 { height: 32px; background: #94a3b8; color: #0f172a; }
.plate-empty { font-size: 0.85rem; color: var(--muted); padding: 0 12px; font-weight: 600; }
.plate-summary { text-align: center; display: flex; flex-direction: column; gap: 4px; }
.plate-result-main { font-size: 1rem; }
.plate-result-sub { font-size: 0.85rem; color: var(--muted); }

/* RESPONSIVE: TABLET (<= 960px) */
@media (max-width: 960px) {
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .workout-aside { position: static; }
  .progress-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .progress-exercise-grid { grid-template-columns: minmax(0, 1fr); }
  .program-browser-controls { grid-template-columns: minmax(0, 1fr); }
}

/* RESPONSIVE: MOBILE (<= 768px) — Fixed Bottom Tab Bar + Dock Above It */
@media (max-width: 768px) {
  .topbar-inner { height: 56px; padding: 0 14px; }
  .pill-label { display: none; }
  .icon-pill { padding: 7px 9px; min-width: 38px; }

  main { padding: 14px 12px calc(185px + env(safe-area-inset-bottom)); }
  body:not([data-view="workout"]) main { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }

  /* Sleek Fixed Bottom Tab Bar */
  #viewNav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    margin: 0;
    border-radius: 0;
    border: 0;
    border-top: 1px solid var(--line);
    background: var(--nav-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
  }
  #viewNav button {
    flex-direction: column;
    gap: 3px;
    padding: 6px 2px;
    min-height: 50px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
  }
  .nav-label-desktop { display: none; }
  .nav-label-mobile { display: block; }
  .nav-icon { width: 20px; height: 20px; }

  /* Dock sits directly above the bottom tab bar */
  .training-dock {
    bottom: calc(68px + env(safe-area-inset-bottom));
    width: calc(100vw - 16px);
    padding: 8px 10px 10px;
    border-radius: 16px;
  }
  .dock-controls { gap: 6px; }
  #timerToggle { min-width: 102px; padding: 6px 10px; font-size: 0.8rem; }
  #clock { font-size: 0.95rem; }
  #timerStart { padding: 8px 10px; font-size: 0.8rem; }
  #nextExercise { padding: 8px 10px; font-size: 0.82rem; min-width: 80px; }

  .session { padding: 16px 14px; border-radius: var(--radius-lg); }
  .workout-tracking { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .workout-start-actions { flex-direction: row; }
  .workout-start-actions button { flex: 1; }
  .energy-fields { grid-template-columns: minmax(0, 1fr); }
  .schedule { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .day { min-height: 78px; }

  .rpe-pills { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .progress-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calorie-totals { grid-template-columns: minmax(0, 1fr); }
  .history-item { flex-direction: column; align-items: stretch; }
  .history-item button { width: 100%; }
}

/* COMPACT PHONES (<= 560px) — Ergonomic Set Inputs (no iOS zoom, no cramped buttons!) */
@media (max-width: 560px) {
  .set-row {
    grid-template-columns: 42px minmax(0, 1fr) minmax(0, 1fr) 44px;
    gap: 6px;
    padding: 8px 4px;
  }
  .step-field {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px;
  }
  .step-field input {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    font-size: 16px;
    min-height: 40px;
  }
  .step-button {
    min-width: 0;
    width: 100%;
    min-height: 32px;
    font-size: 1rem;
  }
  .step-button:first-child { grid-column: 1; grid-row: 2; }
  .step-button:last-child { grid-column: 2; grid-row: 2; }
  .set-previous { grid-column: 1 / -1; justify-self: start; margin-top: 2px; }
  .plate-inputs { grid-template-columns: minmax(0, 1fr); }
}

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