/* Synth Secrets — Global Styles */

:root {
  --bg: #fafafa;
  --text: #1a1a1a;
  --text-secondary: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --surface: #ffffff;
  --border: #e5e7eb;
  --font-body: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', monospace;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Page Layout === */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.page-header a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.page-header a:hover {
  text-decoration: underline;
}

.page-header .nav-disabled {
  color: var(--text-secondary);
  opacity: 0.4;
}

.page-header h1 {
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.page-title {
  padding: var(--space-3);
  padding-bottom: 0;
}

.page-title h2 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.page-title .part-number {
  font-size: 0.875rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

/* === Notebook Layout === */

.notebook {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-3) var(--space-6);
}

.nb-section {
  margin-bottom: var(--space-3);
}

.nb-section h2 {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--space-1);
}

.nb-section .part-number {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
  font-family: var(--font-mono);
  margin-bottom: 2px;
}

.nb-summary {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 720px;
}

.nb-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.nb-scopes {
  gap: var(--space-2);
  align-items: stretch;
  margin-bottom: var(--space-1);
}

.nb-controls {
  margin-bottom: var(--space-2);
}

.freq-readout {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
}

.demo-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  position: relative;
}

/* Two-column layout (for Parts 2, 3 that still use it) */
.page-content {
  display: grid;
  grid-template-columns: 1fr 2.5fr;
  gap: var(--space-3);
  padding: var(--space-3);
  max-width: 1440px;
  margin: 0 auto;
}

.page-summary {
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.page-summary p + p {
  margin-top: var(--space-2);
}

/* Responsive */
@media (max-width: 768px) {
  .notebook {
    padding: var(--space-2);
  }

  .nb-scopes {
    flex-direction: column;
  }

  .page-content {
    grid-template-columns: 1fr;
    padding: var(--space-2);
  }

  .page-header {
    padding: var(--space-1) var(--space-2);
  }
}

/* === Transport Bar (Play + Mute + Volume) === */

.transport-bar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.mute-toggle {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  min-width: 52px;
  justify-content: center;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.mute-toggle.is-muted {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.mute-toggle.is-muted:hover {
  background: #374151;
}

.volume-slider {
  width: 100px;
  height: 6px;
  accent-color: var(--accent);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border);
  border-radius: 3px;
  outline: none;
}
.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  margin-top: -4px;
}
.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}
.volume-slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
}

.volume-label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-secondary);
  min-width: 28px;
}

/* === Keyboard Shortcuts Overlay === */

.shortcuts-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  z-index: 200;
}

.shortcuts-overlay.visible {
  display: flex;
}

.shortcuts-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  min-width: 260px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.shortcuts-modal h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--text);
}

.shortcuts-modal table {
  width: 100%;
  border-collapse: collapse;
}

.shortcuts-modal td {
  padding: 4px 0;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.shortcuts-modal td:first-child {
  padding-right: var(--space-2);
  white-space: nowrap;
}

.shortcuts-modal kbd {
  display: inline-block;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  box-shadow: 0 1px 0 var(--border);
}

/* === Vertical Slider (lib/vslider.js) === */

.vslider-label {
  font-size: 0.625rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
}
.vslider-value {
  font-size: 0.5625rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  text-align: center;
  white-space: nowrap;
}

/* === Oscilloscope === */

.scope-container {
  margin-bottom: var(--space-1);
}

.scope-canvas {
  width: 100%;
  height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: block;
  background: #f8f9fa;
}

.scope-legend {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-top: 2px;
}

.scope-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.scope-legend-swatch {
  width: 12px;
  height: 3px;
  border-radius: 1px;
  display: inline-block;
}

.scope-canvas.scope-sm {
  height: 80px;
}

.scope-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  margin-top: 4px;
}

/* === Slider Components === */

.slider-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.slider-wrapper.slider-horizontal {
  flex-direction: row;
  gap: var(--space-1);
  min-width: 0;
}

.slider-wrapper.slider-horizontal .slider-label {
  min-width: 40px;
  text-align: right;
}

.slider-wrapper.slider-horizontal .slider-canvas {
  flex: 1;
}

.slider-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.slider-value {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.slider-canvas {
  display: block;
  cursor: pointer;
}

/* Fader bank (vertical sliders in a row) */
.fader-bank {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  justify-content: stretch;
  padding: var(--space-1) 0;
}

.fader-bank .slider-wrapper {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  max-width: 40px;
  overflow: hidden;
}

.fader-bank .slider-canvas {
  width: 100% !important;
}

.fader-bank .slider-label {
  font-size: 0.625rem;
}

/* === Controls Row === */

.controls-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.controls-row .slider-wrapper.slider-horizontal {
  flex: 1;
  min-width: 120px;
}

/* === Buttons === */

.btn {
  display: inline-flex;
  align-items: center;
  vertical-align: top;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg);
  border-color: #d1d5db;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.preset-group {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.preset-group .btn {
  font-size: 0.75rem;
  padding: 4px 10px;
}

/* === Debug Panel === */

.debug-panel {
  position: fixed;
  bottom: var(--space-2);
  right: var(--space-2);
  background: rgba(26, 26, 26, 0.9);
  color: #e5e7eb;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  z-index: 100;
  line-height: 1.6;
  display: none;
}

.debug-panel.visible {
  display: block;
}

/* === Floating Audio Panel (backtick key) === */

.audio-panel {
  position: fixed;
  bottom: 60px;
  right: var(--space-2);
  background: rgba(17, 17, 17, 0.95);
  border: 1px solid #333;
  border-radius: var(--radius-md);
  z-index: 200;
  display: none;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  user-select: none;
}

.audio-panel.visible {
  display: block;
}

.audio-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 6px;
  cursor: grab;
  border-bottom: 1px solid #333;
}

.audio-panel-header:active {
  cursor: grabbing;
}

.audio-panel-title {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.audio-panel-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.audio-panel-pause,
.audio-panel-close {
  background: transparent;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.audio-panel-pause {
  font-size: 0.625rem;
}

.audio-panel-close {
  font-size: 1rem;
}

.audio-panel-pause:hover,
.audio-panel-close:hover {
  color: #e5e7eb;
}

.audio-panel-row {
  position: relative;
}

.audio-panel-row + .audio-panel-row {
  border-top: 1px solid #222;
}

.audio-panel-label {
  position: absolute;
  top: 2px;
  left: 4px;
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  color: #555;
  z-index: 1;
  pointer-events: none;
}

.audio-panel-canvas {
  display: block;
}

.audio-panel-row:last-child .audio-panel-canvas {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* === Landing Page === */

.landing-container {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-3);
}

.landing-container h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: var(--space-1);
}

.landing-subtitle {
  color: var(--text-secondary);
  font-size: 1.0625rem;
  margin-bottom: var(--space-6);
  line-height: 1.6;
}

.section-header {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-top: var(--space-4);
  margin-bottom: var(--space-1);
  padding-bottom: var(--space-1);
  border-bottom: 2px solid var(--accent);
}

.section-header:first-of-type {
  margin-top: 0;
}

.part-list {
  list-style: none;
}

.part-list li {
  border-bottom: 1px solid var(--border);
}

.part-list li:first-child {
  border-top: 1px solid var(--border);
}

.part-list a {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  text-decoration: none;
  color: var(--text);
  transition: color 0.15s;
}

.part-list a:hover {
  color: var(--accent);
}

.part-list .part-num {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  min-width: 32px;
}

.part-list .part-title {
  font-weight: 500;
}

.part-list .part-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-left: auto;
  text-align: right;
}

@media (max-width: 600px) {
  .part-list a {
    flex-wrap: wrap;
  }
  .part-list .part-desc {
    width: 100%;
    margin-left: 32px;
    text-align: left;
    font-size: 0.8125rem;
  }
}

.part-list .part-coming-soon {
  opacity: 0.4;
  pointer-events: none;
}

.landing-toc {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.landing-toc-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px var(--space-2);
  align-items: baseline;
}

.landing-toc-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  width: 100%;
  margin-bottom: 2px;
}

.landing-toc a {
  font-size: 0.875rem;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.landing-toc a:hover {
  background: rgba(37, 99, 235, 0.08);
  text-decoration: none;
}

.landing-intro {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-2);
  background: var(--bg);
}

.landing-intro .landing-subtitle {
  margin-bottom: 0;
  font-size: 0.9375rem;
}

.landing-intro a {
  color: var(--accent);
}

.landing-resources {
  list-style: none;
  padding: 0;
}

.landing-resources li {
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.landing-resources li:last-child {
  border-bottom: none;
}

.landing-resources a {
  color: var(--accent);
  font-weight: 500;
}

/* === Inactive panel dimming (Part 2) === */

.panel-inactive {
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.3s var(--ease-out);
}

.panel-inactive .fader-bank .slider-canvas {
  filter: grayscale(1);
}

/* === Lesson Prose (West Coast+ parts — self-contained educational content) === */

.nb-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.try-it-prompt {
  font-size: 0.875rem;
  color: var(--text);
  padding: var(--space-2);
  margin: var(--space-2) 0;
  border-left: 4px solid var(--accent);
  background: #eff6ff;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  line-height: 1.6;
}

.reference-list {
  list-style: none;
  padding: 0;
}

.reference-list li {
  padding: var(--space-1) 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}

.reference-list a {
  color: var(--accent);
}

/* === Article Links === */

.nb-article-link {
  font-size: 0.8125rem;
  color: var(--accent);
  margin-top: var(--space-1);
  display: inline-block;
}

/* === Inline Hints === */

.hint {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 2px;
}

/* === Piano Keyboard === */

.piano-wrapper {
  display: flex;
  flex-direction: column;
}

.piano-octave-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
  font-size: 0.625rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.piano-oct-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1px 5px;
  cursor: pointer;
  font-size: 0.625rem;
  color: var(--text-secondary);
  line-height: 1;
}

.piano-oct-btn:hover, .midi-btn:hover {
  background: var(--bg);
  color: var(--text);
}
.midi-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  cursor: pointer;
  font-size: 0.6875rem;
  color: var(--text-secondary);
  line-height: 1;
}

.piano-oct-label {
  min-width: 56px;
  text-align: center;
}

.midi-status {
  margin-left: 4px;
  font-size: 0.5rem;
  color: #9ca3af;
  line-height: 1;
}

.piano-body {
  display: flex;
  align-items: stretch;
}

.pitch-wheel {
  width: 28px;
  margin-right: 4px;
  position: relative;
  background: #e5e7eb;
  border-radius: 3px;
  cursor: ns-resize;
  touch-action: none;
}

.pitch-wheel-center {
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 1px;
  background: var(--text-secondary);
}

.pitch-wheel-thumb {
  position: absolute;
  left: 2px;
  right: 2px;
  height: 8px;
  background: var(--accent);
  border-radius: 2px;
  top: 50%;
  transform: translateY(-50%);
  transition: top 0.2s ease-out;
}

.pitch-wheel-thumb.dragging {
  transition: none;
}

.piano-keyboard {
  display: flex;
  position: relative;
  height: 80px;
  user-select: none;
  touch-action: pan-y;
  flex: 1;
  min-width: 0;
}

.piano-key {
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.5625rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  transition: background 0.05s, transform 0.05s, box-shadow 0.05s;
}

.piano-key-white {
  flex: 1;
  min-width: 0;
  height: 80px;
  background: linear-gradient(to bottom, #fff 85%, #f0f0f0);
  box-shadow: 0 2px 3px rgba(0,0,0,0.08), inset 0 -1px 0 #e5e7eb;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  z-index: 1;
}

.piano-key-black {
  width: 24px;
  flex: 0 0 24px;
  height: 50px;
  background: linear-gradient(to bottom, #2a2a2a, #1a1a1a 60%, #0a0a0a);
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  color: transparent;
  border-radius: 0 0 3px 3px;
  margin: 0 -12px;
  z-index: 2;
}

.piano-key-white:hover { background: #f0f0f0; }
.piano-key-black:hover { background: #333; }
.piano-key-white.active, .piano-key-white.highlight {
  background: var(--accent);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
  transform: translateY(1px);
  color: white;
}
.piano-key-black.active, .piano-key-black.highlight {
  background: #1e40af;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
  transform: translateY(1px);
}

.piano-key-white.voice-active {
  background: var(--accent);
  color: white;
}

.piano-key-black.voice-active {
  background: var(--accent);
}

.piano-key-white.voice-stolen, .piano-key-black.voice-stolen {
  background: #ef4444;
  transition: background 0.3s;
}

/* === Envelope Editor === */

.envelope-canvas {
  width: 100%;
  height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: block;
  cursor: default;
}

/* === Signal Flow Animation === */

.signal-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  row-gap: 6px;
  padding: var(--space-1) 0;
  flex-wrap: wrap;
}

.flow-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.15s var(--ease-out);
}

.flow-block[style*="cursor: pointer"]:hover { transform: scale(1.02); }

.flow-box {
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 10px;
  background: var(--surface);
  text-align: center;
  min-width: 90px;
  overflow: hidden;
  box-shadow: 0 0 0 3px transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.flow-block.active .flow-box {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.flow-box-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  white-space: nowrap;
}

.flow-box-value {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.flow-arrow {
  font-size: 1.25rem;
  color: var(--text-secondary);
  padding: 0 var(--space-1);
  transition: color 0.15s;
}

.flow-arrow.active { color: var(--accent); }

.flow-arrow-cv {
  border-bottom: 2px dashed var(--border);
}

.flow-arrow-cv.active {
  border-color: #f59e0b;
  color: #f59e0b;
}

@keyframes flow-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.flow-arrow.flow-animate {
  animation: flow-pulse 1s ease-in-out infinite;
}

.flow-block.flow-playing .flow-box {
  border-color: var(--accent);
}

/* === Spectrogram === */

.spectrogram-canvas {
  width: 100%;
  height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: block;
  background: #000;
}

/* === A/B Toggle === */

.ab-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: var(--space-1);
}

.ab-toggle .btn {
  border: none;
  border-radius: 0;
  font-size: 0.75rem;
  padding: 4px 12px;
}

.ab-toggle .btn + .btn {
  border-left: 1px solid var(--border);
}

/* === Section Card (shared) === */

.section-card {
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  background: var(--bg);
}

.section-card h4 {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: var(--space-1);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* === Dual Viz (shared) === */

.dual-viz {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-1);
  overflow: hidden;
}

.dual-viz .scope-container { flex: 1; min-width: 0; }

/* === Control Rows (shared) === */

.control-row {
  display: flex;
  gap: var(--space-1);
  align-items: start;
  flex-wrap: wrap;
}

.control-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.control-item label {
  font-size: 0.6875rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  text-align: center;
}

/* === Vocoder Band Level Display === */

.vocoder-bands {
  display: flex;
  gap: 2px;
  height: 60px;
  align-items: flex-end;
}

.vocoder-band {
  flex: 1;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: height 0.05s;
}

/* === Step Sequencer === */

.step-sequencer {
  margin-bottom: var(--space-1);
}

.seq-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: 4px;
}

.seq-row-label {
  font-size: 0.6875rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 48px;
  text-align: right;
}

.seq-grid {
  display: flex;
  gap: 2px;
  flex-wrap: nowrap;
}

.seq-step {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  cursor: pointer;
  padding: 0;
  transition: background 0.1s, border-color 0.1s;
}

.seq-step:hover {
  border-color: var(--accent);
}

.seq-step.active {
  background: var(--accent);
  border-color: var(--accent);
}

/* Playhead overlay — GPU-composited, replaces per-cell .seq-step-current */
.seq-playhead {
  background: rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  transition: opacity 0.1s;
}

.seq-step.seq-step-group-start {
  margin-left: 4px;
}

/* === Melodic Sequencer (Piano Roll) === */

.melodic-sequencer {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.mel-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.mel-row {
  display: flex;
  align-items: center;
  gap: 0;
  height: 20px;
}

.mel-note-label {
  font-size: 0.5625rem;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  min-width: 32px;
  text-align: right;
  padding-right: 4px;
  user-select: none;
}

.mel-note-label.mel-root {
  color: var(--accent);
  font-weight: 600;
}

.mel-note-label.mel-black {
  color: #9ca3af;
}

.mel-cell {
  width: 22px;
  height: 18px;
  border: none;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  transition: background 0.08s;
  flex-shrink: 0;
}

.mel-cell:hover {
  background: #e0e7ff;
}

.mel-cell.mel-cell-black {
  background: #f3f4f6;
}

.mel-cell.mel-cell-root {
  border-bottom: 1px solid #93c5fd;
}

.mel-cell.mel-cell-group {
  border-left: 1px solid #d1d5db;
}

.mel-cell.active {
  background: var(--accent);
}

/* Playhead overlay — GPU-composited, no per-cell DOM mutations */
.mel-playhead {
  background: rgba(239, 68, 68, 0.25);
  border-radius: 2px;
  transition: opacity 0.1s;
}

/* === Mod Matrix Grid === */

.mod-matrix {
  display: flex;
  flex-direction: column;
  gap: 0;
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  user-select: none;
}

.mod-matrix-row {
  display: flex;
  align-items: stretch;
}

.mod-matrix-label {
  width: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding-right: 4px;
  color: var(--text-secondary);
  font-size: 0.5625rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mod-matrix-corner {
  /* empty top-left corner */
}

.mod-matrix-dest-label {
  flex: 1;
  flex-shrink: 0;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.5625rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding-bottom: 2px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.mod-cell {
  flex: 1;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #fff;
  padding: 2px;
  margin: 1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

.mod-cell-value {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  font-weight: 600;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}

.mod-cell:hover {
  border-color: #93c5fd;
}

/* === Mode Tabs === */

.mode-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: var(--space-1);
}

.mode-tab {
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--bg);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: none;
}

.mode-tab.active {
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--surface);
  position: relative;
  z-index: 1;
}
