/* The two instruments have their own composition, sharing only functional marks. */
.audio-lab {
  --lab-paper: #fff;
  --lab-ink: #171715;
  --lab-red: #cf291d;
  --lab-rule: #bdb9b0;
  --lab-mono: 'Courier New', monospace;
  min-width: 0;
  font-family: var(--sans, 'Helvetica Neue', Helvetica, Arial, sans-serif);
}
.audio-lab *, .audio-lab *::before, .audio-lab *::after { box-sizing: border-box; }
.audio-lab button, .audio-lab input, .audio-lab select { font: inherit; border-radius: 0; }
.audio-lab button { cursor: pointer; }
.audio-lab button:disabled { opacity: .4; cursor: default; }
.audio-lab button:focus-visible, .audio-lab input:focus-visible,
.audio-lab select:focus-visible, .audio-lab summary:focus-visible { outline: 2px solid var(--lab-red); outline-offset: 4px; }
.instrument-kicker { margin: 0; font: 11px/1.4 var(--lab-mono); }
.audio-status { margin: 0; font: 11px/1.5 var(--lab-mono); }
.audio-help { padding: 20px; font-size: 13px; line-height: 1.6; }
.audio-instructions { border-top: 1px solid var(--lab-rule); }
.audio-instructions summary { padding: 20px 0; font: 11px/1.5 var(--lab-mono); cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.audio-instructions summary::-webkit-details-marker { display: none; }
.audio-instructions summary>span { font-size: 18px; }
.audio-instructions[open] summary>span { transform: rotate(45deg); }
.audio-instructions p { font-size: 13px; line-height: 1.7; max-width: 60ch; margin: 0 0 30px; }

/* SYNTH: a black listening room. The line is measured sound, never an idle loop. */
.synth-lab {
  --lab-rule: #474742;
  --lab-red: #ff5543;
  background: var(--lab-ink);
  color: var(--lab-paper);
  margin: 0;
  padding: 26px clamp(18px, 3vw, 48px) 0;
}
.synth-heading { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 30px; padding-bottom: 28px; }
.synth-heading h1 { margin: 0; font-size: clamp(64px, 7.5vw, 120px); font-weight: 400; letter-spacing: -.075em; line-height: .76; }
.synth-heading h1>span { display: block; font-size: .48em; letter-spacing: -.06em; margin-top: .21em; }
.synth-heading-aside { align-self: stretch; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 24px; padding-top: 5px; }
.synth-power { background: transparent; color: inherit; border: 1px solid var(--lab-paper); min-height: 52px; padding: 14px 22px; font: 11px var(--lab-mono)!important; text-transform: uppercase; }
.synth-power::before { content: ''; display: inline-block; width: 6px; height: 6px; border: 1px solid currentColor; margin-right: 12px; vertical-align: 1px; }
.synth-power[aria-pressed=true] { color: var(--lab-red); border-color: var(--lab-red); }
.synth-power[aria-pressed=true]::before { background: currentColor; }
.synth-power:hover { background: var(--lab-paper); color: var(--lab-ink); }
.synth-scope-top { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--lab-rule); border-bottom: 1px solid var(--lab-rule); min-height: 46px; gap: 12px; }
.synth-view-switch { display: flex; align-self: stretch; }
.synth-view-switch button { background: none; border: 0; color: #aaa89f; padding: 12px 22px; font: 10px var(--lab-mono); text-transform: uppercase; border-right: 1px solid var(--lab-rule); }
.synth-view-switch button:first-child { padding-left: 0; padding-right: 26px; }
.synth-view-switch button[aria-pressed=true] { color: var(--lab-paper); }
.synth-view-switch button[aria-pressed=true]::before { content: '● '; color: var(--lab-red); font-size: 8px; }
.synth-readout { font: 9px/1.4 var(--lab-mono); text-align: right; }
.synth-display { position: relative; height: clamp(220px, 31svh, 380px); overflow: hidden; }
.synth-display canvas { display: block; width: 100%; height: 100%; }
.synth-note-register { position: absolute; left: 0; bottom: 26px; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.synth-note-register>span:first-child { font-size: clamp(35px, 5vw, 74px); letter-spacing: -.055em; line-height: 1; }
.synth-note-register>span:last-child { font: 9px var(--lab-mono); }
.synth-axis-label { position: absolute; right: 0; bottom: 28px; font: 9px var(--lab-mono); writing-mode: vertical-rl; color: #aaa89f; }
.synth-keyboard-wrap { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--lab-paper) var(--lab-ink); border-top: 1px solid var(--lab-rule); border-bottom: 1px solid var(--lab-rule); }
.synth-keyboard { display: grid; grid-template-columns: repeat(13, minmax(44px, 1fr)); min-width: 572px; height: 110px; }
.synth-keyboard .synth-key { display: flex; align-items: flex-start; justify-content: space-between; flex-direction: column; padding: 17px 13px; border: 0; border-right: 1px solid var(--lab-rule); background: none; color: var(--lab-paper); touch-action: pan-x; user-select: none; text-align: left; }
.synth-keyboard .synth-key:last-child { border-right: 0; }
.synth-keyboard .synth-key-sharp { background: #292925; height: 80px; border-bottom: 1px solid var(--lab-rule); }
.synth-key-name { font-size: 22px; letter-spacing: -.05em; }
.synth-key-name small { font: 9px var(--lab-mono); margin-left: 2px; vertical-align: top; }
.synth-keyboard kbd { color: #aaa89f; font: 10px var(--lab-mono); }
.synth-keyboard .synth-key:hover { background: #353530; }
.synth-keyboard .synth-key[aria-pressed=true] { background: var(--lab-red); color: var(--lab-ink); }
.synth-keyboard .synth-key[aria-pressed=true] kbd { color: inherit; }
.synth-keyboard .synth-key:focus-visible { outline-offset: -5px; }
.synth-performance { display: flex; align-items: center; gap: 24px; min-height: 55px; font: 10px var(--lab-mono); }
.synth-hold { align-self: stretch; padding: 12px 20px 12px 0; background: none; border: 0; border-right: 1px solid var(--lab-rule); color: inherit; text-transform: uppercase; }
.synth-hold span { margin-left: 16px; }
.synth-hold[aria-pressed=true] { color: var(--lab-red); }
.synth-key-range { margin-left: auto; }
.synth-scroll-hint { display: none; }
.synth-patch-heading { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--lab-paper); margin-top: 48px; padding-top: 17px; }
.synth-patch-heading h2 { font-size: 30px; font-weight: 400; letter-spacing: -.045em; margin: 0; }
.synth-patch-heading button { background: none; color: inherit; border: 0; padding: 12px 0 12px 16px; font: 11px var(--lab-mono); }
.synth-patch-heading button>span { margin-left: 24px; }
.synth-controls { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(16px, 2vw, 36px); padding: 34px 0 44px; }
.synth-control { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.synth-control>span { color: #aaa89f; font: 9px var(--lab-mono); text-transform: uppercase; white-space: nowrap; }
.synth-control output { font-size: clamp(18px, 1.8vw, 30px); letter-spacing: -.06em; white-space: nowrap; }
.synth-control select { background: var(--lab-ink); color: inherit; border: 0; border-bottom: 1px solid var(--lab-rule); padding: 0 18px 10px 0; width: 100%; min-height: 44px; font-size: clamp(18px, 1.8vw, 30px); letter-spacing: -.06em; }
.synth-control input { width: 100%; min-width: 0; height: 24px; margin: 0; appearance: none; background: none; cursor: pointer; }
.synth-control input::-webkit-slider-runnable-track { height: 1px; background: #73736b; }
.synth-control input::-moz-range-track { height: 1px; background: #73736b; }
.synth-control input::-webkit-slider-thumb { width: 6px; height: 20px; margin-top: -10px; appearance: none; background: var(--lab-paper); border: 0; border-radius: 0; }
.synth-control input::-moz-range-thumb { width: 6px; height: 20px; appearance: none; background: var(--lab-paper); border: 0; border-radius: 0; }
.synth-control input:active::-webkit-slider-thumb { background: var(--lab-red); }
.synth-control input:active::-moz-range-thumb { background: var(--lab-red); }
.synth-lab .audio-instructions summary { color: #aaa89f; }

/* MIDI: uncoated paper, engraved time divisions, mutable red notation. */
.midi-lab { color: var(--lab-ink); background: var(--lab-paper); padding: 26px 0 0; }
.midi-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 46px; }
.midi-heading .instrument-kicker { margin-bottom: 30px; }
.midi-heading h1 { font-size: clamp(56px, 8.8vw, 142px); font-weight: 400; line-height: .79; letter-spacing: -.075em; margin: 0; }
.midi-metre { display: flex; flex-direction: column; font-size: clamp(42px, 7vw, 120px); font-weight: 400; line-height: .95; letter-spacing: -.06em; }
.midi-metre>span:first-child { border-bottom: 2px solid currentColor; padding-bottom: 4px; }
.midi-transport { display: flex; gap: 28px; align-items: stretch; border-top: 1px solid var(--lab-ink); border-bottom: 1px solid var(--lab-ink); min-height: 88px; }
.midi-play { border: 0; border-right: 1px solid var(--lab-ink); color: inherit; background: none; padding: 20px 28px 20px 0; min-width: 120px; font-size: 28px!important; letter-spacing: -.04em; text-align: left; }
.midi-play::after { content: '↗'; font-size: 24px; margin-left: 20px; }
.midi-play[aria-pressed=true] { color: var(--lab-red); }
.midi-play[aria-pressed=true]::after { content: '■'; font-size: 14px; }
.midi-position { display: flex; align-items: baseline; align-self: center; min-width: 105px; font: 11px var(--lab-mono); }
.midi-position>span:first-child { font: 52px/.9 var(--sans, 'Helvetica Neue', Helvetica, Arial, sans-serif); letter-spacing: -.075em; }
.midi-position>span:last-child { margin-left: 10px; }
.midi-lab[data-playing=true] .midi-position { color: var(--lab-red); }
.midi-tempo, .midi-octave { display: flex; align-self: center; flex-wrap: wrap; align-items: baseline; column-gap: 8px; font: 10px var(--lab-mono); }
.midi-tempo { max-width: 130px; }
.midi-tempo>input { color: inherit; width: 64px; background: none; border: 0; border-bottom: 1px solid var(--lab-rule); font-size: 28px; padding: 0 0 3px; appearance: textfield; letter-spacing: -.065em; }
.midi-tempo input::-webkit-inner-spin-button { appearance: none; }
.midi-tempo>span { font-size: 9px; }
.midi-tempo { font-size: 0; }
.midi-tempo>input { font-size: 28px; }
.midi-octave { flex-direction: column; gap: 7px; }
.midi-octave select { color: inherit; background: none; border: 0; padding: 3px 22px 3px 0; font: 12px var(--lab-mono); min-height: 28px; }
.midi-note-count { align-self: center; margin-left: auto; font: 10px var(--lab-mono); white-space: nowrap; }
.midi-note-count strong { font-weight: 400; }
.midi-scroll { overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-color: var(--lab-ink) var(--lab-paper); scrollbar-width: thin; }
.midi-beats { display: grid; grid-template-columns: 48px repeat(4, minmax(176px, 1fr)); min-width: 752px; padding-top: 25px; height: 90px; }
.midi-beats>span:not(:first-child) { font-size: 40px; font-weight: 400; letter-spacing: -.06em; padding-left: 6px; border-left: 1px solid var(--lab-rule); }
.midi-ruler, .midi-row { display: grid; grid-template-columns: 48px repeat(16, minmax(44px, 1fr)); min-width: 752px; }
.midi-ruler { height: 32px; align-items: center; font: 9px var(--lab-mono); }
.midi-ruler>span { padding-left: 6px; }
.midi-ruler>span:not(.midi-ruler-0) { color: #64625c; }
.midi-row { height: 34px; }
.midi-pitch { display: flex; align-items: center; font: 10px var(--lab-mono); border-top: 1px solid var(--lab-rule); border-right: 1px solid var(--lab-ink); position: sticky; left: 0; background: var(--lab-paper); z-index: 2; }
.midi-row>div { border-top: 1px solid var(--lab-rule); border-right: 1px solid var(--lab-rule); min-width: 0; }
.midi-row>div:nth-child(4n+2) { border-left: 1px solid var(--lab-ink); }
.midi-row-sharp { background: #e4e4e4; }
.midi-row button { width: 100%; height: 100%; display: block; border: 0; padding: 4px; background: none; position: relative; touch-action: pan-x pan-y; }
.midi-row button[aria-pressed=true] { touch-action: none; cursor: grab; }
.midi-row button[aria-pressed=true]::after { content: ''; position: absolute; inset: 5px 3px; background: var(--lab-red); }
.midi-row button.is-selected[aria-pressed=true]::after { outline: 1px solid var(--lab-red); outline-offset: 2px; }
.midi-row button.is-playing { background: #c7c7c7; }
.midi-row button.is-playing[aria-pressed=true]::after { background: var(--lab-ink); }
.midi-row button:hover { background: #d6d6d6; }
.midi-row button:focus-visible { outline-offset: -3px; z-index: 1; }
.midi-row button.is-dragging { cursor: grabbing; }
.midi-score-end { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--lab-ink); border-bottom: 1px solid var(--lab-ink); padding: 15px 0; font: 9px var(--lab-mono); }
.midi-scroll-hint { display: none; }
.midi-edit-strip { display: flex; align-items: center; min-height: 74px; border-bottom: 1px solid var(--lab-rule); gap: 20px; }
.midi-selection { font: 10px var(--lab-mono); min-width: 180px; }
.midi-move { display: flex; }
.midi-move button { background: none; border: 0; border-left: 1px solid var(--lab-rule); padding: 12px; min-height: 44px; min-width: 44px; color: inherit; font-size: 18px; }
.midi-move button:last-child { border-right: 1px solid var(--lab-rule); }
.midi-move button:hover { color: var(--lab-red); }
.midi-clear { margin-left: auto; background: none; border: 0; padding: 16px 0 16px 20px; color: inherit; font: 11px var(--lab-mono)!important; }
.midi-export-row { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 36px 0; }
.midi-export { display: flex; align-items: baseline; gap: clamp(20px, 7vw, 130px); background: none; color: var(--lab-ink); border: 0; padding: 6px 0 10px; border-bottom: 1px solid var(--lab-ink); font-size: clamp(26px, 4.5vw, 70px)!important; letter-spacing: -.065em; line-height: 1; }
.midi-export:hover { color: var(--lab-red); border-color: var(--lab-red); }

@media(max-width:1000px) {
  .synth-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px 26px; }
  .synth-control output, .synth-control select { font-size: 26px; }
  .midi-transport { gap: 18px; }
  .midi-position { min-width: 92px; }
  .midi-note-count { display: none; }
}
@media(max-width:760px) {
  .synth-lab { padding-top: 24px; }
  .synth-heading { gap: 18px; padding-bottom: 30px; }
  .synth-heading h1 { font-size: clamp(57px, 16vw, 108px); }
  .synth-heading-aside { max-width: 130px; gap: 25px; }
  .synth-heading-aside .instrument-kicker { font-size: 9px; text-align: right; max-width: 12ch; }
  .synth-power { min-height: 46px; padding: 12px 10px; font-size: 9px!important; white-space: nowrap; }
  .synth-power::before { margin-right: 6px; }
  .synth-view-switch button { padding: 12px 13px; font-size: 9px; }
  .synth-view-switch button:first-child { padding-right: 14px; }
  .synth-readout { font-size: 8px; max-width: 115px; }
  .synth-display { height: clamp(210px, 32svh, 290px); }
  .synth-note-register { bottom: 22px; }
  .synth-axis-label { font-size: 8px; bottom: 24px; }
  .synth-keyboard { height: 104px; }
  .synth-keyboard .synth-key { padding: 14px 9px; }
  .synth-keyboard .synth-key-sharp { height: 74px; }
  .synth-key-name { font-size: 19px; }
  .synth-performance { gap: 16px; font-size: 9px; }
  .synth-performance .audio-status { font-size: 9px; }
  .synth-scroll-hint { display: inline; margin-left: 10px; }
  .synth-patch-heading { margin-top: 26px; }
  .synth-patch-heading h2 { font-size: 25px; }
  .synth-patch-heading button { font-size: 10px; }
  .synth-patch-heading button>span { margin-left: 10px; }
  .synth-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 30px 26px; padding: 26px 0 30px; }
  .synth-control { gap: 12px; }
  .synth-control>span { font-size: 8px; }
  .synth-control output, .synth-control select { font-size: 24px; }
  .midi-heading { margin-bottom: 32px; gap: 12px; }
  .midi-heading .instrument-kicker { font-size: 9px; margin-bottom: 23px; }
  .midi-heading h1 { font-size: clamp(46px, 12.8vw, 98px); }
  .midi-metre { font-size: 45px; }
  .midi-transport { display: grid; grid-template-columns: 1fr 1fr; gap: 0; min-height: 0; }
  .midi-play { min-height: 70px; min-width: 0; padding: 14px 18px 14px 0; font-size: 28px!important; }
  .midi-position { padding-left: 24px; }
  .midi-position>span:first-child { font-size: 45px; }
  .midi-tempo { border-right: 1px solid var(--lab-ink); border-top: 1px solid var(--lab-rule); max-width: none; padding: 10px 0; min-height: 61px; }
  .midi-octave { border-top: 1px solid var(--lab-rule); padding: 10px 0 10px 24px; gap: 0; min-height: 61px; }
  .midi-tempo>input { font-size: 27px; width: 50px; min-height: 40px; }
  .midi-octave select { min-height: 30px; }
  .midi-beats { padding-top: 20px; height: 78px; }
  .midi-beats>span:not(:first-child) { font-size: 35px; }
  .midi-row { height: 44px; }
  .midi-score-end { font-size: 8px; gap: 8px; flex-wrap: wrap; }
  .midi-scroll-hint { display: block; margin-left: auto; }
  .midi-score-end>span:nth-child(3) { display: none; }
  .midi-edit-strip { flex-wrap: wrap; gap: 0; padding: 13px 0; }
  .midi-selection { width: 100%; min-width: 0; margin-bottom: 12px; font-size: 9px; }
  .midi-move button { min-width: 39px; padding: 10px; }
  .midi-clear { font-size: 9px!important; padding-left: 8px; }
  .midi-export-row { display: block; padding: 24px 0 30px; }
  .midi-export-row .audio-status { font-size: 10px; margin-bottom: 28px; }
  .midi-export { width: 100%; justify-content: space-between; gap: 14px; font-size: 42px!important; }
  .audio-instructions summary { font-size: 10px; }
  .audio-instructions p { font-size: 12px; }
}
@media(prefers-reduced-motion:reduce) { .audio-lab * { scroll-behavior: auto!important; } }
