/* ATLAS · Private Training Studio — app styling */

:root {
  color-scheme: dark;

  /* Surfaces & ink */
  --bg: #0d0f12;
  --surface-0: #0d0f12;
  --surface-1: #14171c;
  --surface-2: #1b1f26;
  --surface-3: #232831;
  --line: #2a2f38;
  --line-strong: #3a414d;
  --text-primary: #eceae4;
  --text-secondary: #a7a59d;
  --text-tertiary: #8a887f;

  /* Accent */
  --accent: #c9a86a;
  --accent-strong: #dcbd83;
  --accent-soft: rgba(201, 168, 106, 0.16);
  --accent-ink: #17130b;

  /* Status (always paired with an icon + label) */
  --good: #3fb67f;
  --warning: #f0a94b;
  --serious: #e2574c;

  /* Muscle highlight colors, shared with the 3D viewer */
  --muscle-primary: #e2574c;
  --muscle-secondary: #f0a94b;
  --muscle-flagged: #7c6cf0;
  --muscle-neutral: #8a7f78;

  /* Charts */
  --series-1: #3987e5;
  --grid: #2a2f38;

  /* Shape & motion */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 14px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  /* Type scale: the only sizes the app uses. Touch screens and client view step the small ones up. */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-body: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 19px;
  --fs-2xl: 22px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-fast: 120ms;
  --t: 200ms;
  --glass: rgba(20, 23, 28, 0.76);
  --glass-strong: rgba(20, 23, 28, 0.95);
  --glass-line: rgba(255, 255, 255, 0.07);
  --pop-shadow: 0 16px 40px rgba(0, 0, 0, 0.42);

  /* Layout */
  --topbar-h: 60px;
  --roster-w: 280px;
  --panel-w: 440px;
  --transport-w: 200px; /* play + speed controls at the stage's bottom right; the legend stays clear */
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font: 400 var(--fs-body)/1.45 var(--font);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.45; }
h1, h2, h3, h4, p { margin: 0; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.num, input[type='number'], table { font-variant-numeric: tabular-nums; }

.i {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.i-fill { fill: currentColor; stroke: none; }
.i-sm { width: 14px; height: 14px; }

* { scrollbar-width: thin; scrollbar-color: #343a45 transparent; }

/* ---------------------------------------------------------------- Layout */

.app {
  display: grid;
  grid-template-columns: var(--roster-w) minmax(0, 1fr) var(--panel-w);
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas: 'top top top' 'roster stage panel';
  height: 100vh;
  height: 100dvh;
}

/* ---------------------------------------------------------------- Top bar */

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  min-width: 0;
}

.brand {
  display: flex; align-items: center; gap: 12px;
  color: inherit; text-decoration: none; min-width: 0;
  border-radius: var(--radius-sm);
}
.brand-mark { width: 28px; height: 28px; flex: none; fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark circle { stroke-opacity: 0.4; }
.brand-name { font-weight: 600; font-size: var(--fs-md); letter-spacing: 0.32em; margin-right: -0.32em; }
.brand-sub {
  padding-left: 12px; border-left: 1px solid var(--line);
  color: var(--text-secondary); font-size: var(--fs-base); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar-divider { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
.topbar .roster-toggle { display: none; }
.topbar .data-more { display: none; }
#presentBtn { margin-right: 6px; }

/* ---------------------------------------------------------------- Controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface-2); color: var(--text-primary);
  font-size: var(--fs-base); font-weight: 500; line-height: 1; white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.btn:hover:not(:disabled) { background: var(--surface-3); border-color: var(--line-strong); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn-quiet:hover:not(:disabled) { color: var(--text-primary); background: var(--surface-2); border-color: transparent; }
.btn-danger { color: #f08a80; }
.btn-danger:hover:not(:disabled) { border-color: rgba(226, 87, 76, 0.5); background: rgba(226, 87, 76, 0.1); }
.btn-danger-solid { background: var(--serious); border-color: var(--serious); color: #fff; }
.btn-danger-solid:hover:not(:disabled) { background: #ec6a5f; border-color: #ec6a5f; }
.btn-sm { height: 28px; padding: 0 10px; font-size: var(--fs-sm); border-radius: var(--radius-sm); gap: 6px; }
.btn-block { width: 100%; }
.btn-toggle[aria-pressed='true'] { color: var(--accent-strong); border-color: rgba(201, 168, 106, 0.55); background: rgba(201, 168, 106, 0.12); }

.icon-btn {
  display: inline-grid; place-items: center; flex: none;
  width: 34px; height: 34px; padding: 0;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface-2); color: var(--text-secondary);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.icon-btn:hover:not(:disabled) { color: var(--text-primary); background: var(--surface-3); border-color: var(--line-strong); }
.icon-btn.sm { width: 28px; height: 28px; border-radius: var(--radius-sm); }
.icon-btn.quiet { background: transparent; border-color: transparent; }
.icon-btn.quiet:hover:not(:disabled) { background: var(--surface-3); border-color: transparent; }
.icon-btn.danger:hover:not(:disabled) { color: #f08a80; background: rgba(226, 87, 76, 0.12); }

.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface-1);
}
.seg > button {
  height: 28px; padding: 0 12px;
  border: 0; border-radius: 7px; background: transparent;
  color: var(--text-secondary); font-size: var(--fs-base); font-weight: 500; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.seg > button:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.04); }
.seg > button[aria-checked='true'], .seg > button[aria-pressed='true'] {
  background: var(--surface-3); color: var(--text-primary);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.seg-sm > button { height: 24px; padding: 0 9px; font-size: var(--fs-sm); }

.input {
  width: 100%; height: 36px; padding: 0 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text-primary);
  font-size: var(--fs-body);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.input::placeholder { color: #6f6e68; }
.input:hover { border-color: var(--line-strong); }
.input:focus-visible, .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid='true'] { border-color: var(--serious); box-shadow: 0 0 0 3px rgba(226, 87, 76, 0.16); }
textarea.input { height: auto; min-height: 64px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
select.input {
  appearance: none; padding-right: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4.5 6.5 3.5 3.5 3.5-3.5' fill='none' stroke='%23a7a59d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; background-size: 14px;
}
select.input option, select.input optgroup { background: var(--surface-2); color: var(--text-primary); }
.input-sm { height: 30px; font-size: var(--fs-base); padding: 0 9px; }
select.input-sm { padding-right: 26px; background-position: right 7px center; }
input[type='number'] { -moz-appearance: textfield; }
input[type='number']::-webkit-inner-spin-button, input[type='number']::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type='date'].input::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

.input-unit { position: relative; }
.input-unit .input { padding-right: 38px; }
.input-unit .unit {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-tertiary); font-size: var(--fs-sm); pointer-events: none;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field-label { font-size: var(--fs-sm); color: var(--text-secondary); font-weight: 500; }
.field > legend { margin-bottom: 8px; }
.inline-field { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); font-weight: 500; color: var(--text-secondary); }
.inline-field select { width: auto; min-width: 150px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }

.search { position: relative; }
.search > .i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-tertiary); pointer-events: none; }
.search .input { padding-left: 34px; }
.search .input::-webkit-search-cancel-button { filter: grayscale(1) brightness(1.4); cursor: pointer; }

.check { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-base); cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }

/* ---------------------------------------------------------------- Chips & badges */

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 9px 0 8px;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text-primary); font-size: var(--fs-sm); font-weight: 500; line-height: 1; white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--dot, var(--text-tertiary)); }
.dot-primary, .chip.primary { --dot: var(--muscle-primary); }
.dot-secondary, .chip.secondary { --dot: var(--muscle-secondary); }
.dot-flagged, .chip.flagged { --dot: var(--muscle-flagged); }
/* Compare tint (viewer.js COMPARE_CSS): mint where the client is bigger now, ice blue where smaller. */
.dot-gain { --dot: #5fe0b2; }
.dot-loss { --dot: #9fbfff; }
.chip.flagged { border-color: rgba(124, 108, 240, 0.4); background: rgba(124, 108, 240, 0.1); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.chip-btn { transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast); color: var(--text-secondary); height: 28px; padding: 0 12px; }
.chip-btn:hover { color: var(--text-primary); border-color: var(--line-strong); }
.chip-btn[aria-pressed='true'] { color: var(--accent-strong); border-color: rgba(201, 168, 106, 0.55); background: rgba(201, 168, 106, 0.1); }

.status {
  --c: var(--text-secondary);
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px 0 6px;
  border-radius: 999px; font-size: var(--fs-sm); font-weight: 600; line-height: 1; white-space: nowrap;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
}
.status .i { width: 13px; height: 13px; stroke-width: 2; }
.status.good { --c: var(--good); }
.status.warning { --c: var(--warning); }
.status.serious { --c: #ef6b60; }

.flag-badge {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 20px; padding: 0 8px 0 7px; border-radius: 999px;
  background: rgba(124, 108, 240, 0.12); border: 1px solid rgba(124, 108, 240, 0.38);
  color: #c4bcff; font-size: var(--fs-xs); font-weight: 500; line-height: 1; white-space: nowrap;
}
.flag-badge .dot { width: 6px; height: 6px; }

/* Flag warnings carry the flag's own note. Tone: warning (secondary muscle), serious (primary muscle
   or a ruled-out movement), info (prescribed rehab work). */
.warn-badge {
  --c: var(--warning);
  display: flex; align-items: flex-start; gap: 7px;
  padding: 7px 10px 7px 8px; border-radius: 9px;
  font-size: var(--fs-sm); line-height: 1.35; color: var(--text-secondary);
  background: color-mix(in srgb, var(--c) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 32%, transparent);
}
.warn-badge.serious { --c: #ef6b60; }
.warn-badge.info { --c: #9aa7b8; }
.warn-badge > .i { width: 14px; height: 14px; stroke-width: 2; margin-top: 1px; color: var(--c); }
.warn-text { min-width: 0; flex: 1; }
.warn-text b { display: block; font-weight: 600; color: color-mix(in srgb, var(--c) 80%, white); }
.warn-note { display: block; margin-top: 1px; }
.warn-link {
  display: inline-flex; align-items: center; margin-top: 7px; min-height: 26px; padding: 3px 9px; border-radius: 7px; text-align: left;
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); background: transparent;
  color: var(--text-primary); font-size: var(--fs-xs); font-weight: 600;
}
.warn-link:hover { background: color-mix(in srgb, var(--c) 14%, transparent); }
/* In lists the note is clamped to two lines; the full text is in the tooltip. */
.ex-foot .warn-note, .item-flags .warn-note {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
}

.eyebrow {
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.2;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-secondary);
}
.eyebrow .count { color: var(--text-tertiary); margin-left: 6px; letter-spacing: 0.02em; }
.meta { font-size: var(--fs-sm); color: var(--text-tertiary); }

.avatar {
  --c: var(--accent);
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; border-radius: 50%;
  background: color-mix(in srgb, var(--c) 16%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--c) 50%, transparent);
  color: color-mix(in srgb, var(--c) 82%, white);
  font-size: var(--fs-base); font-weight: 600; letter-spacing: 0.03em;
}
.avatar.lg { width: 44px; height: 44px; font-size: var(--fs-body); }

/* ---------------------------------------------------------------- Roster */

.roster {
  grid-area: roster;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--line);
}
.roster-head { padding: 20px 20px 12px; }
.roster-search { margin: 0 14px 10px; }
.roster-list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 10px 12px; }
.roster-list > li + li { margin-top: 2px; }
.roster-foot { padding: 14px; border-top: 1px solid var(--line); }
.roster-empty { padding: 28px 12px; text-align: center; color: var(--text-tertiary); font-size: var(--fs-base); }

.client-card {
  position: relative;
  display: grid; grid-template-columns: 40px minmax(0, 1fr); column-gap: 12px;
  width: 100%; padding: 12px 12px 12px 10px;
  border: 1px solid transparent; border-radius: 12px;
  background: transparent; text-align: left;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.client-card:hover { background: var(--surface-2); }
.client-card:focus-visible { outline-offset: -2px; }
.client-card[aria-current='true'] { background: var(--surface-2); border-color: var(--line); }
.client-card[aria-current='true']::before {
  content: ''; position: absolute; left: -1px; top: 14px; bottom: 14px; width: 2px;
  border-radius: 2px; background: var(--accent);
}
.client-card .avatar { align-self: start; margin-top: 1px; }
.cc-text { display: block; min-width: 0; }
.cc-name, .cc-role, .cc-goal { display: block; }
.cc-name { font-weight: 600; font-size: var(--fs-body); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-role { font-size: var(--fs-sm); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-goal { font-size: var(--fs-sm); color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.cc-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: var(--fs-sm); color: var(--text-tertiary); }
.cc-when { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cc-when .i { width: 12px; height: 12px; }
.cc-rail-flag { display: none; }

.scrim { display: none; }

/* ---------------------------------------------------------------- Stage */

.stage {
  grid-area: stage;
  position: relative; min-width: 0; min-height: 0; overflow: hidden;
  background: var(--bg);
  container: stage / size;
}
/* Own stacking context: CSS2D tape labels carry depth z-indexes that must stay under the overlays. */
.stage:focus { outline: none; }
.viewer { position: absolute; inset: 0; z-index: 0; isolation: isolate; }
.viewer canvas { display: block; outline: none; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
  border: 1px solid var(--glass-line);
}

.stage-toolbar {
  position: absolute; top: 16px; right: 16px; left: 16px;
  display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px;
  pointer-events: none; z-index: 4;
}
.stage-toolbar > *, .stage-transport > * { pointer-events: auto; }
.stage-toolbar .seg, .stage-transport .seg { background: var(--glass); border-color: var(--glass-line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.stage-toolbar .icon-btn, .stage-toolbar .btn, .stage-transport .icon-btn {
  background: var(--glass); border-color: var(--glass-line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.stage-toolbar .btn-toggle[aria-pressed='true'] { background: rgba(201, 168, 106, 0.16); border-color: rgba(201, 168, 106, 0.55); }
.stage-toolbar .seg > button { height: 28px; }
.stage-toolbar .icon-btn { width: 36px; height: 36px; }
.stage-toolbar .btn { height: 36px; }

.select-pill {
  position: relative; display: inline-flex; align-items: center;
  height: 36px; border-radius: 10px; color: var(--text-secondary);
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  transition: border-color var(--t-fast), color var(--t-fast);
}
.select-pill:hover { border-color: var(--line-strong); color: var(--text-primary); }
.select-pill > .i { position: absolute; left: 11px; pointer-events: none; }
.select-pill select {
  appearance: none; height: 100%; max-width: 230px; padding: 0 30px 0 34px;
  border: 0; border-radius: 10px; background: transparent; color: inherit;
  font-size: var(--fs-base); font-weight: 500; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m4.5 6.5 3.5 3.5 3.5-3.5' fill='none' stroke='%23a7a59d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 14px;
}
.select-pill select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.select-pill select option { background: var(--surface-2); color: var(--text-primary); }
.select-pill.active { color: var(--accent-strong); border-color: rgba(201, 168, 106, 0.55); }

.hud {
  position: absolute; top: 16px; left: 16px; z-index: 3;
  width: clamp(224px, 38cqw, 300px); max-height: calc(100% - 92px); overflow-y: auto;
  border-radius: var(--radius-lg);
}
.hud-actions { display: flex; gap: 2px; margin: -4px -8px -4px 0; }
.hud .chip, .ex-card .chip {
  height: auto; min-height: 22px; max-width: 100%; padding: 3px 8px 3px 7px;
  border-radius: 11px; font-size: var(--fs-sm); line-height: 1.25; white-space: normal;
}
.hud .chips { gap: 5px; }
.hud-card { padding: 16px 18px 18px; border-radius: var(--radius-lg); }
.hud-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.hud-top .eyebrow { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-title { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.hud-phase {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  font-size: var(--fs-base); color: var(--accent-strong); font-weight: 500; min-height: 19px;
}
.hud-phase .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(201, 168, 106, 0.5); animation: pulse 1.8s var(--ease) infinite; }
.hud-phase.paused { color: var(--text-secondary); }
.hud-phase.paused .pulse { animation: none; background: var(--text-tertiary); }
.hud-group { margin-top: 14px; }
.hud-group .eyebrow { display: block; margin-bottom: 7px; font-size: var(--fs-xs); color: var(--text-tertiary); }
.hud-cues { counter-reset: cue; display: grid; gap: 7px; }
.hud-cues li { position: relative; padding-left: 25px; font-size: var(--fs-base); color: var(--text-secondary); line-height: 1.4; counter-increment: cue; }
.hud-cues li::before {
  content: counter(cue); position: absolute; left: 0; top: 0;
  width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--line-strong);
  display: grid; place-items: center; font-size: var(--fs-xs); line-height: 1; font-weight: 600; color: var(--text-tertiary);
}
.hud-stats { display: flex; justify-content: space-between; gap: 8px; margin-top: 14px; }
.hud-stat-label { font-size: var(--fs-xs); color: var(--text-tertiary); }
.hud-stat-value { font-size: var(--fs-md); font-weight: 600; margin-top: 2px; white-space: nowrap; }
.hud-stat-value .unit { margin-left: 3px; font-size: var(--fs-xs); font-weight: 500; color: var(--text-tertiary); }
.hud-warnings { display: grid; gap: 6px; margin-top: 12px; }
.hud-muted { font-size: var(--fs-base); color: var(--text-tertiary); }
.hud-stat-sub { margin-top: 1px; font-size: var(--fs-xs); color: var(--text-tertiary); white-space: nowrap; }
.hud-progress .hud-stat-value { font-size: var(--fs-lg); letter-spacing: -0.01em; }
.hud-progress .hud-stat-value .delta.neutral { color: var(--text-primary); }
.hud-goal { font-size: var(--fs-base); color: var(--text-secondary); line-height: 1.4; }

.preview-bar { padding: 12px 14px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: 1px solid var(--line); background: rgba(201, 168, 106, 0.08); }
.preview-bar + .hud-card { border-top-left-radius: 0; border-top-right-radius: 0; border-top: 0; }
.preview-row { display: flex; align-items: center; gap: 6px; }
.preview-row .eyebrow { flex: 1; min-width: 0; color: var(--accent-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-track { height: 3px; margin-top: 10px; border-radius: 3px; background: rgba(201, 168, 106, 0.18); overflow: hidden; }
.preview-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; }

.legend {
  position: absolute; left: 16px; bottom: 16px; z-index: 3;
  max-width: calc(100% - 32px - var(--transport-w) - 12px); /* wraps before it reaches the transport */
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px;
  padding: 8px 14px; border-radius: 17px; font-size: var(--fs-sm); color: var(--text-secondary);
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.legend .ghost-swatch { width: 14px; height: 9px; border-radius: 3px; border: 1px dashed #a7c3ff; background: rgba(167, 195, 255, 0.14); }

.stage-transport { position: absolute; right: 16px; bottom: 16px; z-index: 3; display: flex; align-items: center; gap: 8px; pointer-events: none; }
.stage-transport .icon-btn { width: 36px; height: 36px; border-radius: 10px; color: var(--text-primary); }
.stage-transport .seg { border-radius: 10px; }

.stage-hint {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2;
  padding: 7px 14px; border-radius: 999px; font-size: var(--fs-base); color: var(--text-secondary);
  white-space: nowrap; pointer-events: none;
  background: rgba(13, 15, 18, 0.6); border: 1px solid var(--glass-line);
  animation: fade-in 0.4s var(--ease);
}

.hover-tag {
  position: absolute; z-index: 6; pointer-events: none;
  padding: 4px 9px; border-radius: 7px;
  background: var(--glass-strong); border: 1px solid rgba(201, 168, 106, 0.5);
  color: var(--text-primary); font-size: var(--fs-sm); font-weight: 500; white-space: nowrap;
  transform: translate(14px, -120%);
}

.popover {
  position: absolute; z-index: 8;
  width: 300px; max-height: min(460px, calc(100% - 32px)); overflow-y: auto;
  padding: 16px 18px 18px; border-radius: var(--radius-lg);
  background: var(--glass-strong); border: 1px solid var(--line-strong);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  box-shadow: var(--pop-shadow);
  animation: pop-in var(--t) var(--ease);
}
.popover:focus { outline: none; }
.popover-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.popover h3 { font-size: var(--fs-lg); font-weight: 600; margin-top: 4px; }
.popover .anatomy { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-tertiary, var(--text-secondary)); font-style: italic; }
.popover .desc { margin-top: 8px; font-size: var(--fs-base); color: var(--text-secondary); line-height: 1.5; }
.popover h4 { margin: 16px 0 8px; }
.pop-flag {
  display: flex; gap: 8px; margin-top: 12px; padding: 9px 10px; border-radius: 9px;
  background: rgba(124, 108, 240, 0.1); border: 1px solid rgba(124, 108, 240, 0.35);
  font-size: var(--fs-base); line-height: 1.4; color: #cfc8ff;
}
.pop-flag .i { color: #a99dff; margin-top: 1px; }
.pop-ex { display: grid; gap: 2px; }
.pop-ex button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: var(--fs-base);
  transition: background var(--t-fast);
}
.pop-ex button:hover { background: rgba(255, 255, 255, 0.05); }
.pop-ex .role { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-tertiary); }
.pop-ex .play-glyph { color: var(--accent); }
.popover-foot { margin-top: 12px; }

.stage-empty { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; background: radial-gradient(ellipse at center, #161a20, var(--bg) 70%); }
.empty-card { max-width: 360px; text-align: center; display: grid; justify-items: center; gap: 12px; }
.empty-card h2 { font-size: var(--fs-2xl); font-weight: 600; }
.empty-card p { color: var(--text-secondary); font-size: var(--fs-body); margin-bottom: 8px; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.empty-mark { width: 52px; height: 52px; fill: none; stroke: var(--accent); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.empty-mark circle { stroke-opacity: 0.35; }

.viewer-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-tertiary); font-size: var(--fs-base); }

/* Tape-measure labels rendered by the viewer's CSS2DRenderer */
div.tape-label {
  padding: 3px 8px; border-radius: 999px;
  background: rgba(13, 15, 18, 0.8); border: 1px solid rgba(201, 168, 106, 0.75);
  color: var(--text-primary); font: 500 var(--fs-xs)/1.25 var(--font);
  font-variant-numeric: tabular-nums; letter-spacing: 0.01em;
  white-space: nowrap; pointer-events: none;
}

/* ---------------------------------------------------------------- Right panel */

.panel {
  grid-area: panel;
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: var(--surface-1);
  border-left: 1px solid var(--line);
}
.panel-client { display: flex; align-items: flex-start; gap: 12px; padding: 16px 22px 14px; min-height: 74px; }
.panel-client > .avatar { margin-top: 2px; }
.pc-text { min-width: 0; flex: 1; }
.pc-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--fs-lg); font-weight: 600; }
.pc-name-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-meta { font-size: var(--fs-base); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pc-actions .btn .i { width: 14px; height: 14px; }
.pc-actions .btn-primary .i { fill: currentColor; stroke: none; }
.tab-quick { display: none; }

.tabs { display: flex; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; flex: 1 0 auto; height: 42px; padding: 0 10px;
  border: 0; background: none; color: var(--text-secondary);
  font-size: var(--fs-base); font-weight: 500; transition: color var(--t-fast);
}
.tab:hover { color: var(--text-primary); }
.tab[aria-selected='true'] { color: var(--text-primary); }
.tab::after {
  content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px;
  border-radius: 2px; background: var(--accent);
  transform: scaleX(0); transition: transform var(--t) var(--ease);
}
.tab[aria-selected='true']::after { transform: scaleX(1); }
.tab:focus-visible { outline-offset: -4px; border-radius: 10px; }

.tabpanel { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 22px 40px; scrollbar-gutter: stable; }
.tabpanel:focus-visible { outline-offset: -3px; }
.tabpanel > * { animation: fade-in 0.22s var(--ease); }

.section + .section { margin-top: 26px; padding-top: 24px; border-top: 1px solid var(--line); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 28px; }
.section-head h3 { font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-secondary); }
.subhead { font-size: var(--fs-sm); font-weight: 500; color: var(--text-tertiary); margin: 18px 0 10px; }
.subhead:first-child { margin-top: 0; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; }
.measure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 12px 10px; }
.measure-grid .field > label { font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }

.swatches { display: flex; gap: 10px; }
.swatch {
  position: relative; width: 26px; height: 26px; border-radius: 50%; padding: 0;
  border: 0; background: var(--c); cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
  transition: transform var(--t-fast);
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-checked='true'] { box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 3.5px var(--c); }

.flag-list { display: grid; gap: 8px; }
.flag-item {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: start;
  padding: 10px 10px 10px 12px; border-radius: var(--radius);
  background: rgba(124, 108, 240, 0.07); border: 1px solid rgba(124, 108, 240, 0.28);
}
.flag-item .dot { margin-top: 6px; }
.flag-muscle { font-size: var(--fs-base); font-weight: 600; }
.flag-note { font-size: var(--fs-base); color: var(--text-secondary); margin-top: 1px; }
.flag-avoid { font-size: var(--fs-sm); color: #cfc8ff; margin-top: 4px; }
.flag-tag {
  display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px; vertical-align: 1px;
  font-size: var(--fs-xs); font-weight: 600; color: #b9c3d0; border: 1px solid rgba(154, 167, 184, 0.4);
}
.flag-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }
.flag-add select { grid-column: 1 / -1; }
.flag-rules { grid-column: 1 / -1; display: grid; gap: 8px; margin-top: 4px; }
.flag-rules .chips { gap: 6px; }
.chip-check { cursor: pointer; color: var(--text-secondary); height: 28px; padding: 0 11px 0 9px; user-select: none; transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast); }
.chip-check input { width: 13px; height: 13px; margin: 0; accent-color: var(--muscle-flagged); cursor: pointer; }
.chip-check:hover { color: var(--text-primary); border-color: var(--line-strong); }
.chip-check:has(input:checked) { color: #d9d3ff; border-color: rgba(124, 108, 240, 0.55); background: rgba(124, 108, 240, 0.12); }
.chip-check:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.flag-rules .check { font-size: var(--fs-base); color: var(--text-secondary); }
.field-hint { align-self: end; padding-bottom: 9px; font-size: var(--fs-sm); color: var(--text-tertiary); line-height: 1.35; }
.empty-inline { font-size: var(--fs-base); color: var(--text-tertiary); padding: 2px 0; }

/* ---------------------------------------------------------------- Analysis */

.diagram { min-height: 200px; border-radius: var(--radius-lg); background: var(--bg); border: 1px solid var(--line); padding: 10px; }
.diagram svg { display: block; width: 100%; height: auto; }

.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metric {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 14px 13px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.metric.wide { grid-column: 1 / -1; }
.metric-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.metric > .status { align-self: flex-start; }
.metric-label { font-size: var(--fs-sm); color: var(--text-secondary); font-weight: 500; }
.metric-value { font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -0.015em; line-height: 1.1; white-space: nowrap; }
.metric-value .unit { font-size: var(--fs-sm); font-weight: 500; color: var(--text-tertiary); margin-left: 4px; letter-spacing: 0; }
.metric-note { font-size: var(--fs-sm); color: var(--text-tertiary); line-height: 1.4; }
.split { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; margin: 4px 0 2px; }
.split > span { display: block; height: 100%; }
.split .lean { background: var(--accent); }
.split .fat { background: #5d5a54; }
.split-legend { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: var(--fs-base); color: var(--text-secondary); }
.split-legend b { color: var(--text-primary); font-weight: 600; margin-left: 4px; }
.split-legend .key { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 7px; }
.footnote { margin-top: 14px; font-size: var(--fs-sm); color: var(--text-tertiary); }

/* ---------------------------------------------------------------- Progress */

.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.kpi-label { font-size: var(--fs-sm); color: var(--text-tertiary); }
.kpi-value { font-size: var(--fs-xl); font-weight: 600; margin-top: 3px; white-space: nowrap; letter-spacing: -0.01em; }
.kpi-sub { font-size: var(--fs-sm); color: var(--text-tertiary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delta { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.delta .i { width: 12px; height: 12px; stroke-width: 2.2; }
.delta.better { color: var(--good); }
.delta.worse { color: #ef6b60; }
.delta.neutral { color: var(--text-secondary); }

.chart { min-height: 220px; border-radius: var(--radius-lg); background: var(--surface-1); border: 1px solid var(--line); padding: 14px 20px 10px 14px; }

.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.history { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.history th {
  text-align: right; font-weight: 500; font-size: var(--fs-xs); color: var(--text-tertiary);
  padding: 0 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: bottom;
}
.history th .unit { display: block; font-weight: 400; opacity: 0.8; }
.history th:first-child, .history td:first-child { text-align: left; padding-left: 2px; }
.history td { text-align: right; padding: 9px 6px; border-bottom: 1px solid rgba(42, 47, 56, 0.6); vertical-align: top; white-space: nowrap; }
.history td .v { display: block; color: var(--text-primary); font-weight: 500; }
.history td .delta { display: block; font-size: var(--fs-xs); margin-top: 2px; }
.history td.date { color: var(--text-secondary); }
.history td.date .tag { display: block; font-size: var(--fs-xs); color: var(--accent); margin-top: 2px; }
.history .sel { background: rgba(201, 168, 106, 0.05); }
.history th.sel { color: var(--accent-strong); }
.history td.act, .history th.act { width: 32px; padding-right: 0; text-align: right; }
.history tbody tr { transition: background var(--t-fast); }
.history tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

/* ---------------------------------------------------------------- Exercises */

.ex-filters { display: grid; gap: 12px; margin-bottom: 16px; }
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.filter-row .field { flex-direction: row; align-items: center; gap: 10px; flex: 1; }
.filter-row .field > label { white-space: nowrap; }
.filter-row select { max-width: 220px; }
.ex-list { display: grid; gap: 10px; }
.ex-card {
  position: relative; padding: 14px 14px 12px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--line);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.ex-card:hover { border-color: var(--line-strong); }
.ex-card.active { border-color: rgba(201, 168, 106, 0.6); background: linear-gradient(180deg, rgba(201, 168, 106, 0.07), rgba(201, 168, 106, 0.02)); }
.ex-top { display: flex; align-items: flex-start; gap: 10px; }
.ex-top > .btn { flex: none; }
.ex-main {
  display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: 0; padding: 0;
  border: 0; background: none; text-align: left; border-radius: 8px;
}
.ex-play {
  display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line-strong); color: var(--accent);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.ex-card:hover .ex-play { border-color: rgba(201, 168, 106, 0.6); }
.ex-card.active .ex-play { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.ex-play .i { width: 13px; height: 13px; }
.ex-text { min-width: 0; flex: 1; }
.ex-title { display: block; font-size: var(--fs-body); font-weight: 600; }
.ex-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: var(--fs-sm); color: var(--text-tertiary); }
.ex-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line-strong); }
.difficulty { display: inline-flex; gap: 3px; }
.difficulty i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.difficulty i.on { background: var(--accent); }
.ex-muscles { display: grid; gap: 6px; margin-top: 10px; padding-left: 46px; }
.ex-role { display: grid; grid-template-columns: 62px minmax(0, 1fr); align-items: start; gap: 8px; }
.ex-role-label { font-size: var(--fs-xs); line-height: 22px; color: var(--text-tertiary); }
.ex-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; padding-left: 46px; }
.ex-card .chips { gap: 5px; }
.ex-empty { padding: 36px 12px; text-align: center; color: var(--text-tertiary); font-size: var(--fs-base); }
.result-count { font-size: var(--fs-sm); color: var(--text-tertiary); white-space: nowrap; }

/* ---------------------------------------------------------------- Program */

.day-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 16px 0 14px; }

.day-pill {
  height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--text-secondary);
  font-size: var(--fs-base); font-weight: 500; white-space: nowrap;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.day-pill:hover { color: var(--text-primary); border-color: var(--line-strong); }
.day-pill[aria-pressed='true'] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.day-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: end; }
.day-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.day-stat { padding: 10px 12px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); min-width: 0; }
.day-stat .label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-stat .label .i { width: 12px; height: 12px; }
.day-stat .value { font-size: var(--fs-md); font-weight: 600; margin-top: 3px; white-space: nowrap; }

.items { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.item { padding: 12px 12px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); transition: border-color var(--t-fast); }
.item.active { border-color: rgba(201, 168, 106, 0.6); }
.item-head { display: flex; align-items: center; gap: 10px; }
.item-index {
  display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--line-strong); font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary);
}
.item.active .item-index { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.item-name { flex: 1; min-width: 0; padding: 0; border: 0; background: none; text-align: left; border-radius: 6px; }
.item-name b { display: block; font-size: var(--fs-body); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-name span { display: block; font-size: var(--fs-sm); color: var(--text-tertiary); }
.item-name:hover b { color: var(--accent-strong); }
.item-actions { display: flex; gap: 2px; }
.item-actions .item-delete { margin-left: 10px; } /* kept apart from reorder so a slip does not delete */
.item-flags { display: grid; gap: 6px; margin-top: 10px; }
.item-fields { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1.1fr); gap: 8px; margin-top: 10px; }
.item-fields .field > label { font-size: var(--fs-xs); color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.07em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-fields .input, .item-notes { height: 32px; font-size: var(--fs-base); }
.item-fields .input-unit .input { padding-right: 30px; }
.item-fields .input-unit .unit { right: 8px; font-size: var(--fs-xs); }
.item-notes { margin-top: 8px; }
.add-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 12px; }

.session-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; padding: 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.rpe { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 3px; }
.rpe label { position: relative; }
.rpe input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.rpe span {
  display: grid; place-items: center; height: 30px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface-1);
  font-size: var(--fs-base); font-weight: 500; color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.rpe label:hover span { color: var(--text-primary); border-color: var(--line-strong); }
.rpe input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.rpe input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.session-form-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.pick-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.pick-row label { position: relative; }
.pick-row input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pick-row span {
  display: grid; place-items: center; height: 32px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface-1);
  font-size: var(--fs-base); font-weight: 500; color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.pick-row label:hover span { color: var(--text-primary); border-color: var(--line-strong); }
.pick-row input:checked + span { background: var(--surface-3); border-color: var(--line-strong); color: var(--text-primary); box-shadow: inset 0 0 0 1px var(--line-strong); }
.pick-row input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
fieldset:disabled .rpe { opacity: 0.4; }
.session-list { display: grid; gap: 2px; margin-top: 14px; }
.session {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 10px 4px 10px 2px; border-bottom: 1px solid rgba(42, 47, 56, 0.6);
}
.session-main { min-width: 0; }
.session-date { font-size: var(--fs-sm); color: var(--text-secondary); }
.session-day { font-size: var(--fs-base); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-note { font-size: var(--fs-sm); color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-tags { display: flex; align-items: center; gap: 6px; }
.rpe-tag { font-size: var(--fs-sm); color: var(--text-secondary); padding: 2px 7px; border-radius: 6px; border: 1px solid var(--line); white-space: nowrap; }

/* ---------------------------------------------------------------- Menu, modals, toasts */

.menu {
  position: fixed; z-index: 60; min-width: 210px; padding: 6px;
  border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line-strong);
  box-shadow: var(--pop-shadow); animation: pop-in var(--t-fast) var(--ease);
}
.menu-title { padding: 6px 10px 6px; font-size: var(--fs-xs); color: var(--text-tertiary); }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }
.menu-warn { display: flex; align-items: center; gap: 7px; margin: 0 4px 6px; padding: 7px 9px; border-radius: 8px; font-size: var(--fs-sm); color: #f5b1aa; background: rgba(226, 87, 76, 0.1); }
.menu button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; text-align: left; font-size: var(--fs-base);
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-3); outline: none; }
.menu button span { color: var(--text-tertiary); font-size: var(--fs-sm); margin-left: auto; }
.menu button > .i { color: var(--text-secondary); }
.menu button:has(> .i) { justify-content: flex-start; }
.menu button.danger, .menu button.danger > .i { color: #f08a80; }
.menu button.danger:hover, .menu button.danger:focus-visible { background: rgba(226, 87, 76, 0.12); }

.modal {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0;
  border: 1px solid var(--line-strong); border-radius: 16px;
  background: var(--surface-1); color: var(--text-primary);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}
.modal[open] { animation: modal-in 0.22s var(--ease); }
.modal::backdrop { background: rgba(6, 7, 9, 0.66); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.modal-confirm { width: min(420px, calc(100vw - 32px)); }
.modal-form { display: flex; flex-direction: column; max-height: calc(100dvh - 50px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 6px; }
.modal-head h2 { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.01em; }
.modal-head p { font-size: var(--fs-base); color: var(--text-secondary); margin-top: 4px; }
.modal-body { padding: 16px 24px 22px; overflow-y: auto; }
.modal-body .subhead { margin-top: 22px; }
.modal-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.modal-body .subhead:first-child { margin-top: 0; }
.group-note { margin-top: 8px; font-size: var(--fs-sm); color: var(--text-tertiary); line-height: 1.4; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--line); }
.modal-foot .meta { margin-right: auto; }
.modal-confirm .modal-body { padding-top: 10px; font-size: var(--fs-body); color: var(--text-secondary); line-height: 1.55; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 12px; }
.form-note { display: flex; align-items: flex-start; gap: 8px; margin-top: 14px; padding: 9px 12px; border-radius: 9px; font-size: var(--fs-base); color: var(--text-primary); background: rgba(201, 168, 106, 0.1); border: 1px solid rgba(201, 168, 106, 0.4); }
.form-note .i { color: var(--accent); margin-top: 2px; }
.form-error { margin-top: 14px; padding: 9px 12px; border-radius: 9px; font-size: var(--fs-base); color: #f5b1aa; background: rgba(226, 87, 76, 0.1); border: 1px solid rgba(226, 87, 76, 0.35); }

.toasts {
  position: fixed; left: 16px; right: 16px; bottom: 24px; z-index: 80;
  display: grid; justify-items: center; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  max-width: min(560px, 100%); padding: 10px 16px 10px 12px; border-radius: 12px;
  background: var(--surface-3); border: 1px solid var(--line-strong);
  box-shadow: var(--pop-shadow); font-size: var(--fs-base); line-height: 1.4;
  animation: toast-in 0.26s var(--ease);
}
.toast.interactive { pointer-events: auto; padding-right: 8px; }
.toast-text { min-width: 0; }
.toast > .i { color: var(--accent); }
.toast.error > .i { color: #ef6b60; }
.toast-action {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 30px; padding: 0 12px; margin-left: 4px;
  border: 1px solid rgba(201, 168, 106, 0.5); border-radius: 8px; background: rgba(201, 168, 106, 0.12);
  color: var(--accent-strong); font-size: var(--fs-base); font-weight: 600; white-space: nowrap;
}
.toast-action:hover { background: rgba(201, 168, 106, 0.2); }
.toast-close { margin-left: -2px; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }

/* ---------------------------------------------------------------- Motion */

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(201, 168, 106, 0.55); }
  70% { box-shadow: 0 0 0 7px rgba(201, 168, 106, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 168, 106, 0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* ---------------------------------------------------------------- Stage container sizes */

@container stage (max-width: 820px) {
  .hud { top: calc(30px + var(--toolbar-h, 36px)); max-height: calc(100% - 106px - var(--toolbar-h, 36px)); }
  .hud.hud-idle { width: clamp(200px, 34cqw, 260px); }
  .hud-card { padding: 14px 16px 16px; }
  .hud-title { font-size: var(--fs-lg); }
  .hud-stat-value { font-size: var(--fs-body); }
  .hud-stats { gap: 4px; }
  .stage-toolbar { justify-content: flex-start; }
}
@container stage (max-width: 860px) {
  .stage-hint { bottom: 66px; }
}
@container stage (max-width: 520px) {
  .legend { bottom: 64px; max-width: calc(100% - 32px); }
  .stage-hint { display: none; }
}
@container stage (max-width: 640px) {
  .select-pill select { max-width: 180px; }
  .hud-cues li { font-size: var(--fs-sm); }
  .popover { width: 272px; }
}

/* ---------------------------------------------------------------- Responsive layout */

/* Large laptops and desktops: the panel grows so charts and diagrams are not stamp-sized. */
@media (min-width: 1600px) {
  :root { --panel-w: clamp(440px, 28vw, 560px); }
}

/* < 1366 (13-inch laptops, iPad landscape): roster collapses to an avatar rail with a drawer toggle */
@media (max-width: 1365.98px) {
  :root { --roster-w: 72px; --panel-w: 400px; }
  .topbar .roster-toggle { display: inline-grid; }
  .topbar { padding-left: 12px; }

  .roster:not(.open) .roster-head,
  .roster:not(.open) .roster-search,
  .roster:not(.open) .cc-text,
  .roster:not(.open) .roster-empty { display: none; }
  .roster:not(.open) .roster-list { padding: 12px 10px; }
  .roster:not(.open) .client-card { display: grid; place-items: center; grid-template-columns: 1fr; padding: 7px 0; }
  .roster:not(.open) .client-card .avatar { grid-row: auto; margin: 0; }
  .roster:not(.open) .client-card[aria-current='true']::before { left: -10px; top: 12px; bottom: 12px; }
  .roster:not(.open) .cc-rail-flag {
    display: block; position: absolute; top: 5px; right: 8px; width: 10px; height: 10px; border-radius: 50%;
    background: var(--muscle-flagged); border: 2px solid var(--surface-1);
  }
  .roster:not(.open) .roster-foot { padding: 12px 10px; }
  .roster:not(.open) #newClientBtn { padding: 0; }
  .roster:not(.open) #newClientBtn .btn-label { display: none; }

  .roster.open {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; z-index: 50; width: 304px;
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.45);
    animation: drawer-in 0.24s var(--ease);
  }
  .scrim:not([hidden]) { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 45; background: rgba(6, 7, 9, 0.5); animation: fade-in 0.2s; }
  .client-card { grid-template-columns: 40px minmax(0, 1fr); }
}
@keyframes drawer-in { from { transform: translateX(-16px); opacity: 0.4; } to { transform: none; opacity: 1; } }

/* Narrow top bar: export, import and reset move into one labelled Data menu (no bare arrow icons). */
@media (max-width: 1140px) {
  .topbar #exportBtn, .topbar #importBtn, .topbar #resetBtn { display: none; }
  .topbar .data-more { display: inline-flex; }
}

/* < 1024: the workspace panel moves below the stage (iPad portrait) */
@media (max-width: 1023.98px) {
  .app {
    grid-template-columns: var(--roster-w) minmax(0, 1fr);
    grid-template-rows: var(--topbar-h) minmax(0, 1fr) minmax(0, 42%);
    grid-template-areas: 'top top' 'roster stage' 'roster panel';
  }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .panel-client { display: none; }
  .tab-quick { display: block; margin: -6px 0 18px; }
  .tab-quick .pc-actions { margin-top: 0; }
  .brand-sub { display: none; }
  .stage-hint { display: none; }
}

@media (max-width: 640px) {
  :root { --roster-w: 0px; }
  .roster:not(.open) { display: none; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'top' 'stage' 'panel'; }
  .topbar-divider, .brand-name { display: none; }
  #presentBtn .btn-label { display: none; }
  .hud { display: none; }
}

/* ---------------------------------------------------------------- Client view and empty roster */

/* Client view: a full-bleed stage for the client. Other clients, private notes, editing and the
   data actions are hidden; only the view toggle and units stay in the top bar. */
.app.present {
  grid-template-columns: 0 minmax(0, 1fr) 0;
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
  grid-template-areas: 'top top top' 'roster stage panel';
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
}
.app.present .roster,
.app.present .panel,
.app.present .scrim,
.app.present .roster-toggle,
.app.present .stage-hint,
.app.present .topbar-actions > :not(#presentBtn):not(#unitsToggle) { display: none !important; }
.app.present .hud { width: clamp(260px, 30cqw, 340px); }
.app.present .hud-title { font-size: var(--fs-2xl); }
.app.present .hud-progress .hud-stat-value { font-size: var(--fs-xl); }
.app.present .brand-sub { display: inline; }

.app.empty .panel-client, .app.empty .tabs { display: none; }
.onboard { display: grid; gap: 12px; justify-items: start; padding: 6px 0; }
.onboard h3 { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.01em; }
.onboard-steps { display: grid; gap: 10px; margin: 6px 0 8px; counter-reset: step; width: 100%; }
.onboard-steps li {
  position: relative; display: grid; gap: 2px; padding: 12px 14px 12px 50px; counter-increment: step;
  border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
}
.onboard-steps li::before {
  content: counter(step); position: absolute; left: 14px; top: 12px;
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid rgba(201, 168, 106, 0.55); color: var(--accent-strong); font-size: var(--fs-sm); font-weight: 600;
}
.onboard-steps b { font-size: var(--fs-body); font-weight: 600; }
.onboard-steps span { font-size: var(--fs-base); color: var(--text-secondary); }

/* ---------------------------------------------------------------- Touch screens (iPad)
   44 px targets for fingers; laptop density is unchanged. */

@media (pointer: coarse) {
  :root { --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --transport-w: 250px; }
  .btn, .input, select.input { min-height: 44px; }
  .btn-sm { min-height: 40px; }
  .icon-btn, .icon-btn.sm { width: 44px; height: 44px; }
  .seg { padding: 4px; }
  .seg > button, .seg-sm > button, .stage-toolbar .seg > button { height: 36px; min-width: 44px; }
  .stage-toolbar .icon-btn, .stage-toolbar .btn, .select-pill, .stage-transport .icon-btn { height: 44px; min-width: 44px; }
  .stage-toolbar .icon-btn, .stage-transport .icon-btn { width: 44px; }
  .tab { height: 48px; }
  .chip-btn, .chip-check, .day-pill { height: 40px; padding: 0 14px; }
  .rpe span, .pick-row span { height: 44px; }
  .swatch { width: 36px; height: 36px; }
  .swatches { gap: 12px; }
  .pop-ex button, .menu button { min-height: 44px; }
  .item-fields .input, .item-notes { height: 44px; }
  .item-head { flex-wrap: wrap; }
  .item-name { flex: 1 1 96px; }
  .item-actions { gap: 6px; margin-left: auto; }
  .item-actions .item-delete { margin-left: 14px; }
  .hud-actions { margin: -10px -12px -10px 0; }
  .warn-link, .toast-action { height: 40px; }
  .check input { width: 22px; height: 22px; }
  .client-card { padding-top: 14px; padding-bottom: 14px; }

  /* The muscle card docks as a bottom sheet instead of covering the body. */
  .muscle-popover {
    left: max(16px, calc(50% - 220px)); right: max(16px, calc(50% - 220px)); top: auto; bottom: 76px;
    width: auto; max-height: 45%;
  }
}

/* ---------------------------------------------------------------- Print: session sheet */

.print-sheet { display: none; }

@media print {
  @page { margin: 14mm; }
  html, body { height: auto; overflow: visible; background: #fff; color: #000; }
  .app, .menu, .modal, .toasts { display: none !important; }
  .print-sheet { display: block; font: 400 10.5pt/1.4 var(--font); color: #000; }
  .ps-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; padding-bottom: 10pt; border-bottom: 1.5pt solid #000; }
  .ps-brand { font-size: 9pt; font-weight: 600; letter-spacing: 0.28em; }
  .ps-title { font-size: 17pt; font-weight: 600; margin-top: 4pt; }
  .ps-sub { font-size: 10pt; color: #333; margin-top: 2pt; }
  .ps-meta { display: grid; grid-template-columns: auto auto; gap: 2pt 12pt; font-size: 9.5pt; text-align: left; }
  .ps-meta dt { color: #555; }
  .ps-meta dd { margin: 0; font-weight: 600; }
  .ps-flags { margin-top: 10pt; font-size: 9.5pt; }
  .ps-flags b { font-weight: 600; }
  .ps-table { width: 100%; border-collapse: collapse; margin-top: 14pt; font-variant-numeric: tabular-nums; }
  .ps-table th { text-align: left; font-size: 8.5pt; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; padding: 5pt 6pt; border-bottom: 1pt solid #000; }
  .ps-table td { padding: 8pt 6pt; border-bottom: 0.5pt solid #999; vertical-align: top; }
  .ps-table tr { break-inside: avoid; }
  .ps-num { width: 18pt; color: #555; }
  .ps-ex b { display: block; font-weight: 600; }
  .ps-ex span { font-size: 8.5pt; color: #555; }
  .ps-notes { color: #333; font-size: 9.5pt; }
  .ps-boxes { display: flex; flex-wrap: wrap; gap: 4pt; }
  .ps-box { width: 13pt; height: 13pt; border: 0.9pt solid #000; border-radius: 2pt; }
  .ps-foot { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 18pt; margin-top: 22pt; font-size: 9pt; }
  .ps-line { border-bottom: 0.75pt solid #000; height: 22pt; }
  .ps-line-label { color: #555; margin-top: 3pt; }
}
