/* Home-screen PWA: let the background reach the edges, keep content in the safe area. */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
.app-standalone [data-action="fullscreen"],
.no-fullscreen [data-action="fullscreen"] { display: none; }
.landscape-hint { display: none; }
@media (max-width: 1024px) {
  .start-screen { padding-top: calc(100px + var(--safe-top)); padding-bottom: calc(50px + var(--safe-bottom)); padding-left: calc(22px + var(--safe-left)); padding-right: calc(22px + var(--safe-right)); }
  .player .topbar, .start-screen .topbar { top: calc(24px + var(--safe-top)); left: calc(22px + var(--safe-left)); right: calc(22px + var(--safe-right)); }
  .device-code { right: calc(20px + var(--safe-right)); bottom: calc(12px + var(--safe-bottom)); }
  .start-foot { position: static; margin-top: 24px; }
  .pause-backdrop { padding: calc(20px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) calc(20px + var(--safe-left)); overflow-y: auto; }
}
@media (max-width: 700px) and (orientation: portrait) {
  .landscape-hint { display: block; max-width: 330px; margin: -8px auto 20px; font-size: 12px; line-height: 1.5; color: var(--muted); }
  .player { height: 100dvh; min-height: calc(740px + var(--safe-top) + var(--safe-bottom)); }
  .workout-grid { padding-top: calc(83px + var(--safe-top)); padding-bottom: calc(148px + var(--safe-bottom)); }
  .playback-controls { bottom: calc(75px + var(--safe-bottom)); }
  .workout-footer { bottom: calc(24px + var(--safe-bottom)); }
}
/* Short, wide phone screens: video on the left, clock on the right.
   Rotation only changes layout; the player and workout clock stay mounted. */
@media (orientation: landscape) and (max-height: 500px) {
  .player { height: 100svh; height: 100dvh; min-height: 0; overflow: hidden; }
  .player .topbar, .start-screen .topbar { top: calc(4px + var(--safe-top)); left: calc(14px + var(--safe-left)); right: calc(14px + var(--safe-right)); height: 40px; }
  .brand { font-size: 14px; gap: 8px; }
  .brand-mark { width: 28px; height: 28px; border-radius: 9px; }
  .brand-mark svg { width: 20px; height: 20px; }
  .player .brand span:last-child { display: inline; }
  .session-label { font-size: 11px; gap: 8px; min-width: 0; }
  #session-equipment { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .header-buttons { margin-left: 0; gap: 0; }
  .player .header-buttons .icon-btn { width: 44px; height: 40px; }
  .top-note { display: none; }
  .workout-grid { display: grid; grid-template-columns: minmax(200px, 1.2fr) minmax(220px, 1fr); gap: 20px; height: 100%; padding: calc(46px + var(--safe-top)) calc(16px + var(--safe-right)) calc(60px + var(--safe-bottom)) calc(16px + var(--safe-left)); align-items: center; }
  .player .demonstration { width: 100%; height: 100%; min-height: 0; align-self: stretch; }
  .stage { height: 100%; min-height: 0; max-height: none; }
  .stage svg { height: 100%; width: 100%; }
  .stage-caption { display: none; }
  .video-frame { width: min(100%, calc((100dvh - 106px - var(--safe-top) - var(--safe-bottom)) * 16 / 9)); min-height: 200px; max-height: 100%; border-radius: 12px; }
  .workout-info { align-self: center; min-width: 0; padding: 0; text-align: left; }
  .phase-label { justify-content: flex-start; font-size: 11px; letter-spacing: 1.3px; min-height: 14px; gap: 8px; }
  .phase-line { width: 16px; }
  .workout-info h1 { font-size: clamp(21px, 3.2vw, 29px); line-height: 1.08; letter-spacing: -.7px; margin: 5px 0; }
  .muscle-tags { display: none; }
  .timer { font-size: clamp(66px, 21dvh, 96px); letter-spacing: -4px; line-height: 1; margin: 6px 0 4px; }
  .set-row { justify-content: flex-start; min-height: 24px; gap: 12px; }
  .set-label { font-size: clamp(18px, 5dvh, 23px); line-height: 1.15; }
  .set-dots { gap: 6px; }
  .set-dots i { width: 6px; height: 6px; }
  .side-pill { font-size: 11px; margin-top: 4px; padding: 3px 8px; }
  .technique { font-size: clamp(12px, 3.6dvh, 16px); line-height: 1.25; margin: 7px 0 0; max-width: none; }
  .next-line { font-size: 11px; line-height: 1.2; margin-top: 6px; min-height: 0; justify-content: flex-start; }
  .player[data-state=REST] .next-line:before { width: 12px; height: 12px; }
  .playback-controls { left: auto; right: calc(16px + var(--safe-right)); bottom: calc(7px + var(--safe-bottom)); transform: none; padding: 2px 5px; gap: 2px; border-radius: 16px; opacity: 1; }
  .playback-controls .icon-btn, .playback-controls .pause-control { width: 44px; height: 44px; }
  .playback-controls svg { width: 20px; height: 20px; }
  .controls-divider { margin: 0 3px; }
  .workout-footer { left: calc(16px + var(--safe-left)); right: calc(280px + var(--safe-right)); bottom: calc(16px + var(--safe-bottom)); }
  .progress-label { font-size: 11px; margin-bottom: 8px; gap: 12px; }
  .video-status { padding: 12px; gap: 8px; font-size: 15px; }
  .video-status .video-note { font-size: 11px; }
  .video-status .quiet-button { min-height: 44px; font-size: 13px; }
  .pause-backdrop { padding-top: calc(12px + var(--safe-top)); padding-bottom: calc(12px + var(--safe-bottom)); }
  .pause-card { width: min(600px, 100%); }
  .pause-symbol { display: none; }
  .pause-card .eyebrow, .resume-card .eyebrow { font-size: 11px; }
  .pause-card h2 { font-size: 32px; margin: 8px 0; letter-spacing: -1px; }
  .pause-card p { font-size: 15px; margin: 8px 0 14px; line-height: 1.3; }
  .pause-card .primary { min-height: 44px; padding: 10px 24px; font-size: 16px; }
  .pause-navigation { margin: 5px 0 0; gap: 18px; }
  .pause-card .quiet-button, .resume-card .quiet-button { min-height: 44px; font-size: 13px; }
  .resume-count { font-size: 110px; line-height: 1.15; }
  .toast { bottom: calc(65px + var(--safe-bottom)); font-size: 13px; padding: 10px 16px; }
  /* The launch screen remains useful before rotating into a session. */
  .start-screen { min-height: 100dvh; padding: calc(52px + var(--safe-top)) calc(18px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(18px + var(--safe-left)); }
  .program-screen .welcome { max-width: 1000px; }
  .program-screen .eyebrow, .program-screen h1, .program-details, .program-screen .streak-block, .program-screen .device-code { display: none; }
  .day-picker { grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 12px; }
  .day-picker button { min-height: 94px; padding: 12px; gap: 6px; border-radius: 12px; }
  .day-picker strong { font-size: 17px; }
  .day-number, .day-detail { font-size: 10px; }
  .program-screen .facts { font-size: 14px; margin: 0 0 10px; }
  .program-options { display: inline-flex; vertical-align: middle; margin-right: 20px; }
  .program-options .set-picker { flex-direction: row; gap: 10px; margin: 0; }
  .set-picker-options button { min-width: 44px; min-height: 44px; padding: 8px 12px; }
  .program-screen .primary { min-width: 220px; min-height: 44px; font-size: 16px; padding: 12px 20px; vertical-align: middle; }
  .program-screen .secondary-controls { margin-top: 4px; }
  .program-screen .quiet-button { min-height: 44px; font-size: 12px; }
  .complete-screen .hero-mark, .start-screen:has(.code-form) .hero-mark { display: none; }
  .complete-screen .welcome h1, .start-screen:has(.code-form) .welcome h1 { font-size: 32px; margin: 8px 0; letter-spacing: -1px; }
  .complete-screen .welcome h1 span, .start-screen:has(.code-form) .welcome h1 span { display: inline; }
  .start-screen .subtitle { font-size: 16px; margin-bottom: 12px; }
  .completion-stats { margin: 15px 0; }
  .complete-screen .primary { min-height: 44px; padding: 12px 24px; font-size: 16px; }
  .code-form { flex-direction: row; justify-content: center; }
  .code-form .primary { min-width: 150px; min-height: 50px; padding: 12px 20px; }
}
@media (orientation: landscape) and (max-height: 350px) {
  .technique { font-size: 12px; margin-top: 4px; }
  .next-line { display: none; }
  .workout-info h1 { font-size: 21px; }
  .program-screen .secondary-controls { position: absolute; top: -48px; right: 0; margin: 0; z-index: 6; }
}

/* Warm-up target areas remain readable when the PWA is mirrored horizontally. */
@media (orientation: landscape) and (max-height: 500px) {
 .player:is([data-state^="WARMUP"],[data-state^="COOLDOWN"],:has(.video-frame[data-video-state="error"])) .muscle-tags { display:flex; gap:4px; justify-content:flex-start; }
 .player:is([data-state^="WARMUP"],[data-state^="COOLDOWN"],:has(.video-frame[data-video-state="error"])) .muscle-tags span { font-size:10px; padding:3px 6px; }
 .player:is([data-state^="WARMUP"],[data-state^="COOLDOWN"]) .timer { font-size:clamp(58px,18dvh,82px); margin-top:4px; }
}
@media (orientation: landscape) and (max-height: 350px) {
 .player:is([data-state^="WARMUP"],[data-state^="COOLDOWN"]) .technique { display:none; }
}
