:root {
  --bg: #d8d3ca;
  --panel: #1e1e1e;
  --panel-alt: #282828;
  --panel-mid: #323232;
  --screen: #131313;
  --text: #eeeae4;
  --text-dark: #181818;
  --muted: #8a8a8a;
  --muted-dark: #5a5a5a;
  --amber: #e09000;
  --amber-dim: rgba(224,144,0,0.55);
  --red: #cc2020;
  --green: #1aaa3e;
  --blue: #2a88cc;
  --line: rgba(255,255,255,0.09);
  --line-dark: rgba(0,0,0,0.22);
  --shadow: 0 4px 18px rgba(0,0,0,0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  color: var(--text-dark);
  background: linear-gradient(160deg, #c8c3ba 0%, #ddd8cf 45%, #c6c1b8 100%);
  background-attachment: fixed;
}

.app-shell {
  width: min(1150px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 20px 0 48px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Panels ─── */

.hero,
.stage {
  position: relative;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.2);
  overflow: hidden;
}

.hero {
  background: linear-gradient(180deg, #ebe6dd 0%, #e0dbd2 100%);
  box-shadow: 0 3px 12px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.75);
  padding: 28px 32px;
}

/* ─── Typography ─── */

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted-dark);
  font-size: 0.7rem;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  font-weight: 800;
  line-height: 0.92;
  color: var(--text-dark);
  letter-spacing: -0.02em;
  max-width: 10ch;
}

h2 {
  margin: 0;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  line-height: 1;
  color: var(--text-dark);
}

.lede {
  max-width: 580px;
  margin: 14px 0 0;
  color: var(--muted-dark);
  font-size: 0.9rem;
  line-height: 1.55;
}

/* ─── Product badge ─── */

.product-badge {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.badge-brand {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted-dark);
}

.badge-model {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: clamp(2.6rem, 6.5vw, 4.8rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 0.9;
  color: var(--text-dark);
}

.badge-type {
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--amber);
}

/* ─── Pixel visualizer ─── */

.pixel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.pixel-wrap {
  width: min(420px, 100%);
  margin-top: 18px;
}

#pixelCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.28);
  background: #080012;
  image-rendering: pixelated;
}

.pixel-progress-wrap {
  height: 4px;
  background: rgba(0,0,0,0.13);
  border-radius: 2px;
  margin-top: 8px;
  overflow: hidden;
}

.pixel-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5500bb, #cc00ff);
  border-radius: 2px;
  transition: none;
}

/* ─── Transport & RPC controls ─── */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.transport,
.connect-button,
.rpc-input {
  min-height: 44px;
  border-radius: 7px;
  border: 1px solid rgba(0,0,0,0.28);
}

.transport {
  padding: 0 24px;
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(180deg, #eba020 0%, #c88000 100%);
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.22);
  transition: transform 70ms, box-shadow 70ms;
}

.transport:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(0,0,0,0.32), inset 0 1px 0 rgba(255,255,255,0.22);
}

.transport:active {
  transform: translateY(1px);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3), inset 0 2px 4px rgba(0,0,0,0.18);
  background: linear-gradient(180deg, #c88000 0%, #a86800 100%);
}

.rpc-controls {
  display: flex;
  flex: 1 1 380px;
  gap: 8px;
}

.rpc-input {
  flex: 1 1 260px;
  min-width: 180px;
  padding: 0 16px;
  font: inherit;
  font-size: 0.88rem;
  color: var(--text-dark);
  background: rgba(0,0,0,0.06);
  border-color: rgba(0,0,0,0.18);
}

.rpc-input::placeholder {
  color: rgba(0,0,0,0.32);
}

.connect-button {
  padding: 0 16px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dark);
  background: linear-gradient(180deg, #ddd8cf 0%, #b8b3aa 100%);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.16), inset 0 1px 0 rgba(255,255,255,0.75);
  letter-spacing: 0.04em;
}

.connect-button:hover {
  background: linear-gradient(180deg, #ece7de 0%, #c8c3ba 100%);
}

/* ─── Stats readouts ─── */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
}

.stats article {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid rgba(0,0,0,0.5);
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.4);
}

.label {
  display: block;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 3px;
}

.stats strong {
  font-size: 0.98rem;
  color: var(--amber);
  font-family: "Courier New", Courier, monospace;
  font-weight: 700;
}

.connection-status {
  margin: 12px 0 0;
  color: var(--muted-dark);
  font-size: 0.8rem;
}

/* ─── FX cards (dark panels) ─── */

.fx-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 0;
}

.fx-card {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.55);
  background: var(--panel);
  box-shadow: inset 0 2px 7px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.06);
}

.fx-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.fx-card strong,
.drum-card strong {
  color: var(--amber);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.84rem;
}

/* fader handle style for all sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: #3a3a3a;
  outline: none;
  cursor: pointer;
  margin: 4px 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 24px;
  border-radius: 3px;
  background: linear-gradient(180deg, #d4d0ca 0%, #9e9a95 100%);
  border: 1px solid rgba(0,0,0,0.38);
  box-shadow: 0 2px 5px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.55);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 24px;
  border-radius: 3px;
  background: linear-gradient(180deg, #d4d0ca 0%, #9e9a95 100%);
  border: 1px solid rgba(0,0,0,0.38);
  box-shadow: 0 2px 5px rgba(0,0,0,0.45);
  cursor: pointer;
}

.fx-card p {
  margin: 8px 0 0;
  color: #5a5a5a;
  font-size: 0.68rem;
  line-height: 1.4;
}

/* ─── Drum controls ─── */

.drum-master-panel {
  margin-top: 16px;
}

.drum-master-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.drum-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.drum-card {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.55);
  background: var(--panel);
  box-shadow: inset 0 2px 7px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.06);
}

.drum-control {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
}

/* ─── Visualiser canvas ─── */

#visualCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ─── Stage (dark screen) ─── */

.stage {
  background: var(--screen);
  min-height: 460px;
  display: grid;
  place-items: center;
  padding: 24px;
  border-color: rgba(0,0,0,0.6);
  box-shadow: inset 0 4px 20px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.3);
}

.rings {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(224,144,0,0.07);
}

.ring-a {
  width: min(70vw, 540px);
  height: min(70vw, 540px);
}

.ring-b {
  width: min(54vw, 400px);
  height: min(54vw, 400px);
}

.ring-c {
  width: min(40vw, 290px);
  height: min(40vw, 290px);
}

.core {
  display: none;
}

.event-popups {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 3;
  display: grid;
  gap: 8px;
  width: min(270px, calc(100% - 40px));
  pointer-events: none;
}

.event-popup {
  padding: 10px 12px;
  border: 1px solid rgba(224,144,0,0.28);
  border-radius: 8px;
  background: rgba(19,19,19,0.92);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(-6px);
  animation: popup-in 200ms ease forwards, popup-out 280ms ease 2.6s forwards;
}

.event-popup strong {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
}

.event-popup span {
  display: block;
  margin-top: 3px;
  color: rgba(255,255,255,0.7);
  font-size: 0.82rem;
  line-height: 1.35;
}

@keyframes popup-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes popup-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-4px); }
}


.lane-grid {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 20px;
  display: grid;
  gap: 10px;
  z-index: 2;
}

.lane {
  display: grid;
  gap: 7px;
}

.lane span {
  color: rgba(224,144,0,0.45);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.64rem;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.hat-steps {
  grid-template-columns: repeat(16, minmax(0, 1fr));
}

.step {
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.05);
  background: rgba(255,255,255,0.025);
  display: grid;
  place-items: center;
  color: rgba(255,255,255,0.18);
  font-size: 0.76rem;
  transition: transform 80ms linear, background 80ms linear, border-color 80ms linear;
}

.step.active {
  transform: translateY(-2px);
  color: var(--text);
}

.step.kick.active {
  background: rgba(224,144,0,0.18);
  border-color: rgba(224,144,0,0.5);
}

.step.snare.active {
  background: rgba(204,34,34,0.18);
  border-color: rgba(204,34,34,0.5);
}

.step.hihat.active {
  background: rgba(26,170,62,0.18);
  border-color: rgba(26,170,62,0.5);
}

.step.offbeat.active {
  background: rgba(42,136,204,0.18);
  border-color: rgba(42,136,204,0.5);
}

/* ─── Sequencer panels ─── */

.sequencer-panel {
  padding: 24px 28px;
}

.sequencer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.sequencer-toggles {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  min-height: 40px;
  border-radius: 7px;
  border: 1px solid rgba(0,0,0,0.2);
  background: rgba(0,0,0,0.06);
  color: var(--text-dark);
  font-size: 0.82rem;
  cursor: pointer;
}

.toggle input {
  accent-color: var(--amber);
  cursor: pointer;
}

.sequencer-copy {
  margin-bottom: 14px;
  font-size: 0.88rem;
}

.sequencer-grid {
  display: grid;
  grid-template-columns: 64px repeat(16, minmax(0, 1fr));
  gap: 2px;
  width: 100%;
}

.note-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  color: var(--muted-dark);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  min-height: 20px;
  border-radius: 4px;
}

.roll-cell,
.note-label {
  min-height: 20px;
  border-radius: 4px;
}

.roll-cell {
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.04);
  cursor: pointer;
  transition: background 80ms, border-color 80ms, transform 80ms;
}

.roll-cell.bar-line {
  border-left-color: rgba(224,144,0,0.42);
}

.roll-cell.beat-line {
  border-left-color: rgba(0,0,0,0.18);
}

.roll-cell.active {
  background: linear-gradient(180deg, rgba(224,144,0,0.52), rgba(192,100,0,0.36));
  border-color: rgba(224,144,0,0.68);
}

.roll-cell.active.run-r {
  position: relative;
  z-index: 1;
  width: calc(100% + 3px);
  border-radius: 4px 0 0 4px;
  border-right-color: transparent;
}

.roll-cell.active.run-l {
  border-radius: 0 4px 4px 0;
  border-left-color: transparent;
}

.roll-cell.active.run-r.run-l {
  border-radius: 0;
}

.roll-cell.playhead {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(26,170,62,0.88);
}

.bass-grid .roll-cell.active {
  background: linear-gradient(180deg, rgba(42,136,204,0.48), rgba(26,170,62,0.32));
  border-color: rgba(42,136,204,0.62);
}

.bass-grid .roll-cell.active.run-r {
  border-right-color: transparent;
}

.bass-grid .roll-cell.active.run-l {
  border-left-color: transparent;
}

/* ─── Synth voice ─── */

.synth-fx-panel {
  margin-bottom: 16px;
}

.synth-voice-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.waveform-selector {
  flex: 1;
  display: flex;
  gap: 5px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.55);
  background: var(--panel);
  box-shadow: inset 0 2px 7px rgba(0,0,0,0.45);
}

.wave-btn {
  flex: 1;
  padding: 7px 0;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.03);
  color: var(--muted);
  font: inherit;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 100ms, color 100ms, border-color 100ms;
}

.wave-btn.active {
  background: rgba(224,144,0,0.14);
  border-color: rgba(224,144,0,0.48);
  color: var(--amber);
}

.wave-btn:hover:not(.active) {
  background: rgba(255,255,255,0.07);
  color: var(--text);
}

.dynamics-card {
  flex-shrink: 0;
  width: 170px;
}

/* ─── Bass controls ─── */

.bass-controls-panel {
  margin-bottom: 16px;
}

.bass-controls-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

/* ─── Responsive ─── */

@media (max-width: 840px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fx-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bass-controls-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drum-master-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drum-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bass-controls-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stage {
    min-height: 560px;
  }

  .core {
    width: min(58vw, 240px);
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100vw - 16px, 100%);
    padding: 10px 0 24px;
  }

  .rpc-controls {
    flex-direction: column;
  }

  .hero,
  .stage {
    border-radius: 10px;
  }

  .hero {
    padding: 18px 20px;
  }

  .sequencer-panel {
    padding: 18px 20px;
  }

  .sequencer-grid {
    grid-template-columns: 52px repeat(16, minmax(0, 1fr));
  }

  .note-label,
  .roll-cell {
    min-height: 16px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fx-panel,
  .drum-master-grid,
  .drum-panel,
  .bass-controls-grid {
    grid-template-columns: 1fr;
  }

  .stage {
    min-height: 520px;
    padding: 16px;
  }

  .event-popups {
    top: 16px;
    right: 16px;
    left: 16px;
    width: auto;
  }

  .lane-grid {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .steps {
    gap: 5px;
  }

  .hat-steps {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .step {
    min-height: 36px;
  }

  .synth-voice-row {
    flex-direction: column;
  }

  .dynamics-card {
    width: auto;
  }
}
