/* ============================================================
   PADLAB — 16 pad mic sampler
   Dark, mobile-first, no external assets.
   ============================================================ */

/* ── Tokens ───────────────────────────────────────────────── */
:root {
  --bg:          #08080a;
  --surface:     #101015;
  --surface-2:   #17171e;
  --surface-3:   #1e1e27;
  --line:        rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .14);

  --text:        #f3f3f6;
  --muted:       #8c8c99;
  --muted-dim:   #5d5d69;

  --accent:      #35d9a0;
  --accent-dim:  rgba(53, 217, 160, .16);
  --accent-line: rgba(53, 217, 160, .42);
  --on-accent:   #05130d;

  --wave-base:   #3b3b47;

  --rec:         #ff4a5e;
  --rec-dim:     rgba(255, 74, 94, .15);

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pad: 16px;

  --pad-gap: 9px;

  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);

  --wave-h: 104px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

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

/* Several components set an explicit display, which would otherwise
   win over the [hidden] attribute's UA rule. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* No accidental text selection / callouts while playing pads. */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* Kills the 300 ms double-tap zoom without disabling pinch zoom. */
  touch-action: manipulation;
  overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── App shell ────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100vh;          /* fallback for older iOS */
  height: 100dvh;
  padding:
    calc(var(--sat) + 12px)
    calc(var(--sar) + 14px)
    calc(var(--sab) + 10px)
    calc(var(--sal) + 14px);
  max-width: 640px;
  margin: 0 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.app-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 9px; }

.brand-mark {
  width: 13px; height: 13px;
  border-radius: 4px;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .16em;
}

.privacy {
  font-size: 10.5px;
  color: var(--muted-dim);
  letter-spacing: .02em;
}

.chip-btn {
  -webkit-appearance: none;
  appearance: none;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  cursor: pointer;
  touch-action: manipulation;
}
.chip-btn:active { transform: scale(.96); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 13px;
  flex: 0 0 auto;
}

/* ── Banner ───────────────────────────────────────────────── */
.banner {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  background: var(--rec-dim);
  border: 1px solid rgba(255, 74, 94, .3);
  font-size: 12.5px;
  color: #ffd9de;
}
.hint-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 9px 13px;
  border-radius: var(--r-md);
  background: rgba(245, 196, 81, .1);
  border: 1px solid rgba(245, 196, 81, .28);
  font-size: 12.5px;
  line-height: 1.35;
  color: #f7dfa8;
}
.hint-bar span { flex: 1 1 auto; }

.hint-close {
  -webkit-appearance: none;
  appearance: none;
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #f7dfa8;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.banner code {
  font-family: var(--mono);
  font-size: 11.5px;
  background: rgba(0, 0, 0, .3);
  padding: 1px 4px;
  border-radius: 4px;
}

/* ── Recording card ───────────────────────────────────────── */
.rec-status {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 11px;
  min-height: 20px;
}

.rec-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted-dim);
  flex: 0 0 auto;
  transition: background-color .18s ease;
}
.rec-dot[data-state="recording"] {
  background: var(--rec);
  animation: pulse 1.15s ease-in-out infinite;
}
.rec-dot[data-state="ready"]      { background: var(--accent); }
.rec-dot[data-state="processing"] { background: #f5c451; animation: pulse .8s ease-in-out infinite; }
.rec-dot[data-state="error"]      { background: var(--rec); }

@keyframes pulse {
  0%, 100% { opacity: 1;   box-shadow: 0 0 0 0 var(--rec-dim); }
  50%      { opacity: .55; box-shadow: 0 0 0 6px transparent; }
}

.rec-label {
  font-size: 13px;
  color: var(--muted);
  flex: 1 1 auto;
  min-width: 0;
}
.rec-label.is-error { color: #ff9aa7; }

.rec-time {
  font-size: 13px;
  color: var(--muted-dim);
  letter-spacing: .02em;
}
.rec-time.is-live { color: var(--rec); }

.rec-actions {
  display: grid;
  grid-template-columns: 1.35fr 1fr .8fr;
  gap: 8px;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform .09s ease, background-color .15s ease, opacity .15s ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: default; }

.btn-sm { min-height: 42px; font-size: 13.5px; }

.btn-rec {
  background: var(--rec);
  border-color: transparent;
  color: #fff;
}
.btn-rec[data-state="armed"] { background: var(--surface-3); color: var(--muted); }

.btn-stop { background: var(--surface-3); }

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: var(--on-accent);
}
.btn-primary.is-saved { background: var(--accent); }

.btn-ghost { background: transparent; }

.btn-danger {
  background: var(--rec);
  border-color: transparent;
  color: #fff;
}

.btn-glyph { flex: 0 0 auto; display: block; }
.glyph-rec  { width: 11px; height: 11px; border-radius: 50%; background: currentColor; }
.glyph-stop { width: 10px; height: 10px; border-radius: 2px; background: currentColor; }
.glyph-play {
  width: 0; height: 0;
  border-left: 9px solid currentColor;
  border-top: 5.5px solid transparent;
  border-bottom: 5.5px solid transparent;
}

.link-btn {
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: 0;
  padding: 4px 2px;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:active { color: var(--text); }

/* ── Mode switch ──────────────────────────────────────────── */
.mode-switch {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

.mode-btn {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  min-height: 40px;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color .15s ease, color .15s ease;
}
.mode-btn.is-active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.mode-btn:disabled { opacity: .4; cursor: default; }

/* ── Editor / waveform ────────────────────────────────────── */
.editor { padding: 12px 13px 11px; }

.editor-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}

.editor-pad {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}
.editor[data-mode="customize"] .editor-pad { color: var(--accent); }

.editor-range {
  font-size: 11.5px;
  color: var(--muted-dim);
}

.wave-wrap {
  position: relative;
  height: var(--wave-h);
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
  touch-action: none;   /* drag the selection without scrolling the page */
  /* No height transition: animating this slides the pad grid for ~180 ms
     after a mode switch and taps land on the wrong pad. */
}

.wave-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
}

.wave-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  color: var(--muted-dim);
}

/* Selection window — the grab target is the whole window, not a handle. */
.sel {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0;
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  box-shadow: 0 0 0 1px rgba(53, 217, 160, .18) inset;
  cursor: grab;
  will-change: transform;
  display: none;
}
.sel-clip { position: absolute; inset: 0; overflow: hidden; }
.sel-clip .wave-canvas { will-change: transform; }

.sel-tag {
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .14em;
  color: var(--accent);
  background: rgba(8, 8, 10, .72);
  padding: 1px 5px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
}
.sel.is-narrow .sel-tag { display: none; }
.sel.is-dragging { cursor: grabbing; background: rgba(53, 217, 160, .24); }

/* Play mode: slimmer strip, no selection, no controls. */
.editor[data-mode="play"] { --wave-h: 66px; }
.editor[data-mode="play"] .editor-controls,
.editor[data-mode="play"] .editor-foot { display: none; }
.editor[data-mode="customize"] .sel { display: block; }

.editor-controls {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.78fr) minmax(0, 1.15fr);
  grid-template-areas:
    "src  len  vol"
    "prev save save";
  gap: 8px;
  align-items: end;
  margin-top: 11px;
}
.field-src  { grid-area: src; }
.field-len  { grid-area: len; }
.field-vol  { grid-area: vol; }
#btnPreview { grid-area: prev; }
#btnSave    { grid-area: save; }

.field-vol .field-label b { color: var(--accent); font-variant-numeric: tabular-nums; }

/* Big, thumb-friendly range control. */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 42px;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;
}
.slider:disabled { opacity: .4; }

.slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right,
    var(--accent) 0 var(--fill, 100%), var(--surface-3) var(--fill, 100%) 100%);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px; height: 26px;
  margin-top: -10px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}
.slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right,
    var(--accent) 0 var(--fill, 100%), var(--surface-3) var(--fill, 100%) 100%);
  border: 1px solid var(--line-strong);
}
.slider::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
}

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.field-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted-dim);
  padding-left: 2px;
}

.select {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 42px;
  padding: 0 22px 0 10px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background-color: var(--surface-2);
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-overflow: ellipsis;
}
.select:disabled { opacity: .4; }

.editor-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  min-height: 18px;
}

.hint {
  font-size: 11.5px;
  color: var(--muted-dim);
}

/* ── Launchpad ────────────────────────────────────────────── */
.loop-panel { padding: 11px 13px; }

.loop-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
}
.loop-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.loop-src {
  font-size: 11.5px;
  color: var(--muted-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 16 steps as 2 rows of 8: a single row of 16 would put every cell
   well below the 44px touch minimum on a phone. */
.step-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
}

.step {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  min-height: 40px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted-dim);
  font-family: var(--mono);
  font-size: 9.5px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .1s ease, border-color .1s ease;
}
.step.is-beat { border-color: var(--line-strong); }
.step.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}
.step.is-cursor { box-shadow: 0 0 0 2px var(--text) inset; }
.step.is-on.is-cursor { box-shadow: 0 0 0 2px #fff inset; }

.transport {
  display: grid;
  grid-template-columns: minmax(112px, auto) 1fr;
  gap: 9px;
  align-items: end;
  margin-top: 10px;
}
.field-bpm .field-label b { color: var(--accent); font-variant-numeric: tabular-nums; }

.loop-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.pad-section {
  flex: 1 1 0%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Floor keeps pads at the 44px touch minimum on short phones. */
  min-height: 204px;
  container-type: size;
}

.pad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--pad-gap);
  width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

/* The square has to fit the shorter axis of the free space, otherwise a
   height clamp squashes the pads into rectangles. cqmin does exactly that. */
@supports (width: 1cqmin) {
  .pad-grid { width: 100cqmin; }
}
/* aspect-ratio fallback: keeps pads square on very old engines */
@supports not (aspect-ratio: 1 / 1) {
  .pad-grid::before { content: ""; grid-area: 1 / 1; padding-bottom: 100%; }
}

.pad {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  padding: 8px 9px;
  min-width: 0;
  border-radius: var(--r-pad);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted-dim);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  /* Audio-first: only cheap compositor properties are animated. */
  transition: transform .1s ease-out, background-color .12s ease, border-color .12s ease;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.pad-num { opacity: .8; }

/* Empty pads carry a dotted mark, so "empty" is not colour-only. */
.pad-mark {
  position: absolute;
  top: 9px; right: 9px;
  width: 7px; height: 7px;
  border-radius: 50%;
  border: 1px dashed var(--muted-dim);
}

.pad.is-loaded {
  background: linear-gradient(160deg, rgba(53, 217, 160, .13), rgba(53, 217, 160, .05));
  border-color: var(--accent-line);
  color: var(--accent);
}
.pad.is-loaded .pad-mark {
  border: 0;
  background: var(--accent);
}

.pad.is-muted { opacity: .55; }
.pad.is-muted .pad-mark { background: var(--muted); }

.pad.is-active {
  box-shadow: 0 0 0 2px var(--accent) inset;
  color: var(--accent);
}
.pad.is-active::after {
  content: "EDIT";
  position: absolute;
  top: 8px; left: 9px;
  font-size: 8.5px;
  letter-spacing: .1em;
  color: var(--accent);
}

.pad-len {
  position: absolute;
  bottom: 8px; right: 9px;
  font-size: 9.5px;
  opacity: .75;
}

.pad-src {
  position: absolute;
  left: 9px; right: 9px;
  bottom: 21px;
  font-size: 8.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.pad-steps {
  position: absolute;
  top: 8px; right: 22px;
  font-size: 8.5px;
  color: var(--accent);
  opacity: .9;
}
.pad.has-steps { border-color: var(--accent-line); }

.pad-key {
  position: absolute;
  top: 8px; left: 9px;
  font-size: 9px;
  opacity: .45;
  display: none;
}
@media (hover: hover) and (pointer: fine) {
  .pad-key { display: block; }
  .pad.is-active .pad-key { display: none; }
}

/* Trigger flash: ~110 ms, transform + colour only. */
.pad.is-hit {
  transform: scale(.965);
  background: rgba(53, 217, 160, .3);
  border-color: var(--accent);
  transition: none;
}
/* An empty pad acknowledges the tap without pretending to be loaded. */
.pad:not(.is-loaded).is-hit {
  background: rgba(255, 255, 255, .1);
  border-color: var(--line-strong);
}

.app-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted-dim);
  padding-top: 2px;
  min-height: 15px;
}
.app-foot .foot-hint::after {
  content: "\00b7";
  padding-left: 8px;
  color: var(--line-strong);
}

/* ── Modal ────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--sat) + 20px) 20px calc(var(--sab) + 20px);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 6, .72);
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 340px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
}

.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.modal-body  { font-size: 13.5px; color: var(--muted); margin-bottom: 16px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: calc(var(--sat) + 16px) 0 0;
}

.sheet-card {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 16px 16px calc(var(--sab) + 16px);
  box-shadow: 0 -12px 44px rgba(0, 0, 0, .6);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.sheet-save {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.text-input {
  -webkit-appearance: none;
  appearance: none;
  min-height: 42px;
  padding: 0 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;   /* below 16px iOS zooms the page on focus */
  min-width: 0;
}
.text-input::placeholder { color: var(--muted-dim); }

.sheet-note {
  font-size: 11.5px;
  color: var(--muted-dim);
  margin: 9px 2px 4px;
}
.sheet-note.is-error { color: #ff9aa7; }

.song-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.song-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  border-top: 1px solid var(--line);
}
.song-info { flex: 1 1 auto; min-width: 0; }
.song-name {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.song-meta { font-size: 11px; color: var(--muted-dim); }
.song-empty { padding: 14px 2px; font-size: 12.5px; color: var(--muted-dim); }

/* ── Responsive tweaks ────────────────────────────────────── */
/* Short phones (iPhone SE class): claw back enough vertical space that
   customize mode still fits without scrolling and pads stay >= 44px. */
@media (max-height: 700px) {
  :root { --wave-h: 54px; --pad-gap: 8px; }
  .app { gap: 5px; }
  .card { padding: 8px 9px; }
  .field-label { font-size: 9.5px; }
  .hint { font-size: 11px; }
  .editor-foot { min-height: 0; }
  .mode-btn { min-height: 36px; }
  .editor-head, .loop-head { margin-bottom: 7px; }
  .btn { min-height: 46px; }
  .btn-sm { min-height: 38px; }
  .select { min-height: 38px; }
  .slider { height: 36px; }
  .slider::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -9px; }
  .rec-status { margin-bottom: 9px; }
  .editor-controls { margin-top: 7px; gap: 7px; }
  .editor-foot { margin-top: 5px; }
  .pad-section { min-height: 200px; }
  .app-foot .foot-hint { display: none; }
  .loop-panel { padding: 9px 11px; }
  .step { min-height: 34px; }
  .transport { margin-top: 8px; }
  .editor[data-mode="play"] { --wave-h: 56px; }
}

@media (max-height: 600px) {
  :root { --wave-h: 60px; }
  .btn { min-height: 44px; }
  /* Header shrinks but never disappears — it carries the privacy notice. */
  .brand-name { font-size: 14px; }
  .brand-mark { width: 10px; height: 10px; }
  .privacy { font-size: 10px; }
  .rec-status { margin-bottom: 7px; }
}

@media (min-width: 560px) {
  :root { --pad-gap: 12px; --wave-h: 140px; }
  body { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .pad.is-hit { transform: none; }
}
