/*
 * Metronome. The page is one screen, sized by the window's height so it
 * fits a phone without scrolling and grows on a tablet: the beat lights, the
 * pendulum, the tempo, three pills (time, clicks, sound) and, in the thumb's
 * reach at the bottom, Tap, Start and the mute. Everything else is in sheets
 * (app-shell.css, run by nav.js): time, clicks, sound, and Practice, which on
 * a wide screen is a drawer down the right. Light and dark come from theme.js;
 * every colour is drawn from the shell's tokens and --ab-accent.
 */

body.qp-app {
  --mt-cell: color-mix(in srgb, var(--text, #191918) 6%, var(--surface, #fffdf8));
  --mt-cell-line: color-mix(in srgb, var(--text, #191918) 10%, transparent);
  --mt-dim: color-mix(in srgb, var(--text, #191918) 22%, transparent);
  --mt-poly: #c2410c;
}

html[data-theme="dark"] body.qp-app { --mt-poly: #fb923c; }

/* ---------- Stage ---------- */

.mt-main {
  position: relative;
  display: flex;
  justify-content: center;
  height: calc(100vh - var(--qp-bar-actual, var(--qp-bar-h)));
  height: calc(100dvh - var(--qp-bar-actual, var(--qp-bar-h)));
  min-height: 460px;
  overflow: hidden;
}

/* Beside the Practice drawer on a wide screen, the stage keeps to the left. */
html.qp-drawer-open .mt-main { padding-right: 380px; }

/* Whatever height is spare is shared out between the parts, so a tall
   tablet does not open one empty band in the middle. */
.mt-stage {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(10px, 2.2vh, 24px);
  width: min(100%, 620px);
  padding: clamp(12px, 2.6vh, 32px) 16px max(16px, env(safe-area-inset-bottom));
}

/* ---------- Song, while a setlist song is loaded ---------- */

.mt-song {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}

.mt-song[hidden] { display: none; }

.mt-song-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font: 700 .86rem/1.2 "Inter", system-ui, sans-serif;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mt-song-name em { color: var(--muted); font-style: normal; font-weight: 600; }

.mt-song-step {
  display: grid;
  flex: none;
  width: 40px;
  height: 36px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 11px;
  color: var(--text);
  background: var(--mt-cell);
  cursor: pointer;
}

.mt-song-step svg { width: 18px; height: 18px; }

/* ---------- Beat lights ----------
   One per beat, as wide as the pulses in it, filled to its accent level.
   The dots under a light are its clicks, placed where they fall. */

.mt-beats-wrap { position: relative; flex: none; }

.mt-beats {
  display: flex;
  gap: 8px;
  height: clamp(64px, 11.5vh, 150px);
}

.mt-beat {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  padding: 0;
  border: 1px solid var(--mt-cell-line);
  border-radius: 16px;
  background: var(--mt-cell);
  cursor: pointer;
  overflow: hidden;
  touch-action: manipulation;
}

.mt-beat-fill {
  position: absolute;
  right: 6px;
  bottom: 22px;
  left: 6px;
  height: calc((100% - 50px) * var(--lv, .66));
  border-radius: 9px;
  background: color-mix(in srgb, var(--ab-accent) 30%, var(--mt-cell));
  transition: height .16s cubic-bezier(.2, .8, .2, 1), background-color .08s;
}

.mt-beat[data-level="3"] .mt-beat-fill { --lv: 1; background: color-mix(in srgb, var(--ab-accent) 48%, var(--mt-cell)); }
.mt-beat[data-level="2"] .mt-beat-fill { --lv: .62; }
.mt-beat[data-level="1"] .mt-beat-fill { --lv: .3; }
.mt-beat[data-level="0"] .mt-beat-fill {
  --lv: 1;
  border: 1.5px dashed var(--mt-dim);
  background: transparent;
}

.mt-beat-num {
  position: absolute;
  top: 8px;
  right: 0;
  left: 0;
  z-index: 1;
  color: var(--muted);
  font: 700 .74rem/1 "DM Mono", ui-monospace, monospace;
  text-align: center;
  pointer-events: none;
}

.mt-beat[data-level="3"] .mt-beat-num { color: var(--text); }

.mt-beat-dots {
  position: absolute;
  right: 10px;
  bottom: 8px;
  left: 10px;
  height: 7px;
  pointer-events: none;
}

.mt-beat-dots i {
  position: absolute;
  top: 0;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: var(--mt-dim);
}

.mt-beat-dots i:first-child { top: -1px; width: 9px; height: 9px; margin-left: -4.5px; }
.mt-beat-dots i.is-on { background: var(--ab-accent); }

/* The beat that is sounding stays lit until the next one. */
.mt-beat.is-on {
  border-color: color-mix(in srgb, var(--ab-accent) 60%, transparent);
  background: color-mix(in srgb, var(--ab-accent) 14%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ab-accent) 16%, transparent), 0 10px 28px color-mix(in srgb, var(--ab-accent) 22%, transparent);
}

.mt-beat.is-on .mt-beat-fill { background: var(--ab-accent); }
.mt-beat.is-on .mt-beat-num { color: var(--text); }
.mt-beat.is-on[data-level="0"] .mt-beat-fill { border-color: var(--ab-accent); background: transparent; }

.mt-beat.is-muted.is-on {
  border-color: var(--mt-dim);
  background: var(--mt-cell);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 8%, transparent);
}

.mt-beat.is-muted.is-on .mt-beat-fill { background: var(--mt-dim); }
.mt-beats.is-countin .mt-beat.is-on { border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 12%, transparent); }
.mt-beats.is-countin .mt-beat.is-on .mt-beat-fill { background: var(--text); }

@media (hover: hover) {
  .mt-beat:hover { border-color: color-mix(in srgb, var(--ab-accent) 40%, var(--border)); }
}

/* The polyrhythm's own row, under the beats. */
.mt-poly {
  position: relative;
  height: 18px;
  margin: 10px 4px 0;
  border-radius: 9px;
  background: color-mix(in srgb, var(--mt-poly) 9%, transparent);
}

.mt-poly i {
  position: absolute;
  top: 4px;
  width: 10px;
  height: 10px;
  margin-left: -5px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--mt-poly) 35%, transparent);
}

.mt-poly i:first-child { margin-left: 0; }
.mt-poly i.is-on { background: var(--mt-poly); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mt-poly) 22%, transparent); }

/* ---------- Pendulum ---------- */

.mt-pendulum {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  justify-content: center;
  height: clamp(70px, 15vh, 200px);
  min-height: 0;
  color: var(--text);
}

.mt-pendulum svg { display: block; width: 100%; max-width: 560px; height: 100%; overflow: visible; }
.mt-pendulum[hidden] { display: none; }

.mt-arc { fill: none; stroke: var(--mt-cell-line); stroke-width: 3; stroke-linecap: round; }
.mt-end { fill: var(--mt-cell); stroke: var(--mt-cell-line); stroke-width: 1.5; transition: fill .25s; }
.mt-end.is-on { fill: var(--ab-accent); stroke: var(--ab-accent); transition: none; }
.mt-rod { stroke-width: 2.5; stroke-linecap: round; }
.mt-bob { fill: var(--ab-accent); }
.mt-bob-glow { fill: color-mix(in srgb, var(--ab-accent) 22%, transparent); opacity: 0; }
.mt-pendulum.is-idle .mt-bob { fill: var(--mt-dim); }
.mt-pendulum.is-idle .mt-rod { opacity: .5; }

/* ---------- Tempo ---------- */

.mt-tempo {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 4vw, 30px);
}

.mt-step {
  display: grid;
  flex: none;
  width: clamp(50px, 7.5vh, 64px);
  height: clamp(50px, 7.5vh, 64px);
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.mt-step svg { width: 22px; height: 22px; }
.mt-step:active { transform: scale(.94); }

@media (hover: hover) {
  .mt-step:hover { border-color: var(--border-hover); }
}

.mt-bpm {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.mt-bpm-value,
.mt-bpm-input {
  width: clamp(168px, 26vh, 290px);
  height: clamp(78px, 12.5vh, 140px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  color: var(--text);
  background: transparent;
  font: 800 clamp(4.4rem, 11.5vh, 8.4rem)/1 "Manrope", "Inter", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.06em;
  text-align: center;
}

.mt-bpm-value {
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.mt-bpm-value.is-dragging { color: var(--ab-accent); }

body.__accessbox-tool .mt-bpm-input {
  border: 1.5px solid var(--ab-accent);
  background: var(--surface);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--ab-accent) 12%, transparent);
}

.mt-bpm-label {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  color: var(--muted);
  font: 600 .82rem/1 "Inter", system-ui, sans-serif;
  white-space: nowrap;
}

.mt-bpm-label #marking { color: var(--text-secondary); }
.mt-unit { display: inline-flex; align-items: center; }
.mt-unit:empty { display: none; }
.mt-unit svg { width: 18px; height: 22px; margin-right: -2px; color: var(--text-secondary); }

/* The tempo slider: a thick track filled up to the thumb. */
.mt-slider {
  --fill: 26%;
  flex: none;
  width: 100%;
  height: 34px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.mt-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--ab-accent) var(--fill), var(--mt-cell) var(--fill));
  box-shadow: inset 0 0 0 1px var(--mt-cell-line);
}

.mt-slider::-moz-range-track {
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--ab-accent) var(--fill), var(--mt-cell) var(--fill));
}

.mt-slider::-webkit-slider-thumb {
  width: 28px;
  height: 28px;
  margin-top: -10px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--ab-accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .22);
  -webkit-appearance: none;
  appearance: none;
}

.mt-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--ab-accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .22);
}

body.__accessbox-tool .mt-slider,
body.__accessbox-tool .mt-slider:focus,
html[data-theme="dark"] body.__accessbox-tool .mt-slider { border: 0; background-color: transparent; box-shadow: none; }

/* ---------- Pills: what the bar is, each opening its sheet ---------- */

.mt-pills {
  display: grid;
  flex: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mt-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  height: clamp(54px, 7.4vh, 66px);
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 15px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  touch-action: manipulation;
}

.mt-pill b {
  overflow: hidden;
  max-width: 100%;
  font: 800 1.12rem/1.1 "Manrope", "Inter", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mt-pill small {
  overflow: hidden;
  max-width: 100%;
  color: var(--muted);
  font: 600 .66rem/1.1 "Inter", system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mt-pill-icon { display: block; height: 24px; }
.mt-pill-icon svg { width: 40px; height: 28px; margin-top: -3px; overflow: visible; }

.mt-pill[aria-expanded="true"] { border-color: color-mix(in srgb, var(--ab-accent) 55%, var(--border)); }
.mt-pill:active { transform: scale(.97); }

@media (hover: hover) {
  .mt-pill:hover { border-color: var(--border-hover); }
}

/* Practice settings that are on, each opening the sheet. */
.mt-active {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: -4px;
}

.mt-active[hidden] { display: none; }

.mt-tag {
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 99px;
  color: color-mix(in srgb, var(--ab-accent) 80%, var(--text));
  background: color-mix(in srgb, var(--ab-accent) 12%, transparent);
  cursor: pointer;
  font: 700 .72rem/1 "Inter", system-ui, sans-serif;
}

/* ---------- Status and transport, at the bottom ---------- */

.mt-foot {
  display: flex;
  flex: none;
  flex-direction: column;
  gap: clamp(8px, 1.6vh, 16px);
}

.mt-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  min-height: 1.3em;
  margin: 0;
  color: var(--muted);
  font: 500 .8rem/1.3 "DM Mono", ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.mt-status-extra:empty { display: none; }
.mt-status-extra { color: var(--text-secondary); }
.mt-status .is-gap { color: var(--ab-accent); font-weight: 600; }

.mt-trainer-bar {
  width: min(320px, 70%);
  height: 4px;
  margin: -4px auto 0;
  overflow: hidden;
  border-radius: 9px;
  background: var(--mt-cell);
}

.mt-trainer-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--ab-accent);
  transition: width .3s ease;
}

.mt-transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(26px, 9vw, 52px);
}

.mt-play {
  display: grid;
  flex: none;
  width: clamp(80px, 12.5vh, 118px);
  height: clamp(80px, 12.5vh, 118px);
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--bg);
  background: var(--text);
  box-shadow: 0 12px 30px rgba(25, 25, 24, .22);
  cursor: pointer;
  touch-action: manipulation;
}

.mt-play svg { width: 42%; height: 42%; }
.mt-play .mt-ico-stop,
.mt-play.is-on .mt-ico-play { display: none; }
.mt-play.is-on .mt-ico-stop { display: block; }
.mt-play.is-on { color: #fff; background: var(--ab-accent); box-shadow: 0 12px 30px color-mix(in srgb, var(--ab-accent) 38%, transparent); }
.mt-play:active { transform: scale(.96); }

.mt-round {
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: clamp(62px, 9vh, 80px);
  height: clamp(62px, 9vh, 80px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  font: 800 .95rem/1 "Manrope", "Inter", system-ui, sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.mt-round small { color: var(--muted); font: 600 .6rem/1 "Inter", system-ui, sans-serif; letter-spacing: .02em; }
.mt-round svg { width: 22px; height: 22px; }
.mt-round:active { transform: scale(.95); }

.mt-tap.is-hit {
  border-color: var(--ab-accent);
  background: color-mix(in srgb, var(--ab-accent) 16%, var(--surface));
  transition: none;
}

.mt-mute .mt-ico-muted,
.mt-mute[aria-pressed="true"] .mt-ico-sound { display: none; }
.mt-mute[aria-pressed="true"] .mt-ico-muted { display: block; }
.mt-mute[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--ab-accent) 50%, var(--border));
  color: var(--ab-accent);
  background: color-mix(in srgb, var(--ab-accent) 10%, var(--surface));
}

@media (hover: hover) {
  .mt-round:hover { border-color: var(--border-hover); }
  .mt-play:hover { transform: translateY(-1px); }
}

/* ---------- Full-screen flash ---------- */

.mt-flash {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--ab-accent);
  opacity: 0;
  pointer-events: none;
}

.mt-flash.is-soft { background: var(--text); }

/* ---------- Inside the sheets ---------- */

.mt-label {
  display: block;
  margin: 0 0 8px;
  color: var(--text-secondary);
  font: 650 .76rem/1.3 "Inter", system-ui, sans-serif;
}

.mt-help { margin: 16px 0 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }

.mt-grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }

.mt-chip {
  height: 48px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text-secondary);
  background: var(--surface);
  cursor: pointer;
  font: 800 1rem/1 "Manrope", "Inter", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.mt-sounds .mt-chip { font: 700 .8rem/1.15 "Inter", system-ui, sans-serif; white-space: normal; }

.mt-chip[aria-pressed="true"],
.mt-sub[aria-pressed="true"],
.mt-seg button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--ab-accent) 60%, var(--border));
  color: var(--text);
  background: color-mix(in srgb, var(--ab-accent) 13%, var(--surface));
}

.mt-custom {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: end;
  margin-top: 20px;
}

.mt-stepper { display: grid; grid-template-columns: auto auto auto; align-items: center; gap: 8px; }
.mt-stepper .mt-label { grid-column: 1 / -1; margin: 0; }
.mt-stepper b { min-width: 30px; font: 800 1.4rem/1 "Manrope", "Inter", system-ui, sans-serif; text-align: center; font-variant-numeric: tabular-nums; }
.mt-stepper .mt-seg { grid-column: 1 / -1; }

.mt-mini {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: var(--text);
  background: var(--mt-cell);
  cursor: pointer;
  font: 700 1.2rem/1 "Inter", system-ui, sans-serif;
  touch-action: manipulation;
}

.mt-mini:disabled { opacity: .35; cursor: default; }

/* A row of equal buttons, one of them chosen. */
.mt-seg {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: 6px;
}

.mt-seg button {
  height: 44px;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-secondary);
  background: var(--surface);
  cursor: pointer;
  font: 700 .86rem/1 "Inter", system-ui, sans-serif;
}

.mt-group { margin-top: 20px; }
.mt-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.mt-wrap .mt-chip { height: 42px; font-size: .9rem; }

/* Clicks: every rhythm as notation, with its name under it. */
.mt-subs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }

.mt-sub {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  height: 84px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.mt-sub svg { width: 48px; height: 34px; overflow: visible; }
.mt-sub span { color: var(--text-secondary); font: 600 .66rem/1.2 "Inter", system-ui, sans-serif; text-align: center; }

.mt-range { margin-top: 22px; }

@media (hover: hover) {
  .mt-chip:hover,
  .mt-sub:hover,
  .mt-seg button:hover { border-color: var(--border-hover); }
  .mt-mini:hover:not(:disabled) { background: color-mix(in srgb, var(--text) 10%, var(--surface)); }
}

/* Practice: each a switch; what it needs shows only while it is on. */
.mt-opts { display: grid; }

.mt-opt { padding: 14px 0; border-bottom: 1px solid var(--border); }
.mt-opt:first-child { padding-top: 6px; }
.mt-opt-body { padding-top: 14px; }
.mt-opt:not(:has(> .mt-switch input:checked)) .mt-opt-body { display: none; }

.mt-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  color: var(--text);
  cursor: pointer;
  font-size: .86rem;
  font-weight: 600;
  line-height: 1.35;
}

.mt-switch span { display: grid; gap: 2px; min-width: 0; }
.mt-switch b { font-weight: 700; }
.mt-switch small { color: var(--muted); font-size: .74rem; font-weight: 500; }

.mt-switch input {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  margin: 0;
  border: 0;
  border-radius: 99px;
  background: color-mix(in srgb, var(--text) 18%, transparent);
  cursor: pointer;
  transition: background-color .15s;
  -webkit-appearance: none;
  appearance: none;
}

.mt-switch input::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  content: "";
  transition: transform .15s;
}

body.__accessbox-tool .mt-switch input { background-color: color-mix(in srgb, var(--text) 18%, transparent); }
body.__accessbox-tool .mt-switch input:checked { background-color: var(--ab-accent); }
.mt-switch input:checked::after { transform: translateX(18px); }

.mt-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.mt-field { display: grid; gap: 6px; }
.mt-field span { color: var(--text-secondary); font: 650 .72rem/1.2 "Inter", system-ui, sans-serif; }
.mt-field .media-input,
.mt-stop .media-input { min-height: 44px; font-size: 1rem; font-variant-numeric: tabular-nums; }

.mt-poly-pick {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font: 700 .9rem "Inter", system-ui, sans-serif;
}

.mt-stop { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; }

.mt-screen { padding-top: 20px; }
.mt-screen .mt-switch { padding: 9px 0; }

.mt-theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  font-size: .86rem;
  font-weight: 600;
}

/* ---------- Setlist popover ---------- */

.mt-presets { width: min(380px, calc(100vw - 24px)); }
.mt-presets-hint { font-size: .76rem; }

.mt-preset-list {
  display: grid;
  gap: 4px;
  margin: 10px 0 12px;
  padding: 0;
  list-style: none;
}

.mt-preset-list:empty { display: none; }

.mt-preset {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 8px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

.mt-preset.is-active {
  border-color: color-mix(in srgb, var(--ab-accent) 55%, var(--border));
  background: color-mix(in srgb, var(--ab-accent) 9%, var(--surface));
}

.mt-preset-n { color: var(--muted); font: 600 .7rem "DM Mono", ui-monospace, monospace; }

.mt-preset-load {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  color: var(--text);
  background: none;
  cursor: pointer;
  text-align: left;
}

.mt-preset-load b { overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.mt-preset-load span { color: var(--muted); font: 500 .68rem "DM Mono", ui-monospace, monospace; }

.mt-preset-tools { display: flex; gap: 2px; }

.mt-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.mt-icon svg { width: 15px; height: 15px; }
.mt-icon:disabled { opacity: .3; cursor: default; }

@media (hover: hover) {
  .mt-icon:hover:not(:disabled) { color: var(--text); background: var(--mt-cell); }
  .mt-icon.is-delete:hover { color: #c0392b; }
}

.mt-preset-save { display: flex; gap: 8px; }
.mt-preset-save .media-input { min-height: 42px; }
.mt-preset-save .btn { min-height: 42px; }
.mt-preset-update { display: block; margin-top: 10px; text-align: left; }

/* ---------- Sizes ---------- */

/* A short window gives up the pendulum before anything else. */
@media (max-height: 640px) {
  .mt-pendulum { display: none; }
}

/* Short lights keep a fill tall enough to read the accents by. */
@media (max-height: 700px) {
  .mt-beat-num { top: 6px; font-size: .68rem; }
  .mt-beat-fill { bottom: 18px; height: calc((100% - 40px) * var(--lv, .66)); }
  .mt-beat-dots { bottom: 6px; }
}

@media (max-width: 400px) {
  .mt-beats { gap: 5px; }
  .mt-beat { border-radius: 12px; }
  .mt-beat-fill { right: 4px; left: 4px; }
  .mt-beat-dots { right: 6px; left: 6px; }
  .mt-tempo { gap: 8px; }
  .mt-bpm-value, .mt-bpm-input { width: 150px; font-size: min(4.2rem, 11.5vh); }
  .mt-pill b { font-size: 1rem; }
}

/* A phone on its side: the lights across the top, the tempo on the left,
   the pills and the transport on the right. */
@media (orientation: landscape) and (max-height: 540px) {
  .mt-main { min-height: 0; }
  .mt-stage {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-areas: "song song" "beats beats" "tempo pills" "slider active" "slider foot";
    grid-template-rows: auto auto auto auto 1fr;
    align-content: start;
    column-gap: 28px;
    row-gap: 10px;
    width: min(100%, 940px);
    padding-top: 10px;
  }

  .mt-song { grid-area: song; }
  .mt-beats-wrap { grid-area: beats; }
  .mt-beats { height: 64px; }
  .mt-pendulum { display: none; }
  .mt-tempo { grid-area: tempo; }
  .mt-slider { grid-area: slider; align-self: start; }
  .mt-pills { grid-area: pills; align-self: center; }
  .mt-active { grid-area: active; margin: 0; }
  .mt-foot { grid-area: foot; margin: 0; align-self: end; }
  .mt-bpm-value, .mt-bpm-input { height: 76px; font-size: 4.2rem; }
  .mt-play { width: 72px; height: 72px; }
  .mt-round { width: 56px; height: 56px; }
}

@media (prefers-reduced-motion: reduce) {
  .mt-beat-fill, .mt-trainer-bar span, .mt-end, .mt-switch input, .mt-switch input::after { transition: none; }
}
