:root {
  --bg: #242424;
  --panel: #1a1a1a;            /* 90% black */
  --text: #e8e8e8;
  --muted: #9a9a9a;
  --field: #2f2f2f;
  --field-border: #444;

  --silent: #3c3c3c;           /* dark gray */
  --silent-lit: #8a8a8a;
  --normal: #2b5fa8;           /* dark blue */
  --normal-lit: #6aa8ff;
  --accent: #a66a00;           /* dark amber */
  --accent-lit: #ffb020;

  --play: #2e7d32;
  --stop: #b23a3a;

  --dialog: #1a1a1a;
  --focus: #6aa8ff;
  --hover: #ffffff0d;
  --hover-2: #ffffff10;
  --press: #ffffff1f;
  --press-2: #ffffff20;
  --btn-hover: #3a3a3a;
  --shadow: #0007;
  --backdrop: #000a;
  --error: #ff6b6b;
  --warn: #ffb84a;
  --ink-blue: var(--normal-lit);    /* lit colours used as text / controls outside the beats panel */
  --ink-amber: var(--accent-lit);
  --panel-edge: #ffffff0d;     /* inset hairline around the beats panel */
  --ring: #fff;                /* outline of the lit beat */
  color-scheme: dark;
}
/* Light theme (theme.js sets data-theme): the room goes light, the beats panel stays a dark display. */
:root[data-theme="light"] {
  --bg: #e2eaf5;
  --text: #1c1f23;
  --muted: #5f666e;
  --field: #ffffff;
  --field-border: #bccadc;
  --dialog: #f4f7fb;
  --focus: #2462c4;
  --hover: #0000000a;
  --hover-2: #0000000d;
  --press: #00000014;
  --press-2: #0000001a;
  --btn-hover: #eaf0f8;
  --shadow: #0003;
  --backdrop: #0008;
  --error: #c62828;
  --warn: #a15c00;
  --ink-blue: #2462c4;
  --ink-amber: #a15c00;
  /* beats panel: dark gray (lighter than the dark theme's), the disks keep their colours */
  --panel: #2e3135;
  color-scheme: light;
}
:root[data-theme="light"] .panel {   /* light handle, strike and focus ring on the dark panel */
  --text: #e8e8e8;
  --muted: #a3a8ae;
  --focus: #6aa8ff;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;            /* single, non-scrollable page */
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;  /* no double-tap zoom on fast taps */
}

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;   /* the stage below takes all spare height, so the controls sit at the bottom */
  gap: clamp(12px, 3.5dvh, 32px);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.title {
  margin: 0;
  font-size: clamp(1rem, 4dvh, 1.5rem);
  font-weight: 600;
  color: var(--muted);
}

/* Only the beats stage may shrink; every other control keeps its size. */
.app > * { flex-shrink: 0; }
.version { cursor: pointer; margin: 0; font-size: 12px; opacity: .6; text-align: center; }

/* ---------- Beats panel ---------- */
/* The stage takes all the vertical space left by the other controls, which stay at
   the bottom; the beats panel is centred in it and the disks are sized to fit inside it,
   so adding measures never moves the controls. */
.stage {
  --n: 4;                              /* beats per measure (set by JS) */
  --m: 1;                              /* number of measures (set by JS) */
  --pad-y: clamp(14px, 3vw, 28px);
  --row-gap: clamp(10px, 2.2dvh, 18px);
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel {
  width: min(100%, 1500px);
  background: var(--panel);
  border-radius: 14px;
  padding: var(--pad-y) clamp(10px, 3vw, 28px);
  box-shadow: 0 8px 30px var(--shadow), inset 0 0 0 1px var(--panel-edge);
}

.measures {
  display: flex;
  flex-direction: column;
  gap: var(--row-gap);
}

.beats {
  container-type: inline-size;
  display: flex;
  flex-wrap: nowrap;           /* always one line */
  justify-content: center;
  /* disk diameter: 88px max, shrinks so N disks + gaps + the length handle (0.6 d) fit on one line
     (cqw = this row), and so all stacked measures fit the stage height (cqh = .stage) */
  --d: min(88px,
           100cqw / (var(--n) * 1.25 + 0.6),
           (100cqh - 2 * var(--pad-y) - (var(--m) - 1) * var(--row-gap)) / var(--m));
  --gap: calc(var(--d) * 0.25);
}
.cells {
  position: relative;
  display: flex;
  flex-wrap: nowrap;
  gap: var(--gap);
  padding-right: calc(var(--d) * 0.85);   /* room for the handle at full length */
}

/* Length handle: an arrow tip at the end of the row; dragged left it erases the last beats. */
.handle {
  position: absolute;
  top: 0;
  left: calc(var(--len) * (var(--d) + var(--gap)) - var(--gap) / 2);   /* tip right after the last active beat */
  z-index: 2;
  width: calc(var(--d) * 0.6);
  height: var(--d);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
}
.handle::before {            /* generous touch target */
  content: '';
  position: absolute;
  left: -8px; right: -8px; top: 50%;
  height: max(100%, 44px);
  transform: translateY(-50%);
}
.handle svg { width: 100%; height: 100%; fill: currentColor; pointer-events: none; }
.handle:hover { color: var(--text); }
.handle:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* One measure or one beat: no handle, so no room reserved for it */
.stage[data-nohandle] .handle { display: none; }
.stage[data-nohandle] .cells { padding-right: 0; }
.stage[data-nohandle] .beats {
  --d: min(88px, 100cqw / (var(--n) * 1.25 - 0.25),
           (100cqh - 2 * var(--pad-y) - (var(--m) - 1) * var(--row-gap)) / var(--m));
}
/* A lone beat is drawn bigger (up to 150px). The rows are spaced by 0.35 d instead of
   --row-gap, so the lit ring (offset outline + scale, ~0.15 d) never reaches the next disk. */
.stage[data-single] .measures { gap: 0; }
.stage[data-single] .beats + .beats { margin-top: calc(var(--d) * 0.35); }
.stage[data-single] .beats { --d: min(150px, 100cqw / 1.85, (100cqh - 2 * var(--pad-y)) / (var(--m) * 1.35 - 0.35)); }
.stage[data-single][data-nohandle] .beats { --d: min(150px, 100cqw, (100cqh - 2 * var(--pad-y)) / (var(--m) * 1.35 - 0.35)); }

/* Horizontal segment striking through the erased beats, up to the arrow tip. */
.strike {
  display: none;
  position: absolute;
  top: 50%;
  left: calc(var(--len) * (var(--d) + var(--gap)) - var(--gap) / 2 + var(--d) * 0.1);   /* starts under the arrow's vertical bar */
  width: calc((var(--n) - var(--len)) * (var(--d) + var(--gap)) - var(--gap) / 2 - var(--d) * 0.1);
  height: max(2px, calc(var(--d) * 0.07));
  transform: translateY(-50%);
  border-radius: 2px;
  background: var(--muted);
  pointer-events: none;
  z-index: 1;
}
.cells[data-custom] .strike { display: block; }

/* Erased beats: still visible under the line, but darker and inert */
.disk[data-erased] { filter: brightness(.35); cursor: default; }

.disk {
  flex: 0 0 auto;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  background: var(--silent);
  color: #0009;
  font: 600 calc(var(--d) * 0.36)/1 system-ui, sans-serif;
  display: grid;
  place-items: center;
  outline: calc(max(2px, var(--d) * 0.06)) solid transparent;
  outline-offset: calc(max(2px, var(--d) * 0.06));
  transition: background-color 120ms ease-out, outline-color 120ms ease-out, transform 120ms ease-out;
  user-select: none;
}
.disk[data-state="silent"] { color: #fff5; }
.disk[data-state="normal"] { background: var(--normal); }
.disk[data-state="accent"] { background: var(--accent); }

.disk:focus-visible { outline-color: var(--focus); }

/* Lit beat: instant on, short fade out */
.disk.lit {
  position: relative;
  z-index: 1;                /* ring painted above the neighbouring disks */
  outline-color: var(--ring);
  transform: scale(1.06);
  transition: none;
}
.disk.lit[data-state="silent"] { background: var(--silent-lit); }
.disk.lit[data-state="normal"] { background: var(--normal-lit); box-shadow: 0 0 calc(var(--d) * .5) #6aa8ff66; }
.disk.lit[data-state="accent"] { background: var(--accent-lit); box-shadow: 0 0 calc(var(--d) * .5) #ffb02077; }

.legend {
  margin: 0;
  display: flex;
  gap: 18px;
  font-size: .8rem;
  color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.stage[data-single] + .legend span:first-child { display: none; }   /* one beat: no silent state */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.silent { background: var(--silent); box-shadow: inset 0 0 0 1px #fff3; }
.dot.normal { background: var(--normal); }
.dot.accent { background: var(--accent); }

/* ---------- Play / Stop ---------- */
.play {
  --size: clamp(56px, 12dvh, 84px);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  border: 0;
  background: var(--play);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px var(--shadow);
  transition: background-color 150ms, transform 80ms;
}
/* small devices (phones, portrait or landscape): 30% smaller, but never below a 44px touch target */
@media (max-width: 600px), (max-height: 480px) {
  .play { --size: max(44px, calc(clamp(56px, 12dvh, 84px) * 0.7)); }
}
.play:active { transform: scale(.95); }
.play:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.play { padding: 0; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }   /* definite track + no default button padding, so the % sizes below are of the whole button */
.play svg { fill: currentColor; pointer-events: none; }
/* Uniform play/stop symbol, same in every app and at every size: its circumscribed circle is half the button's
   diameter and concentric with the button. Triangle: circle d = 15.45/24 of the icon box, centre (11.27, 12), so the
   box is 77.67% of the button, nudged right 3.04%. Square: d = 16.97/24, so the box is 70.71%. */
.play .icon-play { width: 77.67%; height: 77.67%; transform: translateX(3.04%); }
.play .icon-stop { width: 70.71%; height: 70.71%; }
.play .icon-stop { display: none; }
.play[aria-pressed="true"] { background: var(--stop); }
.play[aria-pressed="true"] .icon-play { display: none; }
.play[aria-pressed="true"] .icon-stop { display: block; }

/* ---------- Controls ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(12px, 3vw, 40px);
  row-gap: clamp(10px, 2dvh, 20px);
  width: min(100%, 720px);
}

.field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.field.tempo { flex: 1 1 240px; }

label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
}
.unit { opacity: .7; }
.tempo-val.multiplied, .mult select.multiplied { color: var(--ink-amber); }

.stepper {
  display: flex;
  align-items: stretch;
  height: 44px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--field-border);
  background: var(--field);
}
.stepper button {
  width: 44px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
}
.stepper button:hover { background: var(--hover-2); }
.stepper button:active { background: var(--press-2); }
.stepper input {
  width: 4.2ch;
  border: 0;
  border-inline: 1px solid var(--field-border);
  background: transparent;
  color: var(--text);
  font: 600 1.25rem/1 system-ui, sans-serif;
  text-align: center;
  font-variant-numeric: tabular-nums;
  appearance: textfield;
  -moz-appearance: textfield;
}
.stepper input::-webkit-inner-spin-button,
.stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; background: var(--hover); }
/* touch screens: value shown, not editable, never focused (no virtual keyboard) */
.stepper input.display-only { pointer-events: none; user-select: none; -webkit-user-select: none; }
.field.tempo .stepper input { flex: 0 0 auto; width: 4.8ch; padding: 0; }   /* tempo: room for 3 digits on every device (no padding, never shrinks) */

.tempo-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.mult { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 1.1rem; }
.mult select {
  height: 44px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--text);
  font: 600 1.05rem system-ui, sans-serif;
}
.mult select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }

.tap {
  min-width: 76px;
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  user-select: none;
  transition: background-color 80ms;
}
.tap:hover { background: var(--btn-hover); }

/* icon-only button (edit beat sequence) */
.icon-btn {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover { background: var(--btn-hover); }
.icon-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn .lbl { display: none; }
/* PC and large displays: icon + text label (the complement of the compact breakpoint above). */
@media (min-width: 601px) and (min-height: 481px) {
  .icon-btn:has(.lbl) { width: auto; padding: 0 14px; grid-auto-flow: column; gap: 8px; font: 600 .85rem system-ui, sans-serif; white-space: nowrap; }
  .icon-btn .lbl { display: inline; }
}
.tap.hit { background: var(--normal); transition: none; }
.tap:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.tap-label { font-weight: 600; font-size: .95rem; }
.tap-info { font-size: .65rem; color: var(--muted); font-variant-numeric: tabular-nums; min-height: 1em; }
.tap-info:empty { display: none; }

input[type="range"] {
  width: 100%;
  accent-color: var(--ink-blue);
  height: 28px;
}

/* Short screens (phones in landscape): tighten everything */
@media (max-height: 480px) and (orientation: landscape) {
  .title, .legend { display: none; }
  .app { gap: 12px; }
}
/* ...and put the controls on one line only when it fits (about 700px of controls); narrower, they wrap */
@media (max-height: 480px) and (orientation: landscape) and (min-width: 761px) {
  .controls { flex-wrap: nowrap; width: min(100%, 900px); align-items: flex-end; }
  .field.tempo { flex: 1 1 auto; }
}

/* Narrow phones: tighter steppers so Beats + Measures share a row */
@media (max-width: 400px) {
  .stepper button { width: 38px; }
  .app { gap: clamp(10px, 2.5dvh, 24px); }
}

/* Very narrow: smaller Beats / pencil / Measures so they stay on one line */
@media (max-width: 349px) {
  .controls { gap: 8px; }
  .controls .field:not(.tempo) .stepper { height: 36px; }
  .controls .field:not(.tempo) .stepper button { width: 30px; font-size: 1.1rem; }
  .controls .field:not(.tempo) .stepper input { width: 3ch; font-size: 1.05rem; }
  .controls .field:not(.tempo) .tempo-row { gap: 6px; }
  .controls .field:not(.tempo) .icon-btn { width: 36px; height: 36px; }
  .controls .field:not(.tempo) .icon-btn svg { width: 17px; height: 17px; }
  /* tempo row: multiplier, stepper, Tap */
  .controls .field.tempo .tempo-row { gap: 6px; }
  .controls .field.tempo .stepper { height: 36px; }
  .controls .field.tempo .stepper button { width: 30px; font-size: 1.1rem; }
  .controls .field.tempo .stepper input { width: 4.8ch; padding: 0; font-size: .9rem; }   /* room for 3 digits plus borders */
  .controls .field.tempo > label { font-size: .72rem; }
  .controls .field.tempo .mult { gap: 4px; font-size: 1rem; }
  .controls .field.tempo .mult select { height: 36px; padding: 0 4px; font-size: .95rem; }
  .controls .field.tempo .tap { min-width: 56px; height: 36px; padding: 0 8px; }
  .controls .field.tempo .tap-label { font-size: .8rem; }
}

/* Embedded in the home page: the tab already names the app */
.embedded .title { display: none; }

/* ---------- Beat sequence dialog ---------- */
.seq-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--field-border);
  border-radius: 14px;
  background: var(--dialog);
  color: var(--text);
  box-shadow: 0 20px 60px var(--shadow);
}
.seq-dialog::backdrop { background: var(--backdrop); }
.seq-dialog form { display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.seq-dialog label { text-transform: none; letter-spacing: 0; font-size: .95rem; color: var(--text); }
.seq-dialog input {
  height: 46px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--text);
  font: 600 1.25rem/1 system-ui, sans-serif;
  letter-spacing: .04em;
}
.seq-dialog input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.seq-dialog input.invalid { outline-color: var(--error); border-color: var(--error); }
.seq-error, .seq-warn { margin: 0; font-size: .8rem; }
.seq-error { color: var(--error); }
.seq-warn { color: var(--warn); }
.seq-result {
  min-height: 1.4em;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-blue);
  word-break: break-word;
}
.seg { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.seg legend { padding: 0; margin-bottom: 6px; font-size: .85rem; color: var(--text); }
.seg legend small { color: var(--muted); margin-left: 4px; }
.seg-opts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--field-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--field);
}
.seg-opts label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  font-size: .85rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.seg-opts label + label { border-left: 1px solid var(--field-border); }
.seg-opts label:hover { background: var(--hover); }
.seg-opts input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg-opts label:has(input:checked) { background: var(--press); color: var(--text); font-weight: 600; }
.seg-opts label:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: -2px; }

/* tabs: the panels share one grid cell, so the dialog keeps its size when switching */
.dlg-tabs { display: flex; border-bottom: 1px solid var(--field-border); }
.dlg-tabs button { flex: 1; height: 38px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font: 600 .9rem system-ui, sans-serif; cursor: pointer; }
.dlg-tabs button:hover { background: var(--hover); }
.dlg-tabs button[aria-selected="true"] { border-bottom-color: var(--focus); color: var(--text); }
.dlg-tabs button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.dlg-panels { display: grid; grid-template-columns: minmax(0, 1fr); }
.dlg-panel { grid-area: 1 / 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dlg-panel.off { visibility: hidden; }

/* the entered pattern as beat disks, always on one line (they shrink when many); empty while not valid */
.seq-preview { display: flex; justify-content: center; align-items: center; gap: 3px; height: 28px; flex: none; padding: 0 8px; border-radius: 10px; background: #000; }
.seq-preview .dot { flex: 0 1 12px; min-width: 0; height: auto; aspect-ratio: 1; }
/* preview and down / up buttons: all lit, like the metronome's disks while they sound */
.seq-preview .dot.silent, .seg-opts .dot.silent { background: var(--silent-lit); box-shadow: none; }
.seq-preview .dot.normal, .seg-opts .dot.normal { background: var(--normal-lit); box-shadow: 0 0 6px #6aa8ff66; }
.seq-preview .dot.accent, .seg-opts .dot.accent { background: var(--accent-lit); box-shadow: 0 0 6px #ffb02077; }

.bar-demo { width: 100%; height: auto; max-height: 90px; }
.help-text { margin: 0; font-size: .9rem; line-height: 1.4; color: var(--muted); }
.seq-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.btn {
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--text);
  font: 600 .95rem system-ui, sans-serif;
  cursor: pointer;
}
.btn:hover { background: var(--btn-hover); }
.btn.primary { background: var(--play); border-color: transparent; color: #fff; }
.btn.primary:hover { background: #379140; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Transport row & sound settings ---------- */
.transport {
  display: flex;
  justify-content: center;   /* toggle + play button centered as one group */
  align-items: center;
  gap: clamp(12px, 4vw, 24px);
  width: min(100%, 560px);   /* room for the sound type labels with their icons */
}
.mode-toggle {
  display: flex;
  height: 40px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--field);
}
.mode-toggle button {
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: 600 .72rem system-ui, sans-serif;
  letter-spacing: .02em;
  cursor: pointer;
}
/* Sound type: icon + label (metronome, trombone, darbuka), icon only on small devices */
.mode-toggle button:not(.mute-btn) { display: inline-flex; align-items: center; gap: 5px; }
.mode-ico { flex: 0 0 auto; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.800; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
@media (max-width: 600px), (max-height: 480px) {
  .mode-toggle .txt { display: none; }
  .mode-toggle button:not(.mute-btn) { padding: 0 12px; }
}
.mute-btn { display: grid; place-items: center; }
.mute-btn svg { width: 18px; height: 18px; fill: currentColor; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.mute-btn svg path:first-child { stroke-width: 1; }
.mute-btn svg path:last-child { fill: none; }
.mode-toggle button + button { border-left: 1px solid var(--field-border); }
.mode-toggle button:hover { background: var(--hover); }
.mode-toggle button[aria-pressed="true"] { background: var(--press); color: var(--text); }
.mode-toggle button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.dlg-title { margin: 0; font-weight: 600; font-size: 1.05rem; }
.note-row { display: flex; gap: 10px; align-items: center; }
.seq-dialog select {
  height: 44px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--field-border);
  background: var(--field);
  color: var(--text);
  font: 600 1.05rem system-ui, sans-serif;
}
.seq-dialog select:first-child { flex: 1 1 auto; }
.seq-dialog select:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.seq-dialog .stepper input { height: auto; padding: 0; border-radius: 0; letter-spacing: 0; }
.stepper input.frac-input { width: 6ch; }
.seg-opts.two { grid-template-columns: repeat(2, 1fr); }
.seg-opts.stack { grid-template-columns: 1fr; }
.seg-opts.stack label { justify-content: flex-start; padding: 0 14px; }
.seg-opts.stack label + label { border-left: 0; border-top: 1px solid var(--field-border); }
.seq-dialog .oct-label { color: var(--muted); font-size: .85rem; }


/* ---------- Presets dialog ---------- */
/* Fixed size: the list scrolls inside it. */
#presetsDialog { height: fit-content; max-height: none; overflow: hidden; }
#presetsDialog form { height: min(460px, calc(100dvh - 32px)); box-sizing: border-box; }
#presetsDialog .seq-actions { margin-top: auto; }
.dlg-title small { color: var(--muted); font-weight: 400; font-size: .8rem; margin-left: .4em; }
.preset-save { display: flex; gap: 8px; }
.preset-save input { flex: 1 1 auto; min-width: 0; }
.preset-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; flex: 1 1 0; min-height: 0; overflow-y: auto; }
.preset-list[hidden] { display: none; }
.preset-list li { display: flex; gap: 6px; }
.preset-load {
  flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 6px 12px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px;
  border-radius: 10px; border: 1px solid var(--field-border); background: var(--field);
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.preset-load:hover { background: var(--btn-hover); }
.preset-load:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* label, then the tempo summary to its right when it fits, otherwise below it */
.preset-head { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 12px; row-gap: 0; max-width: 100%; }
.preset-name { font-weight: 600; overflow-wrap: anywhere; }
.preset-load small { color: var(--muted); }
.preset-dots { display: flex; flex-wrap: wrap; gap: 3px; }
.preset-dots .dot { width: 8px; height: 8px; }
.preset-del svg { width: 18px; height: 18px; }
.preset-empty { margin: 0; color: var(--muted); font-size: .9rem; }
.preset-empty[hidden] { display: none; }
