/* Lab styles stay inside its own page content. */
.lab-page {
  --lab-amber: #e2b376;
  --lab-sage: #a9b88f;
  --lab-muted: #b6a99b;
  max-width: 1280px;
  padding: clamp(2rem, 4vw, 3.5rem) clamp(1rem, 3vw, 2rem) 5rem;
}

.lab-intro {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  align-items: end;
  gap: 1.5rem 3rem;
  margin-bottom: clamp(1.75rem, 3vw, 2.5rem);
}

.lab-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--lab-amber);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
}

.lab-eyebrow::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--lab-sage);
}

.lab-intro h1 {
  margin: 0;
  font-size: clamp(2rem, 3.9vw, 3.3rem);
  font-weight: 600;
  line-height: 1.13;
  letter-spacing: -0.045em;
}

.lab-intro h1 span {
  color: var(--accent);
}

.lab-intro-copy {
  max-width: 34ch;
  margin: 0 0 0.2rem auto;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.3vw, 1.05rem);
  line-height: 1.75;
}

.lab-workbench {
  overflow: hidden;
  border: 1px solid rgba(216, 166, 122, 0.25);
  border-top: 3px solid #906545;
  border-radius: 22px;
  background: linear-gradient(145deg, #25211d, #1a1816 75%);
  box-shadow: 0 24px 55px rgba(0, 0, 0, 0.22);
}

.lab-tool-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1.25rem, 2.5vw, 2rem);
  border-bottom: 1px solid var(--line);
}

.lab-tool-heading {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.lab-tool-icon {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  color: var(--lab-amber);
  background: rgba(216, 166, 122, 0.08);
  border: 1px solid rgba(216, 166, 122, 0.16);
  border-radius: 13px;
}

.lab-tool-icon svg {
  width: 30px;
  height: 30px;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lab-tool-icon .lab-key-fill {
  fill: currentColor;
  stroke: none;
}

.lab-tool-heading h2,
.lab-melody h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.2vw, 1.75rem);
  line-height: 1.3;
  letter-spacing: -0.025em;
}

.lab-tool-heading p {
  margin: 0.35rem 0 0;
  color: var(--lab-muted);
  font-size: 0.85rem;
}

.lab-preview-badge {
  display: inline-block;
  flex-shrink: 0;
  padding: 0.25rem 0.65rem;
  border: 1px solid rgba(216, 166, 122, 0.2);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.68rem;
  letter-spacing: 0.035em;
}

.lab-sequence {
  padding: clamp(1rem, 2.5vw, 2rem);
}

.lab-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.lab-configuration {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 0.65fr)) minmax(0, 0.85fr) minmax(0, 1.2fr) minmax(0, 0.7fr) minmax(0, 3fr);
  gap: 0.85rem;
  min-width: 0;
  margin: 0;
  padding: 1.25rem clamp(1rem, 2.5vw, 2rem) 0.75rem;
  border: 0;
  background: rgba(0, 0, 0, 0.1);
}

.lab-field { min-width: 0; }

.lab-field label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--lab-muted);
  font-size: 0.73rem;
}

.lab-field select,
.lab-field input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.6rem 0.55rem;
  border: 1px solid rgba(216, 166, 122, 0.24);
  border-radius: 8px;
  background: #2a241f;
  color: var(--secondary);
  color-scheme: dark;
  font: inherit;
  font-size: 0.85rem;
}

.lab-field select { cursor: pointer; }
.lab-field input { font-variant-numeric: tabular-nums; }
.lab-progression-field select {
  border-color: rgba(226, 179, 118, 0.5);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lab-field select:focus-visible,
.lab-field input:focus-visible {
  outline: 2px solid var(--lab-amber);
  outline-offset: 3px;
}

.lab-configuration-note {
  margin: 0;
  padding: 0  clamp(1rem, 2.5vw, 2rem) 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.1);
  color: var(--lab-muted);
  font-size: 0.72rem;
}

.lab-sequence-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-bottom: 1rem;
}

.lab-sequence-heading p {
  margin: 0;
  color: var(--secondary);
  font-size: 0.78rem;
  font-weight: 600;
}

.lab-sequence-heading > span {
  color: var(--lab-muted);
  font-size: 0.72rem;
}

.lab-chords {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.65rem, 1.4vw, 1.1rem);
  list-style: none;
  margin: 0;
  padding: 0;
}

.lab-chords[data-length="6"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.lab-chord {
  position: relative;
  min-width: 0;
  padding: clamp(0.85rem, 1.6vw, 1.3rem);
  border: 1px solid rgba(236, 211, 185, 0.17);
  border-radius: 14px;
  background: linear-gradient(160deg, rgba(240, 223, 200, 0.055), rgba(240, 223, 200, 0.015));
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.1);
}

.lab-chord-amber { --chord-accent: #e2b376; }
.lab-chord-clay { --chord-accent: #d69a7b; }
.lab-chord-sage { --chord-accent: #a9b88f; }
.lab-chord-sand { --chord-accent: #d9c8a2; }

.lab-chord-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--lab-muted);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.lab-chord-mark {
  width: 20px;
  height: 3px;
  border-radius: 2px;
  background: var(--chord-accent);
}

.lab-chord-play {
  position: relative;
  z-index: 2;
  min-width: 32px;
  min-height: 30px;
  margin-left: auto;
  padding: 0.2rem 0.45rem;
  border: 1px solid rgba(236, 211, 185, 0.22);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.14);
  color: var(--chord-accent);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.lab-chord-play + .lab-chord-mark { margin-left: 0.55rem; }
.lab-chord-play:hover { border-color: var(--chord-accent); background: rgba(226, 179, 118, 0.08); }
.lab-chord-play:focus-visible { outline: 2px solid var(--lab-amber); outline-offset: 2px; }
.lab-chord-play:disabled { cursor: wait; opacity: 0.72; }
.lab-chord-play.is-playing { color: #211d19; background: var(--chord-accent); }

.lab-audio-status {
  min-height: 1.25rem;
  margin: 0.75rem 0 0;
  color: var(--lab-muted);
  font-size: 0.72rem;
}

.lab-chord h3 {
  margin: 1.1rem 0 0;
  color: var(--chord-accent);
  font-size: clamp(2.75rem, 4.5vw, 3.6rem);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.05em;
  overflow-wrap: anywhere;
}

.lab-chord h3 .lab-chord-suffix {
  font-size: 0.52em;
  letter-spacing: -0.035em;
}

.lab-chord h3 .lab-chord-root { font-size: inherit; }
.lab-chord h3 .lab-chord-bass { font-size: inherit; letter-spacing: -0.05em; }

.lab-chord-name {
  margin: 0.3rem 0 1.6rem;
  color: var(--lab-muted);
  font-size: 0.73rem;
  overflow-wrap: anywhere;
}

.lab-page [hidden] { display: none !important; }

.lab-chord.is-editable {
  border-color: rgba(226, 179, 118, 0.35);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.lab-chord.is-editable:hover {
  border-color: var(--chord-accent);
  background-color: rgba(216, 166, 122, 0.05);
}

.lab-edit-indicator {
  color: var(--chord-accent);
  font-size: 0.68rem;
  letter-spacing: 0;
}

.lab-edit-chord {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: pointer;
}

.lab-edit-chord:focus-visible,
.lab-page .lab-button:focus-visible,
.lab-editor-close:focus-visible,
.lab-advanced summary:focus-visible {
  outline: 2px solid var(--lab-amber);
  outline-offset: 3px;
}

.lab-custom-manager {
  padding: 1rem clamp(1rem, 2.5vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(169, 184, 143, 0.035);
}

.lab-custom-actions,
.lab-delete-confirmation {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.lab-custom-actions .lab-button { min-height: 40px; font-size: 0.78rem; }

#lab-custom-status {
  margin-left: auto;
  color: var(--lab-sage);
  font-size: 0.75rem;
}

.lab-save {
  background: #e2b376;
  border-color: #e2b376;
  color: #21160e;
}

.lab-page .lab-button:not(:disabled) { cursor: pointer; }
.lab-page .lab-button:not(:disabled):hover { filter: brightness(1.08); }

.lab-delete-confirmation {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.lab-delete-confirmation p {
  flex: 1 1 100%;
  margin: 0;
  color: var(--muted);
  font-size: 0.83rem;
}

.lab-delete-confirm {
  color: #efb397;
  background: rgba(191, 125, 92, 0.1);
  border-color: rgba(191, 125, 92, 0.45);
}

.lab-storage-notice {
  margin: 0;
  padding: 0.8rem clamp(1rem, 2.5vw, 2rem);
  color: var(--lab-amber);
  background: rgba(226, 179, 118, 0.06);
  font-size: 0.8rem;
}

body.lab-editor-open,
body.lab-rhythm-open,
body.lab-audio-settings-open,
body.lab-reset-open { overflow: hidden; }

.lab-editor {
  width: min(660px, calc(100% - 2rem));
  max-width: calc(100% - 2rem);
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: clamp(1rem, 3vw, 1.75rem);
  border: 1px solid rgba(226, 179, 118, 0.4);
  border-radius: 20px;
  background: #211d19;
  color: var(--text);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.5);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  color-scheme: dark;
}

.lab-editor::backdrop { background: rgba(10, 8, 6, 0.78); }
.lab-reset-dialog { width: min(460px, calc(100% - 2rem)); }

.lab-editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.lab-editor-header .eyebrow { margin-bottom: 0.35rem; font-size: 0.65rem; }
.lab-editor-header h2 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.65rem); line-height: 1.3; }

.lab-editor-close {
  flex: 0 0 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
}

#lab-editor-description,
.lab-editor-help {
  color: var(--lab-muted);
  font-size: 0.78rem;
  line-height: 1.65;
}

.lab-editor-preview {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid rgba(226, 179, 118, 0.2);
  border-radius: 12px;
  background: rgba(226, 179, 118, 0.045);
}

.lab-editor-preview > span {
  display: block;
  color: var(--lab-muted);
  font-size: 0.7rem;
}

#lab-chord-preview {
  display: block;
  margin-top: 0.25rem;
  color: var(--lab-amber);
  font-size: clamp(1.6rem, 5vw, 2.5rem);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.lab-editor-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.lab-quality-field { grid-column: 1 / -1; }
.lab-editor select:disabled { opacity: 0.5; cursor: default; }

.lab-advanced {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.lab-advanced summary {
  padding: 0.9rem 0.1rem;
  color: var(--secondary);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

.lab-advanced fieldset {
  min-width: 0;
  margin: 0 0 1rem;
  padding: 0;
  border: 0;
}

.lab-interval-group legend {
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.lab-interval-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: 0.45rem;
}

.lab-interval-choice {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(240, 223, 200, 0.025);
  color: var(--secondary);
  font-size: 0.8rem;
  cursor: pointer;
}

.lab-interval-choice input {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--lab-amber);
}

.lab-interval-choice:has(input:checked) {
  border-color: rgba(226, 179, 118, 0.5);
  background: rgba(226, 179, 118, 0.07);
}

.lab-interval-choice:has(input:disabled) { opacity: 0.5; cursor: default; }
.lab-interval-choice:focus-within { outline: 2px solid var(--lab-amber); outline-offset: 2px; }

.lab-editor-modifiers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 0.85rem;
}

.lab-editor-error { color: #efb397; font-size: 0.8rem; }

.lab-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
  padding-top: 1.25rem;
}

@media (max-width: 560px) {
  #lab-custom-status { width: 100%; margin: 0; }
  .lab-editor { width: calc(100% - 1rem); max-width: calc(100% - 1rem); border-radius: 14px; }
  .lab-editor-actions .lab-button { flex: 1; }
}

.lab-step-labels {
  display: grid;
  grid-template-columns: repeat(var(--rhythm-steps), minmax(0, 1fr));
  gap: 0;
}

.lab-edit-rhythm {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.lab-rhythm {
  position: relative;
  display: block;
  height: 36px;
  border-radius: 4px;
  background: repeating-linear-gradient(to right, rgba(236, 211, 185, 0.12) 0 1px,
    transparent 1px calc(100% / var(--rhythm-steps))), rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 0 0 1px rgba(236, 211, 185, 0.12);
}

.lab-rhythm .lab-rhythm-block { border-width: 1px; border-radius: 3px; }

.lab-rhythm-block,
.lab-rhythm-ghost {
  position: absolute;
  top: 0;
  height: 100%;
  box-sizing: border-box;
  min-width: 0;
  padding: 0;
  border: 2px solid #29221b;
  border-radius: 5px;
  background: var(--chord-accent, var(--lab-amber));
  box-shadow: inset 0 2px rgba(255, 255, 255, 0.15);
}

.lab-edit-rhythm:hover .lab-rhythm { filter: brightness(1.1); }
.lab-edit-rhythm:focus-visible,
.lab-rhythm-tabs button:focus-visible,
.lab-rhythm-grid button:focus-visible {
  outline: 2px solid var(--lab-amber);
  outline-offset: 3px;
}

.lab-rhythm-tabs {
  display: flex;
  gap: 0.4rem;
  margin: 1.25rem 0 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--line);
}

.lab-rhythm-tabs button {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0.5rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--lab-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.lab-rhythm-tabs button[aria-selected="true"] {
  border-color: rgba(226, 179, 118, 0.4);
  background: rgba(226, 179, 118, 0.09);
  color: var(--lab-amber);
}

.lab-rhythm-editor .lab-draw-labels {
  margin: 1.2rem 0 0.5rem;
  color: var(--lab-muted);
  font-size: 0.75rem;
}

.lab-rhythm-grid {
  position: relative;
  height: clamp(164px, 22vw, 184px);
  border-radius: 8px;
  background: #181613;
  box-shadow: 0 0 0 1px rgba(236, 211, 185, 0.2);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.lab-rhythm-steps {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--rhythm-steps), minmax(0, 1fr));
}

.lab-rhythm-steps button {
  min-width: 0;
  padding: 0;
  border: 0;
  border-right: 1px dashed rgba(236, 211, 185, 0.15);
  background: transparent;
  cursor: crosshair;
}

.lab-rhythm-steps button.is-beat-end { border-right-style: solid; border-right-color: rgba(236, 211, 185, 0.3); }
.lab-rhythm-steps button:last-child { border-right: 0; }
.lab-rhythm-steps button:hover { background: rgba(226, 179, 118, 0.06); }
.lab-rhythm-steps button:focus-visible { outline-offset: -4px; }
.lab-rhythm-steps button[aria-disabled="true"] { cursor: default; }

.lab-rhythm-events { position: absolute; inset: 36px 0; pointer-events: none; }
.lab-rhythm-events .lab-rhythm-block {
  pointer-events: auto;
  color: #21160e;
  font: inherit;
  font-size: clamp(0.65rem, 2vw, 0.9rem);
  font-weight: 600;
  overflow: hidden;
  cursor: grab;
}

.lab-rhythm-events .lab-rhythm-block:active { cursor: grabbing; }

.lab-rhythm-events .lab-rhythm-block[aria-pressed="true"] {
  background: var(--lab-sage);
  box-shadow: inset 0 0 0 2px #d5dfc4;
}

.lab-rhythm-ghost {
  top: 36px;
  height: calc(100% - 72px);
  pointer-events: none;
  background: rgba(226, 179, 118, 0.6);
  border: 2px dashed var(--lab-amber);
}

.lab-rhythm-ghost.is-invalid { background: rgba(191, 125, 92, 0.3); border-color: #efb397; }

.lab-rhythm-handle {
  position: absolute;
  z-index: 2;
  width: 28px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--lab-sage);
  cursor: ew-resize;
  touch-action: none;
}

.lab-rhythm-handle::after {
  content: '';
  display: block;
  width: 5px;
  height: 16px;
  margin: auto;
  border-inline: 2px solid currentColor;
  border-radius: 2px;
  background: #211d19;
}

.lab-rhythm-handle:hover { background: rgba(169, 184, 143, 0.12); }
.lab-rhythm-handle-left { top: 0; }
.lab-rhythm-handle-right { bottom: 0; }

.lab-rhythm-copy-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.lab-rhythm-copy-actions > * { flex: 1 1 170px; min-width: 0; }
.lab-rhythm-copy-actions .lab-button { font-size: 0.78rem; }
.lab-rhythm-copy-actions select { width: 100%; }
.lab-rhythm-apply-confirmation {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid rgba(226, 179, 118, 0.4);
  border-radius: 10px;
  background: rgba(226, 179, 118, 0.05);
}

.lab-rhythm-apply-confirmation > p { margin-top: 0; }
#lab-rhythm-workspace[inert] { opacity: 0.6; }

.lab-rhythm-selection {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.lab-rhythm-selection p {
  flex: 1 1 200px;
  margin: 0;
  color: var(--lab-sage);
  font-size: 0.8rem;
  line-height: 1.6;
}

.lab-rhythm-selection .lab-button { min-height: 44px; }
.lab-rhythm-coming {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--lab-muted);
}

.lab-record-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
  color: var(--lab-sage);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

#lab-record-status { font-weight: 600; }
#lab-record-tempo { color: var(--lab-muted); font-size: 0.75rem; }
.is-recording #lab-record-status { color: #efb397; }
.lab-record-count-space { min-height: calc(48px + 1rem); }
.lab-record-count {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.lab-record-count span {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--lab-muted);
  background: rgba(226, 179, 118, 0.03);
  font-size: 1.2rem;
}

.lab-record-count .is-active {
  color: #21160e;
  background: var(--lab-amber);
  border-color: var(--lab-amber);
}

.lab-record-preview { position: relative; margin-bottom: 1rem; }
.lab-record-surface {
  position: relative;
  height: 168px;
  box-sizing: border-box;
  padding: 36px 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.lab-record-preview .lab-rhythm { height: 96px; }
.lab-record-events .lab-rhythm-block { cursor: grab; }
.lab-record-events .lab-rhythm-block:active { cursor: grabbing; }
.lab-record-events .lab-rhythm-block:disabled { cursor: default; }
.lab-record-events .lab-rhythm-block[aria-pressed="true"] {
  background: var(--lab-sage);
  box-shadow: inset 0 0 0 2px #d5dfc4;
}
.lab-record-surface button:focus-visible { outline: 2px solid var(--lab-amber); outline-offset: 2px; }
.lab-record-playhead {
  position: absolute;
  top: 36px;
  width: 2px;
  height: 96px;
  background: var(--lab-sage);
  box-shadow: 0 0 0 1px #211d19;
  pointer-events: none;
}

.lab-draw-playhead {
  position: absolute;
  top: 36px;
  bottom: 36px;
  width: 2px;
  background: var(--lab-sage);
  box-shadow: 0 0 0 1px #211d19;
  pointer-events: none;
}

.lab-rhythm-preview-button { min-height: 40px; font-size: 0.78rem; }
.lab-rhythm-user-preset > .lab-rhythm-preview-button { align-self: flex-start; }

.lab-record-pad {
  display: block;
  width: 100%;
  min-height: clamp(80px, 18vw, 110px);
  padding: 1rem;
  border: 1px solid rgba(226, 179, 118, 0.45);
  border-radius: 12px;
  color: var(--lab-amber);
  background: rgba(226, 179, 118, 0.06);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}

.lab-record-pad:disabled { opacity: 0.45; cursor: default; }
.lab-record-pad.is-held { color: #21160e; background: var(--lab-amber); }
.lab-record-pad:focus-visible { outline: 2px solid var(--lab-amber); outline-offset: 3px; }
.lab-record-actions,
.lab-record-versions { display: flex; flex-wrap: wrap; gap: 0.65rem; margin-top: 1rem; }
.lab-record-actions .lab-button { flex: 1 1 110px; }
.lab-record-versions .lab-button { flex: 1; min-width: 0; }
.lab-record-versions [aria-pressed="true"] { border-color: var(--lab-sage); color: var(--lab-sage); }
.lab-record-actions .lab-button:disabled,
.lab-record-versions .lab-button:disabled,
#lab-record-use:disabled { opacity: 0.45; }
#lab-record-use { width: 100%; }

.lab-rhythm-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.lab-rhythm-preset {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.45rem;
  padding: 1rem;
  border: 1px solid rgba(226, 179, 118, 0.2);
  border-radius: 12px;
  background: rgba(226, 179, 118, 0.025);
  color: var(--lab-amber);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.lab-rhythm-preset strong { font-size: 0.9rem; font-weight: 500; }
.lab-rhythm-preset-description {
  flex: 1;
  color: var(--lab-muted);
  font-size: 0.75rem;
  line-height: 1.55;
}
.lab-rhythm-preset .lab-rhythm { width: 100%; margin-top: 0.35rem; flex-shrink: 0; }
.lab-rhythm-preset .lab-step-labels { width: 100%; margin-top: 0; }
.lab-rhythm-preset:not(:disabled):hover { background: rgba(226, 179, 118, 0.07); }
.lab-rhythm-preset:disabled { cursor: default; color: var(--lab-muted); }
.lab-rhythm-user-preset { display: flex; flex-direction: column; min-width: 0; gap: 0.5rem; }
.lab-rhythm-user-preset > .lab-rhythm-preset { flex: 1; width: 100%; }
.lab-rhythm-user-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.lab-rhythm-user-actions .lab-button { flex: 1; min-height: 40px; font-size: 0.75rem; }
.lab-save-personal-action { margin-top: 0.75rem; min-height: 40px; font-size: 0.78rem; }
.lab-personal-rhythm-dialog { width: min(460px, calc(100% - 2rem)); }
#lab-personal-rhythm-choice { margin-top: 1.25rem; }
.lab-rhythm-preset[aria-pressed="true"] {
  --chord-accent: var(--lab-sage);
  border-color: var(--lab-sage);
  background: rgba(169, 184, 143, 0.08);
  color: var(--lab-sage);
}
.lab-rhythm-preset:focus-visible { outline: 2px solid var(--lab-amber); outline-offset: 2px; }
.lab-rhythm-preset-actions {
  position: sticky;
  bottom: -1px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--line);
  background: #211d19;
}
.lab-rhythm-preset-actions p { flex: 1 1 180px; margin: 0; }
@media (max-width: 560px) {
  .lab-rhythm-presets { grid-template-columns: minmax(0, 1fr); }
}

.lab-step-labels {
  margin-top: 0.4rem;
  color: var(--lab-muted);
  text-align: center;
  font-size: 0.6rem;
}

.lab-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem 2rem;
  padding: 1.25rem clamp(1rem, 2.5vw, 2rem);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.14);
}

.lab-settings {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem 0.75rem;
  margin-right: auto;
}

.lab-settings .lab-setting {
  display: flex;
  flex: 0 0 44px;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.lab-settings .lab-setting + .lab-setting { margin-left: 0; }
.lab-settings .lab-setting:has(#lab-percussion) { flex-basis: auto; min-width: 70px; }
.lab-settings .lab-setting > span { width: 100%; margin: 0; text-align: center; line-height: 1.2; }
.lab-settings .lab-switch { width: 44px; min-height: 44px; justify-content: center; }
.lab-settings .lab-switch > span:last-child { display: none; }

.lab-setting > span {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--lab-muted);
  font-size: 0.72rem;
}

.lab-switch {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 29px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--lab-sage);
  font-size: 0.65rem;
  font-weight: 700;
}

.lab-switch-track {
  display: flex;
  justify-content: flex-end;
  width: 34px;
  padding: 3px;
  border: 1px solid rgba(169, 184, 143, 0.45);
  border-radius: 999px;
  background: rgba(169, 184, 143, 0.16);
}

.lab-switch-track::after {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--lab-sage);
}

.lab-switch[aria-checked="false"] { color: var(--lab-muted); }
.lab-switch[aria-checked="false"] .lab-switch-track { justify-content: flex-start; background: rgba(236, 211, 185, 0.06); border-color: rgba(236, 211, 185, 0.24); }
.lab-switch[aria-checked="false"] .lab-switch-track::after { background: var(--lab-muted); }
.lab-switch:focus-visible { outline: 2px solid var(--lab-amber); outline-offset: 4px; border-radius: 4px; }

.lab-button.lab-audio-settings-open,
.lab-metronome-button {
  min-height: 36px;
  padding: 0.45rem 0.8rem;
  color: var(--lab-amber);
  background: rgba(226, 179, 118, 0.08);
  font-size: 0.76rem;
}

.lab-button.lab-audio-settings-open {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  aspect-ratio: 1 / 1;
  font-size: 19px;
  line-height: 1;
  margin-right: -3px;
}

.lab-metronome-button { margin-right: 1rem; }

.lab-metronome-button[aria-pressed="true"] {
  color: var(--lab-sage);
  border-color: rgba(169, 184, 143, 0.45);
  background: rgba(169, 184, 143, 0.12);
}

.lab-audio-settings-dialog { width: min(570px, calc(100% - 2rem)); }
.lab-audio-settings-heading {
  margin: 1.1rem 0 0;
  color: var(--lab-amber);
  font-size: 0.72rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}
.lab-audio-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
  margin-top: 1.25rem;
}
.lab-audio-setting { min-width: 0; }
.lab-audio-setting label {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--text);
  font-size: 0.8rem;
}
.lab-audio-setting output { color: var(--lab-amber); font-variant-numeric: tabular-nums; }
.lab-audio-setting input[type="range"] { width: 100%; accent-color: var(--lab-amber); cursor: pointer; }
.lab-audio-setting select {
  width: 100%;
  min-height: 40px;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #302820;
  color: var(--text);
}
.lab-audio-register { grid-column: 1 / -1; }
@media (max-width: 560px) {
  .lab-audio-settings-grid { grid-template-columns: minmax(0, 1fr); }
  .lab-audio-register { grid-column: auto; }
}

.lab-transport {
  display: flex;
  gap: 0.65rem;
}

.lab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 46px;
  padding: 0.65rem 1.2rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
}

.lab-button:disabled,
.lab-switch:disabled {
  opacity: 1;
  cursor: default;
}

.lab-button svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.lab-play {
  min-width: 112px;
  color: #21160e;
  background: linear-gradient(135deg, #edbc7e, #d99a62);
  border-color: #e2b376;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.lab-play svg {
  fill: currentColor;
}

.lab-reset {
  background: rgba(240, 223, 200, 0.04);
  color: var(--muted);
}

.lab-export {
  background: transparent;
  color: var(--lab-amber);
  border-color: rgba(226, 179, 118, 0.32);
}

.lab-export svg {
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lab-preview-note {
  margin: 0;
  padding: 0.8rem 1.25rem;
  color: var(--lab-muted);
  text-align: center;
  font-size: 0.72rem;
}

.lab-melody {
  margin-top: clamp(2rem, 4vw, 3rem);
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(240, 223, 200, 0.025);
}

.lab-melody-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.25rem;
}

.lab-melody-header .eyebrow { margin-bottom: 0.35rem; }
.lab-melody-header p:not(.eyebrow) {
  margin: 0.4rem 0 0;
  color: var(--lab-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.lab-melody-summary {
  display: grid;
  gap: 0.3rem;
  min-width: 190px;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(169, 184, 143, 0.25);
  border-radius: 12px;
  background: rgba(169, 184, 143, 0.06);
  color: var(--lab-muted);
  font-size: 0.74rem;
}

.lab-melody-summary strong { color: var(--lab-sage); font-size: 0.84rem; font-weight: 600; }
.lab-melody-summary small { color: var(--lab-amber); line-height: 1.4; }
.lab-melody-summary small[hidden] { display: none; }

.lab-melody-controls {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.4rem;
  padding: 1rem;
  border: 1px solid rgba(216, 166, 122, 0.18);
  border-radius: 12px;
  background: rgba(216, 166, 122, 0.035);
}

.lab-smart-mix-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; }
#lab-smart-mix-panel[hidden] { display: none; }
.lab-mix-play-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; max-width: 100%; }
#lab-smart-mix-reset {
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--lab-amber);
  border-radius: 8px;
  background: transparent;
  color: var(--lab-amber);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
#lab-smart-mix-reset:disabled { border-color: var(--line); color: var(--lab-muted); opacity: 0.45; cursor: default; }
#lab-smart-mix-reset:focus-visible { outline: 2px solid var(--lab-amber); outline-offset: 3px; }

.lab-melody-length-controls,
.lab-melody-save-controls {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 0.65rem 0.85rem;
}

.lab-melody-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  color: var(--secondary);
  font-size: 0.8rem;
  cursor: pointer;
}

.lab-melody-link input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--lab-sage);
  cursor: pointer;
}

.lab-melody-length-field { width: min(170px, 100%); }
.lab-melody-instrument-field { flex: 0 1 170px; max-width: 100%; }
.lab-melody-slot-field { flex: 1 1 190px; max-width: 270px; }
.lab-melody-save-controls .lab-button { min-height: 44px; font-size: 0.78rem; }
.lab-melody-save-controls .lab-button:disabled { opacity: 0.45; }
#lab-melody-action-status { min-height: 1em; color: var(--lab-sage); font-size: 0.74rem; }
.lab-melody-delete-dialog { width: min(480px, calc(100% - 1rem)); }
.lab-melody-length-field[hidden] { display: none; }

.lab-melody-editor {
  min-width: 0;
  margin-top: 1.2rem;
  border: 1px solid rgba(216, 166, 122, 0.23);
  border-radius: 14px;
  overflow: hidden;
  background: #211d19;
}

.lab-melody-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
}

.lab-melody-editor-heading h3 { margin: 0; color: var(--secondary); font-size: 1rem; }
.lab-melody-editor-heading p { margin: 0.25rem 0 0; color: var(--lab-muted); font-size: 0.74rem; line-height: 1.45; }
.lab-melody-editor-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; }
.lab-melody-editor-actions .lab-button { min-height: 40px; font-size: 0.75rem; }
.lab-melody-editor-actions .lab-button:disabled { opacity: 0.45; }
.lab-melody-editor-status { min-height: 1.1em; margin: 0; padding: 0.25rem 1rem; color: var(--lab-sage); font-size: 0.72rem; }

.lab-melody-roll-scroll {
  --melody-key-width: 58px;
  --melody-beat-width: 48px;
  height: clamp(360px, 48vw, 560px);
  overflow: auto;
  position: relative;
  scrollbar-color: #846445 #27211d;
}

.lab-melody-roll-scroll:focus-visible { outline: 2px solid var(--lab-amber); outline-offset: -2px; }
.lab-melody-roll-inner { position: relative; }
.lab-melody-roll-ruler { position: sticky; top: 0; z-index: 5; display: flex; height: 32px; background: #332a23; }
.lab-melody-roll-corner,
.lab-melody-roll-pitch {
  position: sticky;
  left: 0;
  z-index: 3;
  flex: 0 0 var(--melody-key-width);
  width: var(--melody-key-width);
  border-right: 1px solid rgba(226, 179, 118, 0.28);
  color: var(--lab-muted);
  background: #302820;
  text-align: center;
}
.lab-melody-roll-corner { z-index: 6; display: grid; place-items: center; font-size: 0.57rem; letter-spacing: 0.07em; }
.lab-melody-roll-bar {
  flex: 0 0 calc(var(--melody-beat-width) * 4);
  padding: 0.48rem 0.45rem;
  border-left: 1px solid rgba(226, 179, 118, 0.45);
  color: var(--lab-amber);
  font-size: 0.68rem;
}
.lab-melody-roll-row { position: absolute; left: 0; display: flex; height: 24px; }
.lab-melody-roll-pitch { display: grid; place-items: center; font-size: 0.68rem; }
.lab-melody-roll-pitch.is-c { color: var(--lab-amber); font-weight: 700; }
.lab-melody-roll-row.is-black .lab-melody-roll-pitch { background: #28231e; }
.lab-melody-roll-grid {
  height: 24px;
  border-bottom: 1px solid rgba(240, 223, 200, 0.07);
  background-color: rgba(240, 223, 200, 0.025);
  background-image:
    linear-gradient(to right, rgba(240, 223, 200, 0.08) 1px, transparent 1px),
    linear-gradient(to right, rgba(240, 223, 200, 0.16) 1px, transparent 1px),
    linear-gradient(to right, rgba(226, 179, 118, 0.4) 1px, transparent 1px);
  background-size: 12px 100%, 48px 100%, 192px 100%;
}
.lab-melody-roll-row.is-black .lab-melody-roll-grid { background-color: rgba(0, 0, 0, 0.1); }
.lab-melody-note {
  position: absolute;
  z-index: 2;
  height: 20px;
  padding: 0;
  border: 1px solid #dbb77e;
  border-radius: 4px;
  background: #a67a4f;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: grab;
  touch-action: none;
}
.lab-melody-note.is-selected { z-index: 3; border-color: #c7dfa9; background: #8b9f70; }
.lab-melody-note.is-clipped { border-right-style: dashed; opacity: 0.7; }
.lab-melody-note:focus-visible { outline: 2px solid var(--lab-sage); outline-offset: 2px; }
.lab-melody-note:active { cursor: grabbing; }
.lab-melody-note-resize {
  position: absolute;
  top: 0;
  right: 0;
  width: min(14px, 45%);
  height: 100%;
  border-left: 1px solid rgba(255, 248, 233, 0.65);
  cursor: ew-resize;
}
.lab-melody-playhead {
  position: absolute;
  z-index: 4;
  top: 32px;
  bottom: 0;
  width: 2px;
  background: var(--lab-sage);
  box-shadow: 0 0 7px rgba(169, 184, 143, 0.7);
  pointer-events: none;
}
.lab-melody-edit-cursor {
  position: absolute;
  z-index: 1;
  top: 32px;
  bottom: 0;
  border-left: 1px dashed rgba(226, 179, 118, 0.45);
  pointer-events: none;
}
.lab-melody-marquee {
  position: absolute;
  z-index: 4;
  border: 1px solid var(--lab-sage);
  background: rgba(169, 184, 143, 0.18);
  pointer-events: none;
}

.lab-melody-methods {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-top: 1.5rem;
}

.lab-melody-method {
  min-width: 0;
  padding: 1.1rem;
  border: 1px solid rgba(216, 166, 122, 0.2);
  border-radius: 12px;
  background: rgba(216, 166, 122, 0.035);
}

.lab-melody-badge {
  display: inline-block;
  padding: 0.22rem 0.55rem;
  border: 1px solid rgba(169, 184, 143, 0.3);
  border-radius: 999px;
  color: var(--lab-sage);
  font-size: 0.67rem;
}

.lab-melody-method h3 {
  margin: 0.75rem 0 0.35rem;
  color: var(--secondary);
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
}

.lab-melody-method p {
  margin: 0;
  color: var(--lab-muted);
  font-size: 0.77rem;
  line-height: 1.55;
}

.lab-melody-midi { grid-column: 1 / -1; }
.lab-import-file { display: grid; gap: 8px; margin: 14px 0; font-size: .85rem; }
.lab-import-file input { width: 100%; min-width: 0; color: var(--secondary); }
.lab-import-file input::file-selector-button { padding: 10px 14px; border: 1px solid var(--lab-amber); border-radius: 8px; background: #30261e; color: var(--secondary); cursor: pointer; }
#lab-import-limits { display: block; color: var(--lab-muted); font-size: .75rem; }
#lab-import-details, #lab-import-status { margin-top: 10px; overflow-wrap: anywhere; }
#lab-import-cancel { margin-top: 10px; }
#lab-import-cancel[hidden] { display: none; }
.lab-melody-midi-connect,
.lab-melody-midi-options {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 0.65rem;
  margin-top: 0.9rem;
}
.lab-melody-midi-connect .lab-field,
.lab-melody-midi-options .lab-field { flex: 1 1 145px; max-width: 245px; }
.lab-melody-midi-connect .lab-field[hidden] { display: none; }

.lab-melody-record-controls,
.lab-melody-quantize { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; }
.lab-melody-record-controls { margin-top: 16px; }
.lab-melody-record-controls .lab-field,
.lab-melody-quantize .lab-field { flex: 0 1 180px; min-width: 120px; }
.lab-melody-quantize { margin: 12px 0; padding: 12px; border: 1px solid rgba(226, 184, 112, .18); border-radius: 10px; }
.lab-melody-quantize p { flex-basis: 100%; margin: 0; font-size: .85rem; }
.lab-melody-quantize p:empty { display: none; }
.lab-melody-record-status { min-height: 1.5em; font-size: .9rem; }
.lab-melody-midi-connect .lab-button,
.lab-midi-panic { min-height: 44px; font-size: 0.75rem; }
.lab-melody-midi-status { min-height: 1em; margin-top: 0.5rem !important; color: var(--lab-sage) !important; }
.lab-virtual-keyboard-scroll {
  width: max-content;
  max-width: 100%;
  margin: 1rem auto 0;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid rgba(226, 179, 118, 0.26);
  border-radius: 10px;
  background: #1d1916;
}
.lab-virtual-keyboard { position: relative; height: 112px; touch-action: pan-x; }
.lab-virtual-key:disabled { opacity: 0.35; cursor: not-allowed; }

.lab-track-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.lab-track-slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 10px; margin: 12px 0 20px; }
.lab-track-slot { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 14px; border: 1px solid rgba(226, 184, 112, .2); border-radius: 12px; background: #24201c; }
.lab-track-slot.is-active { border-color: var(--lab-sage); box-shadow: inset 3px 0 var(--lab-sage); }
.lab-track-identity { min-width: 0; grid-column: 1 / -1; display: grid; gap: 4px; }
.lab-track-identity strong { overflow-wrap: anywhere; }
.lab-track-identity small, .lab-track-length small, .lab-record-help { color: var(--lab-muted); font-size: .78rem; }
.lab-track-instrument { min-width: 0; width: 100%; min-height: 44px; padding: 8px; border: 1px solid rgba(226, 184, 112, .25); border-radius: 8px; color: var(--secondary); background: #1d1916; }
.lab-track-slot .lab-button { grid-column: 1 / -1; min-height: 44px; }
.lab-track-length { display: grid; gap: 8px; }
.lab-record-help { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-top: 8px; }
.lab-melody-quantize > strong { align-self: end; min-height: 46px; display: flex; align-items: center; }
.lab-melody-record-controls .lab-button, .lab-melody-quantize .lab-button { min-height: 46px; }
.lab-virtual-key {
  position: absolute;
  top: 0;
  padding: 0;
  cursor: pointer;
  touch-action: none;
}
.lab-virtual-key.is-white {
  width: 38px;
  height: 112px;
  border: 1px solid #82684e;
  border-radius: 0 0 5px 5px;
  background: linear-gradient(#e1d2b8, #bfa98b);
  color: #43372d;
  font-size: 0.63rem;
  font-weight: 700;
  text-align: center;
  padding-top: 88px;
}
.lab-virtual-key.is-black {
  z-index: 1;
  width: 24px;
  height: 70px;
  border: 1px solid #473c31;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(#3a3029, #171412);
}
.lab-virtual-key.is-active.is-white { background: linear-gradient(#cad8a8, #9bab78); }
.lab-virtual-key.is-active.is-black { background: linear-gradient(#9dae78, #66774c); }
.lab-virtual-key:focus-visible { outline: 3px solid var(--lab-amber); outline-offset: -3px; }
.lab-midi-panic { margin-top: 0.8rem; }

@media (max-width: 1040px) {
  .lab-configuration { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .lab-progression-field { grid-column: 1 / -1; }
  .lab-chords,
  .lab-chords[data-length="6"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lab-controls { gap: 1.25rem; }
}

@media (max-width: 760px) {
  .lab-intro { grid-template-columns: 1fr; gap: 1rem; }
  .lab-intro-copy { margin: 0; max-width: 48ch; }
  .lab-tool-header { flex-wrap: wrap; }
  .lab-settings { width: 100%; margin-right: 0; }
  .lab-transport { flex: 1; }
  .lab-transport .lab-button { flex: 1; }
  .lab-melody-header { grid-template-columns: minmax(0, 1fr); }
  .lab-melody-summary { min-width: 0; }
  .lab-melody-methods { grid-template-columns: minmax(0, 1fr); }
  .lab-melody-slot-field { max-width: none; }
  .lab-melody-editor-actions { width: 100%; }
  .lab-melody-editor-actions .lab-button { flex: 1 1 auto; }
}

@media (max-width: 560px) {
  .lab-configuration { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lab-bpm-field { grid-column: span 2; }
  .lab-instrument-field { grid-column: span 2; }
  .lab-chords,
  .lab-chords[data-length="6"] { grid-template-columns: 1fr; }
  .lab-chord { padding: 1.15rem; }
  .lab-chord h3 { margin-top: 0.55rem; }
  .lab-chord-name { margin-bottom: 1rem; }
  .lab-tool-icon { display: none; }
  .lab-export { width: 100%; }
}

/* Independent panels hide content without rebuilding musical state. */
.lab-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.lab-panel-header > div, .lab-tool-heading, .lab-melody-header > div { min-width: 0; }
.lab-collapse { flex: 0 0 44px; width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(218, 174, 100, .35); border-radius: 10px; background: rgba(218, 174, 100, .08); color: inherit; font: inherit; font-size: 1.5rem; cursor: pointer; }
.lab-collapse:hover { background: rgba(218, 174, 100, .16); }
.lab-collapse:focus-visible { outline: 2px solid #dab06d; outline-offset: 3px; }
.lab-collapse:disabled { opacity: .45; cursor: default; }
.lab-panel-body[hidden], .lab-import-reference[hidden] { display: none; }
.lab-melody-header { grid-template-columns: minmax(0, 1fr) 44px; align-items: center; }
.lab-tool-header { flex-wrap: nowrap; }
.lab-panel-body > .lab-melody-summary { margin-bottom: 1rem; }
.lab-import-reference { display: flex; flex-wrap: wrap; gap: .75rem 1.5rem; }
.lab-import-reference dt { font-size: .8rem; opacity: .7; }
.lab-import-reference dd { margin: .25rem 0 0; }

.lab-track-volume { display: flex; align-items: center; gap: .6rem; grid-column: 1 / -1; }
.lab-track-volume input { min-width: 0; flex: 1; min-height: 44px; accent-color: var(--lab-sage); }
.lab-virtual-keyboard.is-drums { height: auto; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 90px), 1fr)); gap: 10px; padding: 12px; }
.lab-virtual-key.lab-drum-pad { position: static; width: auto; height: auto; min-height: 64px; padding: 10px; border-radius: 9px; background: #45372a; color: #f6e8cc; }
.lab-drum-pad.is-active { background: #7e955f; }
.lab-melody-midi-options[hidden] { display: none; }

.lab-share { margin: 2rem 0; padding: 1.5rem; border: 1px solid rgba(218,174,100,.3); border-radius: 16px; }
.lab-share h2 { margin-bottom: 1rem; }
.lab-send-length { max-width: 10rem; margin-bottom: 1rem; }
