:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --card: #fffefd;
  --ink: #1d1d1f;
  --muted: #7a7d84;
  --line: #e3dfd6;
  --brand: #335f52;
  --accent: #3f7567;
  --good: #0f766e;
  --warn: #b45309;
  --danger: #b42318;
  --scap: #6d28d9;
  --core: #c2410c;
  --stretch: #3f6212;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--card);
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--card);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: 108px;
}

body::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0 0 160px 0;
  background: var(--bg);
}

button, input, select, textarea {
  font: inherit;
  color-scheme: light;
}

button {
  min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

input, select, textarea {
  font-size: 16px;
  background: var(--card);
  color: var(--ink);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: calc(18px + env(safe-area-inset-top)) 22px 8px;
  background: var(--card);
  border-bottom: 0;
}

.app-header h1 {
  font-size: 34px;
  line-height: 1.1;
  margin: 22px 0 14px;
  font-weight: 760;
  letter-spacing: -.035em;
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  color: var(--brand);
}


.brand-lockup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--brand);
}

.brand-word {
  font-size: 13px;
  line-height: 1;
  font-weight: 520;
  letter-spacing: .01em;
  color: var(--ink);
}

.brand-mark {
  width: 24px;
  height: 19px;
  position: relative;
  display: inline-block;
  color: var(--brand);
}

.brand-mark::before {
  content: "";
  position: absolute;
  top: 1px;
  right: 0;
  width: 13px;
  height: 13px;
  border: 3px solid currentColor;
  border-left: 0;
  border-bottom: 0;
  border-radius: 0 9px 0 0;
}

.brand-mark::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 0;
  width: 13px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(44deg);
  transform-origin: right center;
}

.brand-mark span {
  position: absolute;
  left: 0;
  width: 11px;
  height: 3px;
  border-radius: 999px;
  background: currentColor;
}

.brand-mark span:nth-child(1) { top: 3px; }
.brand-mark span:nth-child(2) { top: 8px; width: 8px; opacity: .78; }
.brand-mark span:nth-child(3) { top: 13px; }
.brand-mark.large {
  width: 56px;
  height: 44px;
  color: var(--brand);
}
.brand-mark.large::before {
  width: 31px;
  height: 31px;
  border-width: 6px;
  border-radius: 0 18px 0 0;
}
.brand-mark.large::after {
  right: 4px;
  width: 30px;
  height: 6px;
}
.brand-mark.large span {
  width: 25px;
  height: 6px;
}
.brand-mark.large span:nth-child(1) { top: 7px; }
.brand-mark.large span:nth-child(2) { top: 19px; width: 18px; }
.brand-mark.large span:nth-child(3) { top: 31px; }
.icon-btn {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  width: 46px;
  height: 46px;
  font-size: 20px;
}

main {
  width: 100%;
  max-width: 760px;
  margin: auto;
  padding: 0 22px 28px;
  background: var(--card);
  min-height: calc(100dvh - 122px - 108px);
}

.hero {
  background: #1d1d1f;
  color: #fff;
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 12px;
}

.hero h2 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.15;
}

.hero p {
  margin: 0;
  color: rgba(255, 255, 255, .82);
  line-height: 1.45;
}

.workout-home {
  min-height: calc(100dvh - 156px - 108px);
  display: grid;
  align-content: start;
  gap: 12px;
}

.routine-row {
  width: 100%;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  border-radius: 12px;
  background: #f1f3f7;
  color: var(--ink);
  padding: 18px 22px;
  text-align: left;
}

.routine-row span {
  font-size: 22px;
  font-weight: 850;
}

.routine-row b {
  font-size: 28px;
  font-weight: 500;
}

.routine-row.active-draft {
  background: #1d1d1f;
  color: #fff;
}

.day-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.day-card, .exercise-card, .summary-card, .history-card, .backup-card, .resume-card, .finish-warning {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(29, 29, 31, .045);
}

.day-card {
  padding: 14px;
}

.day-card .day {
  min-height: 44px;
  font-weight: 850;
  font-size: 18px;
  line-height: 1.18;
}

.day-card .meta {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 12px;
}

.primary-btn, .secondary-btn, .danger-btn, .tab-btn {
  border: none;
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 800;
  font-size: 15px;
}

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

.secondary-btn, .tab-btn {
  background: #edf3ef;
  color: #335f52;
}

.danger-btn {
  background: #fee4e2;
  color: var(--danger);
}

.small-btn {
  min-height: 40px;
  padding: 2px 10px 14px;
  font-size: 13px;
}

.full {
  width: 100%;
  margin-top: 8px;
}

.resume-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

.resume-card span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.section-title {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  margin: 20px 4px 8px;
  color: var(--muted);
}

.section-title.scap, .section-title.activation { color: var(--scap); }
.section-title.core { color: var(--core); }
.section-title.stretch { color: var(--stretch); }

.exercise-card {
  padding: 14px;
  margin: 9px 0;
  border-left: 4px solid transparent;
}

.today-hero {
  background: #1d1d1f;
  color: #fff;
  border-radius: 14px;
  padding: 18px;
  margin: 6px 0 12px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
}

.today-hero span, .section-kicker {
  display: block;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

.today-hero span {
  color: rgba(255, 255, 255, .68);
}

.today-hero h2 {
  margin: 6px 0;
  font-size: 28px;
  line-height: 1.1;
}

.today-hero p {
  margin: 0;
  color: rgba(255, 255, 255, .76);
  line-height: 1.45;
}

.import-ready-card {
  background: #edf7f3;
  border-color: #b7d6cb;
}

.import-pending-card {
  background: #faf9f5;
}

.import-ready-card span, .import-pending-card span {
  display: block;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--brand);
}

.import-ready-card h2, .import-pending-card h2 {
  margin-top: 6px;
}

.exercise-card.warmup { border-left-color: var(--warn); }
.exercise-card.simple { border-left-color: var(--stretch); }
.exercise-card.activation { border-left-color: var(--scap); }
.exercise-card.core { border-left-color: var(--core); }

.exercise-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.exercise-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.exercise-summary > div,
.exercise-result > span {
  min-width: 0;
}

.exercise-thumb {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--line);
}

.exercise-thumb.placeholder {
  display: inline-block;
  background: linear-gradient(135deg, #edf2f7, #f8fafc);
}

.exercise-name {
  font-size: 17px;
  line-height: 1.25;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.warmup-label {
  display: inline-block;
  margin-top: 5px;
  color: var(--warn);
  font-size: 12px;
  font-weight: 850;
}

.prescription {
  flex: 0 1 auto;
  font-size: 13px;
  color: var(--brand);
  font-weight: 800;
  text-align: right;
  overflow-wrap: anywhere;
}

.last {
  display: block;
  width: 100%;
  border: 0;
  text-align: left;
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
  padding: 9px 10px;
  background: #faf9f5;
  border-radius: 14px;
  line-height: 1.45;
}

.last b, .last span {
  display: block;
}

.last.empty {
  font-weight: 700;
}

.last-fill {
  cursor: pointer;
}

.last-fill em {
  display: block;
  margin-top: 4px;
  color: var(--brand);
  font-style: normal;
  font-weight: 850;
}

.progress-note {
  margin-top: 8px;
  color: var(--good);
  font-size: 13px;
  font-weight: 750;
}

.labels, .set-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) minmax(0, 1fr) minmax(0, .85fr) 58px;
  gap: 6px;
  align-items: center;
}

.labels {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  margin-top: 12px;
  text-align: center;
  text-transform: uppercase;
}

.set-row {
  margin-top: 8px;
}

.set-n {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.set-row input {
  width: 100%;
  min-width: 0;
  height: 46px;
  padding: 9px 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  text-align: center;
}

.set-row.saved input {
  border-color: #b7e2d8;
  background: #f0fdfa;
}

.set-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.set-actions button {
  min-width: 0;
  height: 46px;
  border: none;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 900;
}

.save-set {
  background: #dcfce7;
  color: #166534;
}

.delete-set {
  background: #fee2e2;
  color: #991b1b;
}

.simple-done {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.done-badge {
  color: var(--good);
  font-weight: 850;
}

.workout-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0 18px;
}

.timer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #1d1d1f;
  color: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 10px 0;
}

.timer strong {
  font-variant-numeric: tabular-nums;
  font-size: 22px;
}

.timer div {
  display: flex;
  gap: 6px;
}

.timer button {
  border: none;
  background: #3f7567;
  color: #fff;
  border-radius: 14px;
  padding: 8px 10px;
  font-size: 13px;
}

.summary-card, .history-card, .backup-card {
  padding: 15px;
  margin: 10px 0;
}

.summary-card h2, .history-card h3, .backup-card h3 {
  margin: 0 0 8px;
}

.finish-warning {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 12px;
  margin-bottom: 10px;
  border-color: #fedf89;
}

.finish-warning span {
  color: var(--muted);
  font-size: 13px;
}

.finish-summary {
  text-align: center;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.metric-grid div {
  background: #faf9f5;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}

.metric-grid b, .metric-grid span {
  display: block;
}

.metric-grid b {
  font-size: 22px;
}

.metric-grid span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.history-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 2px 0 10px;
}

.tab-btn.active {
  background: #dbeafe;
  color: var(--accent);
}

.history-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.history-card .sub, .history-metrics {
  color: var(--muted);
  font-size: 13px;
}

.history-metrics {
  margin: 8px 0;
  font-weight: 750;
}

.session-lines {
  font-size: 13px;
  line-height: 1.5;
}

.session-lines p {
  margin: 9px 0 0;
}

.exercise-select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 9px 6px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.backup-card p {
  line-height: 1.45;
}

.backup-card button + button, .backup-card input + button {
  margin-top: 8px;
}

.backup-card input[type="file"] {
  width: 100%;
  min-height: 46px;
}

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

.setting-row input,
.setting-row select {
  width: 110px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
}

.profile-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}
.profile-avatar {
  width: 82px;
  height: 82px;
  border-radius: 50%;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #e9f1ed;
  color: var(--brand);
  font-size: 30px;
  font-weight: 900;
  border: 1px solid var(--line);
  cursor: pointer;
}
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-avatar input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}
.profile-info input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px;
  font-size: 18px;
  font-weight: 850;
}

.bottom-nav {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(382px, calc(100vw - 44px));
  z-index: 20;
  display: flex;
  gap: 0;
  height: 84px;
  align-items: center;
  padding: 8px 10px;
  background: rgba(255, 254, 253, .9);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(29, 29, 31, .22);
  border-radius: 999px;
  box-shadow: 0 18px 42px rgba(29, 29, 31, .13);
}

.nav-btn {
  flex: 1;
  min-height: 66px;
  display: grid;
  place-items: center;
  gap: 1px;
  border: none;
  border-radius: 999px;
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 850;
  color: var(--muted);
  background: transparent;
}

.nav-icon {
  display: block;
  font-size: 28px;
  line-height: 1;
  font-weight: 500;
}

.nav-btn.active {
  background: #e9f1ed;
  color: var(--accent);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  background: #1d1d1f;
  color: #fff;
  text-align: center;
  font-weight: 700;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.onboarding-screen { max-width: 520px; margin: 24px auto; padding: 20px 0 32px; }
.onboarding-screen h2 { margin: 18px 0 10px; font-size: 26px; }
.onboarding-mark { display: grid; justify-items: center; gap: 10px; color: var(--brand); font-size: 24px; font-weight: 560; letter-spacing: -.02em; }
.welcome-screen { padding-top: 18vh; text-align: center; }
.welcome-screen p { max-width: 430px; margin: 0 auto 24px; line-height: 1.55; }
.text-btn { border: 0; background: transparent; color: var(--brand); min-height: 44px; font-weight: 800; }
.progress-label { color: var(--muted); font-size: 12px; font-weight: 800; }
.choice-grid { display: grid; gap: 9px; margin: 20px 0; }
.choice-card { min-height: 50px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); text-align: left; font-weight: 800; }
.choice-card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--card)); }
.onboarding-input { display: block; margin: 24px 0; color: var(--muted); font-weight: 800; }
.onboarding-input input { display: block; width: 100%; margin-top: 8px; min-height: 52px; border: 1px solid var(--line); border-radius: 14px; padding: 12px; font-size: 22px; }
.onboarding-actions { display: flex; gap: 8px; align-items: center; margin-top: 24px; }
.onboarding-actions .primary-btn { margin-left: auto; }
.social-stack { display: grid; gap: 8px; margin: 18px 0; }
.or-divider { text-align: center; color: var(--muted); margin: 3px 0; }
.field-error { padding: 10px; border: 1px solid #fecaca; border-radius: 14px; color: var(--danger); background: #fef2f2; }
.field-help { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.password-field { display: flex; gap: 6px; margin-top: 5px; }
.password-field input { flex: 1; min-width: 0; }
.password-field button { min-width: 64px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--brand); font-weight: 800; }

.program-card, .builder-day, .builder-section, .builder-exercise, .builder-head {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 10px 0;
  padding: 12px;
}
.active-program-card {
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(37, 99, 235, .12);
}
.create-program-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.import-upload { display: grid; gap: 12px; }
.import-upload input[type="file"] { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
.upload-row { cursor: pointer; }
.import-status { min-height: 32px; color: var(--muted); font-size: 14px; }
.loading-state { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; }
.loading-spinner { width: 18px; height: 18px; border: 3px solid #d9e6df; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.import-warning { border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin: 10px 0; font-size: 13px; }
.import-warning.warning { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.import-warning.error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.import-warning.info { background: #edf7f3; border-color: #b7d6cb; color: var(--brand); }
.unparsed { border-top: 1px solid var(--line); padding: 10px 0; }
.unparsed b, .unparsed span { display: block; font-size: 13px; overflow-wrap: anywhere; }
.unparsed span { color: var(--muted); margin: 3px 0 7px; }
.unparsed button { min-height: 34px; margin-right: 5px; border: 1px solid var(--line); border-radius: 14px; background: #faf9f5; color: var(--brand); font-weight: 750; }
.match-status { display: inline-block; padding: 3px 6px; border-radius: 14px; font-size: 11px; font-weight: 850; margin-bottom: 6px; background: #fef3c7; color: #92400e; }
.match-status.matched { background: #dcfce7; color: #166534; }
.match-status.custom { background: #edf3ef; color: #335f52; }
.import-exercise > .small { margin: 3px 0 8px; }
.program-card, .builder-row, .compact-fields, .builder-actions { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.program-card > div:first-child { min-width: 0; }
.program-card b, .program-card span { display: block; }
.program-card span, .video-result small { color: var(--muted); font-size: 12px; margin-top: 3px; }
.program-section { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 9px; }
.program-section > b { display: block; font-size: 13px; }
.program-exercise { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0 0; font-size: 13px; }
.program-exercise span { min-width: 0; overflow-wrap: anywhere; }
.program-exercise small { color: var(--muted); text-align: right; overflow-wrap: anywhere; }
.compact-actions, .order-actions { display: flex; gap: 5px; flex-wrap: wrap; }
.compact-actions button, .order-actions button, .section-options button, .builder-add button, .instruction-row button, .details button, .video-link {
  min-height: 36px; border: 1px solid var(--line); border-radius: 14px; background: #faf9f5; color: var(--brand); font-weight: 750; padding: 7px 9px;
}
.builder-head input, .builder-head textarea, .builder-row input, .builder-row select, .builder-add input, .instruction-row input, .compact-fields input, .detail-grid input, .individual-set input, .individual-set select {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); padding: 10px;
}
.builder-head textarea { min-height: 70px; margin-top: 8px; resize: vertical; }
.builder-actions { margin-top: 8px; }
.builder-row input { font-weight: 800; }
.builder-row select { max-width: 145px; }
.builder-section { border-left: 4px solid var(--accent); }
.builder-section-hidden {
  background: transparent;
  border: 0;
  border-radius: 0;
  margin: 8px 0 0;
  padding: 0;
}
.section-options { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.section-options button { font-size: 12px; min-height: 34px; }
.builder-add, .instruction-row { display: flex; gap: 7px; margin-top: 9px; }
.builder-add button { flex: 0 0 auto; }
.search-results { display: grid; gap: 5px; margin-top: 6px; }
.search-results button { text-align: left; background: #faf9f5; border: 1px solid var(--line); border-radius: 14px; padding: 9px; color: var(--ink); }
.search-results span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.search-results .exercise-result {
  display: flex;
  align-items: center;
  gap: 11px;
}
.exercise-result b,
.exercise-result small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.exercise-result small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}
.exercise-picker { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.exercise-picker > input { width: 100%; min-width: 0; margin: 8px 0; padding: 11px; border: 1px solid var(--line); border-radius: 14px; }
.exercise-pool-page {
  display: grid;
  gap: 10px;
}
.picker-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.picker-filters { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: thin; }
.picker-filters button { flex: 0 0 auto; min-height: 36px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 14px; background: #faf9f5; color: var(--ink); font-weight: 700; }
.picker-filters button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.exercise-pool-results {
  display: grid;
  gap: 14px;
}
.exercise-pool-group {
  display: grid;
  gap: 6px;
}
.exercise-pool-group h3 {
  margin: 4px 0 0;
  font-size: 18px;
}
.custom-exercise-result {
  margin-top: 4px;
}
.builder-exercise { background: #faf9f5; margin: 9px 0 0; }
.simple-builder-head {
  display: grid;
  gap: 10px;
}
.simple-builder-head .builder-actions {
  margin-top: 0;
}
.simple-builder-day {
  border-radius: 16px;
  padding: 14px;
}
.simple-day-label {
  display: grid;
  gap: 5px;
  flex: 1;
  min-width: 0;
}
.simple-day-label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}
.simple-builder-section {
  border-left: 0;
}
.simple-builder-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}
.builder-exercise-shell {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  margin: 9px 0 0;
  background: #ef4444;
}
.builder-delete-action {
  position: absolute;
  inset-block: 0;
  right: 0;
  width: 92px;
  border: 0;
  background: #ef4444;
  color: #fff;
  font-weight: 900;
  font-size: 15px;
}
.simple-builder-exercise {
  position: relative;
  z-index: 1;
  margin: 0;
  border-radius: 14px;
  background: #faf9f5;
  transition: transform .18s ease, box-shadow .12s ease, opacity .12s ease;
  touch-action: pan-y;
}
.simple-builder-exercise.swiped {
  transform: translateX(-92px);
}
.builder-exercise-shell.dragging .simple-builder-exercise {
  box-shadow: 0 14px 34px rgba(15, 23, 42, .18);
  opacity: .88;
  transform: scale(.985);
}
.builder-exercise-shell.drop-before {
  margin-top: 24px;
}
.builder-exercise-shell.drop-before::before,
.builder-exercise-shell.drop-after::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
  z-index: 3;
}
.builder-exercise-shell.drop-before::before {
  top: -14px;
}
.builder-exercise-shell.drop-after {
  margin-bottom: 24px;
}
.builder-exercise-shell.drop-after::after {
  bottom: -14px;
}
.builder-exercise-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}
.builder-exercise-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.builder-exercise-title b {
  min-width: 0;
  overflow-wrap: anywhere;
}
.drag-handle {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--muted);
  font-size: 18px;
  font-weight: 900;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.drag-handle:active {
  cursor: grabbing;
}
.is-dragging-builder-exercise {
  user-select: none;
}
.compact-fields { align-items: end; margin-top: 9px; }
.compact-fields label, .detail-grid label { font-size: 11px; font-weight: 800; color: var(--muted); min-width: 0; }
.compact-fields input { margin-top: 3px; }
.builder-main-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 42px;
}
.detail-toggle-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--brand);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}
.details { display: none; margin-top: 10px; }
.details.open { display: block; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-bottom: 8px; }
.individual-set { display: grid; grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 5px; align-items: center; margin-top: 7px; }
.individual-set select:last-child { grid-column: 2 / -1; }
.individual-set button { min-height: 34px; grid-column: 2 / -1; }
.video-name-link {
  min-height: 0;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.video-results { display: grid; gap: 8px; margin-top: 10px; }
.video-result { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 9px; text-align: left; border: 1px solid var(--line); border-radius: 14px; background: var(--card); padding: 6px; color: var(--ink); }
.video-result img { width: 104px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 5px; }
.video-result b, .video-result small { display: block; overflow-wrap: anywhere; }
.video-player iframe { border: 0; width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; }
.recovery-link {
  position: fixed;
  left: 50%;
  bottom: calc(94px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid #f4b4ab;
  border-radius: 999px;
  background: #fff1f0;
  color: #b42318;
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 24px rgba(180, 35, 24, .12);
}

.progress {
  height: 7px;
  background: #e5e7eb;
  border-radius: 20px;
  overflow: hidden;
  margin: 8px 0 2px;
}

.progress > div {
  height: 100%;
  background: var(--accent);
}

@media (max-width: 420px) {
  main { padding-left: 10px; padding-right: 10px; }
  .day-grid { grid-template-columns: 1fr; }
  .exercise-card { padding: 12px; }
  .exercise-head { display: block; }
  .prescription { margin-top: 6px; white-space: normal; }
  .labels, .set-row {
    grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr) 56px;
    gap: 5px;
  }
  .set-row input {
    padding-left: 4px;
    padding-right: 4px;
  }
  .finish-warning {
    grid-template-columns: 1fr 1fr;
  }
  .finish-warning b, .finish-warning span {
    grid-column: 1 / -1;
  }
  .program-card { align-items: flex-start; }
  .program-card, .builder-row, .compact-fields { flex-wrap: wrap; }
  .builder-main-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 42px; }
  .program-card > .compact-actions { width: 100%; }
  .compact-fields label { flex: 1 1 90px; }
  .compact-fields button { flex: 1 1 100%; }
  .builder-main-fields .detail-toggle-btn { flex: 0 0 42px; }
  .onboarding-screen { margin-top: 8px; padding-left: 2px; padding-right: 2px; }
  .welcome-screen { padding-top: 12vh; }
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: light;
    --bg: #f7f5ef;
    --card: #fffefd;
    --ink: #1d1d1f;
    --muted: #7a7d84;
    --line: #e3dfd6;
    --brand: #335f52;
    --accent: #3f7567;
  }
  html, body, main, .app-header { background: var(--card); color: var(--ink); }
  body::before { background: var(--bg); }
  .bottom-nav { background: rgba(255, 254, 253, .94); }
  input, select, textarea { background: var(--card); color: var(--ink); }
  .set-row input { background: var(--card); color: var(--ink); }
  .set-row.saved input { background: #f0fdfa; color: var(--ink); }
  .secondary-btn, .tab-btn { background: #edf3ef; color: #335f52; }
  .nav-btn.active { background: #e9f1ed; }
}
