/* Layout: one 9:16 stage (the reel) laid out like a lab instrument — HUD counters, title,
   a polar "rhythm scope", a per-scene readout and a scrolling multitrack lane view.
   Phone: only Play and the clock under the stage. Desktop: the timeline on the left, sounds on the right.
   Sizes inside the stage are in cqw (percent of the stage width) so it scales as one picture. */
/* The two variable fonts are served from the site (#11): the Latin subsets Google Fonts serves,
   from Fontsource 5.3.0, under the SIL Open Font License (fonts/OFL-*.txt). */
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url("fonts/space-grotesk-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("fonts/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215,
    U+FEFF, U+FFFD;
}
:root {
  color-scheme: dark;
  /* Palette: one owner, src/theme.js COLORS; tests/styles.test.js keeps these equal to it. */
  --void: #07060b;
  --fg: #ece8ff;
  --amber: #ffc53d;
  --ember: #ff5a36;
  --ice: #3fd7ff;
  --magenta: #ff4fa3;
  /* translucent colours, built from the palette's channels */
  --line: rgba(236, 232, 255, 0.16); /* fg */
  --dim: rgba(236, 232, 255, 0.55); /* fg */
  --link-stopped: rgba(236, 232, 255, 0.62); /* fg: the source link over the stopped stage */
  --split-pink: rgba(255, 79, 163, 0.75); /* magenta */
  --split-cyan: rgba(63, 215, 255, 0.75); /* ice */
  /* roles point at the palette (src/theme.js ROLES) */
  --accent: var(--amber);
  --main-hand: var(--amber);
  --answer-hand: var(--ember);
  --f-display: "Space Grotesk", "Helvetica Neue", Arial, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  /* Controls (outside the stage): rem, so they follow the reader's text size; the values in use. */
  --space-1: 0.125rem; /* 2px */
  --space-2: 0.25rem; /* 4px */
  --space-3: 0.375rem; /* 6px */
  --space-4: 0.5rem; /* 8px */
  --space-5: 0.625rem; /* 10px */
  --space-6: 0.75rem; /* 12px */
  --space-7: 0.875rem; /* 14px */
  --space-8: 1rem; /* 16px */
  --space-9: 1.125rem; /* 18px */
  --space-11: 2.5rem; /* 40px */
  --chip-padding: 0.3125rem 0.6875rem; /* 5px 11px */
  --text-xs: 0.6875rem; /* 11px */
  --text-s: 0.75rem; /* 12px */
  --text-m: 0.8125rem; /* 13px */
  --text-l: 0.875rem; /* 14px */
  --text-xl: 1.125rem; /* 18px */
  --text-display: 2.75rem; /* 44px */
  --radius-pill: 6.1875rem; /* 99px */
  --radius-stage: 0.75rem; /* 12px */
  --play-min-width: 8.125rem; /* 130px */
  /* Stage text: five steps in cqw (percent of the stage width), so the reel scales as one picture. */
  --stage-label: 2.2cqw;
  --stage-text: 2.6cqw;
  --stage-figure-s: 7cqw;
  --stage-figure: 11cqw;
  --stage-title: 13cqw;
  --gutter: var(--space-8);
  --controls-height: 0px; /* phones: nothing under the stage; it is its own Play button */
  --desktop-side: 340px;
  --stage-ratio: calc(393 / 852); /* in calc(), so dividing by it divides by the whole ratio */ /* desktop stage: an iPhone screen's shape */
  --label-at-phone: 2.8cqw; /* 11px on a 393px stage */
  --text-at-phone: 3.31cqw; /* 13px on a 393px stage */
  --tap-label-size: 4.58cqw; /* the Play overlay: 18px on a 393px stage */
  --tap-time-size: 3.56cqw; /* its time: 14px on a 393px stage */
  --figure-grow: 4cqw; /* how much a baque's numbers grow on a tall phone */
  --page-max: 100rem; /* 1600px: the widest the three columns get */
  --side-min: 12rem; /* 192px: the longest sound option, «chocalho de platinela», on one line */
}
html,
body {
  height: 100%;
  /* the page never scrolls or bounces: every view fits the window, and only a side column scrolls */
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  margin: 0;
  background: var(--void);
  color: var(--fg);
  font-family: var(--f-display);
  box-sizing: border-box;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-block: max(var(--gutter), env(safe-area-inset-top, 0px)) max(var(--gutter), env(safe-area-inset-bottom, 0px));
}
.wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-7);
}

/* ---------- stage ---------- */
.stage {
  position: relative;
  flex: none;
  width: min(100%, calc((100svh - var(--controls-height)) * 9 / 16)); /* svh: a phone toolbar sliding in and out does not resize the stage (#8) */
  min-width: min(100%, 300px);
  max-width: 100%;
  aspect-ratio: 9 / 16;
  container-type: inline-size;
  background: var(--void);
  border-radius: var(--radius-stage);
  overflow: hidden;
  isolation: isolate;
}
.stage canvas {
  position: absolute;
  display: block;
}
#fx,
#bg {
  inset: 0;
  width: 100%;
  height: 100%;
}
#fx {
  z-index: -3;
}
#bg {
  z-index: -2;
}
.stage::after {
  /* scanlines */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: overlay;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.35) 0 1px, transparent 1px 3px);
}
.inner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 5cqw 5cqw 4.5cqw;
  gap: 2cqw;
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 2cqw;
  font-family: var(--f-mono);
  font-size: var(--stage-label);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}
.hud b {
  color: var(--fg);
  font-weight: 700;
}
.hud .r {
  text-align: right;
}

/* fixed height: the title shrinks to fit long words, and that must never move the wheel */
.head {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.6cqw;
  height: 17cqw;
  flex: none;
}
.eyebrow {
  min-height: 1.2em;
  font-family: var(--f-mono);
  font-size: var(--stage-text);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.title {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: var(--stage-title);
  line-height: 0.9;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  transform-origin: left center;
  min-height: 0.9em;
  /* its chromatic split is drawn by src/title.js every frame, from TINTS */
}

.scope {
  position: relative;
  width: 74cqw;
  aspect-ratio: 1;
  align-self: center;
  max-width: 100%;
  flex: none;
  margin-block: -1cqw;
}
.scope svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

/* ---------- readout ---------- */
.read {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1.4cqw;
  font-family: var(--f-mono);
  font-size: var(--stage-text);
}
.read .k {
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: var(--stage-label);
}
.read .big {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: calc(var(--stage-title) * 1.5); /* the instrument that enters: the scene's focus, larger than the title */
  line-height: 1;
  text-transform: uppercase;
}
.read .row {
  display: flex;
  justify-content: space-between;
  gap: 2cqw;
  align-items: baseline;
}
/* a muted instrument entering: shown, but disabled */
[data-entry].muted .big,
[data-entry].muted .row {
  opacity: 0.2;
}
.notation {
  display: grid;
  grid-template-columns: 13cqw 1fr 12cqw;
  gap: 0.4cqw 2cqw;
  align-items: center;
}
.notation .seq {
  letter-spacing: 0.12em;
  white-space: nowrap;
  font-size: var(--stage-text);
}
.notation .n {
  text-align: right;
  color: var(--dim);
  font-size: var(--stage-label);
}
/* the swing table: the sixteenth, then a meter and its milliseconds for the caixa and the alfaia */
.notation.swing {
  grid-template-columns: minmax(19cqw, max-content) 1fr 9cqw 1fr 9cqw;
  gap: 0.2cqw 1.6cqw;
}
/* one swing meter: a bar from the middle, to the left when early and to the right when late */
.meter {
  position: relative;
  display: block;
  height: 1.6cqw;
  margin: 0.3cqw 0;
}
.meter-bar {
  position: absolute;
  top: 0;
  height: 100%;
}
/* the zero line of each swing meter: one row's piece runs into the next row's, so the column
   shows one continuous line where a hit lands exactly on time */
.notation.swing .zero {
  position: absolute;
  left: 50%;
  top: calc(-1.2cqw - var(--swing-row-gap, 0.2cqw) / 2);
  bottom: calc(-1.2cqw - var(--swing-row-gap, 0.2cqw) / 2);
  width: 1px;
}
/* the swing table: what plays now on a line above it, and its ms legend right under its number
   columns, on every screen */
.read .row.swing-head {
  display: contents; /* beats .read .row's flex */
}
.read .swing-head > :last-child {
  order: 1;
  align-self: flex-end;
}
/* the summary's closing row stands apart from the list of baques above it */
.notation.tight + .row {
  margin-top: 2cqw;
}
.notation.tight {
  grid-template-columns: auto 1fr auto; /* the counts and baque names keep one line */
  gap: 0.1cqw 2cqw;
  line-height: 1.15;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2cqw;
  text-align: center;
}
.stats.two {
  grid-template-columns: 1fr 1fr;
}
.stats .k {
  white-space: pre-line; /* a stat label puts its parts on lines of their own, not « · » */
  line-height: 1.1;
}
.stats b {
  display: block;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: var(--stage-figure);
  line-height: 1;
}
.stats.small b {
  font-size: var(--stage-figure-s);
}
.score {
  position: relative;
  width: 100%;
}
/* a baque scene (stats + score) must fit its box: if it overflowed, the centred column would spill
   up into the wheel and cover its "9" label */
.read:has(> .score) {
  gap: 0;
}
.read > .score {
  width: 54%; /* the widest that keeps a baque scene inside its box (tests/page.test.js) */
  align-self: center;
}
.stats b small {
  font-size: 0.7em; /* the denominator, below its figure */
  opacity: 0.6;
}
.score svg {
  width: 100%;
  height: auto;
  display: block;
}
/* the alfaia's sound waves, in the last two bars of a baque scene: one row per hand */
.wave {
  /* one grid for both hands, so both waves start at the same x */
  display: grid;
  grid-template-columns: max-content 1fr max-content;
  gap: 0.6cqw 3cqw;
  align-items: center;
}
.wave > .k {
  grid-column: 1 / -1;
}
/* the waves stand a little apart from the baque's numbers above them */
.read > .wave {
  margin-top: 2.5cqw;
}
.wave[hidden],
.score[hidden] {
  display: none;
}
.wrow {
  display: contents;
}
.wrow svg {
  width: 100%;
  height: 4.6cqw;
  display: block;
}
.wrow .n {
  text-align: right;
  color: var(--dim);
  font-size: var(--stage-label);
}
.score .scur {
  position: absolute;
  top: 6%;
  bottom: 6%;
  width: 0.4cqw;
  margin-left: -0.2cqw;
  background: var(--fg);
  opacity: 0.55;
  border-radius: 1cqw;
  box-shadow: 0 0 1.2cqw var(--fg);
}
.fade {
  animation: fade 0.35s ease-out both;
}
@keyframes fade {
  from {
    opacity: 0.2;
    transform: translateX(-1.2cqw);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.lanes {
  position: relative;
  height: 37cqw;
  flex: none;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
/* names the wheel's dot colours the lanes do not show as rows (#12); one line, so the canvas keeps
   its height from scene to scene */
.key {
  flex: none;
  display: flex;
  gap: 1.6cqw;
  min-height: 1.3em;
  margin: 0.8cqw 0 0;
  font-family: var(--f-mono);
  font-size: var(--stage-label);
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.lanes canvas {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
}

/* ---------- controls (outside the reel) ---------- */
.side {
  width: min(100%, 720px);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  align-items: center;
  font-family: var(--f-mono);
}
.brand {
  /* phones: hidden from view but kept as the page's heading for screen readers */
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.brand h1 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: var(--text-display);
  line-height: 0.95;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  text-shadow:
    calc(-1 * var(--space-1)) 0 0 var(--split-pink),
    var(--space-1) 0 0 var(--split-cyan);
}
.brand p {
  margin: var(--space-4) 0 0;
  font-size: var(--text-m);
  color: var(--dim);
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.chip:focus-visible,
a:focus-visible {
  outline: var(--space-1) solid var(--fg);
  outline-offset: var(--space-1);
}
.chips {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  justify-content: center;
}
.chip {
  white-space: nowrap;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: var(--chip-padding);
  font-size: var(--text-s);
  color: var(--dim);
}
.chip:hover {
  border-color: var(--dim);
  color: var(--fg);
}
/* the stage itself is the Play and Pause button, on every screen (mobile first, 2026-11-16) */
.tap {
  touch-action: manipulation; /* no double-tap zoom */
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: max(var(--space-5), 2.54cqw);
  padding: 0;
  border: 0;
  border-radius: inherit;
  /* void: a dark veil, darkest at the foot, where the project link sits */
  background: linear-gradient(rgba(7, 6, 11, 0.82) 0 60%, rgba(7, 6, 11, 0.97));
  font-family: var(--f-mono);
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease-out;
}
/* a thumb-sized button: about 54px tall, above the 44pt minimum touch target */
.tap-label {
  background: var(--accent);
  color: var(--void);
  border-radius: var(--radius-pill);
  /* phone sizes (16 x 40px padding, 18px text, 130px wide on a 393px stage), scaled with the stage */
  padding: max(var(--space-8), 4.07cqw) max(var(--space-11), 10.18cqw);
  font-weight: 700;
  font-size: max(var(--text-xl), var(--tap-label-size));
  min-width: max(var(--play-min-width), 33.08cqw);
  box-sizing: border-box;
}
.tap-time {
  font-size: max(var(--text-l), var(--tap-time-size));
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.tap[data-state="pause"] {
  background: transparent;
}
.tap[data-state="pause"] > * {
  visibility: hidden;
}
.tap:focus-visible {
  outline: var(--space-1) solid var(--fg);
  outline-offset: calc(-1 * var(--space-1));
}
/* the rhythm selector, built only with two or more rhythms (main.js): above the Roteiro on desktop,
   under Play on the stopped stage on phones */
.rhythms {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.rhythms .chip {
  text-decoration: none;
}
.rhythms-stage {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% + 18cqw);
  z-index: 6;
  justify-content: center;
}
.tap:where([data-state="pause"]) ~ .rhythms-stage {
  display: none;
}
/* a muted instrument shows disabled wherever the readout shows it (readout.js marks its parts) */
.read [data-muted] {
  opacity: 0.2;
}
.chip[aria-current="true"],
.chip[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
.lbl {
  font-size: var(--text-s);
  color: var(--dim);
  margin: 0;
}
/* one titled block per job: the timeline (where you are in time) and the sounds (what you hear) */
.block {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  width: 100%;
  padding-top: var(--space-8);
  border-top: 1px solid var(--line);
}
.block:first-child {
  padding-top: 0;
  border-top: 0;
}
.side.right,
.side .block {
  display: none; /* phones: the stage alone */
}
/* each column heading (Roteiro, each instrument): set apart from the list under it */
.block-title,
.sound-head > .lbl {
  margin: 0 0 var(--space-4);
  font-family: var(--f-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg);
}
/* the timeline: one rail, one row per scene in show order, the current one lit */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background: var(--line);
}
.step {
  position: relative;
  display: flex;
  gap: var(--space-4);
  align-items: baseline;
  width: 100%;
  padding: var(--space-3) 0 var(--space-3) var(--space-9); /* rows as far apart as the sound options */
  background: none;
  border: 0;
  border-radius: var(--space-2);
  text-align: left;
  font-size: var(--text-s); /* the size of a sound option */
  color: var(--dim);
}
.step::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: calc(-1 * var(--space-2));
  border-radius: 50%;
  background: var(--void);
  border: 1px solid var(--dim);
  box-sizing: border-box;
}
.step .at {
  min-width: 2.375rem; /* 38px: the widest start time, 1:46 */
  font-size: var(--text-s);
  font-variant-numeric: tabular-nums;
}
.step:hover {
  color: var(--fg);
}
.step[aria-current="true"] {
  color: var(--accent);
  font-weight: 700;
}
.step[aria-current="true"]::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 var(--space-3) var(--accent);
}
.step:focus-visible {
  outline: var(--space-1) solid var(--fg);
  outline-offset: var(--space-1);
}
.sound {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
/* a muted instrument dims as a whole, name and options; its slider stays lit to bring it back */
.sound.muted > :not(.sound-head),
.sound.muted .sound-head > .lbl {
  opacity: 0.3;
}
/* an instrument's name line: the name, then its volume slider */
.sound-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  line-height: 1;
}
.vol {
  display: flex;
  align-items: flex-end;
  gap: 0;
}
.volume {
  /* four steps, left to right: mute, low, normal, loud */
  width: calc(var(--space-11) * 1.6);
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
  translate: 0 calc(-2 * var(--space-1)); /* on the name's capitals */
}
.reset {
  align-self: flex-end;
  margin-top: var(--space-6);
}
.reset:disabled {
  opacity: 0.35; /* nothing to restore */
  cursor: default;
}
.volume:focus-visible {
  outline: var(--space-1) solid var(--fg);
  outline-offset: var(--space-1);
}
.foot {
  font-family: var(--f-mono); /* it sits under the reel, outside the mono side columns */
  font-size: var(--text-xs);
  color: var(--dim);
  display: flex;
  gap: var(--space-7);
  flex-wrap: wrap;
  justify-content: center;
  margin: 0;
}
.foot a {
  color: var(--dim);
}

/* ---------- desktop: the reel fills the height, controls on both sides ---------- */
@media (min-width: 900px) {
  .rhythms-stage {
    display: none;
  }
  /* the whole layout sits in the middle of the window, never wider than --page-max */
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-block: 0;
  }
  /* the reel keeps its 9:16 shape and fills the height, unless the columns beside it would fall
     under --side-min: then it narrows and the layout is centred in the height. The columns are
     never taller than the reel. */
  .wrap {
    --stage-width: min(calc(100svh * var(--stage-ratio)), calc(100vw - 2 * var(--gutter) - 2 * var(--side-min) - 2 * var(--space-11)));
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: var(--space-11);
    width: 100%;
    max-width: var(--page-max);
  }
  /* the reel, with the project link centred under it. The stage is laid out at exactly a 393 x 852
     phone screen, and src/main.js zooms it to the column's width: every size inside is the phone's,
     scaled */
  .center {
    order: 2;
    position: relative;
    width: var(--stage-width);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
  }
  .stage {
    width: 393px;
    height: 852px;
    min-width: 0;
    aspect-ratio: auto;
    border-radius: 0;
  }
  /* the project link sits over the foot of the stage while the show is stopped, as on a phone */
  .center > .foot {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(var(--stage-width) * 16 / 393); /* the phone's 16px and 13px, scaled with the stage */
    z-index: 7;
    justify-content: center;
    font-size: calc(var(--stage-width) * 12 / 393); /* the phone's 12px, scaled with the stage */
  }
  .center:has(.tap:not([data-state="pause"])) > .foot {
    display: flex;
  }
  .center > .foot a {
    color: var(--link-stopped);
  }
  html:not(.video-export) .inner {
    --room: 39cqw; /* what a 393 x 852 phone leaves over a 9:16 column: 153px of 393 */
    row-gap: 1.4cqw;
    padding-top: calc(5cqw + min(3cqw, var(--room) * 0.1));
    padding-bottom: calc(4.5cqw + min(3.5cqw, var(--room) * 0.1));
  }
  .side {
    flex: 0 1 var(--desktop-side);
    min-width: var(--side-min);
    align-items: flex-start;
    gap: var(--space-9);
    height: calc(var(--stage-width) / var(--stage-ratio)); /* as tall as the reel */
    box-sizing: border-box; /* the top padding stays inside that height */
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none; /* the columns fit; a very short window still scrolls, without a bar */
    padding-top: var(--space-11);
    /* room for the focus ring, which the scroll box would clip, without moving the controls */
    padding-left: var(--space-2);
    margin-left: calc(-1 * var(--space-2));
    /* the side columns scale with the stage, as its contents do: their sizes are the px values above
       at a 540px-wide stage (a window about 1170px tall), so the sound column always fits the height */
    --space-1: calc(var(--stage-width) * 2 / 540);
    --space-2: calc(var(--stage-width) * 4 / 540);
    --space-3: calc(var(--stage-width) * 6 / 540);
    --space-4: calc(var(--stage-width) * 8 / 540);
    --space-5: calc(var(--stage-width) * 10 / 540);
    --space-6: calc(var(--stage-width) * 12 / 540);
    --space-7: calc(var(--stage-width) * 14 / 540);
    --space-8: calc(var(--stage-width) * 16 / 540);
    --space-9: calc(var(--stage-width) * 18 / 540);
    --space-11: calc(var(--stage-width) * 40 / 540);
    --text-xs: calc(var(--stage-width) * 11 / 540);
    --text-s: calc(var(--stage-width) * 12 / 540);
    --text-m: calc(var(--stage-width) * 13 / 540);
    --text-l: calc(var(--stage-width) * 14 / 540);
    --text-xl: calc(var(--stage-width) * 18 / 540);
    --chip-padding: calc(var(--stage-width) * 5 / 540) calc(var(--stage-width) * 11 / 540);
  }
  .side.left {
    order: 1;
  }
  .side.right,
  .side .block {
    display: flex;
  }
  /* the brand stays a screen-reader heading only, as on a phone: the stage already names the show */
  .brand + .block {
    padding-top: 0;
    border-top: 0; /* the timeline opens its column: no rule above it */
  }
  .sounds {
    display: flex;
    flex-direction: column;
    gap: var(--space-11);
  }
  .chips {
    justify-content: flex-start;
  }

  /* the right column hugs the right edge */
  .side.right,
  .side.right .sound {
    align-items: flex-end;
    text-align: right;
  }
  .side.right .chips {
    justify-content: flex-end;
  }
  .side.right {
    order: 3;
    padding-left: 0;
    margin-left: 0;
    padding-right: var(--space-2); /* room for the focus ring */
    margin-right: calc(-1 * var(--space-2));
  }
}
/* a desktop tall enough for every sound option on its own line (about 1100px of options): one
   option per line, as a list, instead of side by side */
@media (min-width: 900px) and (min-height: 1150px) {
  .side.right .chips {
    flex-direction: column;
    align-items: flex-end;
  }
}
/* ---------- the video export: the 9:16 reel alone (owner, 2026-11-16) ----------
   tools/export-video.mjs sets .video-export and screenshots the stage at 1080 x 1920: the stage is
   a 9:16 box sized from the window height, unzoomed (src/main.js), with nothing drawn over it. */
html.video-export .side,
html.video-export .tap,
html.video-export .rhythms-stage,
html.video-export .center:has(.tap) > .foot {
  display: none; /* the last outranks the stopped-show rule that shows the link */
}
html.video-export .center {
  width: auto;
}
html.video-export .stage {
  width: calc(100svh * 9 / 16);
  height: auto;
  aspect-ratio: 9 / 16;
}
/* ---------- the tall stage: phone and desktop share one layout ----------
   The owner chose the phone's proportions for desktop too (2026-11-16). The stage is 393:852 (an
   iPhone's screen) and --room is the height that leaves over a 9:16 column: the screen's on a
   phone, the same share of the stage on desktop. The video export keeps the 9:16 reel layout
   (tools/export-video.mjs sets .video-export). */
/* a taller screen's extra room goes in two parts, 1 : 6: above the title, and between the
   wheel and the readout, which sits just above the lanes. The two spacers are the column's own
   ::before and ::after, placed by order. The readout keeps its desktop height (28.4cqw at
   9:16), so a scene change never moves the wheel. */
html:not(.video-export) .inner::before,
html:not(.video-export) .inner::after {
  content: "";
}
html:not(.video-export) .inner::before {
  order: 1;
  flex-grow: 1;
}
html:not(.video-export) .inner::after {
  order: 3;
  flex-grow: 6;
}
html:not(.video-export) .hud {
  order: 0;
}
html:not(.video-export) .head,
html:not(.video-export) .scope {
  order: 2;
}
html:not(.video-export) .read,
html:not(.video-export) .lanes {
  order: 4;
}
html:not(.video-export) .scope {
  width: calc(74cqw + min(10cqw, var(--room) * 0.25)); /* up to 84cqw: a tall phone has the height */
  margin-top: calc(-1cqw + min(12cqw, var(--room) * 0.25)); /* the wheel keeps its place while the title rises */
}
html:not(.video-export) .lanes {
  height: calc(26cqw + min(11.2cqw, var(--room) * 0.15));
  margin-top: min(6cqw, var(--room) * 0.15);
}
html:not(.video-export) .notation.tight {
  row-gap: calc(0.1cqw + min(1.2cqw, var(--room) * 0.03));
}
html:not(.video-export) .key {
  gap: 4cqw; /* the colour key: room between the instruments */
}
html:not(.video-export) .notation.swing {
  --swing-row-gap: calc(0.2cqw + min(1.3cqw, var(--room) * 0.04));
  gap: var(--swing-row-gap) 4cqw;
}
html:not(.video-export) .read {
  flex: none;
  height: calc(36cqw + min(8cqw, var(--room) * 0.35)); /* room for the larger phone labels */
}
html:not(.video-export) .read:has(> .score) {
  gap: calc(0.4cqw + min(2.6cqw, var(--room) * 0.08));
}
/* the big numbers stand apart from the rows under them */
html:not(.video-export) .read > .stats {
  margin-bottom: min(3cqw, var(--room) * 0.08);
}
/* a baque scene: the score sits a little closer under its numbers, and the numbers are larger */
html:not(.video-export) .read:has(> .score) > .stats {
  margin-bottom: 0;
}
html:not(.video-export) .read > .score {
  width: calc(62% + min(6%, var(--room) * 0.05)); /* fits the score under the larger labels */
}
html:not(.video-export) .stats.small b {
  font-size: calc(var(--stage-figure-s) + min(var(--figure-grow), var(--room) * 0.1));
} /* the Painel and Leitura labels and values, at the sizes a 393px phone shows them (11, 12 and
   13px there), so the desktop stage reads in the same proportions */
html:not(.video-export) .hud,
html:not(.video-export) .read .k,
html:not(.video-export) .notation .n {
  font-size: max(var(--stage-label), var(--label-at-phone));
}
html:not(.video-export) .read {
  font-size: max(var(--stage-text), var(--text-at-phone));
}
html:not(.video-export) .read > .k,
html:not(.video-export) .read .row .k {
  font-size: max(var(--stage-label), var(--label-at-phone) * 12 / 11);
}
/* ---------- phones: the stage alone, edge to edge ----------
   Inside the stage a phone draws the same picture as desktop, only smaller: no phone-only sizes
   (owner, 2026-11-16; this replaces the 11 px label floor of #4). */
@media (max-width: 899px) {
  /* phones show the stage alone: a tap anywhere plays or pauses, and a paused stage shows the time */
  .side > :not(.brand) {
    display: none;
  }
  /* the project link shows over the foot of the stage only while the show is stopped */
  .center > .foot {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: max(var(--space-8), env(safe-area-inset-bottom, 0px));
    z-index: 7;
    justify-content: center;
    font-size: var(--text-s);
  }
  .center:has(.tap:not([data-state="pause"])) > .foot {
    display: flex;
  }
  .center > .foot a {
    color: var(--link-stopped);
    padding: var(--space-4) var(--space-6); /* a finger-sized target */
  }
  .center {
    display: contents; /* the stage alone lays out as before */
  }
  .side {
    position: absolute; /* holds only the screen-reader heading: it must not add height */
    top: 0;
  }
  /* the stage fills the whole screen, edge to edge; only its text keeps clear of a notch */
  body {
    padding: 0;
  }
  .stage {
    width: 100%;
    min-width: 0;
    height: 100svh;
    aspect-ratio: auto;
    border-radius: 0;
  }
  /* the content column is as wide as a 9:16 box of the screen height allows (a tablet keeps the
     phone proportions), and it is the size container, so the cqw sizes inside match desktop. It
     fills the whole height: the HUD at the top and the lanes low but clear of the bottom edge. */
  .inner {
    container-type: inline-size;
    left: 50%;
    right: auto;
    width: min(100%, 100svh * 9 / 16);
    translate: -50% 0;
    box-sizing: border-box;
    /* --room: the screen height a 9:16 column leaves over. Every phone-only extra below takes a
       capped share of it, so a 9:16 phone (iPhone SE) gets the desktop layout and a taller one
       the full extras. */
    --room: max(0px, 100svh - 100vw * 16 / 9);
    row-gap: 1.4cqw;
    padding-top: max(calc(5cqw + min(3cqw, var(--room) * 0.1)), calc(env(safe-area-inset-top, 0px) + 3cqw));
    padding-bottom: max(calc(4.5cqw + min(3.5cqw, var(--room) * 0.1)), calc(env(safe-area-inset-bottom, 0px) + 3cqw));
  }
  .wrap {
    gap: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .fade {
    animation: none;
  }
}
/* until src/main.js has filled them, the controls and the counters stay hidden, so nothing shows
   empty for a moment and then changes */
html:not(.ready) .tap,
html:not(.ready) .hud,
html:not(.ready) .side {
  visibility: hidden;
}
