body.in-session > :is(header,main,footer) { display:none; }
.stage {
  --ground:var(--pine); --type:var(--paper); --accent:var(--apricot); --track:#738578;
  --gutter:clamp(1rem,4vw,3.5rem);
  background:var(--ground); color:var(--type);
  height:100svh; height:100dvh; display:flex; flex-direction:column;
  padding:env(safe-area-inset-top) max(var(--gutter),env(safe-area-inset-right)) env(safe-area-inset-bottom) max(var(--gutter),env(safe-area-inset-left));
}
.stage[hidden], .stage [hidden], .stage.finished :is(.stage-time,.stage-exit) { display:none; }
.stage button { background:transparent; color:inherit; border:1px solid var(--track); border-radius:5px; min-height:46px; padding:.65rem 1rem; }
.stage button:focus-visible { outline:3px solid var(--accent); outline-offset:3px; }
.stage-head,.stage-dock { width:min(100%,66rem); margin-inline:auto; flex:none; }
.stage-head { display:flex; align-items:center; gap:.7rem; min-height:3.75rem; border-bottom:1px solid var(--track); }
.session-heading { display:grid; gap:.12rem; }
#stageRoutine { font:1.1rem/1.15 var(--serif); }
#stagePhase { font:.85rem/1.2 var(--mono); color:var(--accent); }
.stage .stage-exit { margin-left:auto; border:0; padding-inline:.25rem; font-size:.9rem; text-decoration:underline; text-underline-offset:.22em; }
.exercise-layout {
  flex:1; min-height:0; overflow:auto; display:grid; text-align:center; justify-items:center;
  grid-template-rows:minmax(min-content,1fr) auto auto minmax(min-content,1fr);
  padding-block:clamp(.5rem,2dvh,1.5rem);
}
#stageTitle { align-self:end; margin:0; max-width:22ch; font:normal clamp(2.2rem,8.8vw,5rem)/1 var(--serif); letter-spacing:-.038em; text-wrap:balance; }
#stageTarget {
  margin:.35rem 0 0; min-height:2.2em; align-content:start; max-width:26ch;
  font:700 clamp(1.55rem,7vw,2.9rem)/1.1 Arial,sans-serif; color:var(--accent); text-wrap:balance;
}
.target-detail { font-size:.72em; font-weight:500; white-space:nowrap; }
.stage-time { width:min(100%,clamp(16rem,68vw,32rem)); margin:0 auto; text-align:center; }
#clock {
  font:600 clamp(6rem,min(36vw,21dvh),12.5rem)/.92 'Layover clock',var(--mono);
  font-variant-numeric:tabular-nums; letter-spacing:-.02em;
}
.second-scale { display:block; overflow:visible; width:100%; height:clamp(.65rem,1.7dvh,1rem); margin:clamp(.55rem,1.7dvh,1rem) auto 0; fill:none; stroke-width:1.65; }
.scale-track { stroke:var(--track); }
.scale-active { stroke:var(--accent); }
#stageCue { align-self:start; margin:clamp(.85rem,2.7dvh,2rem) auto 0; max-width:44ch; font-size:clamp(1rem,1.5vw,1.3rem); line-height:1.45; text-wrap:pretty; }
.stage-route { height:2px; background:var(--track); }
#fill { height:100%; background:var(--accent); }
.stage-foot { padding:.65rem 0 .8rem; display:grid; gap:.55rem; }
.stage-foot > div:first-child { display:flex; justify-content:space-between; align-items:baseline; gap:.7rem; min-height:2.5em; }
#stageNext { margin:0; font-size:.96rem; font-weight:600; line-height:1.3; }
#remaining { flex:none; font: .85rem/1.3 var(--mono); }
.stage-buttons { display:flex; gap:.65rem; }
.stage-buttons button { flex:1; }
#stagePause { background:var(--accent); border-color:var(--accent); color:var(--ground); font-weight:700; }
.stage.finished .exercise-layout { align-content:center; grid-template-rows:auto auto auto; }
.stage.finished #stageTarget { min-height:0; }
.stage.finished .stage-foot > div:first-child { display:none; }
@media(min-width:700px) {
  .stage-head { min-height:4.25rem; }
  .session-heading,.stage-foot { display:flex; align-items:center; gap:1rem; }
  .stage-foot { justify-content:space-between; padding-block:1rem; }
  .stage-foot > div:first-child { display:grid; gap:.15rem; }
  .stage-buttons button { min-width:6rem; }
}
@media(max-width:390px) { #remaining { max-width:13ch; text-align:right; } }
@media(max-height:520px) and (orientation:landscape) {
  .stage-head { min-height:2.8rem; }
  .exercise-layout { align-content:center; grid-template-columns:minmax(0,1fr) minmax(0,1fr); grid-template-rows:auto auto auto; column-gap:1.5rem; }
  #stageTitle { grid-column:1; font-size:clamp(1.6rem,5vw,3rem); }
  #stageTarget { grid-column:1; min-height:0; font-size:1.45rem; }
  .exercise-layout .stage-time { grid-column:2; grid-row:1/4; width:85%; align-self:center; }
  #stageCue { grid-column:1; font-size:.95rem; margin-top:.5rem; }
  .stage-foot { display:flex; justify-content:space-between; align-items:center; }
  .stage-foot > div:first-child { display:grid; gap:0; }
}

.stage.night { --ground:#242f3b; --type:#f8efe0; --accent:#e2c19f; --track:#79828a; }
.stage.resting, .stage.finished { --ground:var(--paper); --type:var(--ink); --accent:var(--sienna); --track:var(--line); }
.stage.resting #stagePause, .stage.finished #stagePause { background:var(--pine); color:var(--paper); border-color:var(--pine); }
.stage-sketch { width:clamp(2.9rem,9vw,4.1rem); height:auto; flex:none; object-fit:contain; filter:invert(1) sepia(.62); }
.stage.resting .stage-sketch { filter:none; }
.stage.finished #stageTitle { color:var(--pine); }

@media(max-height:520px) and (orientation:landscape) {
  .stage-sketch { max-height:32px; }
}

.stage button.modify-action {
  display:block; min-height:44px; margin:0 auto; padding:.35rem .55rem;
  color:var(--accent); font-size:.9rem; border:0; text-decoration:underline; text-underline-offset:.22em;
}
.stage button.modify-action[hidden] { display:none; }
.stage #modifyNext { margin:0; padding:0; text-align:left; font-weight:600; }

#stageTitle { max-width:20ch; font-size:clamp(2.8rem,13.6vw,6.8rem); line-height:1.01; overflow-wrap:break-word; }
#clock { font-size:clamp(4.2rem,min(23vw,13dvh),8rem); }
.active-side { display:inline-flex; align-items:center; justify-content:center; gap:.23em; font-size:clamp(1.8rem,8vw,3.3rem); line-height:1.1; }
.active-side .icon { width:1em; height:1em; flex:none; stroke-width:2.5; }
.stage #soundToggle { display:grid; place-items:center; margin-left:auto; padding:.4rem; min-width:44px; border:0; }
.stage .stage-exit { margin-left:0; white-space:nowrap; }
.stage.finished #soundToggle { display:none; }
@media (orientation:landscape) and (max-height:520px) {
  #stageTitle { font-size:clamp(2.05rem,5.3vw,3.9rem); }
  #clock { font-size:clamp(3.7rem,18dvh,6rem); }
  .active-side { font-size:clamp(1.5rem,5.8dvh,2rem); }
}

#effortCue:not([hidden]) { display:block; margin:.35em auto 0; font-size:.85em; }

.move-guide { grid-row:4; align-self:start; width:100%; max-width:34rem; min-width:0; }
#stageCue { margin-inline:auto; }
#cueText { margin:0; }
/* The target and tools share the foot of the illustration area. */
.guide-actions {
  display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center;
  gap:.5rem;
}
.guide-tools { grid-column:2; display:flex; align-items:center; gap:.25rem; }
.stage .guide-icon {
  display:grid; place-items:center; width:44px; min-height:44px; padding:0;
  border:0; border-radius:50%; color:var(--type);
}
.stage .guide-icon:hover, .stage .guide-icon:focus-visible {
  color:var(--accent); background:color-mix(in srgb,var(--type) 8%,var(--ground));
}
.stage .guide-icon[hidden] { display:none; }
.guide-icon .icon { width:1.25rem; height:1.25rem; }
#stageDose {
  justify-self:start; margin:0;
  padding:.28rem .55rem .32rem;
  border:1px solid color-mix(in srgb,var(--accent) 34%,var(--ground));
  border-radius:.35rem;
  color:var(--accent); background:var(--ground);
  font:700 clamp(1.12rem,5.2vw,1.65rem)/1.05 Arial,sans-serif;
  font-variant-numeric:tabular-nums;
}
#stageDose .target-detail { display:block; margin-top:.18rem; font-size:.65em; white-space:normal; }
.has-sketch .exercise-layout {
  grid-template-rows:auto auto auto minmax(0,1fr);
  align-content:start;
  padding-block:clamp(.55rem,1.8dvh,1.1rem) .45rem;
  row-gap:.35rem;
}
.has-sketch #stageTitle { grid-row:1; font-size:clamp(2.2rem,11vw,5.25rem); max-width:21ch; }
.has-sketch #stageTarget { grid-row:2; margin:0; min-height:0; font-size:clamp(1.18rem,4.6vw,1.75rem); }
.has-sketch .active-side { font-size:clamp(1.35rem,5.4vw,2.4rem); }
.has-sketch .stage-time { grid-row:3; margin-top:.15rem; }
.has-sketch #clock { font-size:clamp(3rem,min(17vw,9dvh),5.5rem); }
.has-sketch .second-scale { height:.45rem; margin-top:.3rem; }
.has-sketch .move-guide { display:grid; grid-template-rows:minmax(7rem,1fr) minmax(44px,auto); align-self:stretch; }
.has-sketch .guide-panel { display:grid; place-items:center; min-height:0; container-type:size; }
.has-sketch .guide-actions { z-index:1; margin-block-start:-.3rem; }
.has-sketch #stageCue {
  align-self:center;
  width:100%;
  max-height:100%;
  padding:.5rem .65rem;
  margin:0;
  overflow:auto;
}
.sketch-frame {
  position:relative;
  overflow:hidden;
  width:min(100%, calc(var(--art-ratio) * min(96cqh, 25rem)));
  aspect-ratio:var(--art-ratio);
}
.sketch-frame img { position:absolute; inset:var(--tile-y) auto auto var(--tile-x); max-width:none; }
.sketch-frame .loading-sketch { visibility:hidden; }
.stage.finished .move-guide { display:none; }
.has-sketch .stage-foot > div:first-child { min-height:1.5em; }
.has-sketch .stage-foot { gap:.45rem; }
@media (max-height:650px) and (orientation:portrait) {
  .has-sketch .exercise-layout { padding-block:.45rem .25rem; gap:.27rem; }
  .has-sketch #stageTitle { font-size:clamp(1.8rem,9.5vw,2.8rem); }
  .has-sketch #clock { font-size:clamp(2.65rem,8dvh,3.5rem); }
  .has-sketch .stage-foot { padding-block:.45rem .5rem; }
}
@media (min-width:800px) and (orientation:landscape) {
  .has-sketch .exercise-layout {
    width:min(100%,66rem);
    margin-inline:auto;
    grid-template-columns:minmax(15rem, 2fr) minmax(20rem,3fr);
    grid-template-rows:minmax(0,1fr) auto minmax(0,1fr);
    column-gap:1rem;
  }
  .has-sketch #stageTitle { grid-area:1 / 1; font-size:clamp(2.25rem,5vw,4.5rem); }
  .has-sketch #stageTarget { grid-area:2 / 1; }
  .has-sketch .stage-time { grid-area:3 / 1; width:85%; align-self:start; margin-top:.4rem; }
  .has-sketch .move-guide { grid-area:1 / 2 / 4; max-width:none; }
}
@media (orientation:landscape) and (max-height:520px) {
  .has-sketch .exercise-layout {
    grid-template-columns:minmax(12rem, 2fr) minmax(13rem,3fr);
    grid-template-rows:auto auto minmax(0,1fr);
    column-gap:.75rem;
  }
  .has-sketch #stageTitle { grid-area:1 / 1; font-size:clamp(1.65rem,7dvh,2.5rem); }
  .has-sketch #stageTarget { grid-area:2 / 1; font-size:1.25rem; }
  .has-sketch .active-side { font-size:1.25rem; }
  .has-sketch #clock { font-size:clamp(2.5rem,11dvh,4.25rem); }
  .has-sketch .stage-time { grid-area:3 / 1; width:85%; align-self:start; margin-top:.35rem; }
  .has-sketch .move-guide { grid-area:1 / 2 / 4; }
  .has-sketch .stage-foot > div:first-child { min-height:0; }
}

@media (max-width:360px) {
  .stage-head { gap:.4rem; }
  .stage-sketch { width:2rem; }
  #stageRoutine { font-size:1rem; }
  #stagePhase { font-size:.73rem; }
  .guide-tools { gap:0; }
}

.stage.finished .exercise-layout, .stage.finished .stage-head, .stage.finished .stage-route {display:none}
#printPanel:not([hidden]) {display:flex;flex-direction:column;align-items:center;flex:1;min-height:0;overflow:auto;padding:clamp(.75rem,2vh,1.5rem) 0;text-align:center}
#wallPrint {display:block;width:min(100%,29rem);height:auto;flex:none;margin:auto auto 0}
.print-actions {display:flex;justify-content:center;gap:.6rem;margin:.85rem auto 0}
#printStatus {margin:0 0 auto}
.stage.finished .stage-foot {justify-content:center}
.stage.finished .stage-buttons {width:min(100%,29rem);margin:auto}
