/* Ink Motion · fit (update 8e layout stress; Q-GAUGE »Make sure layout doesn't break though also for longer texts«,
   tests/e2e/layout-stress.spec.js): every text slot holds its longest real string at 320–412 px, also at Android's large
   font scale — Chrome applies it as page zoom, so a 320×568 phone at 1.3 lays out at 246×437 CSS px (its 64-px targets
   are 83 px on the glass). What gives way, in this order: pictures and decoration, second-tier lines the coach says
   anyway, then the type (stepped by the column width) — never a word inside itself, never the timer. Loaded last.
   Bug hunt 10c (fix round): a rep set's »Erklärung« tag gives way up to 760 px tall (it ran into the exercise name). */

/* 1 · CALLOUTS — the type is capped at what the column holds for the widest unbreakable word (--cw: its em width in
   Barlow Condensed caps, ui/workout-bits.js fitWords); an explanation over 64 characters takes the 'xxs' step */
.ws .callout{--cwf:calc((min(100vw - 32px,600px) - 2px) / var(--cw,.01));
  font-size:min(clamp(32px,max(10vw,min(12.4vw,6.4vh)),58px),var(--cwf))}
.ws .callout.sm{font-size:min(clamp(28px,max(10vw,min(11vw,5.4vh)),50px),var(--cwf))}
.ws .callout.xs{font-size:min(clamp(28px,10vw,44px),var(--cwf))}
.ws .callout.xxs{font-size:min(clamp(20px,6.6vw,32px),var(--cwf));line-height:1}

/* 2 · THE RING BOX — it keeps the digits' height (AC 20: never under 26vw); while the ring shows, the breath count and
   the Trinkpause drop keep clear of the digits (--tf: the rest digits' size); once the ensō has given way (container
   ring ≤ 66vw) they stack under the digits instead of floating at ring positions */
.dial-box{min-height:calc(min(26vw,28vh) * .86 + 4px)}
.dial-box.rest-box{min-height:calc(min(26vw,28vh) * .86 + 34px)}
.dial.rest{--tf:min(max(26vw,calc(var(--d) * .33)),28vh)}
.dial.rest>:is(.breath,.breath-count){top:calc(50% + max(var(--d) * .17,var(--tf) * .46))}
.dial.drink>.drop{top:calc(50% + max(var(--d) * .16,var(--tf) * .46))}
@container ring (max-height:66vw){
  .dial.rest{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px}
  .dial.rest>:is(.breath,.breath-count,.drop){position:relative;top:auto;left:auto;right:auto;translate:none}
  .dial.drink>.drop{width:24px;height:24px}
}
/* the Weg-Karte's minutes wrap at their » · « only (two phrases, ui/session-gauge.js), never before the dot */
.gauge.big .g-nums>span{white-space:nowrap}
/* the combo hero squeezed under 90 px by a long explanation: the ring, its figure and the NEU seal step aside */
.combo.hero{container-name:hero}
@container hero (max-height:90px){.combo.hero>.dial{display:none}}

/* 3 · REP SET — the demo gives way like the pictogram: it shrinks to its share, never pushes the count into the clock */
.reps-mid>.grp>.rep-demo{flex:0 1 auto;min-height:min(56px,7vh);display:flex;justify-content:center}
.reps-mid>.grp>.rep-demo>.rep-host{height:100%;min-height:0;display:flex;align-items:center;justify-content:center}
.reps-mid>.grp>.rep-demo>.rep-host>.dm{max-height:100%}
/* a rep set's »Erklärung« tag hangs in the gap above its clock (its 12–15 px type + 6 px): up to 760 px tall that gap,
   less the count's overflow into it (8 px for the longest set at 317×704), leaves it no room — it gives way there (bug
   hunt 10c); the dimmed 0:00 still says »not yet«, and the coach is explaining */
@media (max-height:760px){.prog>.lead-tag{display:none}}

/* 4 · STATUS ROW — »Sag »Andere«« (the glove-up explains the word, the pause overlay says it) gives way on a narrow row,
   in the pause veil the tap icons too (the glove tip says »Unterarm tippen«): one row, clear of the bottom region */
.status{container:status/inline-size}
@container status (max-width:270px){.status .say-hint,.ov .status .tap-hint{display:none}}
/* the NEU seal on a rep demo stays inside the box's top edge: the demo now fills to the label row above it */
.reps-mid .rep-demo .dm-new.sm{top:4px}

/* update 11: a long Kombi des Tages wraps before »Jab blocken« leaves its column (412 px at the large font scale) */
.ws .kdt .cstrip:has(li:nth-child(7)){flex-wrap:wrap;row-gap:6px}
.ws .kdt .cstrip:has(li:nth-child(7)) li{min-width:44px}

/* 5 · NARROW COLUMNS (≤ 300 px: 320 and 360 px phones at the large font scale) */
@media (max-width:300px){
  /* the Kombi des Tages breaks into rows at its » — « beats; a cell keeps a readable width */
  .ws .kdt .cstrip{flex-wrap:wrap;row-gap:6px}
  .ws .kdt .cstrip li{min-width:44px}
  .ws .kdt .cstrip>.cp-div{flex-basis:100%;max-width:none;height:0;min-height:0;margin:0}
  /* Setup: the dial takes the column, its pushers sit under it (− left, + right); the topbar grows with the update note */
  #screen-setup.s-setup{--dd:min(210px,calc(100vw - 2 * var(--gut)))} /* over the easy-hint / drink-line sizes */
  .clockrow{grid-template-columns:var(--dd)}
  .pushers{grid-auto-flow:column;justify-content:center;gap:24px}
  .pushers>:first-child{order:1}
  .topbar{height:auto;min-height:64px}
  /* Vor dem Start: the legend wraps inside its groups; the offline row's count goes under its title */
  .chk .cmds .cg{white-space:normal}
  .chk .row.off{grid-template-columns:28px minmax(0,1fr) 34px}
  .chk .row.off .meta{grid-column:2;grid-row:2}
  .chk .row-t b{font-size:17px}
  /* Geschafft: the weight on its own line over − and +; the rating 2 + 1 */
  .fs-kg{grid-template-columns:1fr 1fr}
  .fs-kg .fs-kg-v{grid-column:1/-1;grid-row:2}
  .fs-kg .fs-sign{grid-row:3;justify-self:center}
  .fin .rate{grid-template-columns:repeat(2,minmax(0,1fr))}
  .fin .rate>.btn:last-child{grid-column:1/-1}
  /* »Training unterbrochen«: the stamp's word fits the column */
  .res .btn-start{padding:0 8px;font-size:clamp(18px,8vw,34px)}
  .res-end{min-width:min(220px,100%)}
  /* the pause confirm's safe choice keeps »Weitertrainieren« whole */
  .confirm.big .btn{font-size:clamp(17px,7vw,22px)}
  .confirm.big .stay svg{display:none}
}
/* 601–640 px tall (a 360×800 phone at the large font scale): the minutes label still shows, so the label row keeps its
   24 px under it (the short-screen 16 px suits only the screens where gauge.css hides the label) */
@media (min-height:601px) and (max-height:640px){.wk-field>.ws{padding-top:max(24px,calc(env(safe-area-inset-top) + 12px))}}
/* every width: Setup's title and minutes, Geschafft's numbers and the check rows step with the column (the minutes
   keep clear of the knob at 60 on a small dial); long compounds hyphenate */
.s-setup h1{font-size:min(44px,12.6vw,calc((100vw - 2 * var(--gut)) / 6.9))}
.readout .n{font-size:clamp(44px,min(var(--dd) * .3,var(--dd) * .48 - 40px),76px)}
.fs .num{font-size:clamp(22px,min(11vw,(100vw - 2 * var(--gut)) * .128),44px)}
.chk .row{flex-wrap:wrap;row-gap:6px}
.chk .row>.row-t{flex:1 1 9em}
.chk .row>.row-t+*{margin-left:auto}
.chk .row-t,.fun-title,.fun-note,.fin .fb-text,.fd-t,.res-where,.res-what,.ov .btn,.confirm.big p{hyphens:auto}

/* 6 · VERY SHORT SCREENS (≤ 500 px tall: a 320×568 phone at the large font scale) */
@media (max-height:500px){
  .status .icons,.status .tap-hint{min-height:40px}
  .mic-on{font-size:17px}
  .tap-hint{font-size:15px}
  .wk-field>.status{margin-bottom:calc(4px + env(safe-area-inset-bottom))}
  .ws-mid,.reps-mid,.rc-mid,.glove-mid{gap:8px}
  /* pictures and the lines the coach says anyway give way first */
  .task svg.task-pic,.task-demo,.reps-mid .rep-pic,.reps-mid>.grp>.rep-demo,.rc-mid .rep-pic,.glove-pic,.next-card .next-combo,
  .drink-note,.rc-mid .rmsg,.rc-mid .rep-more{display:none}
  .rep-n b{font-size:min(80px,12vh)}
  .fertig{min-height:64px;font-size:26px}
  .mode-chip{min-height:56px;font-size:26px}
  .dial.compact{--dial:min(110px,22vh)}
  .dial-box.rest-box{min-height:calc(min(26vw,28vh) * .86 + 26px)} /* the digits and the stacked drop or breath count */
  .dial>.neu-host>.dm-new{top:auto;bottom:0} /* on a small ring the seal leaves the »Erklärung« tag above it */
  .banner.rc.xxl{padding:14px 16px 16px;gap:6px}
  .banner.rc.xxl>svg{width:40px;height:40px}
  .banner.rc.xxl h2{font-size:clamp(26px,10.5vw,40px)}
  .banner.rc.xxl p{font-size:17px}
  /* the pause veil: Block überspringen and Beenden side by side under Fortsetzen, the decoration and the tap icons go */
  .ov .ws{padding-bottom:calc(60px + env(safe-area-inset-bottom))}
  .ov .ws-mid{gap:8px}
  .ov .status .tap-hint{display:none}
  .pause-h,.ov .ws-mid:has(.swap) .pause-h{font-size:30px}
  .ov .dock{grid-template-columns:1fr 1fr;gap:18px}
  .ov .dock>.btn{min-height:64px;padding:0 8px;gap:6px;font-size:16px}
  .ov .dock>.btn:not(.resume) svg{display:none}
  .ov .dock>.btn:not(.resume){padding:0 4px;font:700 18px/1.1 var(--num)} /* condensed: »Block | überspringen« in two lines */
  .ov .dock>.btn.resume,.ov:has(.swap) .dock>.btn.resume{grid-column:1/-1;min-height:72px;font-size:26px}
  .ov .dock>.btn:only-child,.ov .dock>.resume+.btn:last-child{grid-column:1/-1}
  .ov .btn.swap{margin-bottom:6px}
  .confirm.big{padding:14px 16px 16px;gap:10px}
  .confirm.big p{font-size:22px}
  .confirm.big .acts{gap:18px}
  .confirm.big .btn{min-height:64px;font-size:19px}
  .confirm.big .stay{min-height:72px}
  .ov .dial.stop{--d:min(150px,29vh)} /* --d: ui/pause.js pins --dial (280px) inline */
  .pill.stopp{min-height:60px;font-size:22px}
}

/* 7 · RECOVERY CARDS — a card never shrinks under its text (.banner's min-height turns the flex item's automatic minimum
   off: »Keine Verbindung« spilled over the clock at 320×568, its icon over the label); under it the rep picture and the
   extra line give way up to 760 px, and up to 640 px the icon stands beside the title (one row, the sentence under it) */
.rc-mid>.banner{flex-shrink:0}
/* Update 12: a tall phone at the large font scale (412×915 at ×1.3 lays out at 317×704): the rep set's small line, which the coach says
   anyway, gives way before it wraps into the timer */
@media (max-height:720px) and (max-width:340px){.reps-mid .rep-more{display:none}}
@media (max-height:760px){
  .rc-mid:has(>.banner) :is(.rep-pic,.rep-more){display:none}
  .rc-mid>.dial.compact{--dial:min(200px,26vh)} /* the clock under the card: it ran into the status row */
}
@media (max-height:640px){
  .banner.rc:not(.xxl){flex-flow:row wrap;justify-content:center;align-items:center;gap:4px 10px;padding:14px 16px 16px}
  .banner.rc:not(.xxl)>svg{width:32px;height:32px}
  .banner.rc:not(.xxl)>h2{flex:1 1 0;max-width:max-content;font-size:26px;text-align:left}
  .banner.rc:not(.xxl)>h2.long{font-size:22px}
  .banner.rc:not(.xxl)>p{flex:1 0 100%;font-size:17px;line-height:1.25}
  .banner.rc:not(.xxl)>p.lead{order:1}
  .banner.rc.xxl>svg{width:44px;height:44px}
  .rc-mid>.dial.compact{--dial:min(140px,24vh)}
  /* under the wake alarm the clock gives way, never the alarm (9b layout stress: the longest round title on two lines +
     the alarm pushed the clock 6–14 px into the status row at 320×568) */
  .rc-mid:has(>.banner.xxl)>.dial.compact{--dial:min(110px,17vh)}
}
@media (max-height:500px){.rc-mid>.dial.compact{--dial:min(110px,22vh)}}
/* the pause veil without »Andere Kombi« keeps the Weg-Karte; up to 760 px the say pill gives way (the glove tip says it) —
   at 317×704 (a 412×915 phone at the large font scale) the tip ran under Fortsetzen */
@media (max-height:760px){.ov .ws-mid:has(.p-weg) .pill.say{display:none}}

/* 8 · THE BESTZEIT SEAL — pressed over the step label for its 6 s (the label steps aside, still read), never on the
   count, the clock or the demo below (at 246 px it covered the »20«) */
.ws{anchor-scope:--wk-label}
.ws>h1{anchor-name:--wk-label}
.ws>.best{position:absolute;position-anchor:--wk-label;top:anchor(center);left:anchor(center);translate:-50% -50%;margin:0}
.ws:has(>.best:not([hidden]))>h1{opacity:0}

/* »Unterbrochen« (audio lost) covers the field like the pause veil: the session gauge (z-index 1) painted over it; on a
   short screen the disk's ripple ring keeps clear of the label */
.ph-pause:has(>.tapall){position:absolute;inset:0;z-index:10}
@media (max-height:500px){
  .tapall .ws-mid{gap:14px}
  .tapdisk{width:min(232px,24vh);height:min(232px,24vh);margin-top:20px}
  .tapall .rsub{font-size:17px}
}
/* a » · « separator rides on the word before it (ui/dom.js glued): the step label, »Training unterbrochen«'s where */
.ws>h1 .nw,.res-card .nw{white-space:nowrap}

/* 9 · NOTES AND HINTS — a dropped command's note covers the whole status row (the forearm hint too) and stays two lines
   on a narrow row; Vor dem Start's »keine Berührung nötig« wraps under its ruler instead of running onto the phone */
.status:has(.drop-note:not([hidden])) .tap-hint{visibility:hidden}
@media (max-width:359px){.drop-note{padding:8px 12px;font-size:15px}}
@media (max-width:300px){
  /* Mario-Runde: the meaning under the call word takes two lines here, the pad pose (one big moving figure) keeps clear */
  .pad-how{font-size:16px}
  .pad-pose{height:min(48%,calc(54% - 2.4 * 16px))}
  .chk .dist{margin-bottom:22px;padding-left:6px}
  .chk .dist .picto{--ps:52px}
  .chk .dist .ruler span{width:calc(100% + 20px);white-space:normal;text-align:center;font-size:12px;line-height:1.15}
}
