/* A viewport-sized instrument: only the current work surface may scroll. */
:root {
  color-scheme: light;
  --paper: #edf2ef; --surface: #fff; --surface-soft: #f6f9f7;
  --ink: #18343b; --muted: #526c71; --line: #d2dedb;
  --teal: #176b70; --teal-strong: #0e5358; --teal-wash: #e4f2ef;
  --coral: #d97858; --coral-wash: #fff0e9;
  --shadow: 0 5px 18px rgba(18,55,57,.06);
}
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { margin: 0; padding-top: var(--sim-nav-offset,44px); background: var(--paper); color: var(--ink); font-family: 'Inter','Lato',sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }
input, select { color: var(--ink); }
input[type=range] { accent-color: var(--teal); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.eyebrow { color: var(--teal); font-size: .7rem; font-weight: 800; }
.app-shell { position: relative; display: flex; flex-direction: column; gap: 6px; width: min(100%,1440px); height: calc(var(--app-height,100dvh) - var(--sim-nav-offset,44px)); min-height: 0; margin: 0 auto; padding: 8px max(10px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left)); }
.workspace-header { display: flex; align-items: center; gap: 12px; flex-shrink: 0; min-height: 44px; }
.project-name-field { flex: 1; min-width: 0; }
.project-name-field > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.project-name-field input { display: block; width: min(100%,560px); min-height: 44px; padding: 5px 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--ink); font: 650 clamp(1rem,2vw,1.5rem)/1.2 'Fraunces',Georgia,serif; }
.project-name-field input:hover, .project-name-field input:focus { border-color: var(--line); background: var(--surface); }
.top-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.primary-button, .secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 13px; border: 1px solid var(--teal); border-radius: 10px; font-size: .85rem; font-weight: 750; text-align: center; }
.primary-button { background: var(--teal); color: #fff; }
.primary-button:hover { background: var(--teal-strong); }
.secondary-button { background: var(--surface); color: var(--teal-strong); }
.secondary-button:hover { background: var(--teal-wash); }
.danger-button { border-color: var(--coral); background: var(--coral-wash); color: #873e29; }
.text-button { min-height: 44px; padding: 5px 8px; border: 0; background: transparent; color: var(--teal-strong); font-weight: 750; text-decoration: underline; text-underline-offset: 3px; }
.slot-strip { display: grid; flex-shrink: 0; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 7px; }
.slot-card { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 44px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); text-align: left; }
.slot-card:hover { border-color: var(--teal); }
.slot-card.selected { border-color: var(--teal); background: var(--teal-wash); box-shadow: inset 0 0 0 1px var(--teal); }
.slot-index { flex: none; color: var(--muted); font-size: .72rem; font-weight: 800; }
.slot-icon { display: grid; place-items: center; flex: 0 0 26px; width: 26px; height: 26px; color: var(--teal); font: 700 1.25rem Georgia,serif; }
.kind-drums .slot-icon { color: #a75337; }
.kind-strings .slot-icon { color: #915f49; }
.kind-bass .slot-icon { color: #4c628c; }
.slot-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; font-weight: 750; }
.control-band { display: grid; grid-template-columns: auto auto minmax(110px,1fr) auto auto; align-items: center; gap: 12px; flex-shrink: 0; min-height: 48px; }
.transport-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; min-width: 130px; padding: 8px 12px; border: 0; border-radius: 10px; background: var(--coral); color: #fff; font-size: .83rem; font-weight: 800; }
.transport-button:hover { background: #b95c40; }
.transport-button.playing { background: var(--teal-strong); }
.tempo-control { display: flex; align-items: center; gap: 2px; }
.tempo-control button { width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--teal); font-size: 1.2rem; font-weight: 800; }
.tempo-control label { position: relative; display: block; }
.tempo-control label span { position: absolute; top: 4px; left: 0; right: 0; text-align: center; font-size: .58rem; color: var(--muted); pointer-events: none; }
.tempo-control input { width: 63px; height: 44px; padding: 14px 3px 2px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); text-align: center; font-size: 1rem; font-weight: 800; }
.volume-control { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; color: var(--muted); font-size: .72rem; font-weight: 750; }
.volume-control input { min-width: 60px; width: min(140px,100%); height: 44px; margin: 0; }
.motion-toggle { white-space: nowrap; }
.motion-toggle.is-on { background: var(--teal-wash); box-shadow: inset 0 0 0 1px var(--teal); }
.technical-settings { position: relative; color: var(--muted); font-size: .8rem; }
.technical-settings summary { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; list-style: none; font-weight: 900; }
.technical-settings summary::-webkit-details-marker { display: none; }
.technical-settings > div { position: absolute; z-index: 30; top: 50px; right: 0; display: grid; gap: 12px; width: 280px; max-width: calc(100vw - 24px); padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.latency-control { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.latency-control input { width: 155px; height: 44px; }
.latency-control output { font-size: .75rem; }
.instrument-workspace { display: grid; grid-template-columns: 64px minmax(0,1fr) 64px; gap: 8px; flex: 1; min-height: 0; }
.performance-a { grid-column: 1; min-height: 0; }
.performance-b { grid-column: 3; min-height: 0; }
.workspace-center { grid-column: 2; grid-row: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; }
.instrument-workspace.is-empty .workspace-center { grid-column: 1 / -1; }
.app-tabs { display: flex; gap: 5px; flex-shrink: 0; }
.app-tabs button { flex: 1; min-width: 0; min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: .85rem; font-weight: 800; }
.app-tabs button:hover { border-color: var(--teal); }
.app-tabs button.selected { border-color: var(--teal); background: var(--teal); color: #fff; }
.view-card { flex: 1; min-height: 0; min-width: 0; padding: 10px; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.view-sequence { overflow: hidden; }
@media (max-height: 650px) {
  .view-sequence { overflow: auto; }
}
.section-intro h2 { margin: 0; font-size: 1.1rem; }
.section-intro p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.35; }
.preset-chooser { padding: clamp(6px,2vw,24px); }
.preset-chooser-intro { margin-bottom: 18px; }
.preset-chooser h2 { margin: 6px 0; font: 650 clamp(1.3rem,2.3vw,1.8rem)/1.2 'Fraunces',Georgia,serif; }
.preset-chooser p { margin: 0; color: var(--muted); font-size: .88rem; }
.preset-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; }
.preset-card { display: flex; flex-direction: column; align-items: start; gap: 12px; min-width: 0; padding: 18px; border: 2px solid var(--line); border-radius: 14px; background: var(--surface-soft); color: var(--ink); text-align: left; }
.preset-card:hover { border-color: var(--teal); background: var(--teal-wash); }
.preset-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 11px; background: var(--teal); color: #fff; font: 700 1.7rem Georgia,serif; }
.preset-strings .preset-icon { background: #a66f56; }
.preset-bass .preset-icon { background: #506b99; }
.preset-drums .preset-icon { background: #bd6145; }
.preset-card-copy { display: flex; flex-direction: column; gap: 6px; }
.preset-card strong { font-size: 1.1rem; }
.preset-card small { color: var(--muted); font-size: .78rem; line-height: 1.4; }
.preset-arrow { align-self: end; color: var(--teal); }
.audio-alert { flex-shrink: 0; padding: 8px; border: 1px solid var(--coral); border-radius: 9px; background: var(--coral-wash); font-size: .8rem; }
.notice { position: fixed; z-index: 10020; bottom: 18px; left: 50%; display: flex; align-items: center; justify-content: space-between; gap: 15px; width: min(92vw, 560px); padding: 12px 14px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: 0 10px 32px rgba(0,0,0,.2); transform: translateX(-50%); font-size: .83rem; }
.notice button { flex: none; border: 0; background: transparent; color: #fff; font-size: 1.3rem; }
.modal-backdrop { position: fixed; z-index: 10010; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(18, 43, 47, .65); }
.share-dialog, .open-dialog { position: relative; width: min(100%, 520px); max-height: min(92vh, 840px); overflow: auto; padding: 28px; border-radius: 18px; background: var(--surface); box-shadow: 0 28px 70px rgba(0,0,0,.22); }
.open-dialog { display: flex; flex-direction: column; gap: 12px; width: min(100%, 430px); }
.share-dialog h2, .open-dialog h2 { margin: 0 0 9px; padding-right: 34px; font: 650 1.65rem/1.2 'Fraunces', Georgia, serif; }
.share-dialog p, .open-dialog p { margin: 0 0 15px; color: var(--muted); font-size: .85rem; line-height: 1.5; }
.open-dialog .modal-close { align-self: end; }
.modal-close { position: absolute; top: 14px; right: 16px; border: 0; background: transparent; color: var(--muted); font-size: 1.65rem; }
.qr-image { display: block; width: min(100%, 370px); max-height: 430px; object-fit: contain; margin: 16px auto; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.save-qr-button { width: 100%; min-height: 56px; margin: 3px 0 14px; font-size: 1rem; }
.share-link { display: flex; gap: 7px; margin-bottom: 11px; }
.share-link input { min-width: 0; flex: 1; padding: 9px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); font-size: .72rem; }
.share-link .secondary-button { min-height: 38px; padding: 7px 11px; }
.project-file-download { display: block; margin-top: 8px; font-size: .76rem; }
.share-dialog small { display: block; margin-top: 14px; color: var(--muted); font-size: .72rem; line-height: 1.4; }


.notice { bottom: max(16px,env(safe-area-inset-bottom)); }
.notice button, .modal-close { min-width: 44px; min-height: 44px; }
.share-dialog, .open-dialog { max-height: calc(var(--app-height,100dvh) - 32px); }
@media (max-width: 1000px) {
  .control-band { gap: 8px; }
  .volume-control { flex-direction: column; gap: 0; }
  .volume-control span { font-size: .62rem; }
  .volume-control input { height: 28px; }
  .preset-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .app-shell { gap: 5px; padding-top: 5px; padding-inline: max(6px,env(safe-area-inset-left)); }
  .workspace-header { gap: 5px; }
  .top-actions { gap: 5px; }
  .top-actions button { padding-inline: 9px; font-size: .75rem; }
  .slot-strip { gap: 4px; }
  .slot-card { gap: 4px; padding: 4px 6px; }
  .slot-icon { display: none; }
  .slot-name { font-size: .72rem; }
  .control-band { grid-template-columns: auto minmax(0,1fr) auto; gap: 4px 8px; }
  .transport-button { grid-column: 1; grid-row: 1; min-width: 113px; padding: 6px 8px; font-size: .74rem; }
  .tempo-control { grid-column: 2; grid-row: 1; justify-content: center; }
  .tempo-control input { width: 52px; }
  .technical-settings { grid-column: 3; grid-row: 1; justify-self: end; }
  .volume-control { grid-column: 1 / 3; grid-row: 2; flex-direction: row; gap: 8px; justify-content: start; }
  .volume-control span { font-size: .67rem; }
  .volume-control input { width: 100%; max-width: 150px; height: 44px; }
  .motion-toggle { grid-column: 3; grid-row: 2; font-size: .72rem; padding-inline: 8px; }
  .instrument-workspace { grid-template-columns: minmax(0,1fr) minmax(0,1fr); grid-template-rows: minmax(0,1fr) 90px; gap: 6px; }
  .workspace-center { grid-column: 1 / -1; grid-row: 1; gap: 5px; }
  .performance-a { grid-column: 1; grid-row: 2; }
  .performance-b { grid-column: 2; grid-row: 2; }
  .instrument-workspace.is-empty { grid-template-rows: minmax(0,1fr); }
  .app-tabs button { font-size: .78rem; padding-inline: 5px; }
  .view-card { padding: 8px; border-radius: 12px; }
  .notice { bottom: 110px; padding: 7px 10px; font-size: .75rem; }
  .preset-chooser { padding: 8px; }
  .preset-card { padding: 12px; gap: 8px; }
  .preset-chooser-intro { margin-bottom: 12px; }
  .preset-card strong { font-size: .9rem; }
  .preset-card small { font-size: .72rem; }
}
@media (max-width: 370px) {
  .control-band { gap: 4px; }
  .transport-button { min-width: 100px; }
  .tempo-control input { width: 44px; }
  .motion-toggle { padding-inline: 5px; font-size: .65rem; }
  .slot-index { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}

.mapping-dialog { position: relative; width: min(100%,380px); max-height: calc(var(--app-height,100dvh) - 32px); overflow: auto; padding: 24px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.mapping-dialog h2 { margin: 0 38px 8px 0; font-size: 1.3rem; }
.mapping-dialog p { margin: 0 0 16px; color: var(--muted); font-size: .85rem; }
.source-targets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.source-targets button { min-height: 48px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); color: var(--ink); font-weight: 750; font-size: .85rem; }
.source-targets button[aria-pressed=true] { border-color: var(--teal); background: var(--teal-wash); }

/* Status messages reserve space rather than covering playable controls. */
.notice { position: static; z-index: auto; flex: 0 0 auto; width: 100%; margin: 0; padding: 3px 10px; transform: none; border-radius: 9px; box-shadow: none; font-size: .78rem; }
