@font-face {
  font-family: 'Marck Script';
  src: url('./assets/fonts/marck-script-regular.ttf') format('truetype');
  font-style: normal; font-weight: 400; font-display: swap;
}
:root {
  color-scheme: dark;
  --background: #100d14;
  --surface: #231d2c;
  --border: #383040;
  --text: #f4eff7;
  --muted: #85808d;
  --accent: #ff955c;
  --accent-fill: #ffb58a;
  --gap: 10px;
  --gutter: 16px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
  background: var(--background);
  color: var(--text);
}
* { box-sizing: border-box; }
html { min-width: 300px; }
body { margin: 0; min-height: 100vh; min-height: 100svh; }
body.is-starting { overflow: hidden; }
[hidden] { display: none !important; }
.startup-screen {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; overflow-y: auto;
  padding: max(32px, env(safe-area-inset-top)) 28px max(32px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at 50% 35%, #35203e66, transparent 65%), var(--background);
  transition: opacity .18s ease-out;
}
.startup-screen.is-leaving { opacity: 0; pointer-events: none; }
.startup-content { width: 100%; max-width: 330px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.startup-icon { display: block; width: 88px; height: 88px; border-radius: 22px; margin-bottom: 38px; box-shadow: 0 14px 42px #0005; }
.startup-quote { margin: 0; font-family: 'Marck Script', cursive; font-size: clamp(27px, 7.7vw, 32px); font-weight: 400; line-height: 1.3; letter-spacing: 0; text-wrap: balance; }
.startup-quote span { color: var(--accent); }
.startup-author { margin-top: 24px; color: #ac98b5; font-size: 11px; font-style: normal; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; }
.startup-track { width: 152px; height: 3px; margin-top: 42px; overflow: hidden; border-radius: 99px; background: #3b2c44; }
.startup-fill { display: block; height: 100%; background: linear-gradient(90deg, #eb743c, #ffb88f); transform: scaleX(0); transform-origin: left; border-radius: inherit; }
.startup-screen.is-running .startup-fill { animation: startup-progress var(--startup-duration, 2500ms) linear forwards; }
@keyframes startup-progress { 0% { transform: scaleX(0); } 24% { transform: scaleX(.3); } 65% { transform: scaleX(.75); } 90% { transform: scaleX(.92); } 100% { transform: scaleX(1); } }
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background: radial-gradient(ellipse at 70% 10%, #291b381c, transparent 65%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' opacity='.035' filter='url(%23n)'/%3E%3C/svg%3E");
}
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button, .sets-badge { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { touch-action: manipulation; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
button:disabled { cursor: default; opacity: .35; }
h1, h2, p { margin: 0; }
.icon { width: 24px; height: 24px; flex: none; }
.app { width: 100%; max-width: 460px; margin-inline: auto; }
.screen {
  min-height: 100vh; min-height: 100svh;
  padding: max(24px, env(safe-area-inset-top)) var(--gutter) max(24px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
}
.home-screen { padding-top: max(48px, calc(env(safe-area-inset-top) + 12px)); }
.workout-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.workout-tile {
  display: flex; flex-direction: column; align-items: stretch;
  min-width: 0; padding: 12px 8px 8px; border-radius: 17px; border: 1px solid var(--border);
  background: linear-gradient(150deg, #28223080, transparent), var(--surface);
  box-shadow: inset 0 1px 0 #ffffff04;
  transition: border-color .16s, transform .16s;
}
.workout-tile:active { transform: scale(.975); border-color: var(--accent); }
.workout-label { text-align: center; font-size: .75rem; font-weight: 650; line-height: 1.3; letter-spacing: -.025em; white-space: nowrap; }
.tile-rule { height: 1px; background: var(--border); margin: 9px 0 8px; flex-shrink: 0; }
.workout-art { display: block; color: var(--accent); width: 100%; aspect-ratio: 1.04; }
.workout-art .media-image { height: 100%; width: 100%; }
.overall-progress {
  margin-top: 20px; padding: 16px 18px 14px; border: 1px solid #4b3546; border-radius: 18px;
  background: radial-gradient(ellipse at 100% 0, #ff955c14, transparent 65%), linear-gradient(135deg, #2c2232, #201926);
  box-shadow: inset 0 1px 0 #ffffff05;
}
.overall-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.overall-label { max-width: 110px; color: #d7cbdc; font-size: .9375rem; font-weight: 550; line-height: 1.35; letter-spacing: -.015em; }
.overall-label > span { display: block; white-space: nowrap; }
.overall-percentage { display: flex; align-items: baseline; gap: 3px; color: var(--accent); font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; }
.overall-number { font-size: 2.75rem; letter-spacing: -.065em; }
.overall-percent-sign { font-size: 1.125rem; color: #d79a79; }
.overall-segments { display: grid; grid-template-columns: repeat(var(--segment-count), minmax(0, 1fr)); gap: 3px; height: 22px; margin-top: 14px; }
.overall-segment { position: relative; display: block; min-width: 0; height: 100%; overflow: hidden; border-radius: 2px; background: #48364e; }
.overall-segment-fill { display: block; height: 100%; background: linear-gradient(to top, #ed793e, #ffb27f); transform: scaleY(var(--segment-progress, 0)); transform-origin: bottom; }
.overall-legend { margin-top: 9px; color: #a99aaf; font-size: .625rem; line-height: 1.3; letter-spacing: .01em; }
.is-completed .workout-label, .is-completed .workout-art { color: var(--muted); }
.is-completed .workout-art img { filter: grayscale(1); opacity: .6; }
.screen-footer { padding-top: 34px; margin-top: auto; }
.hold-button {
  position: relative; isolation: isolate; overflow: hidden; display: block; width: 100%; min-height: 56px;
  padding: 15px 10px; border: none; border-radius: 16px;
  background: linear-gradient(110deg, #ff8b48, var(--accent)); color: #170e0a;
  font-size: 1rem; line-height: 1.35; font-weight: 750; letter-spacing: -.025em;
  touch-action: none;
}
.hold-button::before {
  content: ''; position: absolute; z-index: -1; inset: 0;
  background: var(--accent-fill); transform: scaleX(var(--hold-progress, 0)); transform-origin: left;
}
.hold-button.is-holding { box-shadow: 0 0 0 2px #ff955c22; }
.hold-label { pointer-events: none; }
.workout-header { display: flex; align-items: center; gap: 14px; padding-bottom: 15px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.back-button, .close-button, .step-button {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: linear-gradient(145deg, #30273866, transparent), var(--surface);
  border-radius: 12px;
}
.back-button { min-height: 44px; padding: 8px 11px; gap: 3px; font-weight: 600; font-size: .875rem; flex-shrink: 0; }
.back-button .icon { width: 19px; height: 19px; color: var(--accent); }
.workout-heading { min-width: 0; }
.workout-heading h1 { font-size: 1.125rem; font-weight: 700; line-height: 1.25; letter-spacing: -.025em; }
.workout-heading p { margin-top: 3px; font-size: .875rem; line-height: 1.35; color: #bfb7c7; }
.exercise-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.exercise-card {
  min-width: 0; padding: 10px 8px; border: 1px solid var(--border); border-radius: 18px;
  background: linear-gradient(145deg, #2c253340, transparent), var(--surface);
}
.exercise-name { font-size: .875rem; line-height: 1.25; font-weight: 650; min-height: 2.5em; margin: 0 3px 9px; letter-spacing: -.015em; overflow-wrap: anywhere; }
.exercise-media, .detail-media {
  position: relative; display: block; width: 100%; aspect-ratio: 1; overflow: hidden;
  border: 0; border-radius: 10px; padding: 0; background: #fff;
}
.media-image { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; overflow: hidden; }
/* Keep the entire motion below the overlaid set badge, including raised arms. */
.exercise-media > img, .exercise-media > video { padding: 34px 4px 4px; }
.detail-media > img, .detail-media > video { padding: 64px 8px 8px; }
.media-placeholder { display: flex; width: 100%; height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #91849f; background: radial-gradient(ellipse at 50% 40%, #31263d, #1b1523); font-size: .6875rem; font-weight: 500; }
.media-placeholder > .icon { width: 32px; height: 32px; opacity: .55; }
.sets-badge {
  display: flex; align-items: center; gap: 2px; position: absolute; top: 6px; left: 6px;
  padding: 4px 5px; background: #231d2cf5; border-radius: 8px; color: var(--accent); pointer-events: none;
}
.sets-badge .icon { width: 16px; height: 19px; stroke-width: 1; }
.exercise-progress { height: 2px; margin-top: 9px; border-radius: 2px; overflow: hidden; background: var(--border); }
.exercise-progress-fill { display: block; height: 100%; background: var(--accent); transform: scaleX(var(--exercise-progress, 0)); transform-origin: left; transition: transform .18s ease-out; }
.load-controls { display: grid; grid-template-columns: 40px minmax(0, 1fr) 40px; gap: 2px; align-items: center; min-height: 68px; padding-top: 9px; }
.step-button { position: relative; width: 40px; height: 44px; padding: 9px; color: var(--accent); }
.step-button::before { content: ''; position: absolute; inset: 0 -2px; }
.step-button .icon { width: 23px; height: 23px; }
.step-button:active:not(:disabled), .back-button:active, .close-button:active { background: #423347; }
.load-readout { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.exercise-card .load-readout { min-height: 56px; }
.load-row { display: flex; align-items: center; justify-content: center; gap: 3px; font-size: .875rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; white-space: nowrap; }
.load-row .icon { width: 15px; height: 17px; color: var(--accent); }
.load-value { display: inline-flex; align-items: baseline; gap: 3px; }
.load-unit { font-size: .6875rem; font-weight: 500; }
.load-row.has-scope { flex-wrap: wrap; row-gap: 1px; }
.load-scope { flex-basis: 100%; color: #a79aaf; text-align: center; font-size: .625rem; line-height: 1.3; font-weight: 400; }
.stale-note { font-size: .6875rem; color: var(--accent); text-align: center; }
.exercise-dialog {
  position: fixed; inset: 0; width: 100%; max-width: none; height: 100%; height: 100dvh; max-height: none;
  margin: 0; padding: 0; border: 0; background: var(--background); color: var(--text); overscroll-behavior: contain;
}
.exercise-dialog::backdrop { background: var(--background); }
.modal-open { overflow: hidden; }
.dialog-body {
  max-width: 460px; min-height: 100%; margin: 0 auto;
  padding: max(28px, env(safe-area-inset-top)) var(--gutter) max(28px, env(safe-area-inset-bottom));
}
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; padding-bottom: 22px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.dialog-header h2 { min-width: 0; max-width: 260px; font-size: 1.75rem; line-height: 1.13; letter-spacing: -.035em; font-weight: 700; overflow-wrap: anywhere; }
.close-button { min-width: 48px; height: 48px; padding: 11px; }
.detail-media { border-radius: 19px; }
.detail-media .sets-badge { top: 12px; left: 12px; padding: 7px 9px; gap: 4px; border-radius: 11px; }
.detail-media .sets-badge .icon { width: 29px; height: 34px; }
.detail-readout { border: 1px solid var(--border); border-radius: 19px; background: var(--surface); padding: 8px 18px; margin-top: 20px; gap: 0; }
.detail-readout .load-row { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 12px; padding: 15px 0; font-size: 2.75rem; line-height: 1.1; }
.detail-readout .load-row + .load-row { border-top: 1px solid var(--border); }
.detail-readout .load-row .icon { width: 42px; height: 44px; }
.detail-readout .load-value { gap: 7px; }
.detail-readout .load-unit { font-size: 1.375rem; }
.detail-readout .load-row.has-scope { grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; }
.detail-readout .load-scope { font-size: .8125rem; text-align: right; align-self: center; }
.notice { position: fixed; z-index: 20; bottom: max(18px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); width: min(92%, 430px); padding: 15px 18px; border: 1px solid var(--accent); background: var(--surface); border-radius: 14px; font-size: .875rem; box-shadow: 0 8px 35px #0008; }
.error-message { padding: 40px 20px; }
.error-message h1 { font-size: 1.5rem; }
.error-message p { margin: 16px 0; line-height: 1.5; }
@media (min-width: 390px) {
  :root { --gutter: 18px; }
  .load-row { font-size: .9375rem; }
}
@media (min-width: 430px) {
  .workout-label { font-size: .8125rem; }
  .exercise-name { font-size: 1rem; }
  .load-controls { gap: 5px; grid-template-columns: 44px minmax(0, 1fr) 44px; }
  .step-button { width: 44px; }
  .load-row { font-size: 1rem; }
}
@media (max-width: 350px) {
  :root { --gutter: 12px; --gap: 8px; }
  .workout-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exercise-grid { grid-template-columns: 1fr; }
  .exercise-name { min-height: 0; font-size: 1rem; }
  .load-controls { grid-template-columns: 48px 1fr 48px; }
  .step-button { width: 48px; height: 48px; }
  .load-row { font-size: 1.125rem; }
}
@media (prefers-reduced-motion: reduce) {
  .startup-screen { transition: none; }
  .startup-screen.is-running .startup-fill { animation: none; transform: scaleX(1); }
  .workout-tile { transition: none; }
  .exercise-progress-fill { transition: none; }
}
