/* style.css - the interface (bar + mixer). The scene itself is a canvas and
   is not styled here, apart from filling the window. */

/* Fonts are stored locally (fonts/), so the page works without internet.
   Both are variable fonts: one file covers all the weights we use. */
@font-face {
  font-family: 'Fredoka';
  src: url('../fonts/Fredoka-latin.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: 'Nunito';
  src: url('../fonts/Nunito-latin.woff2') format('woff2');
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --bg: #141925;
  --panel: rgba(18, 23, 34, 0.9);
  --plate: #1b2231;
  --plate-line: rgba(255, 255, 255, 0.09);
  --well: #2a3346;
  --text: #f1ede4;
  --muted: #9aa6bb;
  --yellow: #f7b733;
  --teal: #3ecfb2;
  --coral: #ff6b5e;
  --head: 'Fredoka', 'Trebuchet MS', 'Segoe UI', sans-serif;
  --body: 'Nunito', 'Segoe UI', Arial, sans-serif;
  --gap: 10px;
}

* { box-sizing: border-box; }

/* ---------- THE SKELETON HAND: the mouse cursor everywhere ----------
   tools/make-cursors.js draws the pictures. A bony hand pointing with its
   index finger; over anything that can be pressed (buttons, links, sliders,
   the neon signs in the hall - see #scene.over-link) the fingertip glows.
   The hot spot is the fingertip (9, 1). Three lines each: a browser keeps
   the last one it understands (plain picture -> sharp pictures for dense
   screens), and after the comma comes the system cursor in case no picture
   loads. Phones and tablets show no cursor, so nothing changes there. */
html, body, #scene, .mixer, .sheet {
  cursor: url('../img/cursor-hand.png') 9 1, auto;
  cursor: -webkit-image-set(url('../img/cursor-hand.png') 1x, url('../img/cursor-hand@2x.png') 2x) 9 1, auto;
  cursor: image-set(url('../img/cursor-hand.png') 1x, url('../img/cursor-hand@2x.png') 2x) 9 1, auto;
}
a, button, .btn, [role="switch"], .slider input, .fader input, .knob input, #scene.over-link {
  cursor: url('../img/cursor-point.png') 9 1, pointer;
  cursor: -webkit-image-set(url('../img/cursor-point.png') 1x, url('../img/cursor-point@2x.png') 2x) 9 1, pointer;
  cursor: image-set(url('../img/cursor-point.png') 1x, url('../img/cursor-point@2x.png') 2x) 9 1, pointer;
}
input[type="text"] { cursor: text; }
.btn:disabled { cursor: default; }
@media (hover: none) { html, body, #scene, .mixer, .sheet, a, button, .btn, input { cursor: auto; } }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  color: var(--text);
  font-family: var(--body);
  -webkit-text-size-adjust: 100%;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: pan-y;        /* sideways swipes go to our own code */
}

#debug {
  position: fixed;
  left: 8px;
  top: 8px;
  z-index: 50;
  margin: 0;
  padding: 8px 10px;
  font: 12px/1.45 Consolas, monospace;
  color: #d6ffe9;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 8px;
  pointer-events: none;
}

/* ---------- shared pieces ---------- */

#ui { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; pointer-events: none; }
#ui > * { pointer-events: auto; }
#ui.hidden-ui, #ui[hidden] { display: none; }              /* H key */

.plate {
  background: var(--plate);
  border: 1px solid var(--plate-line);
  border-radius: 14px;
}

.icon { display: inline-flex; width: 24px; height: 24px; flex: none; }
.icon svg { width: 100%; height: 100%; display: block; }
.icon.coral { color: var(--coral); }
.icon.accent { color: var(--yellow); width: 30px; height: 30px; }

.caption {
  font: 700 13px/1 var(--body);
  letter-spacing: 0.08em;
  color: var(--text);
  white-space: nowrap;
}

.note { font: 600 12px/1.2 var(--body); color: var(--muted); margin: 0; white-space: nowrap; }

.logo { display: flex; align-items: center; gap: 10px; }
.logo .icon { color: var(--teal); width: 34px; height: 34px; }
.logo-text { font: 600 30px/1 var(--head); letter-spacing: 0.04em; white-space: nowrap; }

button { font: inherit; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--well);
  color: var(--text);
  font: 700 14px/1 var(--body);
  letter-spacing: 0.04em;
 
  transition: background 0.15s, transform 0.1s;
}
.btn:hover { background: #36415a; }

/* LABELS CENTRED ON THEIR LETTERS. A font's line box has room above the
   capitals and below the baseline, and not the same amount (Nunito and
   Fredoka differ), so "centred" text sits a pixel or two off its icon.
   text-box trims every label to the height of its capital letters; the
   flex centring then centres the letters themselves. (Browsers without
   text-box simply keep the old, near-centred look.) Measured on screen
   shots, see the v3.8 report. */
.btn > span:not(.icon), .btn-text > *, .ch-name > span:not(.icon), .tl-piece, .glyph {
  text-box: trim-both cap alphabetic;
}
/* the minus, plus and cross of Fredoka sit on the maths axis, about a
   tenth of the letter size below the middle of the capitals: lifted back */
.glyph { display: block; position: relative; top: -0.1em; }
.btn:active { transform: translateY(1px); }

/* One clear focus ring everywhere (keyboard users must see where they are). */
button:focus-visible,
.slider input:focus-visible ~ .slider-thumb,
.fader input:focus-visible ~ .fader-thumb,
.knob input:focus-visible ~ svg {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}
button:focus { outline: none; }
button:focus-visible { outline: 3px solid #ffffff; }

.btn-play { background: var(--yellow); color: #1a1d28; width: 64px; }
.btn-play:hover { background: #ffc94d; }
/* Before the first Play the button gently pulses: "press me for music". */
.btn-play.invite { animation: invite 1.6s ease-in-out infinite; }
@keyframes invite {
  0%, 100% { box-shadow: 0 0 0 0 rgba(247, 183, 51, 0.7); }
  50% { box-shadow: 0 0 0 10px rgba(247, 183, 51, 0); }
}
.transport { display: flex; }

.btn-accent { background: var(--yellow); color: #1a1d28; font: 700 16px/1 var(--body); padding: 0 22px; min-height: 60px; }
.btn-accent:hover { background: #ffc94d; }
.btn-accent .icon { width: 30px; height: 30px; }

/* NEW TRACK and NEW VARIATION: side by side, a short line under each name */
.new-buttons { display: flex; gap: var(--gap); }
.btn-new { min-height: 60px; padding: 0 18px; gap: 10px; justify-content: flex-start; text-align: left; }
.btn-new .icon { width: 28px; height: 28px; color: var(--yellow); }
.btn-new.btn-accent .icon { color: #1a1d28; }
.btn-text { display: flex; flex-direction: column; gap: 4px; }
.btn-text .label { font: 700 15px/1 var(--body); letter-spacing: 0.04em; white-space: nowrap; }
.btn-text small { font: 700 11px/1 var(--body); letter-spacing: 0.02em; opacity: 0.75; white-space: nowrap; }

.btn-square { width: 44px; padding: 0; font: 600 24px/1 var(--head); }

.chip {
  display: inline-flex; align-items: baseline; gap: 5px;
  padding: 0 14px; height: 44px; line-height: 44px;
  background: var(--well); border-radius: 10px;
  font: 600 20px/44px var(--head); white-space: nowrap;
}
.chip[hidden] { display: none; }
.chip-name { font: 700 14px/44px var(--body); color: var(--yellow); max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.chip small, .bpm-read small { font: 700 12px/1 var(--body); letter-spacing: 0.08em; color: var(--muted); }

/* ---------- sliders (invisible real input + our drawing) ---------- */

.slider { position: relative; display: block; height: 30px; flex: 1; min-width: 90px; }
.slider input,
.fader input,
.knob input {
  position: absolute; margin: 0; opacity: 0; z-index: 2;
  -webkit-appearance: none; appearance: none;
}
.slider input { inset: 0; width: 100%; height: 100%; }
.slider-track { position: absolute; left: 0; right: 0; top: 50%; height: 9px; margin-top: -4.5px; background: var(--well); border-radius: 5px; overflow: hidden; }
.slider-fill { display: block; height: 100%; width: calc(var(--v, 0.5) * 100%); background: var(--teal); }
.slider-thumb {
  position: absolute; top: 50%; left: calc(var(--v, 0.5) * (100% - 24px));
  width: 24px; height: 24px; margin-top: -12px; border-radius: 50%;
  background: #f3e8d0; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

/* Vertical fader: the real input is laid on its side, so dragging up or
   pressing the Up arrow raises the value. */
.fader { position: relative; display: block; width: 34px; height: 80px; flex: none; }
.fader input { left: 0; top: 100%; width: 80px; height: 34px; transform: rotate(-90deg); transform-origin: 0 0; }
.fader-track { position: absolute; left: 50%; top: 0; bottom: 0; width: 9px; margin-left: -4.5px; background: var(--well); border-radius: 5px; overflow: hidden; }
.fader-fill { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--v, 0.5) * 100%); background: var(--yellow); }
.fader-thumb {
  position: absolute; left: 50%; bottom: calc(var(--v, 0.5) * (100% - 22px));
  width: 30px; height: 22px; margin-left: -15px; border-radius: 6px;
  background: #f3e8d0; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

/* Knob: an arc that grows with the value and a dot that turns with it. */
.knob { position: relative; display: block; width: 64px; height: 64px; }
.knob input { left: 0; top: 100%; width: 64px; height: 64px; transform: rotate(-90deg); transform-origin: 0 0; }
.knob svg { width: 100%; height: 100%; display: block; transform: rotate(135deg); border-radius: 50%; }
.knob circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.knob-back { stroke: var(--well); stroke-dasharray: 141.4 400; }
.knob-value { stroke: var(--teal); stroke-dasharray: calc(var(--v, 0.5) * 141.4px) 400px; }
.knob.coral .knob-value { stroke: var(--coral); }
.knob-dot {
  position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; margin: -4.5px;
  border-radius: 50%; background: #f3e8d0;
  transform: rotate(calc(-135deg + var(--v, 0.5) * 270deg)) translateY(-15px);
}
.knob-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.knob-read { font: 700 12px/1 var(--body); color: var(--muted); }

/* "the browser is keeping the sound off": a clear note above the bar */
.audio-hint {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: max-content; max-width: calc(100vw - 24px); margin: 0; padding: 10px 16px; border-radius: 12px;
  background: var(--yellow); color: #1a1d28; font: 800 14px/1.3 var(--body); text-align: center;
}
.audio-hint[hidden] { display: none; }
/* links that look like buttons get the same focus ring */
a:focus-visible { outline: 3px solid #ffffff; outline-offset: 3px; }

/* ---------- narrow bar ---------- */

.bar {
  display: flex; align-items: center; gap: var(--gap);
  margin: 0 12px 12px; padding: 8px 12px;
  background: var(--panel);
  backdrop-filter: blur(6px);
  transition: transform 0.35s ease, opacity 0.35s ease;
}
.bar .logo-text { font-size: 24px; }
.bar .logo .icon { width: 28px; height: 28px; }
.bar .btn-play { width: 56px; }
.bar .sfx { display: flex; gap: 8px; margin-left: 6px; }
.bar .note { margin-left: auto; }
.btn-about { text-decoration: none; }
.btn-about .icon { color: #ff4fd8; }
.bar .note + .btn-about { margin-left: 0; }
.bar .btn-open { background: var(--yellow); color: #1a1d28; }
.bar .btn-open:hover { background: #ffc94d; }

.btn-sfx .icon { color: var(--teal); }
.btn-sfx:nth-child(even) .icon { color: var(--coral); }
.btn-sfx.fired { animation: fired 0.45s ease; }
@keyframes fired {
  0% { background: var(--yellow); transform: scale(1.08); }
  100% { background: var(--well); transform: scale(1); }
}

/* resting state after 3 quiet seconds, and while the mixer is open */
.bar.idle, .bar.covered { transform: translateY(130%); opacity: 0; pointer-events: none; }

/* ---------- big mixer ---------- */

.mixer {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; gap: var(--gap);
  padding: 12px 14px 10px;
  background: var(--panel);
  border-top: 1px solid var(--plate-line);
  backdrop-filter: blur(8px);
  transform: translateY(102%);
  visibility: hidden;
  transition: transform 0.38s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.38s;
}
.mixer.open { transform: translateY(0); visibility: visible; transition-delay: 0s; }
.mixer.no-anim { transition: none; }

.mx-top { display: flex; align-items: center; gap: 18px; padding: 10px 16px; }
.mx-top .logo { margin-right: 6px; }
.bpm { display: flex; align-items: center; gap: 8px; }
.bpm-read { min-width: 92px; text-align: center; font: 600 24px/1 var(--head); }

/* the style picker: < NAME > */
.style-pick { display: flex; align-items: center; gap: 4px; background: var(--well); border-radius: 10px; }
.style-pick .btn { background: transparent; }
.style-pick .btn:hover { background: #3d4963; }
.style-pick .btn .icon { width: 18px; height: 18px; }
.style-name {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 150px; font: 700 14px/1 var(--body); letter-spacing: 0.06em; color: var(--yellow); white-space: nowrap;
}
.style-name small { font: 700 10px/1 var(--body); letter-spacing: 0.08em; color: var(--muted); }


.master { flex: 1; min-width: 170px; display: flex; flex-direction: column; gap: 4px; padding-left: 18px; border-left: 1px solid var(--plate-line); }
.master-row { display: flex; align-items: center; gap: 10px; }
.btn-close { flex-direction: column; gap: 2px; background: transparent; min-width: 70px; min-height: 56px; border-left: 1px solid var(--plate-line); border-radius: 0 10px 10px 0; font-size: 13px; }
/* the chevron fills only the middle of its 26 px box: the box is cut to the
   chevron's height (the drawing hangs over), so icon and CLOSE are centred
   as a pair on their ink, not on empty space above the arrow */
.btn-close .icon { width: 26px; height: 14px; align-items: center; overflow: visible; }
.btn-close .icon svg { height: 26px; flex: none; }

.mx-mid { display: flex; gap: var(--gap); align-items: stretch; }
.channels { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--gap); flex: 3.3; }   /* (wider since the mode switch and the two track buttons are gone) */
.channel { padding: 8px 8px 10px; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
/* The channel name is a button: it chooses whose steps the grid shows. */
.ch-name {
  display: flex; align-items: center; gap: 5px; width: 100%; min-height: 32px;
  padding: 4px 6px; border: 0; border-radius: 8px; background: transparent;
  font: 700 13px/1 var(--body); letter-spacing: 0.04em; color: var(--text); text-align: left;
  overflow: hidden; white-space: nowrap;          /* the label never runs under the dice: mixer.js shrinks it instead */
}
.ch-name:hover { background: var(--well); }
.ch-name[aria-pressed="true"] { background: var(--yellow); color: #1a1d28; }
.ch-name[aria-pressed="true"] .icon { color: #1a1d28; }
.ch-name .icon { width: 18px; height: 18px; }
.channel-body { display: flex; align-items: flex-end; justify-content: center; gap: 12px; }
.ch-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.channel.off .fader-fill { background: #5b667c; }
.channel.off .ch-name:not([aria-pressed="true"]) { color: var(--muted); }

.switch { width: 46px; height: 26px; flex: none; border: 0; border-radius: 13px; background: var(--well); padding: 0; position: relative; transition: background 0.15s; }
.switch span { position: absolute; top: 4px; left: 4px; width: 18px; height: 18px; border-radius: 50%; background: #f3e8d0; transition: transform 0.15s; }
.switch[aria-checked="true"] { background: var(--teal); }
.switch[aria-checked="true"] span { transform: translateX(20px); }

.meter { width: 8px; height: 80px; border-radius: 4px; background: var(--well); overflow: hidden; display: flex; align-items: flex-end; }
.meter i { display: block; width: 100%; height: 100%; background: var(--teal); transform-origin: 50% 100%; transform: scaleY(0); }

.lock { width: 36px; height: 36px; border: 0; border-radius: 8px; background: var(--well); color: var(--muted); padding: 7px; }
.lock svg { width: 100%; height: 100%; display: block; }
.lock[aria-pressed="true"] { background: var(--coral); color: #1a1d28; }

.effects { flex: 1.55; padding: 12px 14px 10px; display: flex; flex-direction: column; gap: 8px; }
.effects.eq { flex: 1.15; }
.effects.eq .knobs { grid-template-columns: repeat(3, 1fr); }
.knobs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; flex: 1; align-items: center; }

.mx-bottom { display: flex; gap: var(--gap); align-items: stretch; }
.steps { flex: 3; display: flex; align-items: center; gap: 18px; padding: 10px 16px; min-width: 0; }
.steps .caption { line-height: 1.5; }
.steps .caption small { color: var(--yellow); font-size: 12px; }
.step-grid { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 8px; flex: 1; }
.step { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 0; border: 0; background: transparent; min-width: 0; }
.step-pad { display: block; width: 100%; max-width: 36px; aspect-ratio: 1; border-radius: 7px; background: var(--well); transition: transform 0.08s; }
.step[aria-pressed="true"] .step-pad { background: var(--yellow); }
.step.now .step-pad { box-shadow: 0 0 0 3px var(--teal); transform: scale(1.12); }
.step-num { font: 700 12px/1 var(--body); color: var(--muted); }
.step.now .step-num { color: var(--text); }

.energy { flex: 1.3; display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.energy-body { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.energy-body .slider { flex: none; height: 26px; }
.energy-read { font: 600 18px/1 var(--head); min-width: 48px; text-align: right; }


/* About and BUY A ROUND in the mixer's top row, the glass in the bar */
.mx-links { display: flex; gap: 8px; }
.mx-links .btn { background: var(--well); text-decoration: none; }
.btn-round .icon { color: var(--yellow); }

/* in compact mode the top row may take two lines */
.mixer.compact .mx-top { flex-wrap: wrap; row-gap: 8px; gap: 12px; }
.mixer.compact .mx-top .logo { display: none; }
/* (with ONE play button there is room for the whole row on a laptop:
   1280 and 1366 px wide - the style name and the volume give a little) */
.mixer.compact .style-name { min-width: 128px; }
.mixer.compact .master { min-width: 140px; padding-left: 14px; }

/* NEW TRACK / NEW VARIATION moved up into the top row (mixer.js does that
   on screens where the bottom row would need scrolling): compact buttons */
.mx-top .new-buttons { gap: 8px; }
.mx-top .btn-new { min-height: 44px; padding: 0 12px; gap: 8px; }
.mx-top .btn-new .icon { width: 22px; height: 22px; }
.mx-top .btn-text small { display: none; }
.mx-top .btn-text .label { font-size: 13px; }

/* ---------- track row ---------- */

.track { display: flex; align-items: center; gap: var(--gap); padding: 8px 12px; }
.track .btn { white-space: nowrap; }
.track .btn .icon { width: 22px; height: 22px; color: var(--teal); }
.btn-yellow { background: var(--yellow); color: #1a1d28; }
.btn-yellow:hover { background: #ffc94d; }
.sheet .btn-yellow .icon { color: #1a1d28; }
.btn:disabled { opacity: 0.5; cursor: default; }
.track-time { font: 600 18px/1 var(--head); min-width: 108px; text-align: center; white-space: nowrap; }

/* The timeline: one piece per section; its width is the section's length. */
.timeline { position: relative; display: flex; gap: 3px; flex: 1; min-width: 120px; height: 44px; }
.tl-piece {
  flex: 1 1 0; min-width: 0; height: 100%; padding: 0 2px; border: 0; border-radius: 7px;
  background: var(--well); color: #1a1d28; overflow: hidden; white-space: nowrap; text-overflow: clip;
  font: 800 11px/1 var(--body); letter-spacing: 0.06em;
  opacity: 0.55; transition: opacity 0.15s, transform 0.1s;
}
.tl-piece:hover, .tl-piece.now { opacity: 1; }
.tl-piece:active { transform: translateY(1px); }
.tl-intro, .tl-outro { background: #7f8ba3; }
.tl-build { background: var(--yellow); }
.tl-groove { background: var(--teal); }
.tl-drop { background: var(--coral); }
.tl-breakdown { background: #a98bf0; }
.tl-head {
  position: absolute; top: -4px; bottom: -4px; left: 0; width: 4px; margin-left: -2px;
  border-radius: 2px; background: #ffffff; box-shadow: 0 0 0 2px rgba(20, 25, 37, 0.7); pointer-events: none;
}

/* ---------- sound / pattern pickers on a channel card ---------- */

.ch-head { display: flex; align-items: center; gap: 4px; }
.ch-head .ch-name { flex: 1; min-width: 0; }
.ch-dice {
  flex: none; width: 32px; height: 32px; padding: 6px; border: 0; border-radius: 8px;
  background: var(--well); color: var(--yellow); transition: background 0.15s;
}
.ch-dice:hover { background: #36415a; }
.ch-dice svg { width: 100%; height: 100%; display: block; }
.ch-dice.rolled svg { animation: roll 0.4s ease; }
@keyframes roll { from { transform: rotate(-180deg) scale(0.7); } to { transform: rotate(0) scale(1); } }

.pick { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pick-label { font: 800 10px/1 var(--body); letter-spacing: 0.12em; color: var(--muted); padding-left: 2px; }
.pick-row { display: flex; align-items: center; height: 28px; background: var(--well); border-radius: 8px; min-width: 0; }
.pick-btn {
  flex: none; width: 26px; height: 28px; padding: 7px 6px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); transition: background 0.15s, transform 0.1s;
}
.pick-btn:hover { background: #3d4963; }
.pick-btn:active { transform: scale(0.88); }
.pick-btn svg { width: 100%; height: 100%; display: block; }
.pick-name {
  /* The whole name must be readable: it may break into two lines - but
     only BETWEEN words, never inside one - and mixer.js makes the letters
     smaller until it fits (never "..."). */
  flex: 1; min-width: 0; max-height: 28px; overflow: hidden; text-align: center;
  white-space: normal; overflow-wrap: normal; word-break: keep-all; hyphens: none;
  font: 700 12px/1.08 var(--body);
}

/* ---------- the donation box (BUY A ROUND; js/ui/donate.js) ---------- */
.donate-soon { display: inline-block; margin: 0; padding: 10px 16px; border-radius: 10px; background: var(--well); font: 800 16px/1.2 var(--body); color: var(--yellow); }
.donate-box { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.donate-main { flex: 1; min-width: 240px; }
.donate-plate { display: flex; align-items: stretch; gap: 8px; padding: 6px; border-radius: 12px; background: var(--well); }
.donate-address span { white-space: nowrap; }          /* each half of the address stays whole */
.donate-address { flex: 1; min-width: 0; align-self: center; padding: 6px 8px; font: 14px/1.45 Consolas, 'SF Mono', Menlo, monospace; letter-spacing: 0.01em; overflow-wrap: normal; color: var(--text); }
.donate-copy { flex: none; min-height: 48px; min-width: 100px; padding: 0 18px; border: 0; border-radius: 9px; background: var(--yellow); color: #1a1d28; font: 800 15px/1 var(--body); }
.donate-copy:hover { background: #ffc94d; }
.donate-copy:focus-visible { outline: 3px solid #ffffff; outline-offset: 3px; }
.donate-net { margin: 10px 0 0; color: var(--muted); font: 700 14px/1.3 var(--body); }
.donate-net b { color: var(--text); }
.donate-warn { margin: 6px 0 0 4px; color: var(--coral); font: 800 12.5px/1.3 var(--body); }
.donate-qr { margin: 0; padding: 8px; background: #fff; border-radius: 12px; line-height: 0; }
.donate-qr[hidden] { display: none; }
.donate-qr img { width: 150px; height: 150px; display: block; }

/* ---------- dialogs (Save, My tracks, Buy a round) ---------- */

.sheet {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto;
  padding: 18px; border: 1px solid var(--plate-line); border-radius: 16px;
  background: var(--plate); color: var(--text); font-family: var(--body);
}
.sheet::backdrop { background: rgba(8, 10, 16, 0.6); }
.sheet[open] { display: flex; flex-direction: column; gap: 14px; animation: sheet-in 0.2s ease; }
@keyframes sheet-in { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { margin: 0; font: 600 26px/1 var(--head); letter-spacing: 0.04em; }
.sheet .btn-square { font-size: 28px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field input {
  height: 44px; padding: 0 12px; border: 2px solid transparent; border-radius: 10px;
  background: var(--well); color: var(--text); font: 700 16px/1 var(--body);
}
.field input:focus-visible { outline: none; border-color: #ffffff; }
.sheet-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.sheet-actions .btn { min-height: 52px; padding: 0 10px; font-size: 13px; }
.sheet-actions .btn .icon { width: 22px; height: 22px; color: var(--teal); }
.sheet .note { white-space: normal; }
.sheet .status { min-height: 15px; color: var(--text); overflow-wrap: anywhere; }
.progress { height: 10px; border-radius: 5px; background: var(--well); overflow: hidden; }
.progress[hidden] { display: none; }
.progress i { display: block; height: 100%; width: 0; background: var(--teal); transition: width 0.3s; }

.track-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.track-item { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 12px; background: var(--well); border-radius: 12px; }
.track-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.track-text strong { font: 700 15px/1.1 var(--body); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.track-text small { font: 600 12px/1 var(--body); color: var(--muted); }
.track-empty { padding: 14px; color: var(--muted); font: 600 14px/1.4 var(--body); }
.btn-small { min-height: 40px; min-width: 40px; padding: 0 10px; font-size: 12px; background: var(--plate); }
.btn-small .icon { width: 18px; height: 18px; color: var(--teal); }

/* Flex children refuse to get narrower than their content unless told so.
   Without this the channel row would push the whole panel off screen. */
.mixer > *, .mx-mid > *, .mx-bottom > *, .track > * { min-width: 0; }

/* ---------- the mixer must never hide the party ----------
   The hall can be drawn at most about 3.6 times wider than it is tall. So
   above the mixer there must stay a strip at least 27.6% of the window's
   width high - otherwise the disco ball would be cut off. If the mixer
   does not fit under that line it scrolls inside itself. */
.mixer { max-height: max(250px, calc(100vh - 27.6vw)); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; }

/* Wide but not tall windows: a tighter mixer, so that it rarely has to scroll. */
@media (min-width: 981px) and (min-aspect-ratio: 9/5), (min-width: 981px) and (max-height: 900px) {
  .mixer { gap: 7px; padding: 8px 12px 8px; }
  .mx-top { padding: 4px 14px; }
  .track { padding: 4px 10px; }
  .timeline { height: 38px; }
  .mx-mid, .mx-bottom, .channels { gap: 7px; }
  .channel { padding: 6px 7px 7px; gap: 5px; }
  .fader { height: 50px; }
  .fader input { width: 50px; }
  .meter { height: 50px; }
  .ch-side { flex-direction: row; gap: 6px; }
  .lock { width: 30px; height: 30px; padding: 6px; }
  .effects { padding: 8px 12px 6px; gap: 4px; }
  .knob, .knob input { width: 52px; height: 52px; }
  .knob-dot { transform: rotate(calc(-135deg + var(--v, 0.5) * 270deg)) translateY(-12px); }
  .steps, .energy { padding: 6px 14px; }
  .step-pad { max-width: 30px; }
  .step { gap: 3px; }
  .btn-accent { min-height: 50px; }
}

/* Very wide windows (21:9 monitors): two columns, so the mixer is low and
   the whole hall stays in view above it. */
@media (min-width: 2000px) and (min-aspect-ratio: 21/10) {
  /* three columns: transport / channels / effects. The middle box is
     "display: contents", so its three parts become grid cells of their own
     and the channel cards get enough width for readable names. */
  .mixer {
    display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.35fr) minmax(0, 0.62fr);
    grid-template-areas: "top chan fx" "track chan fx" "bottom chan eq";
  }
  .mx-mid { display: contents; }
  .channels { grid-area: chan; }
  .effects { grid-area: fx; }
  .effects.eq { grid-area: eq; }
  .mx-top { grid-area: top; gap: 12px; }
  .mx-top .logo-text { display: none; }
  .track { grid-area: track; }
  .track .btn .label { display: none; }
  .mx-bottom { grid-area: bottom; flex-wrap: wrap; }
  /* the top row has less room here: tighter pieces, so MASTER VOLUME fits */
  .mx-top { gap: 10px; padding: 6px 10px; }
  .bpm-read { min-width: 64px; }
  .style-name { min-width: 118px; }
  /* MASTER VOLUME goes onto a second line of the top plate */
  .mx-top { flex-wrap: wrap; row-gap: 4px; }
  .btn-close { min-width: 52px; min-height: 44px; margin-left: auto; order: 7; flex-direction: row; gap: 6px; }
  .master { order: 8; flex-basis: 100%; flex-direction: row; align-items: center; gap: 12px; padding-left: 0; border-left: 0; }
  .master .master-row { flex: 1; }
  .mx-bottom .steps { flex-basis: 100%; }               /* the 16 steps get a full row */
  .track { flex-wrap: wrap; }
  .track .timeline { order: 9; flex-basis: 100%; height: 34px; }   /* and so does the timeline */
  .track .track-time { margin-left: auto; }
  .ch-name .icon { display: none; }
  /* there is room to spare here: full-size faders again */
  .fader { height: 76px; }
  .fader input { width: 76px; }
  .meter { height: 76px; }
  .ch-side { flex-direction: column; }
}

/* Low laptop screens: the step numbers go, so the whole mixer fits without scrolling. */
@media (min-width: 981px) and (max-height: 800px) {
  .step-num { display: none; }
  .btn-close { min-height: 44px; flex-direction: row; gap: 6px; }
  .mx-top { padding: 3px 14px; }
  .channel { gap: 3px; padding: 5px 7px 6px; }
  .effects { padding: 6px 12px 4px; }
  .steps, .energy { padding: 5px 14px; }
  .btn-accent { min-height: 44px; }
}

/* ---------- smaller screens ---------- */

@media (max-width: 1420px) {
  .mx-top .logo-text { display: none; }
  .channels { flex: 3.6; }
  .pick-btn { width: 20px; padding: 7px 4px; }
  .tl-piece { font-size: 9px; letter-spacing: 0; }
  .ch-side { flex-direction: column; gap: 4px; }
  .lock { width: 40px; height: 24px; padding: 4px 12px; }
  .channel-body { gap: 6px; }
}

/* Narrow channel strips: drop the little icon so the name fits. */
@media (max-width: 1500px) {
  .track .btn .label { display: none; }
  .ch-name .icon { display: none; }
  .ch-name { padding: 4px 6px; letter-spacing: 0.04em; }
  .switch { width: 40px; }
  .switch[aria-checked="true"] span { transform: translateX(14px); }
  .channel-body { gap: 8px; }
  .knob { width: 56px; height: 56px; }
  .knob input { width: 56px; height: 56px; }
  .knob-dot { transform: rotate(calc(-135deg + var(--v, 0.5) * 270deg)) translateY(-13px); }
  .effects { padding: 10px 10px 8px; }
}

@media (max-width: 1250px) {
  .hide-medium { display: none; }
  .bar .btn-about { margin-left: auto; }
  .mx-top { gap: 12px; flex-wrap: wrap; }
  .master { min-width: 140px; }
  .channels { flex: 4.6; }
  .knob, .knob input { width: 46px; height: 46px; }
  .knob-dot { transform: rotate(calc(-135deg + var(--v, 0.5) * 270deg)) translateY(-10px); }
  .knobs { gap: 4px; }
  .effects .caption { font-size: 11px; letter-spacing: 0.04em; }
  .mx-top .logo-text { font-size: 24px; }
  .mx-top .logo-text { display: none; }
  .track-time { min-width: 96px; font-size: 16px; }
  .ch-dice { width: 28px; height: 28px; padding: 5px; }
}

@media (max-width: 980px) {
  .bar .btn-sfx .label { display: none; }
  .hide-small { display: none; }
  .mx-top { flex-wrap: wrap; }
  .mx-mid { flex-direction: column; }
  .mx-bottom { flex-wrap: wrap; }
  .steps { flex-basis: 100%; }
  .track { flex-wrap: wrap; }
  .timeline { order: 9; flex-basis: 100%; }
  .track-time { margin-left: auto; }
  .channels { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* the mixer is taller than a small window now: let it scroll */
  .mixer { max-height: 74vh; overflow-y: auto; overscroll-behavior: contain; }
}

/* Short screens (a phone on its side): the mixer becomes a scrolling sheet. */
@media (max-height: 560px) {
  .mixer { max-height: 66vh; overflow-y: auto; overscroll-behavior: contain; }
  .bar { margin: 0 8px 8px; padding: 6px 10px; }
  .bar .logo-text { display: none; }
}

/* Tall phone: icon-only bar with big touch targets, mixer as a full-width
   sheet; channels scroll sideways. */
@media (max-width: 640px) and (orientation: portrait) {
  .bar { margin: 0; border-radius: 14px 14px 0 0; padding: 8px; gap: 6px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .bar .logo, .bar .chip, .bar .note, .bar .label { display: none; }
  .bar .btn-round { display: none; }          /* no room: on a phone the glass is in the mixer, next to About */
  .bar .btn { min-width: 46px; min-height: 46px; padding: 0 10px; }
  .bar .sfx { margin: 0; gap: 6px; flex: 1; justify-content: center; }
  .bar .btn-open { margin-left: 0; }

  .mixer { max-height: 62vh; overflow-y: auto; overscroll-behavior: contain; padding: 10px 8px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .mx-top { gap: 10px; padding: 10px; }
  .mx-top .logo { display: none; }
  .master { flex-basis: 100%; order: 5; border-left: 0; padding-left: 0; }
  .mx-top .new-buttons { order: 3; flex-basis: 100%; }
  .mx-top .new-buttons .btn { flex: 1; justify-content: center; }
  .mx-links { order: 4; }
  .btn-close { margin-left: auto; border-left: 0; flex-direction: row; min-height: 44px; }
  .channels { display: flex; overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .channel { flex: 0 0 150px; scroll-snap-align: start; }
  .tl-piece { font-size: 0; padding: 0; }
  .tl-piece::after { content: attr(data-short); font-size: 9px; letter-spacing: 0; }
  .track .btn { flex: 1; min-width: 46px; padding: 0 8px; }
  .sheet-actions { grid-template-columns: 1fr; }
  .track-item { flex-wrap: wrap; }
  .track-text { flex-basis: 100%; }
  .steps { flex-direction: column; align-items: stretch; gap: 10px; }
  .step-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); row-gap: 10px; }
  .step { min-height: 44px; }
  .energy { flex-basis: 100%; }
  .btn-accent { flex: 1; }
}

/* People who asked their system for less motion get no sliding panels. */
@media (prefers-reduced-motion: reduce) {
  .bar, .mixer, .btn, .switch, .switch span, .step-pad, .tl-piece, .pick-btn, .progress i { transition: none; }
  .sheet[open], .ch-dice.rolled svg { animation: none; }
  .btn-sfx.fired, .btn-play.invite { animation: none; }
}

/* the song's name only where the bar has room for it */
@media (max-width: 1500px) { .chip-name { display: none; } }

/* Laptop widths: the channel cards take more of the row, and the arrows
   around a preset name get a little narrower, so long names stay whole. */
@media (max-width: 1600px) and (min-width: 981px) {
  .channels { flex: 3.9; }
  .pick-btn { width: 20px; padding: 7px 4px; }
  .effects .knobs { gap: 4px; }
}

/* the bar: labels never wrap; the "press play" hint goes first when room is short */
.bar .btn, .bar .label { white-space: nowrap; }
@media (max-width: 1500px) { #bar-hint { display: none; } }

/* Medium windows: the sound effect buttons keep only their icons (the name
   is in the tooltip), so the whole bar - with Open mixer - fits. */
@media (max-width: 1200px) {
  .bar .btn-sfx .label { display: none; }
}
@media (max-width: 1500px) { .bar .btn-round .label { display: none; } }
@media (max-width: 1100px) {
  .bar .logo-text, .bar .btn-about .label { display: none; }    /* only the icons, the names are in the tooltips */
}
