:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #f9fbfd;
  --text: #0b0d10;
  --muted: #69717d;
  --line: #dce2e8;
  --red: #ff3b30;
  --red-dark: #d9271e;
  --blue: #006cff;
  --blue-soft: #e8f1ff;
  --shadow: 0 22px 60px rgba(8, 18, 32, 0.14);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

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

.app-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  background:
    linear-gradient(90deg, rgba(0, 108, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(0, 108, 255, 0.08) 1px, transparent 1px),
    var(--bg);
  background-size: 28px 28px;
}

.workout-app-shell {
  align-items: start;
}

.phone-screen {
  width: min(100%, 430px);
  min-height: min(820px, calc(100svh - 32px));
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid rgba(10, 18, 28, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.brand,
.screen-note,
.form-status,
.preview-copy span,
.build-step em {
  margin: 0;
  color: var(--muted);
}

.brand {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(2.25rem, 12vw, 3.45rem);
  line-height: 0.92;
  letter-spacing: 0;
}

.format-chip {
  flex: 0 0 auto;
  min-width: 76px;
  padding: 10px 12px;
  color: var(--blue);
  font-weight: 900;
  text-align: center;
  background: var(--blue-soft);
  border: 1px solid #b8d4ff;
  border-radius: 8px;
}

.screen-note {
  max-width: 31ch;
  font-size: 1rem;
  line-height: 1.45;
}

.builder-form,
.speed-stack,
.build-steps {
  display: grid;
  gap: 12px;
}

.auth-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.auth-state .speed-label {
  margin-bottom: 0;
}

.auth-state strong {
  min-width: 0;
  font-size: 0.98rem;
  text-align: right;
  word-break: break-word;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 8px;
}

.auth-form input {
  min-width: 0;
  min-height: 46px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid #cfd7df;
  border-radius: 8px;
}

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

.auth-link {
  flex: 1;
}

.secondary-action {
  min-height: 46px;
  padding: 0 12px;
  color: var(--blue);
  font-weight: 900;
  background: var(--blue-soft);
  border: 1px solid #b8d4ff;
  border-radius: 8px;
}

.catalogue-picker {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.catalogue-picker select {
  width: 100%;
  min-height: 46px;
  color: var(--text);
  font: inherit;
  font-weight: 850;
  background: #fff;
  border: 1px solid #cfd7df;
  border-radius: 8px;
}

.catalogue-picker select:disabled {
  color: var(--text);
  opacity: 1;
  background: #f7fafc;
}

.speed-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.speed-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.speed-card strong {
  display: block;
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: 0;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(2, 48px);
  gap: 8px;
}

.stepper button {
  width: 48px;
  height: 48px;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 900;
  background: #fff;
  border: 1px solid #cfd7df;
  border-radius: 8px;
}

.stepper button:active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.primary-action {
  width: 100%;
  min-height: 58px;
  margin-top: 4px;
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
  background: var(--red);
  border: 0;
  border-radius: 8px;
  box-shadow: 0 12px 22px rgba(255, 59, 48, 0.25);
}

.primary-action:active {
  background: var(--red-dark);
}

.form-status {
  min-height: 1.35em;
  font-size: 0.95rem;
  line-height: 1.4;
}

.auth-panel .form-status {
  min-height: 1.2em;
  font-size: 0.88rem;
}

.preview-panel {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 14px;
  align-items: center;
  margin-top: auto;
  padding: 14px;
  background: #0b0d10;
  border-radius: 8px;
}

.preview-copy strong {
  display: block;
  margin-top: 4px;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
}

.preview-copy p {
  margin: 8px 0 0;
  color: #d8dee7;
  font-weight: 700;
}

.cue-art,
.generation-art {
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.cue-art {
  aspect-ratio: 1;
}

.cue-art img,
.generation-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.generate-screen {
  justify-content: flex-start;
}

.generation-art {
  position: relative;
  aspect-ratio: 1;
  margin-top: 4px;
}

.progress-shell {
  overflow: hidden;
  height: 12px;
  background: #edf1f5;
  border-radius: 8px;
}

.progress-bar {
  width: 18%;
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--blue));
  border-radius: inherit;
  transition: width 260ms ease;
}

.complete-burst {
  position: absolute;
  inset: auto 18px 18px;
  display: grid;
  place-items: center;
  min-height: 54px;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 950;
  background: var(--red);
  border-radius: 8px;
  box-shadow: 0 16px 32px rgba(255, 59, 48, 0.28);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 220ms ease, transform 220ms ease;
}

.generate-screen.is-complete .complete-burst {
  opacity: 1;
  transform: translateY(0) scale(1);
  animation: readyPulse 900ms ease both;
}

.generate-screen.is-complete .generation-art img {
  transform: scale(0.96);
  transition: transform 260ms ease;
}

.generate-screen.is-complete .progress-bar {
  width: 100%;
}

@keyframes readyPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.45);
  }
  100% {
    box-shadow: 0 0 0 18px rgba(255, 59, 48, 0);
  }
}

.build-step {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 6px 12px;
  align-items: center;
  padding: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.build-step span {
  width: 14px;
  height: 14px;
  grid-row: span 2;
  background: #cbd3dc;
  border-radius: 50%;
}

.build-step strong {
  font-size: 1.02rem;
}

.build-step em {
  font-size: 0.9rem;
  font-style: normal;
}

.build-step.is-active {
  border-color: #a9cbff;
  background: var(--blue-soft);
}

.build-step.is-active span {
  background: var(--blue);
}

.build-step.is-done span {
  background: var(--red);
}

.player-screen {
  gap: 16px;
}

.player-topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.quiet-link {
  align-self: flex-start;
  min-width: 64px;
  padding: 10px 12px;
  color: var(--blue);
  font-size: 0.9rem;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
  background: var(--blue-soft);
  border: 1px solid #b8d4ff;
  border-radius: 8px;
}

.timer-panel {
  padding: 18px;
  background: #0b0d10;
  border-radius: 8px;
}

.timer-label,
.speed-callout,
.next-panel span,
.next-panel p,
.timeline-labels {
  margin: 0;
}

.timer-label {
  color: #bfc7d1;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.timer {
  display: block;
  margin-top: 6px;
  color: #fff;
  font-size: clamp(4.8rem, 24vw, 6.5rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.speed-callout {
  margin-top: 8px;
  color: #fff;
  font-size: 1.45rem;
  font-weight: 900;
}

.player-art {
  aspect-ratio: 1;
}

.next-panel {
  padding: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 8px;
}

.next-panel span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.next-panel strong {
  display: block;
  margin-top: 4px;
  font-size: 1.45rem;
}

.next-panel p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.audio-panel {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 10px;
}

.audio-panel button {
  min-height: 50px;
  color: var(--text);
  font-weight: 900;
  background: #fff;
  border: 1px solid #cfd7df;
  border-radius: 8px;
}

.audio-panel .play-button {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.timeline-panel {
  display: grid;
  gap: 10px;
  margin-top: auto;
}

.timeline-track {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(22px, 1fr));
  gap: 5px;
  height: 13px;
}

.timeline-track span {
  background: #d8dee6;
  border-radius: 8px;
}

.timeline-track .is-done {
  background: var(--red);
}

.timeline-track .is-active {
  background: var(--blue);
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.timeline-labels strong {
  color: var(--text);
}

@media (max-width: 380px) {
  .auth-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .auth-state {
    display: grid;
    justify-items: start;
    gap: 4px;
  }

  .auth-state strong {
    max-width: 100%;
    text-align: left;
  }
}

.workout-details {
  margin-top: 4px;
  border-top: 1px solid var(--line);
}

.workout-details summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  color: var(--blue);
  font-weight: 900;
  cursor: pointer;
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 8px 0 16px;
}

.stats-strip article {
  padding: 10px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stats-strip strong {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
}

.workout-intel,
.movement-guide {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.4rem;
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.block-list,
.movement-grid {
  display: grid;
  gap: 10px;
}

.intel-block,
.movement-card {
  padding: 12px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.block-kicker {
  display: grid;
  gap: 4px;
}

.block-kicker span {
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 900;
}

.block-kicker strong {
  font-size: 1rem;
}

.goal,
.intel-block li {
  color: var(--muted);
  line-height: 1.35;
}

.intel-block ul {
  display: grid;
  gap: 8px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.intel-block li {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px;
  font-size: 0.9rem;
}

.intel-block li span {
  color: var(--text);
  font-weight: 900;
}

.movement-card {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 12px;
  align-items: center;
}

.movement-card img {
  width: 88px;
  aspect-ratio: 1;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.movement-card h3,
.movement-card p {
  margin: 0;
}

.movement-card p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

@media (min-width: 800px) {
  .phone-screen {
    min-height: 820px;
  }
}
