:root {
  --bg-top: #f4dd96;
  --bg-bottom: #d6842e;
  --panel: rgba(33, 24, 18, 0.88);
  --panel-soft: rgba(75, 56, 37, 0.88);
  --trim: #f6d778;
  --trim-shadow: #b8761f;
  --accent: #ff5f2e;
  --accent-soft: #ffc261;
  --text: #fff7de;
  --muted: rgba(255, 247, 222, 0.72);
  --white-key: #fff9e8;
  --black-key: #2b221b;
  --white-key-active: #ffcb5a;
  --black-key-active: #ff8746;
  --danger: #d43e24;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(255, 244, 204, 0.65), transparent 38%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next Condensed", "Futura", "Trebuchet MS", sans-serif;
  font-size: 14px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(82, 44, 16, 0.25), rgba(46, 19, 5, 0.45)),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.03) 0,
      rgba(255, 255, 255, 0.03) 3px,
      transparent 3px,
      transparent 10px
    );
}

button,
kbd,
output,
label {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100vw - 24px));
  margin: 12px auto;
  padding: 14px;
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(98, 55, 24, 0.96), rgba(27, 18, 12, 0.96)),
    radial-gradient(circle at right top, rgba(255, 208, 95, 0.15), transparent 35%);
  box-shadow:
    0 30px 80px rgba(32, 13, 2, 0.35),
    inset 0 1px 0 rgba(255, 251, 230, 0.12);
}

.hero,
.synth-panel,
.keyboard-panel,
.demo-panel {
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(40, 28, 20, 0.92), rgba(22, 15, 10, 0.94));
  border: 1px solid rgba(255, 226, 149, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.hero {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 14px;
}

.hero-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.hero-scope {
  flex: 0 0 360px;
  max-width: 360px;
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: var(--accent-soft);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.9rem, 3.4vw, 3rem);
  line-height: 0.92;
}

h2 {
  font-size: clamp(1.15rem, 1.8vw, 1.55rem);
}

.lede {
  margin: 6px 0 0;
  max-width: 58ch;
  font-size: 0.92rem;
  line-height: 1.35;
  color: var(--muted);
}

.power-button,
.toggle-button,
.wave-button {
  border: 0;
  border-radius: 999px;
  color: #20150f;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  font-size: 0.78rem;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.power-button:disabled,
.toggle-button:disabled,
.wave-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
  box-shadow: none;
}

.power-button {
  padding: 11px 18px;
  background: linear-gradient(180deg, #fff3c4, #f2b73c);
  box-shadow: 0 12px 30px rgba(240, 153, 33, 0.25);
}

.power-button:hover,
.toggle-button:hover,
.wave-button:hover {
  transform: translateY(-1px);
}

.synth-panel {
  padding: 14px;
  margin-bottom: 14px;
}

.panel-top,
.utility-row,
.keyboard-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.panel-top {
  align-items: center;
  margin-bottom: 14px;
}

.brand-tag {
  margin: 0 0 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.78rem;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(255, 219, 126, 0.08);
  border: 1px solid rgba(255, 219, 126, 0.18);
  color: var(--accent-soft);
  font-size: 0.8rem;
}

.wave-selector {
  display: inline-flex;
  gap: 8px;
}

.wave-button,
.toggle-button {
  min-height: 34px;
  padding: 0 13px;
  background: linear-gradient(180deg, #ffe8a5, #e0a73b);
}

.wave-button.active,
.toggle-button.active {
  background: linear-gradient(180deg, #fff7d5, #ffb347);
  box-shadow: 0 0 0 1px rgba(255, 191, 80, 0.35), 0 8px 22px rgba(255, 145, 36, 0.25);
}

.toggle-button.danger {
  background: linear-gradient(180deg, #f7b38a, #d25a34);
  color: #fff7de;
}

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

.knob-card {
  padding: 10px 8px 10px;
  border-radius: 16px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(98, 72, 46, 0.4), rgba(54, 39, 26, 0.18)),
    rgba(255, 255, 255, 0.01);
}

.knob-card label,
.knob-card output {
  display: block;
}

.knob-card label {
  margin-top: 7px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: 0.74rem;
}

.knob-card output {
  margin-top: 4px;
  color: var(--accent-soft);
  font-size: 0.76rem;
}

.knob {
  --rotation: -132deg;
  width: 78px;
  height: 78px;
  margin: 0 auto;
  touch-action: none;
  cursor: ns-resize;
}

.knob-face {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #786652, #2f231a 70%),
    linear-gradient(180deg, #67523c, #221811);
  border: 3px solid #1f1711;
  box-shadow:
    inset 0 2px 8px rgba(255, 255, 255, 0.08),
    inset 0 -8px 12px rgba(0, 0, 0, 0.45),
    0 10px 18px rgba(0, 0, 0, 0.22);
}

.knob-indicator {
  position: absolute;
  left: 50%;
  top: 10px;
  width: 4px;
  height: 25px;
  margin-left: -2px;
  border-radius: 99px;
  background: linear-gradient(180deg, #ffedb0, #ff7840);
  box-shadow: 0 0 12px rgba(255, 126, 58, 0.35);
  transform-origin: 50% 29px;
  transform: rotate(var(--rotation));
}

.utility-row {
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

#oscilloscope {
  display: block;
  width: 100%;
  height: 86px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(11, 17, 18, 0.95), rgba(16, 29, 25, 0.96)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 198, 92, 0.06) 0,
      rgba(255, 198, 92, 0.06) 1px,
      transparent 1px,
      transparent 48px
    );
  border: 1px solid rgba(255, 219, 126, 0.14);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    inset 0 12px 26px rgba(0, 0, 0, 0.28);
}

.keyboard-panel {
  padding: 14px;
}

.demo-panel {
  padding: 14px;
  margin-top: 14px;
}

.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.demo-lockout {
  display: none;
  margin: 0 0 10px;
  padding: 9px 11px;
  border-radius: 12px;
  background: rgba(255, 186, 100, 0.12);
  border: 1px solid rgba(255, 205, 132, 0.18);
  color: var(--accent-soft);
  line-height: 1.45;
}

.demo-lockout.active {
  display: block;
}

.demo-steps {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}

.demo-step {
  padding: 7px 4px;
  border-radius: 10px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(97, 71, 45, 0.38), rgba(47, 34, 24, 0.52)),
    rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 219, 126, 0.08);
  transition: transform 90ms ease, box-shadow 90ms ease, background 90ms ease;
}

.demo-step.active {
  transform: translateY(-2px);
  background:
    linear-gradient(180deg, rgba(255, 212, 111, 0.38), rgba(202, 109, 37, 0.58)),
    rgba(255, 255, 255, 0.04);
  box-shadow: 0 10px 20px rgba(255, 126, 58, 0.18);
}

.demo-step.is-rest {
  opacity: 0.6;
}

.demo-step-index,
.demo-step-flags,
.demo-step-note {
  display: block;
}

.demo-step-index {
  margin-bottom: 3px;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.demo-step-note {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.demo-step-flags {
  margin-top: 3px;
  font-size: 0.58rem;
  color: var(--accent-soft);
  letter-spacing: 0.08em;
  min-height: 1em;
}

.demo-label {
  display: inline-block;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
  font-size: 0.76rem;
}

.demo-data {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 219, 126, 0.12);
  background: rgba(18, 20, 16, 0.82);
  color: var(--text);
  font: 12px/1.35 "SFMono-Regular", "Consolas", monospace;
}

.demo-data:focus {
  outline: 2px solid rgba(255, 192, 91, 0.38);
  outline-offset: 2px;
}

.keyboard-panel.demo-locked {
  position: relative;
}

.keyboard-panel.demo-locked .keyboard {
  opacity: 0.5;
}

.keyboard-panel.demo-locked .instructions::after {
  content: " Live keyboard is disabled while the demo is playing.";
  color: var(--accent-soft);
}

.keyboard-header {
  align-items: end;
  margin-bottom: 10px;
}

.instructions {
  max-width: 30rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.instructions p {
  margin: 0;
}

.instructions p + p {
  margin-top: 4px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  min-height: 1.35rem;
  padding: 0 0.28rem;
  border-radius: 6px;
  background: rgba(255, 251, 230, 0.12);
  border: 1px solid rgba(255, 240, 198, 0.18);
  font-size: 0.74rem;
  color: var(--text);
}

.keyboard-wrap {
  overflow: hidden;
  height: 202px;
}

.keyboard {
  position: relative;
  width: 1120px;
  height: 270px;
  padding: 16px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(88, 64, 42, 0.85), rgba(31, 23, 17, 0.85)),
    radial-gradient(circle at center, rgba(255, 227, 143, 0.12), transparent 45%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transform: scale(0.74);
  transform-origin: top left;
}

.white-key,
.black-key {
  position: absolute;
  user-select: none;
  -webkit-user-select: none;
  border: 0;
  cursor: pointer;
  transition: transform 60ms ease, background 100ms ease, box-shadow 100ms ease;
}

.white-key {
  width: 60px;
  height: 220px;
  top: 20px;
  border-radius: 0 0 16px 16px;
  background: linear-gradient(180deg, #fffdf4, #efe2bf 72%, #dbc48f);
  box-shadow: inset 0 0 0 1px rgba(53, 35, 21, 0.2), 0 12px 18px rgba(0, 0, 0, 0.16);
}

.white-key.active {
  background: linear-gradient(180deg, #fff0b6, var(--white-key-active) 72%, #e29431);
  transform: translateY(2px);
}

.black-key {
  width: 38px;
  height: 136px;
  top: 20px;
  border-radius: 0 0 12px 12px;
  background: linear-gradient(180deg, #56473b, var(--black-key));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 10px 16px rgba(0, 0, 0, 0.24);
  z-index: 2;
}

.black-key.active {
  background: linear-gradient(180deg, #ffb470, var(--black-key-active));
  transform: translateY(2px);
}

.key-label,
.key-note {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-transform: uppercase;
  pointer-events: none;
}

.key-note {
  bottom: 14px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: rgba(32, 21, 15, 0.75);
}

.black-key .key-note {
  color: rgba(255, 250, 238, 0.8);
}

.key-label {
  top: 12px;
  padding: 0.2rem 0.35rem;
  border-radius: 999px;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  background: rgba(255, 180, 88, 0.14);
  color: rgba(32, 21, 15, 0.82);
}

.black-key .key-label {
  color: rgba(255, 247, 222, 0.82);
  background: rgba(255, 219, 144, 0.12);
}

.key-octave-active {
  box-shadow: inset 0 0 0 2px rgba(255, 160, 64, 0.5), 0 12px 18px rgba(0, 0, 0, 0.16);
}

.black-key.key-octave-active {
  box-shadow: inset 0 0 0 2px rgba(255, 178, 92, 0.55), 0 10px 16px rgba(0, 0, 0, 0.24);
}

@media (min-width: 1100px) {
  .app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.36fr) minmax(360px, 0.94fr);
    gap: 14px;
    align-items: start;
  }

  .hero {
    grid-column: 1 / -1;
    margin-bottom: 0;
  }

  .synth-panel {
    grid-column: 1;
    grid-row: 2 / span 2;
    margin-bottom: 0;
  }

  .keyboard-panel {
    grid-column: 2;
    grid-row: 2;
  }

  .demo-panel {
    grid-column: 2;
    grid-row: 3;
    margin-top: 0;
  }
}

@media (max-width: 980px) {
  .hero,
  .panel-top,
  .keyboard-header {
    flex-direction: column;
    align-items: start;
  }

  .hero-scope {
    width: 100%;
    max-width: none;
    flex: 1 1 auto;
  }

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

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

  .keyboard-wrap {
    overflow-x: auto;
    height: auto;
    padding-bottom: 8px;
  }

  .keyboard {
    transform: none;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1220px);
    margin: 10px auto;
    padding: 12px;
    border-radius: 22px;
  }

  .hero,
  .synth-panel,
  .keyboard-panel,
  .demo-panel {
    border-radius: 18px;
  }

  .hero,
  .synth-panel,
  .keyboard-panel,
  .demo-panel {
    padding: 16px;
  }

  .control-bank {
    grid-template-columns: 1fr;
  }

  .knob {
    width: 92px;
    height: 92px;
  }

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

  #oscilloscope {
    height: 110px;
  }
}
