:root {
  --bg-start: #1a0308;
  --bg-end: #6b1128;
  --accent: #fdd787;
  --accent-strong: #ffb359;
  --txt-light: #fdfdfd;
  --txt-muted: rgba(253, 228, 230, 0.8);
  --card-bg: rgba(50, 6, 16, 0.68);
  --card-border: rgba(255, 110, 130, 0.22);
  --input-border: rgba(255, 141, 160, 0.32);
  --surface-hover: rgba(255, 110, 130, 0.14);
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 999px;
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 24px rgba(0, 0, 0, 0.22);
  --shadow-sm: 0 6px 16px rgba(0, 0, 0, 0.18);
  --max-width: min(1080px, 92vw);
  --font-display: "Outfit", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: middle;
}

.icon path,
.icon rect,
.icon circle,
.icon line,
.icon polyline,
.icon polygon {
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--txt-light);
  background: linear-gradient(148deg, var(--bg-start), var(--bg-end));
  min-height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 4rem;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

header.site-header {
  width: 100%;
  padding: clamp(1rem, 3vw, 1.75rem) clamp(1rem, 5vw, 2rem) 0;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(0.5rem, 2vw, 1rem);
  margin-right: auto;
}

.brand img {
  height: clamp(56px, 20vw, 112px);
  width: auto;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.45));
}

.brand span {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.25rem, 10vw, 3.875rem);
  text-shadow: 0 14px 28px rgba(0, 0, 0, 0.45);
  letter-spacing: -0.01em;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(0.75rem, 3vw, 1.5rem);
  position: relative;
}

.header-actions {
  display: flex;
  align-items: center;
  position: relative;
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(253, 253, 253, 0.18);
  background: rgba(253, 253, 253, 0.08);
  color: var(--txt-light);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.menu-toggle:hover,
.menu-toggle:focus,
.menu-toggle:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 179, 89, 0.42);
  background: rgba(253, 215, 135, 0.14);
  outline: none;
}

.menu-toggle:active {
  transform: translateY(1px);
}

.menu-toggle.is-open {
  background: rgba(253, 215, 135, 0.24);
  border-color: rgba(255, 179, 89, 0.5);
}

.menu-toggle .icon {
  width: 1.2em;
  height: 1.2em;
}

.header-menu {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  min-width: 190px;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: rgba(20, 18, 27, 0.94);
  border: 1px solid rgba(253, 253, 253, 0.12);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 40;
}

.header-menu[hidden] {
  display: none;
}

.header-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: calc(var(--radius-sm) * 1.2);
  font-weight: 600;
  font-size: 0.95rem;
  color: rgba(253, 253, 253, 0.88);
  transition: background 0.18s ease, color 0.18s ease;
}

.header-menu a:hover,
.header-menu a:focus,
.header-menu a:focus-visible {
  background: rgba(253, 215, 135, 0.16);
  color: var(--txt-light);
  outline: none;
}

.header-menu a.is-active {
  background: rgba(253, 215, 135, 0.28);
  color: var(--txt-light);
}

.header-menu a.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

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

main {
  width: 100%;
  max-width: var(--max-width);
  margin: clamp(1.5rem, 4vw, 2.6rem) auto clamp(2rem, 6vw, 3rem);
  padding: 0 clamp(1rem, 5vw, 2rem);
}

.account-summary {
  margin-top: 1.5rem;
  display: grid;
  gap: clamp(0.75rem, 3vw, 1.2rem);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.account-summary-item {
  background: rgba(253, 253, 253, 0.06);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 0.85rem 1rem;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.account-summary-item .summary-label {
  display: block;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--txt-muted);
  margin-bottom: 0.25rem;
}

.account-summary-item .summary-value {
  font-size: 1rem;
  font-weight: 600;
  color: var(--txt-light);
  word-break: break-word;
}

.account-summary--primary {
  margin-top: clamp(1rem, 4vw, 1.4rem);
}

.account-summary--secondary {
  margin-top: clamp(1.75rem, 4vw, 2.2rem);
}

.account-card--logged-in .account-profile-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: clamp(0.75rem, 3vw, 1.5rem);
  flex-wrap: wrap;
}

.account-card--logged-in .account-profile-header h1 {
  margin: 0;
}

.account-edit-controls {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.account-edit-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: calc(var(--radius-sm) * 1.2);
  background: rgba(253, 253, 253, 0.09);
  border: 1px solid rgba(253, 253, 253, 0.16);
  color: var(--txt-light);
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.account-edit-toggle:hover,
.account-edit-toggle:focus,
.account-edit-toggle:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 179, 89, 0.42);
  background: rgba(253, 215, 135, 0.16);
  outline: none;
}

.account-edit-toggle:active {
  transform: translateY(1px);
}

.account-edit-toggle.is-hidden {
  display: none;
}

.account-edit-toggle .icon {
  width: 1.1em;
  height: 1.1em;
}

.account-profile-form {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.profile-field-content {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.profile-field-text {
  font-size: 1.05rem;
  font-weight: 600;
}

.profile-field-input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(253, 253, 253, 0.18);
  background: rgba(253, 253, 253, 0.08);
  color: var(--txt-light);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.profile-field-input:focus,
.profile-field-input:focus-visible {
  outline: none;
  border-color: rgba(255, 179, 89, 0.52);
  box-shadow: 0 0 0 3px rgba(253, 215, 135, 0.15);
}

.profile-field-input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.account-profile-form:not(.is-editing) .profile-field-input {
  display: none;
}

.account-profile-form.is-editing .profile-field-text {
  display: none;
}

.account-edit-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.account-profile-form:not(.is-editing) .account-edit-actions {
  display: none;
}

.account-profile-form.is-busy .account-edit-actions .btn {
  pointer-events: none;
}

.account-section-title {
  margin: clamp(1.5rem, 4vw, 2rem) 0 0.75rem;
  font-size: 1.15rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(253, 228, 230, 0.82);
}

.status-message {
  font-size: 0.92rem;
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  border: 1px solid transparent;
}

.status-message[hidden] {
  display: none;
}

.status-message.is-success {
  background: rgba(102, 194, 171, 0.16);
  border-color: rgba(102, 194, 171, 0.45);
  color: #d8fff4;
}

.status-message.is-error {
  background: rgba(255, 110, 130, 0.16);
  border-color: rgba(255, 110, 130, 0.45);
  color: #ffd3dc;
}

.account-card--logged-in h1 {
  font-size: clamp(2rem, 6vw, 2.6rem);
  margin-bottom: 0.5rem;
}

.account-card--logged-out h1 {
  font-size: clamp(2rem, 7vw, 2.7rem);
  margin-bottom: 0.4rem;
}

.account-card--logged-out .btn-primary {
  font-size: 1.1rem;
  padding: 0.75rem 1.6rem;
}

.card {
  background: var(--card-bg);
  backdrop-filter: blur(28px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: clamp(1.4rem, 4vw, 2.4rem) clamp(1.25rem, 5vw, 2.4rem);
  box-shadow: var(--shadow-lg);
  margin-bottom: clamp(1.5rem, 4vw, 2.4rem);
}

.workout-topbar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: clamp(0.75rem, 3vw, 1.25rem);
}

.workout-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: calc(var(--radius-sm) * 1.2);
  border: 1px solid rgba(253, 253, 253, 0.18);
  background: rgba(253, 253, 253, 0.08);
  font-weight: 600;
  color: var(--txt-light);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.workout-back-link:hover,
.workout-back-link:focus,
.workout-back-link:focus-visible {
  background: rgba(253, 215, 135, 0.18);
  border-color: rgba(255, 179, 89, 0.42);
  transform: translateX(-1px);
  outline: none;
}

.workout-back-link .icon {
  width: 1.1em;
  height: 1.1em;
}

.workout-back-link .back-label {
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.card h1, .card h2 {
  font-family: var(--font-display);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-align: center;
  margin-bottom: clamp(0.5rem, 2vw, 0.9rem);
}

.card h1 {
  font-size: clamp(2.05rem, 7vw, 2.85rem);
}

.card h2 {
  font-size: clamp(1.4rem, 6vw, 1.9rem);
}

.muted { color: var(--txt-muted); }

form {
  display: flex;
  flex-direction: column;
  gap: clamp(0.65rem, 2vw, 0.9rem);
  width: 100%;
}

label {
  font-weight: 600;
  font-size: 0.95rem;
  display: block;
}

input[type="text"], input[type="email"], input[type="number"], textarea {
  width: 100%;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--input-border);
  background: rgba(253, 253, 253, 0.08);
  color: var(--txt-light);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: rgba(253, 253, 253, 0.55);
  box-shadow: 0 0 0 3px rgba(253, 253, 253, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: rgba(253, 253, 253, 0.08);
  color: var(--txt-light);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
  min-height: 42px;
  min-width: 42px;
}

.btn:hover,
.btn:focus-visible {
  transform: translateY(-1px);
  background: rgba(253, 253, 253, 0.16);
  border-color: rgba(253, 253, 253, 0.26);
  outline: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: #2a0509;
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(253, 253, 253, 0.24);
}

.btn-icon {
  font-size: 1.2rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.btn-icon .icon {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn .btn-label {
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

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

.welcome-container {
  text-align: center;
}

.welcome-heading {
  font-size: clamp(2.2rem, 9vw, 3.5rem);
  font-weight: 800;
  margin-bottom: 0.4rem;
}

.welcome-name {
  color: var(--accent-strong);
}

.welcome-subtext {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.user-id-display {
  text-align: center;
  margin-top: 1rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  align-items: center;
}

.user-id-display-name {
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.03em;
}

.library-card {
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 3vw, 1.6rem);
}

.library-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.library-controls .controls-left,
.library-controls .controls-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.library-table-wrapper {
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid rgba(253, 253, 253, 0.14);
  background: rgba(253, 253, 253, 0.02);
}

.library-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--txt-light);
}

.library-table thead {
  background: rgba(253, 253, 253, 0.08);
}

.library-table thead th {
  text-align: left;
  font-weight: 700;
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(253, 253, 253, 0.12);
  position: relative;
  font-size: 0.9rem;
}

.library-table thead th.status-column {
  min-width: 110px;
}

.library-table thead th .sort-icon {
  margin-left: 0.35rem;
  font-size: 0.85rem;
  opacity: 0.65;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.library-table thead th .sort-icon i {
  font-size: inherit;
  pointer-events: none;
}

.library-table thead th.column-actions,
.library-table tbody td.actions-cell {
  width: 60px;
  text-align: center;
}

.library-table tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(253, 253, 253, 0.08);
  font-size: 0.93rem;
}

.library-table tbody tr:hover {
  background: rgba(253, 253, 253, 0.05);
}

.library-table tbody tr.workout-link {
  cursor: pointer;
}

.library-table tbody tr.workout-link:hover {
  background: rgba(253, 253, 253, 0.08);
}

.library-table tbody tr.workout-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.library-table tbody tr.workout-disabled:hover {
  background: rgba(253, 253, 253, 0.05);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(253, 253, 253, 0.08);
  border: 1px solid rgba(253, 253, 253, 0.12);
  color: var(--txt-light);
}

.status-pill.is-ready {
  background: rgba(102, 194, 171, 0.18);
  border-color: rgba(102, 194, 171, 0.42);
  color: #d9fff2;
}

.status-pill.is-processing {
  background: rgba(253, 215, 135, 0.18);
  border-color: rgba(253, 215, 135, 0.42);
  color: #fff3d6;
}

.status-pill.is-error,
.status-pill.is-failed {
  background: rgba(255, 110, 130, 0.18);
  border-color: rgba(255, 110, 130, 0.42);
  color: #ffe0e6;
}

.status-pill.is-draft {
  background: rgba(173, 181, 189, 0.18);
  border-color: rgba(173, 181, 189, 0.42);
  color: #f1f3f5;
}

.workout-table tr.progress-current {
  background: rgba(253, 215, 135, 0.16);
  box-shadow: inset 0 0 0 1px rgba(253, 215, 135, 0.55);
}

.workout-table tr.progress-current td {
  color: var(--accent);
  font-weight: 600;
}

.library-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.library-status {
  text-align: center;
  font-size: 0.95rem;
}

.workout-summary {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.workout-summary-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: center;
}

.workout-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  text-align: center;
}

.meta-label {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.68;
  margin-bottom: 0.2rem;
}

.meta-value {
  font-size: 1.1rem;
  font-weight: 600;
}

.workout-card {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.workout-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.workout-action-buttons .btn {
  flex: 1 1 200px;
  justify-content: center;
  font-size: 1.05rem;
  padding: 0.85rem 1.2rem;
  min-height: 48px;
}

.workout-play-button {
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.workout-resume-button {
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.workout-resume-button:hover,
.workout-resume-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-outline {
  background: transparent;
  border-color: rgba(253, 215, 135, 0.64);
  color: var(--accent);
}

.btn-outline:hover,
.btn-outline:focus-visible {
  background: rgba(253, 215, 135, 0.12);
  border-color: rgba(253, 215, 135, 0.85);
  color: var(--accent-strong);
}

.btn-resume.btn-primary {
  background: linear-gradient(135deg, rgba(255, 185, 95, 1), rgba(253, 215, 135, 1));
  color: #2a0509;
  box-shadow: 0 16px 32px rgba(253, 215, 135, 0.3);
}

.btn-resume.btn-primary:hover,
.btn-resume.btn-primary:focus-visible {
  background: linear-gradient(135deg, rgba(255, 205, 130, 1), rgba(253, 225, 160, 1));
}

.workout-empty {
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.6;
}

.workout-story-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, rgba(255, 70, 94, 0.38), rgba(10, 10, 12, 0.95)), #050506;
  color: #fdfdfd;
  display: flex;
  flex-direction: column;
  padding: 0;
  z-index: 9999;
  gap: clamp(0.8rem, 4vw, 1.6rem);
  height: 100dvh;
  min-height: 100vh;
  width: 100vw;
  overflow: hidden;
  box-sizing: border-box;
  overscroll-behavior: contain;
  touch-action: none;
  justify-content: space-between;
  background-attachment: fixed;
}

html.story-active,
body.story-active {
  overflow: hidden;
  height: 100%;
}

.workout-story-tap-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 2;
}

.workout-story-tap-left { left: 0; }
.workout-story-tap-right { right: 0; }

body.story-active {
  overflow: hidden;
}

body.story-active header.site-header {
  display: none;
}

body.story-active main > *:not(#workout-story-overlay) {
  visibility: hidden;
  pointer-events: none;
  height: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}

body.story-active #workout-story-overlay {
  visibility: visible;
  pointer-events: auto;
}

body.story-active footer {
  display: none;
}

body.story-active .workout-card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
}

.workout-story-topbar {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0) + clamp(12px, 3vw, 20px)) clamp(12px, 3vw, 20px) 0;
  width: 100%;
  box-sizing: border-box;
}

.workout-story-logo {
  width: clamp(48px, 14vw, 72px);
  height: auto;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.6)) drop-shadow(0 8px 24px rgba(255, 70, 94, 0.35));
}

.workout-story-setcount {
  font-family: var(--font-display);
  text-align: center;
  font-size: clamp(1.2rem, 4.4vw, 1.65rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 0, 0, 0.6);
}

.workout-story-content {
  position: absolute;
  bottom: clamp(100px, 22vw, 140px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: clamp(0.5rem, 2vw, 1rem);
  text-align: center;
  width: 100%;
  max-width: min(620px, 92vw);
  margin: 0 auto;
  z-index: 1;
  padding: clamp(0.5rem, 5vw, 1.5rem) clamp(0.9rem, 6vw, 1.8rem);
  box-sizing: border-box;
  transition: bottom 0.2s ease, top 0.2s ease, transform 0.2s ease;
}

.workout-story-overlay.no-video .workout-story-content {
  bottom: auto;
  top: 50%;
  transform: translateY(-50%);
  justify-content: center;
}

.workout-story-slide {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(0.85rem, 4vw, 1.9rem);
  text-align: center;
  pointer-events: none;
}

.workout-story-video-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #000;
  overflow: hidden;
}

.workout-story-video-bg::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 40%, transparent 100%);
  pointer-events: none;
  z-index: 1;
}

.workout-story-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.workout-story-topbar-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.workout-story-topbar-controls .workout-story-icon-btn {
  width: clamp(36px, 10vw, 44px);
  height: clamp(36px, 10vw, 44px);
  padding: 0;
}

.workout-story-topbar-controls .workout-story-icon-btn .btn-icon {
  width: 20px;
  height: 20px;
}

.workout-story-topbar-controls .workout-story-icon-btn .btn-icon .icon {
  width: 20px;
  height: 20px;
}

.workout-story-topbar-controls .workout-story-icon-btn[hidden] {
  display: none;
}

#workout-story-flag.flagged {
  background: rgba(255, 193, 7, 0.3);
  pointer-events: none;
  opacity: 0.6;
}

#workout-story-flag.flagged .icon {
  color: #ffc107;
}

#workout-story-flag:disabled {
  pointer-events: none;
  opacity: 0.4;
}

.playpause-icon[hidden] {
  display: none;
}

.workout-story-overlay .workout-story-headline {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 6.6vw, 2.5rem);
  font-weight: 700;
  line-height: 1.05;
  margin: 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 0, 0, 0.6), 0 0 40px rgba(255, 70, 94, 0.4);
  display: block;
  text-align: center;
}

.workout-story-reps {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 4.4vw, 1.65rem);
  font-weight: 700;
  line-height: 1.1;
  margin: 0;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 20px rgba(0, 0, 0, 0.6), 0 0 40px rgba(255, 70, 94, 0.4);
  display: block;
  text-align: center;
  color: #fff;
}

.workout-story-notes {
  font-size: clamp(0.9rem, 3.5vw, 1rem);
  max-width: min(420px, 85vw);
  margin: 0;
  padding: 0 0.4rem;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8), 0 0 12px rgba(0, 0, 0, 0.5);
}

.workout-story-complete {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(1rem, 4vw, 1.8rem);
  text-align: center;
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.workout-story-complete h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 3.2rem);
  margin: 0;
}

.workout-story-complete .workout-story-icon-btn {
  width: clamp(60px, 16vw, 80px);
  height: clamp(60px, 16vw, 80px);
  font-size: clamp(1.6rem, 7vw, 2rem);
}

.workout-story-loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  position: relative;
  z-index: 1;
}

.workout-story-loading-text {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 5vw, 1.6rem);
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
}

.workout-story-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(0.65rem, 5vw, 1.35rem);
  margin-top: auto;
  padding: 0 clamp(0.9rem, 6vw, 1.8rem) calc(env(safe-area-inset-bottom, 0) + clamp(0.65rem, 5vw, 1.2rem));
  width: 100%;
  position: relative;
  z-index: 3;
  box-sizing: border-box;
}

.workout-story-progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 6px;
  width: 100%;
  background: rgba(253, 215, 135, 0.18);
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
}

.workout-story-progress-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.workout-story-icon-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  width: clamp(52px, 13vw, 68px);
  height: clamp(52px, 13vw, 68px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: transform 0.18s ease, filter 0.18s ease;
}

.workout-story-icon-btn .btn-icon {
  font-size: clamp(2.4rem, 9vw, 3.2rem);
  color: inherit;
}

.workout-story-icon-btn .btn-icon .icon {
  stroke-width: 2.2;
}

.workout-story-complete .workout-story-icon-btn {
  pointer-events: auto;
  position: relative;
  z-index: 4;
}

.workout-story-icon-btn:hover,
.workout-story-icon-btn:focus,
.workout-story-icon-btn:focus-visible {
  transform: translateY(-2px);
  outline: none;
  filter: drop-shadow(0 6px 12px rgba(255, 110, 130, 0.45));
}

.workout-story-icon-btn:active {
  transform: translateY(1px);
}

.workout-story-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

@media (min-width: 721px) {
  .workout-story-overlay {
    padding: clamp(0.9rem, 4vw, 2.2rem);
    padding-top: clamp(1.2rem, 3vw, 2.4rem);
    padding-bottom: clamp(1rem, 3vw, 2.2rem);
  }
  .workout-story-top {
    align-items: center;
  }
}

@media (max-height: 720px) {
  .workout-story-overlay {
    padding: clamp(0.6rem, 4vw, 1.2rem);
    padding-top: calc(env(safe-area-inset-top, 0) + clamp(0.6rem, 4vw, 1.2rem));
    padding-bottom: calc(env(safe-area-inset-bottom, 0) + clamp(0.6rem, 4vw, 1rem));
  }
  .workout-story-headline {
    font-size: clamp(1.8rem, 7vw, 2.8rem);
  }
  .workout-story-nav {
    gap: clamp(0.5rem, 4vw, 1rem);
  }
}

@media (max-height: 600px) {
  .workout-story-slide {
    gap: clamp(0.6rem, 3vw, 1.2rem);
  }
  .workout-story-notes {
    font-size: clamp(0.85rem, 3vw, 0.95rem);
  }
  .workout-story-icon-btn {
    width: clamp(48px, 12vw, 60px);
    height: clamp(48px, 12vw, 60px);
  }
}

@media (max-width: 720px) {
  .workout-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }
}

footer {
  margin-top: auto;
  padding: 2.2rem 1rem 2.8rem;
  text-align: center;
  color: var(--txt-muted);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

/* Circular icon button - matches existing btn patterns */
.btn-icon-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid rgba(253, 253, 253, 0.16);
  background: rgba(253, 253, 253, 0.08);
  border-radius: 50%;
  color: var(--txt-muted);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.btn-icon-circle:hover,
.btn-icon-circle:focus-visible {
  transform: translateY(-1px);
  background: rgba(253, 215, 135, 0.16);
  border-color: rgba(255, 179, 89, 0.42);
  color: var(--accent);
  outline: none;
}

.btn-icon-circle:active {
  transform: translateY(1px);
}

.btn-icon-circle .icon {
  width: 1em;
  height: 1em;
  font-size: 1.1rem;
}

/* Workout title row with edit button */
.workout-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.workout-title-row h2 {
  margin: 0;
}

/* Source image section */
.workout-source-image-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(253, 253, 253, 0.1);
}

.source-image-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--txt-muted);
  margin-bottom: 0.75rem;
  text-align: center;
}

.workout-source-image {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  margin: 0 auto;
}

.workout-source-image:hover {
  transform: scale(1.01);
  box-shadow: var(--shadow-md);
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay .modal-content {
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  margin: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.modal-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  text-align: left;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--txt-muted);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.modal-actions-centered {
  justify-content: center;
}

.modal-content-sm {
  max-width: 320px;
  text-align: center;
}

.modal-body-centered {
  text-align: center;
  margin-bottom: 1.25rem;
}

.modal-body-centered p {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}

/* Danger ghost button - matches btn-ghost pattern */
.btn-danger-ghost {
  background: transparent;
  border: 1px solid rgba(255, 110, 130, 0.35);
  color: rgba(255, 110, 130, 0.85);
}

.btn-danger-ghost:hover,
.btn-danger-ghost:focus-visible {
  background: rgba(255, 110, 130, 0.15);
  border-color: rgba(255, 110, 130, 0.55);
  color: #ff6e82;
}

/* Image viewer overlay */
.image-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1rem;
}

.image-viewer-close-btn {
  position: absolute;
  top: max(env(safe-area-inset-top, 0px), 1rem);
  right: max(env(safe-area-inset-right, 0px), 1rem);
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background: rgba(253, 253, 253, 0.12);
  border-color: rgba(253, 253, 253, 0.24);
  color: var(--txt-light);
  z-index: 2001;
}

.image-viewer-close-btn .icon {
  font-size: 1.3rem;
}

.image-viewer-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--radius-md);
}

/* Exercise row action button - compact for table cells */
.exercise-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--txt-muted);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.16s ease, color 0.16s ease;
}

.exercise-action-btn.exercise-edit-btn:hover,
.exercise-action-btn.exercise-edit-btn:focus-visible {
  background: rgba(253, 215, 135, 0.15);
  color: var(--accent);
  outline: none;
}

.exercise-action-btn.exercise-delete-btn:hover,
.exercise-action-btn.exercise-delete-btn:focus-visible {
  background: rgba(255, 110, 130, 0.15);
  color: #ff6e82;
  outline: none;
}

.exercise-action-btn .icon {
  width: 1em;
  height: 1em;
  font-size: 1rem;
}

.icon-video {
  width: 14px;
  height: 14px;
  color: var(--accent);
  margin-left: 0.4rem;
  vertical-align: baseline;
  opacity: 0.85;
}

.actions-cell {
  display: flex;
  gap: 0.25rem;
  justify-content: flex-end;
}

/* Alternate exercise card */
.alternate-exercise-card {
  background: rgba(253, 253, 253, 0.06);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.alternate-exercise-card h4 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--txt-light);
}

.alternate-meta {
  font-size: 0.9rem;
  color: var(--txt-muted);
  margin-bottom: 0.75rem;
}

.alternate-reason {
  font-size: 0.9rem;
  color: rgba(102, 194, 171, 0.9);
  margin: 0 0 0.5rem;
  line-height: 1.4;
}

/* Prevent body scroll when modal is open */
body.modal-open {
  overflow: hidden;
}

@media (max-width: 720px) {
  main {
    padding: 0 clamp(0.75rem, 6vw, 1.4rem);
  }

  /* Mobile adjustments for edit features */
  .workout-title-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .modal-overlay .modal-content {
    max-height: 85vh;
    margin: auto 0.5rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal-actions-split {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .modal-actions-split .modal-actions-right {
    width: 100%;
    justify-content: flex-end;
  }

  /* Actions cell in mobile card view */
  .library-table tbody td.actions-cell {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    padding-top: 0.5rem;
    margin-top: 0.25rem;
    border-top: 1px solid rgba(253, 253, 253, 0.08);
  }

  .library-table tbody td.actions-cell::before {
    display: none;
  }
  .card {
    padding: clamp(1.25rem, 6vw, 1.75rem) clamp(1rem, 6vw, 1.75rem);
    border-radius: calc(var(--radius-lg) * 0.85);
  }
  form {
    gap: 0.75rem;
  }
  .account-card--logged-in .account-profile-header {
    flex-direction: column;
    align-items: stretch;
  }
  .account-edit-controls {
    width: 100%;
    justify-content: flex-start;
  }
  .account-edit-actions {
    width: 100%;
  }
  .library-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .library-controls .controls-left,
  .library-controls .controls-right {
    justify-content: space-between;
  }
  .library-table thead {
    display: none;
  }
  .library-table-wrapper {
    border: none;
    background: transparent;
    overflow: visible;
  }
  .library-table tbody {
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }
  .library-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.8rem;
    padding: 1rem;
    background: rgba(13, 18, 23, 0.6);
    border-radius: calc(var(--radius-md) * 1.1);
    border: 1px solid rgba(253, 253, 253, 0.08);
    box-shadow: var(--shadow-md);
  }
  .library-table thead th.column-actions,
  .library-table thead th.status-column {
    display: none;
  }
  .library-table tbody td {
    border: none;
    padding: 0;
  }
  .library-table tbody td.actions-cell {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    padding-top: 0.4rem;
  }
  .library-table tbody td:nth-child(1) {
    grid-column: 1 / -1;
    font-weight: 600;
    font-size: 1rem;
  }
  .library-table tbody td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    opacity: 0.6;
    margin-bottom: 0.2rem;
  }
}
