/* Bellworx editing surfaces. State and playback belong to their JS owners.
   Shared dimensions and machine-derived materials apply to every workspace. */
.compact-header,
#bellworx-host > .profile-strip,
#mobile-dock,
#bellworx-host:not([data-studio-view="instrument"]) #studio-workspace {
  width: calc(100% - var(--ui-gutter) * 2);
  max-width: var(--ui-width);
  margin-inline: auto;
}
.compact-header {
  display: grid;
  grid-template-columns: 36px minmax(180px, 240px) minmax(0, 1fr) 44px 44px;
  align-items: center;
  min-height: 72px;
  height: auto;
  padding: 0;
  gap: var(--ui-space-16);
}
.compact-header .wordmark {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 44px;
}
.compact-header .brand-symbol {
  margin: 0;
}
.machine-picker {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 44px;
}
.machine-picker > span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.machine-picker > span::after {
  content: none;
}
.compact-header .machine-picker #instrument-profile {
  width: 180px;
  max-width: none;
  min-width: 0;
  min-height: 44px;
  height: 44px;
  background: transparent;
  border: 0;
  color: var(--ui-text);
  font-size: 16px;
  font-weight: 500;
  padding: 0 var(--ui-space-4);
}
.compact-header #randomize {
  margin-left: auto;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: var(--ui-space-8);
}
.compact-header #randomize:hover {
  color: var(--ui-text);
}
.compact-header .instrument-help {
  margin: 0;
}
.compact-header .instrument-help > summary {
  font-size: var(--ui-type-value);
  letter-spacing: 2px;
}
#instrument-options {
  display: flex;
  flex-direction: column;
  gap: var(--ui-space-8);
  background: var(--ui-popover);
  padding: var(--ui-space-16);
  width: min(280px, calc(100vw - 32px));
  max-height: 75dvh;
  overflow-y: auto;
  scrollbar-gutter: stable;
  z-index: 30;
}
#instrument-options .meter-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--ui-text);
  font-size: var(--ui-type-meta);
}
#instrument-options select {
  min-height: 44px;
  background: transparent;
  color: var(--ui-text);
  border: 1px solid var(--ui-line);
  padding: var(--ui-space-8);
}
#instrument-options > button {
  min-height: 44px;
  background: transparent;
  border: 0;
  color: var(--ui-text);
  text-align: left;
  padding: var(--ui-space-8) 0;
}
#instrument-options details {
  position: static;
  margin: 0;
}
#instrument-options summary {
  justify-content: space-between;
  font-size: var(--ui-type-meta);
  letter-spacing: 0;
  min-height: 44px;
  width: 100%;
  margin: 0;
}
#instrument-options details > summary::after {
  content: "+";
  color: var(--ui-accent);
}
#instrument-options details[open] > summary::after {
  content: "−";
}
#instrument-options .hardware-view-actions {
  order: 2;
}
#instrument-options .help-copy {
  order: 3;
}
#instrument-options .help-copy strong {
  display: none;
}
#instrument-options .hardware-view-buttons button {
  font-family: var(--ui-font);
}
#instrument-options .hardware-view-buttons {
  box-shadow: none;
  border: 0;
  padding: 0;
  flex-wrap: wrap;
}
select {
  color-scheme: dark;
}
select option,
select optgroup {
  color: var(--ui-text);
  background: var(--ui-popover);
}
#mobile-dock {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: var(--ui-space-32);
  padding: 0 0 var(--ui-space-16);
}
#workspace-nav {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: var(--ui-space-24);
  margin: 0 var(--ui-space-24) 0 0;
  max-width: none;
}
#workspace-nav button {
  position: relative;
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 48px;
  padding: var(--ui-space-12) 0;
  font-size: var(--ui-type-control);
  color: var(--muted);
  text-align: center;
  white-space: nowrap;
  background: none;
  border: 0;
  border-radius: 0;
}
#workspace-nav button[aria-pressed="true"] {
  color: var(--ui-text);
  font-weight: 500;
  box-shadow: inset 0 -1px var(--ui-accent);
}
.transport-disclosure {
  order: 1;
  margin: 0 0 0 auto;
  width: auto;
}
.transport-disclosure .mobile-transport {
  padding: 0;
  gap: var(--ui-space-16);
}
#bellworx-host[data-studio-view="instrument"] .transport-disclosure,
#bellworx-host[data-studio-view="instrument"] #mobile-dock {
  display: none;
}
.mobile-transport > button {
  min-width: 48px;
  min-height: 48px;
  background: var(--ui-text);
  border: 0;
  border-radius: var(--ui-radius);
  color: var(--ui-inverse);
  font-size: var(--ui-type-value);
  box-shadow:
    inset 0 1px #fff8,
    0 2px #0005;
}
.mobile-transport label {
  color: var(--ui-muted);
}
.tempo-nudge {
  margin: 0;
}
.tempo-nudge button {
  min-width: 36px;
  width: 36px;
  min-height: 36px;
}
.mobile-tempo-control {
  width: auto;
  flex-shrink: 0;
}
.tempo-nudge > * {
  flex-shrink: 0;
}
#mobile-tempo {
  appearance: textfield;
  font-variant-numeric: tabular-nums;
  color: var(--ui-text);
  font-size: var(--ui-type-value);
  width: calc(3ch + var(--ui-space-8) + var(--ui-space-8));
  padding-inline: var(--ui-space-4);
  min-height: 36px;
}
#mobile-tempo::-webkit-inner-spin-button,
#mobile-tempo::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.mobile-volume {
  width: 116px;
}
.mobile-volume input {
  height: 36px;
  accent-color: var(--ui-accent);
}
#studio-workspace {
  margin: 0 auto;
  padding-top: var(--ui-space-16);
  padding-bottom: var(--ui-space-32);
  min-height: 440px;
}
#bellworx-host:not([data-studio-view="instrument"]) #studio-workspace {
  padding-inline: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#bellworx-host[data-studio-view="instrument"] #studio-workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#bellworx-host[data-studio-view="instrument"] {
  height: 100svh;
}
#bellworx-host[data-studio-view="instrument"] .hardware {
  min-height: 0;
}
.hardware {
  flex: 1;
  min-height: var(--instrument-min-height);
  margin-bottom: 0;
}
.hardware-knob:focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 3px;
}
/* Each workspace owns the remaining viewport. Dividers separate functions,
   rather than enclosing the application in a floating card. */
#bellworx-host[data-studio-view="tone"] .tuning-deck,
#flat-editor,
#files-workspace {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
  margin: 0;
  flex: 1;
}
/* Sound: select the voice, tune it, then edit the selected note. */
#bellworx-host:not([data-studio-view="tone"]) .sound-selector {
  display: none;
}
.tuning-deck > .section-heading,
.tuning-voice > div h3 {
  display: none;
}
.sound-selector {
  display: flex;
  gap: var(--ui-space-32);
  border-bottom: 1px solid var(--ui-line);
  margin-bottom: var(--ui-space-32);
}
.sound-selector button {
  min-height: 56px;
  padding: 0 0 var(--ui-space-16);
  background: transparent;
  color: var(--ui-muted);
  border: 0;
  border-radius: 0;
  font-size: var(--ui-type-value);
  letter-spacing: 0;
}
.sound-selector button[aria-pressed="true"] {
  color: var(--ui-text);
  box-shadow: inset 0 -2px var(--ui-accent);
}
#bellworx-host[data-studio-view="tone"] .tuning-deck {
  display: flex;
  flex-direction: column;
}
#bellworx-host[data-studio-view="tone"] .tuning-voices {
  display: flex;
  flex: 1;
  max-width: none;
}
#bellworx-host[data-studio-view="tone"] .tuning-voice {
  display: grid;
  flex: 1;
  align-content: stretch;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(160px, 1fr) auto;
  gap: var(--ui-space-32) var(--ui-space-48);
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  border-radius: 0;
}
.tuning-voice > div {
  display: none;
}
#bellworx-host[data-studio-view="tone"] .tuning-voice > label {
  display: grid;
  align-self: center;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--ui-space-12);
  margin: 0;
  font-size: var(--ui-type-meta);
  color: var(--ui-muted);
}
.tuning-voice > label output {
  grid-column: 2;
  grid-row: 1;
  font: var(--ui-type-value) var(--ui-font);
  color: var(--ui-text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.tuning-voice > label output small {
  font: var(--ui-type-meta) var(--ui-font);
  color: var(--ui-muted);
  letter-spacing: 0;
}
.tuning-voice > label input {
  grid-column: 1/-1;
  grid-row: 2;
  width: 100%;
  min-height: 44px;
}
#bellworx-host[data-studio-view="tone"] .note-inspector {
  grid-column: 1/-1;
  display: grid;
  align-items: start;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--ui-space-16);
  margin: var(--ui-space-8) 0 0;
  padding: var(--ui-space-24) 0 0;
  border-top: 1px solid var(--ui-line);
  border-bottom: 0;
  background: none;
  box-shadow: none;
}
.note-inspector > div {
  grid-column: 1/-1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--ui-space-16);
  min-width: 0;
}
.note-inspector h2 {
  margin: 0;
}
#note-state {
  font-size: var(--ui-type-meta);
  color: var(--ui-muted);
}
.note-inspector label {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 72px;
  gap: var(--ui-space-8);
  margin: 0;
  color: var(--ui-muted);
  font-size: var(--ui-type-meta);
}
#bellworx-host[data-studio-view="tone"] .note-inspector :is(input, select) {
  width: 100%;
  height: 100%;
  font-size: var(--ui-type-value);
  letter-spacing: 0;
}
/* All faders share the same track and thumb, including monitor and texture. */
:is(.tuning-voice, .tone, .mobile-volume) input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  accent-color: var(--ui-accent);
  cursor: ew-resize;
  margin: 0;
  min-width: 0;
  min-height: 44px;
}
:is(.tuning-voice, .tone, .mobile-volume) input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--ui-accent) var(--range-position, 0%),
    #edf0eb24 var(--range-position, 0%)
  );
  box-shadow: 0 1px #0007;
}
:is(.tuning-voice, .tone, .mobile-volume) input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 26px;
  margin-top: -11px;
  border-radius: 3px;
  background: linear-gradient(90deg, #bdc3bc, var(--ui-text) 30%, var(--ui-text) 70%, #b9bfb8);
  border: 1px solid #fff6;
  box-shadow: 0 2px 4px #0006;
}
:is(.tuning-voice, .tone, .mobile-volume) input[type="range"]::-moz-range-track {
  height: 4px;
  background: #edf0eb24;
  border: 0;
}
:is(.tuning-voice, .tone, .mobile-volume) input[type="range"]::-moz-range-progress {
  height: 4px;
  background: var(--ui-accent);
}
:is(.tuning-voice, .tone, .mobile-volume) input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 26px;
  border-radius: 3px;
  background: var(--ui-text);
  border: 1px solid #fff6;
}
/* Controls: the score stays mounted; mobile selects a lane within the same grid. */
#flat-editor {
  color: var(--ui-text);
  overflow: visible;
}
#flat-editor::before,
#flat-editor .screw,
#flat-editor .device-brand,
#flat-editor .section-number,
#flat-editor .instrument-top,
#flat-editor .control-strip > label:has(#bpm),
#flat-editor .monitor {
  display: none;
}
#flat-editor .control-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ui-space-24);
  margin: 0;
  padding: 0 0 var(--ui-space-24);
  border: 0;
  border-bottom: 1px solid var(--ui-line);
}
#flat-editor .control-strip label {
  font: var(--ui-type-meta) var(--ui-font);
  letter-spacing: 0;
  color: var(--ui-muted);
}
#flat-editor .control-strip select {
  font-size: var(--ui-type-value);
  min-width: 88px;
  color: var(--ui-text);
  background: var(--ui-field);
}
#flat-editor .control-strip .loop {
  order: 3;
  margin: 0 0 0 auto;
  min-height: 44px;
  color: var(--ui-muted);
}
#flat-editor .loop input {
  width: 20px;
  height: 20px;
  accent-color: var(--ui-accent);
}
#flat-editor .sequencer-heading {
  margin: 20px 0 var(--ui-space-12);
}
#flat-editor .sequencer-heading h2 {
  font-size: var(--ui-type-heading);
  letter-spacing: -0.035em;
  font-weight: 400;
}
#flat-editor #undo {
  background: none;
  color: var(--ui-muted);
  border: 0;
}
#flat-editor
  :is(.subtle, .step-label, .lane-label small, .pattern-hint, .chord > span, .tone output) {
  color: var(--ui-muted);
  opacity: 1;
}
#flat-editor .lane-label {
  font-size: var(--ui-type-meta);
  white-space: nowrap;
}
#flat-editor .sequencer {
  grid-template-columns: max-content repeat(16, minmax(32px, 1fr));
  min-width: 900px;
  gap: 6px;
}
#flat-editor .pad {
  height: clamp(48px, 7.2svh, 92px);
  font-size: var(--ui-type-meta);
  border: 1px solid #ffffff0c;
  border-radius: var(--ui-radius);
  background: var(--ui-key-surface);
  color: var(--ui-text);
  box-shadow: var(--ui-key-shadow);
}
#flat-editor .pad.on {
  background: color-mix(in srgb, var(--ui-accent) 22%, var(--ui-key));
  box-shadow:
    inset 0 -3px var(--ui-accent),
    inset 0 1px #fff1,
    0 2px #0005;
}
#flat-editor .pad.current {
  background: color-mix(in srgb, var(--ui-accent) 45%, var(--ui-key));
  box-shadow:
    inset 0 -4px var(--ui-text),
    inset 0 1px #fff4,
    0 0 12px color-mix(in srgb, var(--ui-accent) 18%, transparent);
  filter: none;
}
#flat-editor .pattern-hint {
  font-size: var(--ui-type-meta);
  line-height: 1.6;
  margin: var(--ui-space-12) 0 0;
}
#controls-lanes {
  display: none;
}
.harmony-disclosure {
  border-top: 1px solid var(--ui-line);
  margin-top: var(--ui-space-24);
}
.harmony-disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  min-height: 56px;
  color: var(--ui-text);
  font-size: var(--ui-type-control);
  list-style: none;
}
.harmony-disclosure > summary::-webkit-details-marker {
  display: none;
}
.harmony-disclosure > summary::after {
  content: "+";
  color: var(--ui-muted);
}
.harmony-disclosure[open] > summary::after {
  content: "−";
}
#flat-editor .lower-deck {
  border: 0;
  padding: var(--ui-space-8) 0 0;
  gap: var(--ui-space-32);
}
#flat-editor .chord {
  padding: var(--ui-space-12);
  background: var(--ui-field);
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  box-shadow: none;
}
#flat-editor .chord.active {
  border-color: var(--ui-accent);
}
#flat-editor .chord select {
  width: 100%;
  color: var(--ui-text);
  font-size: var(--ui-type-value);
  margin-top: var(--ui-space-8);
  padding: var(--ui-space-8) var(--ui-space-4);
  background: transparent;
  border: 0;
  box-shadow: none;
}
#flat-editor .tone label {
  font-size: var(--ui-type-meta);
  margin-top: var(--ui-space-8);
  min-height: 44px;
  color: var(--ui-muted);
}
#flat-editor .tone input {
  width: 100%;
  min-height: 44px;
}
#flat-editor .tone output {
  font-family: var(--ui-font);
  font-size: var(--ui-type-value);
  font-variant-numeric: tabular-nums;
}
/* Files: a composition library with two explicit exchange sections. */
#files-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 0 var(--ui-space-48);
  max-width: none;
}
.file-section {
  padding: 0 0 var(--ui-space-24);
  min-width: 0;
}
.project-section {
  display: flex;
  flex-direction: column;
  grid-row: span 2;
  border-right: 1px solid var(--ui-line);
  padding-right: var(--ui-space-48);
  padding-bottom: 0;
}
.file-section:last-child {
  border-top: 1px solid var(--ui-line);
  padding-top: var(--ui-space-16);
  padding-bottom: 0;
}
.file-section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  align-items: center;
  min-height: 44px;
  margin-bottom: var(--ui-space-12);
}
.file-section-heading h2 {
  margin: 0;
  font-size: var(--ui-type-heading);
  font-weight: 400;
  letter-spacing: -0.04em;
}
.project-title {
  display: flex;
  align-items: center;
  gap: var(--ui-space-12);
  margin: 0 0 var(--ui-space-24);
}
#files-workspace .project-title input {
  width: 100%;
  font-size: var(--ui-type-heading);
  letter-spacing: -0.04em;
  min-height: 96px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ui-line);
  border-radius: 0;
  box-shadow: none;
  padding: 0 0 var(--ui-space-8);
}
.project-title #dirty {
  font: var(--ui-type-meta) var(--ui-font);
  color: var(--ui-muted);
  white-space: nowrap;
}
#files-workspace .file-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--ui-space-8);
}
#files-workspace .file-actions button {
  min-width: 0;
  min-height: 64px;
  font-size: var(--ui-type-control);
  padding: var(--ui-space-12);
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: var(--ui-key-surface);
  color: var(--ui-text);
  box-shadow: var(--ui-key-shadow);
}
#files-workspace :is(#save, #export) {
  background: var(--ui-accent);
  color: var(--ui-inverse);
  border-color: transparent;
  font-weight: 500;
}
.saved-library {
  display: grid;
  gap: var(--ui-space-8);
  margin-top: auto;
  padding-top: var(--ui-space-32);
  font-size: var(--ui-type-meta);
  color: var(--ui-muted);
}
.saved-library select {
  width: 100%;
  font-size: var(--ui-type-value);
}
#storage-note {
  font-size: var(--ui-type-meta);
  color: var(--ui-muted);
  line-height: 1.5;
  margin: 10px 0 0;
}
.file-info {
  display: contents;
}
.file-info summary {
  grid-column: 2;
  grid-row: 1;
  cursor: pointer;
  list-style: none;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ui-muted);
}
.file-info summary::-webkit-details-marker {
  display: none;
}
.file-info p {
  grid-column: 1/-1;
  grid-row: 2;
  position: static;
  margin: 0;
  padding: var(--ui-space-12) 0;
  font-size: var(--ui-type-control);
  line-height: 1.5;
  color: var(--ui-muted);
  max-width: 60ch;
}
.file-info:not([open]) p {
  display: none;
}
#bellworx-host[data-studio-view="files"] .tuning-deck {
  display: none;
}
#status:empty {
  display: none;
}
#bellworx-host:is([data-studio-view="tone"], [data-studio-view="controls"]) #status:not(.error) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
#status {
  font: var(--ui-type-meta) var(--ui-font);
  line-height: 1.5;
  margin: var(--ui-space-16) 0;
}
#status.error {
  padding: var(--ui-space-12) var(--ui-space-16);
  border-left: 2px solid var(--ui-accent);
  background: var(--ui-surface);
}
@media (hover: hover) {
  #files-workspace .file-actions button:hover:not(:disabled) {
    filter: brightness(1.1);
  }
  #flat-editor .pad:hover:not(:disabled) {
    border-color: var(--ui-accent);
  }
}
@media (max-width: 1100px) {
  #mobile-dock {
    gap: var(--ui-space-16);
  }
  #workspace-nav {
    gap: var(--ui-space-12);
  }
  .transport-disclosure .mobile-transport {
    gap: var(--ui-space-8);
  }
  .mobile-volume {
    width: 80px;
  }
  #files-workspace {
    gap: 0 var(--ui-space-24);
  }
  .project-section {
    padding-right: var(--ui-space-24);
  }
  #flat-editor .lower-deck {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 700px) {
  .compact-header {
    gap: 0 var(--ui-space-8);
  }
  .machine-picker {
    flex: 1;
  }
  .compact-header .machine-picker #instrument-profile {
    width: 100%;
  }
  #mobile-dock {
    flex-wrap: wrap;
    gap: 0;
    padding-bottom: var(--ui-space-8);
  }
  #workspace-nav {
    gap: var(--ui-space-4);
  }
  #workspace-nav button {
    text-align: center;
    min-height: 44px;
    font-size: var(--ui-type-meta);
    padding: var(--ui-space-8) 2px;
  }
  .transport-disclosure {
    width: 100%;
    margin: 0;
  }
  .transport-disclosure .mobile-transport {
    padding: var(--ui-space-8) 0 0;
    gap: var(--ui-space-12);
  }
  .mobile-volume {
    width: auto;
    flex: 1;
    min-width: 60px;
  }
  .mobile-transport > button {
    min-width: 44px;
    min-height: 44px;
  }
  #studio-workspace {
    padding-top: 0;
    padding-bottom: var(--ui-space-24);
  }
  #bellworx-host[data-studio-view="tone"] .tuning-deck,
  #flat-editor,
  #files-workspace {
    padding: 0;
  }
  .sound-selector {
    gap: var(--ui-space-24);
    margin-bottom: var(--ui-space-12);
  }
  .sound-selector button {
    font-size: var(--ui-type-heading);
    min-height: 44px;
    padding-bottom: var(--ui-space-12);
  }
  #bellworx-host[data-studio-view="tone"] .tuning-voice {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    align-content: start;
    gap: var(--ui-space-8);
  }
  #bellworx-host[data-studio-view="tone"] .tuning-voice > label {
    grid-template-columns: 40px minmax(0, 1fr) 90px;
    gap: var(--ui-space-8);
  }
  .tuning-voice > label output {
    grid-column: 3;
    grid-row: 1;
    font-size: var(--ui-type-value);
  }
  .tuning-voice > label input {
    grid-column: 2;
    grid-row: 1;
    min-height: 44px;
  }
  #bellworx-host[data-studio-view="tone"] .note-inspector {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--ui-space-12);
    margin-top: var(--ui-space-8);
    padding-top: var(--ui-space-16);
  }
  .note-inspector label {
    grid-template-rows: auto 44px;
    gap: var(--ui-space-4);
  }
  #bellworx-host[data-studio-view="tone"] .note-inspector :is(input, select) {
    font-size: var(--ui-type-value);
    padding: 6px var(--ui-space-8);
  }
  #flat-editor .control-strip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    gap: var(--ui-space-12);
    padding-bottom: var(--ui-space-12);
  }
  #flat-editor .control-strip label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: var(--ui-type-meta);
    gap: var(--ui-space-4);
  }
  #flat-editor .control-strip .loop {
    grid-column: auto;
    flex-direction: row;
    align-items: center;
    align-self: end;
    margin: 0;
  }
  #flat-editor .control-strip select {
    width: 100%;
  }
  #flat-editor .control-strip select {
    min-width: 0;
    font-size: var(--ui-type-value);
    padding: 6px;
  }
  #flat-editor .sequencer-heading {
    display: none;
  }
  #controls-lanes {
    display: flex;
    gap: var(--ui-space-4);
    margin: var(--ui-space-8) 0 var(--ui-space-16);
    border-bottom: 1px solid var(--ui-line);
  }
  #controls-lanes button {
    flex: 1;
    min-width: 0;
    min-height: 44px;
    padding: var(--ui-space-4);
    background: none;
    border: 0;
    border-radius: 0;
    font-size: var(--ui-type-meta);
    color: var(--ui-muted);
  }
  #controls-lanes button[aria-pressed="true"] {
    color: var(--ui-text);
    box-shadow: inset 0 -2px var(--ui-accent);
  }
  #flat-editor .sequencer {
    min-width: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--ui-space-8);
  }
  #flat-editor .sequencer > span,
  #flat-editor .sequencer .lane-label {
    display: none;
  }
  #flat-editor .sequencer .pad {
    height: 54px;
    text-align: right;
    padding: var(--ui-space-8);
    font-size: var(--ui-type-meta);
  }
  #flat-editor .sequencer .pad::before {
    content: attr(data-step);
    position: absolute;
    left: 8px;
    top: 8px;
    font: var(--ui-type-meta) var(--ui-font);
    color: var(--ui-muted);
  }
  #flat-editor .sequencer[data-lane="kick"] .pad:not(.kick),
  #flat-editor .sequencer[data-lane="snare"] .pad:not(.snare),
  #flat-editor .sequencer[data-lane="hats"] .pad:not(.hats),
  #flat-editor .sequencer[data-lane="percussion"] .pad:not(.percussion),
  #flat-editor .sequencer[data-lane="bass"] .pad:not(.bass) {
    display: none;
  }
  #flat-editor .pattern-hint {
    display: none;
  }
  .harmony-disclosure {
    margin-top: var(--ui-space-16);
  }
  .harmony-disclosure > summary {
    min-height: 48px;
  }
  #flat-editor .lower-deck {
    grid-template-columns: 1fr;
    gap: var(--ui-space-24);
  }
  #flat-editor .chords {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: var(--ui-space-8);
  }
  #flat-editor .chord {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--ui-space-4) var(--ui-space-8);
    padding: var(--ui-space-8);
  }
  #flat-editor .chord > span {
    grid-column: 1/-1;
    margin: 0;
  }
  #flat-editor .chord select {
    margin: 0;
  }
  #files-workspace {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .project-section {
    display: block;
    grid-row: auto;
    border-right: 0;
    padding-right: 0;
    padding-bottom: var(--ui-space-16);
  }
  .file-section {
    padding: var(--ui-space-12) 0 var(--ui-space-16);
    border-bottom: 1px solid var(--ui-line);
  }
  .file-section:last-child {
    border-top: 0;
    border-bottom: 0;
    padding-top: var(--ui-space-12);
  }
  .file-section-heading h2 {
    font-size: var(--ui-type-heading);
  }
  #files-workspace .file-actions button {
    min-height: 44px;
  }
  .file-section-heading {
    margin-bottom: var(--ui-space-4);
    min-height: 36px;
  }
  .file-info summary {
    min-height: var(--ui-control-size);
  }
  .project-title {
    margin-bottom: var(--ui-space-12);
  }
  #files-workspace .project-title input {
    min-height: 56px;
    font-size: var(--ui-type-heading);
  }
  .saved-library {
    margin-top: var(--ui-space-16);
    padding-top: 0;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }
  .saved-library select {
    font-size: var(--ui-type-value);
    padding: var(--ui-space-8);
  }
}

/* Use the production display face only where hierarchy benefits from it. */
.sound-selector button,
.file-section-heading h2,
#flat-editor .sequencer-heading h2,
#files-workspace .project-title input {
  font-family: var(--ui-display);
}

/* Presentation-only feedback. No delays, layout animation, or audio coupling. */
@keyframes workspace-arrive {
  from {
    opacity: 0.72;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
#bellworx-host[data-input="pointer"][data-studio-view="tone"] .tuning-deck,
#bellworx-host[data-input="pointer"][data-studio-view="controls"] #flat-editor,
#bellworx-host[data-input="pointer"][data-studio-view="files"] #files-workspace {
  animation: workspace-arrive var(--ui-motion-enter) var(--ui-ease-settle);
}
:is(.tuning-deck, #flat-editor) :is(input, select) {
  transition:
    border-color var(--ui-motion-feedback) ease,
    box-shadow var(--ui-motion-feedback) ease;
}
:is(.tuning-deck, #flat-editor) :is(input, select):focus {
  border-color: var(--ui-accent);
}
.tuning-voice > label:focus-within output {
  color: var(--ui-accent);
}
#files-workspace .file-actions button {
  position: relative;
  overflow: hidden;
  transition:
    background var(--ui-motion-feedback) ease,
    box-shadow var(--ui-motion-feedback) ease,
    transform var(--ui-motion-feedback) var(--ui-ease-settle);
}
#files-workspace .file-actions button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: inset 0 2px 5px #0004;
}
#files-workspace #export[aria-busy="true"] {
  opacity: 1;
  cursor: progress;
}
#export[aria-busy="true"]::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 35%;
  height: 3px;
  background: currentColor;
  animation: render-travel 1.2s ease-in-out infinite alternate;
}
@keyframes render-travel {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(286%);
  }
}
#export[data-state="complete"]::before {
  content: "✓";
  margin-right: var(--ui-space-8);
}
#export[data-state="error"]::before {
  content: "!";
  margin-right: var(--ui-space-8);
}
@media (prefers-reduced-motion: reduce) {
  #bellworx-host[data-input="pointer"][data-studio-view] :is(.tuning-deck, #flat-editor, #files-workspace) {
    animation: none;
  }
  #export[aria-busy="true"]::after {
    animation: none;
    width: 100%;
    opacity: 0.5;
  }
  #files-workspace .file-actions button,
  :is(.tuning-deck, #flat-editor) :is(input, select) {
    transition: none;
  }
}

/* Subordinate file operations remain full-size targets without competing with Save/Export. */
#files-workspace .file-actions button:not(#save):not(#export) {
  background: transparent;
  box-shadow: none;
}
/* Sparse ruler marks make the two bipolar tuning faders read as measured controls. */
.tuning-voice > label input[type="range"] {
  background-image:
    linear-gradient(var(--ui-muted), var(--ui-muted)),
    repeating-linear-gradient(90deg, var(--ui-line) 0 1px, transparent 1px 12.5%);
  background-size:
    1px 8px,
    calc(100% - 18px) 4px;
  background-position:
    center calc(50% + 14px),
    center calc(50% + 16px);
  background-repeat: no-repeat;
}

/* The playhead owns one light treatment; focus remains a separate keyboard cue. */
#flat-editor .pad.current:not(:focus-visible) {
  outline: 0;
}
#flat-editor .pad.current::after {
  content: none;
}

/* Navigation shares the machine/action row where it fits; compact screens get
   one evenly distributed second row. DOM and focus order stay the same. */
@media (max-width: 1100px) {
  .compact-header {
    grid-template-columns: 36px minmax(0, 1fr) 44px 44px;
    grid-template-rows: 56px 48px;
    min-height: 104px;
  }
  .compact-header .wordmark {
    grid-column: 1;
    grid-row: 1;
  }
  .compact-header .machine-picker {
    grid-column: 2;
    grid-row: 1;
  }
  .compact-header #randomize {
    grid-column: 3;
    grid-row: 1;
  }
  .compact-header .instrument-help {
    grid-column: 4;
    grid-row: 1;
  }
  #workspace-nav {
    grid-column: 1/-1;
    grid-row: 2;
    justify-self: stretch;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0;
    gap: var(--ui-space-16);
  }
  #workspace-nav button {
    width: 100%;
    min-width: 0;
  }
}

@media (min-width: 701px) {
  #files-workspace {
    --file-heading-height: max(var(--ui-control-size), calc(var(--ui-type-heading) * 1.5));
  }
  #files-workspace .project-title {
    margin-bottom: var(--ui-space-12);
  }
  #files-workspace .file-section-heading {
    min-height: var(--file-heading-height);
  }
  #files-workspace .project-title input {
    height: var(--file-heading-height);
    min-height: var(--file-heading-height);
    padding-bottom: 0;
  }
}
/* Repeated control taps adjust the instrument instead of double-tap page zoom. */
#instrument-options button {
  touch-action: manipulation;
}

/* Short landscape viewports spend height on the instrument, not a second nav row. */
@media (min-width: 701px) and (max-width: 1100px) and (max-height: 500px) {
  .compact-header {
    grid-template-columns: 36px minmax(180px, 220px) minmax(0, 1fr) 44px 44px;
    grid-template-rows: 56px;
    min-height: 56px;
    gap: var(--ui-space-8);
  }
  .compact-header #workspace-nav {
    grid-column: 3;
    grid-row: 1;
    gap: var(--ui-space-8);
  }
  .compact-header #workspace-nav button {
    font-size: var(--ui-type-meta);
    min-width: 44px;
  }
  .compact-header #randomize {
    grid-column: 4;
  }
  .compact-header .instrument-help {
    grid-column: 5;
  }
  #bellworx-host[data-studio-view="instrument"] #studio-workspace {
    padding-block: var(--ui-space-8);
  }
}

/* First-use help belongs to the session, never to individual machine meshes. */
#first-play {
  position: absolute;
  bottom: var(--ui-space-8);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--ui-space-12);
  z-index: 2;
  white-space: nowrap;
  color: var(--ui-muted);
  font-size: var(--ui-type-meta);
}
#first-play button {
  min-width: 64px;
  min-height: 44px;
  padding: var(--ui-space-8) var(--ui-space-16);
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: var(--ui-surface);
  color: var(--ui-text);
}
