:root {
  color-scheme: dark;
  --bg: #111111;
  --surface: #1b1b1b;
  --elevated: #232323;
  --ink: #f5f5f5;
  --muted: #9ca3af;
  --subtle: #71717a;
  --line: #2e2e2e;
  --teal: #7dd3fc;
  --teal-dark: #f5f5f5;
  --coral: #d97757;
  --mustard: #d6a24a;
  --mint: rgba(74, 222, 128, 0.12);
  --rose: rgba(217, 119, 87, 0.14);
  --teal-soft: rgba(125, 211, 252, 0.12);
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% -10%, rgba(255, 255, 255, 0.06), transparent 32rem),
    radial-gradient(circle at 90% 8%, rgba(125, 211, 252, 0.05), transparent 28rem),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141414;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #525252;
  box-shadow: 0 0 0 3px rgba(245, 245, 245, 0.08);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

.field-stack {
  display: grid;
  gap: 7px;
}

.field-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 650;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 1.08rem;
  line-height: 1.1;
}

h2 {
  font-size: clamp(1.65rem, 3vw, 2.55rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h3 {
  font-size: 1.35rem;
}

h4 {
  font-size: 1rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}

.auth-locked .app-shell {
  display: none !important;
}

.auth-pending .app-shell {
  display: none !important;
}

/* Never show client portal or questionnaire while auth gate is active */
.auth-locked .client-portal-shell,
.auth-pending .client-portal-shell {
  display: none !important;
}

.auth-locked .onboarding-overlay,
.auth-pending .onboarding-overlay {
  display: none !important;
}

.auth-pending .auth-gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 26px;
}

.auth-pending .auth-gate::before {
  content: "Loading Transform With Tien...";
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 8px 16px;
  font-weight: 850;
}

body.client-mode .app-shell { display: none !important; }

.client-portal-shell { display: none; }
body.client-mode .client-portal-shell { display: flex; }

.client-mode .sidebar,
.client-mode .tab[data-view="program"],
.client-mode .tab[data-view="library"],
.client-mode .tab[data-view="clients"],
.client-mode .tab[data-view="clientsList"],
.client-mode .coach-only,
.client-mode #resetDemoBtn,
.client-mode #exportDataBtn,
.client-mode #addAppointmentBtn,
.client-mode #dayAddAppointmentBtn,
.client-mode #workoutBuilderForm,
.client-mode #exerciseLibraryForm,
.client-mode #photoForm,
.client-mode #measurementForm,
.client-mode #strengthForm,
.client-mode .schedule-list-panel .session-actions button:not([data-action="view-workout"]),
.client-mode .day-event-card .session-actions button:not([data-action="view-workout"]),
.client-mode .photo-controls,
.client-mode #clientNoteForm {
  display: none !important;
}

.client-mode .workspace {
  max-width: 1320px;
  margin: 0 auto;
}

.client-mode .tab[data-view="schedule"] {
  order: 1;
}

.client-mode .tab[data-view="portal"] {
  order: 2;
}

.client-mode .tab[data-view="nutrition"] {
  order: 3;
}

.client-mode .tab[data-view="progress"] {
  order: 4;
}

.client-mode .tab[data-view="photos"] {
  order: 5;
}

.client-mode .tab[data-view="settings"] {
  order: 6;
}

.client-mode .topbar-actions {
  justify-content: flex-end;
}

.client-mode .portal-grid {
  grid-template-columns: minmax(0, 1fr);
}

.client-mode #portalView .wide-panel {
  grid-column: 1 / -1;
}

.client-mode .client-switcher {
  display: none;
}

.auth-gate {
  display: none;
}

.auth-locked .auth-gate {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.08), transparent 26rem),
    radial-gradient(circle at 80% 0%, rgba(125, 211, 252, 0.07), transparent 30rem),
    #0b0b0c;
  padding: 26px;
}

.auth-card {
  display: grid;
  gap: 22px;
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.46);
  padding: 30px;
}

.auth-brand {
  display: flex;
  gap: 13px;
  align-items: center;
}

.auth-brand h1 {
  font-size: clamp(1.8rem, 4vw, 2.65rem);
  letter-spacing: 0;
}

.auth-brand span {
  color: var(--muted);
  font-weight: 650;
}

.auth-card-form {
  display: grid;
  gap: 13px;
}

.auth-card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.link-button {
  justify-self: start;
  padding: 0;
  background: transparent;
  color: var(--teal-dark);
  font-weight: 850;
}

.auth-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.auth-card .brand-mark {
  background: #f5f5f5;
  color: #111111;
}

.sidebar {
  display: none;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 253, 249, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 45px;
  height: 45px;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 850;
  letter-spacing: 0;
}

.brand p,
.muted {
  color: var(--muted);
}

.search-box {
  margin-bottom: 16px;
}

.client-list {
  display: grid;
  gap: 9px;
  margin-bottom: 18px;
}

.client-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf2;
  color: var(--ink);
  text-align: left;
}

.client-card.active {
  border-color: var(--teal);
  background: var(--mint);
}

.client-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}

.client-card strong,
.client-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-card span {
  color: var(--muted);
  font-size: 0.84rem;
}

.session-pill {
  min-width: 36px;
  border-radius: 999px;
  background: #fff;
  color: var(--teal-dark);
  padding: 4px 8px;
  font-weight: 800;
  text-align: center;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: flex-end;
}

.client-switcher {
  min-width: min(360px, 100%);
  text-align: left;
}

.client-switcher span {
  font-size: 0.76rem;
}

.client-switcher select {
  min-height: 40px;
}

.auth-panel {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  padding: 11px 13px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.84);
  box-shadow: 0 10px 26px rgba(50, 45, 37, 0.07);
}

.auth-panel strong,
.auth-panel span {
  display: block;
}

.auth-panel span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.auth-status {
  min-width: max-content;
  border-radius: 999px;
  background: var(--mint);
  color: var(--teal-dark) !important;
  padding: 6px 10px;
  font-weight: 850 !important;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(180px, 0.8fr) minmax(140px, 0.55fr) auto auto;
  gap: 10px;
  align-items: end;
  width: 100%;
}

.auth-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.eyebrow {
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 10px;
}

.stat strong {
  font-size: clamp(1.2rem, 2.4vw, 2.05rem);
  line-height: 1;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  width: fit-content;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.7);
  margin-bottom: 22px;
  position: sticky;
  top: 0;
  z-index: 900;
  backdrop-filter: blur(16px);
}

.tab {
  min-height: 39px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 8px 13px;
  font-weight: 750;
}

.tab.active {
  background: var(--ink);
  color: #fff;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 15px;
}

.section-heading p {
  margin-top: 5px;
  color: var(--muted);
}

.content-grid {
  display: grid;
  gap: 16px;
  align-items: start;
}

.schedule-grid,
.photos-grid,
.portal-grid {
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
}

.calendar-layout {
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
}

.calendar-panel,
.schedule-list-panel {
  grid-column: span 1;
}

.schedule-list-panel {
  grid-column: 1 / -1;
}

.nutrition-grid {
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
}

.library-grid {
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
}

.clients-grid {
  grid-template-columns: minmax(280px, 420px) minmax(280px, 420px);
}

.program-grid {
  grid-template-columns: minmax(0, 1fr);
}

.session-workouts-panel {
  grid-column: 1 / -1;
}

.workout-builder-panel {
  grid-column: 1 / -1;
}

.progress-grid {
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
}

.panel {
  display: grid;
  gap: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.wide-panel {
  min-width: 0;
}

.calendar-sidebar {
  align-content: start;
}

.calendar-stats {
  display: grid;
  gap: 10px;
}

.calendar-stats > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.calendar-stats span,
.calendar-legend {
  color: var(--muted);
}

.calendar-legend {
  display: grid;
  gap: 9px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-weight: 650;
}

.calendar-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend-dot.scheduled {
  background: #38bdf8;
}

.legend-dot.completed {
  background: var(--teal);
}

.legend-dot.cancelled {
  background: var(--coral);
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

.calendar-nav h4 {
  min-width: 120px;
  font-size: 1.25rem;
}

.schedule-view-toggle-group {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding: 3px;
  margin-left: 6px;
}

.schedule-view-toggle {
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 5px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
  white-space: nowrap;
}

.schedule-view-toggle:hover {
  background: var(--field-hover);
  color: var(--ink);
}

.schedule-view-toggle.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

.calendar-grid.two-week-view {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #fff;
}

.calendar-weekdays span {
  padding: 12px;
  color: var(--ink);
  font-weight: 800;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  background: #fff;
}

.calendar-day {
  position: relative;
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 132px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  padding: 10px;
  text-align: left;
}

.calendar-day:hover {
  background: #f8fffc;
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.18);
}

.calendar-day.today {
  background: #f0fdfa;
}

.calendar-day.muted-day {
  background: #fbfaf7;
  color: #9a948a;
}

.calendar-day-number {
  justify-self: end;
  font-weight: 800;
}

.calendar-add-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.16s ease, transform 0.16s ease, background 0.16s ease;
  z-index: 2;
}

.day-action-menu {
  position: fixed;
  z-index: 70;
  display: none;
  width: 240px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
  padding: 8px;
}

.day-action-menu.visible {
  display: grid;
}

.day-action-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  font-weight: 850;
  text-align: left;
  cursor: pointer;
}

.day-action-menu button:hover {
  background: var(--field-hover);
}

.day-action-menu span {
  color: var(--muted);
  font-size: 0.75rem;
}

.calendar-day:hover .calendar-add-button,
.calendar-day:focus-visible .calendar-add-button {
  opacity: 1;
  transform: translateY(0);
}

.calendar-events {
  display: grid;
  gap: 5px;
}

.calendar-event {
  display: block;
  overflow: hidden;
  border-left: 4px solid #38bdf8;
  background: #e0f2fe;
  color: #075985;
  padding: 5px 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
  border-radius: 3px;
  transition: filter 0.18s, box-shadow 0.18s, transform 0.18s;
}

.calendar-event:hover {
  filter: brightness(1.09);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
  transform: translateY(-1px);
}

.calendar-event.cal-dragging {
  opacity: 0.32;
  transform: none;
  box-shadow: none;
}

.calendar-event.status-completed {
  border-left-color: var(--teal);
  background: var(--mint);
  color: var(--teal-dark);
}

.calendar-event.status-cancelled {
  border-left-color: var(--coral);
  background: var(--rose);
  color: #8a2e1d;
  text-decoration: line-through;
}

.calendar-event.status-late_cancelled {
  border-left-color: #b7791f;
  background: #fef3c7;
  color: #92400e;
}

.calendar-event.status-draft {
  border-left-color: var(--muted);
  background: color-mix(in srgb, var(--raised) 88%, var(--surface));
  color: var(--text);
}

.appointment-client-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--mint);
  color: var(--teal-dark);
  padding: 10px 12px;
  font-weight: 750;
}

.appointment-client-card span {
  color: var(--muted);
  font-weight: 650;
}

.day-events-dialog {
  width: min(860px, 100%);
}

.workout-builder-dialog {
  width: min(960px, calc(100vw - 32px)) !important;
  max-height: 90vh !important;
  padding: 24px !important;
  align-content: start;
}

.workout-builder-dialog .workout-table-wrap {
  max-height: min(56vh, 620px);
  overflow: auto;
}

.workout-builder-dialog .builder-meta-grid {
  grid-template-columns: minmax(240px, 1fr) 140px !important;
}

.day-event-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.day-event-card:hover {
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.08);
  border-color: rgba(15, 118, 110, 0.25);
}

.appointment-modal {
  position: fixed;
  inset: 0;
  z-index: 1700;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(4px);
  padding: 24px;
}

.appointment-modal.visible {
  display: flex;
}

.appointment-dialog {
  position: relative;
  display: grid;
  gap: 14px;
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.28);
  padding: 34px;
}

.appointment-dialog h3 {
  font-size: clamp(1.8rem, 4vw, 2.4rem);
}

.progress-grid .wide-panel {
  grid-column: 1 / -1;
}

.chart-panel {
  min-width: 0;
}

.progress-log-column,
.progress-chart-column {
  display: grid;
  gap: 14px;
  align-content: start;
}

.progress-chart-column {
  min-width: 0;
}

.compact-log-panel {
  box-shadow: none;
}

.form-section-label {
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.progress-grid .chart-panel {
  grid-column: auto;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header select {
  max-width: 220px;
}

.builder-header {
  align-items: start;
}

.builder-status {
  width: fit-content;
  border-radius: 999px;
  background: var(--mint);
  color: var(--teal-dark);
  padding: 7px 11px;
  font-size: 0.82rem;
  font-weight: 850;
}

.builder-meta-grid {
  display: grid;
  grid-template-columns: 130px 110px minmax(180px, 1.1fr) minmax(180px, 1.1fr) minmax(180px, 1fr) 120px;
  gap: 10px;
}

.builder-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}

.compact-select {
  width: auto;
  min-height: 40px;
  padding-block: 8px;
}

.workout-files-header {
  align-items: start;
}

.workout-month-shell {
  display: grid;
  grid-template-columns: auto minmax(220px, 360px) auto;
  gap: 9px;
  align-items: center;
  width: fit-content;
  max-width: 100%;
}

.month-arrow {
  min-width: 42px;
  min-height: 46px;
  padding-inline: 10px;
  font-size: 1.2rem;
}

.current-month-card {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--mint);
  color: var(--teal-dark);
  padding: 9px 13px;
  font-weight: 850;
}

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

.two-col,
.three-col,
.four-col {
  display: grid;
  gap: 10px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.four-col {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.primary,
.ghost,
.danger,
.small-action {
  min-height: 40px;
  border-radius: 8px;
  padding: 9px 13px;
  font-weight: 800;
}

.primary {
  background: var(--teal);
  color: #fff;
}

.primary:hover {
  background: var(--teal-dark);
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.danger {
  background: #7f1d1d;
  color: #fff;
}

.small-action {
  min-height: 34px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.86rem;
}

.small-action.teal {
  border-color: rgba(15, 118, 110, 0.35);
  background: var(--mint);
  color: var(--teal-dark);
}

.small-action.coral {
  border-color: rgba(217, 93, 57, 0.35);
  background: var(--rose);
  color: #8a2e1d;
}

.small-action.danger {
  border-color: rgba(220, 38, 38, 0.35);
  background: rgba(127, 29, 29, 0.12);
  color: #dc2626;
}

.small-action.danger:hover {
  background: rgba(127, 29, 29, 0.22);
}

.icon-action {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--teal-dark);
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1;
}

.inline-check {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.inline-check input {
  width: 18px;
  height: 18px;
}

.stack {
  display: grid;
  gap: 10px;
}

.session-item,
.exercise-row,
.workout-file-card,
.portal-session,
.measurement-row,
.photo-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.session-item {
  display: grid;
  gap: 12px;
  padding: 14px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.session-item:hover {
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.07);
  border-color: rgba(15, 118, 110, 0.22);
}

.session-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-badge,
.type-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 850;
}

.status-scheduled {
  background: var(--mint);
  color: var(--teal-dark);
}

.status-completed {
  background: #e8f0ff;
  color: #1d4ed8;
}

.status-cancelled {
  background: var(--rose);
  color: #8a2e1d;
}

.status-late_cancelled {
  background: #fef3c7;
  color: #92400e;
}

.type-before {
  background: #ede9fe;
  color: #5b21b6;
}

.type-checkin {
  background: var(--mint);
  color: var(--teal-dark);
}

.type-after {
  background: #fff0cc;
  color: #8a5800;
}

.note {
  color: var(--muted);
  line-height: 1.5;
}

.program-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.exercise-list {
  display: grid;
  gap: 9px;
}

.exercise-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) repeat(4, minmax(74px, auto)) 36px;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.exercise-library-panel {
  min-height: 520px;
}

.exercise-database-list {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.exercise-library-panel > input[type="search"] {
  margin-bottom: 12px;
}

.exercise-database-table {
  display: grid;
  min-width: 760px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.exercise-database-header,
.exercise-data-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) 62px 74px 74px 86px minmax(130px, 0.8fr) minmax(150px, 1fr) 70px 40px;
  gap: 10px;
  align-items: center;
}

.exercise-database-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--mint);
  color: var(--teal-dark);
  padding: 10px 12px;
  font-size: 0.82rem;
  font-weight: 900;
}

.exercise-data-row {
  width: 100%;
  min-height: 66px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}

.exercise-data-row:hover {
  background: rgba(216, 244, 237, 0.38);
}

.exercise-data-row .exercise-name {
  display: grid;
  gap: 2px;
}

.exercise-data-row .exercise-name small,
.exercise-note-preview {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.exercise-note-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.form-actions .primary {
  flex: 1;
}

.builder-exercise-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 56px;
  position: relative;
}

.builder-exercise-control.no-video {
  grid-template-columns: minmax(0, 1fr);
}

.builder-exercise-control .builder-exercise-input {
  min-width: 0;
}

.builder-exercise-suggestions {
  position: fixed;
  z-index: 2400;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #232323;
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.46);
  padding: 6px;
}

.builder-exercise-suggestions button {
  width: 100%;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) minmax(92px, 0.75fr);
  align-items: center;
  gap: 10px;
  min-height: 66px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.builder-exercise-suggestions button:hover,
.builder-exercise-suggestions button:focus-visible,
.builder-exercise-suggestions button.active {
  background: rgba(255, 255, 255, 0.08);
}

.builder-exercise-suggestions .suggestion-thumb {
  width: 48px;
  height: 42px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  border-radius: 9px;
  background: color-mix(in srgb, var(--raised) 82%, transparent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}

.builder-exercise-suggestions .suggestion-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.builder-exercise-suggestions .suggestion-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.builder-exercise-suggestions strong {
  font-size: 0.92rem;
  line-height: 1.2;
}

.builder-exercise-suggestions small,
.builder-exercise-suggestions span {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.2;
}

.builder-exercise-suggestions .suggestion-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.builder-exercise-suggestions .suggestion-tags em {
  max-width: 86px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 3px 6px;
  color: #d1d5db;
  font-size: 0.68rem;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-chip {
  display: grid;
  place-items: center;
  width: 46px;
  height: 42px;
  margin-left: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--teal-dark);
  padding: 0;
  font-size: 0.7rem;
  font-weight: 900;
}

.video-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.library-video-chip,
.readonly-video-chip {
  margin-left: 0;
}

.readonly-exercise-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
}

.readonly-exercise-control.no-video {
  grid-template-columns: minmax(0, 1fr);
}

.workout-file-list {
  display: grid;
  gap: 12px;
}

.workout-file-card {
  display: grid;
  gap: 13px;
  padding: 14px;
}

.workout-file-details {
  display: grid;
  gap: 10px;
}

.workout-file-details summary {
  width: fit-content;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  cursor: pointer;
  padding: 7px 11px;
  font-size: 0.84rem;
  font-weight: 850;
}

.workout-file-details[open] summary {
  margin-bottom: 10px;
}

.workout-file-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.date-tile {
  display: grid;
  place-items: center;
  width: 58px;
  min-height: 58px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

.date-tile strong {
  font-size: 1.22rem;
  line-height: 1;
}

.date-tile span {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.78);
}

.workout-exercise-row {
  grid-template-columns: 34px minmax(160px, 1fr) repeat(4, minmax(74px, auto));
}

.exercise-order {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 850;
}

.workout-meta-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.workout-meta-strip > * {
  min-height: 44px;
  display: grid;
  place-items: center;
  padding: 10px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.workout-meta-strip > *:last-child {
  border-right: 0;
}

.workout-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.workout-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
}

.workout-table th,
.workout-table td {
  border: 1px solid #1f2933;
  padding: 0;
  text-align: center;
  vertical-align: middle;
}

.workout-table th {
  height: 34px;
  color: #080808;
  font-size: 0.92rem;
  font-weight: 900;
}

.workout-table th:nth-child(1) {
  width: 42px;
  background: #f3f4f6;
}

.editable-workout-table th:nth-child(2),
.readonly-workout-table:not(.editable-workout-table) th:nth-child(1) {
  width: 250px;
  background: #e99195;
}

.editable-workout-table th:nth-child(3),
.editable-workout-table th:nth-child(4),
.readonly-workout-table:not(.editable-workout-table) th:nth-child(2),
.readonly-workout-table:not(.editable-workout-table) th:nth-child(3) {
  width: 74px;
  background: #f3d17b;
}

.editable-workout-table th:nth-child(5),
.readonly-workout-table:not(.editable-workout-table) th:nth-child(4) {
  width: 78px;
  background: #93c47d;
}

.editable-workout-table th:nth-child(6),
.readonly-workout-table:not(.editable-workout-table) th:nth-child(5) {
  width: 118px;
  background: #a8c7ce;
}

.editable-workout-table th:nth-child(7),
.readonly-workout-table:not(.editable-workout-table) th:nth-child(6) {
  width: 220px;
  background: #f2ad63;
}

.editable-workout-table th:nth-child(n + 8),
.readonly-workout-table:not(.editable-workout-table) th:nth-child(n + 7) {
  width: 130px;
  background: #c6d9f1;
}

/* Builder tables never scroll — override the default 1120px min-width */
.workout-builder-table {
  min-width: 0;
}

.workout-builder-table th:nth-child(1) {
  width: 26px;
  padding: 0;
  background: transparent;
}

.workout-builder-table th:nth-child(2) {
  width: 250px;
  background: #e99195;
}

.workout-builder-table th:nth-child(3),
.workout-builder-table th:nth-child(4) {
  width: 74px;
  background: #f3d17b;
}

.workout-builder-table th:nth-child(5) {
  width: 78px;
  background: #93c47d;
}

.workout-builder-table th:nth-child(6) {
  width: 118px;
  background: #a8c7ce;
}

.workout-builder-table th:nth-child(7) {
  width: 220px;
  background: #f2ad63;
}

.workout-builder-table th:nth-child(n + 8) {
  width: 130px;
  background: #c6d9f1;
}

.workout-table td {
  height: 58px;
  background: #fff;
}

.workout-table input,
.workout-table textarea {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  text-align: center;
}

.workout-table textarea {
  display: block;
  padding-top: 10px;
  text-align: center;
}

.workout-table .exercise-cell input,
.workout-table .exercise-name-cell {
  font-weight: 850;
}

.workout-table .set-cell,
.workout-table .set-result-cell {
  background: #ff9708;
}

.workout-table .set-cell input {
  font-weight: 800;
}

.workout-table tr.selected-row td {
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.42);
}

.workout-builder-table tr.dragging-row td {
  opacity: 0.55;
}

.workout-builder-table tbody tr[data-kind="exercise"] {
  cursor: grab;
}

.builder-row-dragging {
  cursor: grabbing;
  user-select: none;
}

.workout-builder-table tr.drop-target-row td {
  box-shadow: inset 0 3px 0 var(--teal), inset 0 0 0 2px rgba(15, 118, 110, 0.18);
}

.workout-builder-table tr.drop-after-row td {
  box-shadow: inset 0 -3px 0 var(--teal), inset 0 0 0 2px rgba(15, 118, 110, 0.18);
}

.workout-section-row td {
  height: 48px;
  padding: 0 14px;
  background: #e5e7eb;
  color: #111827;
  font-weight: 950;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0;
}

.workout-section-row .delete-col {
  text-align: center;
}

.workout-section-row.section-warmup td {
  background: #e5e7eb;
  color: #111827;
}

.workout-section-row.section-main td {
  background: #d1d5db;
  color: #111827;
}

.workout-section-row.section-cooldown td {
  background: #e5e7eb;
  color: #111827;
}

.workout-section-row input.section-title-input {
  min-height: 46px;
  padding: 0;
  color: inherit;
  font-weight: 950;
  text-align: left;
  text-transform: uppercase;
}

.readonly-workout-table td {
  padding: 12px 10px;
}

.readonly-workout-table .set-result-cell {
  font-weight: 800;
}

.delete-col {
  width: 42px;
}

.builder-context-menu {
  position: fixed;
  z-index: 2000;
  display: none;
  width: 170px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.18);
}

.builder-context-menu.visible {
  display: block;
}

.builder-context-menu button {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-size: 0.9rem;
  font-weight: 850;
}

.builder-context-menu button:hover:not(:disabled) {
  background: var(--mint);
  color: var(--teal-dark);
}

.builder-context-menu button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.context-menu-divider {
  height: 1px;
  background: var(--line);
  margin: 2px 0;
}

.builder-context-menu [hidden] {
  display: none !important;
}

.builder-context-menu .context-menu-danger {
  color: #e03e3e;
}

.builder-context-menu .context-menu-danger:hover:not(:disabled) {
  background: #fff0f0;
  color: #b91c1c;
}

.nutrition-result-panel {
  align-self: stretch;
}

.nutrition-result {
  display: grid;
  gap: 14px;
}

.nutrition-hero {
  display: grid;
  gap: 4px;
  min-height: 160px;
  align-content: center;
  border: 1px solid rgba(20, 109, 100, 0.22);
  border-radius: 8px;
  background: var(--mint);
  color: var(--teal-dark);
  padding: 22px;
}

.nutrition-hero span,
.nutrition-hero small,
.nutrition-metrics span {
  color: var(--muted);
  font-weight: 800;
}

.nutrition-hero strong {
  color: var(--teal-dark);
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.95;
}

.nutrition-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 10px;
}

.nutrition-metrics div {
  display: grid;
  gap: 4px;
  min-height: 82px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.nutrition-metrics strong {
  font-size: 1.35rem;
}

.icon-action {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--rose);
  color: #8a2e1d;
  font-weight: 900;
}

.exercise-name strong {
  display: block;
}

.exercise-name span,
.exercise-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.chart-panel canvas {
  width: 100%;
  max-width: 100%;
  height: 310px;
}

.chart-panel:has(#circumferenceChart) canvas {
  height: 340px;
}

.split-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.progress-grid .chart-panel:last-of-type canvas {
  height: 280px;
}

.infographic-chart {
  background: #fbf7f9;
  box-shadow: none;
}

.table-like {
  display: grid;
  gap: 8px;
}

.measurement-row {
  display: grid;
  grid-template-columns: 120px repeat(6, minmax(80px, 1fr)) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
}

.strength-log-row {
  grid-template-columns: 120px minmax(180px, 1.5fr) repeat(4, minmax(80px, 1fr)) auto;
}

.chart-point-menu {
  position: fixed;
  z-index: 2200;
  display: none;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 5px;
}

.chart-point-menu.visible {
  display: flex;
}

.chart-point-menu button {
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  font-weight: 800;
}

.chart-point-menu button:hover {
  background: var(--mint);
}

.measurement-row span {
  color: var(--muted);
  font-size: 0.84rem;
}

.photo-gallery {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.comparison-row {
  display: grid;
  gap: 10px;
}

.comparison-row h4 {
  font-size: 1.05rem;
}

.comparison-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.photo-slot {
  display: grid;
  gap: 8px;
}

.photo-slot-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

.photo-frame {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  cursor: grab;
}

.photo-frame img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.photo-empty {
  display: grid;
  place-items: center;
  min-height: 420px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 750;
}

.photo-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.photo-controls input {
  padding: 0;
}

.photo-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.portal-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.portal-session {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.portal-program {
  display: grid;
  gap: 9px;
  margin-top: 13px;
}

.portal-program-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.32fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-top: 14px;
}

.portal-assigned-list {
  display: grid;
  gap: 9px;
}

.portal-assigned-item {
  display: grid;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.portal-assigned-item.active {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.portal-program-detail,
.session-feedback-form,
.session-feedback-box {
  display: grid;
  gap: 10px;
}

.session-feedback-form textarea {
  width: 100%;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.exercise-video-modal {
  position: fixed;
  inset: 0;
  z-index: 1800;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.72);
  padding: 28px;
}

.exercise-video-modal.visible {
  display: flex;
}

.exercise-video-dialog {
  position: relative;
  width: min(1180px, 100%);
  max-height: min(760px, calc(100vh - 56px));
  overflow: auto;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.34);
  padding: 28px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 2rem;
  line-height: 1;
}

.exercise-video-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.7fr);
  gap: 28px;
  align-items: start;
}

.exercise-video-pane {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #050505;
}

.exercise-video-pane iframe,
.exercise-video-pane video,
.exercise-video-pane img {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  background: #000;
  object-fit: contain;
}

.exercise-video-info {
  display: grid;
  gap: 18px;
  padding-right: 18px;
}

.exercise-video-info h3 {
  font-size: clamp(1.7rem, 3vw, 2.35rem);
}

.preview-meta-list {
  display: grid;
  gap: 8px;
}

.preview-meta-list p {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.preview-meta-list strong {
  color: var(--ink);
}

.preview-meta-list span {
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-list span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 6px 9px;
  font-size: 0.9rem;
  font-weight: 800;
}

.instruction-block {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.instruction-block p {
  color: var(--muted);
  line-height: 1.5;
}

.add-client-form {
  margin-top: 10px;
}

.client-management-form {
  gap: 18px;
}

.client-form-modal {
  z-index: 2100;
}

.client-form-dialog {
  width: min(920px, calc(100vw - 48px));
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 22px;
}

.client-info-summary {
  display: grid;
  gap: 18px;
}

.client-info-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
}

.client-profile-lockup {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.client-profile-avatar {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  border-radius: 18px;
  background: var(--primary-bg);
  color: var(--primary-fg, var(--bg));
  font-size: 1.2rem;
  font-weight: 950;
}

.client-info-hero h3 {
  margin: 2px 0 8px;
  font-size: clamp(1.8rem, 3vw, 2.65rem);
}

.client-inline-badges,
.client-info-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.client-inline-badges span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--field);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 900;
}

.client-inline-badges .status-pending_invite,
.client-inline-badges .status-active,
.client-inline-badges .status-archived {
  border-color: transparent;
}

.client-info-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.client-info-card {
  align-content: start;
  min-height: 220px;
  padding: 22px;
}

.client-detail-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.client-detail-list div {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.client-detail-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.client-detail-list dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.client-detail-list dd {
  margin: 0;
  color: var(--text);
  font-weight: 850;
  text-align: right;
  overflow-wrap: anywhere;
}

.client-metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.client-metric-tile {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--field);
  padding: 14px;
}

.client-metric-tile span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
}

.client-metric-tile strong {
  color: var(--text);
  font-size: 1.35rem;
}

.client-note-text {
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-wrap;
}

.client-form-section {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--field) 56%, transparent);
  padding: 16px;
}

.client-form-section h4 {
  font-size: 0.98rem;
}

.segmented-choice {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.segmented-choice label {
  display: block;
}

.segmented-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.segmented-choice span {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 900;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.segmented-choice input:checked + span {
  border-color: color-mix(in srgb, var(--primary-bg) 42%, var(--line));
  background: var(--primary-bg);
  color: var(--primary-fg, var(--bg));
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 10px 12px;
}

.toggle-row input {
  width: 42px;
  height: 22px;
  accent-color: var(--primary-bg);
}

.client-auth-status.status-pending_invite,
.client-card-badges em.status-pending_invite {
  background: rgba(217, 164, 65, 0.16);
  color: #d6a24a;
}

.client-auth-status.status-active,
.client-card-badges em.status-active {
  background: rgba(74, 222, 128, 0.14);
  color: #86efac;
}

.client-auth-status.status-archived,
.client-card-badges em.status-archived {
  background: rgba(156, 163, 175, 0.14);
  color: var(--muted);
}

.client-card-badges {
  display: flex !important;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px !important;
}

.client-card-badges em {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--field-hover) 72%, transparent);
  color: var(--muted);
  padding: 2px 6px;
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .library-grid,
  .clients-grid,
  .nutrition-grid,
  .progress-grid {
    grid-template-columns: 1fr 1fr;
  }

  .library-grid .wide-panel,
  .progress-grid .wide-panel,
  .progress-grid .chart-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .portal-program-layout {
    grid-template-columns: 1fr;
  }

  .topbar-actions button {
    flex: 1;
  }

  .client-switcher {
    min-width: 100%;
  }

  .auth-panel,
  .auth-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .auth-actions {
    justify-content: stretch;
  }

  .auth-actions button {
    flex: 1;
  }

  .schedule-grid,
  .calendar-layout,
  .photos-grid,
  .portal-grid,
  .program-grid,
  .library-grid,
  .nutrition-grid,
  .progress-grid,
  .split-chart-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .nutrition-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-col,
  .three-col,
  .four-col,
  .builder-meta-grid,
  .workout-month-shell,
  .workout-meta-strip,
  .exercise-row,
  .measurement-row,
  .portal-hero,
  .workout-file-header {
    grid-template-columns: 1fr;
  }

  .calendar-panel {
    overflow-x: auto;
  }

  .calendar-weekdays,
  .calendar-grid {
    min-width: 760px;
  }

  .appointment-dialog {
    padding: 24px;
  }

  .panel-header,
  .session-main {
    display: grid;
  }

  .exercise-video-layout {
    grid-template-columns: 1fr;
  }

  .exercise-video-pane {
    min-height: 240px;
  }

  .workout-meta-strip > * {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workout-meta-strip > *:last-child {
    border-bottom: 0;
  }
}

@media (max-width: 520px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .nutrition-metrics {
    grid-template-columns: 1fr;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1 1 130px;
  }
}

/* Premium dark visual system */
.tab[data-view="portal"] {
  display: none;
}

.client-mode .tab[data-view="portal"] {
  display: inline-flex;
}

::selection {
  background: rgba(245, 245, 245, 0.16);
  color: var(--ink);
}

body,
.workspace {
  background-color: var(--bg);
}

.sidebar,
.tabs,
.auth-card,
.auth-panel,
.stat,
.panel,
.calendar-weekdays,
.calendar-grid,
.calendar-day,
.day-event-card,
.appointment-dialog,
.exercise-video-dialog,
.workout-table-wrap,
.workout-meta-strip,
.nutrition-metrics div,
.exercise-database-table,
.exercise-data-row,
.workout-file-card,
.portal-session,
.portal-assigned-item,
.session-item,
.exercise-row,
.measurement-row,
.photo-card,
.builder-context-menu,
.chart-point-menu,
.empty-state {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.tabs {
  background: rgba(17, 17, 17, 0.86);
  border-color: #333333;
}

.tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.tab:hover {
  background: #202020;
  color: var(--ink);
}

.tab.active {
  background: #f5f5f5;
  color: #111111;
}

.topbar,
.section-heading,
.calendar-toolbar,
.panel-header {
  color: var(--ink);
}

.eyebrow {
  color: #a1a1aa;
  letter-spacing: 0.12em;
}

.muted,
.brand p,
.section-heading p,
.auth-panel span,
.calendar-stats span,
.calendar-legend,
.note,
.exercise-meta,
.exercise-name span,
.measurement-row span,
.photo-meta,
.photo-slot-label,
.instruction-block p,
.auth-message,
label {
  color: var(--muted);
}

.auth-panel {
  background: linear-gradient(180deg, #1d1d1d, #171717);
}

.auth-status,
.builder-status,
.current-month-card,
.appointment-client-card,
.session-pill,
.exercise-order,
.status-scheduled,
.type-checkin {
  background: rgba(74, 222, 128, 0.12);
  color: #86efac !important;
  border-color: rgba(74, 222, 128, 0.22);
}

.brand-mark,
.date-tile,
.toast {
  background: #f5f5f5;
  color: #111111;
}

.client-card,
.workout-file-details summary,
.small-action,
.ghost,
.icon-action,
.video-chip,
.tag-list span,
.chart-point-menu button,
.builder-context-menu button {
  border-color: var(--line);
  background: #171717;
  color: var(--ink);
}

.client-card:hover,
.exercise-data-row:hover,
.portal-assigned-item:hover,
.ghost:hover,
.small-action:hover,
.workout-file-details summary:hover,
.builder-context-menu button:hover:not(:disabled),
.chart-point-menu button:hover {
  background: #242424;
  color: var(--ink);
}

.client-card.active,
.portal-assigned-item.active {
  border-color: #525252;
  background: #232323;
}

.client-avatar {
  background: #2e2e2e;
  color: var(--ink);
}

.primary {
  background: #f5f5f5;
  color: #111111;
}

.primary:hover {
  background: #d4d4d8;
}

.danger,
.small-action.coral,
.status-cancelled {
  background: rgba(217, 119, 87, 0.14);
  color: #fca5a5;
  border-color: rgba(217, 119, 87, 0.28);
}

.status-completed {
  background: rgba(74, 222, 128, 0.12);
  color: #86efac;
}

.status-late_cancelled,
.type-after {
  background: rgba(214, 162, 74, 0.14);
  color: #f2c879;
}

.type-before {
  background: rgba(125, 211, 252, 0.12);
  color: #93c5fd;
}

.calendar-weekdays {
  background: #181818;
}

.calendar-weekdays span {
  color: var(--muted);
}

.calendar-grid {
  background: #151515;
}

.calendar-day {
  background: #151515;
  color: var(--ink);
}

.calendar-day:hover {
  background: #1f1f1f;
  box-shadow: inset 0 0 0 1px #3f3f46;
}

.calendar-day.today {
  background: #1f2937;
}

.calendar-day.muted-day {
  background: #111111;
  color: #52525b;
}

.calendar-event {
  border-left-color: #60a5fa;
  background: rgba(96, 165, 250, 0.14);
  color: #bfdbfe;
}

.calendar-event.status-completed {
  border-left-color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
  color: #bbf7d0;
}

.calendar-event.status-cancelled {
  border-left-color: #d97757;
  background: rgba(217, 119, 87, 0.14);
  color: #fecaca;
}

.calendar-event.status-late_cancelled {
  border-left-color: #d6a24a;
  background: rgba(214, 162, 74, 0.14);
  color: #fde68a;
}

.legend-dot.scheduled {
  background: #60a5fa;
}

.legend-dot.completed {
  background: #4ade80;
}

.legend-dot.cancelled {
  background: #d97757;
}

.auth-card,
.appointment-dialog,
.exercise-video-dialog {
  background: #1b1b1b;
}

.appointment-modal,
.exercise-video-modal {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
}

.exercise-video-pane,
.photo-frame,
.photo-empty,
.infographic-chart,
.nutrition-hero {
  background: #151515;
  border-color: var(--line);
  color: var(--ink);
}

.nutrition-hero {
  background: linear-gradient(180deg, #232323, #191919);
}

.nutrition-hero strong,
.nutrition-hero span,
.nutrition-hero small {
  color: var(--ink);
}

.workout-table-wrap,
.workout-table td,
.workout-table input,
.workout-table textarea,
.workout-meta-strip {
  background: #151515;
  color: var(--ink);
}

.workout-table th,
.workout-table td {
  border-color: #333333;
}

.workout-table th,
.workout-builder-table th:nth-child(n),
.editable-workout-table th:nth-child(n),
.readonly-workout-table:not(.editable-workout-table) th:nth-child(n) {
  background: #232323;
  color: #f5f5f5;
}

.workout-table th:nth-child(1) {
  background: #181818;
}

.workout-table .set-cell,
.workout-table .set-result-cell {
  background: rgba(214, 162, 74, 0.14);
}

.workout-section-row td,
.workout-section-row.section-warmup td,
.workout-section-row.section-main td,
.workout-section-row.section-cooldown td {
  background: #2a2a2a;
  color: #f5f5f5;
}

.workout-table tr.selected-row td {
  box-shadow: inset 0 0 0 2px rgba(245, 245, 245, 0.36);
}

.workout-builder-table tr.drop-target-row td {
  box-shadow: inset 0 3px 0 #f5f5f5, inset 0 0 0 1px rgba(245, 245, 245, 0.2);
}

.workout-builder-table tr.drop-after-row td {
  box-shadow: inset 0 -3px 0 #f5f5f5, inset 0 0 0 1px rgba(245, 245, 245, 0.2);
}

.exercise-database-header {
  background: #232323;
  color: var(--ink);
}

.exercise-data-row {
  background: #171717;
}

.empty-state {
  background: rgba(255, 255, 255, 0.03);
}

.chart-panel canvas {
  filter: saturate(0.82) contrast(1.04);
}

@media (max-width: 860px) {
  .tabs {
    position: sticky;
    top: 0;
    width: 100%;
  }
}

/* Premium hierarchy refinement */
:root {
  --bg: #101010;
  --surface: #191919;
  --elevated: #202020;
  --raised: #242424;
  --field: #121212;
  --field-hover: #171717;
  --line: #2e2e2e;
  --line-soft: rgba(255, 255, 255, 0.075);
  --line-strong: #3a3a3a;
  --ink: #f5f5f5;
  --muted: #a1a1aa;
  --subtle: #71717a;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 12px 30px rgba(0, 0, 0, 0.22);
  --blue-muted: #7aa2d6;
  --green-muted: #83c59b;
  --amber-muted: #d0a45f;
}

body {
  background:
    radial-gradient(circle at 18% -8%, rgba(255, 255, 255, 0.045), transparent 34rem),
    radial-gradient(circle at 84% 6%, rgba(122, 162, 214, 0.045), transparent 30rem),
    linear-gradient(180deg, #111111 0%, #0f0f0f 45%, #101010 100%);
}

input,
select,
textarea {
  border-color: var(--line);
  background: var(--field);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
  background: var(--field-hover);
}

input:focus,
select:focus,
textarea:focus {
  border-color: #5a5a5a;
  background: #151515;
  box-shadow: 0 0 0 3px rgba(245, 245, 245, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

::placeholder {
  color: #66666d;
}

.tabs {
  gap: 4px;
  padding: 5px;
  border-color: var(--line);
  background: rgba(24, 24, 24, 0.88);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tab {
  color: #a3a3aa;
  border: 1px solid transparent;
  transition:
    color 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.tab:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.04);
}

.tab.active {
  background: #f5f5f5;
  color: #111111;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.24);
}

.panel,
.stat,
.auth-panel,
.calendar-panel,
.schedule-list-panel,
.chart-panel,
.photo-card,
.portal-session,
.portal-program-detail,
.appointment-dialog,
.exercise-video-dialog,
.auth-card,
.day-event-card {
  border-color: var(--line);
  background: linear-gradient(180deg, #1d1d1d 0%, #181818 100%);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.panel:hover,
.stat:hover {
  border-color: #343434;
}

.stat {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 42%),
    #1a1a1a;
}

.stat span,
label,
.section-heading p,
.muted {
  color: var(--muted);
}

.auth-panel {
  border-color: rgba(255, 255, 255, 0.09);
}

.auth-status,
.session-pill,
.small-action.teal,
.status-completed {
  background: rgba(131, 197, 155, 0.13);
  color: #a7f3c2 !important;
  border-color: rgba(131, 197, 155, 0.2);
}

.primary {
  background: #f5f5f5;
  color: #111111;
  border: 1px solid #f5f5f5;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
}

.primary:hover {
  background: #e4e4e7;
  border-color: #e4e4e7;
  transform: translateY(-1px);
}

.ghost,
.small-action,
.danger {
  border: 1px solid var(--line);
  background: #191919;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.ghost:hover,
.small-action:hover {
  border-color: #454545;
  background: #222222;
  color: #ffffff;
  transform: translateY(-1px);
}

.danger,
.small-action.coral,
.status-cancelled {
  background: rgba(217, 119, 87, 0.13);
  color: #efb0a0;
  border-color: rgba(217, 119, 87, 0.24);
}

.status-late_cancelled,
.type-after {
  background: rgba(208, 164, 95, 0.14);
  color: #e7c98d;
  border-color: rgba(208, 164, 95, 0.22);
}

.type-before,
.calendar-event {
  background: rgba(122, 162, 214, 0.13);
  color: #b8cff0;
  border-color: rgba(122, 162, 214, 0.2);
}

.workout-table-wrap,
.exercise-database-table {
  border-color: var(--line);
  background: #141414;
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.workout-table {
  background: #141414;
}

.workout-table th,
.workout-builder-table th:nth-child(n),
.editable-workout-table th:nth-child(n),
.readonly-workout-table:not(.editable-workout-table) th:nth-child(n),
.exercise-database-header {
  background: #202020;
  color: #f5f5f5;
  border-color: #343434;
  text-transform: none;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.035);
}

.workout-table th:nth-child(1),
.workout-builder-table th:nth-child(2),
.editable-workout-table th:nth-child(2),
.readonly-workout-table:not(.editable-workout-table) th:nth-child(1) {
  background: #242424;
}

.workout-builder-table th:nth-child(1) {
  background: transparent;
  width: 26px;
  padding: 0;
}

.workout-table th:nth-child(n + 7),
.workout-builder-table th:nth-child(n + 8),
.editable-workout-table th:nth-child(n + 8),
.readonly-workout-table:not(.editable-workout-table) th:nth-child(n + 7) {
  background: #202326;
  color: #d7e2f2;
}

.workout-table td {
  border-color: #303030;
  background: #151515;
}

.workout-builder-table tbody tr[data-kind="exercise"]:nth-of-type(odd) td,
.editable-workout-table tbody tr:not(.workout-section-row):nth-of-type(odd) td,
.readonly-workout-table tbody tr:not(.workout-section-row):nth-of-type(odd) td,
.exercise-data-row:nth-child(odd) {
  background: #171717;
}

.workout-builder-table tbody tr[data-kind="exercise"]:nth-of-type(even) td,
.editable-workout-table tbody tr:not(.workout-section-row):nth-of-type(even) td,
.readonly-workout-table tbody tr:not(.workout-section-row):nth-of-type(even) td,
.exercise-data-row:nth-child(even) {
  background: #141414;
}

.workout-builder-table tbody tr[data-kind="exercise"]:hover td,
.editable-workout-table tbody tr:not(.workout-section-row):hover td,
.readonly-workout-table tbody tr:not(.workout-section-row):hover td,
.exercise-data-row:hover {
  background: #1f1f1f;
}

.workout-section-row td,
.workout-section-row.section-warmup td,
.workout-section-row.section-main td,
.workout-section-row.section-cooldown td {
  background: #272727 !important;
  color: #f5f5f5;
  border-color: #3a3a3a;
  box-shadow: inset 3px 0 0 #5a5a5a;
}

.workout-section-row.section-main td {
  box-shadow: inset 3px 0 0 var(--blue-muted);
}

.workout-section-row.section-warmup td {
  box-shadow: inset 3px 0 0 var(--green-muted);
}

.workout-section-row.section-cooldown td {
  box-shadow: inset 3px 0 0 var(--amber-muted);
}

.workout-table input,
.workout-table textarea {
  background: transparent;
  color: var(--ink);
}

.workout-table input:hover,
.workout-table textarea:hover,
.workout-table input:focus,
.workout-table textarea:focus {
  background: rgba(255, 255, 255, 0.035);
}

.workout-table .set-cell,
.workout-table .set-result-cell {
  background: rgba(208, 164, 95, 0.1) !important;
}

.workout-table tr.selected-row td {
  box-shadow: inset 0 0 0 2px rgba(245, 245, 245, 0.25);
}

.builder-exercise-suggestions {
  border-color: #3a3a3a;
  background: #202020;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.builder-exercise-suggestions button:hover,
.builder-exercise-suggestions button:focus-visible {
  background: #2a2a2a;
}

.exercise-data-row {
  border-top-color: #2f2f2f;
  color: var(--ink);
}

.exercise-data-row .exercise-name small,
.exercise-note-preview {
  color: var(--muted);
}

.calendar-weekdays,
.calendar-grid,
.calendar-day {
  border-color: var(--line);
}

.calendar-weekdays {
  background: #202020;
}

.calendar-grid,
.calendar-day {
  background: #141414;
}

.calendar-day:nth-child(odd) {
  background: #151515;
}

.calendar-day:hover {
  background: #202020;
  box-shadow: inset 0 0 0 1px #404040;
}

.calendar-day.today {
  background: #1b2228;
}

.calendar-event {
  border-left-color: var(--blue-muted);
}

.calendar-event.status-completed {
  border-left-color: var(--green-muted);
  background: rgba(131, 197, 155, 0.12);
  color: #c3efd1;
}

.calendar-event.status-cancelled {
  border-left-color: #d97757;
  background: rgba(217, 119, 87, 0.12);
  color: #efb0a0;
}

.photo-frame,
.photo-empty,
.infographic-chart,
.nutrition-hero {
  background: #141414;
  border-color: var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

table,
.exercise-database-table,
.workout-table-wrap {
  border-radius: 10px;
}

button,
.tab,
.client-card,
.exercise-data-row,
.calendar-day {
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

/* Product polish: quiet background sync status */
.developer-action {
  display: none !important;
}

.local-demo-mode .developer-action {
  display: inline-flex !important;
}

.auth-panel:empty {
  display: none;
}

.auth-panel {
  justify-content: flex-end;
  margin: -6px 0 16px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.sync-indicator {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  width: max-content;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted) !important;
  font-size: 0.75rem !important;
  font-weight: 800 !important;
  letter-spacing: 0;
}

.sync-indicator i {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.sync-indicator.synced {
  border-color: rgba(131, 197, 155, 0.18);
  background: rgba(131, 197, 155, 0.08);
  color: #8fd6a8 !important;
}

.sync-indicator.syncing {
  border-color: rgba(108, 154, 203, 0.22);
  background: rgba(108, 154, 203, 0.1);
  color: #9dbce0 !important;
}

.sync-indicator.offline {
  border-color: rgba(217, 119, 87, 0.2);
  background: rgba(217, 119, 87, 0.08);
  color: #d99a82 !important;
}

#developerToolsPanel[hidden] {
  display: none;
}

/* Nutrition roadmap: premium coaching system */
.nutrition-grid {
  grid-template-columns: minmax(280px, 0.32fr) minmax(0, 1fr);
  align-items: start;
}

.nutrition-result-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.01)),
    var(--surface);
}

.nutrition-result {
  gap: 18px;
}

.nutrition-overview {
  display: grid;
  grid-template-columns: minmax(220px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
}

.nutrition-hero {
  min-height: 190px;
  border-color: rgba(131, 197, 155, 0.22);
  background:
    radial-gradient(circle at 86% 18%, rgba(131, 197, 155, 0.14), transparent 34%),
    linear-gradient(145deg, #202020, #151515);
  color: var(--ink);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.045);
}

.nutrition-hero strong {
  color: var(--ink);
  letter-spacing: -0.04em;
}

.nutrition-strategy-card,
.nutrition-block,
.meal-card,
.nutrition-framework-grid article {
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.032), rgba(255, 255, 255, 0.008)),
    #171717;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.nutrition-strategy-card {
  display: grid;
  gap: 12px;
  min-height: 190px;
  align-content: center;
  padding: 18px;
}

.nutrition-strategy-card h4 {
  color: var(--ink);
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  text-transform: capitalize;
}

.nutrition-strategy-card p,
.meal-card p {
  color: var(--muted);
  line-height: 1.45;
}

.nutrition-progress-bars {
  display: grid;
  gap: 9px;
}

.nutrition-progress-bars span {
  position: relative;
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.nutrition-progress-bars span::before,
.nutrition-progress-bars span::after {
  content: "";
  display: block;
  height: 5px;
  border-radius: 999px;
}

.nutrition-progress-bars span::before {
  background: #2a2a2a;
}

.nutrition-progress-bars span::after {
  position: absolute;
  left: 0;
  bottom: 0;
  width: var(--value, 70%);
  background: linear-gradient(90deg, rgba(131, 197, 155, 0.78), rgba(108, 154, 203, 0.72));
}

.nutrition-metrics {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.nutrition-metrics div {
  border-color: var(--line);
  background: #151515;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.nutrition-metrics strong {
  color: var(--ink);
}

.nutrition-block {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.nutrition-block > h4,
.nutrition-block .panel-header h4 {
  color: var(--ink);
}

.nutrition-roadmap {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.nutrition-phase-card {
  display: grid;
  gap: 9px;
  min-height: 230px;
  padding: 16px;
  border: 1px solid #333;
  border-radius: 12px;
  background:
    radial-gradient(circle at 100% 0%, rgba(108, 154, 203, 0.08), transparent 36%),
    #151515;
}

.nutrition-phase-card span,
.nutrition-framework-grid article > span,
.meal-card span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
}

.nutrition-phase-card h4 {
  color: var(--ink);
  font-size: 1.15rem;
}

.nutrition-phase-card strong {
  color: #cfe6d7;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
}

.nutrition-phase-card p {
  color: var(--muted);
  line-height: 1.4;
}

.nutrition-chip-list,
.nutrition-framework-grid article div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.nutrition-chip-list span,
.nutrition-framework-grid article div span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border: 1px solid #343434;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: #d7d7d7;
  font-size: 0.78rem;
  font-weight: 800;
}

.nutrition-framework-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.nutrition-framework-grid article {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.nutrition-framework-grid article.wide {
  grid-column: 1 / -1;
}

.meal-structure-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.meal-card {
  overflow: hidden;
}

.meal-image {
  min-height: 86px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 30% 35%, rgba(131, 197, 155, 0.18), transparent 28%),
    radial-gradient(circle at 80% 10%, rgba(108, 154, 203, 0.12), transparent 30%),
    linear-gradient(135deg, #242424, #141414);
}

.meal-card > div:not(.meal-image) {
  display: grid;
  gap: 7px;
  padding: 13px;
}

.meal-card strong {
  color: var(--ink);
  font-size: 1.15rem;
}

.meal-card small {
  color: #b8c7d9;
  font-weight: 850;
}

@media (max-width: 1180px) {
  .nutrition-grid,
  .nutrition-overview {
    grid-template-columns: 1fr;
  }

  .meal-structure-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .nutrition-roadmap,
  .nutrition-framework-grid,
  .meal-structure-grid,
  .nutrition-metrics {
    grid-template-columns: 1fr;
  }
}

/* Modern SaaS shell with light/dark theme support */
:root {
  --sidebar-width: 276px;
  --sidebar-collapsed-width: 82px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --app-transition: 180ms ease;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f7f7f4;
  --surface: #ffffff;
  --elevated: #ffffff;
  --raised: #f5f5f2;
  --field: #ffffff;
  --field-hover: #fafafa;
  --ink: #111111;
  --muted: #666a70;
  --subtle: #8b8f96;
  --line: #e4e4df;
  --line-strong: #d4d4cc;
  --shadow: 0 18px 48px rgba(15, 15, 15, 0.08);
  --sidebar-bg: #0b0b0c;
  --sidebar-elevated: #171719;
  --sidebar-line: #26262a;
  --sidebar-text: #f5f5f5;
  --sidebar-muted: #9ca3af;
  --primary-bg: #111111;
  --primary-text: #ffffff;
  --ghost-bg: #ffffff;
  --accent-blue: #5f8fc7;
  --accent-green: #5e9f76;
  --accent-amber: #b98945;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111214;
  --surface: #1a1b1f;
  --elevated: #212227;
  --raised: #28292f;
  --field: #15161a;
  --field-hover: #1d1e23;
  --ink: #f5f5f5;
  --muted: #a1a1aa;
  --subtle: #71717a;
  --line: #303137;
  --line-strong: #42434a;
  --shadow: 0 22px 56px rgba(0, 0, 0, 0.38);
  --sidebar-bg: #f4f4f5;
  --sidebar-elevated: #ffffff;
  --sidebar-line: #e2e2e5;
  --sidebar-text: #0b0b0c;
  --sidebar-muted: #5d626b;
  --primary-bg: #f5f5f5;
  --primary-text: #111214;
  --ghost-bg: #1a1b1f;
  --accent-blue: #7fa6d8;
  --accent-green: #83c59b;
  --accent-amber: #d0a45f;
}

html,
body,
.app-shell,
.workspace,
.sidebar,
.panel,
.stat,
.tabs,
.tab,
input,
select,
textarea,
button {
  transition:
    background-color var(--app-transition),
    color var(--app-transition),
    border-color var(--app-transition),
    box-shadow var(--app-transition),
    opacity var(--app-transition);
}

body {
  background: var(--bg) !important;
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1000;
  display: flex !important;
  width: var(--sidebar-width);
  height: 100vh;
  flex-direction: column;
  overflow: hidden;
  padding: 18px 14px;
  border-right: 1px solid var(--sidebar-line);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  box-shadow: 18px 0 42px rgba(0, 0, 0, 0.12);
}

.client-mode .sidebar {
  display: flex !important;
}

.workspace,
.client-mode .workspace {
  width: auto;
  max-width: none;
  min-height: 100vh;
  margin: 0 0 0 var(--sidebar-width);
  padding: 30px;
  background: var(--bg);
}

.brand {
  min-height: 58px;
  margin-bottom: 18px;
  padding: 8px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border: 1px solid var(--sidebar-line);
  border-radius: 12px;
  background: var(--sidebar-elevated);
  color: var(--sidebar-text);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16);
}

.brand h1 {
  color: var(--sidebar-text);
  font-size: 0.98rem;
}

.brand p {
  color: var(--sidebar-muted);
  font-size: 0.8rem;
}

.tabs {
  position: static;
  display: flex;
  width: 100%;
  max-width: none;
  flex: 1;
  flex-direction: column;
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.tab {
  display: flex;
  width: 100%;
  min-height: 44px;
  justify-content: flex-start;
  gap: 11px;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--sidebar-muted);
  font-weight: 780;
  text-align: left;
}

.tab:hover {
  border-color: var(--sidebar-line);
  background: color-mix(in srgb, var(--sidebar-elevated) 72%, transparent);
  color: var(--sidebar-text);
}

.tab.active {
  border-color: var(--sidebar-line);
  background: var(--sidebar-elevated);
  color: var(--sidebar-text);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
}

.nav-icon {
  display: grid;
  width: 22px;
  min-width: 22px;
  place-items: center;
  color: currentColor;
  font-size: 1rem;
  line-height: 1;
}

.nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-actions {
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-line);
}

.sidebar-control {
  display: flex;
  width: 100%;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border: 1px solid var(--sidebar-line);
  border-radius: 12px;
  background: transparent;
  color: var(--sidebar-muted);
  font-weight: 820;
  text-align: left;
}

.sidebar-control:hover {
  background: var(--sidebar-elevated);
  color: var(--sidebar-text);
}

:root[data-sidebar="collapsed"] .app-shell {
  grid-template-columns: var(--sidebar-collapsed-width) minmax(0, 1fr);
}

:root[data-sidebar="collapsed"] .sidebar {
  width: var(--sidebar-collapsed-width);
  padding-inline: 12px;
}

:root[data-sidebar="collapsed"] .workspace {
  margin-left: var(--sidebar-collapsed-width);
}

:root[data-sidebar="collapsed"] .brand {
  justify-content: center;
  padding-inline: 0;
}

:root[data-sidebar="collapsed"] .brand > div:not(.brand-mark),
:root[data-sidebar="collapsed"] .nav-label {
  display: none;
}

:root[data-sidebar="collapsed"] .tab,
:root[data-sidebar="collapsed"] .sidebar-control {
  justify-content: center;
  padding-inline: 8px;
}

:root[data-sidebar="collapsed"] #sidebarToggleBtn .nav-icon {
  transform: rotate(180deg);
}

.tab[data-view="portal"] {
  display: none;
}

.client-mode .tab[data-view="portal"] {
  display: flex !important;
}

.client-mode .tab[data-view="program"],
.client-mode .tab[data-view="library"],
.client-mode .tab[data-view="clients"],
.client-mode .tab[data-view="clientsList"] {
  display: none !important;
}

.topbar {
  position: relative;
  align-items: flex-start;
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.topbar h2 {
  color: var(--ink);
  letter-spacing: -0.04em;
}

.eyebrow {
  color: var(--muted);
  letter-spacing: 0.1em;
}

.panel,
.stat,
.auth-panel,
.calendar-panel,
.calendar-sidebar,
.schedule-list-panel,
.workout-file-card,
.day-event-card,
.appointment-dialog,
.exercise-video-dialog,
.auth-card,
.empty-state,
.nutrition-result-panel,
.nutrition-block,
.nutrition-strategy-card,
.nutrition-framework-grid article,
.meal-card {
  border: 1px solid var(--line) !important;
  border-radius: var(--radius-lg);
  background: var(--surface) !important;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.panel,
.stat {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)),
    var(--surface) !important;
}

:root[data-theme="light"] .panel,
:root[data-theme="light"] .stat {
  background: #ffffff !important;
}

input,
select,
textarea {
  border-color: var(--line);
  background: var(--field) !important;
  color: var(--ink);
}

input:hover,
select:hover,
textarea:hover {
  background: var(--field-hover) !important;
  border-color: var(--line-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--line-strong);
  background: var(--field-hover) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ink) 9%, transparent);
}

.primary,
button.primary {
  border: 1px solid var(--primary-bg);
  background: var(--primary-bg) !important;
  color: var(--primary-text) !important;
}

.ghost,
.small-action,
.icon-action,
.secondary,
.link-button {
  border-color: var(--line);
  background: var(--ghost-bg) !important;
  color: var(--ink) !important;
}

.ghost:hover,
.small-action:hover,
.icon-action:hover,
.secondary:hover {
  border-color: var(--line-strong);
  box-shadow: 0 10px 26px color-mix(in srgb, var(--ink) 10%, transparent);
}

.stats-grid {
  gap: 16px;
}

.stat {
  min-height: 118px;
  padding: 18px;
}

.stat span,
.note,
.muted,
label,
.section-heading p,
.client-card span,
.auth-panel span {
  color: var(--muted);
}

.calendar-weekdays,
.calendar-grid,
.calendar-day,
.workout-table-wrap,
.workout-table td,
.workout-table th,
.exercise-database-table,
.exercise-database-header,
.exercise-data-row,
.workout-meta-strip,
.nutrition-metrics div,
.photo-frame,
.photo-empty,
.infographic-chart {
  border-color: var(--line) !important;
  background: var(--surface) !important;
  color: var(--ink);
}

.calendar-weekdays,
.workout-table th,
.exercise-database-header,
.workout-section-row td,
.workout-section-row.section-warmup td,
.workout-section-row.section-main td,
.workout-section-row.section-cooldown td {
  background: var(--raised) !important;
  color: var(--ink);
}

.calendar-day:hover,
.exercise-data-row:hover,
.workout-builder-table tbody tr[data-kind="exercise"]:hover td,
.editable-workout-table tbody tr:not(.workout-section-row):hover td,
.readonly-workout-table tbody tr:not(.workout-section-row):hover td {
  background: var(--field-hover) !important;
}

.workout-builder-table tbody tr[data-kind="exercise"]:nth-of-type(odd) td,
.editable-workout-table tbody tr:not(.workout-section-row):nth-of-type(odd) td,
.readonly-workout-table tbody tr:not(.workout-section-row):nth-of-type(odd) td,
.exercise-data-row:nth-child(odd) {
  background: var(--surface) !important;
}

.workout-builder-table tbody tr[data-kind="exercise"]:nth-of-type(even) td,
.editable-workout-table tbody tr:not(.workout-section-row):nth-of-type(even) td,
.readonly-workout-table tbody tr:not(.workout-section-row):nth-of-type(even) td,
.exercise-data-row:nth-child(even) {
  background: color-mix(in srgb, var(--surface) 82%, var(--raised)) !important;
}

.builder-status,
.status-badge,
.session-pill,
.sync-indicator.synced {
  background: color-mix(in srgb, var(--accent-green) 18%, transparent) !important;
  color: color-mix(in srgb, var(--accent-green) 75%, var(--ink)) !important;
}

.calendar-event,
.sync-indicator.syncing {
  border-left-color: var(--accent-blue);
}

.calendar-event.status-completed {
  border-left-color: var(--accent-green);
}

.calendar-event.status-cancelled {
  border-left-color: var(--accent-amber);
}

:root[data-theme="dark"] .nutrition-hero,
:root[data-theme="dark"] .meal-image {
  background:
    radial-gradient(circle at 84% 18%, rgba(127, 166, 216, 0.12), transparent 34%),
    linear-gradient(145deg, #24252a, #17181b) !important;
}

:root[data-theme="light"] .nutrition-hero,
:root[data-theme="light"] .meal-image {
  background:
    radial-gradient(circle at 84% 18%, rgba(95, 143, 199, 0.1), transparent 34%),
    linear-gradient(145deg, #ffffff, #f5f5f2) !important;
}

@media (max-width: 980px) {
  :root {
    --sidebar-width: 84px;
  }

  .sidebar {
    width: var(--sidebar-width);
    padding-inline: 12px;
  }

  .workspace,
  .client-mode .workspace {
    margin-left: var(--sidebar-width);
    padding: 20px;
  }

  .brand > div:not(.brand-mark),
  .nav-label {
    display: none;
  }

  .tab,
  .sidebar-control {
    justify-content: center;
  }
}

@media (max-width: 700px) {
  .workspace,
  .client-mode .workspace {
    padding: 16px;
  }

  .topbar {
    display: grid;
  }
}

/* Layout repair: fixed sidebar + full-width flexible content */
.app-shell {
  display: flex !important;
  min-height: 100vh;
  width: 100%;
  background: var(--bg);
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
}

.main-content,
.workspace,
.client-mode .workspace {
  flex: 1 1 auto;
  min-width: 0;
  width: calc(100% - var(--sidebar-width));
  max-width: none;
  margin-left: var(--sidebar-width);
  padding: 0 !important;
  overflow-x: auto;
  background: var(--bg);
}

.content-container {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 32px;
  box-sizing: border-box;
}

:root[data-sidebar="collapsed"] .sidebar {
  flex-basis: var(--sidebar-collapsed-width);
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
  max-width: var(--sidebar-collapsed-width);
}

:root[data-sidebar="collapsed"] .main-content,
:root[data-sidebar="collapsed"] .workspace {
  width: calc(100% - var(--sidebar-collapsed-width));
  margin-left: var(--sidebar-collapsed-width);
}

.topbar,
.auth-panel,
.view,
.section-heading,
.content-grid,
.stats-grid {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.content-grid {
  display: grid;
  gap: 18px;
  align-items: start;
}

.calendar-layout,
.schedule-grid {
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
}

.schedule-list-panel,
.session-workouts-panel,
.workout-builder-panel,
.wide-panel {
  grid-column: 1 / -1;
}

.program-grid {
  grid-template-columns: minmax(0, 1fr);
}

.library-grid,
.nutrition-grid {
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
}

.progress-grid {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.photos-grid,
.portal-grid {
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
}

.clients-grid {
  grid-template-columns: minmax(300px, 420px) minmax(300px, 520px);
}

.panel,
.stat,
.calendar-panel,
.workout-table-wrap,
.exercise-database-table {
  min-width: 0;
}

.calendar-panel,
.schedule-list-panel,
.nutrition-result-panel,
.exercise-library-panel,
.workout-builder-panel,
.session-workouts-panel {
  width: 100%;
}

.calendar-grid {
  min-width: 760px;
}

.workout-table-wrap,
.exercise-database-table {
  overflow-x: auto;
}

@media (max-width: 1180px) {
  .calendar-layout,
  .schedule-grid,
  .library-grid,
  .nutrition-grid,
  .progress-grid,
  .photos-grid,
  .portal-grid,
  .clients-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .content-container {
    padding: 22px;
  }

  .main-content,
  .workspace,
  .client-mode .workspace {
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
  }
}

@media (max-width: 700px) {
  .content-container {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Schedule dashboard: calendar-first layout */
#scheduleView .calendar-layout,
#scheduleView .schedule-grid {
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 18px;
}

#scheduleView .calendar-panel {
  grid-column: 1 / -1;
  order: 1;
  padding: 18px;
}

#scheduleView .schedule-list-panel {
  order: 2;
}

#scheduleView .calendar-grid {
  min-width: 920px;
}

#scheduleView .calendar-day {
  min-height: 120px;
}

@media (max-width: 700px) {
  #scheduleView .calendar-day {
    min-height: 100px;
  }
}

/* Exercise Program cleanup */
.topbar {
  align-items: flex-start;
}

.topbar > div:first-child {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.client-search-switcher {
  width: min(420px, 100%);
  min-width: 0;
  margin-bottom: 6px;
}

.client-search-switcher span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.client-search-switcher input {
  min-height: 46px;
  border-radius: 14px;
  padding-left: 38px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--ink) 8%, transparent), transparent 26px),
    var(--field) !important;
}

.client-search-switcher::after {
  content: "⌕";
  position: absolute;
  left: 14px;
  bottom: 12px;
  color: var(--muted);
  font-weight: 900;
  pointer-events: none;
}

.client-search-switcher {
  position: relative;
}

#selectedClientName {
  font-size: clamp(2rem, 4vw, 3.75rem);
}

#selectedClientMeta {
  max-width: 520px;
  font-size: 1rem;
  font-weight: 750;
}

#programView {
  padding-top: 4px;
}

.workout-builder-panel {
  gap: 18px;
}

.builder-header {
  padding-bottom: 4px;
}

.builder-header h4 {
  font-size: 1.15rem;
}

.builder-header .note {
  max-width: 520px;
}

.builder-meta-grid {
  grid-template-columns: 140px 118px minmax(220px, 1.15fr) minmax(220px, 1.15fr) 130px !important;
  gap: 12px;
  align-items: end;
}

.builder-toolbar {
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 76%, var(--raised));
}

.builder-toolbar .primary,
.builder-toolbar .small-action {
  min-height: 42px;
  border-radius: 11px;
}

.session-workouts-panel {
  gap: 16px;
}

.workout-files-header {
  align-items: center;
  padding-bottom: 2px;
}

.workout-files-header h4 {
  font-size: 1.1rem;
}

.workout-month-shell {
  width: fit-content;
  max-width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 82%, var(--raised));
}

.workout-file-list {
  gap: 12px;
}

.workout-file-card {
  padding: 16px;
}

.workout-file-header {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}

.workout-file-card .session-actions {
  gap: 8px;
}

.workout-file-card .session-actions .small-action {
  min-height: 38px;
}

.workout-meta-strip {
  margin-top: 4px;
  border-radius: 12px;
}

.workout-file-details summary {
  width: fit-content;
  border-radius: 999px;
}

@media (max-width: 980px) {
  .builder-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 640px) {
  .builder-meta-grid,
  .workout-file-header {
    grid-template-columns: 1fr !important;
  }

  .workout-month-shell {
    width: 100%;
  }
}

/* Exercise Program polish */
.builder-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.builder-toolbar .primary,
.builder-toolbar .small-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 0.92rem;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
}

.builder-toolbar .primary {
  min-width: 140px;
}

.builder-toolbar .small-action {
  min-width: 80px;
}

.builder-toolbar .small-action.ghost {
  color: var(--muted) !important;
}

.builder-toolbar .small-action.coral {
  color: #fecaca !important;
}

.builder-exercise-suggestions {
  border-color: #333333;
  background: #1b1b1b;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.52);
}

.builder-exercise-suggestions button {
  color: #ffffff !important;
}

.builder-exercise-suggestions strong {
  color: #ffffff !important;
  font-weight: 850;
}

.builder-exercise-suggestions span {
  color: #9ca3af !important;
  font-weight: 650;
}

.builder-exercise-suggestions button:hover,
.builder-exercise-suggestions button:focus-visible,
.builder-exercise-suggestions button.active {
  background: rgba(255, 255, 255, 0.09);
}

.workout-file-details summary {
  background: var(--ghost-bg) !important;
  border-color: var(--line);
  color: var(--ink) !important;
}

:root[data-theme="light"] .workout-file-details summary {
  background: #111111 !important;
  border-color: #2e2e2e;
  color: #ffffff !important;
}

:root[data-theme="dark"] .workout-file-details summary {
  background: #f5f5f5 !important;
  border-color: #e5e7eb;
  color: #111214 !important;
}

@media (max-width: 640px) {
  .builder-toolbar {
    width: 100%;
  }

  .builder-toolbar .primary,
  .builder-toolbar .small-action {
    flex: 1 1 calc(50% - 8px);
    min-width: 0;
  }
}

/* Workspace navigation architecture */
.client-workspace-subnav {
  position: sticky;
  top: 16px;
  z-index: 12;
  display: none;
  width: fit-content;
  max-width: 100%;
  gap: 6px;
  align-items: center;
  margin: -10px 0 22px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: 0 18px 45px color-mix(in srgb, #000 18%, transparent);
  overflow-x: auto;
  backdrop-filter: blur(18px);
}

.client-workspace-subnav.is-visible {
  display: flex;
}

.client-workspace-tab {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 850;
  white-space: nowrap;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.client-workspace-tab:hover {
  border-color: var(--line);
  background: var(--ghost-bg);
  color: var(--ink);
}

.client-workspace-tab.active {
  border-color: var(--line-strong);
  background: var(--primary-bg);
  color: var(--primary-text);
  box-shadow: 0 10px 28px color-mix(in srgb, var(--ink) 10%, transparent);
}

.client-overview-grid {
  display: grid;
  gap: 18px;
}

.client-overview-stats {
  margin-bottom: 0;
}

.overview-detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.nutrition-grid {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr) !important;
}

.nutrition-setup-panel {
  align-self: start;
}

@media (max-width: 1180px) {
  .nutrition-grid {
    grid-template-columns: 1fr !important;
  }
}

.overview-summary-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.overview-summary-list p {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.overview-summary-list p:last-child {
  border-bottom: 0;
}

.overview-summary-list span {
  color: var(--muted);
  font-weight: 750;
}

.overview-summary-list strong {
  color: var(--ink);
  text-align: right;
}

.empty-workspace {
  display: grid;
  gap: 8px;
  min-height: 220px;
  align-content: center;
}

@media (max-width: 980px) {
  .client-workspace-subnav {
    width: 100%;
  }

  .overview-detail-grid {
    grid-template-columns: 1fr;
  }
}

/* Multi-panel coaching workspace */
:root {
  --client-panel-width: 288px;
  --client-panel-collapsed-width: 84px;
  --workspace-left-offset: calc(var(--sidebar-width) + var(--client-panel-width));
}

:root[data-sidebar="collapsed"] {
  --workspace-left-offset: calc(var(--sidebar-collapsed-width) + var(--client-panel-width));
}

:root[data-client-panel="collapsed"] {
  --workspace-left-offset: calc(var(--sidebar-width) + var(--client-panel-collapsed-width));
}

:root[data-sidebar="collapsed"][data-client-panel="collapsed"] {
  --workspace-left-offset: calc(var(--sidebar-collapsed-width) + var(--client-panel-collapsed-width));
}

.client-panel {
  position: fixed;
  inset: 0 auto 0 var(--sidebar-width);
  z-index: 990;
  display: flex;
  width: var(--client-panel-width);
  height: 100vh;
  flex-direction: column;
  gap: 14px;
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, #000), var(--bg)),
    var(--surface);
  box-shadow: 16px 0 36px color-mix(in srgb, #000 20%, transparent);
  transition:
    left var(--app-transition),
    width var(--app-transition),
    background-color var(--app-transition),
    border-color var(--app-transition);
}

:root[data-sidebar="collapsed"] .client-panel {
  left: var(--sidebar-collapsed-width);
}

:root[data-client-panel="collapsed"] .client-panel {
  width: var(--client-panel-collapsed-width);
  padding-inline: 10px;
}

.client-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
}

.client-panel-eyebrow {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.client-panel-header h2 {
  color: var(--ink);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.client-panel-collapse {
  width: 36px;
  height: 36px;
  min-height: 36px;
  border-radius: 11px;
  font-size: 1rem;
}

:root[data-client-panel="collapsed"] .client-panel-collapse {
  transform: rotate(180deg);
}

.client-panel-search {
  margin: 0;
}

.client-panel-search input {
  min-height: 42px;
  border-radius: 12px;
}

.client-panel-list {
  flex: 1;
  gap: 8px;
  margin: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.client-panel .client-card {
  display: flex;
  align-items: center;
  min-height: 52px;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
}

.client-panel .client-card:hover {
  border-color: var(--line);
  background: color-mix(in srgb, var(--elevated) 92%, var(--field-hover));
}

.client-panel .client-card.active {
  border-color: color-mix(in srgb, var(--primary-bg) 40%, var(--line));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary-bg) 10%, transparent), transparent 62%),
    var(--elevated);
  box-shadow: inset 3px 0 0 var(--primary-bg);
}

.client-panel .client-avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-bg);
  color: var(--primary-text);
  font-size: 0.72rem;
}

.client-card-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 700;
}

:root[data-client-panel="collapsed"] .client-panel-header > div,
:root[data-client-panel="collapsed"] .client-panel-search,
:root[data-client-panel="collapsed"] .client-panel .client-card-name {
  display: none;
}

:root[data-client-panel="collapsed"] .client-panel-header {
  justify-content: center;
}

:root[data-client-panel="collapsed"] .client-panel-list {
  justify-items: center;
  padding-right: 0;
}

:root[data-client-panel="collapsed"] .client-panel .client-card {
  position: relative;
  width: 58px;
  min-height: 58px;
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 7px;
}

:root[data-client-panel="collapsed"] .client-panel .session-pill {
  position: absolute;
  right: -4px;
  bottom: -2px;
  min-width: 22px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  font-size: 0.68rem;
}

.main-content,
.workspace,
.client-mode .workspace {
  width: calc(100% - var(--workspace-left-offset)) !important;
  margin-left: var(--workspace-left-offset) !important;
}

.topbar {
  min-height: 48px;
  margin-bottom: 18px;
  padding: 0 0 16px;
}

.topbar > div:first-child {
  gap: 2px;
}

.topbar .eyebrow {
  font-size: 0.66rem;
}

#selectedClientName {
  font-size: clamp(1.05rem, 1.3vw, 1.35rem) !important;
  letter-spacing: -0.02em;
}

#selectedClientMeta {
  display: inline-flex;
  width: fit-content;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--field);
  padding: 3px 9px;
  font-size: 0.75rem;
  line-height: 1.2;
}

.client-mode .client-panel {
  display: none;
}

.client-mode .main-content,
.client-mode .workspace {
  width: calc(100% - var(--sidebar-width)) !important;
  margin-left: var(--sidebar-width) !important;
}

.clients-grid {
  grid-template-columns: minmax(320px, 560px) !important;
}

#scheduleView > .stats-grid {
  display: none !important;
}

@media (max-width: 1120px) {
  :root,
  :root[data-sidebar="collapsed"],
  :root[data-client-panel="collapsed"],
  :root[data-sidebar="collapsed"][data-client-panel="collapsed"] {
    --workspace-left-offset: var(--sidebar-width);
  }

  .client-panel {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    max-height: 360px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .app-shell {
    display: grid !important;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }

  .main-content,
  .workspace,
  .client-mode .workspace {
    width: calc(100% - var(--sidebar-width)) !important;
    margin-left: var(--sidebar-width) !important;
  }
}

/* Scope the client panel to the Dashboard client workspace only. */
:root {
  --workspace-left-offset: var(--sidebar-width);
}

:root[data-sidebar="collapsed"] {
  --workspace-left-offset: var(--sidebar-collapsed-width);
}

:root[data-workspace="client"] {
  --workspace-left-offset: calc(var(--sidebar-width) + var(--client-panel-width));
}

:root[data-sidebar="collapsed"][data-workspace="client"] {
  --workspace-left-offset: calc(var(--sidebar-collapsed-width) + var(--client-panel-width));
}

:root[data-client-panel="collapsed"][data-workspace="client"] {
  --workspace-left-offset: calc(var(--sidebar-width) + var(--client-panel-collapsed-width));
}

:root[data-sidebar="collapsed"][data-client-panel="collapsed"][data-workspace="client"] {
  --workspace-left-offset: calc(var(--sidebar-collapsed-width) + var(--client-panel-collapsed-width));
}

.client-panel {
  display: none;
}

:root[data-workspace="client"] .client-panel {
  display: flex;
}

.client-mode .client-panel {
  display: none !important;
}

:root[data-active-view="library"] .topbar,
:root[data-active-view="library"] .client-workspace-subnav {
  display: none !important;
}

@media (max-width: 1120px) {
  :root[data-workspace="client"],
  :root[data-sidebar="collapsed"][data-workspace="client"],
  :root[data-client-panel="collapsed"][data-workspace="client"],
  :root[data-sidebar="collapsed"][data-client-panel="collapsed"][data-workspace="client"] {
    --workspace-left-offset: var(--sidebar-width);
  }
}

.hidden {
  display: none !important;
}

.calendar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.calendar-event {
  border-left-color: var(--client-color, var(--accent-blue));
}

.calendar-grid.week-view {
  grid-auto-rows: minmax(200px, 1fr);
}

.calendar-grid.week-view .calendar-day {
  min-height: 200px;
}

.calendar-grid.two-week-view .calendar-day {
  min-height: 160px;
}

.client-panel-list {
  gap: 6px;
}

.client-panel .client-card {
  min-height: 72px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 12px;
}

.client-panel .client-avatar {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 0.78rem;
  font-weight: 900;
}

.client-panel .client-card strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 1.12;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-panel .client-card span span {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-panel .session-pill {
  min-width: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
}

:root[data-client-panel="collapsed"] .client-panel .client-card {
  min-height: 56px;
}

/* Final client panel density polish: desktop CRM / Trainerize-style list */
:root {
  --client-panel-width: 292px;
  --client-panel-collapsed-width: 82px;
}

.client-panel {
  gap: 10px;
  padding: 14px 12px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 98%, #000), var(--bg)),
    var(--surface);
  box-shadow: 10px 0 28px color-mix(in srgb, #000 18%, transparent);
}

.client-panel-header {
  min-height: 42px;
  padding: 0 2px;
}

.client-panel-eyebrow {
  font-size: 0.6rem;
  letter-spacing: 0.14em;
}

.client-panel-header h2 {
  margin-top: 1px;
  font-size: 0.98rem;
  line-height: 1.05;
}

.client-panel-collapse {
  width: 32px;
  height: 32px;
  min-height: 32px;
  border-radius: 10px;
  font-size: 0.9rem;
}

.client-panel-search {
  position: relative;
  display: block;
  margin: 0 0 2px;
}

.client-panel-search > span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.client-panel-search::before {
  content: "⌕";
  position: absolute;
  left: 12px;
  top: 50%;
  z-index: 1;
  color: var(--muted);
  font-size: 0.95rem;
  transform: translateY(-50%);
  pointer-events: none;
}

.client-panel-search input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px 0 36px;
  border-radius: 12px;
  border-color: color-mix(in srgb, var(--line) 86%, transparent);
  background: color-mix(in srgb, var(--field) 82%, transparent);
  font-size: 0.86rem;
  font-weight: 700;
}

.client-panel-list {
  gap: 6px;
  padding-right: 1px;
  align-content: start;
  grid-auto-rows: max-content;
}

.client-panel .client-card {
  height: 76px;
  min-height: 76px;
  max-height: 76px;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 9px;
  padding: 8px;
  border-radius: 13px;
  background: color-mix(in srgb, var(--elevated) 68%, transparent);
  box-shadow: none;
}

.client-panel .client-card:hover {
  border-color: color-mix(in srgb, var(--line-strong) 82%, transparent);
  background: color-mix(in srgb, var(--elevated) 88%, var(--field-hover));
  transform: translateY(-1px);
}

.client-panel .client-card.active {
  border-color: color-mix(in srgb, var(--primary-bg) 42%, var(--line-strong));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary-bg) 8%, transparent), transparent 58%),
    color-mix(in srgb, var(--elevated) 94%, var(--surface));
  box-shadow:
    inset 2px 0 0 color-mix(in srgb, var(--primary-bg) 78%, transparent),
    0 10px 24px color-mix(in srgb, #000 16%, transparent);
}

.client-panel .client-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 0.78rem;
  letter-spacing: -0.02em;
}

.client-panel .client-card strong {
  font-size: 0.9rem;
  line-height: 1.1;
}

.client-panel .client-card span span {
  margin-top: 4px;
  font-size: 0.72rem;
  line-height: 1.2;
}

.client-panel .session-pill {
  min-width: 30px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  line-height: 1.35;
}

:root[data-client-panel="collapsed"] .client-panel {
  padding-inline: 9px;
}

:root[data-client-panel="collapsed"] .client-panel .client-card {
  width: 56px;
  min-height: 62px;
  padding: 5px;
}

:root[data-client-panel="collapsed"] .client-panel .client-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 0.76rem;
}

/* Library architecture */
.library-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.library-section {
  display: none;
  min-width: 0;
}

.library-section.active {
  display: block;
}

.library-subnav {
  position: sticky;
  top: 24px;
  gap: 6px;
  padding: 12px;
}

.library-subnav-item {
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  text-align: left;
  font-weight: 850;
}

.library-subnav-item.active {
  border-color: var(--line);
  background: var(--elevated);
  color: var(--ink);
}

.library-subnav-item:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.library-topbar,
.library-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.library-filter-bar {
  flex-wrap: wrap;
  justify-content: flex-start;
  padding-bottom: 10px;
  position: relative;
}

.library-filter-bar input[type="search"] {
  flex: 1 1 280px;
  min-width: 240px;
}

.library-filter-toggle,
.library-tags-button {
  min-height: 42px;
  border-radius: 12px;
  padding-inline: 16px;
}

.library-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
  margin: -2px 0 14px;
}

.filter-chip,
.filter-clear {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--elevated);
  color: var(--ink);
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 850;
}

.filter-chip strong {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
}

.filter-clear {
  background: transparent;
  color: var(--muted);
}

.library-filter-drawer {
  display: none;
  margin: 0 0 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--elevated) 88%, transparent);
  box-shadow: var(--shadow);
  padding: 16px;
}

.library-filter-drawer.visible {
  display: block;
  animation: filterDrawerIn 160ms ease-out;
}

@keyframes filterDrawerIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.filter-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.filter-drawer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.filter-section {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.filter-section h5 {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.filter-pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-pill,
.filter-check {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 800;
}

.filter-check {
  width: fit-content;
  border-radius: 10px;
}

.filter-check span {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  vertical-align: -1px;
  background: var(--field);
}

.filter-pill:hover,
.filter-check:hover,
.filter-pill.is-selected,
.filter-check.is-selected {
  border-color: color-mix(in srgb, var(--teal) 34%, var(--line));
  background: color-mix(in srgb, var(--teal-soft) 58%, var(--surface));
  color: var(--ink);
}

.filter-check.is-selected span {
  border-color: var(--ink);
  background: var(--ink);
}

.exercise-database-header,
.exercise-data-row {
  grid-template-columns: 92px minmax(240px, 1.35fr) minmax(130px, 0.9fr) minmax(150px, 1fr) minmax(150px, 1fr) 110px minmax(130px, 0.9fr) 110px 44px;
}

.exercise-database-table {
  min-width: 1160px;
}

.exercise-video-cell {
  display: grid;
  place-items: center;
}

.exercise-data-row {
  cursor: default;
}

.exercise-video-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 72px;
  height: 56px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--muted);
  padding: 0;
  font-size: 0.75rem;
  font-weight: 900;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.exercise-video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.22s ease, filter 0.22s ease;
}

.exercise-video-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.22);
  opacity: 0.72;
  transition: opacity 0.16s ease;
}

.exercise-video-thumb .play-overlay {
  position: absolute;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(245, 245, 245, 0.94);
  color: #111;
  font-size: 0.72rem;
  line-height: 1;
  transform: scale(0.92);
  transition: transform 0.16s ease;
}

.exercise-video-thumb:hover,
.exercise-video-thumb:focus-visible {
  border-color: color-mix(in srgb, var(--ink) 34%, var(--line));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  transform: translateY(-1px);
}

.exercise-video-thumb:hover img,
.exercise-video-thumb:focus-visible img {
  filter: brightness(0.82);
  transform: scale(1.06);
}

.exercise-video-thumb:hover .play-overlay,
.exercise-video-thumb:focus-visible .play-overlay {
  transform: scale(1);
}

.exercise-name-button {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.exercise-name-button:hover strong,
.exercise-name-button:focus-visible strong {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.media-field-panel {
  align-content: start;
}

.exercise-editor-dialog {
  width: min(1120px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.find-workout-dialog {
  width: min(1100px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.find-workout-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 18px;
}

.find-workout-list-panel,
.find-workout-preview,
.workout-preview-card {
  display: grid;
  gap: 12px;
}

.find-workout-list {
  display: grid;
  gap: 8px;
  max-height: 520px;
  overflow: auto;
}

.find-workout-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--field);
  color: var(--ink);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.find-workout-item:hover,
.find-workout-item.active {
  border-color: color-mix(in srgb, var(--ink) 28%, var(--line));
  background: var(--field-hover);
}

.find-workout-item span,
.workout-preview-card p {
  color: var(--muted);
}

.workout-preview-card {
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--field);
  padding: 18px;
}

.preview-section-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-section-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  padding: 6px 9px;
  font-size: 0.82rem;
  font-weight: 800;
}

.builder-schedule-field {
  display: none !important;
}

.exercise-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  gap: 18px;
}

.exercise-editor-dialog select[multiple] {
  min-height: 112px;
  padding-block: 8px;
}

.tag-picker {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--field) 92%, transparent);
  padding: 10px;
}

.tag-picker-selected,
.tag-picker-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tag-picker-selected {
  min-height: 34px;
  padding-bottom: 2px;
}

.tag-picker-empty,
.tag-picker small {
  color: var(--subtle);
  font-size: 0.78rem;
  font-weight: 750;
}

.tag-chip,
.tag-option {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 800;
}

.tag-chip {
  border-color: color-mix(in srgb, var(--teal) 42%, var(--line));
  background: color-mix(in srgb, var(--teal-soft) 64%, var(--surface));
}

.tag-chip strong {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.tag-option {
  color: var(--muted);
}

.tag-option:hover:not(:disabled),
.tag-option.is-selected {
  border-color: color-mix(in srgb, var(--teal) 36%, var(--line));
  background: var(--elevated);
  color: var(--ink);
}

.tag-option:disabled {
  opacity: 0.35;
}

.exercise-preview-card {
  display: grid;
  min-height: 260px;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: var(--field);
  color: var(--muted);
  font-weight: 800;
}

.template-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.template-card {
  display: grid;
  gap: 14px;
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  padding: 16px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.template-card h4 {
  margin-top: 8px;
  font-size: 1.08rem;
}

.template-card p,
.template-meta {
  color: var(--muted);
  font-weight: 700;
}

.template-meta,
.template-tags,
.template-actions,
.type-choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.template-tags span,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-dark);
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.workout-template-builder.hidden {
  display: none;
}

.template-meta-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.type-choice-dialog {
  width: min(680px, calc(100vw - 48px));
}

.type-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.type-choice-card {
  display: grid;
  gap: 8px;
  min-height: 140px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  padding: 18px;
  text-align: left;
}

.type-choice-card span {
  color: var(--muted);
  font-weight: 700;
}

.exercise-preview-card img {
  width: 100%;
  height: 100%;
  max-height: 340px;
  object-fit: cover;
}

@media (max-width: 980px) {
  .client-info-hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .client-info-card-grid,
  .client-metric-grid {
    grid-template-columns: 1fr;
  }

  .client-form-dialog {
    width: min(100%, calc(100vw - 24px));
    padding: 24px;
  }

  .library-shell,
  .filter-drawer-grid,
  .exercise-editor-grid {
    grid-template-columns: 1fr;
  }

  .library-subnav {
    position: static;
  }
}

/* ─── CLIENT PORTAL – WORKOUT TABLE IN SCHEDULE ────────────────────────────── */

.cp-workout-detail .workout-table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-top: 4px;
}

.cp-workout-detail .workout-table {
  font-size: 0.8rem;
}

/* ─── CLIENT PORTAL VARIABLES ────────────────────────────────────────────── */

:root {
  --text: var(--ink);
  --text-muted: var(--muted);
  --card-bg: var(--elevated);
  --border: var(--line);
  --accent: #6366f1;
  --accent-faint: rgba(99, 102, 241, 0.1);
}

:root[data-theme="light"] {
  --accent: #4f46e5;
  --accent-faint: rgba(79, 70, 229, 0.08);
}

/* ─── CLIENT PORTAL SHELL ─────────────────────────────────────────────────── */

.client-portal-shell {
  width: 100vw;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  flex-direction: row;
  background: var(--bg);
  color: var(--text);
}

/* Sidebar */
.cp-sidebar {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.cp-sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.cp-brand-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.cp-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 2px;
  overflow-y: auto;
}

.cp-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.cp-nav-btn svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.cp-nav-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.cp-nav-btn.active {
  background: var(--accent-faint, rgba(99,102,241,0.12));
  color: var(--accent);
  font-weight: 600;
}

.cp-nav-btn.active svg {
  opacity: 1;
}

.cp-sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

.cp-sign-out-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.cp-sign-out-btn:hover {
  background: var(--bg);
  color: var(--danger, #ef4444);
}

/* Main area */
.cp-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.cp-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.cp-header-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.cp-mobile-menu-btn {
  display: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 4px;
  cursor: pointer;
  border-radius: 6px;
}

.cp-mobile-menu-btn:hover { background: var(--bg); }

.cp-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 24px;
}

/* Dashboard grid */
.cp-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 1100px;
}

.cp-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.cp-box-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}

.cp-box-title {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0;
}

.cp-box-body {
  padding: 20px;
}

/* Hero card (Box 1) */
.cp-hero-card {
  grid-column: 1 / -1;
}

.cp-hero-inner {
  display: flex;
  align-items: center;
  gap: 20px;
}

.cp-hero-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-faint, rgba(99,102,241,0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  overflow: hidden;
}

.cp-hero-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.cp-hero-info {
  flex: 1;
  min-width: 0;
}

.cp-hero-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 2px;
}

.cp-hero-package {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.cp-sessions-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.cp-sessions-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.cp-sessions-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Body Metrics box charts */
.cp-metrics-charts {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cp-metric-chart-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cp-metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.cp-metric-canvas {
  width: 100%;
  height: 90px;
  display: block;
}

/* Photos placeholder (Box 3) */
.cp-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 120px;
  color: var(--text-muted);
}

.cp-placeholder svg {
  opacity: 0.3;
}

.cp-placeholder-text {
  font-size: 0.875rem;
  font-style: italic;
}

/* Profile box (Box 4) */
.cp-profile-sections {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.cp-profile-section-title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 0 0 10px;
}

.cp-profile-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 16px;
}

.cp-profile-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cp-field-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.cp-field-value {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

.cp-field-value.empty {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}

/* Tags (goals) */
.cp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.cp-tag {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-faint, rgba(99,102,241,0.12));
  color: var(--accent);
}

/* Schedule page */
.cp-schedule-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 760px;
}

.cp-next-session-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.cp-next-session-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 0 0 8px;
}

.cp-next-session-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.cp-next-session-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.cp-no-session {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

.cp-upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cp-upcoming-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.cp-upcoming-date-badge {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--accent-faint, rgba(99,102,241,0.12));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cp-upcoming-date-month {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1;
}

.cp-upcoming-date-day {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.cp-upcoming-details {
  flex: 1;
  min-width: 0;
}

.cp-upcoming-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 2px;
}

.cp-upcoming-time {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Placeholder pages (Nutrition / Messages) */
.cp-coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: 12px;
  color: var(--text-muted);
}

.cp-coming-soon svg {
  opacity: 0.25;
}

.cp-coming-soon-heading {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.cp-coming-soon-sub {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* ─── ONBOARDING MODAL ───────────────────────────────────────────────────── */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  -webkit-overflow-scrolling: touch;
}

.onboarding-overlay[aria-hidden="true"] {
  display: none;
}

.onboarding-dialog {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: calc(100svh - 32px);
  max-height: calc(100vh - 32px); /* fallback for older browsers */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
}

.onboarding-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.onboarding-progress-track {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.onboarding-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.35s ease;
}

.onboarding-step-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.onboarding-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  padding: 16px 24px 0;
  flex-shrink: 0;
}

.onboarding-step-content {
  flex: 1;
  padding: 16px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.onboarding-field-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.onboarding-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.onboarding-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.onboarding-label .required {
  color: var(--danger, #ef4444);
  margin-left: 2px;
}

.onboarding-input,
.onboarding-select,
.onboarding-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem; /* min 16px — prevents iOS Safari auto-zoom on focus */
  font-family: inherit;
  transition: border-color 0.15s;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.onboarding-input:focus,
.onboarding-select:focus,
.onboarding-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.onboarding-textarea {
  resize: vertical;
  min-height: 80px;
}

.onboarding-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.onboarding-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.onboarding-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
  font-size: 0.9375rem;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.onboarding-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.onboarding-goal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.onboarding-goal-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.onboarding-goal-chip input[type="checkbox"] {
  display: none;
}

.onboarding-goal-chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-faint, rgba(99,102,241,0.1));
  color: var(--accent);
  font-weight: 600;
}

.onboarding-range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.onboarding-range-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

.onboarding-range-value {
  font-weight: 700;
  font-size: 0.9rem;
  width: 24px;
  text-align: center;
  color: var(--accent);
}

.onboarding-agree-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.onboarding-agree-block input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.onboarding-agree-text {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.onboarding-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 10px;
}

.onboarding-footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.onboarding-btn {
  min-height: 44px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9375rem; /* 15px — visible enough, still large tap target */
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  border: 1px solid transparent;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.onboarding-btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.onboarding-btn.primary:hover { opacity: 0.88; }

.onboarding-btn.ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}

.onboarding-btn.ghost:hover {
  background: var(--bg);
  color: var(--text);
}

.onboarding-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Onboarding badge on client cards */
.onboarding-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(234, 179, 8, 0.15);
  color: #b45309;
  border: 1px solid rgba(234, 179, 8, 0.35);
  vertical-align: middle;
  margin-left: 6px;
}

/* ─── CLIENT PORTAL RESPONSIVE ───────────────────────────────────────────── */

@media (max-width: 900px) {
  .cp-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .cp-hero-card {
    grid-column: 1;
  }
}

/* Mobile sidebar overlay backdrop */
.cp-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 799;
}

@media (max-width: 680px) {
  .cp-sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    bottom: 0;
    width: 240px;
    z-index: 800;
    transition: left 0.25s ease;
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    padding-left: env(safe-area-inset-left);
  }

  .cp-sidebar.open {
    left: 0;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  .cp-sidebar.open ~ .cp-sidebar-overlay,
  .cp-sidebar-overlay.visible {
    display: block;
  }

  .cp-mobile-menu-btn {
    display: flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
  }

  .cp-content {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .cp-header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .onboarding-two-col {
    grid-template-columns: 1fr;
  }

  .onboarding-goal-grid {
    grid-template-columns: 1fr;
  }

  .cp-profile-fields {
    grid-template-columns: 1fr;
  }

  /* Onboarding modal full-screen on small phones */
  .onboarding-dialog {
    border-radius: 12px;
    max-height: calc(100svh - 24px);
    max-height: calc(100vh - 24px);
  }

  .onboarding-overlay {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    align-items: flex-end; /* slide up from bottom on mobile */
  }
}

/* ─── DRAG HANDLE ─────────────────────────────────────────────────────────── */

.drag-handle-col,
.drag-handle-cell {
  width: 26px;
  min-width: 26px;
  padding: 0 !important;
  text-align: center;
  vertical-align: middle;
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 30px;
  background: none;
  color: var(--subtle);
  opacity: 0.35;
  cursor: grab;
  border-radius: 4px;
  transition: opacity 0.12s, background 0.12s;
}

.drag-handle:hover {
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.06);
}

tr:hover .drag-handle {
  opacity: 0.6;
}

.workout-builder-table tbody tr[data-kind="exercise"] {
  cursor: default;
}

/* ─── BUILDER TOOLBAR GROUPS ─────────────────────────────────────────────── */

.builder-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.builder-toolbar-sep {
  width: 1px;
  height: 24px;
  background: var(--line);
  flex-shrink: 0;
  margin: 0 2px;
}

.builder-more-btn {
  display: none !important;
}

@media (max-width: 768px) {
  .builder-toolbar-secondary {
    display: none !important;
  }

  .builder-more-btn {
    display: inline-flex !important;
  }
}

/* ─── BUILDER DROPDOWN ───────────────────────────────────────────────────── */

.builder-dropdown {
  position: fixed;
  z-index: 1200;
  min-width: 180px;
  background: var(--elevated);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.48);
  padding: 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 12px;
  border-radius: 7px;
  background: none;
  border: 0;
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.dropdown-item:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ─── PREV WORKOUT TOOLTIP ───────────────────────────────────────────────── */

.prev-workout-tooltip {
  min-width: 160px;
  font-size: 0.82rem;
  pointer-events: auto;
}

.prev-workout-tooltip-content {
  padding: 6px 10px 8px;
  color: var(--muted);
  line-height: 1.5;
}

.prev-workout-tooltip strong {
  color: var(--ink);
  display: block;
  margin-bottom: 3px;
  font-size: 0.86rem;
}

/* ─── SECTION HEADER BAR ─────────────────────────────────────────────────── */

/* Sticky on the <tr> — later headers visually cover earlier ones as you scroll */
.section-header-row {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
}

.section-header-row > td.section-header-cell {
  border: 0 !important;
  padding: 16px 0 4px !important;
  background: transparent !important;
}

.section-header-row:first-child > td.section-header-cell {
  padding-top: 4px !important;
}

.section-header-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 10px;
  background: var(--elevated, #232323);
  border-radius: 8px;
  border-left: 4px solid var(--section-color, #EF4444);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.22);
}

.section-color-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--section-color, #EF4444);
  flex-shrink: 0;
}

.workout-builder-table .section-title-input {
  flex: 1;
  min-width: 0;
  background: none !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  min-height: unset !important;
  height: auto;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--ink);
  text-align: left;
  line-height: 1.2;
  width: auto;
}

.workout-builder-table .section-title-input:focus {
  outline: none;
  border-bottom: 1px solid var(--section-color, #EF4444) !important;
}

.section-exercise-count {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.section-drag-handle {
  flex-shrink: 0;
  opacity: 0.4;
  cursor: grab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 28px;
  border-radius: 5px;
  transition: opacity 0.12s, background 0.12s;
  margin-right: 2px;
}

.section-drag-handle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.section-exercise-count {
  margin-left: auto;
}

/* Light theme section bar */
:root[data-theme="light"] .section-header-bar {
  background: #f8f8f8;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] .workout-builder-table .section-title-input {
  color: #111;
}

/* ─── NEW SECTION MODAL ──────────────────────────────────────────────────── */

.new-section-dialog {
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.new-section-color-label {
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--muted);
}

.section-color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.section-color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
  flex-shrink: 0;
}

.section-color-swatch:hover {
  transform: scale(1.15);
}

.section-color-swatch.selected {
  border-color: var(--ink);
  transform: scale(1.12);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink);
}

/* ── Exercise row: hybrid simple/detailed mode ─────────────────────────── */

.exercise-content-cell {
  padding: 6px 8px 6px 4px !important;
  vertical-align: top;
}

.exercise-row-inner {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
}

.exercise-mode-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 4px 2px;
  margin-top: 2px;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
}

.exercise-mode-btn:hover {
  color: var(--ink);
  background: var(--surface-hover, rgba(128,128,128,0.12));
}

.exercise-name-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Simple mode: name + mini-fields on same row */
.exercise-row-inner > .exercise-name-col {
  flex: 0 0 auto;
  width: clamp(140px, 30%, 240px);
}

.exercise-mini-fields {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 3px 4px;
  flex: 1;
  min-width: 0;
}

.mini-field-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

.mini-field-group > span {
  font-size: 0.65rem;
  color: var(--muted);
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mini-field {
  width: 52px;
  text-align: center;
  font-size: 0.82rem;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--input-bg, var(--surface));
  color: var(--ink);
  transition: border-color 0.12s;
}

.mini-field:focus {
  outline: none;
  border-color: var(--accent, #3b82f6);
}

.mini-op {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 14px;
}

.mini-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 12px 2px 0;
  align-self: flex-end;
}

/* Exercise note */
.exercise-note-wrap {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.exercise-note-icon {
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--muted);
  flex-shrink: 0;
}

.exercise-note-input {
  width: 100%;
  font-size: 0.78rem;
  color: var(--muted);
  background: transparent;
  border: none;
  resize: none;
  padding: 0;
  line-height: 1.4;
  font-family: inherit;
  overflow: hidden;
}

.exercise-note-input:focus {
  outline: none;
  color: var(--ink);
}

.exercise-note-input::placeholder {
  color: var(--muted);
  opacity: 0.55;
}

/* Varies indicator */
.exercise-varies-area {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  padding-top: 2px;
}

.varies-badge {
  font-size: 0.76rem;
  color: var(--muted);
  background: var(--surface-hover, rgba(128,128,128,0.1));
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}

.varies-icon {
  background: none;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 2px;
  color: var(--muted);
}

/* Detailed mode layout */
.exercise-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
}

.exercise-detail-header .exercise-name-col {
  flex: 1;
  width: auto;
}

.exercise-sets-block {
  margin-top: 8px;
  width: 100%;
}

.sets-detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.sets-detail-table th {
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 2px 6px 4px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.sets-detail-table td {
  padding: 3px 3px;
  text-align: center;
}

.set-num-col,
.sets-detail-table .set-number-cell {
  width: 32px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.set-field {
  width: 68px;
  text-align: center;
  font-size: 0.82rem;
  padding: 3px 4px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--input-bg, var(--surface));
  color: var(--ink);
  transition: border-color 0.12s;
}

.set-field:focus {
  outline: none;
  border-color: var(--accent, #3b82f6);
}

.exercise-detail-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 4px;
}

.btn-xs {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}

.btn-xs:hover {
  background: var(--surface-hover, rgba(128,128,128,0.12));
  border-color: var(--muted);
}

.btn-xs--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-xs--ghost:hover {
  color: var(--ink);
  background: var(--surface-hover, rgba(128,128,128,0.1));
  border-color: transparent;
}

/* Detailed mode row wrapping: column layout */
tr[data-mode="detailed"] .exercise-row-inner {
  flex-direction: column;
}

/* RPE dropdown */
.rpe-dropdown {
  background: var(--surface, #1e1e1e);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  min-width: 200px;
}

.rpe-option {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: none;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.rpe-option:hover {
  background: var(--surface-hover, rgba(128,128,128,0.15));
  border-color: var(--border);
}

.rpe-num {
  font-size: 1rem;
  font-weight: 700;
  min-width: 36px;
  color: var(--ink);
}

.rpe-label {
  font-size: 0.82rem;
  color: var(--muted);
}

/* Hide the thead for the builder tables — headings are now implicit */
.workout-builder-table > thead {
  display: none;
}


/* ══════════════════════════════════════════════════════════════════════════
   EXERCISE CARD LAYOUT (Part A)
   ══════════════════════════════════════════════════════════════════════════ */

/* Cell that holds the card — zero visual chrome, just spacing */
/* ════════════════════════════════════════════════
   EXERCISE CARD — PILL BOX LAYOUT
   ════════════════════════════════════════════════ */

.exercise-card-cell {
  padding: 6px 0 !important;
  border: none !important;
  background: transparent !important;
  vertical-align: top;
}

.exercise-card {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

tr.selected-row .exercise-card {
  border-color: var(--accent, #3b82f6);
  box-shadow: 0 0 0 1px var(--accent, #3b82f6);
}

tr.dragging-row .exercise-card {
  opacity: 0.45;
}

/* ── Card Header ── */
.exercise-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.exercise-card-drag {
  flex-shrink: 0;
  color: var(--muted);
  opacity: 0.6;
  cursor: grab;
  width: 24px;
  height: 24px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: none;
  background: none;
  transition: opacity 0.12s, background 0.12s;
}

.exercise-card-drag:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.exercise-thumb {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.07);
  border: none;
  padding: 0;
  cursor: default;
  font-size: 1.1rem;
}

button.exercise-thumb {
  cursor: pointer;
  transition: opacity 0.12s;
}

button.exercise-thumb:hover {
  opacity: 0.82;
}

.exercise-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.exercise-card-name {
  flex: 0 0 auto;
  min-width: 140px;
  max-width: 420px;
  width: auto;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: left !important;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  box-shadow: none !important;
  height: 36px !important;
  min-height: unset !important;
  color: var(--ink);
  line-height: 36px;
}

.exercise-card-name::placeholder {
  color: var(--muted);
  opacity: 0.5;
  font-weight: 400;
}

.exercise-card-name:focus {
  outline: none;
}

/* Flexible spacer between name and history icon */
.header-spacer {
  flex: 1;
  min-width: 8px;
}

.exercise-history-icon {
  flex-shrink: 0;
  font-size: 0.82rem;
  opacity: 0.3;
  line-height: 1;
  user-select: none;
  cursor: default;
}

/* ── Card Body — shared ── */
.exercise-card-body {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 16px 14px 12px;
}

/* ── Chevron toggle button ── */
.exercise-chevron {
  flex-shrink: 0;
  font-size: 1.1rem;
  color: var(--muted);
  opacity: 0.5;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  /* align-items: flex-end on body + margin-bottom centers chevron with 56px pill:
     labels(~17px) + pill(56px) = 73px total. flex-end aligns bottom.
     margin-bottom = (56 - ~20chevron) / 2 = 18px → chevron center at pill center */
  margin-bottom: 18px;
  line-height: 1;
  transition: opacity 0.12s, color 0.12s;
}

.exercise-chevron:hover {
  opacity: 0.9;
  color: var(--ink);
}

/* Detailed: top-aligned, centered within header row height (32px) */
.exercise-card-body--detailed {
  align-items: flex-start;
}

.exercise-chevron--open {
  opacity: 0.7;
  margin-bottom: 0;
  /* (header-row 32px - chevron ~20px) / 2 = 6px top offset */
  margin-top: 6px;
}

/* ── Pill area (labels + pill box) ── */
.pill-area {
  flex: 1;
  min-width: 0;
}

/* Column spec: SET=60px fixed, WEIGHT/REPS/REST=1fr equal, RPE=70px fixed.
   Total fixed: 130px. Remaining flexible space split evenly 3 ways.
   Applied identically to pill-labels, pill-box, and every pill-set-row. */
:root { --pill-cols: 60px 1fr 1fr 70px 1fr; }

/* Labels row — above simple pill.
   Horizontal padding MUST match .pill-box so column positions align. */
.pill-labels {
  display: grid;
  grid-template-columns: var(--pill-cols);
  gap: 8px;
  padding: 0 8px 6px;
}

.pill-labels span {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94A3B8;
  line-height: 1;
}

/* ── Pill box — single border, values as inputs ── */
.pill-box {
  display: grid;
  grid-template-columns: var(--pill-cols);
  gap: 8px;
  align-items: center;
  height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 0 8px;
  box-sizing: border-box;
  overflow: hidden;
}

/* Input values inside pill */
.pill-value {
  min-width: 0;
  width: 100%;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  background: none;
  border: none;
  padding: 4px 4px;
  transition: background 0.1s;
}

.pill-value:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
}

.pill-value::placeholder {
  color: #94A3B8;
  opacity: 1;
  font-weight: 400;
  font-size: 16px;
}

/* ── Pill box — expanded / detailed mode ── */
.pill-box--expanded {
  height: auto;
  display: flex;
  flex-direction: column;
  /* align-items: center comes from .pill-box (simple pill vertical centering).
     In flex-column, center = horizontal centering → rows shrink-wrap → 1fr
     columns collapse. Override to stretch so rows fill full width. */
  align-items: stretch;
  /* gap: 8px from .pill-box is flex row-gap in column mode — creates 8px space
     between rows, making borders float. Reset to 0 for tight row dividers. */
  gap: 0;
  padding: 0;
  overflow: hidden;
}

/* All rows (header + data) share the same grid — alignment guaranteed.
   gap and horizontal padding MUST match across header and data rows.
   width: 100% ensures full stretch even if parent flex container
   somehow doesn't stretch (belt-and-suspenders for alignment). */
.pill-set-row {
  display: grid;
  grid-template-columns: var(--pill-cols);
  gap: 8px;
  align-items: center;
  width: 100%;
  height: 48px;
  padding: 0 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-sizing: border-box;
}

.pill-set-row:last-child {
  border-bottom: none;
}

/* Header row styling */
.pill-set-row--header {
  height: 32px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
}

.pill-set-row--header span {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94A3B8;
  text-align: center;
}

.pill-set-num {
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.pill-set-field {
  min-width: 0;
  width: 100%;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  background: none;
  border: none;
  padding: 4px 4px;
  transition: background 0.1s;
}

.pill-set-field:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
}

.pill-set-field::placeholder {
  color: var(--muted);
  opacity: 0.55;
  font-size: 0.82rem;
  font-weight: 400;
}

.exercise-detail-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
}

/* ── Varies display: read-only span shown in simple pill when sets differ ── */
.pill-varies-val {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  opacity: 0.9;
  cursor: default;
  position: relative;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill-varies-val[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: var(--elevated, #1e293b);
  color: var(--ink);
  font-size: 0.72rem;
  line-height: 1.6;
  white-space: pre;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
  min-width: max-content;
}

.pill-varies-val[data-tooltip]:hover::after {
  opacity: 1;
}

/* ── Note Box — 3-state pill system (card-level, below body) ── */
.exercise-card-note {
  display: block;
  text-align: left;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  padding: 8px 14px 12px;
}

/* Default hidden state for all children */
.exercise-card-note .note-display-row,
.exercise-card-note .card-note-input {
  display: none;
}

/* Empty state: show pill, hide others */
[data-note-state="empty"] .note-add-pill {
  display: inline-flex;
  align-items: center;
  margin: 0;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  border: none;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

[data-note-state="empty"] .note-add-pill:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

[data-note-state="empty"] .note-display-row,
[data-note-state="empty"] .card-note-input {
  display: none;
}

/* Display state: show text row */
[data-note-state="display"] .note-add-pill,
[data-note-state="display"] .card-note-input {
  display: none;
}

[data-note-state="display"] .note-display-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
  cursor: pointer;
  padding: 4px 0;
}

/* Notion-style vertical bar accent — replaces 💬 emoji */
[data-note-state="display"] .note-display-row::before {
  content: '';
  width: 3px;
  background: rgba(148, 163, 184, 0.5);
  border-radius: 1px;
  flex-shrink: 0;
}

[data-note-state="display"] .note-display-row:hover .note-delete-btn {
  opacity: 1;
}


.note-display-text {
  flex: 1;
  align-self: center;
  font-size: 0.875rem;
  color: var(--ink);
  line-height: 1.5;
  word-break: break-word;
}

.note-delete-btn {
  flex-shrink: 0;
  opacity: 0;
  font-size: 0.75rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  border-radius: 4px;
  transition: opacity 0.12s, background 0.12s;
}

.note-delete-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
}

/* Edit state: show textarea */
[data-note-state="edit"] .note-add-pill,
[data-note-state="edit"] .note-display-row {
  display: none;
}

[data-note-state="edit"] .card-note-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid rgba(148, 163, 184, 0.7);
  border-radius: 0 6px 6px 0;
  padding: 8px 12px;
  resize: none;
  font-family: inherit;
  field-sizing: content;
  min-height: 38px;
  overflow: hidden;
  transition: border-color 0.15s;
}

[data-note-state="edit"] .card-note-input:focus {
  outline: none;
  border-left-color: rgba(148, 163, 184, 0.9);
}

.card-note-input::placeholder {
  color: #6B7280;
  font-style: italic;
}

/* Hide the "note-add-pill" by default (only shown in [data-note-state=empty]) */
.note-add-pill {
  display: none;
}

/* ── Light theme overrides ── */
:root[data-theme="light"] .exercise-card {
  border-color: rgba(0, 0, 0, 0.09);
  background: rgba(0, 0, 0, 0.015);
}

:root[data-theme="light"] .exercise-card-header {
  background: rgba(0, 0, 0, 0.03);
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

:root[data-theme="light"] [data-note-state="empty"] .note-add-pill {
  background: rgba(0, 0, 0, 0.04);
}

:root[data-theme="light"] [data-note-state="edit"] .card-note-input {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.10);
}

:root[data-theme="light"] .pill-box {
  border-color: rgba(0, 0, 0, 0.12);
  background: rgba(0, 0, 0, 0.02);
}

:root[data-theme="light"] .pill-labels span {
  color: #64748b;
}

:root[data-theme="light"] .pill-set-row {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

:root[data-theme="light"] .pill-value:focus,
:root[data-theme="light"] .pill-set-field:focus {
  background: rgba(0, 0, 0, 0.04);
}

:root[data-theme="light"] .card-note-input {
  border-color: rgba(0, 0, 0, 0.08);
}

:root[data-theme="light"] .card-note-input:focus {
  border-color: rgba(0, 0, 0, 0.16);
}

:root[data-theme="light"] .exercise-card-drag:hover {
  background: rgba(0, 0, 0, 0.06);
}

:root[data-theme="light"] .exercise-thumb {
  background: rgba(0, 0, 0, 0.06);
}

:root[data-theme="light"] .pill-value::placeholder {
  color: #94a3b8;
}

/* ══════════════════════════════════════════════════════════════════════════
   CALENDAR INTERACTIVE UX — drag ghost, context menu, confirm modals
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Drag-and-drop ghost that follows cursor ── */
.cal-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9998;
  border-left: 4px solid #38bdf8;
  background: #e0f2fe;
  color: #075985;
  padding: 5px 12px;
  font-size: 0.78rem;
  font-weight: 750;
  border-radius: 4px;
  max-width: 230px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.24);
  opacity: 0.9;
  transform: rotate(1.5deg) scale(1.04);
}

.cal-drag-ghost.status-completed {
  border-left-color: var(--teal);
  background: var(--mint);
  color: var(--teal-dark);
}

.cal-drag-ghost.status-cancelled,
.cal-drag-ghost.status-late_cancelled {
  border-left-color: #b7791f;
  background: #fef3c7;
  color: #92400e;
}

/* ── Day cell highlighted as drop target ── */
.calendar-day.cal-drop-target {
  background: #f0fdfa !important;
  box-shadow: inset 0 0 0 2px var(--teal) !important;
}

/* ── Custom right-click context menu ── */
.cal-context-menu {
  position: fixed;
  z-index: 10000;
  display: none;
  flex-direction: column;
  min-width: 185px;
  background: var(--surface, #fff);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
}

.cal-context-menu.visible {
  display: flex;
}

.cal-context-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 550;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s;
}

.cal-context-menu-item:hover {
  background: var(--field-hover, rgba(0, 0, 0, 0.05));
}

.cal-context-menu-item.danger {
  color: #dc2626;
}

.cal-context-menu-item.danger:hover {
  background: #fef2f2;
}

.cal-context-menu-sep {
  height: 1px;
  background: var(--line);
  margin: 4px 6px;
}

/* Hide Duplicate + separator when right-clicking a draft chip */
.cal-ctx-draft [data-cal-action="duplicate"],
.cal-ctx-draft .cal-context-menu-sep {
  display: none;
}

/* ── Shared modal overlay for calendar confirmations ── */
.cal-confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  padding: 24px;
}

.cal-confirm-modal.visible {
  display: flex;
}

.cal-confirm-dialog {
  background: var(--surface, #fff);
  border-radius: 16px;
  padding: 28px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
  display: grid;
  gap: 18px;
}

.cal-confirm-dialog h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}

.cal-confirm-dialog .note {
  margin: 0;
}

.cal-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.cal-confirm-actions button {
  padding: 9px 22px;
  border-radius: 9px;
  border: none;
  font-size: 0.88rem;
  font-weight: 650;
  cursor: pointer;
  transition: background 0.15s;
}

.cal-btn-cancel {
  background: var(--raised, #f1f5f9);
  color: var(--ink);
}

.cal-btn-cancel:hover {
  background: var(--field-hover, #e2e8f0);
}

.cal-btn-danger {
  background: #dc2626;
  color: #fff;
}

.cal-btn-danger:hover {
  background: #b91c1c;
}

.cal-btn-primary {
  background: var(--teal, #0f766e);
  color: #fff;
}

.cal-btn-primary:hover {
  background: var(--teal-dark, #0d6b64);
}

/* ── Duplicate modal date picker ── */
.cal-duplicate-date {
  display: grid;
  gap: 8px;
}

.cal-duplicate-date label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cal-duplicate-date input[type="date"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--field, #f8fafc);
  color: var(--ink);
  box-sizing: border-box;
}
