* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

  /* ─── Accessibility utilities ─── */
  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Skip navigation link */
  .skip-link {
    position: absolute;
    top: -999px;
    left: 8px;
    z-index: 9999;
    padding: 8px 16px;
    background: #00e5ff;
    color: #1a1a3e;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 14px;
    border-radius: 4px;
    text-decoration: none;
  }
  .skip-link:focus {
    top: 8px;
  }

  /* Global visible focus ring */
  :focus-visible {
    outline: 2px solid #00e5ff;
    outline-offset: 2px;
  }
  /* Remove outline for mouse users */
  :focus:not(:focus-visible) {
    outline: none;
  }
  /* Respect reduced motion preference */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }
  html {
    overflow: hidden;
    height: 100%;
  }
  body {
    background: #1a1a3e;
    font-family: 'Courier New', monospace;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    height: 100%;
    color: #e8e8ff;
    user-select: none;
    padding: 0;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  #synth {
    background: linear-gradient(180deg, #1a1a40 0%, #111135 40%, #1a1a40 100%);
    border: 3px solid #0088bb;
    border-radius: 16px;
    padding: 30px 40px 40px;
    box-shadow: 0 10px 60px rgba(5,5,30,0.7), 0 0 30px rgba(0,136,187,0.1), inset 0 1px 0 rgba(100,140,255,0.08);
    width: 100%;
    max-width: 960px;
    position: relative;
  }

  #synth-header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 2px solid #0088bb;
    padding-bottom: 12px;
  }
  #synth-header h1 {
    font-size: 30px;
    letter-spacing: 12px;
    text-transform: uppercase;
    color: #ffffff;
    text-shadow: 0 0 14px rgba(0,229,255,0.5), 0 0 30px rgba(0,229,255,0.2);
    position: relative;
    display: inline-block;
  }
  #synth-header .sub {
    font-size: 12px;
    letter-spacing: 6px;
    color: #b0c0ff;
    margin-top: 4px;
  }

  /* Control Panel */
  #controls {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    justify-content: center;
  }
  .control-group {
    background: linear-gradient(180deg, rgba(5,10,30,0.65) 0%, rgba(10,15,40,0.6) 100%);
    border: 2px solid #0099cc;
    border-radius: 8px;
    padding: 10px 14px;
    min-width: 100px;
    text-align: center;
    box-shadow: 0 0 14px rgba(0,229,255,0.06), inset 0 1px 0 rgba(0,229,255,0.05);
  }
  .control-group h3 {
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #00e5ff;
    margin-bottom: 8px;
  }
  .knob-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
  }
  .knob-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
  }
  .knob-container label {
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #b0c0ff;
  }
  .knob {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #7070cc, #3a3580);
    border: 2px solid #5555a0;
    position: relative;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(20,20,60,0.4);
  }
  .knob::after {
    content: '';
    position: absolute;
    width: 3px;
    height: 16px;
    background: #ffffff;
    top: 4px;
    left: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(var(--rotation, 0deg));
    border-radius: 2px;
  }
  .knob-value {
    font-size: 12px;
    color: #00e5ff;
  }

  /* Waveform selector */
  .wave-btns {
    display: flex;
    gap: 6px;
    justify-content: center;
  }
  .wave-btn {
    width: 40px;
    height: 32px;
    background: rgba(5,10,30,0.7);
    border: 1px solid #0088aa;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  }
  .wave-btn.active {
    background: #253a70;
    border-color: #00e5ff;
    box-shadow: 0 0 8px rgba(0,229,255,0.3);
  }
  .wave-btn svg { width: 22px; height: 16px; }
  .wave-btn svg path { stroke: #b0c0ff; stroke-width: 1.5; fill: none; }
  .wave-btn.active svg path { stroke: #ffffff; }

  /* LED indicator */
  #led {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #2a1060;
    box-shadow: none;
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    transition: background 0.1s, box-shadow 0.1s;
    will-change: background, box-shadow;
  }
  #led.on {
    background: #00e5ff;
    box-shadow: 0 0 8px #00e5ff, 0 0 20px rgba(0,229,255,0.5);
  }

  /* Octave display */
  #octave-display {
    text-align: center;
    margin-top: 12px;
    font-size: 14px;
    color: #00e5ff;
    letter-spacing: 3px;
  }
  .octave-btn {
    background: rgba(5,10,30,0.6);
    border: 1px solid #0088aa;
    border-radius: 4px;
    color: #b0c0ff;
    font-size: 14px;
    padding: 6px 14px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s, color 0.15s;
    vertical-align: middle;
    display: none;
  }
  .octave-btn:hover {
    border-color: #00e5ff;
    color: #00e5ff;
  }
  #octave-display span {
    display: inline-block;
    background: rgba(5,10,30,0.6);
    border: 1px solid #0088aa;
    border-radius: 4px;
    padding: 4px 12px;
    min-width: 60px;
  }

  /* Live track octave controls */
  .live-oct-ctrl {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-right: 6px;
    flex-shrink: 0;
  }
  .live-oct-btn {
    background: rgba(5,10,30,0.6);
    border: 1px solid #0088aa;
    border-radius: 3px;
    color: #b0c0ff;
    font-size: 11px;
    padding: 2px 5px;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
    transition: border-color 0.15s, color 0.15s;
  }
  .live-oct-btn:hover {
    border-color: #00e5ff;
    color: #00e5ff;
  }
  .live-oct-val {
    font-size: 11px;
    color: #00e5ff;
    min-width: 18px;
    text-align: center;
  }

  /* Track Selector */
  #track-selector {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
  }
  .track-sel-btn {
    padding: 8px 20px;
    background: rgba(5,10,30,0.6);
    border: 1px solid #006699;
    border-radius: 6px;
    color: #b0c0ff;
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s, box-shadow 0.2s;
    font-family: inherit;
  }
  .track-sel-btn:hover {
    border-color: #99aaee;
    color: #00e5ff;
  }
  .track-sel-btn.active {
    border-color: #00e5ff;
    color: #ffffff;
    background: rgba(0,229,255,0.12);
    box-shadow: 0 0 10px rgba(0,229,255,0.15);
  }
  /* Per-track color tints */
  .track-tint-0 .control-group,
  .track-tint-0 .fx-group { border-color: #3d3878; }
  .track-tint-0 .track-sel-btn.active { border-color: #00e5ff; background: rgba(0,229,255,0.12); }

  .track-tint-1 .control-group,
  .track-tint-1 .fx-group { border-color: #552050; }
  .track-tint-1 .control-group { background: rgba(255,45,120,0.12); }
  .track-tint-1 .fx-group { background: rgba(255,45,120,0.15); }
  .track-tint-1 .track-sel-btn.active { border-color: #ff2d78; background: rgba(255,45,120,0.15); color: #ffb5d5; }

  .track-tint-2 .control-group,
  .track-tint-2 .fx-group { border-color: #184a25; }
  .track-tint-2 .control-group { background: rgba(57,255,20,0.12); }
  .track-tint-2 .fx-group { background: rgba(57,255,20,0.15); }
  .track-tint-2 .track-sel-btn.active { border-color: #39ff14; background: rgba(57,255,20,0.15); color: #ccffbb; }

  .track-tint-3 .control-group,
  .track-tint-3 .fx-group { border-color: #352075; }
  .track-tint-3 .control-group { background: rgba(180,77,255,0.12); }
  .track-tint-3 .fx-group { background: rgba(180,77,255,0.15); }
  .track-tint-3 .track-sel-btn.active { border-color: #b44dff; background: rgba(180,77,255,0.15); color: #ddb5ff; }

  /* Effects Section */
  #effects {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    justify-content: center;
    flex-wrap: wrap;
    background: linear-gradient(180deg, rgba(15,8,40,0.7) 0%, rgba(20,12,50,0.65) 100%);
    border: 2px solid #8050c0;
    border-radius: 10px;
    padding: 14px 12px;
    box-shadow: 0 0 20px rgba(128,80,192,0.1), inset 0 1px 0 rgba(180,100,255,0.06);
  }
  .fx-group {
    background: rgba(10,6,30,0.6);
    border: 1px solid #7060c0;
    border-radius: 8px;
    padding: 8px 10px 10px;
    min-width: 90px;
    text-align: center;
    position: relative;
    box-shadow: 0 0 10px rgba(112,96,192,0.08);
  }
  .fx-group.fx-on {
    border-color: #ff2d78;
    box-shadow: 0 0 18px rgba(255,45,120,0.25);
    background: rgba(40,8,30,0.7);
  }
  .fx-group h3 {
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #ff7eb3;
    margin-bottom: 6px;
  }
  .fx-toggle {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid #5555a0;
    background: #3a3580;
    cursor: pointer;
    position: absolute;
    top: 8px;
    right: 8px;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  }
  .fx-toggle.on {
    background: #ff2d78;
    border-color: #ffb5d5;
    box-shadow: 0 0 8px rgba(255,45,120,0.5);
  }
  .fx-knob-row {
    display: flex;
    gap: 6px;
    justify-content: center;
  }
  .fx-knob-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }
  .fx-knob-container label {
    font-size: 9px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: #a0b0ee;
  }
  .fx-knob-container .knob {
    width: 36px;
    height: 36px;
  }
  .fx-knob-container .knob::after {
    height: 12px;
  }
  .fx-knob-container .knob-value {
    font-size: 11px;
  }

  /* ─── Sequencer Section ─── */
  #recorder {
    background: linear-gradient(180deg, rgba(5,10,30,0.7) 0%, rgba(10,15,40,0.65) 100%);
    border: 2px solid #0099cc;
    border-radius: 10px;
    padding: 14px 20px;
    margin-bottom: 24px;
    box-shadow: 0 0 20px rgba(0,229,255,0.08), inset 0 1px 0 rgba(0,229,255,0.06);
  }
  #recorder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
  }
  #recorder-header h3 {
    font-size: 13px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #00e5ff;
    text-shadow: 0 0 8px rgba(0,229,255,0.4);
  }
  #transport {
    display: flex;
    gap: 8px;
    align-items: center;
  }
  .transport-group {
    display: flex;
    gap: 6px;
    align-items: center;
  }
  .transport-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 2px solid #0099cc;
    background: rgba(5,10,30,0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, box-shadow 0.15s;
    position: relative;
  }
  .transport-btn:hover {
    border-color: #00e5ff;
  }
  .transport-btn.active {
    border-color: #ffffff;
    box-shadow: 0 0 8px rgba(0,229,255,0.3);
  }
  .transport-btn svg { width: 14px; height: 14px; }
  .transport-btn svg path,
  .transport-btn svg rect,
  .transport-btn svg circle { fill: #b0c0ff; }
  .transport-btn:hover svg path,
  .transport-btn:hover svg rect,
  .transport-btn:hover svg circle { fill: #00e5ff; }
  .transport-btn.active svg path,
  .transport-btn.active svg rect { fill: #ffffff; }

  #tracks {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  #master-meter {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(3,6,20,0.75);
    border: 2px solid #0099cc;
    border-radius: 6px;
    margin-top: 6px;
    height: 28px;
    box-shadow: 0 0 10px rgba(0,153,204,0.08);
  }
  #master-meter-label {
    font-size: 11px;
    color: #b0c0ff;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
    width: 42px;
  }
  #master-meter-bar {
    flex: 1;
    height: 10px;
    background: #1e1e48;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    border: 1px solid #3a3580;
  }
  #master-meter-fill {
    height: 100%;
    width: 0%;
    border-radius: 2px;
    background: linear-gradient(to right, #0066aa, #00aacc, #00ddaa, #00ccdd);
    transition: width 0.06s linear;
    will-change: width;
  }
  #master-meter-fill.hot {
    background: linear-gradient(to right, #0066aa, #00aacc, #00ccdd, #ff6644);
  }
  #master-meter-fill.clip {
    background: linear-gradient(to right, #0066aa, #00ddaa, #ff6644, #ff3322);
  }
  #master-meter-peak {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    background: #00e5ff;
    right: 0;
    display: none;
  }
  #master-meter-peak.clip {
    background: #ff3322;
  }
  #master-clip-indicator {
    font-size: 10px;
    font-weight: bold;
    color: #3d3878;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
    border-radius: 3px;
    padding: 1px 0;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: 'Courier New', monospace;
  }
  #master-clip-indicator.clip {
    color: #ff3322;
    text-shadow: 0 0 4px rgba(255,50,30,0.5);
  }
  #master-vol {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #3a3580;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    flex-shrink: 0;
  }
  #master-vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 18px;
    background: #b0c0ff;
    border-radius: 3px;
    cursor: pointer;
  }
  #master-vol::-webkit-slider-thumb:hover { background: #00e5ff; }
  #master-vol-val {
    font-size: 10px;
    color: #99aaee;
    min-width: 18px;
    text-align: right;
    flex-shrink: 0;
  }
  #master-db {
    font-size: 10px;
    color: #99aaee;
    min-width: 38px;
    text-align: right;
    flex-shrink: 0;
    font-family: monospace;
  }
  .track {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(5,8,25,0.7);
    border: 1px solid #006688;
    border-radius: 6px;
    padding: 6px 10px;
    min-height: 40px;
    box-shadow: 0 0 8px rgba(0,102,136,0.06);
  }
  .track.has-data {
    border-color: #4050aa;
  }
  .track-label {
    font-size: 13px;
    font-weight: bold;
    color: #b0c0ff;
    min-width: 16px;
    letter-spacing: 1px;
  }
  .track-mute, .track-solo {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 4px 8px;
    border: 1px solid #005577;
    border-radius: 3px;
    background: rgba(5,10,30,0.7);
    color: #99aaee;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
  }
  .track-mute.on { background: #253a70; color: #00e5ff; border-color: #00e5ff; }
  .track-solo.on { background: #1a5530; color: #39ff14; border-color: #39ff14; }
  .track-clear {
    font-size: 10px;
    padding: 4px 8px;
    border: 1px solid #005577;
    border-radius: 3px;
    background: rgba(5,10,30,0.7);
    color: #99aaee;
    cursor: pointer;
    flex-shrink: 0;
  }
  .track-clear:hover { color: #ff6644; border-color: #ff6644; }
  .track-vol {
    width: 48px;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: #3a3580;
    border-radius: 2px;
    outline: none;
    flex-shrink: 0;
  }
  .track-vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 18px;
    background: #b0c0ff;
    border-radius: 3px;
    cursor: pointer;
  }
  .track-vol::-webkit-slider-thumb:hover { background: #00e5ff; }
  .track-vol-val {
    font-size: 10px;
    color: #99aaee;
    min-width: 20px;
    text-align: center;
    flex-shrink: 0;
  }

  /* ─── Step Grid ─── */
  .step-grid {
    display: flex;
    gap: 2px;
    flex: 1;
  }
  .step-cell {
    flex: 1;
    height: 32px;
    min-width: 0;
    background: rgba(8,12,35,0.6);
    border: 1px solid #2a2a60;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s, box-shadow 0.1s;
    position: relative;
    touch-action: manipulation;
    will-change: background, border-color;
  }
  .step-cell:hover {
    border-color: #00bbdd;
    background: rgba(0,180,220,0.1);
  }
  .step-cell .step-note {
    font-size: 10px;
    color: #6060aa;
    letter-spacing: 0.5px;
    font-family: 'Courier New', monospace;
    pointer-events: none;
  }
  .step-cell.has-note {
    background: rgba(0,229,255,0.25);
    border-color: #00aadd;
  }
  .step-cell.has-note .step-note {
    color: #ffffff;
    font-weight: bold;
    text-shadow: 0 0 4px rgba(0,229,255,0.4);
  }
  .step-cell.playing {
    border-color: #00e5ff;
    box-shadow: 0 0 10px rgba(0,229,255,0.5);
  }
  .step-cell.playing.has-note {
    background: rgba(0,229,255,0.5);
  }
  .step-cell.beat-start {
    border-left: 2px solid #0088aa;
  }
  /* Per-track step colors */
  .track[data-track="1"] .step-cell.has-note {
    background: rgba(255,45,120,0.3);
    border-color: #cc2060;
  }
  .track[data-track="1"] .step-cell.has-note .step-note { color: #ffccdf; text-shadow: 0 0 4px rgba(255,45,120,0.4); }
  .track[data-track="1"] .step-cell.playing { border-color: #ff2d78; box-shadow: 0 0 10px rgba(255,45,120,0.5); }
  .track[data-track="1"] .step-cell.playing.has-note { background: rgba(255,45,120,0.5); }

  .track[data-track="2"] .step-cell.has-note {
    background: rgba(57,255,20,0.28);
    border-color: #20aa15;
  }
  .track[data-track="2"] .step-cell.has-note .step-note { color: #ccffbb; text-shadow: 0 0 4px rgba(57,255,20,0.4); }
  .track[data-track="2"] .step-cell.playing { border-color: #39ff14; box-shadow: 0 0 10px rgba(57,255,20,0.5); }
  .track[data-track="2"] .step-cell.playing.has-note { background: rgba(57,255,20,0.5); }

  .track[data-track="3"] .step-cell.has-note {
    background: rgba(180,77,255,0.3);
    border-color: #7733cc;
  }
  .track[data-track="3"] .step-cell.has-note .step-note { color: #ddb5ff; text-shadow: 0 0 4px rgba(180,77,255,0.4); }
  .track[data-track="3"] .step-cell.playing { border-color: #b44dff; box-shadow: 0 0 10px rgba(180,77,255,0.5); }
  .track[data-track="3"] .step-cell.playing.has-note { background: rgba(180,77,255,0.5); }

  /* Metronome */
  #metronome {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 12px;
  }
  #metronome .knob-container .knob {
    width: 38px;
    height: 38px;
  }
  #metronome .knob-container .knob::after {
    height: 12px;
  }
  #metronome .knob-container label {
    font-size: 10px;
  }
  #metronome .knob-value {
    font-size: 11px;
  }
  #metro-flash {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #251565;
    transition: background 0.05s;
  }
  #metro-flash.beat {
    background: #ffffff;
    box-shadow: 0 0 6px rgba(0,229,255,0.6);
  }

  /* Visual drum track */
  #drum-track {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(5,8,25,0.7);
    border: 1px solid #006688;
    border-radius: 6px;
    padding: 6px 10px;
    margin-bottom: 4px;
    box-shadow: 0 0 8px rgba(0,102,136,0.06);
  }
  #drum-track-left {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
  }
  #drum-left-row1 {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  #drum-track-left .track-label {
    font-size: 13px;
    font-weight: bold;
    color: #b0c0ff;
    min-width: 12px;
    letter-spacing: 1px;
  }
  .drum-mute, .drum-solo {
    font-size: 10px;
    font-weight: bold;
    letter-spacing: 1px;
    padding: 4px 8px;
    border: 1px solid #005577;
    border-radius: 3px;
    background: rgba(5,10,30,0.7);
    color: #99aaee;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
  }
  .drum-mute.on { background: #253a70; color: #00e5ff; border-color: #00e5ff; }
  .drum-solo.on { background: #1a5530; color: #39ff14; border-color: #39ff14; }
  #drum-track-left #drum-vol {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    background: #3a3580;
    border-radius: 2px;
    outline: none;
  }
  #drum-track-left #drum-vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 18px;
    background: #b0c0ff;
    border-radius: 3px;
    cursor: pointer;
  }
  #drum-track-left #drum-vol::-webkit-slider-thumb:hover { background: #00e5ff; }
  #drum-track-left #drum-select {
    background: rgba(5,10,30,0.7);
    color: #00e5ff;
    border: 1px solid #0088aa;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    padding: 4px 6px;
    cursor: pointer;
    outline: none;
    width: 100%;
  }
  #drum-track-left #drum-select:hover { border-color: #00e5ff; }
  #drum-track-left #drum-select option { background: #0a0a25; color: #00e5ff; }

  #drum-spacer {
    min-width: 30px;
    flex-shrink: 0;
  }
  /* Drum sequencer grid */
  #drum-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
  }
  .drum-row {
    display: flex;
    align-items: center;
    gap: 2px;
  }
  .drum-row-label {
    font-size: 9px;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    min-width: 32px;
    width: 32px;
    flex-shrink: 0;
    text-align: right;
    padding-right: 3px;
    box-sizing: border-box;
    color: #99aaee;
  }
  .drum-step-grid {
    display: flex;
    gap: 2px;
    flex: 1;
  }
  .drum-step-cell {
    flex: 1;
    height: 18px;
    min-width: 0;
    background: rgba(8,12,35,0.5);
    border: 1px solid #2a2a60;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.1s, border-color 0.1s, box-shadow 0.1s;
    touch-action: manipulation;
  }
  .drum-step-cell:hover {
    border-color: #00bbdd;
    background: rgba(0,180,220,0.15);
  }
  .drum-step-cell.beat-start {
    border-left: 2px solid #0088aa;
  }
  .drum-step-cell.active {
    opacity: 0.85;
  }
  .drum-step-cell.drum-playing {
    border-color: #00e5ff;
    box-shadow: 0 0 8px rgba(0,229,255,0.5);
  }

  /* ─── Live Keyboard (Track 4) ─── */
  #live-keyboard {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    height: 48px;
  }
  #live-keys {
    position: relative;
    display: flex;
    flex: 1;
    height: 100%;
  }
  .live-key-white {
    flex: 1;
    height: 100%;
    background: linear-gradient(180deg, #2a2a68 0%, #3a3580 100%);
    border: 1px solid #3a3580;
    border-radius: 3px;
    margin-right: 1px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 2px;
    transition: background 0.05s, border-color 0.05s, box-shadow 0.05s;
    position: relative;
    z-index: 1;
    min-width: 0;
    touch-action: manipulation;
  }
  .live-key-white.active {
    background: linear-gradient(180deg, #152560 0%, #1a2a6a 100%);
    border-color: #00e5ff;
    box-shadow: 0 0 6px rgba(0,229,255,0.3);
  }
  .live-key-black {
    position: absolute;
    width: 60%;
    height: 60%;
    top: 0;
    background: linear-gradient(180deg, #1a1a3e 0%, #1a1a42 100%);
    border: 1px solid #0f0f38;
    border-radius: 0 0 3px 3px;
    z-index: 2;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding-bottom: 1px;
    transition: background 0.05s, border-color 0.05s, box-shadow 0.05s;
    touch-action: manipulation;
  }
  .live-key-black.active {
    background: linear-gradient(180deg, #2a3578 0%, #1a2868 100%);
    border-color: #00e5ff;
    box-shadow: 0 0 6px rgba(0,229,255,0.3);
  }
  .live-key-label {
    font-size: 8px;
    color: #6565b0;
    text-transform: uppercase;
    pointer-events: none;
  }
  .live-key-white.active .live-key-label,
  .live-key-black.active .live-key-label {
    color: #00e5ff;
  }
  .track-live .track-label { color: #00e5ff; }

  /* Loop button */
  #btn-loop svg path { fill: none; stroke: #b0c0ff; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
  #btn-loop:hover svg path { stroke: #00e5ff; }
  #btn-loop.loop-active { border-color: #39ff14; box-shadow: 0 0 8px rgba(57,255,20,0.3); }
  #btn-loop.loop-active svg path { stroke: #39ff14; }

  /* Export button */
  #btn-export {
    padding: 6px 14px;
    background: rgba(5,10,30,0.7);
    border: 1px solid #0088aa;
    border-radius: 4px;
    color: #b0c0ff;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s, color 0.15s;
  }
  #btn-export:hover { border-color: #00e5ff; color: #00e5ff; }
  #btn-export.exporting { border-color: #39ff14; color: #39ff14; cursor: wait; }

  /* Record button */
  #btn-rec {
    padding: 6px 14px;
    background: rgba(5,10,30,0.7);
    border: 1px solid #0088aa;
    border-radius: 4px;
    color: #b0c0ff;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
  }
  #btn-rec:hover { border-color: #ff4488; color: #ff4488; }
  #btn-rec.recording { border-color: #ff4444; color: #ff4444; box-shadow: 0 0 8px rgba(255,50,80,0.5); animation: rec-pulse 1s ease-in-out infinite; }
  @keyframes rec-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

  /* Bar/beat position */
  #bar-beat {
    font-size: 14px;
    font-family: 'Courier New', monospace;
    color: #00e5ff;
    letter-spacing: 2px;
    min-width: 52px;
    text-align: center;
    background: rgba(0,50,80,0.4);
    border: 1px solid #0099cc;
    border-radius: 4px;
    padding: 5px 10px;
    text-shadow: 0 0 6px rgba(0,229,255,0.3);
  }

  /* Sequencer help */
  #sound-section {
    background: linear-gradient(180deg, rgba(5,10,30,0.6) 0%, rgba(10,15,40,0.55) 100%);
    border: 2px solid #4466bb;
    border-radius: 10px;
    padding: 16px 14px;
    box-shadow: 0 0 18px rgba(68,102,187,0.08), inset 0 1px 0 rgba(68,102,187,0.06);
  }
  #seq-help {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #0088aa;
    text-align: center;
    font-size: 11px;
    letter-spacing: 1px;
    color: #99aaee;
    line-height: 1.8;
  }
  #seq-help kbd {
    display: inline-block;
    background: rgba(0,100,150,0.2);
    border: 1px solid #0088aa;
    border-radius: 3px;
    padding: 2px 8px;
    font-family: 'Courier New', monospace;
    color: #00e5ff;
    font-size: 12px;
    min-width: 18px;
    text-align: center;
  }
  #keyboard-help {
    margin-top: 8px;
    text-align: center;
    font-size: 11px;
    letter-spacing: 1px;
    color: #99aaee;
    line-height: 1.8;
  }
  #keyboard-help .help-row {
    margin: 2px 0;
  }
  #keyboard-help span {
    color: #b0c0ff;
    margin-right: 6px;
  }
  #keyboard-help kbd {
    display: inline-block;
    background: rgba(0,100,150,0.2);
    border: 1px solid #0088aa;
    border-radius: 3px;
    padding: 2px 8px;
    font-family: 'Courier New', monospace;
    color: #00e5ff;
    font-size: 12px;
    min-width: 18px;
    text-align: center;
  }

  /* ─── Mobile Responsive ─── */
  @media (max-width: 768px) {
    body {
      align-items: flex-start;
    }
    #synth {
      border-radius: 0;
      border-left: none;
      border-right: none;
      padding: calc(40px + env(safe-area-inset-top, 0px)) 10px 20px;
    }

    /* Header */
    #synth-header h1 {
      font-size: 22px;
      letter-spacing: 6px;
    }
    #synth-header .sub {
      font-size: 10px;
      letter-spacing: 4px;
    }

    /* Recorder / Sequencer section */
    #recorder {
      padding: 10px 8px;
    }
    #recorder-header {
      flex-direction: column;
      gap: 8px;
      align-items: stretch;
    }
    #recorder-header h3 {
      text-align: center;
    }

    /* Transport bar: split into 2 rows on mobile portrait */
    #transport {
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
      width: 100%;
      gap: 8px 6px;
    }
    .transport-group:first-child {
      /* Playback group: full width, centered on top row */
      flex: 1 1 100%;
      justify-content: center;
    }
    .transport-group {
      gap: 8px;
    }
    #metronome {
      margin-left: 0;
      gap: 6px;
    }

    /* Track rows: stack controls above grid */
    .track {
      flex-wrap: wrap;
      padding: 8px 8px;
      gap: 6px;
    }
    .track-label {
      min-width: 18px;
      font-size: 14px;
    }
    .track-vol {
      width: 40px;
    }
    .step-grid {
      flex-basis: 100%;
      order: 10;
    }
    .track-clear {
      order: 5;
    }

    /* Step cells: taller for touch */
    .step-cell {
      height: 34px;
    }

    /* Drum track: stack left controls above grid */
    #drum-track {
      flex-wrap: wrap;
    }
    #drum-track-left {
      flex-direction: row;
      flex-wrap: wrap;
      gap: 6px;
      width: 100%;
      align-items: center;
    }
    #drum-track-left #drum-select {
      width: auto;
      flex: 1;
    }
    #drum-track-left #drum-vol {
      width: 60px;
    }
    #drum-grid {
      flex-basis: 100%;
      order: 10;
    }
    #drum-spacer {
      display: none;
    }
    .drum-row-label {
      min-width: 28px;
      width: 28px;
      font-size: 8px;
    }
    .drum-step-cell {
      height: 22px;
    }

    /* Live keyboard taller */
    #live-keyboard {
      height: 84px;
      flex-basis: 100%;
      order: 10;
    }

    /* Master meter */
    #master-meter {
      flex-wrap: wrap;
      height: auto;
      gap: 4px;
      padding: 6px 8px;
    }

    /* Sound section */
    #track-selector {
      flex-wrap: wrap;
      gap: 4px;
    }
    .track-sel-btn {
      padding: 10px 16px;
      font-size: 13px;
    }

    /* Octave buttons visible on mobile */
    .octave-btn {
      display: inline-block;
    }
    #octave-display {
      margin-top: 8px;
      margin-bottom: 8px;
    }

    /* Control groups: stack vertically, tighter */
    #controls {
      flex-direction: column;
      gap: 6px;
      align-items: stretch;
    }
    .control-group {
      min-width: unset;
      padding: 8px 10px;
    }
    .control-group h3 {
      margin-bottom: 6px;
    }

    /* All knobs in sound section use smaller size */
    #sound-section .knob {
      width: 40px;
      height: 40px;
    }
    #sound-section .knob::after {
      height: 12px;
    }
    #sound-section .knob-value {
      font-size: 10px;
    }
    #sound-section .knob-container label {
      font-size: 9px;
    }
    #sound-section .knob-row {
      gap: 8px;
    }

    /* FX effects wrap nicely, tighter */
    #effects {
      gap: 5px;
      margin-bottom: 10px;
    }
    .fx-group {
      min-width: 80px;
      flex: 1 1 calc(50% - 5px);
      max-width: calc(50% - 3px);
      padding: 8px 10px 10px;
    }

    /* Help sections: hide on mobile */
    #seq-help, #keyboard-help {
      display: none;
    }
  }

  /* Mobile landscape: transport back to single row */
  @media (max-width: 768px) and (orientation: landscape) {
    .transport-group:first-child {
      flex: 0 1 auto;
    }
    #transport {
      flex-wrap: nowrap;
      justify-content: space-between;
    }
  }

  /* Extra small phones */
  @media (max-width: 400px) {
    #synth {
      padding: 10px 6px 14px;
    }
    #synth-header h1 {
      font-size: 16px;
      letter-spacing: 4px;
    }
    .step-cell {
      height: 28px;
    }
    .step-cell .step-note {
      font-size: 8px;
    }
    .transport-btn {
      width: 34px;
      height: 34px;
    }
    #btn-export, #btn-rec {
      font-size: 10px;
      padding: 5px 10px;
    }
    #bar-beat {
      font-size: 11px;
      padding: 3px 6px;
      min-width: 36px;
    }
    .knob {
      width: 40px;
      height: 40px;
    }
    .knob::after {
      height: 12px;
    }
    .fx-group {
      flex: 1 1 100%;
      max-width: 100%;
    }
  }

  /* ─── Share + Support Buttons ─── */
  #btn-share, #btn-bmc {
    background: transparent;
    border: 1px solid #00e5ff55;
    color: #00e5ff;
    padding: 4px 10px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    border-radius: 3px;
    margin-left: 6px;
    vertical-align: middle;
    text-decoration: none;
    display: inline-block;
  }
  #btn-share:hover, #btn-bmc:hover { background: #00e5ff22; }
  #btn-share:focus-visible, #btn-bmc:focus-visible { outline: 2px solid #00e5ff; outline-offset: 2px; }
