/* Brand and semantic colours shared by the studio, mixer, and dialogs. */
:root {
  color-scheme: dark;
  --brand: #9487F2;
  --primary-hover: #A69BF5;
  --primary-pressed: #8173DD;
  --on-primary: #141414;
  --selected-bg: rgba(148, 135, 242, 0.12);
  --page: #141414;
  --surface: #242424;
  --raised: #2D2D2D;
  --ink: #FFFFFF;
  --muted: #A1A1AA;
  --line: #333333;
  --control-line: #777777;
  --accent: var(--brand);
  --accent-text: #D8D2FA;
  --focus: var(--accent);
  --intro-bg: var(--raised);
  --chorus-bg: var(--raised);
  --bridge-bg: var(--raised);
  --warning: #E4B780;
  --success: #A9D7A0;
  --backdrop: rgb(0 0 0 / 60%);
  --wave-grid: var(--line);
  --waveform: var(--muted);
  --stem-default: #90D6C7;
  --stem-low: #8BBBEA;
  --stem-guitar: #E4B780;
  --stem-backing: #BEABE9;
  --radius: 16px;
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--ink);
  background: var(--page);
}
:root[data-theme="light"] {
  color-scheme: light;
  --page: #F5F3FA;
  --surface: #FFFFFF;
  --raised: #F0EDF7;
  --ink: #24212C;
  --muted: #60596A;
  --line: #DCD7E4;
  --control-line: #766F81;
  --accent: #5946A2;
  --accent-text: var(--accent);
  --intro-bg: #E8EEF4;
  --chorus-bg: #EEE8F3;
  --bridge-bg: #F5EDE0;
  --warning: #704825;
  --success: #38613B;
  --stem-default: #1B6D60;
  --stem-low: #285A87;
  --stem-guitar: #84511B;
  --stem-backing: #624493;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.topbar {
  min-height: 68px; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px max(20px, calc((100vw - 1360px) / 2));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 750; white-space: nowrap; }
.brand-mark { display: block; flex: none; width: 32px; height: 32px; }
.brand-middle, .brand-chord { color: var(--brand); }
.top-actions, .song-actions, .dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; }
button, .button, select, input[type="text"], textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--control-line);
  border-radius: 8px; padding: 7px 11px; min-height: 38px;
}
button, .button, select { background: var(--raised); }
button, .button, select { cursor: pointer; }
button:hover, .button:hover, select:hover { border-color: var(--accent); }
.brand:focus-visible, button:focus-visible, .button:focus-within, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
button:disabled { opacity: .5; cursor: default; }
button[aria-pressed="true"], button[aria-current="true"] { border-color: var(--accent); background: var(--selected-bg); color: var(--accent-text); font-weight: 680; }
.primary { background: var(--brand); border-color: var(--accent); color: var(--on-primary); font-weight: 640; }
.primary:hover:not(:disabled) { background: var(--primary-hover); }
.primary:active:not(:disabled) { background: var(--primary-pressed); }
.file-button { position: relative; display: inline-flex; align-items: center; white-space: nowrap; overflow: hidden; }
.file-button input { position: absolute; inset: 0; width: 100%; opacity: 0; cursor: pointer; }
.layout { max-width: 1400px; margin: auto; padding: 24px 20px 40px; display: grid; grid-template-columns: 205px minmax(0, 1fr); gap: 22px; }
.library { min-width: 0; padding: 15px 0; }
.library-heading { display: grid; gap: 5px; margin: 0 0 17px; }
.library-toggle { display: inline-flex; align-items: center; justify-self: start; gap: 9px; font-weight: 650; }
.library-toggle-icon { font-size: 1.25rem; line-height: 1; }
.library-toggle-label { display: none; }
.library-toggle[aria-expanded="true"] .library-toggle-label { display: inline; }
.library-toggle::after {
  content: ''; width: 6px; height: 6px; margin-top: -3px;
  border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg);
}
.library-toggle[aria-expanded="true"]::after { margin-top: 3px; transform: rotate(225deg); }
.library:has(.library-toggle[aria-expanded="false"]) .songs { display: none; }
@media (width > 1100px), (width > 980px) and (orientation: landscape) {
  .layout:has(.library-toggle[aria-expanded="false"]) { grid-template-columns: 52px minmax(0, 1fr); }
  .library:has(.library-toggle[aria-expanded="false"]) .offline { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .library-toggle::after { margin-top: 0; transform: rotate(-45deg); }
  .library-toggle[aria-expanded="true"]::after { margin-top: 0; transform: rotate(135deg); }
}
.offline { color: var(--muted); font-size: .81rem; }
.offline[data-ready="true"] { color: var(--success); }
.songs { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.songs li { display: flex; position: relative; gap: 4px; min-width: 0; }
.songs li > button:first-child { display: grid; flex: 1; min-width: 0; text-align: left; padding: 10px 12px; overflow-wrap: anywhere; user-select: none; -webkit-touch-callout: none; }
.songs li[data-dragging] > button { cursor: grabbing; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.songs li[data-drop]::after { content: ''; position: absolute; inset-inline: 0; height: 2px; background: var(--accent); pointer-events: none; }
.songs li[data-drop="before"]::after { top: -3px; }
.songs li[data-drop="after"]::after { bottom: -3px; }
.songs small { font-weight: 450; color: var(--muted); }
.main-column, .studio, .sheet-panel, .mixer-panel { min-width: 0; }
.studio { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.song-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 14px; padding: 18px 20px 14px;
}
.song-info { min-width: 0; overflow-wrap: anywhere; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(29px, 4.2vw, 45px); letter-spacing: -.06em; line-height: 1.08; }
h2 { font-size: .99rem; font-weight: 690; }
.eyebrow { color: var(--muted); font-size: .78rem; font-weight: 660; letter-spacing: .055em; text-transform: uppercase; margin-bottom: 4px; }
.song-actions { align-items: center; }
.song-actions label, .transport label { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: .87rem; }
.song-actions select, .transport select { color: var(--ink); }
#play { min-height: 42px; min-width: 92px; }
#silent-play { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; }
#silent-play[aria-pressed="false"] .sound-off,
#silent-play[aria-pressed="true"] .sound-on { display: none; }
#toggle-mixer[aria-expanded="true"] { background: var(--selected-bg); color: var(--accent-text); }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .85rem; }
.song-info .clock { display: block; margin-top: 4px; }
.song-progress { position: relative; height: 44px; margin: 0 19px; }
.song-progress[data-sections="true"] { height: 66px; }
.song-progress-rail {
  position: absolute; top: calc(50% - 3px); right: 0; left: 0; height: 6px;
  border-radius: 4px; outline: 1px solid var(--control-line); background: var(--page); overflow: hidden;
}
.song-progress[data-sections="true"] .song-progress-rail { top: calc((100% + 30px) / 2 - 3px); }
#song-progress { display: block; height: 100%; width: 0%; background: var(--accent); }
#song-seek { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; appearance: none; background: transparent; cursor: ew-resize; }
.song-progress[data-sections="true"] #song-seek { top: 30px; height: calc(100% - 30px); }
#song-seek::-webkit-slider-thumb { appearance: none; width: 2px; height: 28px; background: transparent; }
#song-seek::-moz-range-thumb { width: 2px; height: 28px; border: 0; background: transparent; }
#song-seek:focus-visible { outline-offset: 0; }
.song-sections { position: absolute; inset: 0 0 auto; height: 30px; pointer-events: none; }
.progress-section {
  position: absolute; inset-block: 0; overflow: hidden; padding: 2px 5px; min-height: 30px;
  border-radius: 5px; text-align: left; color: var(--ink); background: var(--raised);
  font-size: .78rem; white-space: nowrap; text-overflow: ellipsis; pointer-events: auto;
}
.progress-section[data-kind="intro"], .progress-section[data-kind="outro"] { background: var(--intro-bg); }
.progress-section[data-kind="chorus"] { background: var(--chorus-bg); }
.progress-section[data-kind="bridge"], .progress-section[data-kind="break"] { background: var(--bridge-bg); }
.progress-section[aria-current="true"] { background: var(--selected-bg); color: var(--accent-text); border-color: var(--accent); }
.sheet-layout { --mixer-width: 30%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(230px, var(--mixer-width)); gap: 16px; }
.sheet-layout[data-mixer-hidden="true"] { grid-template-columns: minmax(0, 1fr); }
.sheet-layout:has(> .mixer-panel:not([hidden])) { padding-inline-end: 12px; }
.sheet-layout > .mixer-panel { margin-block: 12px; }
.sheet-panel { padding: 14px 19px 17px; }
.song-sheet-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 4px; padding-block: 20px; }
.sheet-heading-title { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 9px; margin-inline-end: auto; }
.song-sheet-heading h2 { font-size: 22px; line-height: 1.25; }
#sheet-silent-status { color: var(--accent); }
.song-sheet-heading button { min-height: 40px; padding: 7px 14px; border-radius: 12px; font-size: .9rem; font-weight: 650; white-space: nowrap; }
#toggle-mixer { display: none; align-items: center; justify-content: space-between; gap: 10px; min-width: 117px; }
#mixer-toggle-count, #mixer-toggle-icon { display: none; }
.sheet-layout[data-mixer-hidden="true"] #toggle-mixer { display: inline-flex; width: 188px; min-width: 188px; }
.sheet-layout[data-mixer-hidden="true"] #mixer-toggle-count,
.sheet-layout[data-mixer-hidden="true"] #mixer-toggle-icon { display: inline; }
.chord-cues { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.chord-cue {
  min-width: 0; display: flex; align-items: baseline; align-content: center; flex-wrap: wrap; gap: 4px 10px;
  min-height: 66px; padding: 9px 12px; border-radius: 9px;
}
.chord-cue span { font-size: .82rem; font-weight: 700; }
.chord-cue strong { font-size: clamp(29px, 4.3vw, 45px); line-height: 1; letter-spacing: -.045em; overflow-wrap: anywhere; }
.cue-now { color: var(--ink); background: var(--selected-bg); }
.cue-now strong { color: var(--accent); }
.cue-next { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.cue-next small { font-size: .83rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet-timing-tools, .cue-timing-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.sheet-timing-tools { margin-top: 9px; }
.sheet-timing-tools button, .cue-timing button, .cue-timing input { min-height: 32px; font-size: .84rem; padding-block: 4px; }
.cue-timing { padding: 9px; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; background: var(--raised); }
.cue-timing-heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; margin-bottom: 6px; overflow-wrap: anywhere; }
.cue-timing-heading strong { font-size: .92rem; }
.cue-timing fieldset { min-width: 0; margin: 0; padding: 0; border: 0; display: grid; gap: 6px; }
.cue-timing label { display: inline-flex; gap: 5px; align-items: center; font-size: .84rem; }
.cue-timing output, #cue-timing-start, #cue-timing-original { font-variant-numeric: tabular-nums; }
#cue-timing-status:not(:empty) { margin-top: 5px; }
#cue-edit-form textarea { width: 100%; min-width: 0; padding: 6px 8px; font: inherit; resize: vertical; }
.song-sheet {
  display: grid; align-content: start; gap: 5px; margin-top: 0; padding: 0 4px 6px;
  border-top: 1px solid var(--line); max-height: clamp(240px, 49svh, 550px); overflow-y: auto; scrollbar-width: thin;
}
.sheet-section { margin: 5px 0 0 7px; font-size: .83rem; color: var(--muted); }
.sheet-section button {
  min-height: 27px; padding: 2px 6px; margin-left: -6px; color: inherit; font: inherit;
  text-align: left; background: transparent; border-color: transparent;
}
.sheet-section button:hover { border-color: var(--accent); }
.sheet-section button[aria-pressed="true"] { border-color: var(--accent); background: var(--selected-bg); }
.sheet-row {
  display: flex; flex-wrap: wrap; align-items: end; gap: 3px 6px; min-width: 0;
  padding: 3px 6px; border-left: 3px solid transparent; border-radius: 4px 8px 8px 4px;
}
.sheet-row[data-active="true"] { background: var(--selected-bg); border-color: var(--accent); border-inline-start-width: 5px; padding-inline-start: 4px; }
.sheet-word[data-current-word="true"] { background: var(--brand); color: var(--on-primary); border-radius: 3px; }
.sheet-phrase { display: grid; justify-items: start; min-width: 0; max-width: 100%; }
.sheet-symbols { display: flex; gap: 3px; flex-wrap: wrap; }
.sheet-chord {
  min-height: 25px; padding: 1px 5px; border-radius: 5px; background: transparent;
  color: var(--accent-text); border-color: transparent; font-size: .93rem; font-weight: 740;
  text-align: left; overflow-wrap: anywhere; max-width: 100%;
}
.sheet-chord[aria-current="true"] { background: var(--brand); border-color: var(--accent); color: var(--on-primary); }
.sheet-chord[data-next="true"] { border-color: var(--accent); }
.sheet-lyric {
  min-height: 27px; padding: 0 5px; background: transparent; text-align: left;
  border-color: transparent; font-size: clamp(17px, 2.1vw, 21px); line-height: 1.27;
  overflow-wrap: anywhere; max-width: 100%;
}
.sheet-lyric:hover { text-decoration: underline; border-color: transparent; }
.sheet-chord, .sheet-lyric { touch-action: manipulation; }
.sheet-chord[data-timing-selected="true"], .sheet-lyric[data-timing-selected="true"] { outline: 2px solid var(--warning); outline-offset: -2px; }
.mixer-panel {
  position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0;
  color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 15px 19px;
}
.mixer-heading, #vocal-mode-field, #vocal-split-open { flex-shrink: 0; }
.mixer-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 4px 7px; margin-bottom: 16px; }
.mixer-heading-titles { display: flex; min-width: 0; flex-direction: column; gap: 0; }
.mixer-heading h2 { font-size: 22px; line-height: 1.25; font-weight: 650; }
#collapse-mixer { width: 36px; height: 32px; min-height: 32px; padding: 0; border-radius: 9px; background: var(--raised); color: var(--ink); font-size: 1.25rem; line-height: 1; }
#mixer-summary { color: var(--muted); }
#mixer-resize { position: absolute; z-index: 2; inset: 0 auto 0 -7px; width: 14px; min-height: 0; padding: 0; border: 0; border-radius: 6px; background: transparent; cursor: col-resize; touch-action: none; }
#mixer-resize::after { content: ''; position: absolute; top: 50%; left: 4px; width: 2px; height: 34px; border-radius: 1px; background: var(--muted); box-shadow: 4px 0 var(--muted); transform: translateY(-50%); }
#mixer-resize:hover::after, #mixer-resize:focus-visible::after, #mixer-resize[data-dragging="true"]::after { background: var(--accent); box-shadow: 4px 0 var(--accent); }
#mixer-resize:focus-visible { outline-offset: -1px; }
#mixer-summary { font-size: .875rem; overflow-wrap: anywhere; }
#mixer { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; scrollbar-width: thin; scrollbar-gutter: stable; padding-inline-end: 4px; }
#mixer:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.lane { --stem-wave: var(--stem-default); display: grid; grid-template-rows: auto 31px auto; gap: 3px; padding: 8px 0; border-top: 1px solid var(--line); }
.lane:is([data-stem="bass"], [data-stem="piano"]) { --stem-wave: var(--stem-low); }
.lane[data-stem="guitar"] { --stem-wave: var(--stem-guitar); }
.lane:is([data-stem="backing-vocals"], [data-stem="backing"]) { --stem-wave: var(--stem-backing); }
.lane-label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.lane-label strong { font-size: .94rem; font-weight: 650; overflow-wrap: anywhere; color: var(--ink); }
.lane-label output { font-size: .82rem; font-variant-numeric: tabular-nums; color: var(--muted); }
.lane-wave {
  width: 100%; height: 31px; min-width: 0; position: relative; isolation: isolate; overflow: hidden; border-radius: 6px;
  background: var(--page);
}
.lane-wave::before, .lane-wave::after { content: ''; position: absolute; inset-block: 0; z-index: 1; pointer-events: none; }
.lane-wave::before { left: 0; width: var(--mixer-position, 0%); background: var(--selected-bg); border-radius: 6px 0 0 6px; }
.lane-wave::after { left: clamp(0px, var(--mixer-position, 0%), calc(100% - 1px)); width: 1.5px; background: var(--accent); }
.lane-wave canvas { display: block; position: absolute; inset: 0; width: 100%; height: 100%; color: var(--stem-wave); }
.lane-wave-status { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .72rem; }
.lane-wave input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; appearance: none; background: transparent; cursor: ew-resize; touch-action: pan-y; }
.lane-wave input::-webkit-slider-thumb { appearance: none; width: 2px; height: 28px; background: transparent; }
.lane-wave input:focus-visible { outline-offset: -3px; }
.lane-wave input::-moz-range-thumb { width: 2px; height: 28px; border: 0; background: transparent; }
.lane-controls { display: grid; grid-template-columns: minmax(38px, 1fr) auto auto; align-items: center; gap: 5px; }
.lane[data-muted="true"] strong { color: var(--muted); }
.lane[data-muted="true"] .lane-wave canvas { opacity: .36; }
.lane-controls input { width: 100%; min-width: 0; margin: 0; accent-color: var(--accent); touch-action: pan-y; }
.lane button { padding-inline: 7px; min-height: 30px; font-size: .79rem; border-radius: 12px; }
#vocal-split-open { margin-top: 8px; align-self: flex-start; }
#vocal-mode-field { color: var(--muted); font-size: .85rem; }
#vocal-mode { min-width: 0; color: var(--ink); }
.playback-tools { border-top: 1px solid var(--line); background: var(--surface); }
.playback-tools summary { padding: 10px 19px; font-size: .9rem; font-weight: 640; cursor: pointer; }
.playback-tools summary:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.timeline { display: grid; gap: 8px; padding: 0 19px 12px; }
.seek-rail { position: relative; height: 42px; border-radius: 8px; overflow: hidden; background: var(--page); }
.seek-rail canvas { color: var(--waveform); display: block; width: 100%; height: 100%; }
#playhead { pointer-events: none; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); }
#loop-area { pointer-events: none; position: absolute; top: 0; bottom: 0; border-inline: 1px solid var(--accent); background: var(--selected-bg); }
#seek { width: 100%; height: 100%; margin: 0; position: absolute; inset: 0; appearance: none; background: transparent; cursor: ew-resize; }
#seek::-webkit-slider-thumb { appearance: none; width: 2px; height: 42px; background: transparent; }
#seek::-moz-range-thumb { width: 2px; height: 42px; border: 0; background: transparent; }
#seek:focus-visible { outline-offset: -3px; }
.transport, .song-footer, .song-footer-actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.song-footer { border-top: 1px solid var(--line); padding: 10px 19px; }
.song-footer-actions { margin-left: auto; }
.quiet { color: var(--muted); font-size: .87rem; }
.warnings { color: var(--warning); margin: 10px 19px 0; font-size: .86rem; }
.warnings p + p { margin-top: 4px; }
.notice { position: fixed; bottom: max(12px, env(safe-area-inset-bottom)); right: 12px; max-width: min(460px, calc(100% - 24px)); z-index: 2; padding: 10px 14px; border-radius: 10px; background: var(--raised); color: var(--ink); }
dialog { color: var(--ink); width: min(660px, calc(100% - 22px)); max-height: calc(100% - 28px); padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
dialog::backdrop { background: var(--backdrop); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }
.dialog-head h2 { font-size: 1.3rem; }
.stack-label { display: grid; gap: 4px; margin-bottom: 10px; }
.check { display: flex; align-items: flex-start; gap: 6px; margin-block: 7px; }
.check input { accent-color: var(--accent); }
textarea { width: 100%; resize: vertical; font-family: ui-monospace, monospace; }
#prepare-status, #lyrics-status, #edit-status, #export-status { margin-block: 8px; }
#prepare-status:empty { margin: 0; }
.prepare-progress-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
#prepare-percent { color: var(--accent); font-size: .87rem; font-weight: 650; font-variant-numeric: tabular-nums; }
progress { accent-color: var(--accent); }
#prepare-progress, #lyrics-progress, #vocal-progress, #section-progress { display: block; width: 100%; height: .8rem; margin-bottom: 12px; }
#lyrics-review, #vocal-review, #section-review { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
#vocal-tracks, #section-preview { padding-inline-start: 20px; margin-block: 0 10px; }
#vocal-status, #vocal-setup, #section-status { margin-block: 8px; }
#chart { min-height: 55px; max-height: 48vh; overflow: auto; white-space: pre; padding: 12px; background: var(--page); border-radius: 8px; font: .88rem/1.55 ui-monospace, monospace; }
@media (max-width: 980px), (max-width: 1100px) and (orientation: portrait) {
  .layout { grid-template-columns: 1fr; gap: 12px; padding: 12px 12px 30px; }
  .library { padding: 0; }
  .library-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
  .songs { display: flex; overflow: auto; padding-bottom: 2px; }
  .songs li { flex: 0 0 auto; max-width: 75%; }
  .songs li > button:first-child { display: flex; gap: 7px; align-items: baseline; flex-wrap: wrap; }
  .songs li[data-drop]::after { inset-block: 0; inset-inline: auto; width: 2px; height: auto; }
  .songs li[data-drop="before"]::after { inset-inline-start: 0; }
  .songs li[data-drop="after"]::after { inset-inline-end: 0; }
}
@media (max-width: 1100px) and (orientation: portrait) {
  .library-heading { margin-bottom: 0; }
  .library .songs { margin-top: 8px; }
}
@media (min-width: 691px) {
  /* Match the sheet's grid row without letting the stem list size that row. */
  .mixer-panel { contain: size; min-height: 240px; }
}
@media (min-width: 691px) and (max-width: 1100px) and (orientation: portrait) {
  .sheet-layout { --mixer-width: 251px; grid-template-columns: minmax(0, 1fr) minmax(251px, var(--mixer-width)); }
}
@media (min-width: 691px) and (max-width: 1100px) and (min-height: 740px) and (orientation: portrait) {
  body { display: flex; flex-direction: column; height: 100dvh; }
  .topbar { flex: none; }
  .layout {
    flex: 1; min-height: 0; width: 100%; grid-template-rows: auto minmax(0, 1fr);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .studio { display: flex; flex-direction: column; height: 100%; }
  .studio > :not(.sheet-layout), .sheet-panel > :not(.song-sheet) { flex-shrink: 0; }
  .sheet-layout { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); }
  .sheet-panel { display: flex; flex-direction: column; min-height: 0; }
  .song-sheet { flex: 1; min-height: 0; max-height: none; }
  .mixer-panel { min-height: 0; }
}
@media (max-width: 690px) {
  .sheet-layout { grid-template-columns: minmax(0, 1fr); }
  .sheet-layout:has(> .mixer-panel:not([hidden])) { padding-inline-end: 0; }
  .sheet-layout > .mixer-panel { margin: 0 12px 12px; }
  .sheet-layout[data-mixer-hidden="true"] { grid-template-columns: minmax(0, 1fr); }
  .mixer-panel { max-height: clamp(225px, 42svh, 360px); }
  #mixer-resize { display: none; }
  .sheet-panel, .mixer-panel, .song-header, .song-footer, .timeline, .playback-tools summary { padding-inline: 11px; }
  .song-progress { margin-inline: 11px; }
}
@media (max-width: 520px) {
  .topbar { padding-inline: 11px; flex-wrap: wrap; }
  .song-header { padding-block: 13px; }
  .chord-cue { padding-inline: 8px; gap: 3px 7px; }
  .song-footer-actions { margin-left: 0; }
}
@media (pointer: coarse) {
  button, .button, select, .lane button, .playback-tools summary { min-height: 44px; }
  .sheet-row .sheet-chord, .sheet-row .sheet-lyric, .sheet-section button { min-height: 42px; }
  .progress-section { min-height: 30px; }
  .song-progress[data-sections="true"] { height: 74px; }
  .lane-wave { height: 44px; }
}

:root:not([data-theme="light"]) .cue-now { border: 1px solid var(--accent); }
:root:not([data-theme="light"]) #song-timeline {
  background: var(--surface); border-radius: 12px;
}
.topbar { position: relative; z-index: 3; }
.top-menu > summary {
  display: inline-flex; align-items: center; justify-content: center; list-style: none;
  min-height: 44px; min-width: 44px; cursor: pointer;
}
.top-menu > summary::-webkit-details-marker { display: none; }
.top-menu > summary:focus-visible, .prepare-quality summary:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
#settings-menu > summary { font-size: 1.2rem; }
.top-menu-panel {
  position: absolute; inset-block-start: calc(100% + 4px); inset-inline-end: max(12px, calc((100vw - 1360px) / 2));
  display: grid; gap: 6px; width: min(248px, calc(100% - 24px)); padding: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.top-menu-panel > :is(button, label) { min-height: 44px; text-align: left; }
.appearance, .prepare-options, #stem-quality { margin: 0; padding: 0; border: 0; min-width: 0; }
.appearance legend { margin-bottom: 8px; color: var(--muted); }
.theme-options {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px;
  padding: 4px; background: var(--page); border: 1px solid var(--line); border-radius: 9px;
}
.theme-options label { position: relative; cursor: pointer; }
.theme-options input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.theme-options label > span {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; border-radius: 6px;
}
.theme-options input:checked + span { box-shadow: inset 0 0 0 1px var(--accent); background: var(--brand); color: var(--on-primary); font-weight: 650; }
.theme-options input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

#prepare-dialog { max-width: 480px; }
#prepare-form { display: grid; gap: 14px; }
#prepare-form .dialog-head { margin: 0; }
#prepare-form .dialog-head button { min-width: 44px; min-height: 44px; font-size: 1.15rem; }
.prepare-file { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 12px; }
.prepare-file strong { overflow-wrap: anywhere; }
.prepare-file small, .prepare-option small { display: block; }
.prepare-options legend { font-weight: 650; margin-bottom: 5px; }
.prepare-option, .prepare-quality summary {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  min-height: 44px; padding: 7px 2px; border-top: 1px solid var(--line);
}
.prepare-option input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; }
.prepare-quality { padding-inline-start: 12px; }
.prepare-quality summary { list-style: none; cursor: pointer; color: var(--muted); }
.prepare-quality summary::-webkit-details-marker { display: none; }
#prepare-quality-label::after { content: ' ▾'; }
.prepare-quality[open] #prepare-quality-label::after { content: ' ▴'; }
.prepare-footer { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.prepare-footer .check { margin: 0; color: var(--muted); }
.prepare-progress-heading:has(#prepare-status:empty) { display: none; }
#prepare-submit { justify-self: end; min-height: 44px; }

#realign-status { margin-block: 10px; }
#realign-status[data-saved="true"] { padding: 10px 12px; border: 1px solid var(--success); border-radius: 8px; background: var(--raised); color: var(--success); }
#realign-status[data-saved="true"] strong { display: block; margin-bottom: 4px; font-size: 1rem; }
#realign-status[data-saved="true"] span { color: var(--ink); }
#realign-setup > button { margin-top: 10px; }
#realign-pins { max-height: 32dvh; overflow: auto; }
#realign-pins .check { overflow-wrap: anywhere; }
#realign-progress, #realign-audio { width: 100%; margin-bottom: 10px; }
#realign-changes { list-style: none; margin: 8px 0 12px; padding: 0; max-height: 38dvh; overflow-y: auto; }
#realign-changes li { display: grid; gap: 5px; padding: 8px 4px; border-top: 1px solid var(--line); }
#realign-changes .realign-group-title { color: var(--accent); font-weight: 650; padding-top: 12px; }
#realign-changes label { display: flex; align-items: baseline; gap: 7px; overflow-wrap: anywhere; }
#realign-changes input { accent-color: var(--accent); flex: none; }
#realign-changes button { font-size: .85rem; }

.sheet-reading { display: contents; }
.song-sheet[data-editing="true"] .sheet-reading, .sheet-placement-grid[hidden] { display: none; }
.sheet-placement-grid {
  display: flex; flex-wrap: wrap; flex-basis: 100%; gap: 4px; min-width: 0;
}
.sheet-placement-cell {
  display: flex; flex-direction: column; justify-content: flex-end; min-width: 42px; max-width: 100%;
  border: 1px solid var(--line); border-radius: 5px;
}
.sheet-placement-cell:hover, .sheet-placement-cell:focus-within {
  border-color: var(--accent);
}
.sheet-placement-cell[data-selected="true"] {
  border-color: var(--accent); background: var(--selected-bg);
}
.sheet-placement-symbols {
  display: flex; gap: 2px; flex-wrap: wrap; align-items: center; min-height: 28px; padding: 1px 4px 0;
}
.sheet-placement-word, .sheet-placement-word[aria-pressed="true"] {
  min-height: 34px; padding: 1px 8px 5px; color: var(--ink); background: transparent;
  border-color: transparent; text-align: left; overflow-wrap: anywhere;
  font-size: clamp(17px, 2.1vw, 21px); line-height: 1.27; font-weight: inherit;
}
.sheet-placement-chord { color: var(--accent-text); font-weight: 740; padding-inline: 5px; }
.sheet-placement-chord:empty { display: none; }

.song-sheet[data-editing="true"] .sheet-chord { cursor: grab; touch-action: none; user-select: none; }
.song-sheet[data-editing="true"] .sheet-chord[data-dragging="true"] { cursor: grabbing; }
.song-sheet [data-drop-hover="true"] { outline: 2px solid var(--accent); outline-offset: 1px; }
.sheet-chord { cursor: grab; user-select: none; }
.sheet-chord[data-dragging="true"] { cursor: grabbing; opacity: .55; }
.sheet-drag-preview {
  position: fixed; z-index: 100; pointer-events: none; transform: translate(9px, calc(-100% - 6px));
  padding: 3px 8px; border: 1px solid var(--accent); border-radius: 5px;
  background: var(--raised); color: var(--accent-text); font-weight: 740;
}
