/* Purpose: Bugulet 61 chassis UI — silver face, silkscreen labels, LED display. */

:root {
  --page-bg: #14110e;
  --chassis-top: #8a7f72;
  --chassis-mid: #5c5348;
  --chassis-deep: #3a332c;
  --chassis-well: #221c16;
  --chassis-edge: #120e0a;
  --plate-bg-top: #d8cbb8;
  --plate-bg-mid: #a89888;
  --plate-ink: #120c08;
  --plate-label: #3d2e22;
  --deck-bg: #2e2720;
  --deck-ink: #f2e8d8;
  --deck-label: #d4c4a8;
  --silk: #f0e6d4;
  --silk-dim: #c4b8a4;
  --lcd-bg: #0a0806;
  --lcd-glow: #ffc966;
  --lcd-dim: #a87840;
  --led-on: #ffb84d;
  --led-dim: #5c4030;
  --midi-led: #ff9f3c;
  --mod-accent: #c97b5c;
  --font-brand: "Archivo Narrow", "Segoe UI", sans-serif;
  --font-silk: "Share Tech Mono", ui-monospace, monospace;
  --font-lcd: "Press Start 2P", "Share Tech Mono", monospace;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  font-family: var(--font-silk);
  font-size: 12px;
  color: var(--silk);
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, #2a2218 0%, transparent 50%),
    var(--page-bg);
}

.page {
  width: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.chassis-viewport {
  flex-shrink: 0;
  overflow: hidden;
  max-width: 100vw;
  max-height: 100dvh;
}

.chassis-stage {
  display: inline-block;
  vertical-align: top;
  transform-origin: top left;
}

.page[data-audio="on"] .chassis {
  box-shadow:
    0 0 0 1px #4a4038,
    0 12px 40px rgba(0, 0, 0, 0.55),
    0 0 20px rgba(255, 184, 77, 0.08);
}

.error-panel {
  position: fixed;
  top: 0.5rem;
  left: 50%;
  z-index: 20;
  max-width: min(32rem, 92vw);
  margin: 0;
  transform: translateX(-50%);
  padding: 0.55rem 0.75rem;
  border-radius: 4px;
  background: rgba(180, 40, 40, 0.2);
  border: 1px solid rgba(255, 100, 100, 0.45);
  color: #ffb4b4;
  font-size: 11px;
}

/* —— Chassis shell —— */

.chassis {
  width: max-content;
  max-width: none;
  position: relative;
  border-radius: 8px 8px 4px 4px;
  border: 1px solid var(--chassis-edge);
  background: linear-gradient(180deg, var(--chassis-top) 0%, var(--chassis-mid) 4%, var(--chassis-deep) 18%, #221c16 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    0 10px 32px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.chassis-plate {
  padding: 0.65rem 0.85rem 0.5rem;
  border-bottom: 2px solid var(--chassis-edge);
  background: linear-gradient(180deg, var(--plate-bg-top) 0%, var(--plate-bg-mid) 55%, #6b5f52 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.chassis-plate-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.28rem;
  width: 100%;
  min-width: 0;
}

.chassis-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.2rem 0.45rem 0.18rem 0.32rem;
  border-radius: 3px;
  border: 1px solid #2a2218;
  background: linear-gradient(180deg, #b8a898 0%, #9a8a7a 55%, #8a7a6a 100%);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.28),
    inset 0 -1px 0 rgba(255, 255, 255, 0.18),
    0 1px 0 rgba(255, 255, 255, 0.22);
  font-family: var(--font-brand);
  text-decoration: none;
  color: var(--plate-label);
}

.chassis-back-btn:hover {
  color: var(--plate-ink);
}

.chassis-back-btn:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 3px 5px rgba(0, 0, 0, 0.38),
    0 0 0 rgba(255, 255, 255, 0);
}

.chassis-back-arrow {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}

.chassis-back-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.chassis-plate-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  width: 100%;
  min-width: 0;
}

.chassis-plate-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
  flex-shrink: 0;
  margin-left: auto;
  text-align: right;
}

.chassis-plate-silk {
  font-family: var(--font-brand);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--plate-label);
  opacity: 0.72;
}

.page[data-audio="pending"] .chassis-plate-silk {
  display: none;
}

.page[data-audio="pending"] .gesture-hint {
  display: inline-flex;
  cursor: pointer;
}

.page[data-audio="on"] .gesture-hint {
  display: none;
}

.gesture-hint {
  display: none;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  font-family: var(--font-brand);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

#gestureBannerTitle {
  color: var(--lcd-glow);
  text-shadow: 0 0 8px rgba(255, 201, 102, 0.75);
}

.gesture-hint-led {
  flex-shrink: 0;
  width: 0.48rem;
  height: 0.48rem;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--lcd-glow);
  border: 1px solid #7a5520;
  box-shadow:
    inset 0 0 2px rgba(255, 248, 220, 0.55),
    inset 0 -2px 3px rgba(120, 60, 10, 0.35),
    0 0 7px rgba(255, 201, 102, 0.95),
    0 0 2px rgba(255, 184, 77, 0.6),
    0 1px 2px rgba(0, 0, 0, 0.4);
  animation: gesture-hint-pwm 0.5s ease-in-out infinite;
}

.gesture-hint-sub:empty {
  display: none;
}

.gesture-hint-sub:not(:empty)::before {
  content: "·";
  margin: 0 0.25rem;
  opacity: 0.55;
}

.gesture-hint-sub {
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0.03em;
  color: var(--midi-led);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

@keyframes gesture-hint-pwm {
  0%,
  100% {
    filter: brightness(0.32);
    box-shadow:
      inset 0 2px 3px rgba(0, 0, 0, 0.75),
      inset 0 -1px 0 rgba(255, 255, 255, 0.05),
      0 1px 0 rgba(255, 255, 255, 0.1),
      0 1px 3px rgba(0, 0, 0, 0.45),
      0 0 2px rgba(255, 201, 102, 0.15);
  }
  50% {
    filter: brightness(1);
    box-shadow:
      inset 0 0 2px rgba(255, 248, 220, 0.65),
      inset 0 -2px 3px rgba(120, 60, 10, 0.35),
      0 0 7px rgba(255, 201, 102, 0.95),
      0 0 2px rgba(255, 184, 77, 0.6),
      0 1px 2px rgba(0, 0, 0, 0.4);
  }
}

.chassis-display-bay {
  --display-module-h: 4.85rem;
  display: flex;
  align-items: stretch;
  gap: 0.55rem;
}

#dataEntryMount {
  display: flex;
  justify-content: center;
  width: 100%;
}

#dataEntryMount .fader-field {
  width: 100%;
  align-items: center;
}

.chassis-title {
  margin: 0;
  font-family: var(--font-brand);
  font-size: clamp(1.45rem, 4vw, 1.85rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--plate-ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.28);
}

.chassis-lcd {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.4rem;
  box-sizing: border-box;
  width: 16.25rem;
  min-width: 12rem;
  flex: 0 0 auto;
  padding: 0.28rem 0.4rem 0.28rem 0.32rem;
  border-radius: 3px;
  background: var(--lcd-bg);
  border: 2px inset #3a2024;
  box-shadow: inset 0 0 12px rgba(255, 60, 60, 0.15);
  font-family: var(--font-lcd);
  color: var(--lcd-glow);
}

.chassis-lcd-left {
  display: flex;
  flex: 0 0 50%;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: 0.2rem;
  min-width: 0;
  min-height: 0;
  padding-left: 0.28rem;
}

.chassis-lcd-scope-well {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  padding: 0.14rem 0.12rem 0.12rem 0.14rem;
  border: 1px solid var(--lcd-dim);
  background: #060504;
  box-shadow: inset 0 0 0 1px rgba(255, 201, 102, 0.32);
}

.chassis-lcd-scope {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  background: transparent;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.chassis-lcd-readout {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.1rem;
  min-width: 0;
}

.chassis-lcd-top {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.08rem;
  min-width: 0;
}

.chassis-lcd-keys {
  margin: 0;
  font-size: 0.5rem;
  line-height: 1.65;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chassis-lcd-chord {
  margin: 0;
  font-size: 0.52rem;
  line-height: 1.65;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chassis-lcd-foot {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  justify-content: flex-end;
  width: 100%;
  min-width: 0;
}

.chassis-lcd-voices {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.05rem;
  flex-shrink: 0;
}

.chassis-lcd-voices-label {
  font-size: 0.42rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chassis-lcd-voices-val {
  font-size: 0.62rem;
  font-weight: 400;
  min-width: 2ch;
  text-align: right;
}

.chassis-lcd-label {
  font-size: 0.42rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.chassis-lcd-value {
  font-size: 0.55rem;
  font-weight: 400;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chassis-lcd-status {
  flex: 0 0 auto;
  padding-left: 0.28rem;
  font-size: 0.42rem;
  line-height: 1.7;
  text-align: left;
  white-space: normal;
}

.chassis-lcd-status[data-level="error"] {
  color: #ff8a8a;
}

/* —— Control deck (MIDI / preset / wave) —— */

.chassis-deck {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.75rem;
  align-items: flex-end;
  padding: 0.55rem 0.85rem 0.6rem;
  background: linear-gradient(180deg, var(--deck-bg) 0%, #221c16 100%);
  border-bottom: 2px solid var(--chassis-edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  color: var(--deck-ink);
}

.hw-bay {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.55rem;
  align-items: flex-end;
}

.hw-bay--wide {
  flex: 1 1 12rem;
}

.hw-bay--actions {
  margin-left: auto;
}

.control-slot-silk--fixed {
  cursor: default;
  pointer-events: none;
}

.hw-well {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.hw-well-label {
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--deck-label);
  font-weight: 600;
}

.hw-slot {
  min-width: 6.5rem;
  padding: 0.32rem 1.4rem 0.32rem 0.45rem;
  border-radius: 3px;
  border: 1px solid #0a0806;
  background: linear-gradient(180deg, #1a1510 0%, #0f0c09 100%);
  color: var(--deck-ink);
  font-family: inherit;
  font-size: 11px;
  box-shadow:
    inset 0 3px 8px rgba(0, 0, 0, 0.65),
    0 1px 0 rgba(255, 255, 255, 0.06);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%23d4c4a8' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
}

.hw-slot--wide {
  min-width: 9rem;
}

.hw-push {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.55rem 0.3rem;
  border-radius: 4px;
  border: 1px solid #0a0806;
  background: linear-gradient(180deg, #5c5348 0%, #3a332c 55%, #2a2218 100%);
  color: var(--silk);
  font-family: inherit;
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 2px 4px rgba(0, 0, 0, 0.4);
}

.hw-push:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}

.hw-push--small {
  padding: 0.28rem 0.45rem;
  font-size: 8px;
}

.hw-push--file {
  display: inline-flex;
  align-items: center;
}

.hw-push-led {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--led-dim);
  border: 1px solid #0a0806;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
}

.hw-push.is-on .hw-push-led {
  background: var(--led-on);
  box-shadow:
    0 0 6px rgba(255, 184, 77, 0.85),
    inset 0 0 2px rgba(255, 240, 200, 0.5);
}

.hw-push.is-on {
  border-color: #6b4a20;
}

.hw-push:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bugulet-silk {
  font-size: 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--silk-dim);
}

/* —— Control face —— */

.bugulet-face {
  --bugulet-well-h: 7.5rem;
  --bugulet-slot-stack-h: calc(var(--bugulet-well-h) + 1.65rem);
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-end;
  align-content: flex-end;
  gap: 0;
  padding: 0.75rem 0.85rem 0.65rem;
  background: linear-gradient(180deg, #4a4038 0%, #322b24 55%, #2a2218 100%);
  border-bottom: none;
}

.bugulet-block {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.bugulet-block--wheels {
  margin-left: 0;
  height: var(--bugulet-slot-stack-h);
  justify-content: flex-start;
}

.bugulet-block--faders {
  flex: 0 0 auto;
  margin-left: 1.35rem;
  height: var(--bugulet-slot-stack-h);
  justify-content: flex-start;
}

.bugulet-block--knobs {
  --knob-size: 2.45rem;
  --knob-slot: 3.35rem;
  flex: 0 0 auto;
  margin-left: 1.35rem;
  height: var(--bugulet-slot-stack-h);
  justify-content: flex-start;
}

.bugulet-block--display {
  margin-left: auto;
  flex: 0 1 auto;
  min-width: 0;
}

.bugulet-block--display.chassis-display-bay {
  --fader-slot: 2.05rem;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-end;
  align-self: flex-end;
  justify-content: flex-end;
  gap: 0.35rem;
  height: var(--bugulet-slot-stack-h);
}

.bugulet-block--display .chassis-lcd {
  height: var(--bugulet-slot-stack-h);
  max-height: var(--bugulet-slot-stack-h);
}

@media (max-width: 900px) {
  .bugulet-face {
    flex-wrap: wrap;
  }

  .bugulet-block--faders {
    flex: 1 1 100%;
    order: 2;
    margin-left: 0;
  }

  .bugulet-block--knobs {
    order: 3;
    margin-left: 0;
  }

  .bugulet-block--wheels {
    order: 1;
  }

  .bugulet-block--display {
    order: 4;
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

}

.bugulet-block--wheels.bugulet-wheels {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  align-content: flex-start;
  height: 100%;
  gap: 0.5rem;
}

.bugulet-wheels {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.5rem;
}

.control-slot--wheel {
  flex: 0 0 auto;
  width: 2.15rem;
  max-width: none;
}

.control-slot--wheel .control-slot-dial {
  width: 100%;
}

.control-slot-num--wheel,
.control-slot-num--data {
  visibility: hidden;
}

.bugulet-wheel-track {
  width: 100%;
  height: var(--bugulet-well-h, 7.5rem);
  background: var(--chassis-well);
  border: 1px solid var(--chassis-edge);
  border-radius: 4px;
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.55);
  position: relative;
  overflow: hidden;
}

.bugulet-wheel-fill {
  --wheel-t: 0.5;
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  height: calc(var(--wheel-t) * (100% - 8px));
  min-height: 2px;
  max-height: calc(100% - 8px);
  border-radius: 2px;
  background: linear-gradient(0deg, #5c3a18, var(--led-on));
  transition: height 0.05s linear;
}

.bugulet-wheel-fill--mod {
  background: linear-gradient(0deg, #4a3580, var(--mod-accent));
}

.bugulet-faders {
  --fader-slot: 2.05rem;
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  width: auto;
  height: 100%;
  gap: 0.35rem;
}

/* Master vol slightly separated from the ADSR bank */
.control-slot--fader[data-slot-id="fader-1"] + .control-slot--fader {
  margin-left: 0.35rem;
}

.bugulet-knob-bank {
  /* Nudge top row (9–12) up; bottom row (13–16) stays pinned via :last-child */
  --knob-top-row-nudge: -0.25rem;
  display: grid;
  grid-template-rows: 1fr 1fr;
  align-content: stretch;
  width: 100%;
  height: var(--bugulet-slot-stack-h);
  max-height: var(--bugulet-slot-stack-h);
  box-sizing: border-box;
}

.bugulet-knob-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 0.35rem;
  min-height: 0;
}

.bugulet-knob-row:first-child {
  align-items: flex-start;
  align-self: start;
  margin-top: var(--knob-top-row-nudge);
}

.bugulet-knob-row:last-child {
  align-items: flex-end;
  align-self: end;
}

.bugulet-knob-row--offset {
  padding-left: calc(var(--knob-slot) / 2);
}

.control-slot--data-entry {
  flex: 0 0 var(--fader-slot, 2.05rem);
  width: var(--fader-slot, 2.05rem);
  max-width: none;
}

.bugulet-led {
  font-family: var(--font-silk);
  font-size: 1.65rem;
  color: var(--lcd-glow);
  text-shadow: 0 0 10px rgba(255, 77, 77, 0.55);
  min-width: 2ch;
  text-align: center;
}

/* —— Control slots —— */

.control-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  box-sizing: border-box;
  min-width: 0;
  position: relative;
}

.control-slot--fader {
  flex: 0 0 var(--fader-slot, 2.05rem);
  width: var(--fader-slot, 2.05rem);
  max-width: none;
}

.control-slot--knob {
  flex: 0 0 var(--knob-slot, 3.35rem);
  width: var(--knob-slot, 3.35rem);
}

.control-slot--knob .control-slot-dial,
.control-slot--knob .pot-field {
  width: auto;
  align-items: center;
}

.control-slot--waveform .control-slot-dial {
  position: relative;
  width: var(--knob-size, 2.45rem);
  height: var(--knob-size, 2.45rem);
  margin: 0 auto;
  overflow: visible;
  align-items: center;
  justify-content: center;
}

.control-slot--waveform .pot-field--waveform {
  position: relative;
  width: var(--knob-size, 2.45rem);
  height: var(--knob-size, 2.45rem);
  margin: 0;
}

.control-slot-num {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--silk-dim);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
  margin-top: 0.1rem;
}

.control-slot-dial {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  width: 100%;
}

.control-slot-silk {
  display: block;
  width: 100%;
  padding: 0.08rem 0.1rem;
  margin: 0;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: var(--silk-dim);
  font-family: inherit;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.05em;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
  cursor: pointer;
}

.control-slot-silk:hover,
.control-slot-silk.is-picker-open {
  color: var(--silk);
  background: rgba(0, 0, 0, 0.2);
}

.control-slot-silk.is-unassigned {
  opacity: 0.55;
}

.slot-param-picker {
  position: fixed;
  z-index: 2000;
  transform: translateX(-50%);
  padding: 0;
  border-radius: 3px;
  border: 1px solid #0a0806;
  background: var(--chassis-well);
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.slot-param-picker-select {
  display: block;
  min-width: 9.5rem;
  max-width: 14rem;
  padding: 0.35rem 1.5rem 0.35rem 0.45rem;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--silk);
  font-family: inherit;
  font-size: 11px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%23d4c4a8' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.4rem center;
  cursor: pointer;
}

.fader-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.fader-num {
  display: none;
}

.fader-track {
  --fader-cap: 16px;
  --fader-t: 0;
  position: relative;
  width: 1.75rem;
  height: var(--bugulet-well-h, 7.5rem);
  margin: 0 auto;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--chassis-edge);
  border-radius: 3px;
  background: linear-gradient(180deg, #2a2218 0%, #120e0a 100%);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.55);
  cursor: ns-resize;
  overflow: hidden;
}

.fader-ticks {
  position: absolute;
  inset: 4px 50% 4px auto;
  width: 1px;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 4px,
    rgba(255, 255, 255, 0.06) 4px,
    rgba(255, 255, 255, 0.06) 5px
  );
  pointer-events: none;
}

.fader-cap {
  position: absolute;
  left: 1px;
  right: 1px;
  height: var(--fader-cap);
  bottom: calc(var(--fader-t) * (100% - var(--fader-cap)));
  border-radius: 2px;
  background: linear-gradient(180deg, #e8dcc8 0%, #c4a882 45%, #8a7355 100%);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.fader-value {
  display: none;
}

.pot-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.pot-dial-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chassis .pot-dial {
  --pot-deg: -135deg;
  position: relative;
  width: var(--knob-size, 2.45rem);
  height: var(--knob-size, 2.45rem);
  flex-shrink: 0;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  border: 2px solid #1a1510;
  background: radial-gradient(circle at 35% 28%, #7a7064 0%, #4a4038 42%, #221c16 100%);
  box-shadow:
    inset 0 2px 5px rgba(255, 255, 255, 0.1),
    inset 0 -4px 8px rgba(0, 0, 0, 0.5),
    0 2px 5px rgba(0, 0, 0, 0.35);
  cursor: ns-resize;
}

.chassis .pot-pointer {
  position: absolute;
  top: 10%;
  left: 50%;
  width: 3px;
  height: 36%;
  margin-left: -1.5px;
  border-radius: 2px;
  background: linear-gradient(180deg, #f5e6c8, #8a7355);
  transform: rotate(var(--pot-deg));
  transform-origin: 50% 100%;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.pot-label,
.pot-value {
  display: none;
}

/* —— Waveform knob (marks overlay; dial + slot number stay centered) —— */

.pot-dial-wrap--waveform {
  --wave-orbit: calc(var(--knob-size, 2.45rem) * 0.5 + 0.62rem);
  position: relative;
  width: var(--knob-size, 2.45rem);
  height: var(--knob-size, 2.45rem);
  margin: 0;
  flex-shrink: 0;
}

.wave-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
}

.wave-mark {
  position: absolute;
  left: 0;
  top: 0;
  width: 12px;
  height: 9px;
  margin: -4.5px 0 0 -6px;
  padding: 0;
  border: none;
  background: none;
  color: #5c5044;
  opacity: 0.45;
  cursor: pointer;
  pointer-events: auto;
  transform-origin: 6px 4.5px;
  transform: rotate(var(--mark-deg)) translateY(calc(-1 * var(--wave-orbit)));
}

.wave-mark-icon {
  display: block;
  width: 12px;
  height: 9px;
  transform: rotate(calc(-1 * var(--mark-deg)));
  transform-origin: 6px 4.5px;
}

.wave-mark.is-active {
  opacity: 1;
  color: var(--lcd-glow);
  filter: drop-shadow(0 0 3px rgba(255, 200, 120, 0.85));
}

.pot-dial--waveform {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0;
  z-index: 1;
}

.pot-dial--waveform .pot-pointer {
  height: 34%;
  top: 12%;
}

/* —— Piano —— */

.piano {
  position: relative;
  width: 100%;
  margin-top: 0;
  padding-top: 0;
  background: #120e0a;
  user-select: none;
  touch-action: none;
  overflow-x: hidden;
}

.piano-whites {
  display: flex;
  position: relative;
  z-index: 1;
  height: 9rem;
  border-top: none;
}

.piano-blacks {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  height: 58%;
  pointer-events: none;
}

.piano-key {
  position: relative;
  padding: 0;
  margin: 0;
  cursor: pointer;
  border: none;
  font: inherit;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.piano-key--white {
  flex: 1 1 0;
  min-width: 0;
  background: linear-gradient(180deg, #faf6f0 0%, #ebe4d8 50%, #d4cbb8 100%);
  border-right: 1px solid #a89888;
  border-radius: 0 0 7px 7px;
  box-shadow:
    inset 0 -3px 0 #c4b8a4,
    0 2px 4px rgba(0, 0, 0, 0.2);
}

.piano-key--white:last-child {
  border-right: none;
}

.piano-key--black {
  position: absolute;
  top: 0;
  height: 100%;
  pointer-events: auto;
  transform: translateX(-50%);
  border-radius: 0 0 4px 4px;
  background: linear-gradient(180deg, #2a2a2a 0%, #121212 55%, #050505 100%);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.65),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06);
}

.piano-key-label {
  position: absolute;
  left: 0;
  right: 0;
  font-family: var(--font-silk);
  line-height: 1.1;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 1px;
}

.piano-key--unavailable {
  opacity: 0.28;
  cursor: not-allowed;
  pointer-events: none;
}

.piano-key--white.piano-key--unavailable {
  background: linear-gradient(180deg, #d8d4cc 0%, #c8c4bc 72%, #b8b4ac 100%);
}

.piano-key--black.piano-key--unavailable {
  background: linear-gradient(180deg, #2a2828 0%, #1a1818 55%, #0a0808 100%);
}

.piano-key--white.piano-key--chord-degree {
  background: linear-gradient(180deg, #f8f2e8 0%, #ebe4d8 72%, #ddd4c4 100%);
  box-shadow:
    inset 0 2px 0 rgba(255, 184, 77, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

.piano-key-label--white {
  bottom: 0.35rem;
  font-size: 10px;
  font-weight: 600;
  color: #3d3528;
}

.piano-key--chord-degree .piano-key-label--white {
  font-size: 11px;
  font-weight: 700;
  color: #8a5a18;
}

.piano-key--black.piano-key--chord-degree {
  background: linear-gradient(180deg, #3a3028 0%, #1a1510 55%, #080604 100%);
  box-shadow:
    inset 0 2px 0 rgba(200, 160, 100, 0.25),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

.piano-key--borrowed .piano-key-label--black {
  font-size: 8px;
  font-weight: 600;
  color: #c9a86a;
}

.piano-key-label--black {
  bottom: 0.22rem;
  font-size: 9px;
  font-weight: 500;
  color: #e8dcc8;
}

/* --key-vel: 0.05 (soft) … 1 (forte), set from MIDI / pointer pressure */
.piano-key--white.is-down {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, #fff0d0 calc(var(--key-vel, 0.78) * 100%), #ebe4d8) 0%,
    color-mix(in srgb, #ffb84d calc(var(--key-vel, 0.78) * 100%), #d4cbb8) 42%,
    color-mix(in srgb, #c97b20 calc(var(--key-vel, 0.78) * 100%), #b0a090) 100%
  );
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, #8a5a18 calc(var(--key-vel, 0.78) * 100%), transparent),
    0 0 calc(10px * var(--key-vel, 0.78)) rgba(255, 184, 77, calc(0.2 + 0.45 * var(--key-vel, 0.78)));
}

.piano-key--white.is-down .piano-key-label {
  color: color-mix(in srgb, #4a3010 calc(var(--key-vel, 0.78) * 100%), #5c5040);
}

.piano-key--black.is-down {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, #b89870 calc(var(--key-vel, 0.78) * 100%), #2a2a2a) 0%,
    color-mix(in srgb, #6a5848 calc(var(--key-vel, 0.78) * 100%), #121212) 48%,
    color-mix(in srgb, #3a3028 calc(var(--key-vel, 0.78) * 100%), #050505) 100%
  );
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--midi-led) calc(var(--key-vel, 0.78) * 100%), transparent),
    0 0 calc(8px * var(--key-vel, 0.78)) rgba(255, 184, 77, calc(0.15 + 0.4 * var(--key-vel, 0.78)));
}

.piano-key--black.is-down .piano-key-label {
  color: color-mix(in srgb, #fff0d8 calc(var(--key-vel, 0.78) * 100%), #c8c0b0);
}

.piano-key:focus-visible {
  outline: 2px solid var(--midi-led);
  outline-offset: -2px;
}

/* —— Footer help —— */

.midi-help {
  margin-top: 0.75rem;
  font-size: 11px;
  color: var(--silk-dim);
  border: 1px solid #3a332c;
  border-radius: 4px;
  padding: 0.45rem 0.65rem;
  background: #1a1510;
}

.midi-help summary {
  cursor: pointer;
  color: var(--silk);
}

.midi-help-body ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}
