/* Whole-tune practice shares the existing instruments and palette. */
[hidden] { display:none !important; }
/* Content is the primary choice; session controls belong to its selected tab. */
.practice-content .mode-bar { display:flex; align-items:stretch; flex-wrap:wrap; gap:0 12px; }
.practice-content .mode-bar { margin-bottom:0; }

.practice-content .sheet { border-top-left-radius:0; border-top-right-radius:18px; }
.practice-content:has(#timed-actions:not([hidden]), #tune-actions:not([hidden])) .sheet { border-top-left-radius:0; border-top-right-radius:0; }
.scope-switch { display:flex; align-items:stretch; gap:4px; }
.scope-switch button { position:relative; min-width:150px; padding:12px 22px; border:0; border-radius:18px 18px 0 0; background:transparent; color:var(--secondary); font:inherit; font-size:17px; font-weight:550; }
.scope-switch button.selected { background:var(--paper); color:var(--ink); font-weight:650; }
.scope-switch button.selected::after { content:""; position:absolute; bottom:0; left:22px; right:22px; height:3px; border-radius:3px; background:var(--sea); }
.scope-switch button:not(.selected)::before { content:""; position:absolute; inset:0; border:1px solid var(--border, var(--line)); border-bottom:0; border-radius:inherit; pointer-events:none; }
.scope-switch button:not(.selected):hover { background:var(--hover); }
.session-row { display:contents; }
.session-controls { display:flex; align-items:center; gap:6px; margin-left:auto; padding:0; }
.timed-toggle { margin:0; min-height:38px; padding:0 6px; gap:8px; font-size:13px; color:var(--secondary); }
.timed-toggle:has(input:disabled) { opacity:.5; cursor:default; }
.session-row #reset { width:36px; height:36px; flex:none; margin:0; padding:0; font-size:22px; display:grid; place-items:center; border:0; border-radius:50%; background:transparent; color:var(--muted); }
.session-row #reset:hover { background:var(--hover); }
.session-row #reset > span { display:none; }
.session-row .timed-actions { flex-basis:100%; width:100%; margin:0; padding:8px 14px 2px; gap:8px; justify-content:flex-end; background:var(--paper); border-radius:0 18px 0 0; }
.session-row .timed-actions .note-action { padding:7px 12px; }
.session-row .run-clock { font-size:24px; }
@media(max-width:680px){
 .practice-content .mode-bar { gap:0 6px; }
 .scope-switch { flex:1; }
 .scope-switch button { flex:1; min-width:0; padding:11px 8px; font-size:13px; white-space:nowrap; }
 .scope-switch button.selected::after { left:12px; right:12px; }
 .session-controls { gap:2px; }
 .timed-toggle { padding:0 2px; gap:5px; font-size:12px; }
 .mode-bar .session-row #reset { width:30px; height:34px; border:0; font-size:20px; }
 .session-row .timed-actions { padding:6px 12px 2px; flex-wrap:wrap; }
 .session-row .timed-actions .note-action { padding:7px 9px; }
 .session-row .run-clock { font-size:22px; }
}
#tune-settings { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
#tune-settings select { margin:0; width:auto; max-width:250px; padding:8px 10px; background:var(--well); border-color:var(--line); color:var(--ink); border-radius:12px; }
.tune-mode #staff,.tune-mode #practice-settings .compact-clef,.tune-mode #key-signature,.tune-mode #range,.tune-mode #toggle-key-name { display:none; }
.tune-mode .key-name-reveal #current-key { filter:none; }
.tune-mode .sheet-top { gap:12px; }
.tune-mode .sheet-top #practice-settings { display:none; }
.tune-mode #tune-settings { order:0; }
#tune-panel { padding:8px 22px 6px; }
.tune-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:6px 0; }
.tune-heading h2 { font-size:20px; font-weight:650; margin:0 0 4px; letter-spacing:-.4px; }
#tune-detail,#tune-best,.tune-footer { color:var(--muted); font-size:12px; }
#tune-best { text-align:right; }
.tune-score-frame { position:relative; }
#tune-score { position:relative; width:100%; overflow:clip; color:var(--ink); }
.tune-score-exit { position:absolute; inset:0 0 auto; display:flex; flex-direction:column; gap:12px; pointer-events:none; }
#tune-score svg { display:block; max-width:100%; }
#tune-notation { width:100%; display:flex; flex-direction:column; gap:12px; }
.tune-score-line { flex:none; }
#tune-line-status { font-size:11px; color:var(--muted); white-space:nowrap; }
.tune-reading-status { display:flex; align-items:center; gap:12px; flex-shrink:0; }
#tune-score .abcjs-staff { color:var(--staff-line, var(--muted)); }
#tune-score .abcjs-note { fill:var(--ink); }
#tune-score .tune-done { fill:var(--teal); opacity:.48; }
#tune-score .tune-missed { fill:var(--muted); opacity:.35; }
#tune-score .tune-current { fill:var(--teal); }
.tune-cursor { display:none; pointer-events:none; }
.tune-current .tune-cursor { display:block; fill:var(--teal); fill-opacity:.16; stroke:var(--teal); stroke-opacity:.5; stroke-width:1; }
.tune-footer { display:flex; justify-content:space-between; gap:12px; padding:8px 0; }
#tune-progress { white-space:nowrap; font-variant-numeric:tabular-nums; }
#tune-progress-bar { display:block; width:100%; height:4px; border:0; border-radius:5px; overflow:hidden; appearance:none; background:var(--well); color:var(--teal); }
#tune-progress-bar::-webkit-progress-bar { background:var(--well); }
#tune-progress-bar::-webkit-progress-value { background:var(--teal); }
#tune-progress-bar::-moz-progress-bar { background:var(--teal); }
/* Ready/countdown replaces the score until the timed tune starts. */
.tune-ready { min-height:220px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; padding:20px; text-align:center; }
.tune-ready > span { font-size:14px; color:var(--muted); }
.tune-ready > strong { font-size:clamp(27px,4vw,42px); font-weight:650; letter-spacing:-1px; }
.tune-ready .primary-button { margin:0; }
#tune-setup .tune-picker { grid-column:1/-1; }
.single-timed .compact-clef,.single-timed #key-signature,.single-timed #range { display:none; }
@media(max-width:680px){
 .tune-ready { grid-row:3; min-height:190px; padding:12px; }
 .single-timed .sheet-top { display:flex; align-items:center; justify-content:space-between; }
 .single-timed .compact-sound { margin-left:auto; }
}
#tune-history-list { list-style:none; padding:0; max-height:230px; overflow-y:auto; }
#tune-history-list li { display:flex; justify-content:space-between; gap:16px; padding:12px 0; border-bottom:1px solid var(--line); font-size:13px; }
#tune-history-list strong { font-weight:550; text-align:right; }
#tune-results { max-width:580px; }
@media(max-width:680px){
 .tune-mode .sheet-top { display:flex; flex-wrap:wrap; padding:10px 12px 4px; }
 .tune-mode #practice-settings { display:flex; width:auto; }
 .tune-mode #tune-settings { flex-wrap:nowrap; display:grid; grid-template-columns:minmax(0,1fr) 80px 75px; width:100%; gap:5px; }
 #tune-settings select { max-width:none; min-width:0; width:100%; font-size:11px; padding:8px 3px; }
 #tune-panel { grid-row:3; padding:4px 12px 10px; min-width:0; }
 .tune-heading { align-items:flex-start; }
 .tune-heading h2 { font-size:16px; }
 #tune-detail,#tune-best { font-size:10px; }
 .tune-footer { font-size:11px; }
 .tune-mode .sheet-bottom .practice-toggles { grid-row:2; }
 .tune-mode .sheet { display:grid; }
 #tune-history-list li { font-size:12px; }
}

.tune-mode #exercise-summary,.tune-mode .sheet-top > .sr-only { display:none; }


#tune-message { flex:1; min-width:0; }
#tune-message .feedback { min-height:0; padding:0; justify-content:flex-start; text-align:left; font-size:12px; line-height:18px; }
#tune-message .feedback:empty { display:none; }
#tune-message:has(.feedback:not(:empty)) #tune-instruction { display:none; }
.tune-footer { min-height:34px; align-items:center; }
#tune-score [data-tune-note] { cursor:pointer; }
#tune-score [data-tune-note]:focus-visible { outline:2px solid var(--teal); outline-offset:3px; }
@media(max-width:680px){
 #tune-message .feedback { font-size:11px; line-height:16px; }
}

/* Short desktop windows reserve room for the instrument, not empty panel space. */
@media(min-width:681px) and (max-height:850px){
 .tune-mode .topbar { height:64px; }
 .tune-mode main { padding-top:4px; padding-bottom:12px; }
 .tune-mode .scoreboard { padding-bottom:12px; }
 .tune-mode .metric-label { min-height:14px; margin-bottom:3px; }
 .tune-mode .scoreboard strong { font-size:26px; }
 .tune-mode .sheet-top { padding-top:8px; }
 .tune-mode .tune-heading :is(#tune-detail,#tune-best) { display:none; }
 .tune-mode #tune-panel { padding-top:4px; }
 .tune-mode .keyboard-panel { margin-top:10px; padding-top:12px; padding-bottom:12px; }
 .tune-mode .keyboard-toolbar { margin-bottom:8px; }
 .tune-mode .note-choices { padding-block:4px 7px; }
 .tune-mode .note-choice { max-width:44px; font-size:20px; }
}
@media(max-width:680px){
 .tune-reading-status { gap:7px; }
 #tune-line-status { font-size:10px; }
 #tune-instruction { display:none; }
}

.tune-mode.tune-tight .tune-heading :is(#tune-detail,#tune-best) { display:none; }
@media(max-width:680px){ .tune-mode .tune-footer { min-height:48px; } }

/* Tune notation already shows the signature; keep audio beside the note actions. */
.tune-mode .key-signature-header { display:none; }
.tune-mode .sheet-top:has(#tune-settings[hidden]) { display:none; }
/* One compact audio control in the same place for every practice mode. */
.note-actions .sound-button { position:relative; flex:none; width:40px; height:38px; display:grid; place-items:center; margin:0; border:1px solid var(--border, var(--line)); border-radius:13px; color:var(--muted); background:color-mix(in srgb,var(--well) 55%,var(--paper)); box-shadow:0 1px 2px color-mix(in srgb,var(--ink) 7%,transparent); cursor:pointer; transition:background .15s,border-color .15s,box-shadow .15s; }
.sound-button input { position:absolute; inset:0; width:100%; height:100%; margin:0; opacity:0; cursor:pointer; }
.sound-symbol { display:block; pointer-events:none; }
.sound-button:has(input:checked) .sound-muted,.sound-button:has(input:not(:checked)) .sound-waves { display:none; }
.note-actions .sound-button:has(input:checked) { color:var(--sea); background:color-mix(in srgb,var(--sea) 11%,var(--paper)); border-color:color-mix(in srgb,var(--sea) 32%,var(--paper)); }
.note-actions .sound-button:hover { border-color:var(--sea); box-shadow:0 2px 4px color-mix(in srgb,var(--ink) 10%,transparent); }
.note-actions .sound-button:active { box-shadow:none; }
.sound-button:has(input:focus-visible) { outline:3px solid var(--sea); outline-offset:3px; }
@media(max-width:680px){ .key-signature-header { grid-column:1/-1; } }

/* A timed single-note key is meaningful only while answering the sprint. */
.single-timed.timed-waiting .sheet-top { display:none; }

#tune-source { color:var(--muted); font-size:11px; text-underline-offset:3px; }
#tune-source:hover { color:var(--sea); }

/* Lyrics share the note controls; reflowed systems include the words in their bounds. */
.note-actions .lyrics-button[aria-pressed="true"] { color:var(--sea); background:color-mix(in srgb,var(--sea) 11%,var(--paper)); border-color:color-mix(in srgb,var(--sea) 32%,var(--paper)); }


/* A flat library makes every tune visible without opening a category first. */
.tune-mode #tune-settings { display:grid; grid-template-columns:minmax(0,1fr) 110px 90px; width:100%; }
.tune-browse-trigger { display:flex; align-items:center; justify-content:space-between; gap:12px; min-width:0; padding:9px 12px; border:1px solid var(--line); border-radius:12px; background:var(--well); text-align:left; font-size:13px; }
#selected-tune-title { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:600; }
.browse-caption { flex:none; color:var(--sea); font-size:11px; }
.tune-browse-trigger:hover { border-color:var(--sea); }
#tune-library,#tune-setup { width:min(820px,calc(100% - 24px)); max-width:820px; max-height:calc(100dvh - 24px); padding:24px; overflow:hidden; }
#tune-library[open],#tune-setup[open] { display:flex; flex-direction:column; }
#tune-library h2,#tune-setup h2 { margin:0 32px 18px 0; flex:none; font-size:24px; }
.tune-browser { display:flex; flex-direction:column; min-height:0; }
.tune-search { position:relative; flex:none; }
.tune-search input { width:100%; margin:0; padding:12px 42px 12px 14px; font:inherit; font-size:16px; color:var(--ink); border:1px solid var(--line); border-radius:14px; background:var(--well); }
.tune-search input::-webkit-search-cancel-button { display:none; }
.tune-search > button { position:absolute; inset:3px 4px 3px auto; width:36px; border:0; background:transparent; font-size:23px; color:var(--muted); }
.tune-filters { display:flex; flex-wrap:wrap; gap:6px; margin:12px 0 8px; flex:none; }
.tune-filters button { padding:6px 9px; border:1px solid var(--line); border-radius:20px; background:transparent; color:var(--secondary); font-size:11px; }
.tune-filters button[aria-pressed="true"] { color:var(--paper); background:var(--sea); border-color:var(--sea); }
.tune-browser-count { color:var(--muted); font-size:11px; margin:2px 0 8px; flex:none; }
.tune-browser-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-content:start; gap:8px; overflow-y:auto; overscroll-behavior:contain; padding:3px 5px 5px 3px; min-height:100px; max-height:440px; scrollbar-gutter:stable; }
.tune-browser-song { position:relative; display:flex; flex-direction:column; align-items:flex-start; gap:5px; min-width:0; padding:13px 32px 13px 14px; border:1px solid var(--line); border-radius:14px; color:var(--ink); background:var(--well); text-align:left; }
.tune-browser-song:hover { border-color:var(--sea); }
.tune-browser-song[aria-pressed="true"] { border-color:var(--sea); background:color-mix(in srgb,var(--sea) 11%,var(--paper)); }
.tune-browser-song strong { font-size:14px; font-weight:600; line-height:1.3; }
.tune-browser-tags { color:var(--secondary); font-size:10px; line-height:1.5; }
.tune-browser-meta { color:var(--muted); font-size:10px; }
.tune-browser-check { position:absolute; right:12px; top:13px; color:var(--sea); visibility:hidden; }
.tune-browser-song[aria-pressed="true"] .tune-browser-check { visibility:visible; }
.tune-browser-empty { text-align:center; padding:24px 12px; }
#tune-setup-form { display:flex; flex-direction:column; min-height:0; }
#setup-tune-browser { flex:1; min-height:130px; }
.tune-setup-bottom { flex:none; border-top:1px solid var(--line); margin-top:10px; padding-top:8px; }
#setup-selected-tune { margin:0 0 10px; font-size:13px; color:var(--ink); font-weight:600; }
#tune-setup .setup-grid { gap:10px; }
#tune-setup .setup-grid select { margin:5px 0 0; padding:8px; }
#tune-setup .setup-description { font-size:11px; margin:10px 0; }
#tune-setup .dialog-actions { margin:0; }
#tune-setup .dialog-actions button { padding:10px 20px; }
@media(max-width:680px){
 .tune-mode #tune-settings { grid-template-columns:minmax(0,1fr) 85px 73px; gap:5px; }
 .tune-browse-trigger { flex-direction:column; align-items:flex-start; gap:2px; padding:7px 9px; }
 #selected-tune-title { max-width:100%; font-size:11px; }
 .browse-caption { font-size:10px; }
 #tune-settings select { width:100%; max-width:none; }
 #tune-library,#tune-setup { padding:18px 14px; border-radius:20px; }
 #tune-library h2,#tune-setup h2 { font-size:21px; margin-bottom:12px; }
 .tune-browser-list { grid-template-columns:1fr; max-height:50dvh; }
 .tune-filters { gap:5px; margin-top:9px; }
 .tune-filters button { font-size:10px; padding:5px 8px; }
 #tune-setup .setup-description { display:none; }
 #tune-setup .dialog-actions { margin-top:10px; }
}

@media(max-height:600px){
 #tune-library,#tune-setup { overflow-y:auto; }
 #tune-setup-form,#setup-tune-browser,#free-tune-browser { flex:none; }
 .tune-browser-list { max-height:220px; }
}

/* Preview stays beside the title, including compact score layouts. */
.tune-heading > div { min-width:0; }
.tune-title-row { display:flex; align-items:center; gap:10px; }
.tune-title-row h2 { margin:0; }
.tune-preview { flex:none; display:inline-flex; align-items:center; justify-content:center; gap:6px; min-width:80px; height:34px; padding:0 10px; font-size:12px; font-weight:600; border:1px solid var(--border,var(--line)); border-radius:12px; background:var(--well); color:var(--sea); box-shadow:0 2px 0 color-mix(in srgb,var(--ink) 9%,transparent); cursor:pointer; }
.tune-preview:hover { background:color-mix(in srgb,var(--sea) 12%,var(--paper)); }
.tune-preview:focus-visible { outline:2px solid var(--sea); outline-offset:3px; }
.tune-preview[aria-pressed="true"] { color:var(--paper); background:var(--sea); box-shadow:none; }
.tune-preview .preview-stop,.tune-preview[aria-pressed="true"] .preview-play { display:none; }
.tune-preview[aria-pressed="true"] .preview-stop { display:block; }
@media(max-width:680px){ .tune-title-row { gap:8px; } .tune-preview { height:36px; } }

/* Audition is a listening state; retain the keyboard's space and settings. */
.tune-previewing :is(.piano-scroll,#note-choices) { opacity:.4; }
.tune-previewing :is(#piano,#note-choices) button { cursor:pointer; }
.tune-previewing :is(#reveal,#skip) { opacity:.5; }
.tune-previewing #tune-score [data-tune-note] { cursor:default; }
