/*
 * Prophet-5 slide-out edit panel.
 *
 * Two mount points:
 *   .prophet5-panel--top    → slides DOWN from under the top-bar progress strip,
 *                             edits the song-side Prophet-5 instance.
 *   .prophet5-panel--bottom → slides UP from above the piano-roll keyboard,
 *                             edits the user-side Prophet-5 instance.
 *
 * Both anchors overlay the waterfall (no reflow) so the frosted-glass backdrop
 * has live note streams to soften behind it — top and bottom share the same
 * visual treatment.
 *
 * Both share the same .prophet5-panel base and the same synth control surface
 * (built by buildProphet5ParametersUI). A subtle accent strip differentiates
 * "SONG" (top) from "YOU" (bottom) so a glance confirms which lane you're
 * editing.
 */

:root {
  /* Bottom-panel open height — JS computes the exact value based on the
   * content's natural size and the viewport, then writes it here so the
   * panel hugs the controls with no wasted space. The fallback (280px) is
   * only used briefly before _fitContent runs on first open. */
  --user-instrument-panel-open-height: 280px;
  --prophet5-panel-open-height: var(--user-instrument-panel-open-height, 280px);
  /* Hard ceiling: don't let the panel grow taller than this share of the
   * space between the top progress strip and the piano-roll keyboard. JS
   * reads this when computing the final panel height. */
  --user-instrument-panel-max-share: 0.92;
  /* Scale applied to the parameter surface so the full control set fits the
   * available width without scrolling. JS recomputes this on open and on
   * window resize. */
  --prophet5-fit-scale: 1;
  /* Transforms do not affect flex layout. The fitted synth panels subtract
   * this transformed-away block height so a desktop surface does not grow a
   * scrollbar for controls that are already visibly inside its bounds. */
  --prophet5-fit-block-compensation: 0px;
  --sampler-panel-fit-scale: 1;
}

.prophet5-panel {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 11; /* above piano-roll (10), below modals (2000) */
  background: var(--glass-surface);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  color: var(--text-1, #e8e8ea);
  border-color: var(--border-2, rgba(255, 255, 255, 0.08));
  border-style: solid;
  border-width: 0;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  pointer-events: auto;
  transition: transform 0.25s ease, opacity 0.2s ease;
  will-change: transform;
  max-height: calc(100vh - var(--transport-topbar-height, 60px) - var(--transport-progress-height, 45px) - var(--statusbar-height, 28px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Closed means inert (invariant I6, the same rule the MIDI editor follows).
 *
 * The closed rules below specify `opacity: 0` and a translate-away transform,
 * but they are reached through a transition — and a transition that is
 * restarted or never advances leaves the panel sitting at its open values.
 * Measured on an unmodified build: after closing the song instrument editor
 * the panel stayed `opacity: 1`, identity transform, `pointer-events: auto`,
 * fully covering the arrangement it had just been dismissed from.
 *
 * `visibility` and `pointer-events` are not transitioned here, so they apply
 * the moment the open class comes off and cannot be stranded mid-animation.
 * The trade is that a closed panel disappears rather than sliding away; a
 * dismissed surface that is definitely gone beats one that animates nicely
 * most of the time. */
.prophet5-panel:not(.prophet5-panel--open) {
  visibility: hidden;
  pointer-events: none;
}

/* aria-hidden is written by the panel's own close(); this keeps the visual and
 * assistive states from ever disagreeing if one of them is missed. */
.prophet5-panel[aria-hidden="true"] {
  pointer-events: none;
}

/* ───── Top variant: slides DOWN from under the progress strip ───── */
/* ───── Top variant: the SONG surface ─────
 * The song instrument and its effects rack live at the top of the workspace,
 * directly under the ruler — matching the top-bar (song) / status-bar (user)
 * split the app is built around. While open it takes the arrangement's place
 * rather than sitting beside it, so the two never compete for the same band.
 *
 * The ceiling subtracts the keyboard: that is chrome the panel may never cover,
 * and omitting it is what let the rack run 45–150px into the keys on a short
 * viewport. --transport-topbar-height already tracks the Controls disclosure. */
.prophet5-panel--top {
  top: calc(var(--transport-topbar-height, 60px) + var(--transport-progress-height, 45px));
  max-height: calc(100vh - var(--transport-topbar-height, 60px) - var(--transport-progress-height, 45px) - var(--statusbar-height, 28px) - var(--keyboard-height, 150px));
  height: min(
    var(--prophet5-panel-open-height, var(--user-instrument-panel-open-height, 280px)),
    calc(100vh - var(--transport-topbar-height, 60px) - var(--transport-progress-height, 45px) - var(--statusbar-height, 28px) - var(--keyboard-height, 150px))
  );
  border-bottom-width: 1px;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.2s ease, height 0.25s ease;
}

.prophet5-panel--top.prophet5-panel--open {
  transform: translateY(0);
  opacity: 1;
}

/* ───── Bottom variant: slides UP from above the piano-roll keyboard ─────
 * The panel overlays the bottom of the waterfall so its frosted-glass
 * backdrop has live notes to blur behind it — matching the top variant's
 * treatment. The waterfall keeps its full height; only the keyboard and
 * status bar remain uncovered.
 */
.prophet5-panel--bottom {
  bottom: calc(var(--statusbar-height, 28px) + var(--keyboard-height, 150px));
  border-top-width: 1px;
  border-bottom-width: 1px;
  /* Closed: zero height (collapses, no overlay). Open: var-driven height. */
  height: 0;
  overflow: hidden;
  transition: height 0.25s ease, opacity 0.2s ease;
  opacity: 0;
  /* Suppress the broad drop-shadow on the bottom panel — it would cast over the
   * keyboard, which the user explicitly didn't want. */
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.45);
}

.prophet5-panel--bottom.prophet5-panel--open {
  height: min(
    var(--prophet5-panel-open-height, var(--user-instrument-panel-open-height, 540px)),
    max(
      180px,
      calc(100vh - var(--transport-topbar-height, 60px) - var(--transport-progress-height, 45px) - var(--statusbar-height, 28px) - var(--keyboard-height, 150px))
    )
  );
  opacity: 1;
}

/* ───── Accent strip — labels which lane this panel edits ───── */
.prophet5-panel__accent {
  position: relative;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  /* The lane label has its own top row; mode/reset stay there while velocity
   * gets a dedicated lower row. This prevents header controls colliding in
   * either simple or advanced mode. */
  padding: 4px 0 22px;
  user-select: none;
  flex-shrink: 0;
}

.prophet5-panel__accent-label {
  /* Label stays centered; the reset pill sits absolutely on the right so it
   * doesn't shift the label off-axis. */
  display: inline-block;
}

.prophet5-panel__reset-btn {
  position: absolute;
  top: 5px;
  right: 8px;
  transform: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 9px 3px;
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.12em;
  line-height: 1;
  cursor: pointer;
  opacity: 0.78;
  transition: opacity 120ms ease, background-color 120ms ease;
}

.prophet5-panel__reset-btn:hover,
.prophet5-panel__reset-btn:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}

.prophet5-panel__reset-btn:active {
  background: rgba(255, 255, 255, 0.24);
}

.prophet5-panel__mode-toggle {
  position: absolute;
  top: 4px;
  left: 8px;
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  transform: none;
}

.prophet5-panel__mode-btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 2px 8px 3px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0.72;
}

.prophet5-panel__mode-btn:hover,
.prophet5-panel__mode-btn:focus-visible {
  opacity: 1;
  outline: none;
}

.prophet5-panel__mode-btn.is-active {
  background: rgba(255, 255, 255, 0.16);
  opacity: 1;
}

/* Lane MIDI velocity lives in the shared panel chrome, not in either the
 * Simple or Advanced synth surface. The two native ranges share one rail;
 * their thumbs can meet for an exact fixed velocity. */
.velocity-range-control {
  position: absolute;
  top: 24px;
  left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transform: none;
  font-size: 9px;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.velocity-range-control__label {
  opacity: 0.72;
}

.velocity-range-control__rail {
  position: relative;
  display: block;
  width: 78px;
  height: 12px;
  border-radius: 999px;
  background:
    linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.12) 0 var(--velocity-range-start, 0%),
      currentColor var(--velocity-range-start, 0%) var(--velocity-range-end, 100%),
      rgba(255, 255, 255, 0.12) var(--velocity-range-end, 100%) 100%
    );
  opacity: 0.9;
}

.velocity-range-control__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 12px;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  pointer-events: none;
}

.velocity-range-control__input--min { z-index: 1; }
.velocity-range-control__input--max { z-index: 2; }

/* At a collapsed range the component chooses the thumb that reopens the
 * range. Keep this CSS fallback in sync with its inline z-index assignment. */
.velocity-range-control[data-collapsed-edge="min"] .velocity-range-control__input--min,
.velocity-range-control[data-collapsed-edge="max"] .velocity-range-control__input--max {
  z-index: 3;
}

.velocity-range-control__input::-webkit-slider-runnable-track {
  height: 12px;
  background: transparent;
}

.velocity-range-control__input::-moz-range-track {
  height: 12px;
  background: transparent;
}

.velocity-range-control__input::-webkit-slider-thumb {
  width: 10px;
  height: 10px;
  margin-top: 1px;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
  cursor: ew-resize;
  pointer-events: auto;
}

.velocity-range-control__input::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border: 1px solid rgba(0, 0, 0, 0.55);
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
  cursor: ew-resize;
  pointer-events: auto;
}

.velocity-range-control__input:focus-visible::-webkit-slider-thumb {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.velocity-range-control__input:focus-visible::-moz-range-thumb {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.velocity-range-control__value {
  min-width: 29px;
  color: inherit;
  font: inherit;
  letter-spacing: 0.04em;
  opacity: 0.9;
  text-transform: none;
}

@media (max-width: 420px) {
  .velocity-range-control {
    gap: 4px;
  }

  .velocity-range-control__rail {
    width: 64px;
  }

  .velocity-range-control__value {
    min-width: 25px;
  }

}

.prophet5-panel[data-control-mode="simple"] [data-panel-mode="advanced"] {
  display: none !important;
}

.prophet5-panel--song .prophet5-panel__accent {
  background: linear-gradient(90deg, rgba(96, 165, 250, 0.18), rgba(96, 165, 250, 0.08), rgba(96, 165, 250, 0.18));
  color: #93c5fd;
  border-bottom: 1px solid rgba(96, 165, 250, 0.25);
}

.prophet5-panel--user .prophet5-panel__accent {
  background: linear-gradient(90deg, rgba(251, 146, 60, 0.18), rgba(251, 146, 60, 0.08), rgba(251, 146, 60, 0.18));
  color: #fdba74;
  border-top: 1px solid rgba(251, 146, 60, 0.25);
}

.dx7-panel--song .prophet5-panel__accent {
  background: linear-gradient(90deg, rgba(45, 212, 191, 0.18), rgba(45, 212, 191, 0.08), rgba(45, 212, 191, 0.18));
  color: #5eead4;
  border-bottom: 1px solid rgba(45, 212, 191, 0.28);
}

.dx7-panel--user .prophet5-panel__accent {
  background: linear-gradient(90deg, rgba(52, 211, 153, 0.18), rgba(52, 211, 153, 0.08), rgba(52, 211, 153, 0.18));
  color: #86efac;
  border-top: 1px solid rgba(52, 211, 153, 0.28);
}

/* Bottom-anchored panel puts its accent at the top edge for visual symmetry
 * with the top-anchored panel's bottom-edge accent. */
.prophet5-panel--bottom .prophet5-panel__accent {
  order: -1;
}

/* ───── Control surface — hosts buildProphet5ParametersUI's output ─────
 * On normal desktop heights, content is scaled (via transform) so every knob
 * and toggle is visible without a nested scrollbar. Narrow and short layouts
 * re-enable scrolling below, where it is needed to keep controls reachable.
 */
.prophet5-panel__surface {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  padding: 8px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  /* `safe` matters on short viewports: plain `center` lets overflowing content
   * extend above the scroll origin, where no amount of scrolling can reach it
   * (measured 86px of controls permanently cropped at 620px height). With
   * `safe`, the surface centers when the controls fit and top-aligns — fully
   * scrollable — when they don't. The bare `center` line is the fallback for
   * engines that don't parse `safe`. */
  justify-content: center;
  justify-content: safe center;
  gap: 14px;
  scrollbar-gutter: auto;
}

/* ───── Piano faceplate ──────────────────────────────────────────────────
 * The piano is a distinct instrument, but its editor now shares the same
 * collar-lit rotary language as DX7, Prophet-5, and the lane-effects rack.
 * The faceplate is deliberately lacquer-black rather than wood-grained: it
 * should feel like the polished fallboard of a concert grand with electronics
 * thoughtfully fitted into it, not like a generic dark settings card. */
.piano-panel {
  --prophet5-panel-open-height: 540px;
  background: #050606;
  border-color: rgba(244, 189, 72, 0.28);
  box-shadow: 0 12px 44px rgba(0, 0, 0, 0.7);
}

.piano-panel__accent {
  color: #f7ca66;
}

.piano-panel--song .piano-panel__accent {
  background: linear-gradient(90deg, rgba(245, 199, 94, 0.2), rgba(92, 69, 21, 0.2), rgba(245, 199, 94, 0.2));
  border-bottom-color: rgba(244, 189, 72, 0.42);
}

.piano-panel--user .piano-panel__accent {
  background: linear-gradient(90deg, rgba(245, 199, 94, 0.24), rgba(92, 69, 21, 0.22), rgba(245, 199, 94, 0.24));
  border-top-color: rgba(244, 189, 72, 0.42);
}

.piano-panel__surface {
  align-items: stretch;
  /* The piano faceplate is not scaled. When a short viewport caps its fitted
   * panel height, start the scroll range at the first control so both the
   * upper piano controls and the lower effects rack remain reachable. */
  justify-content: flex-start;
  overflow-y: hidden;
  padding: 10px 12px 12px;
  background:
    linear-gradient(108deg, rgba(255, 255, 255, 0.035) 0 14%, transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 32%),
    #070808;
}

/* Physical Piano intentionally remains unscaled. Only a measured height cap
 * restores its outer scroll path, so ordinary desktop panels stay clean. */
.piano-panel[data-fit-clamped="true"] .piano-panel__surface {
  overflow-y: auto;
  /* Reserve the width only when measured content really needs scrolling. */
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.piano-panel__content.instrument-lane-stack__instrument {
  /* The P5 faceplate is the canonical shared physical geometry. Keep the
   * piano's local selectors free of the generic legacy .knob styles loaded
   * later in prophet5.css, so the measured cap/collar never drifts. */
  --instrument-knob-cap: 44px;
  --instrument-knob-collar-inset: -15px;
  --instrument-knob-pointer-height: 16px;
  --knob-led: #f3bd45;
  /* Match the P5/DX7 collar intensity; only the piano's gold hue differs. */
  --knob-led-dim: rgba(243, 189, 69, 0.18);
  --knob-led-glow: rgba(243, 189, 69, 0.5);
  position: relative;
  display: grid;
  align-self: center;
  gap: 8px;
  width: min(680px, 100%);
  min-width: 0;
  overflow: hidden;
  padding: 11px 14px 12px;
  color: #f8f0d9;
  border: 1px solid rgba(248, 218, 133, 0.32);
  border-radius: 7px;
  background:
    radial-gradient(ellipse at 34% -16%, rgba(255, 255, 255, 0.18), transparent 42%),
    linear-gradient(115deg, rgba(255, 255, 255, 0.055), transparent 17% 78%, rgba(255, 255, 255, 0.025)),
    linear-gradient(180deg, #222421 0, #0d0e0d 22%, #040505 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -26px 44px rgba(0, 0, 0, 0.86),
    0 14px 28px rgba(0, 0, 0, 0.45);
}

.piano-panel__content::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 4px);
}

.piano-panel__intro,
.piano-panel__faceplate,
.piano-panel__note {
  position: relative;
  z-index: 1;
}

.piano-panel__intro {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 10px;
  padding: 0 2px 8px;
  border-bottom: 1px solid rgba(247, 202, 102, 0.24);
  color: #f8d276;
  font: 700 12px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.18em;
}

.piano-panel__model {
  color: rgba(248, 240, 217, 0.56);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.piano-panel__statuses {
  display: inline-flex;
  justify-content: flex-end;
  gap: 8px;
  color: rgba(248, 240, 217, 0.64);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: none;
}

.piano-panel__intro [data-piano-core-status][data-state="error"],
.piano-panel__intro [data-piano-action-status][data-state="error"] {
  color: #ff9d87;
}

.piano-panel__faceplate {
  padding: 10px 14px 12px;
  border: 1px solid rgba(255, 229, 151, 0.22);
  border-radius: 3px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.055), transparent 26%),
    linear-gradient(180deg, #171816 0, #080909 100%);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), inset 0 -16px 28px rgba(0, 0, 0, 0.56);
}

.piano-panel__section-label {
  margin: 0 0 11px;
  color: rgba(248, 210, 118, 0.88);
  font: 600 9px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.19em;
  text-align: center;
  text-transform: uppercase;
}

.piano-panel__grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 16px 14px;
  align-items: start;
}

.piano-panel__control {
  display: grid;
  justify-items: center;
  min-width: 0;
}

.piano-panel__knob-control {
  grid-template-areas:
    'label'
    'knob'
    'value';
  grid-template-rows: 13px 76px 12px;
  gap: 2px;
}

.piano-panel__knob {
  grid-area: knob;
  position: relative;
  box-sizing: border-box;
  /* Exact primary Prophet-5 / DX7 cap-to-collar geometry. */
  width: var(--instrument-knob-cap);
  height: var(--instrument-knob-cap);
  margin: 16px;
  padding: 0;
  overflow: visible;
  appearance: none;
  border: 1px solid #060707;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #2c2f37, #16181d 65%, #101216);
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.16), 0 3px 7px rgba(0, 0, 0, 0.55);
  cursor: ns-resize;
  touch-action: none;
  transition: none;
}

.piano-panel__knob:hover {
  border-color: #1c2027;
}

.piano-panel__knob:focus-visible {
  outline: 2px solid #ffe19a;
  outline-offset: 5px;
}

.piano-panel__knob::before {
  content: '';
  position: absolute;
  top: auto;
  bottom: 50%;
  left: calc(50% - 1.5px);
  width: 3px;
  height: var(--instrument-knob-pointer-height);
  border-radius: 2px;
  background: #dde3ec;
  transform: rotate(var(--rotation, -135deg));
  transform-origin: 50% 100%;
  transition: transform 0.1s ease;
}

.piano-panel__knob .knob-collar {
  inset: var(--instrument-knob-collar-inset);
}

.piano-panel__control-label {
  grid-area: label;
  align-self: end;
  max-width: 120px;
  color: #f1d48e;
  font: 700 8px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
}

.piano-panel__control-value {
  grid-area: value;
  min-width: 38px;
  color: rgba(255, 223, 133, 0.82);
  font: 500 9px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.piano-panel__help {
  margin: 0;
  color: rgba(232, 224, 200, 0.58);
  font: 400 9px/1.3 Inter, ui-sans-serif, system-ui, sans-serif;
  text-align: center;
}

.piano-panel__select-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(247, 202, 102, 0.17);
}

.piano-panel__select-control {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 5px 9px;
  align-items: center;
  color: #f1d48e;
  font: 600 9px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.piano-panel__select-control .ui-select {
  min-width: 0;
  color: #f6e8bf;
  border-color: rgba(247, 202, 102, 0.38);
  background-color: rgba(0, 0, 0, 0.46);
}

.piano-panel__select-control .piano-panel__help {
  grid-column: 1 / -1;
  text-align: left;
}

.piano-panel__note {
  margin: 0 3px;
  color: rgba(232, 224, 200, 0.46);
  font: 500 8px/1.25 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.025em;
  text-align: center;
}

.piano-panel__note a { color: #f3c765; }

/* ───── Desktop development faceplate ─────────────────────────────────────
 * The physical-model controls are intentionally exposed while the instrument
 * is under development. On desktop they should read as one compact workbench,
 * not a narrow settings card stranded in the middle of a wide editor. Keep
 * every control present; only rearrange the existing faceplate into a wide
 * preset column + horizontal control span. Narrow screens retain the simpler
 * stacked composition below.
 */
@media screen and (min-width: 1200px) {
  .piano-panel__content.instrument-lane-stack__instrument {
    width: min(1720px, 100%);
    gap: 6px;
  }

  .piano-panel__faceplate {
    display: grid;
    grid-template-areas:
      'preset section'
      'preset controls'
      'preset advanced';
    grid-template-columns: minmax(178px, 0.9fr) minmax(0, 5fr);
    column-gap: 20px;
    align-items: start;
  }

  .piano-panel__preset-control {
    grid-area: preset;
    grid-template-columns: 1fr;
    align-content: start;
    align-self: stretch;
    gap: 8px;
    padding-right: 18px;
    border-right: 1px solid rgba(247, 202, 102, 0.17);
  }

  .piano-panel__section-label {
    grid-area: section;
    margin: 2px 0 8px;
    text-align: left;
  }

  .piano-panel__grid {
    grid-area: controls;
    grid-template-columns: repeat(10, minmax(72px, 1fr));
    gap: 8px 10px;
  }

  .piano-panel[data-control-mode="simple"] .piano-panel__grid {
    grid-template-columns: repeat(5, minmax(72px, 1fr));
  }

  .piano-panel__knob-control {
    grid-template-rows: 13px 76px 12px;
  }

  .piano-panel__select-grid {
    grid-area: advanced;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 8px;
    padding-top: 8px;
  }
}

@media screen and (max-width: 700px) {
  .piano-panel { --prophet5-panel-open-height: 580px; }
  .piano-panel__grid { grid-template-columns: repeat(2, minmax(112px, 1fr)); }
  .piano-panel__knob-control { grid-template-rows: 13px 76px 12px; }
  .piano-panel__intro { grid-template-columns: auto 1fr; }
  .piano-panel__statuses { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 440px) {
  .piano-panel__content { padding: 11px 9px 13px; }
  .piano-panel__select-grid { grid-template-columns: 1fr; }
  .piano-panel__model { display: none; }
  .piano-panel__knob-control { min-width: 0; }
}

.instrument-lane-stack__instrument {
  display: flex;
  flex: 0 0 auto;
  width: 100%;
  justify-content: center;
  min-width: 0;
}

.prophet5-panel__surface > .instrument-lane-stack__instrument > .parameters-panel {
  transform: scale(var(--prophet5-fit-scale, 1));
  transform-origin: top center;
  margin-bottom: calc(-1 * var(--prophet5-fit-block-compensation, 0px));
}

.prophet5-panel__surface > .instrument-lane-stack__instrument > .parameters-panel--faceplate {
  width: 2710px;
  height: 838px;
  max-width: none;
}

/* ───── Prophet-5 hardware faceplate ──────────────────────────────────── */
.prophet5-panel__surface .p5-faceplate {
  position: relative;
  display: block;
  flex: 0 0 auto;
  overflow: hidden;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at 55% -30%, rgba(255, 255, 255, 0.11), transparent 30%),
    linear-gradient(180deg, #252625 0, #111 62px, #090909 692px, #070707 693px, #111 100%);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    inset 0 -22px 42px rgba(0, 0, 0, 0.88),
    0 24px 70px rgba(0, 0, 0, 0.42);
}

.prophet5-panel__surface .p5-faceplate::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.17;
  background-image:
    linear-gradient(90deg, rgba(255, 255, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  background-size: 5px 7px, 9px 5px;
  mix-blend-mode: screen;
}

.prophet5-panel__surface .p5-section {
  position: absolute;
  border: 4px solid rgba(238, 246, 246, 0.96);
  border-radius: 18px;
  background: transparent;
  padding: 0;
  box-shadow:
    0 0 2px rgba(255, 255, 255, 0.65),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.prophet5-panel__surface .p5-section-title {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0 10px;
  border: 0;
  background: #101111;
  color: rgba(246, 249, 247, 0.96);
  font-size: 18px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.09em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

.prophet5-panel__surface .p5-logo {
  position: absolute;
  left: 2050px;
  top: 126px;
  color: #f7f8f2;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 108px;
  line-height: 1;
  font-style: italic;
  font-weight: 900;
  letter-spacing: -7px;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.45);
}

.prophet5-panel__surface .p5-control {
  position: absolute;
  width: 92px;
  height: 122px;
  align-items: center;
  gap: 0;
  text-align: center;
}

.prophet5-panel__surface .p5-control--toggle,
.prophet5-panel__surface .p5-control--display-button {
  width: 66px;
  height: 88px;
}

.prophet5-panel__surface .p5-knob-scale .p5-knob-number {
  position: absolute;
  color: rgba(246, 249, 247, 0.96);
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  transform: translate(-50%, -50%);
}

.prophet5-panel__surface .p5-knob-scale .p5-knob-tick {
  position: absolute;
  width: 2px;
  height: 7px;
  border-radius: 1px;
  background: rgba(238, 246, 246, 0.9);
  box-shadow: 0 0 1px rgba(255, 255, 255, 0.45);
  transform: translate(-50%, -50%) rotate(var(--p5-tick-rotation));
}

.prophet5-panel__surface .p5-knob {
  position: absolute;
  /* cap ≈60% of the full knob unit (cap + collar), matching the FX knobs;
     offsets keep the cap centered where the 56px cap used to sit */
  left: 24px;
  top: 29px;
  width: 44px;
  height: 44px;
  /* unified LED-collar face (approved design); collar child extends past the
     knob bounds, so the old overflow clip is lifted */
  overflow: visible;
  border: 1px solid #090a0d;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #2c2f37, #16181d 65%, #101216);
  box-shadow:
    inset 0 1px 2px rgba(255, 255, 255, 0.16),
    0 3px 7px rgba(0, 0, 0, 0.55);
  transition: none;
}

/* Prophet-5 collar accent: rocker red. The printed dial scale is replaced by
   the LED collar. */
.prophet5-panel__surface {
  --knob-led: #ff4b50;
  --knob-led-dim: rgba(255, 60, 66, 0.18);
  --knob-led-glow: rgba(255, 75, 80, 0.5);
}
.prophet5-panel__surface .p5-knob-scale { display: none; }
/* collar standoff scales with the cap so the LED ring floats clearly outside
   the knob's circumference (matching the FX-rack knob proportions) */
.prophet5-panel__surface .p5-knob .knob-collar { inset: -15px; }
.prophet5-panel__surface .p5-knob--large .knob-collar { inset: -19px; }

.prophet5-panel__surface .p5-knob:hover {
  border-color: #191b19;
  transform: none;
}

.prophet5-panel__surface .p5-knob::before {
  top: auto;
  bottom: 50%;
  left: calc(50% - 1.5px);
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: #dde3ec;
  transform: rotate(var(--rotation, 0deg));
  transform-origin: 50% 100%;
  transition: transform 0.1s ease;
}

.prophet5-panel__surface .p5-knob--large {
  left: 17px;
  top: 19px;
  width: 58px;
  height: 58px;
}

.prophet5-panel__surface .p5-knob--large::before {
  height: 22px;
}

.prophet5-panel__surface .p5-toggle {
  position: absolute;
  left: 16px;
  top: 23px;
  width: 34px;
  height: 34px;
  border: 3px solid rgba(70, 8, 10, 0.92);
  border-radius: 6px;
  background:
    linear-gradient(90deg, transparent 46%, rgba(255, 255, 255, 0.24) 47% 53%, transparent 54%),
    linear-gradient(0deg, transparent 46%, rgba(255, 255, 255, 0.18) 47% 53%, transparent 54%),
    radial-gradient(circle at 45% 36%, #ff8586 0, #ff3037 42%, #821016 100%);
  box-shadow:
    0 0 16px rgba(255, 48, 55, 0.84),
    inset 0 0 8px rgba(255, 255, 255, 0.38);
  transition: none;
}

.prophet5-panel__surface .p5-toggle:hover {
  border-color: rgba(120, 20, 22, 0.95);
  transform: none;
}

.prophet5-panel__surface .p5-toggle::before {
  display: none;
}

.prophet5-panel__surface .p5-toggle.on {
  background:
    linear-gradient(90deg, transparent 46%, rgba(255, 255, 255, 0.3) 47% 53%, transparent 54%),
    linear-gradient(0deg, transparent 46%, rgba(255, 255, 255, 0.22) 47% 53%, transparent 54%),
    radial-gradient(circle at 45% 36%, #ffc2c2 0, #ff4b50 42%, #a81219 100%);
  border-color: rgba(110, 20, 22, 0.95);
  box-shadow:
    0 0 22px rgba(255, 68, 74, 0.95),
    inset 0 0 9px rgba(255, 255, 255, 0.46);
}

.prophet5-panel__surface .p5-toggle--dark {
  left: 14px;
  top: 19px;
  width: 38px;
  height: 46px;
  border-color: #161616;
  border-radius: 4px;
  background: linear-gradient(180deg, #444, #161616);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.16),
    0 4px 8px rgba(0, 0, 0, 0.72);
}

.prophet5-panel__surface .p5-toggle--dark.on {
  background: linear-gradient(180deg, #575757, #1e1e1e);
  border-color: #252525;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.2),
    0 0 10px rgba(255, 255, 255, 0.18),
    0 4px 8px rgba(0, 0, 0, 0.72);
}

/* The Rev4-style velocity route is a four-position control, not a binary
 * switch. Keep its selected route inside the existing faceplate button so
 * the original GLOBAL layout remains intact while the LEDs show destinations.
 */
.prophet5-panel__surface .p5-control--velocityResponse .p5-toggle--display::after {
  content: attr(data-mode-label);
  position: absolute;
  left: 50%;
  bottom: 5px;
  min-width: max-content;
  transform: translateX(-50%);
  color: rgba(232, 236, 233, 0.92);
  font-size: 7px;
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.95);
  white-space: nowrap;
  pointer-events: none;
}

.prophet5-panel__surface .p5-control--velocityResponse .p5-toggle--display[data-current-mode="0"]::after {
  color: rgba(166, 172, 169, 0.92);
}

.prophet5-panel__surface .p5-control-label {
  position: absolute;
  left: 50%;
  right: auto;
  top: 99px;
  width: 116px;
  max-width: none;
  color: rgba(246, 249, 247, 0.96);
  font-size: 12px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: 0.015em;
  text-align: center;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.9);
  text-transform: uppercase;
  transform: translateX(-50%);
}

.prophet5-panel__surface .p5-control--toggle .p5-control-label,
.prophet5-panel__surface .p5-control--display-button .p5-control-label {
  top: 73px;
  left: 50%;
  right: auto;
  width: 86px;
  font-size: 11px;
}

.prophet5-panel__surface .p5-control--filterEnvAmount .p5-control-label {
  width: 140px;
}

.prophet5-panel__surface .p5-control-value {
  position: absolute;
  left: 50%;
  top: 117px;
  min-height: 0;
  transform: translateX(-50%);
  color: transparent;
  font-size: 0;
  pointer-events: none;
}

.prophet5-panel__surface .p5-faceplate > .p5-control .p5-control-value,
.prophet5-panel__surface .p5-section .p5-control-value {
  color: transparent !important;
  font-size: 0 !important;
}

.prophet5-panel__surface .p5-control--toggle .p5-control-value {
  top: 90px;
}

.prophet5-panel__surface .p5-caption {
  position: absolute;
  color: rgba(246, 249, 247, 0.96);
  font-size: 12px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.prophet5-panel__surface .p5-caption--small {
  font-size: 10px;
}

.prophet5-panel__surface .p5-rule {
  position: absolute;
  height: 3px;
  background: rgba(238, 246, 246, 0.96);
}

.prophet5-panel__surface .p5-group-label {
  position: absolute;
  height: 14px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.prophet5-panel__surface .p5-group-label .p5-rule {
  position: static;
  flex: 1 1 auto;
  width: auto !important;
  min-width: 12px;
}

.prophet5-panel__surface .p5-group-label .p5-group-label__caption {
  position: static;
  flex: 0 0 auto;
  transform: none;
}

.prophet5-panel__surface .p5-led {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffdf72 0 24%, #ff9d24 50%, rgba(255, 157, 36, 0) 78%);
  box-shadow: 0 0 12px rgba(255, 157, 36, 0.95);
}

/* The Rev4-style VELOCITY switch owns its FILT and AMP indicators. Other
   faceplate LEDs remain static hardware detail. */
.prophet5-panel__surface .p5-led--controlled {
  background: radial-gradient(circle, rgba(255, 223, 114, 0.14) 0 24%, rgba(255, 157, 36, 0.16) 50%, rgba(255, 157, 36, 0) 78%);
  box-shadow: 0 0 4px rgba(255, 157, 36, 0.18);
}

.prophet5-panel__surface .p5-led--controlled.on {
  background: radial-gradient(circle, #ffdf72 0 24%, #ff9d24 50%, rgba(255, 157, 36, 0) 78%);
  box-shadow: 0 0 12px rgba(255, 157, 36, 0.95);
}

.prophet5-panel__surface .p5-secondary-rack {
  position: absolute;
  left: 26px;
  right: 26px;
  top: 680px;
  height: 144px;
  display: grid;
  /* Columns track the actual module count: in-app the Effects module is
     suppressed (shared lane rack instead), so no stranded empty third slot. */
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  align-items: stretch;
  gap: 14px;
  padding: 0;
  overflow: hidden;
}

.prophet5-panel__surface .p5-secondary-rack .prophet-section {
  min-width: 0;
  min-height: 0;
  height: 100%;
  padding: 9px 12px 12px;
  border: 2px solid rgba(238, 246, 246, 0.72);
  border-radius: 10px;
  background:
    radial-gradient(circle at 20% -20%, rgba(255, 255, 255, 0.08), transparent 36%),
    linear-gradient(180deg, rgba(35, 36, 35, 0.92), rgba(12, 12, 12, 0.96));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -8px 18px rgba(0, 0, 0, 0.55);
}

.prophet5-panel__surface .p5-secondary-rack .prophet-section h3 {
  position: relative;
  z-index: 2;
  /* clearance below the divider so the LED collars never touch it */
  margin: 0 0 14px;
  padding: 0 0 4px;
  border-bottom: 1px solid rgba(238, 246, 246, 0.34);
  color: rgba(246, 249, 247, 0.96);
  font-size: 14px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.prophet5-panel__surface .p5-rack-grid,
.prophet5-panel__surface .p5-effects-panel {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
  min-width: 0;
}

.prophet5-panel__surface .p5-effects-panel {
  display: grid;
  grid-template-columns: 370px 150px minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
}

.prophet5-panel__surface .p5-fx-group {
  min-width: 0;
  padding: 0 8px;
  border-left: 1px solid rgba(238, 246, 246, 0.18);
}

.prophet5-panel__surface .p5-fx-group:first-child {
  border-left: 0;
}

.prophet5-panel__surface .p5-fx-group h4 {
  margin: 0 0 4px;
  color: rgba(246, 249, 247, 0.9);
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.prophet5-panel__surface .p5-secondary-rack .control-container {
  /* A 40px cap has a 62px LED collar. Reserve that full footprint so collars
   * remain inside the lower-rack section instead of colliding or clipping. */
  flex: 0 0 70px;
  width: 70px;
  min-width: 70px;
  gap: 3px;
}

.prophet5-panel__surface .p5-secondary-rack .compact-knob,
.prophet5-panel__surface .p5-secondary-rack .knob,
.prophet5-panel__surface .p5-secondary-rack .p5-fx-knob {
  position: relative;
  overflow: visible;
  width: 40px;
  height: 40px;
  border-width: 2px;
  background: radial-gradient(circle at 34% 28%, #626362, #242524 38%, #0b0b0b 100%);
}

.prophet5-panel__surface .p5-secondary-rack .compact-knob::before,
.prophet5-panel__surface .p5-secondary-rack .knob::before,
.prophet5-panel__surface .p5-secondary-rack .p5-fx-knob::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 3px;
  width: 3px;
  height: 18px;
  border-radius: 2px;
  background: #f8fbf8;
  transform: translateX(-50%) rotate(var(--rotation, 0deg));
  transform-origin: 50% 17px;
}

.prophet5-panel__surface .p5-secondary-rack .p5-fx-knob {
  cursor: ns-resize;
}

.prophet5-panel__surface .p5-secondary-rack .p5-fx-knob:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.9);
  outline-offset: 2px;
}

.prophet5-panel__surface .p5-secondary-rack .compact-toggle,
.prophet5-panel__surface .p5-secondary-rack .toggle {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(70, 8, 10, 0.92);
  border-radius: 6px;
  background:
    linear-gradient(90deg, transparent 46%, rgba(255, 255, 255, 0.18) 47% 53%, transparent 54%),
    linear-gradient(0deg, transparent 46%, rgba(255, 255, 255, 0.12) 47% 53%, transparent 54%),
    radial-gradient(circle at 45% 36%, #ff6e70 0, #d92a31 44%, #6e0e13 100%);
  box-shadow: 0 0 9px rgba(255, 48, 55, 0.52), inset 0 0 6px rgba(255, 255, 255, 0.22);
}

.prophet5-panel__surface .p5-secondary-rack .compact-toggle::before,
.prophet5-panel__surface .p5-secondary-rack .toggle::before {
  display: none;
}

.prophet5-panel__surface .p5-secondary-rack .compact-toggle.on,
.prophet5-panel__surface .p5-secondary-rack .toggle.on {
  background:
    linear-gradient(90deg, transparent 46%, rgba(255, 255, 255, 0.24) 47% 53%, transparent 54%),
    linear-gradient(0deg, transparent 46%, rgba(255, 255, 255, 0.18) 47% 53%, transparent 54%),
    radial-gradient(circle at 45% 36%, #ff9a9b 0, #f34046 44%, #981217 100%);
  box-shadow: 0 0 14px rgba(255, 65, 70, 0.78), inset 0 0 7px rgba(255, 255, 255, 0.32);
}

.prophet5-panel__surface .p5-secondary-rack .control-label {
  max-width: 70px;
  color: rgba(246, 249, 247, 0.9);
  font-size: 10.5px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.prophet5-panel__surface .p5-secondary-rack .control-value {
  min-height: 10px;
  color: rgba(255, 255, 255, 0.48);
  font-size: 9.5px;
  line-height: 1;
}

.prophet5-panel__surface .p5-secondary-rack .delay-grid,
.prophet5-panel__surface .p5-secondary-rack .filter-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  /* Visible collar arcs extend above each cap; reserve a full row gap when
   * compact controls wrap so the next row cannot paint over its readout. */
  gap: 12px 10px;
}

.prophet5-panel__surface .p5-secondary-rack .lfo-switches {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.prophet5-panel__surface .p5-secondary-rack .chorus-btn {
  min-width: 42px;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 10.5px;
}

.prophet5-panel__surface .p5-secondary-rack .control-container input[type="range"] {
  width: 58px;
  height: 7px;
}

.prophet5-panel__surface .p5-secondary-rack .control-container select {
  max-width: 70px;
  height: 20px;
  font-size: 9.5px;
  padding: 1px 3px;
}

.prophet5-panel[data-control-mode="simple"] .prophet5-panel__surface {
  /* Keep the normal desktop no-scroll contract in Simple mode too. The
   * constrained-layout media queries below are the only place this surface
   * becomes scrollable. */
  overflow-y: hidden;
  align-items: center;
  padding: 10px 12px;
}

.prophet5-panel[data-control-mode="simple"] .prophet5-panel__surface > .instrument-lane-stack__instrument > .parameters-panel--faceplate {
  width: min(100%, 1080px);
  height: auto;
}

.prophet5-panel[data-control-mode="simple"] .p5-faceplate {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  overflow: visible;
  padding: 14px;
  background:
    radial-gradient(circle at 50% -24%, rgba(255, 255, 255, 0.1), transparent 30%),
    linear-gradient(180deg, #242524 0, #0b0b0b 100%);
}

.prophet5-panel[data-control-mode="simple"] .p5-faceplate::before {
  opacity: 0.08;
}

.prophet5-panel[data-control-mode="simple"] .p5-section,
.prophet5-panel[data-control-mode="simple"] .p5-secondary-rack {
  position: static;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  width: auto !important;
  height: auto !important;
}

.prophet5-panel[data-control-mode="simple"] .p5-section {
  display: flex;
  flex: 0 1 420px;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 14px;
  min-height: 0;
  padding: 14px;
  border-width: 2px;
  border-radius: 10px;
}

.prophet5-panel[data-control-mode="simple"] .p5-section-title {
  position: static;
  flex: 0 0 100%;
  transform: none;
  /* clearance below the divider so the LED collars never touch it */
  margin: 0 0 12px;
  padding: 0 0 8px;
  border-bottom: 1px solid rgba(238, 246, 246, 0.34);
  background: transparent;
  font-size: 14px;
}

.prophet5-panel[data-control-mode="simple"] .p5-control {
  position: relative;
  left: auto !important;
  top: auto !important;
  width: 76px;
  height: auto;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.prophet5-panel[data-control-mode="simple"] .p5-knob-scale {
  display: none;
}

.prophet5-panel[data-control-mode="simple"] .p5-knob {
  position: relative;
  left: auto;
  top: auto;
  margin: 0 auto;
}

.prophet5-panel[data-control-mode="simple"] .p5-control-label {
  position: static;
  left: auto;
  right: auto;
  width: auto;
  margin-top: 8px;
  font-size: 10.5px;
  line-height: 1.05;
  transform: none;
}

.prophet5-panel[data-control-mode="simple"] .p5-control-value {
  position: static;
  min-height: 10px;
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.48) !important;
  font-size: 9px !important;
  line-height: 1;
  transform: none;
}

.prophet5-panel[data-control-mode="simple"] .p5-secondary-rack {
  flex: 1 1 520px;
  display: block;
  overflow: visible;
}

.prophet5-panel[data-control-mode="simple"] .p5-secondary-rack .p5-rack-module--effects {
  height: auto;
}

.prophet5-panel[data-control-mode="simple"] .p5-secondary-rack .prophet-section {
  height: auto;
}

.prophet5-panel[data-control-mode="simple"] .p5-effects-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  overflow: visible;
}

.prophet5-panel[data-control-mode="simple"] .p5-fx-group {
  flex: 0 1 auto;
  padding: 0 10px;
}

@media (max-width: 700px) {
  .prophet5-panel {
    overflow: hidden;
  }

  .prophet5-panel__surface {
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: 6px;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }

  /* The Simple selector is intentionally more specific on desktop. Match that
   * specificity here so narrow layouts always retain a reachable scroll path. */
  .prophet5-panel[data-control-mode="simple"] .prophet5-panel__surface,
  .piano-panel__surface {
    overflow-y: auto;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }

  .prophet5-panel__surface > .instrument-lane-stack__instrument > .parameters-panel--faceplate {
    width: calc(100vw - 24px);
    height: auto;
    min-height: 0;
  }

  .prophet5-panel__surface .p5-faceplate {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: visible;
    padding: 14px 10px 12px;
    background:
      radial-gradient(circle at 50% -16%, rgba(255, 255, 255, 0.1), transparent 32%),
      linear-gradient(180deg, #242524 0, #0b0b0b 100%);
  }

  .prophet5-panel__surface .p5-faceplate::before {
    opacity: 0.1;
  }

  .prophet5-panel__surface .p5-logo {
    position: static;
    order: -1;
    margin: 0 0 6px;
    font-size: 50px;
    letter-spacing: -4px;
    text-align: center;
  }

  .prophet5-panel__surface .p5-section,
  .prophet5-panel__surface .p5-secondary-rack,
  .prophet5-panel__surface .p5-control,
  .prophet5-panel__surface .p5-caption,
  .prophet5-panel__surface .p5-rule,
  .prophet5-panel__surface .p5-led {
    left: auto !important;
    right: auto !important;
    top: auto !important;
  }

  .prophet5-panel__surface .p5-section {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: center;
    gap: 14px 8px;
    width: auto !important;
    height: auto !important;
    min-height: 0;
    padding: 30px 12px 12px;
    border-width: 2px;
    border-radius: 10px;
  }

  .prophet5-panel__surface .p5-section-title {
    top: 8px;
    font-size: 13px;
    background: #0d0d0d;
  }

  .prophet5-panel__surface .p5-control {
    position: relative;
    width: 78px;
    height: 104px;
    flex: 0 0 78px;
  }

  .prophet5-panel__surface .p5-control--toggle,
  .prophet5-panel__surface .p5-control--display-button {
    width: 66px;
    height: 86px;
    flex-basis: 66px;
  }

  .prophet5-panel__surface .p5-control--large {
    width: 88px;
    flex-basis: 88px;
  }

  .prophet5-panel__surface .p5-faceplate > .p5-control--vintage {
    align-self: center;
    flex: 0 0 78px;
    margin-top: -4px;
  }

  .prophet5-panel__surface .p5-caption,
  .prophet5-panel__surface .p5-rule,
  .prophet5-panel__surface .p5-led {
    display: none;
  }

  .prophet5-panel__surface .p5-group-label {
    display: none;
  }

  .prophet5-panel__surface .p5-control-label:empty::before {
    content: attr(data-mobile-label);
  }

  .prophet5-panel__surface .p5-control-label {
    left: -8px;
    right: -8px;
    width: auto;
    font-size: 10px;
    line-height: 1;
    transform: none;
  }

  .prophet5-panel__surface .p5-control--toggle .p5-control-label,
  .prophet5-panel__surface .p5-control--display-button .p5-control-label {
    left: -8px;
    right: -8px;
    width: auto;
    font-size: 10px;
    transform: none;
  }

  .prophet5-panel__surface .p5-control-value {
    color: rgba(255, 255, 255, 0.5);
    font-size: 9px;
    line-height: 1;
  }

  .prophet5-panel__surface .p5-control--toggle .p5-control-value {
    top: 86px;
  }

  .prophet5-panel__surface .p5-secondary-rack {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
    gap: 10px;
    overflow: visible;
  }

  .prophet5-panel__surface .p5-secondary-rack .prophet-section {
    height: auto;
    min-height: 130px;
  }

  .prophet5-panel__surface .p5-secondary-rack .p5-rack-module--effects {
    grid-column: 1 / -1;
  }

  .prophet5-panel__surface .p5-effects-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    overflow: visible;
  }

  .prophet5-panel__surface .p5-effects-panel .prophet-section,
  .prophet5-panel__surface .p5-effects-panel .prophet-section[data-fx="chorus"],
  .prophet5-panel__surface .p5-effects-panel .prophet-section[data-fx="delay"] {
    flex: none;
  }

  .prophet5-panel__surface .p5-secondary-rack .control-container {
    flex-basis: 62px;
    width: 62px;
    min-width: 62px;
  }
}

/* A desktop panel becomes scrollable only when its available vertical space is
 * genuinely constrained. This also avoids a one-pixel rounding overflow from
 * creating an otherwise empty scrollbar at ordinary desktop heights. */
@media (max-height: 700px) and (min-width: 701px) {
  .prophet5-panel__surface {
    overflow-y: auto;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
  }

  /* Keep the Simple-mode selector from masking the short-desktop escape
   * hatch. Piano is unscaled, so it needs the same outer scroll path. */
  .prophet5-panel[data-control-mode="simple"] .prophet5-panel__surface,
  .piano-panel__surface {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Override the column-based layout from prophet5.css ONLY inside the in-app
 * panel. The standalone prophet5.html page keeps its 3-column shape because
 * it has plenty of vertical space; embedded inside ChordBuddy we want all
 * 10 sections to flow as siblings in a single flex-wrap row so the content
 * uses the panel's full width before adding height. display: contents makes
 * the wrapper divs (.modulation-column, .center-area, .right-area) disappear
 * from layout while leaving their children where they are. */
.prophet5-panel__surface .modulation-column,
.prophet5-panel__surface .center-area,
.prophet5-panel__surface .right-area {
  display: contents;
}

.prophet5-panel__surface .parameters-panel:not(.parameters-panel--faceplate) {
  /* Wrap sections into a rectangular block — Prophet-5 hardware-inspired:
   * modulation cluster, voice path, envelopes, global. The flex-wrap means
   * sections wrap as the viewport narrows, growing the natural content
   * height. Combined with the wide-short internal section overrides below
   * (which flip oscillator/mixer/wheel-mod from column to row), the natural
   * content shape matches the panel surface aspect — so the fit-scale stays
   * higher (~0.65+) and text stays legible. */
  display: flex;
  flex-wrap: wrap;
  gap: var(--prophet5-area-gap);
  justify-content: center;
  align-items: flex-start;
  align-content: flex-start;
  max-width: none;
  width: 100%;
}

/* Sections size to their natural content; no flex-grow so widths stay
 * stable as rows wrap. */
.prophet5-panel__surface .parameters-panel:not(.parameters-panel--faceplate) .prophet-section {
  flex: 0 0 auto;
}

/* ───── Wide-short section internals (in-app panel only) ─────────────────
 * The standalone prophet5.html page renders sections tall-narrow because
 * it has plenty of vertical space (a full standalone window). In the
 * embedded panel that wastes horizontal space and forces aggressive
 * fit-scale shrinkage. We flip the three column-stacked grids to row so
 * each section becomes wide-short, matching the panel aspect.
 *
 * Affected builder classes:
 *   .oscillator-grid — Osc A / Osc B knob stacks (the biggest culprit)
 *   .mixer-grid      — Osc-A / Osc-B / Noise level knobs
 *   .wheel-mod-grid  — mod source mix + switches
 *
 * The horizontal `*-switches` rows inside each section stay as-is — they
 * were already flex-row.
 */
.prophet5-panel__surface .oscillator-grid,
.prophet5-panel__surface .mixer-grid,
.prophet5-panel__surface .wheel-mod-grid {
  flex-direction: row;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
}

/* ───── Edit-toggle button in the host bars (StatusBar + TopbarSongControls) ───── */
.instrument-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid var(--border-2, rgba(255, 255, 255, 0.16));
  background: var(--surface-2, rgba(255, 255, 255, 0.04));
  color: var(--text-2, rgba(255, 255, 255, 0.75));
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  user-select: none;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.instrument-edit-btn:hover {
  background: var(--surface-3, rgba(255, 255, 255, 0.08));
  color: var(--text-1, #fff);
  border-color: var(--border-1, rgba(255, 255, 255, 0.28));
}

.instrument-edit-btn[aria-expanded="true"] {
  background: rgba(96, 165, 250, 0.18);
  border-color: rgba(96, 165, 250, 0.4);
  color: #bfdbfe;
}

.instrument-edit-btn .instrument-edit-btn__glyph {
  display: block;
  width: 12px;
  height: 12px;
  background-image: radial-gradient(circle at 6px 6px, currentColor 1.4px, transparent 1.8px);
  background-size: 6px 6px;
  background-repeat: repeat;
  opacity: 0.85;
}

/* ───── In-app effects sections (Reverb / Chorus / Delay) ───────────────
 * The new buildProphet5EffectsUI emits .prophet-section[data-fx] blocks
 * with native <input type="range">, <select>, and .chorus-btn controls
 * inside .control-container. The standalone-drawer slider/select rules in
 * styles/prophet5.css are scoped to .prophet-fx-row and don't apply here,
 * so we provide panel-scoped equivalents that match the dense, dark
 * .compact-knob/.compact-toggle aesthetic of the synth sections.
 */

/* Wide-short row layout for the seven delay controls. Mirrors the
 * existing .oscillator-grid / .mixer-grid / .wheel-mod-grid flex-row
 * override block above. */
.prophet5-panel__surface .delay-grid {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

/* Slim native range sliders that fit the .control-container shell. */
.prophet5-panel__surface .control-container input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 64px;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.prophet5-panel__surface .control-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-1, #4ea1ff);
  border: 1px solid rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.prophet5-panel__surface .control-container input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-1, #4ea1ff);
  border: 1px solid rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

/* Clickable value chip — used by the delay TIME chip to flip between
 * milliseconds and tempo-synced divisions. Pointer cursor + dotted
 * underline tells users the chip is an affordance, not just readout. */
.prophet5-panel__surface .control-value-clickable {
  cursor: pointer;
  text-decoration: underline dotted rgba(255, 255, 255, 0.4);
  text-underline-offset: 2px;
}

.prophet5-panel__surface .control-value-clickable:hover {
  color: var(--accent-1, #4ea1ff);
}

.prophet5-panel__surface .control-value-clickable.is-sync {
  color: var(--accent-1, #4ea1ff);
}

/* Compact dark select to match adjacent slider density. */
.prophet5-panel__surface .control-container select {
  background: var(--surface-2, rgba(255, 255, 255, 0.04));
  color: var(--text-1, #fff);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 3px;
  font-size: 10px;
  padding: 2px 4px;
  height: 18px;
  cursor: pointer;
}

/* Chorus mode pills — small, dark, with active accent. */
.prophet5-panel__surface .chorus-btn {
  background: var(--surface-2, rgba(255, 255, 255, 0.04));
  color: var(--text-2, rgba(255, 255, 255, 0.75));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 3px;
  font-size: 10px;
  padding: 3px 8px;
  cursor: pointer;
  min-width: 32px;
  text-align: center;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.prophet5-panel__surface .chorus-btn:hover {
  background: var(--surface-3, rgba(255, 255, 255, 0.08));
  color: var(--text-1, #fff);
  border-color: rgba(255, 255, 255, 0.28);
}

.prophet5-panel__surface .chorus-btn.active {
  background: var(--accent-1, #4ea1ff);
  color: #000;
  border-color: var(--accent-1, #4ea1ff);
}

/* ─── Sampler panel ────────────────────────────────────────────────────── */
/* Reuses prophet5-panel chrome (open/closed transitions, accent bar) and
   adds sampler-specific surfaces: waveform, browser, controls. Sized to
   stay compact — single visible row of controls, scrollable browser. */

.sampler-panel__accent {
  background: linear-gradient(180deg, rgba(74,163,255,0.18), rgba(74,163,255,0.06));
}

.sampler-panel__accent .velocity-range-control {
  top: 24px;
  left: 8px;
}

.sampler-panel {
  z-index: 1100;
}

.sampler-panel--bottom {
  max-height: calc(100vh - var(--transport-topbar-height, 60px) - var(--transport-progress-height, 45px) - var(--statusbar-height, 40px));
}

.sampler-panel__close-btn {
  margin-left: auto;
  font-size: 11px;
  background: transparent;
  color: var(--text-2, #cbd5e1);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
}
.sampler-panel__close-btn:hover { color: #fff; border-color: rgba(255,255,255,0.35); }

.sampler-panel__drum-back-btn {
  position: absolute;
  left: 8px;
  top: 5px;
  transform: none;
  padding: 2px 9px 3px;
  border: 1px solid rgba(126, 215, 196, 0.36);
  border-radius: 999px;
  color: rgba(218, 243, 239, 0.92);
  background: rgba(126, 215, 196, 0.08);
  font: inherit;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.sampler-panel__surface {
  display: flex;
  align-items: flex-start;
  /* The fitted content keeps its unscaled layout height even after the
     transform is applied. Centering that larger box can move its transformed
     top above the scroll origin, underneath the accent strip. Keep the drum
     surface top-anchored; _fitContent compensates the unused block size. */
  justify-content: flex-start;
  overflow-y: hidden;
  padding: 8px 10px 10px;
  height: auto;
  background: #0b0d12;
}

/* Sample/drum browsers have their own localized list scrolling, but the
 * complete editor must still scroll when the available panel height is
 * genuinely constrained. Keep this after the base sampler rule so it wins
 * the cascade without affecting normal desktop panels. */
@media (max-width: 700px) {
  .sampler-panel__surface {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-height: 700px) and (min-width: 701px) {
  .sampler-panel__surface {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.sampler-panel__content {
  width: 100%;
  max-width: 1800px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transform: scale(var(--sampler-panel-fit-scale, 1));
  transform-origin: top center;
  margin-bottom: calc(-1 * var(--sampler-panel-fit-block-compensation, 0px));
}

.sampler-panel__advanced {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sampler-panel__advanced[hidden] {
  display: none;
}

.sampler-panel--drums .sampler-panel__accent {
  background: linear-gradient(180deg, rgba(126, 215, 196, 0.19), rgba(126, 215, 196, 0.05));
}

/* ─── Drum Lane / Groove Editor ───────────────────────────────────────── */
.drum-lane-panel {
  display: none;
  width: 100%;
  min-height: 0;
  color: rgba(235, 242, 241, 0.94);
}

.drum-lane-panel--active {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.drum-lane-panel button,
.drum-lane-panel input,
.drum-lane-panel select {
  font: inherit;
}

.drum-lane-panel__toolbar {
  display: grid;
  grid-template-columns: minmax(330px, 1fr) minmax(440px, 1.4fr) auto;
  gap: 10px;
  align-items: stretch;
}

.drum-lane-panel__identity,
.drum-lane-panel__sound,
.drum-browser-group,
.drum-groove-editor {
  border: 1px solid rgba(226, 236, 234, 0.11);
  border-radius: 5px;
  background: #171c1d;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.drum-lane-panel__identity {
  padding: 8px;
}

.drum-lane-panel__eyebrow,
.drum-browser-group__title,
.drum-groove-editor__header {
  color: rgba(218, 232, 230, 0.68);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.drum-lane-panel__pads {
  display: grid;
  grid-template-columns: repeat(3, minmax(80px, 1fr));
  gap: 5px;
  margin-top: 7px;
}

.drum-pad {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 7px 9px;
  border: 1px solid rgba(226, 236, 234, 0.12);
  border-radius: 4px;
  color: rgba(232, 240, 239, 0.76);
  background: #101415;
  cursor: pointer;
}

.drum-pad small {
  max-width: 100%;
  overflow: hidden;
  color: rgba(205, 218, 216, 0.48);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drum-pad--selected {
  border-color: rgba(126, 215, 196, 0.72);
  color: #effffb;
  background: rgba(126, 215, 196, 0.12);
  box-shadow: inset 0 0 0 1px rgba(126, 215, 196, 0.13);
}

.drum-lane-panel__sound {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto minmax(130px, 0.8fr);
  gap: 8px;
  align-items: end;
  padding: 8px;
}

.drum-lane-panel__sound label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 4px;
  color: rgba(205, 218, 216, 0.58);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.drum-lane-panel__sound select {
  min-width: 0;
  height: 26px;
  font-size: 10px;
}

.drum-icon-button,
.drum-lane-panel__tabs button,
.drum-lane-panel__footer button,
.drum-groove-editor button {
  min-height: 26px;
  border: 1px solid rgba(226, 236, 234, 0.16);
  border-radius: 4px;
  color: rgba(231, 239, 238, 0.82);
  background: rgba(255, 255, 255, 0.035);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.drum-icon-button:hover,
.drum-lane-panel__tabs button:hover,
.drum-lane-panel__footer button:hover,
.drum-groove-editor button:hover {
  border-color: rgba(126, 215, 196, 0.56);
  color: #fff;
}

.drum-lane-panel__level input {
  width: 100%;
  accent-color: #7ed7c4;
}

.drum-lane-panel__level output {
  color: rgba(235, 242, 241, 0.8);
  font-size: 9px;
  letter-spacing: 0;
  text-transform: none;
}

.drum-lane-panel__tabs {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.drum-lane-panel__tabs button[aria-selected="true"] {
  border-color: rgba(126, 215, 196, 0.7);
  color: #f1fffc;
  background: rgba(126, 215, 196, 0.12);
}

.drum-lane-panel__browser {
  display: grid;
  grid-template-columns: minmax(330px, 0.8fr) minmax(460px, 1.2fr);
  gap: 8px;
  min-height: 0;
}

.drum-browser-group {
  min-height: 0;
  overflow: hidden;
}

.drum-browser-group__title {
  display: flex;
  min-height: 27px;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  border-bottom: 1px solid rgba(226, 236, 234, 0.08);
}

.drum-browser-group__title > span {
  margin-right: auto;
}

.drum-browser-group__title label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: rgba(205, 218, 216, 0.55);
  font-size: 8px;
  letter-spacing: 0;
  text-transform: none;
}

.drum-browser-list {
  max-height: 168px;
  overflow-y: auto;
  padding: 3px;
}

.drum-browser-row-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.drum-browser-row {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(130px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 3px;
  color: rgba(230, 238, 237, 0.79);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.drum-browser-row:hover,
.drum-browser-row:focus-visible {
  border-color: rgba(126, 215, 196, 0.36);
  color: #fff;
  background: rgba(126, 215, 196, 0.075);
  outline: none;
}

.drum-browser-row > span:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.drum-browser-row strong {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drum-browser-row small {
  color: rgba(205, 218, 216, 0.42);
  font-size: 8px;
}

.drum-pattern-glyphs {
  color: #101718;
  padding: 2px 5px;
  border-radius: 2px;
  background: rgba(126, 215, 196, 0.72);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  letter-spacing: 0.02em;
}

.drum-browser-row__meter,
.drum-browser-row__place {
  color: rgba(205, 218, 216, 0.54);
  font-size: 8px;
}

.drum-browser-empty,
.drum-groove-editor--empty,
.drum-lane-panel__empty {
  margin: 0;
  padding: 18px;
  color: rgba(205, 218, 216, 0.58);
  font-size: 10px;
}

.drum-groove-editor--empty {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.drum-groove-editor--empty strong {
  color: rgba(235, 244, 243, 0.9);
  font-size: 11px;
}

.drum-lane-panel__empty {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.drum-groove-editor {
  padding: 8px;
}

.drum-groove-editor__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.drum-groove-editor__header span:nth-child(2) {
  margin-left: auto;
  color: rgba(205, 218, 216, 0.42);
  letter-spacing: 0.02em;
}

.drum-step-grid {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow: hidden;
}

.drum-step-grid__playhead {
  position: absolute;
  z-index: 3;
  top: 0;
  bottom: 0;
  left: 84px;
  width: calc(100% - 84px);
  pointer-events: none;
  will-change: transform;
}

.drum-step-grid__playhead::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 1px;
  background: rgba(216, 255, 246, 0.72);
  box-shadow: 0 0 5px rgba(126, 215, 196, 0.55);
  content: "";
}

.drum-step-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
}

.drum-step-ruler {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 6px;
  min-width: 0;
}

.drum-step-ruler__steps {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(var(--drum-step-count), minmax(2px, 1fr));
  gap: 1px;
}

.drum-step-ruler__steps span {
  min-width: 0;
  color: rgba(205, 218, 216, 0.28);
  font-size: 7px;
  line-height: 10px;
  text-align: left;
}

.drum-step-ruler__steps .drum-step-ruler__beat {
  color: rgba(218, 232, 230, 0.7);
}

.drum-step-row__label {
  border: 0;
  color: rgba(224, 235, 233, 0.74);
  background: transparent;
  font-size: 9px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.drum-step-row__steps {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(var(--drum-step-count), minmax(2px, 1fr));
  gap: clamp(1px, calc(24px / var(--drum-step-count)), 2px);
}

.drum-step {
  position: relative;
  min-width: 0;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(226, 236, 234, 0.11);
  border-radius: 2px;
  background: #0e1213;
  cursor: crosshair;
}

.drum-step--group-start {
  border-left-color: rgba(226, 236, 234, 0.38);
}

.drum-step:hover,
.drum-step:focus-visible {
  border-color: rgba(126, 215, 196, 0.72);
  outline: none;
}

.drum-step--active {
  border-color: rgba(9, 22, 23, 0.65);
  background: #7ed7c4;
  box-shadow: inset 0 -4px 0 rgba(8, 24, 25, 0.18);
}

.drum-step--hard {
  background: #d8fff6;
}

.drum-step--normal {
  background: #7ed7c4;
}

.drum-step--soft {
  background: #3e7168;
}

.drum-groove-editor__actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
}

.drum-groove-editor__actions input {
  min-width: 160px;
  margin-left: auto;
  padding: 5px 7px;
  border: 1px solid rgba(226, 236, 234, 0.15);
  border-radius: 3px;
  color: rgba(236, 243, 242, 0.9);
  background: #0e1213;
  font-size: 9px;
}

.drum-accent-key {
  color: rgba(205, 218, 216, 0.54);
  font-size: 8px;
}

.drum-accent-key i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 2px 0 6px;
  border-radius: 1px;
  background: #7ed7c4;
}

.drum-accent-key__hard { background: #d8fff6 !important; }
.drum-accent-key__soft { background: #3e7168 !important; }

.drum-lane-panel__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.drum-lane-panel__footer--sequencer {
  padding-inline: 2px;
}

.drum-lane-panel__hint {
  margin-right: auto;
  color: rgba(205, 218, 216, 0.46);
  font-size: 8px;
}

@media (max-width: 920px) {
  .drum-lane-panel__toolbar {
    grid-template-columns: 1fr;
  }

  .drum-lane-panel__sound {
    grid-template-columns: 1fr 1fr;
  }

  .drum-lane-panel__browser {
    grid-template-columns: 1fr;
  }
}

.sampler-panel__top,
.sampler-panel__main { width: 100%; }

.sampler-panel__top {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(210px, 300px);
  gap: 8px;
  align-items: stretch;
}

.sampler-panel__waveform-wrap {
  position: relative;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  background: #0b0d12;
  height: 64px;
  overflow: hidden;
}
.sampler-panel__waveform-wrap--drop-active {
  border-color: rgba(74,163,255,0.7);
  box-shadow: inset 0 0 0 2px rgba(74,163,255,0.35);
}
.sampler-panel__waveform {
  display: block;
  width: 100%;
  height: 100%;
}
.sampler-panel__waveform-hint {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 11px;
  color: rgba(203,213,225,0.55);
  pointer-events: none;
}
.sampler-panel__waveform-flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(74,163,255,0.35), transparent 60%);
  opacity: 0;
  transition: opacity 80ms linear;
}
.sampler-panel__waveform-flash--active { opacity: 1; transition: none; }

.sampler-panel__file-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  align-items: center;
  font-size: 11px;
  color: var(--text-2, #cbd5e1);
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  background: rgba(17,21,27,0.72);
}
.sampler-panel__file-input { color: var(--text-2, #cbd5e1); font-size: 11px; }
.sampler-panel__sample-name {
  width: 100%;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--text-1, #fff);
}

.sampler-panel__main {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 8px;
}

.sampler-panel__browser {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  background: rgba(17,21,27,0.85);
  padding: 6px;
  max-height: 128px;
  overflow-y: auto;
}
.sampler-panel__browser-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(203,213,225,0.7);
  margin-bottom: 6px;
}
.sampler-panel__browser-group { margin-bottom: 8px; }
.sampler-panel__browser-heading {
  font-size: 10px;
  text-transform: uppercase;
  color: rgba(74,163,255,0.8);
  letter-spacing: 0.05em;
  margin: 4px 0 2px;
}
.sampler-panel__browser-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2, #cbd5e1);
  padding: 3px 6px;
  font-size: 11px;
  border-radius: 3px;
  cursor: pointer;
}
.sampler-panel__browser-item:hover {
  background: rgba(74,163,255,0.12);
  border-color: rgba(74,163,255,0.3);
  color: #fff;
}

.sampler-panel__controls {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px 8px;
  align-items: start;
}
.sampler-panel__control-group--sample {
  grid-column: 1;
  grid-row: 1;
}
.sampler-panel__control-group--amp-env {
  grid-column: 2;
  grid-row: 1;
}
.sampler-panel__control-group--filter {
  grid-column: 2;
  grid-row: 2;
}
.sampler-panel__control-group--pitch-env {
  grid-column: 1;
  grid-row: 2;
}
.sampler-panel__control-group {
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 4px;
  padding: 4px 6px 5px;
  background: rgba(17,21,27,0.55);
}
.sampler-panel__control-group-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(74,163,255,0.85);
  margin-bottom: 3px;
}
.sampler-panel__control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 7px;
  align-items: flex-start;
}
.sampler-panel__control {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 0 clamp(76px, 4.8vw, 92px);
  max-width: 92px;
  min-width: 0;
  font-size: 10px;
  color: var(--text-2, #cbd5e1);
}
.sampler-panel__control-label {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 9px;
  color: rgba(203,213,225,0.65);
}
.sampler-panel__control-slider {
  width: 100%;
  height: 6px;
  accent-color: #4aa3ff;
}
.sampler-panel__control-value {
  font-size: 11px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text-1, #fff);
}
.sampler-panel__control-toggle { align-self: flex-start; }
.sampler-panel__control-select { width: 100%; font-size: 11px; }
.sampler-panel__control-readout {
  font-size: 11px;
  color: var(--text-1, #fff);
}

@media (max-width: 820px) {
  .sampler-panel__top,
  .sampler-panel__main {
    grid-template-columns: 1fr;
  }

  .sampler-panel__file-row {
    flex-direction: row;
    justify-content: flex-start;
  }

  .sampler-panel__sample-name {
    text-align: left;
  }

  .sampler-panel__controls {
    grid-template-columns: 1fr;
  }

  .sampler-panel__control-group {
    grid-column: 1;
    grid-row: auto;
  }
}

@media (max-height: 520px) {
  .sampler-panel__content {
    gap: 4px;
  }

  .sampler-panel__top {
    grid-template-columns: 1fr;
  }

  .sampler-panel__waveform-wrap {
    display: none;
  }

  .sampler-panel__file-row {
    min-height: 26px;
    flex-direction: row;
    justify-content: flex-start;
    padding: 4px 6px;
  }

  .sampler-panel__sample-name {
    text-align: left;
  }

  .sampler-panel__main {
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 6px;
  }

  .sampler-panel__browser {
    max-height: 96px;
    padding: 4px;
  }

  .sampler-panel__browser-group {
    margin-bottom: 4px;
  }

  .sampler-panel__browser-item {
    padding: 2px 4px;
    font-size: 10px;
  }

  .sampler-panel__controls {
    grid-template-columns: 400px minmax(0, 1fr);
    gap: 4px 6px;
  }

  .sampler-panel__control-group {
    padding: 3px 5px 4px;
  }

  .sampler-panel__control-row {
    gap: 4px 5px;
  }

  .sampler-panel__control {
    flex-basis: clamp(74px, 4.6vw, 88px);
    max-width: 88px;
  }
}
/* ───── Unified LED-collar knob ring ──────────────────────────────────────
   Shared by DX7, Prophet-5, and the effects rack. Pure CSS: the collar is a
   conic-gradient whose lit edge is derived from the same --rotation custom
   property the controllers already write on the knob element, masked into
   15 radial tick segments over the 270° sweep (start 225°, i.e. 7:30). */
.knob-collar {
  --collar-lit: calc(var(--rotation, -135deg) + 135deg);
  pointer-events: none;
  position: absolute;
  inset: -11px;
  border-radius: 50%;
  background: conic-gradient(from 225deg,
    var(--knob-led, #7fb2e5) 0 var(--collar-lit),
    var(--knob-led-dim, #23262e) var(--collar-lit) 270deg,
    transparent 270deg);
  /* thin tick bars (≈2px wide at the ring radius) with clear air between the
     ring and the knob face, matching the approved SVG collar */
  /* circle closest-side makes 100% = half the box width exactly (the default
     farthest-corner sizing resolves % against the diagonal and pulls the ring
     onto the cap edge) */
  -webkit-mask-image:
    radial-gradient(circle closest-side, transparent 0 calc(100% - 7px), #000 calc(100% - 7px) calc(100% - 2px), transparent calc(100% - 2px)),
    repeating-conic-gradient(from 222.75deg, #000 0 4.5deg, transparent 4.5deg 19.2857deg);
  -webkit-mask-composite: source-in;
  mask-image:
    radial-gradient(circle closest-side, transparent 0 calc(100% - 7px), #000 calc(100% - 7px) calc(100% - 2px), transparent calc(100% - 2px)),
    repeating-conic-gradient(from 222.75deg, #000 0 4.5deg, transparent 4.5deg 19.2857deg);
  mask-composite: intersect;
  filter: drop-shadow(0 0 2.5px var(--knob-led-glow, rgba(127, 178, 229, .55)));
}

/* ───── Lane effects rack (approved redesign) ─────────────────────────────
   One neutral steel identity for both lanes — never inherits the instrument
   accent, and reads as its own unit above/below the instrument surface.
   Knobs are the unified LED-collar design; native inputs stay the source of
   truth (hidden for knobs, styled for the power LED / selects). */
.lane-effects-strip {
  --fx-accent: #7fb2e5;
  --fx-line: #262b35;
  --fx-line-soft: #1e222b;
  /* unified LED-collar accent: neutral steel (never inherits an instrument's) */
  --knob-led: #7fb2e5;
  --knob-led-dim: #23262e;
  --knob-led-glow: rgba(127, 178, 229, 0.55);
  box-sizing: border-box;
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 8px;
  color: #e8e8ec;
  font: 500 12px/1.3 Inter, ui-sans-serif, system-ui, sans-serif;
  background: #0f1116;
  border: 1px solid #2c3340;
  border-radius: 10px;
}
.lane-effects-strip__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 4px 8px;
}
.lane-effects-strip__title {
  margin: 0;
  color: #9fb6cd;
  font: 700 10px/1.2 Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: .22em;
  text-transform: uppercase;
}
.lane-effects-strip__lane {
  margin-left: auto;
  color: #5d6b7c;
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.lane-effects-rack {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 4.2fr) minmax(0, 1.7fr);
  gap: 10px;
}
.lane-effects-module {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
  padding: 0;
  background: #14161c;
  border: 1px solid var(--fx-line);
  border-radius: 10px;
}
.lane-effects-module__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--fx-line-soft);
}
.lane-effects-module__name {
  color: #9a9aa6;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.lane-effects-module--on .lane-effects-module__name { color: #e8e8ec; }
.lane-effects-module__bypass {
  display: none;
  margin-left: auto;
  color: #6a6a76;
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.lane-effects-module:not(.lane-effects-module--on) .lane-effects-module__bypass { display: inline; }
.lane-effects-module__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px 10px;
}
.lane-effects-module:not(.lane-effects-module--on) .lane-effects-module__body {
  opacity: .42;
  filter: saturate(.2);
}
.lane-effects-cells {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  align-items: flex-start;
  justify-content: space-evenly;
}
.lane-effects-tone { border-top: 1px solid var(--fx-line-soft); padding-top: 6px; }
.lane-effects-tone__label {
  display: block;
  color: #6a6a76;
  font-size: 9px;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-bottom: 2px;
}

/* power LED toggle — the native checkbox stays the accessible control */
/* Compound selector: the toggle also carries .lane-effects-control (so
   render() can find it via closest()), whose 58px min-width would otherwise
   win on source order and stretch the LED into an ellipse. */
.lane-effects-control.lane-effects-power {
  position: relative;
  display: inline-flex;
  width: 22px;
  min-width: 22px;
  max-width: 22px;
  height: 22px;
  flex: 0 0 auto;
  padding: 0;
  order: -1; /* LED renders left of the module name (DOM order is name-first) */
  cursor: pointer;
}
.lane-effects-power input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.lane-effects-power__led {
  pointer-events: none;
  position: absolute;
  inset: 0;
  border: 1px solid var(--fx-line);
  border-radius: 50%;
  background: #1a1d24;
}
.lane-effects-power__led::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: #333a46;
}
.lane-effects-power input:checked + .lane-effects-power__led { border-color: #2b4a66; }
.lane-effects-power input:checked + .lane-effects-power__led::after {
  background: var(--fx-accent);
  box-shadow: 0 0 6px 1px rgba(127, 178, 229, .55);
}
.lane-effects-power input:focus-visible + .lane-effects-power__led {
  outline: 2px solid var(--fx-accent);
  outline-offset: 2px;
}

/* knob + select cells */
.lane-effects-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 58px;
  padding: 2px 0;
}
.lane-effects-control--sm { min-width: 48px; }
.lane-effects-control__label {
  color: #9a9aa6;
  font-size: 9px;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
}
.lane-effects-control__value {
  color: #f4f7f9;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.lane-effects-control--select select {
  background: #1e222b;
  color: #e8e8ec;
  border: 1px solid var(--fx-line);
  border-radius: 6px;
  font: inherit;
  font-size: 11px;
  padding: 3px 6px;
}
.lane-effects-control__input--hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* unified LED-collar knob — the collar ring is the shared .knob-collar child */
.lane-effects-knob {
  position: relative;
  touch-action: none;
  cursor: ns-resize;
}
/* standoff keeps the ring clear of the cap at both rack knob sizes */
.lane-effects-knob .knob-collar { inset: -3px; }
.lane-effects-control--sm .knob-collar { inset: -4px; }
.lane-effects-knob__face {
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, #2c2f37, #16181d 65%, #101216);
  border: 1px solid #090a0d;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, .16), 0 3px 7px rgba(0, 0, 0, .55);
}
.lane-effects-knob__ptr {
  position: absolute;
  bottom: 50%;
  left: calc(50% - 1.5px);
  width: 3px;
  height: 33%;
  border-radius: 2px;
  background: #dde3ec;
  transform-origin: 50% 100%;
  transform: rotate(var(--rotation, 0deg));
}

/* responsive composition (mirrors the approved prototype) */
@media (min-width: 1500px) {
  .lane-effects-module--delay .lane-effects-module__body,
  .lane-effects-module--reverb .lane-effects-module__body {
    flex-direction: row;
    align-items: center;
    justify-content: space-evenly;
    gap: 14px;
  }
  .lane-effects-module--delay .lane-effects-tone,
  .lane-effects-module--reverb .lane-effects-tone {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-self: stretch;
    border-top: 0;
    border-left: 1px solid var(--fx-line-soft);
    margin: 0;
    padding: 0 0 0 14px;
  }
}
@media (max-width: 1499px) {
  .lane-effects-module__body > .lane-effects-cells,
  .lane-effects-module__body > .lane-effects-tone {
    width: 100%;
    max-width: 620px;
    margin-inline: auto;
  }
}
@media (max-width: 1100px) {
  .lane-effects-rack { grid-template-columns: auto 1fr; }
  .lane-effects-module--chorus { order: 1; }
  .lane-effects-module--reverb { order: 2; }
  .lane-effects-module--delay { order: 3; grid-column: 1 / -1; }
}
@media (min-width: 641px) and (max-width: 1100px) {
  .lane-effects-module--reverb .lane-effects-module__body {
    flex-direction: row;
    align-items: center;
    justify-content: space-evenly;
    gap: 14px;
  }
  .lane-effects-module--reverb .lane-effects-module__body > .lane-effects-cells {
    width: auto;
    max-width: none;
    margin: 0;
  }
  .lane-effects-module--reverb .lane-effects-module__body > .lane-effects-tone {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-self: stretch;
    width: auto;
    max-width: none;
    margin: 0;
    border-top: 0;
    border-left: 1px solid var(--fx-line-soft);
    padding: 0 0 0 14px;
  }
}
@media (max-width: 640px) {
  .lane-effects-rack { grid-template-columns: 1fr; }
  .lane-effects-module--delay { order: 2; }
  .lane-effects-module--reverb { order: 3; }
  .lane-effects-control { min-width: 62px; }
}
