:root { color-scheme: light; font-family: "Segoe UI", "Malgun Gothic", sans-serif; color: #21352e; background: #f3f5f2; }
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body { margin: 0; }
main { max-width: 1180px; margin: auto; padding: 20px 24px; }
header { margin-bottom: 12px; }
h1 { font-size: clamp(24px, 4vw, 32px); margin: 0 0 8px; letter-spacing: -.04em; }
h2 { font-size: 24px; margin: 0; letter-spacing: -.03em; }
p { margin: 0; line-height: 1.65; }
.muted { color: #5b6a63; font-size: 14px; }
button, input { font: inherit; color: inherit; }
button { min-height: 44px; padding: 10px 14px; border: 1px solid #b5c2ba; border-radius: 6px; background: #fff; cursor: pointer; font-size: 14px; }
button:hover:not(:disabled) { background: #eef4ef; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid #cf7b22; outline-offset: 3px; }
.primary { background: #205c43; color: #fff; border-color: #205c43; }
.primary:hover:not(:disabled) { background: #174630; }
.selection-heading { display: flex; justify-content: space-between; gap: 18px; align-items: baseline; margin: 12px 0 24px; }
.selection-heading p { margin-top: 8px; }
.exercise-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.exercise-card { display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; border-color: #d7dfd9; border-radius: 10px; }
.exercise-card:hover:not(:disabled) { border-color: #205c43; background: #fff; }
.thumbnail { display: block; position: relative; width: 100%; aspect-ratio: 1; background: #fff; overflow: hidden; }
.thumbnail img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.card-label { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 5px; }
.card-label strong { font-size: 16px; line-height: 1.4; }
.workout-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.workout-nav button { flex-shrink: 0; }
.back-button { margin: 0; background: #205c43; color: #fff; border-color: #205c43; font-weight: 650; }
.back-button:hover:not(:disabled) { background: #174630; }
.next-info { flex: 1; margin-left: .75em; min-width: 0; font-size: 14px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.next-countdown { display: inline-block; margin-left: .5em; white-space: nowrap; color: #205c43; font-variant-numeric: tabular-nums; }
.layout { display: grid; grid-template-columns: minmax(0, min(60vh, 624px)) 300px; grid-template-columns: minmax(0, min(60dvh, 624px)) 300px; gap: 16px; align-items: start; }
.viewer { min-width: 0; }
/* Fit the square canvas to the viewport; keep every approved frame transform. */
.stage { container-type: inline-size; position: relative; background: #fff; aspect-ratio: 1; width: min(100%, 60vh, 624px); width: min(100%, 60dvh, 624px); margin-inline: 0; border: 1px solid #d7dfd9; border-radius: 12px; overflow: hidden; }
.stage img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: contain; transform-origin: center; }
.exercise-intro { background: #fff; border: 1px solid #d7dfd9; border-radius: 12px; padding: 16px; height: 148px; grid-column: 1; min-width: 0; display: grid; grid-template-rows: 34px 26px 46px; gap: 4px; }
.caption { min-width: 0; height: 34px; }
.caption h2 { font-size: clamp(20px, 3vw, 24px); line-height: 34px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#exercise-intro-toggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 0; padding: 0; border: 0; background: transparent; text-align: left; font: inherit; }
#exercise-intro-toggle:disabled { opacity: 1; }
#exercise-name { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.intro-toggle-hint { display: none; }
#exercise-description, .workout-live, .workout-settings { display: contents; }
.purpose { margin: 0; font-weight: 600; line-height: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#exercise-guide { margin: 0; line-height: 23px; height: 46px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.stage-countdown { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; pointer-events: none; font-size: 40cqw; line-height: .75; font-weight: 900; font-variant-numeric: tabular-nums; color: #164a34; text-shadow: 0 2px 3px #fff, 0 0 12px #fff; }
#countdown-number { display: block; }
.controls { background: #fff; border: 1px solid #d7dfd9; border-radius: 12px; padding: 18px; }
.state { font-size: 14px; color: #365e47; min-height: 24px; }
[data-phase="preparing"] .state, [data-phase="running"] .state, [data-phase="complete"] .state { display: none; }
.counter { display: flex; align-items: baseline; gap: 10px; margin: 8px 0; font-variant-numeric: tabular-nums; }
.counter strong { font-size: 56px; letter-spacing: -.05em; line-height: 1.2; }
.counter span { color: #5b6a63; }
.progress-wrap { position: relative; border-radius: 6px; }
.progress-beat { position: absolute; inset: 0; border-radius: inherit; opacity: 0; pointer-events: none; background: repeating-linear-gradient(115deg, transparent 0 15px, #b2f4cf 15px 23px, transparent 23px 38px); }
.progress-label { position: absolute; z-index: 1; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 0; background: transparent; color: #205c43; font-size: 15px; font-weight: 700; line-height: 24px; white-space: nowrap; font-variant-numeric: tabular-nums; pointer-events: none; }
progress { display: block; width: 100%; height: 32px; appearance: none; border: 0; border-radius: 6px; overflow: hidden; background: #e0e8e2; accent-color: #205c43; }
progress::-webkit-progress-bar { background: #e0e8e2; }
progress::-webkit-progress-value { background: #205c43; }
progress::-moz-progress-bar { background: #205c43; }
.count-help { margin-top: 10px; font-size: 13px; }
.setting { margin-top: 16px; }
label { font-size: 14px; font-weight: 650; }
.number-field { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.number-field input { min-width: 0; width: 100%; padding: 10px 12px; border: 1px solid #a9b8af; border-radius: 6px; min-height: 44px; background: #fff; }
.number-field input:disabled { background: #f3f5f2; color: #5b6a63; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.setting-heading { display: flex; justify-content: space-between; align-items: center; }
#tempo-value, #volume-value { font-size: 20px; font-weight: 700; color: #205c43; font-variant-numeric: tabular-nums; }
#tempo, #volume { display: block; width: 100%; min-height: 44px; margin: 4px 0; accent-color: #205c43; cursor: pointer; }
.settings-note { border-top: 1px solid #d7dfd9; margin-top: 24px; padding-top: 16px; font-size: 13px; }
.notice { margin-top: 12px; color: #80510c; font-size: 14px; overflow-wrap: anywhere; }
.error { color: #a32323; }
#retry { margin-top: 10px; }
[data-phase="complete"] .state { font-weight: 700; }
@media (max-width: 1000px) { .layout { grid-template-columns: minmax(0, min(52.8vh, 528px)) 300px; grid-template-columns: minmax(0, min(52.8dvh, 528px)) 300px; } .stage { width: min(100%, 52.8vh, 528px); width: min(100%, 52.8dvh, 528px); } .exercise-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .stage { width: min(100%, 52.8vh, 384px); width: min(100%, 52.8dvh, 384px); } main { padding: 20px 16px; } .layout { grid-template-columns: 1fr; gap: 20px; } .controls { padding: 18px; } .exercise-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } .selection-heading { display: block; } #exercise-count { display: block; margin-top: 10px; } .card-label { padding: 12px; } }
[hidden] { display: none !important; }



.stage[aria-disabled="false"] { cursor: pointer; }
.stage:focus-visible { outline: 3px solid #cf7b22; outline-offset: 3px; }

.progress-label.on-fill { color: #fff; }

@media (max-width: 760px) { .workout-nav { min-height: 60px; } }

/* The left column defines the panel height: fixed intro + gap + square image. */
@media (min-width: 761px) {
  .layout { grid-template-rows: 148px auto; }
  .exercise-intro { grid-row: 1; }
  .viewer { grid-column: 1; grid-row: 2; }
  .controls { grid-column: 2; grid-row: 1 / 3; align-self: stretch; contain: size; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding: 16px; }
  .controls > * { flex-shrink: 0; }
  .controls .counter { margin: 4px 0 8px; }
  .controls .counter strong { font-size: 52px; line-height: 1.15; }
  .controls .setting, .controls .actions { margin-top: 12px; }
  .controls .number-field { margin-top: 6px; }
  .controls #tempo, .controls #volume { min-height: 40px; }
  .controls .settings-note { margin-top: auto; padding-top: 12px; font-size: 12px; line-height: 1.5; }
}
@media (max-width: 760px) {
  .exercise-intro { width: min(100%, 52.8vh, 384px); width: min(100%, 52.8dvh, 384px); }
}

/* Center the occupied player columns without changing frame geometry. */
.layout { justify-content: center; }
@media (max-width: 760px) {
  .layout { grid-template-columns: minmax(0, min(52.8vh, 384px)); grid-template-columns: minmax(0, min(52.8dvh, 384px)); }
}

/* PC-only tools stay left of the image and reserve space only while editing. */
.viewer { position: relative; }
main.image-adjust-space { padding-left: 124px; }
.image-adjust-toggle { align-self: flex-start; min-height: 32px; margin: 10px 0; padding: 5px 9px; font-size: 12px; }
.image-adjust-panel { position: absolute; right: calc(100% + 8px); top: 0; width: 108px; padding: 6px; border: 1px solid #b5c2ba; border-radius: 10px; background: #fff; box-shadow: 0 4px 14px #21352e12; }
.image-adjust-heading { display: flex; align-items: center; justify-content: space-between; gap: 2px; margin-bottom: 4px; }
.image-adjust-heading strong { font-size: 11px; line-height: 1.35; }
.image-adjust-heading button { padding: 0; min-height: 22px; width: 22px; flex-shrink: 0; font-size: 18px; border-color: transparent; }
.image-adjust-section-label { display: block; font-size: 10px; font-weight: 700; margin: 4px 0; color: #5b6a63; }
.image-adjust-directions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.image-adjust-directions button, .image-adjust-zoom button { min-height: 26px; padding: 1px; font-size: 17px; }
[data-image-adjust="up"], [data-image-adjust="taller"] { grid-column: 2; }
[data-image-adjust="left"], [data-image-adjust="narrower"] { grid-column: 1; grid-row: 2; }
[data-image-adjust="right"], [data-image-adjust="wider"] { grid-column: 3; grid-row: 2; }
[data-image-adjust="down"], [data-image-adjust="shorter"] { grid-column: 2; grid-row: 3; }
.image-adjust-zoom { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 5px 0 8px; }
.image-adjust-frames { display: flex; gap: 2px; margin: 8px 0 5px; }
.image-adjust-frames button { flex: 1; min-width: 0; min-height: 26px; padding: 2px 0; font-size: 12px; font-weight: 700; }
.image-adjust-frames [aria-pressed="true"] { background: #e0ece5; border-color: #205c43; color: #174630; }
#image-adjust-save { width: 100%; min-height: 30px; padding: 3px 0; font-size: 12px; }
.image-adjust-values { display: block; margin-top: 7px; font-size: 10px; line-height: 1.5; white-space: pre-line; font-variant-numeric: tabular-nums; }
.image-adjust-status, .image-adjust-file-note { margin-top: 6px; font-size: 10px; line-height: 1.45; overflow-wrap: anywhere; color: #205c43; }
.image-adjust-file-note { color: #5b6a63; }
@media (max-width: 760px), (hover: none), (pointer: coarse) {
  .image-adjust-toggle, .image-adjust-panel { display: none !important; }
}

/* Compact workout order: title, live progress/actions, image, settings. */
@media (max-width: 760px), (max-width: 1000px) and (max-height: 500px) {
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; gap: 12px; }
  .exercise-intro { grid-column: 1; grid-row: 1; width: 100%; height: auto; display: block; padding: 8px 12px; }
  .caption { height: auto; }
  .caption h2 { white-space: normal; }
  #exercise-intro-toggle { min-height: 44px; }
  #exercise-name { flex: 1; font-size: 20px; line-height: 1.35; overflow-wrap: anywhere; }
  .intro-toggle-hint { display: block; flex-shrink: 0; font-size: 12px; font-weight: 600; color: #5b6a63; }
  #exercise-description:not([hidden]) { display: block; padding: 6px 0 4px; }
  .purpose { white-space: normal; line-height: 1.6; }
  #exercise-guide { display: block; height: auto; overflow: visible; margin-top: 6px; -webkit-line-clamp: unset; }
  .controls { display: contents; }
  .workout-live, .workout-settings { display: block; min-width: 0; padding: 12px; border: 1px solid #d7dfd9; border-radius: 12px; background: #fff; }
  .workout-live { grid-column: 1; grid-row: 2; }
  .viewer { grid-column: 1; grid-row: 3; }
  .workout-settings { grid-column: 1; grid-row: 4; }
  .stage { width: 100%; max-width: 384px; margin-inline: auto; }
  .workout-live .counter { margin: 0 0 8px; }
  .workout-live .counter strong { font-size: 32px; line-height: 1.1; }
  .workout-live .actions { margin-top: 10px; }
  .workout-settings .count-help { margin-top: 0; }
  .workout-settings .settings-note { margin-top: 16px; }
  #workout { scroll-margin-top: 8px; }
}
