/* kit.css — 16-pad Auto Kit surface (web mirror of mobile SamplePadGrid4x4).
 * All colors ride the shared --jamn-* custom properties with hard fallbacks;
 * per-pad tint arrives as an "r,g,b" triple in --pad-tint (set from the
 * server's colorHint by kit.js) so rgba(var(--pad-tint), a) composes the
 * mobile tint-at-opacity fills without per-category CSS. */

.kit-surface {
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: var(--jamn-text, #fff);
  /* Single source of truth for the surface column width. The grid AND every
   * row that "stays aligned with .kit-grid" (head, transport, arrangement,
   * layers) read this one var, so widening the pads to fill the desktop can
   * never desync the toolbar/transport above them. 16-mode (4-up) caps
   * narrower than 64-mode so 4 pads don't balloon into hero tiles. */
  --kit-w: min(980px, 94vw);
}

/* 64 (8×8) is eight pads wide, so it earns a wider column than the 4-up grid
 * — ~146px pads at the cap, comfortable without the 4-up's ~240px giants.
 * Only the padCount toggle (setPadCount → syncPadCountUi) sets .kit-is-64, so
 * the whole column resizes in lockstep with the grid. */
.kit-surface.kit-is-64 {
  --kit-w: min(1200px, 94vw);
}

/* ---------- header ---------- */

.kit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
  max-width: var(--kit-w); /* stay aligned with .kit-grid */
  margin-inline: auto;
  box-sizing: border-box;
}

.kit-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--jamn-text, #fff);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.kit-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  /* Wrap so no segmented group is clipped off the right edge on narrow
     viewports (mobile web) — every control stays reachable. */
  flex-wrap: wrap;
  row-gap: 8px;
  /* LOCK: the controls always take their OWN full-width row under the
   * title/status line. Without this they are a flex sibling of the status
   * text, so the status changing width ("Loading kit…" → "Loading stems
   * 3/6 — 42 MB…" → "") would reflow where the controls sit. Forcing a
   * 100% basis decouples them: the status can only ever reshuffle the title
   * row above, never the control positions. Every control is built at mount
   * (present-but-disabled, never added post-load), so with a stable row the
   * toolbar is pixel-identical before, during, and after the kit loads. */
  flex-basis: 100%;
}

.kit-seg {
  display: inline-flex;
  background: var(--jamn-surface1, #14141A);
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: 8px;
  padding: 2px;
}

.kit-seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--jamn-text2, #A1A1AA);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.kit-seg-btn.is-on {
  background: var(--jamn-accent, #8B5CF6);
  color: var(--jamn-text, #fff);
}

.kit-toggle,
.kit-stop {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--jamn-border, #2A2A36);
  background: var(--jamn-surface1, #14141A);
  color: var(--jamn-text2, #A1A1AA);
  cursor: pointer;
}

.kit-toggle.is-on {
  border-color: var(--jamn-accent, #8B5CF6);
  color: var(--jamn-accent, #8B5CF6);
}

/* Edit chip (launchpad-edit-mode parity): ON gets a faint accent fill on
 * top of the shared .kit-toggle.is-on outline so "pads are editable right
 * now" reads at a glance — the mode changes what a hold/right-click DOES,
 * not just a panel's visibility. */
.kit-toggle.kit-edit.is-on {
  background: rgba(139, 92, 246, 0.14);
}

/* Latch only means something in Loop mode — fade it in Tap. */
.kit-toggle.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

.kit-stop:hover,
.kit-toggle:hover {
  color: var(--jamn-text, #fff);
}

/* Instant Groove: the one prominent header action (desktop's accent
 * "Groove" button) — filled accent, not another quiet outline chip. */
.kit-groove {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--jamn-accent, #8B5CF6);
  background: var(--jamn-accent, #8B5CF6);
  color: var(--jamn-text, #fff);
  cursor: pointer;
  /* The session block beside it is a COLUMN (controls + caption), which
   * makes its wrap-line tall; centering against that dropped Groove below
   * the control row. Top-align so it sits on the same line as the pills. */
  align-self: flex-start;
}

.kit-groove:hover {
  filter: brightness(1.12);
}

/* ---------- manual chop-slicing (Stem / Slices / Load) ---------- */

/* Reuses the segmented-group shell (.kit-seg) so the cluster reads as one
 * control, matching the surrounding toolbar rather than raw browser selects. */
.kit-chop {
  gap: 6px;
}

.kit-select {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-inline: 4px;
}

.kit-select-cap {
  font-size: 11px;
  font-weight: 600;
  color: var(--jamn-text2, #A1A1AA);
}

/* Styled to sit inside the segmented shell — no default browser chrome. */
.kit-select-el {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--jamn-text, #fff);
  background: var(--jamn-surface2, #1C1C24);
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: 6px;
  padding: 3px 22px 3px 8px;
  cursor: pointer;
  /* Chevron drawn inline so the control needs no external asset. */
  background-image: linear-gradient(45deg, transparent 50%, var(--jamn-text2, #A1A1AA) 50%),
    linear-gradient(135deg, var(--jamn-text2, #A1A1AA) 50%, transparent 50%);
  background-position: right 9px center, right 5px center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.kit-select-el:focus {
  outline: none;
  border-color: var(--jamn-accent, #8B5CF6);
}

.kit-chop-load {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--jamn-accent, #8B5CF6);
  background: transparent;
  color: var(--jamn-accent, #8B5CF6);
  cursor: pointer;
}

.kit-chop-load:hover {
  background: var(--jamn-accent, #8B5CF6);
  color: var(--jamn-text, #fff);
}

/* Disabled while a Load fetch is in flight. */
.kit-chop-load:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ---------- optional Session key/BPM target (Borrow conform) ---------- */

/* OFF by default; songs play TRUE. When on, only ADDED (borrowed) parts are
 * conformed to this key/tempo — never the loaded song's own playback. The
 * cluster stacks its toggle+fields row over a one-line "plays true" hint so
 * the promise stays visible right at the control. */
.kit-session {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
}

.kit-session-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Reuses the .kit-seg segmented shell; hidden until the session is on. */
.kit-session-fields {
  gap: 6px;
}

.kit-session-fields[hidden] {
  display: none;
}

/* Plain number input dressed to match .kit-select-el (no spinner chrome). */
.kit-num {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  width: 52px;
  color: var(--jamn-text, #fff);
  background: var(--jamn-surface2, #1C1C24);
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: 6px;
  padding: 3px 6px;
}

.kit-num::-webkit-outer-spin-button,
.kit-num::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox drops the number spinners without the browser default chrome. */
.kit-num {
  -moz-appearance: textfield;
}

.kit-num:focus {
  outline: none;
  border-color: var(--jamn-accent, #8B5CF6);
}

.kit-session-hint {
  font-size: 11px;
  font-weight: 500;
  color: var(--jamn-text2, #A1A1AA);
  max-width: 340px;
  line-height: 1.3;
}

.kit-session-hint[hidden] {
  display: none;
}

/* ---------- transport strip ---------- */

.kit-transport {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: var(--kit-w); /* stay aligned with .kit-grid */
  margin-inline: auto;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: var(--jamn-radius-md, 12px);
  background: var(--jamn-surface1, #14141A);
}

.kit-play {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid var(--jamn-border, #2A2A36);
  background: var(--jamn-surface2, #1C1C24);
  color: var(--jamn-text, #fff);
  cursor: pointer;
  white-space: nowrap;
}

.kit-play.is-playing {
  border-color: var(--jamn-accent, #8B5CF6);
  color: var(--jamn-accent, #8B5CF6);
}

/* Stop All lives in the transport bar next to Play — same row as Play +
 * Kill All so all three transport actions share one bar. Match Play's fill
 * so it reads as a transport control, not a header toggle. */
.kit-transport-btn {
  padding: 5px 14px;
  background: var(--jamn-surface2, #1C1C24);
  color: var(--jamn-text, #fff);
  white-space: nowrap;
}

.kit-time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--jamn-text2, #A1A1AA);
  white-space: nowrap;
}

.kit-transport-spacer {
  flex: 1 1 auto;
}

/* Kill All: the panic button — danger-tinted and unmissable. */
.kit-kill {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid var(--jamn-danger, #EF4444);
  background: rgba(239, 68, 68, 0.14);
  color: var(--jamn-danger, #EF4444);
  cursor: pointer;
  white-space: nowrap;
}

.kit-kill:hover {
  background: var(--jamn-danger, #EF4444);
  color: var(--jamn-text, #fff);
}

/* ---------- live-capture arrangement ---------- */

/* Own row UNDER the transport: controls line + section strip. Aligned to
 * the same 720px column so it never widens the surface or crowds the
 * transport buttons above it. */
.kit-arr {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: var(--kit-w);
  margin-inline: auto;
  box-sizing: border-box;
  padding: 8px;
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: var(--jamn-radius-md, 12px);
  background: var(--jamn-surface1, #14141A);
}

.kit-arr-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.kit-arr-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--jamn-text2, #A1A1AA);
  margin-right: 2px;
}

/* Rec: filled red while armed so "we're capturing" is unmistakable. */
.kit-toggle.kit-arr-rec.is-recording {
  border-color: var(--jamn-danger, #EF4444);
  background: rgba(239, 68, 68, 0.16);
  color: var(--jamn-danger, #EF4444);
  animation: kit-arr-rec-pulse 1.2s ease-in-out infinite;
}

@keyframes kit-arr-rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* The section strip: one segment per COLLAPSED block, flex-grown by its
 * duration. position:relative anchors the sweeping playhead. */
.kit-arr-strip {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 30px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--jamn-surface2, #1C1C24);
  border: 1px solid var(--jamn-border, #2A2A36);
}

.kit-arr-seg {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border-right: 1px solid var(--jamn-border, #2A2A36);
  background: transparent;
  transition: background 0.15s ease;
}

.kit-arr-seg:last-of-type {
  border-right: 0;
}

.kit-arr-seg-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--jamn-text2, #A1A1AA);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* A block that carries captured pads — a soft accent fill + brighter label. */
.kit-arr-seg.has-pads {
  background: rgba(139, 92, 246, 0.16);
}

.kit-arr-seg.has-pads .kit-arr-seg-label {
  color: var(--jamn-text, #fff);
}

/* The block the song is currently inside. */
.kit-arr-seg.is-active {
  background: rgba(139, 92, 246, 0.30);
}

.kit-arr-seg.is-active .kit-arr-seg-label {
  color: var(--jamn-text, #fff);
}

/* Live playhead: a thin accent line swept by the arrangement poll. */
.kit-arr-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  margin-left: -1px;
  background: var(--jamn-accent, #8B5CF6);
  box-shadow: 0 0 6px rgba(139, 92, 246, 0.9);
  pointer-events: none;
  z-index: 2;
}

.kit-arr-note {
  font-size: 12px;
  color: var(--jamn-text2, #A1A1AA);
  opacity: 0.8;
}

/* ---------- grid ---------- */

.kit-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px; /* matches mobile tile spacing */
  /* Never wider than the visible content area — a fixed 4-up grid was
   * clipping its right column off-screen next to the 260px sidebar. */
  width: 100%;
  /* Launchpad scale: square pads that fill the desktop column (~240px at
   * 4-up, ~146px at 8-up) instead of small centred tiles marooned in empty
   * margin. The cap rides --kit-w so head/transport/arrangement track it. */
  max-width: var(--kit-w);
  margin-inline: auto;
  box-sizing: border-box;
}

/* Loading shimmer + status: the bare skeleton read as "dead page"
 * during the multi-second stem fetch (no spinner anywhere). */
.kit-pad.is-skeleton {
  animation: kit-shimmer 1.2s ease-in-out infinite;
}
@keyframes kit-shimmer {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.9; }
}
.kit-status {
  font-size: 0.85rem;
  color: var(--jamn-text2, #A1A1AA);
  margin-left: 12px;
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kit-pad {
  --pad-tint: 139, 92, 246; /* accent fallback until kit.js sets colorHint */
  position: relative;
  appearance: none;
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: var(--jamn-radius-lg, 16px);
  /* Idle filled pad: tint at low opacity over the surface — the mobile
   * "0.30 over near-black" look ("filled must not read as dead"). */
  background:
    linear-gradient(rgba(var(--pad-tint), 0.28), rgba(var(--pad-tint), 0.28)),
    var(--jamn-surface2, #1C1C24);
  aspect-ratio: 1 / 1;
  min-height: 64px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  gap: 4px;
  cursor: pointer;
  overflow: hidden;
  touch-action: none; /* pointer events own the gesture (no scroll/zoom steal) */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.kit-pad.is-playing {
  /* Stronger tint while ringing (mobile bumps 0.30 → 0.50). */
  background:
    linear-gradient(rgba(var(--pad-tint), 0.5), rgba(var(--pad-tint), 0.5)),
    var(--jamn-surface2, #1C1C24);
  border-color: rgba(255, 255, 255, 0.85);
}

.kit-pad.is-pressed {
  box-shadow: inset 0 0 0 100vmax rgba(255, 255, 255, 0.18);
}

.kit-pad.is-empty {
  background: var(--jamn-surface1, #14141A);
  cursor: default;
  opacity: 0.5;
}

.kit-pad-name {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  color: var(--jamn-text, #fff);
  text-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.45); /* scrim: readable mid-flash */
  /* Truncate at two lines like the mobile tile label. */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  pointer-events: none;
}

/* Source-song label (Borrow): which song a pad's loop came from. The tint
 * (blue = this song, amber = borrowed) carries the same signal in colour;
 * this line makes it readable. Sits under the name, above the waveform. */
.kit-pad-source {
  font-size: 9px;
  font-weight: 600;
  line-height: 1.2;
  text-align: left;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 1px 1.5px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  pointer-events: none;
}

.kit-grid.kit-grid-64 .kit-pad-source {
  font-size: 8px;
  line-height: 1.1;
}

.kit-pad-wave {
  /* Fill the tile body so the waveform reads mid-pad like the native
   * tiles (a 30px bottom strip read as a footer, not the pad's face). */
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  align-self: stretch;
  pointer-events: none;
}

/* Elapsed sweep + playhead over the tile while playing (mobile
 * loopPlayhead: translucent elapsed region ending in a bright line). */
.kit-pad-sweep {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: rgba(255, 255, 255, 0.14);
  border-right: 2px solid rgba(255, 255, 255, 0.95);
  pointer-events: none;
}

.kit-pad:not(.is-playing) .kit-pad-sweep {
  display: none;
}

/* Progress ring: kit.js paints a conic-gradient into this element each
 * frame; the mask hollows it to a 2.5px edge ring hugging the tile radius. */
.kit-pad-ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 2.5px;
  background: none;
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* Armed: triggered but waiting for the quantize boundary — pulsing tinted
 * border reads "waiting for the beat", not broken silence. */
.kit-pad.is-armed {
  border-color: rgba(var(--pad-tint), 0.9);
  animation: kit-armed-pulse 0.9s ease-in-out infinite;
}

@keyframes kit-armed-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--pad-tint), 0.0); }
  50%      { box-shadow: 0 0 0 3px rgba(var(--pad-tint), 0.45); }
}

/* ---------- loading skeleton ---------- */

.kit-pad.is-skeleton {
  border-color: var(--jamn-border, #2A2A36);
  background: var(--jamn-surface1, #14141A);
  cursor: default;
  animation: kit-skeleton 1.2s ease-in-out infinite;
}

@keyframes kit-skeleton {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 0.85; }
}

/* ---------- 8×8 compact grid (header 64 toggle / ?pads=64) ---------- */

/* Header + transport + arrangement + grid all widen together in 64 mode via
 * the --kit-w bump on .kit-surface.kit-is-64 (above) — no per-row max-width
 * override needed here; the grid only changes its column count + gap. */
.kit-grid.kit-grid-64 {
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
}

.kit-grid.kit-grid-64 .kit-pad {
  min-height: 44px;
  padding: 5px;
  border-radius: 10px;
}

.kit-grid.kit-grid-64 .kit-pad-name {
  font-size: 9px;
  -webkit-line-clamp: 1;
}

.kit-grid.kit-grid-64 .kit-pad-badge {
  font-size: 9px;
  padding: 1px 4px;
}

/* Step dots don't survive ~100px tiles — the simplified waveform is the
 * only chrome the compact grid keeps. */
.kit-grid.kit-grid-64 .kit-pad-steps {
  display: none;
}

/* ---------- sequence step dots (kit defaultSequence, kind=flip) ---------- */

.kit-pad-steps {
  display: flex;
  gap: 2px;
  align-items: center;
  pointer-events: none;
}

.kit-pad-step {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  flex: none;
}

.kit-pad-step.is-on {
  background: rgba(255, 255, 255, 0.9);
}

/* ---------- layers view (desktop LayerStackView rack) ---------- */

.kit-layers {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: var(--kit-w); /* stay aligned with .kit-grid */
  margin-inline: auto;
  box-sizing: border-box;
}

.kit-layer-row {
  --pad-tint: 139, 92, 246;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: var(--jamn-radius-md, 12px);
  background: var(--jamn-surface1, #14141A);
}

.kit-layer-row.is-live {
  border-color: rgba(var(--pad-tint), 0.55);
  background:
    linear-gradient(rgba(var(--pad-tint), 0.10), rgba(var(--pad-tint), 0.10)),
    var(--jamn-surface1, #14141A);
}

/* Armed layer: same "waiting for the beat" pulse as the grid pads. */
.kit-layer-row.is-armed {
  animation: kit-armed-pulse 0.9s ease-in-out infinite;
}

.kit-layer-bar {
  width: 6px;
  height: 32px;
  border-radius: 3px;
  background: rgba(var(--pad-tint), 0.95);
  flex: none;
}

.kit-layer-cat {
  width: 66px;
  flex: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(var(--pad-tint), 0.95);
}

.kit-layer-active {
  flex: 0 0 150px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kit-layer-wave {
  width: 100%;
  height: 22px;
}

.kit-layer-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--jamn-text, #fff);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kit-layer-play {
  appearance: none;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--jamn-border, #2A2A36);
  background: var(--jamn-surface2, #1C1C24);
  color: var(--jamn-text, #fff);
  font: inherit;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.kit-layer-row.is-live .kit-layer-play {
  border-color: rgba(var(--pad-tint), 0.9);
  color: rgba(var(--pad-tint), 0.95);
}

/* Swap picker: the category's pads as chips, best score first. */
.kit-layer-chips {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.kit-layer-chip {
  appearance: none;
  flex: none;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--jamn-border, #2A2A36);
  background: var(--jamn-surface2, #1C1C24);
  color: var(--jamn-text2, #A1A1AA);
  cursor: pointer;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kit-layer-chip:hover {
  color: var(--jamn-text, #fff);
}

.kit-layer-chip.is-on {
  border-color: rgba(var(--pad-tint), 0.9);
  color: var(--jamn-text, #fff);
  background:
    linear-gradient(rgba(var(--pad-tint), 0.25), rgba(var(--pad-tint), 0.25)),
    var(--jamn-surface2, #1C1C24);
}

/* ---------- per-pad override badge ---------- */

/* Radial loop/one-shot override marker: ∞ (forced loop) or 1 (forced
 * one-shot) in the pad's top-right corner; hidden when following mode. */
.kit-pad-badge {
  position: absolute;
  top: 5px;
  right: 6px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--jamn-text, #fff);
  display: none;
  pointer-events: none;
}

.kit-pad-badge.is-on {
  display: block;
}

/* "FX" chip: pad carries non-neutral per-pad effects (radial Effects).
 * Bottom-right corner — the name owns the top-left and the loop badge the
 * top-right, and the dark scrim keeps it readable over the waveform. */
.kit-pad-fx {
  position: absolute;
  bottom: 5px;
  right: 6px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.04em;
  padding: 2px 4px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(var(--pad-tint), 0.95);
  display: none;
  pointer-events: none;
}

.kit-pad-fx.is-on {
  display: block;
}

/* ---------- radial pad menu ---------- */

.kit-radial-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  /* Stronger dim + blur: the wheel floats over busy waveforms — at 0.4
   * the buttons read as unrelated circles lost in the pad noise. */
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

.kit-radial {
  position: absolute; /* left/top set by kit.js at the (clamped) cursor */
  --pad-tint: 139, 92, 246;
  width: 0;
  height: 0;
}

/* The pie wheel itself — a single SVG of equal wedges (desktop
 * PadRadialMenu parity). Empty regions carry pointer-events:none so a
 * click outside the ring falls through to the backdrop and dismisses;
 * only the wedge slices below re-enable hit-testing. */
.kit-radial-svg {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(0 12px 48px rgba(0, 0, 0, 0.6));
}

/* One pie slice. The slice captures the pointer; icon/label ride on top
 * but stay inert, so a click ANYWHERE in the wedge fires the action and a
 * hover highlights the whole wedge (not a floating bubble). */
.kit-wedge-slice {
  pointer-events: fill;
  fill: rgba(28, 28, 36, 0.92); /* --jamn-surface2 over the scrim */
  stroke: rgba(255, 255, 255, 0.1); /* the divider line between wedges */
  stroke-width: 1;
  transition: fill 0.1s ease, stroke 0.1s ease;
}

.kit-wedge-icon,
.kit-wedge-label {
  pointer-events: none;
  font-family: inherit;
}

.kit-wedge-icon {
  font-size: 17px;
  font-weight: 600;
  fill: rgba(var(--pad-tint), 0.95); /* tinted icons over the dark ring */
}

/* Labels ALWAYS visible (mobile radial convention). */
.kit-wedge-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.02em;
  fill: var(--jamn-text2, #A1A1AA);
}

/* Hover / press highlights the WEDGE. */
.kit-wedge:hover .kit-wedge-slice {
  fill: rgba(var(--pad-tint), 0.28);
  stroke: rgba(var(--pad-tint), 0.75);
}
.kit-wedge:hover .kit-wedge-label {
  fill: var(--jamn-text, #fff);
}
.kit-wedge:active .kit-wedge-slice {
  fill: rgba(var(--pad-tint), 0.42);
}

/* Active state (e.g. loop engaged, FX present) — a persistent tint. */
.kit-wedge.is-active .kit-wedge-slice {
  fill: rgba(var(--pad-tint), 0.22);
  stroke: rgba(var(--pad-tint), 0.7);
}

.kit-wedge.is-danger .kit-wedge-icon {
  fill: var(--jamn-danger, #EF4444);
}
.kit-wedge.is-danger:hover .kit-wedge-slice {
  fill: rgba(239, 68, 68, 0.28);
  stroke: rgba(239, 68, 68, 0.8);
}

.kit-wedge.is-disabled {
  opacity: 0.35;
}
.kit-wedge.is-disabled .kit-wedge-slice {
  pointer-events: none;
}

/* Solid center hub: pad name + mini waveform, doubles as the cancel zone
 * (desktop's inner circle / identity icon). Size set inline by kit.js. */
.kit-radial-hub {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  appearance: none;
  border: 1px solid var(--jamn-border, #2A2A36);
  background: var(--jamn-surface1, #14141A);
  color: var(--jamn-text2, #A1A1AA);
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    0 6px 28px rgba(0, 0, 0, 0.55);
}
.kit-radial-hub:hover {
  border-color: rgba(var(--pad-tint), 0.6);
}

.kit-radial-hub-wave {
  width: 68%;
  height: 20px;
  display: block;
}

.kit-radial-hub-name {
  font-size: 10px;
  font-weight: 600;
  max-width: 86%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

/* ---------- per-pad FX popover (radial Effects) ---------- */

.kit-fx-pop {
  position: fixed;
  z-index: 1002; /* above the radial backdrop — Effects opens from it */
  --pad-tint: 139, 92, 246;
  width: 264px;
  padding: 10px 12px 8px;
  border: 1px solid var(--jamn-border, #2A2A36);
  border-top: 2px solid rgba(var(--pad-tint), 0.9);
  border-radius: var(--jamn-radius-md, 12px);
  background: var(--jamn-surface1, #14141A);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

.kit-fx-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.kit-fx-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--jamn-text, #fff);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kit-fx-close {
  appearance: none;
  border: none;
  background: none;
  color: var(--jamn-text2, #A1A1AA);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}

.kit-fx-close:hover {
  color: var(--jamn-text, #fff);
}

.kit-fx-row {
  display: grid;
  grid-template-columns: 74px 1fr 52px;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.kit-fx-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--jamn-text2, #A1A1AA);
  white-space: nowrap;
}

.kit-fx-row input[type="range"] {
  width: 100%;
  accent-color: rgb(var(--pad-tint));
}

.kit-fx-val {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--jamn-text, #fff);
}

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

.kit-fx-hint {
  font-size: 10px;
  color: var(--jamn-text2, #A1A1AA);
  opacity: 0.8;
}

.kit-fx-reset {
  appearance: none;
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: 8px;
  background: var(--jamn-surface2, #1C1C24);
  color: var(--jamn-text, #fff);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
}

.kit-fx-reset:hover {
  border-color: rgba(var(--pad-tint), 0.9);
}

/* ---------- toast ---------- */

.kit-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 1001;
  padding: 8px 16px;
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: var(--jamn-radius-md, 12px);
  background: var(--jamn-surface1, #14141A);
  color: var(--jamn-text, #fff);
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  animation: kit-toast-in 0.18s ease-out;
}

/* Action button inside a toast (Delete's Undo). */
.kit-toast .kit-toast-act {
  appearance: none;
  border: none;
  background: none;
  margin-left: 12px;
  padding: 0;
  color: var(--jamn-accent, #8B5CF6);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.kit-toast .kit-toast-act:hover {
  text-decoration: underline;
}

@keyframes kit-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---------- error ---------- */

.kit-error {
  padding: 14px 16px;
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: var(--jamn-radius-lg, 16px);
  background: var(--jamn-surface1, #14141A);
  color: var(--jamn-text2, #A1A1AA);
  font-size: 13px;
}

/* ---------- Remix bar (remix.js, mounted above the kit) ----------
 * Web home of the native Remix sheets. Buttons ride the shared
 * .tab-control-btn look (jam.css) inside a .tab-control-group; the
 * extra classes below only add layout + the busy/active affordances
 * the sheets show per row. */

.remix-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  /* remix-bar mounts in #remix-root (a sibling of .kit-surface, not a
   * descendant), so --kit-w can't cascade here — pin the 16-mode default so
   * it aligns with the grid's common state. */
  max-width: min(980px, 94vw); /* align with .kit-head / .kit-grid */
  margin: 0 auto 10px;
  box-sizing: border-box;
}

.remix-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--jamn-text2, #A1A1AA);
}

.remix-group {
  display: inline-flex;
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: 8px;
  background: var(--jamn-surface1, #14141A);
  overflow: hidden;
}

.remix-btn {
  white-space: nowrap;
  padding: 5px 10px;
}

.remix-btn.is-active {
  color: var(--jamn-bg, #0B0B0F);
  background: var(--jamn-accent, #8B5CF6);
}

/* Busy = quiet pulse, not a spinner — matches the pad "armed" idiom. */
.remix-btn.is-busy {
  color: var(--jamn-text, #fff);
  animation: kit-skeleton 1.2s ease-in-out infinite;
  cursor: progress;
}

.remix-btn:disabled:not(.is-busy) {
  opacity: 0.45;
  cursor: default;
}

.remix-error {
  font-size: 12px;
  color: var(--jamn-danger, #EF4444);
}

/* Re-Drum donor rows expand under the bar on their own line. */
.remix-donors {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.remix-donors .remix-btn {
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: 8px;
  background: var(--jamn-surface1, #14141A);
}

.remix-note {
  font-size: 12px;
  color: var(--jamn-text2, #A1A1AA);
}

/* ---------- "+ Add from another song" (Borrow) ---------- */

/* Toolbar button: accent-outline, matching the chop "Load" chip so it reads
 * as a first-class action in the controls row (not a raw browser widget). */
.kit-borrow-btn {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--jamn-accent, #8B5CF6);
  background: transparent;
  color: var(--jamn-accent, #8B5CF6);
  cursor: pointer;
  white-space: nowrap;
}

.kit-borrow-btn:hover,
.kit-borrow-btn.is-open {
  background: var(--jamn-accent, #8B5CF6);
  color: var(--jamn-text, #fff);
}

/* The popover — house style (mirror of .kit-fx-pop): fixed, accent top rule,
 * clamped on-viewport by kit.js. */
.kit-borrow-pop {
  position: fixed;
  z-index: 1002;
  width: 288px;
  max-width: calc(100vw - 16px);
  padding: 10px 12px 10px;
  border: 1px solid var(--jamn-border, #2A2A36);
  border-top: 2px solid var(--jamn-accent, #8B5CF6);
  border-radius: var(--jamn-radius-md, 12px);
  background: var(--jamn-surface1, #14141A);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

.kit-borrow-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.kit-borrow-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--jamn-text, #fff);
}

.kit-borrow-close {
  appearance: none;
  border: none;
  background: none;
  color: var(--jamn-text2, #A1A1AA);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
}

.kit-borrow-close:hover {
  color: var(--jamn-text, #fff);
}

/* Part selector — the segmented-group shell, so it matches the toolbar. */
.kit-borrow-parts {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--jamn-surface1, #14141A);
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: 8px;
  margin-bottom: 8px;
}

.kit-borrow-part {
  appearance: none;
  flex: 1 1 0;
  border: 0;
  background: transparent;
  color: var(--jamn-text2, #A1A1AA);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.kit-borrow-part.is-on {
  background: var(--jamn-accent, #8B5CF6);
  color: var(--jamn-text, #fff);
}

/* Candidate list. Scrolls if a user has many analyzed songs. */
.kit-borrow-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.kit-borrow-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--jamn-text2, #A1A1AA);
  padding: 6px 2px;
}

/* Small inline spinner for "Finding compatible loops…". */
.kit-borrow-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--jamn-border, #2A2A36);
  border-top-color: var(--jamn-accent, #8B5CF6);
  animation: kit-borrow-spin 0.7s linear infinite;
  flex: 0 0 auto;
}

@keyframes kit-borrow-spin {
  to { transform: rotate(360deg); }
}

/* One donor row — full-width button; name + key/tempo on the left, the
 * Add / Loading… affordance on the right. */
.kit-borrow-cand {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 1px solid var(--jamn-border, #2A2A36);
  border-radius: 8px;
  background: var(--jamn-surface2, #1C1C24);
  color: var(--jamn-text, #fff);
  font: inherit;
  cursor: pointer;
}

.kit-borrow-cand:hover:not(:disabled) {
  border-color: var(--jamn-accent, #8B5CF6);
}

.kit-borrow-cand:disabled {
  opacity: 0.5;
  cursor: default;
}

.kit-borrow-cand.is-busy {
  border-color: var(--jamn-accent, #8B5CF6);
  opacity: 1;
}

.kit-borrow-cand-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kit-borrow-cand-name {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kit-borrow-cand-meta {
  font-size: 11px;
  color: var(--jamn-text2, #A1A1AA);
  font-variant-numeric: tabular-nums;
}

.kit-borrow-cand-act {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--jamn-accent, #8B5CF6);
}

.kit-borrow-cand:disabled .kit-borrow-cand-act {
  color: var(--jamn-text2, #A1A1AA);
}
