:root {
  font-family: "Inter", system-ui, sans-serif;
  color: #19382e;
  background: #eef3f0;
  line-height: 1.5;
  accent-color: #24614e;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.masthead { background: #15392e; color: #fff; }
.masthead > div, .page-switch, main { width: 100%; max-width: 78rem; margin: auto; padding: 1rem 1.25rem; }
.masthead > div { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.masthead strong { font-size: 1.35rem; letter-spacing: .02em; }
.brand-name { font-size: 1.5rem; }
.brand-edition { font-size: 1.2rem; font-weight: 400; }
.language { display: flex; align-items: center; gap: .4rem; }
.language select { margin: 0; width: auto; padding: .2rem .4rem; color: white; background: #15392e; }
.language option { color: #19382e; background: white; }
.sound-download { width: 100%; max-width: 78rem; margin: auto; padding: .5rem 1.25rem; display: flex; align-items: center; gap: .65rem; font-size: .8rem; color: #52695e; flex-wrap: wrap; }
.sound-download progress { flex: 1; min-width: 5rem; height: .6rem; }
.sound-download output { font-variant-numeric: tabular-nums; }
main { display: grid; grid-template-columns: minmax(15rem, 19rem) minmax(0, 1fr); gap: 1rem; align-items: start; }
.page-switch {
  position: sticky; top: 0; z-index: 2; display: flex; gap: clamp(.75rem, 3vw, 2rem);
  padding-block: .35rem 0; background: #eef3f0; border-bottom: 1px solid #cbdad1;
}
.page-switch a {
  min-width: 5rem; padding: .55rem .5rem .45rem; border-bottom: 3px solid transparent;
  text-align: center; text-decoration: none; color: #52695e; font-weight: 650;
}
.page-switch a:hover { color: #24614e; background: #e6eee8; }
.page-switch a[aria-current="page"] { color: #19382e; border-color: #24614e; }
.page-switch a:focus-visible { outline: 2px solid #2f795e; outline-offset: 2px; }
#set-count { margin-left: .3rem; font-size: .7em; font-variant-numeric: tabular-nums; }
.library, .practice {
  min-width: 0; padding: 1.25rem; border: 1px solid #cbdad1;
  border-radius: 1rem; background: #fff;
}
h1, h2, p { margin: 0; }
h1 { font-size: 1.35rem; margin-bottom: .75rem; }
h2 { font-size: clamp(1.25rem, 3vw, 1.8rem); line-height: 1.2; }
label, legend { font-size: .9rem; }
input, select, button { font: inherit; color: inherit; }
input[type="search"], select {
  display: block; width: 100%; margin-top: .3rem; padding: .5rem .65rem;
  border: 1px solid #a6baad; border-radius: .5rem; background: white;
}
button {
  cursor: pointer; padding: .5rem .75rem; border: 1px solid #a6baad;
  border-radius: .5rem; background: #f6faf7;
}
button:hover, button[aria-current="true"] { background: #dcece2; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid #2f795e; outline-offset: 2px;
}
.rank-filters { display: flex; gap: .6rem; margin-top: .65rem; }
.rank-filters label { min-width: 0; flex: 1; }
#library-status:not(:empty) { margin-top: .55rem; }
.dance-caption { margin-top: .35rem; }
.muted, .tunes small { color: #52695e; font-size: .9rem; }
.tunes { max-height: 58vh; overflow: auto; margin: .6rem 0; padding: 0; list-style: none; }
.tunes li + li { border-top: 1px solid #dce5df; }
.tunes button { width: 100%; padding: .55rem .5rem; text-align: left; border: 0; background: white; border-radius: 0; }
.tunes button:hover, .tunes button[aria-current="true"] { background: #e1efe6; }
.tunes small { display: block; }
.score-heading { display: grid; gap: .6rem; overflow-wrap: anywhere; }
.score-heading p { margin-top: .35rem; }
.score-actions { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.score-actions select { width: auto; max-width: min(55%, 13rem); min-width: 0; margin-top: 0; }
.score-actions button { white-space: nowrap; }
#set-feedback:not(:empty), .play-status:not(:empty) { margin-top: .5rem; }
.play-status:empty { display: none; }
#set-tunes { padding-left: 1.2rem; margin: .65rem 0; }
#set-tunes li { padding: .45rem .15rem .45rem .4rem; }
#set-tunes li + li { border-top: 1px solid #dce5df; }
#set-tunes li[aria-current="true"] { background: #e1efe6; border-radius: .35rem; }
.set-entry { display: grid; gap: .35rem; }
.set-entry small { display: block; }
.set-entry-meta { color: #52695e; font-size: .8rem; overflow-wrap: anywhere; }
.set-entry-controls { display: flex; align-items: center; gap: .25rem; }
.set-entry-controls select { width: auto; margin: 0 auto 0 0; padding: .3rem .25rem; }
.set-entry-controls button { padding: .32rem .48rem; }
.settings { grid-column: 1 / -1; width: min(100%, 40rem); margin-inline: auto; }
.score-type-setting { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.3rem; }
.score-type-setting select { width: auto; max-width: 65%; margin: 0; }
.legal-note { margin-top: .9rem; padding-top: .7rem; border-top: 1px solid #dce5df; color: #637168; font-size: .8rem; }
.legal-note a { color: inherit; text-underline-offset: .15rem; }
#instrument-settings { list-style: none; padding: 0; margin: 0; }
#instrument-settings li { display: grid; grid-template-columns: 8rem minmax(0, 1fr) 3.25rem; gap: .55rem; align-items: center; padding: .7rem 0; }
#instrument-settings li + li { border-top: 1px solid #dce5df; }
#instrument-settings label { display: flex; align-items: center; gap: .25rem; }
#instrument-settings output { text-align: right; font-size: .85rem; }
#instrument-settings input[type="range"] { width: 100%; min-width: 0; margin: 0; }
#practice-playing { margin-right: .32rem; font-size: .72em; }
body[data-active-page="practice"] {
  height: 100dvh; display: flex; flex-direction: column;
  overflow: hidden;
}
body[data-active-page="practice"] main { flex: 1; width: 100%; margin-block: 0; min-height: 0; grid-template-columns: minmax(15rem, 19rem) 1.75rem minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: .35rem; }
body[data-active-page="practice"] > :not(main) { flex-shrink: 0; }
body[data-active-page="practice"].set-collapsed main { grid-template-columns: 1.75rem minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
body[data-active-page="practice"].set-collapsed #practice-set { display: none; }
.practice-heading { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.practice-hint { margin-left: auto; max-width: 100%; color: #637168; font-size: .75rem; text-align: right; }
#toggle-set { display: grid; place-items: center; align-self: start; margin-top: 1.25rem; width: 1.75rem; height: clamp(1.5rem, 3.6vw, 2.16rem); padding: 0; border: 0; background: transparent; }
#toggle-set-arrow { font-size: 1.75rem; line-height: 1; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[data-page="practice"] { display: flex; flex-direction: column; min-height: 0; max-height: 100%; }
.practice-tempo {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .3rem;
  padding-bottom: .65rem; margin-bottom: .7rem; border-bottom: 1px solid #dae6df;
}
.practice-tempo output { font-weight: 650; font-variant-numeric: tabular-nums; }
.practice-tempo input { width: 100%; margin: 0; grid-column: 1 / -1; }
#set-tunes { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
#preview-score, #practice-score {
  min-height: 0; max-height: var(--staff-viewport, 38rem); overflow-y: auto;
  overscroll-behavior: contain; scrollbar-gutter: stable;
}
#practice-score article + article { border-top: 1px solid #dae6df; margin-top: .8rem; padding-top: .75rem; }
#practice-score h3 { margin: 0; font-size: 1rem; white-space: pre-wrap; }
#practice-score h3[aria-current="true"] { color: #24614e; }
.score-details { display: flex; flex-wrap: wrap; gap: 0 .3rem; color: #536156; font-size: .85rem; }
.score-details .meter-repaired { color: #a47300; }
#preview-score { max-height: min(65dvh, var(--staff-viewport, 38rem)); }
.score { margin-top: .8rem; color: #182922; }
.score:empty { margin-top: 0; }
.transport { display: flex; gap: .8rem; align-items: center; margin-top: .7rem; }
.primary { background: #24614e; color: white; border-color: #24614e; min-width: 6rem; }
.primary:hover { background: #194c3c; }
@media (max-width: 700px) {
  main { grid-template-columns: minmax(0,1fr); gap: .75rem; padding: .75rem; }
  .library, .practice { padding: .9rem; }
  #toggle-set { margin-top: .9rem; }
  body[data-active-page="practice"] main { grid-template-columns: 1.75rem minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  #practice-set { grid-column: 1 / -1; }
  .library[data-page="practice"] { max-height: clamp(8.75rem, 27dvh, 14.25rem); }
  .page-switch { gap: .3rem; }
  .page-switch a { min-width: 0; flex: 1; }
  .tunes { max-height: 24vh; }
}

.score-progress { flex: 1; min-width: 0; display: flex; align-items: center; gap: .5rem; }
.score-progress input { flex: 1; min-width: 0; margin: 0; }
.progress-track { flex: 1; min-width: 0; position: relative; display: flex; }
.tune-boundaries { position: absolute; inset: 0 .45rem; pointer-events: none; }
.tune-boundaries i { position: absolute; top: 50%; height: .8rem; width: 2px; translate: -50% -50%; background: #f7fbf8; border-inline: 1px solid #47775f; }
.loop-progress { position: absolute; inset: 0 .45rem; pointer-events: none; color: #326b9b; }
.loop-progress b { position: absolute; top: 70%; translate: -50%; font: 650 .68rem system-ui; }
.loop-progress b::before { content: ""; position: absolute; inset: -.3rem 50% auto; height: .3rem; border-left: 1px solid; }
.has-loop .transport { margin-bottom: .55rem; }
.measure-hit { fill: transparent; stroke: none; cursor: pointer; touch-action: pan-y; }
.measure-hit.loop-range { fill: #4c97c842; }
.part-badge { fill: #f0f7f3; stroke: #39745e; stroke-width: 1.5; }
.part-badge-text { fill: #245341; font: 800 16px system-ui; text-anchor: middle; }
.original-part { visibility: hidden; }
#loop-menu, #remove-tune-menu { width: min(25rem, calc(100% - 2rem)); border: 1px solid #a6baad; border-radius: .8rem; color: inherit; }
#loop-menu::backdrop, #remove-tune-menu::backdrop { background: #19382e66; }
#remove-tune-message { overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .65rem; margin-top: 1.25rem; }
#loop-options { display: grid; gap: .35rem; margin: .75rem 0; }
#loop-menu form { margin-top: .7rem; }
.score-progress output { font-size: .85rem; font-variant-numeric: tabular-nums; }
.score .score-repaired { --note-ink: #a47300; }
.score .score-played { --note-ink: #168a8a; }
.score .score-playing { --note-ink: #f57c00; }
.score :is(path, use, text):is(.score-repaired, .score-played, .score-playing):not([fill="none"]),
.score :is(.score-repaired, .score-played, .score-playing) :is(path, use, text):not([fill="none"], [data-name="chord"]) {
  fill: var(--note-ink);
}
.score :is(path, use):is(.score-played, .score-playing)[stroke]:not([stroke="none"]),
.score :is(.score-played, .score-playing) :is(path, use)[stroke]:not([stroke="none"]) {
  stroke: var(--note-ink);
}
.score .score-active-background { fill: #ffb74d; fill-opacity: .28235; pointer-events: none; }

.text-notation { padding: .35rem .1rem; }
.text-notation-header { font-size: .85rem; color: #52695e; margin: 0 0 .7rem; }
.text-staff-wrapper { display: grid; grid-template-columns: repeat(var(--bars-per-line), minmax(0, 1fr)); margin: 1.4rem 0 .75rem; }
.text-measure { position: relative; min-width: 0; border-right: 1px solid #819b8f; padding: .8rem .35rem .6rem; touch-action: pan-y; }
.text-measure.loop-range { background: #4c97c842; }
.text-measure-notes { display: flex; align-items: center; gap: .18rem; min-height: 2.5rem; }
.text-note { position: relative; display: inline-flex; flex-basis: 0; justify-content: center; align-items: center; min-width: 1ch; min-height: 2rem; padding: .3rem .05rem; border-radius: .3rem; }
.text-pitch { white-space: pre; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.abc-notation .text-pitch { font-family: inherit; font-size: .85rem; }
.abc-notation .text-note { min-width: max-content; }
.abc-notation .text-measure-notes { flex-wrap: wrap; row-gap: 1rem; }
.text-chord { position: absolute; left: 0; top: -.75rem; color: #19382e; font: .7rem system-ui; }
.text-part-badge { position: absolute; left: .1rem; top: -1.2rem; display: grid; place-items: center; width: 24px; height: 22px; border: 1.5px solid #39745e; border-radius: 3px; color: #245341; background: #f0f7f3; font: 800 16px system-ui; }
.eighth-note { text-decoration: underline; text-underline-offset: .25rem; }
.sixteenth-note { text-decoration-style: double; }
.numbered-tie { position: absolute; top: -.3rem; right: -.5rem; font-size: .8rem; }
.text-note.score-repaired { color: #a47300; }
.text-note.score-played { color: #168a8a; }
.text-note.score-playing { color: #f57c00; background: #ffb74d48; }

.header-actions { display: flex; align-items: center; gap: .65rem; margin-left: auto; }
.close-home { display: grid; place-items: center; width: 44px; height: 44px; flex: none; color: inherit; border-radius: 50%; }
.close-home:hover { background: #ffffff18; }
.close-home:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* Phone-only shell: no tablet or desktop spacing/type changes. */
.phone-only, .phone-tab-icon { display: none; }
#phone-set-dialog, #install-help { color: inherit; border: 1px solid #a6baad; border-radius: 1rem; }
#install-help { width: min(26rem, calc(100% - 2rem)); padding: 1.25rem; }
#install-help p { margin-top: 1rem; }
#install-help form { margin-top: 1.25rem; text-align: right; }
#phone-set-dialog::backdrop, #install-help::backdrop { background: #132b2366; }
body.phone-layout {
  --phone-nav-height: 64px;
  height: 100vh; height: 100dvh; min-height: 0;
  display: flex; flex-direction: column; overflow: hidden;
  padding-bottom: calc(var(--phone-nav-height) + env(safe-area-inset-bottom, 0px));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
.phone-layout .phone-only { display: block; }
.phone-layout .masthead { flex: none; padding-top: env(safe-area-inset-top, 0px); }
.phone-layout .masthead > div { height: 58px; padding: 4px max(12px, env(safe-area-inset-right, 0px)) 4px max(16px, env(safe-area-inset-left, 0px)); gap: 8px; }
.phone-layout .brand-name { font-size: 23px; letter-spacing: -.3px; }
.phone-layout .brand-edition { font-size: 16px; }
.phone-layout .header-actions { gap: 5px; }
.phone-layout .language { gap: 4px; }
.phone-layout .language svg { width: 17px; }
.phone-layout .language select { min-height: 40px; font-size: 14px; padding: 4px; }
.phone-layout .close-home { width: 44px; height: 44px; }
.phone-layout .close-home svg { width: 32px; height: 32px; }
.phone-layout .page-switch {
  position: fixed; inset: auto 0 0; z-index: 20; height: calc(var(--phone-nav-height) + env(safe-area-inset-bottom, 0px));
  padding: 4px max(12px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(12px, env(safe-area-inset-left, 0px));
  gap: 6px; border: 0; border-top: 1px solid #cad7ce; background: #f8fbf9;
}
.phone-layout .page-switch a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0; padding: 3px 6px; font-size: 12px; border-radius: 10px; }
.phone-layout .page-switch a[aria-current="page"] { background: #e0eee5; color: #194c3c; font-weight: 750; }
.phone-layout .page-switch .desktop-download { display: none; }
.phone-layout .phone-tab-icon { display: block; width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.phone-layout #practice-tab { position: relative; }
.phone-layout #practice-playing { position: absolute; top: 10px; left: calc(50% + 13px); font-size: 10px; }
.phone-layout main, body.phone-layout[data-active-page="practice"] main, body.phone-layout.set-collapsed main {
  display: flex; flex-direction: column; flex: 1; min-height: 0; width: 100%; overflow: hidden;
  margin: 0; padding: 10px max(10px, env(safe-area-inset-right, 0px)) 8px max(10px, env(safe-area-inset-left, 0px)); gap: 0;
}
.phone-layout .library, .phone-layout .practice { border-radius: 14px; padding: 14px; width: 100%; min-height: 0; }
.phone-layout #library-panel { flex: 1; display: flex; flex-direction: column; }
.phone-layout #library-panel h1 { font-size: 19px; margin-bottom: 12px; letter-spacing: -.3px; }
.phone-layout #library-panel > label { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
.phone-layout input[type="search"] { margin: 0; min-height: 46px; font-size: 16px; border-radius: 11px; background: #f2f6f3; }
.phone-layout .rank-filters { margin-top: 10px; }
.phone-layout .rank-filters label { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.phone-layout #dance { flex: 1; min-width: 0; margin: 0; min-height: 42px; font-size: 16px; padding: 6px 10px; }
.phone-layout .dance-caption { font-size: 12px; margin-top: 8px; }
.phone-layout #library-status { font-size: 13px; }
.phone-layout .tunes { flex: 1; min-height: 0; max-height: none; margin: 8px -4px 0; overscroll-behavior: contain; }
.phone-layout .tunes button { min-height: 66px; padding: 10px 8px; font-size: 17px; font-weight: 600; border-radius: 8px; }
.phone-layout .tunes small { font-size: 12px; font-weight: 400; margin-top: 3px; }
.phone-layout #preview-panel { display: none; }
.phone-layout.phone-preview #library-panel { display: none; }
.phone-layout.phone-preview #preview-panel { display: flex; flex: 1; flex-direction: column; }
.phone-layout .phone-back { display: flex; align-items: center; gap: 5px; align-self: flex-start; min-height: 40px; margin: -8px 0 4px -8px; padding: 0 8px; border: 0; background: transparent; color: #24614e; font-size: 15px; }
.phone-layout .phone-back > span:first-child { font-size: 30px; line-height: 1; }
.phone-layout .score-heading { flex: none; gap: 10px; }
.phone-layout #tune-title { font-size: 22px; line-height: 1.18; letter-spacing: -.3px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.phone-layout #tune-meta { font-size: 12px; margin-top: 5px; }
.phone-layout .score-actions { gap: 10px; }
.phone-layout .score-actions select { min-height: 44px; flex: 1; width: 0; max-width: none; font-size: 14px; }
.phone-layout .score-actions button { min-height: 44px; font-size: 14px; padding: 8px 14px; }
.phone-layout #set-feedback { font-size: 13px; flex: none; }
.phone-layout #preview-score, .phone-layout #practice-score {
  flex: 1; min-height: 0; max-height: none; margin: 10px -6px 0; padding: 0 4px; overflow: auto; scrollbar-gutter: auto;
}
.phone-layout #preview-score { order: 3; }
.phone-layout #preview-transport, .phone-layout #practice-transport { flex: none; order: 4; margin-top: 8px; padding-top: 4px; border-top: 1px solid #dce5df; }
.phone-layout .transport { margin-top: 4px; gap: 10px; }
.phone-layout .transport .play { min-width: 84px; min-height: 46px; padding: 8px 12px; border-radius: 24px; font-size: 15px; font-weight: 650; }
.phone-layout .score-progress { gap: 6px; }
.phone-layout .score-progress output { font-size: 11px; }
.phone-layout .score-progress input { min-height: 40px; }
.phone-layout .play-status:not(:empty) { font-size: 11px; margin-top: 4px; }
.phone-layout #practice-panel { flex: 1; display: flex; flex-direction: column; }
.phone-layout #practice-panel > .practice-heading { display: none; }
.phone-layout #toggle-set { display: none; }
.phone-layout .phone-practice-tools { display: flex; align-items: center; gap: 12px; flex: none; }
.phone-layout #phone-set-toggle { min-height: 46px; min-width: 112px; display: flex; flex-wrap: wrap; gap: 4px 7px; align-items: center; justify-content: center; font-size: 13px; color: #24614e; background: #e9f2ec; border-color: #b3cdbd; border-radius: 11px; padding: 6px 10px; }
.phone-layout #phone-set-count { font-size: 12px; }
.phone-layout #phone-tempo-slot { flex: 1; min-width: 0; }
.phone-layout #phone-tempo-slot .practice-tempo { grid-template-columns: auto; gap: 0; padding: 0; margin: 0; border: 0; }
.phone-layout #phone-tempo-slot label { display: none; }
.phone-layout #phone-tempo-slot output { font-size: 14px; text-align: right; }
.phone-layout #phone-tempo-slot input { min-height: 30px; }
.phone-layout .phone-empty { margin: auto; text-align: center; color: #637168; font-size: 17px; padding: 24px 12px; }
.phone-layout #phone-practice-empty:not([hidden]) + #practice-transport + #practice-score { flex: 0; }
.phone-layout .score-details { font-size: 11px; }
.phone-layout #practice-score h3 { font-size: 16px; }
.phone-layout #phone-set-dialog { margin: auto 0 0; width: 100%; max-width: none; max-height: min(75dvh, 640px); padding: 0; border: 0; border-radius: 20px 20px 0 0; overflow: hidden; background: #fff; padding-bottom: env(safe-area-inset-bottom, 0px); }
.phone-layout #phone-set-dialog[open] { display: flex; }
.phone-layout #phone-set-dialog #practice-set { display: flex; flex-direction: column; position: relative; min-height: 160px; max-height: min(72dvh, 610px); border: 0; padding: 22px 18px 18px; border-radius: 0; }
.phone-layout #practice-set #set-title { font-size: 20px; padding-right: 44px; margin-bottom: 14px; }
.phone-layout .sheet-close { position: absolute; right: 14px; top: 12px; width: 40px; height: 40px; padding: 0; border-radius: 50%; font-size: 30px; line-height: 1; color: #315044; background: #eef3f0; border: 0; }
.phone-layout #set-tunes { overflow-y: auto; margin: 0; padding-left: 20px; }
.phone-layout #set-tunes li { padding-block: 12px; }
.phone-layout #set-tunes strong { font-size: 17px; }
.phone-layout .set-entry-controls select, .phone-layout .set-entry-controls button { min-height: 44px; min-width: 44px; font-size: 16px; }
.phone-layout .settings { flex: 1; overflow-y: auto; }
.phone-layout .score-type-setting { font-size: 16px; margin-bottom: 20px; }
.phone-layout .score-type-setting select { font-size: 16px; min-height: 44px; }
.phone-layout .settings h1 { font-size: 20px; }
.phone-layout #instrument-settings li { grid-template-columns: minmax(0,1fr) 45px; gap: 2px 12px; padding: 12px 0; }
.phone-layout #instrument-settings label { min-height: 36px; font-size: 16px; gap: 10px; grid-column: 1; }
.phone-layout #instrument-settings input[type="checkbox"] { width: 22px; height: 22px; flex: none; }
.phone-layout #instrument-settings output { grid-row: 1; grid-column: 2; font-size: 14px; }
.phone-layout #instrument-settings input[type="range"] { grid-column: 1 / -1; min-height: 38px; }
.phone-layout .phone-app-options { display: grid; gap: 10px; border-top: 1px solid #dce5df; margin-top: 12px; padding-top: 18px; }
.phone-layout .phone-app-options > button, .phone-layout .phone-download { min-height: 46px; display: flex; align-items: center; justify-content: center; border-radius: 11px; text-decoration: none; font-size: 15px; }
.phone-layout .legal-note { font-size: 11px; line-height: 1.6; }
.phone-layout .sound-download { flex: none; padding: 6px 14px; gap: 4px 8px; font-size: 11px; }
.phone-layout .sound-download > span { width: 100%; }
.phone-layout .sound-download progress { min-width: 0; }
.phone-layout .offline-status { flex: none; margin: 0; padding: 6px 14px; font-size: 12px; color: #755921; background: #fff0c6; }
.phone-layout dialog:not(#phone-set-dialog) { padding: 20px; width: calc(100% - 24px); max-height: calc(100dvh - 32px); overflow-y: auto; }
.phone-layout dialog h2 { font-size: 21px; }
.phone-layout #loop-options button { min-height: 46px; font-size: 17px; }
.phone-layout dialog form button { min-height: 44px; }
@media (max-width: 360px) {
  .phone-layout .masthead > div { padding-inline: 8px; gap: 4px; }
  .phone-layout .masthead strong { white-space: nowrap; }
  .phone-layout .brand-name { font-size: 20px; }
  .phone-layout .brand-edition { font-size: 13px; }
  .phone-layout .language svg { display: none; }
  .phone-layout .header-actions { gap: 2px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.phone-layout { --phone-nav-height: 52px; }
  .phone-layout .masthead > div { height: 44px; }
  .phone-layout .page-switch a { flex-direction: row; gap: 6px; }
  .phone-layout main { padding-block: 6px; }
  .phone-layout .library, .phone-layout .practice { padding-block: 8px; }
  .phone-layout .phone-back { min-height: 30px; margin-bottom: 0; }
  .phone-layout .score-heading { grid-template-columns: minmax(0,1fr) minmax(220px,.8fr); gap: 12px; align-items: center; }
  .phone-layout #tune-title { font-size: 19px; }
  .phone-layout #preview-score, .phone-layout #practice-score { margin-top: 6px; }
  .phone-layout .play-status { display: none; }
}

/* Local phone spacing refinement; tablet/desktop rules remain unchanged. */
.phone-layout { line-height: 1.4; letter-spacing: 0; }
body.phone-layout { --phone-nav-height: 56px; }
.phone-layout .masthead > div { height: 48px; padding-block: 2px; }
.phone-layout .brand-name { font-size: 22px; letter-spacing: -.25px; }
.phone-layout .brand-edition { font-size: 14px; }
.phone-layout .page-switch { padding-top: 2px; }
.phone-layout .page-switch a { gap: 1px; padding-block: 2px; line-height: 1.15; }
.phone-layout .phone-tab-icon { width: 21px; height: 21px; }
.phone-layout main, body.phone-layout[data-active-page="practice"] main, body.phone-layout.set-collapsed main { padding-block: 6px 4px; }
.phone-layout .library, .phone-layout .practice { padding: 10px; border-radius: 12px; }
.phone-layout #library-panel h1 { font-size: 18px; letter-spacing: -.15px; margin-bottom: 8px; }
.phone-layout input[type="search"] { min-height: 40px; padding: 6px 10px; font-size: 16px; border-radius: 9px; }
.phone-layout .rank-filters { margin-top: 8px; }
.phone-layout .rank-filters label { gap: 10px; }
.phone-layout #dance { min-height: 36px; padding: 4px 8px; }
.phone-layout .dance-caption { margin-top: 5px; line-height: 1.3; }
.phone-layout .tunes { margin-top: 6px; }
.phone-layout .tunes button { min-height: 60px; padding: 8px 6px; font-size: 16px; line-height: 1.35; }
.phone-layout .tunes small { margin-top: 2px; line-height: 1.3; }
.phone-layout .phone-preview-navigation { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -4px -2px 4px; min-height: 34px; }
.phone-layout .phone-back { min-height: 34px; margin: 0; font-size: 14px; padding-inline: 2px 8px; }
.phone-layout .phone-back > span:first-child { font-size: 27px; }
.phone-layout .phone-expand { display: grid; place-items: center; width: 36px; min-width: 36px; height: 36px; padding: 7px; border: 0; border-radius: 8px; background: #e9f2ec; color: #24614e; }
.phone-layout .phone-expand svg { width: 22px; height: 22px; }
.phone-layout .score-heading { gap: 6px; }
.phone-layout #tune-title { font-size: 20px; line-height: 1.15; letter-spacing: -.15px; }
.phone-layout #tune-meta { line-height: 1.3; margin-top: 3px; }
.phone-layout .score-actions { gap: 8px; }
.phone-layout .score-actions select, .phone-layout .score-actions button { min-height: 36px; padding-block: 4px; }
.phone-layout #preview-score, .phone-layout #practice-score { margin-top: 5px; }
.phone-layout #preview-transport, .phone-layout #practice-transport { margin-top: 4px; padding-top: 2px; }
.phone-layout .transport { margin-top: 2px; gap: 8px; }
.phone-layout .transport .play { min-height: 44px; }
.phone-layout .play-status:is([data-text="playing"], [data-text="muted"], [data-text="originalMelody"], [data-text="previewEnded"], [data-text="practiceEnded"]) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); margin: 0; }
.phone-layout .phone-practice-tools { gap: 8px; }
.phone-layout #phone-set-toggle { min-height: 40px; min-width: 102px; padding: 4px 8px; line-height: 1.3; }
.phone-layout #phone-tempo-slot output { line-height: 1.25; }
.phone-layout #phone-tempo-slot input { min-height: 26px; }
.phone-layout .score-type-setting { margin-bottom: 16px; }
.phone-layout .score-type-setting select { min-height: 38px; padding-block: 4px; }
.phone-layout #instrument-settings li { padding-block: 9px; }
.phone-layout #instrument-settings label { line-height: 1.3; }
.phone-layout #phone-focus-bar:not([hidden]) { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; padding: max(2px, env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 2px max(10px, env(safe-area-inset-left, 0px)); background: #eef3f0; flex: none; }
.phone-layout #phone-focus-title { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone-layout #phone-focus-exit { display: flex; gap: 4px; align-items: center; justify-content: center; min-width: 66px; min-height: 38px; padding: 3px 8px; font-size: 14px; color: #24614e; background: #fff; border-radius: 9px; }
.phone-layout #phone-focus-exit > span:first-child { font-size: 23px; line-height: 1; }
body.phone-layout.phone-score-focus { padding-bottom: env(safe-area-inset-bottom, 0px); }
.phone-layout.phone-score-focus > .masthead, .phone-layout.phone-score-focus > .page-switch { display: none; }
.phone-layout.phone-score-focus main { padding: 0 max(4px, env(safe-area-inset-right, 0px)) 2px max(4px, env(safe-area-inset-left, 0px)); }
.phone-layout.phone-score-focus #preview-panel, .phone-layout.phone-score-focus #practice-panel { padding: 0 4px 4px; border: 0; border-radius: 0; }
.phone-layout.phone-score-focus .phone-preview-navigation, .phone-layout.phone-score-focus .score-heading, .phone-layout.phone-score-focus #set-feedback, .phone-layout.phone-score-focus .phone-practice-tools { display: none; }
.phone-layout.phone-score-focus #preview-score, .phone-layout.phone-score-focus #practice-score { margin-top: 0; }
@media (max-width: 360px) {
  .phone-layout .brand-name { font-size: 20px; }
  .phone-layout .brand-edition { font-size: 13px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.phone-layout { --phone-nav-height: 48px; }
  .phone-layout .masthead > div { height: 44px; }
  .phone-layout #tune-title { font-size: 19px; }
  .phone-layout #phone-focus-bar:not([hidden]) { min-height: 36px; }
}

/* Readable type hierarchy: use spacing, rather than tiny text, to retain density. */
:root { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; line-height: 1.45; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
h1 { font-size: 21px; line-height: 1.3; margin-bottom: 12px; }
h2 { font-size: clamp(22px, 2.2vw, 26px); line-height: 1.25; }
label, legend { font-size: 15px; }
.muted, .tunes small, .score-details, .set-entry-meta, .legal-note, .text-notation-header { font-size: 14px; line-height: 1.4; }
.practice-hint { font-size: 13px; line-height: 1.4; }
.tunes { margin-block: 8px; }
.tunes button { line-height: 1.35; padding-block: 7px; }
.tunes small { margin-top: 2px; }
.score-heading { gap: 8px; }
.score-heading p { margin-top: 4px; }
#practice-score article + article { margin-top: 12px; padding-top: 12px; }
.score-details { margin-top: 4px; }
.set-entry { gap: 4px; }
#set-tunes li { padding-block: 8px; }
#instrument-settings li { padding-block: 10px; }
.score-type-setting { margin-bottom: 16px; }
.legal-note { margin-top: 12px; padding-top: 12px; }
.abc-notation .text-pitch { font-size: 15px; }
.text-chord { font-size: 13px; top: -16px; }
.loop-progress b { font-size: 12px; }
/* Keep page pixels opaque and out of the status-bar edge. System chrome remains OS-controlled. */
body.phone-layout { background: #eef3f0; overscroll-behavior: none; isolation: isolate; }
.phone-layout .masthead { position: relative; z-index: 5; background: #15392e; overflow: clip; backdrop-filter: none; -webkit-backdrop-filter: none; }
.phone-layout .masthead > div { height: 50px; }
.phone-layout .page-switch { background: #f8fbf9; }
.phone-layout .page-switch a { font-size: 13px; line-height: 1.2; }
.phone-layout .brand-edition { font-size: 15px; }
.phone-layout .language select, .phone-layout .score-actions select { font-size: 16px; }
.phone-layout .library, .phone-layout .practice { padding: 12px; }
.phone-layout #library-panel h1 { font-size: 19px; line-height: 1.3; margin-bottom: 8px; }
.phone-layout #tune-title { font-size: 21px; line-height: 1.25; letter-spacing: 0; }
.phone-layout .rank-filters { margin-top: 8px; }
.phone-layout .rank-filters label { font-size: 15px; gap: 8px; }
.phone-layout #dance { min-height: 40px; }
.phone-layout .dance-caption, .phone-layout #library-status, .phone-layout .tunes small,
.phone-layout #tune-meta, .phone-layout .set-entry-meta, .phone-layout .score-details,
.phone-layout .legal-note, .phone-layout .play-status:not(:empty), .phone-layout .sound-download,
.phone-layout .offline-status { font-size: 13px; line-height: 1.35; }
.phone-layout .tunes button { font-size: 16px; line-height: 1.35; min-height: 58px; padding: 7px 6px; }
.phone-layout .tunes small { margin-top: 2px; }
.phone-layout #tune-meta { margin-top: 4px; }
.phone-layout .score-actions button { font-size: 15px; }
.phone-layout .score-actions select, .phone-layout .score-actions button { min-height: 40px; }
.phone-layout .score-progress { gap: 4px; }
.phone-layout .score-progress output { font-size: 13px; }
.phone-layout .transport { gap: 6px; }
.phone-layout .transport .play { min-width: 78px; padding-inline: 8px; }
.phone-layout #practice-score h3 { font-size: 17px; line-height: 1.3; }
.phone-layout #phone-set-count { font-size: 13px; }
.phone-layout #set-tunes li { padding-block: 8px; }
.phone-layout #set-tunes strong { font-size: 17px; line-height: 1.3; }
.phone-layout #practice-set #set-title { margin-bottom: 8px; }
.phone-layout #instrument-settings li { padding-block: 8px; }
.phone-layout #instrument-settings label { line-height: 1.35; }
.phone-layout .score-type-setting { margin-bottom: 12px; }
.phone-layout .legal-note { padding-top: 8px; margin-top: 12px; }
.phone-layout #phone-focus-bar:not([hidden]) { position: relative; z-index: 5; background: #eef3f0; backdrop-filter: none; -webkit-backdrop-filter: none; }
@media (display-mode: standalone) {
  .phone-layout .masthead { padding-top: calc(env(safe-area-inset-top, 0px) + 8px); }
  .phone-layout #phone-focus-bar:not([hidden]) { padding-top: calc(env(safe-area-inset-top, 0px) + 8px); }
}
@media (max-width: 360px) {
  .phone-layout .header-actions { gap: 2px; }
  .phone-layout .language { gap: 2px; }
  .phone-layout .brand-name { font-size: 20px; }
  .phone-layout .brand-edition { font-size: 14px; }
  .phone-layout .language select { padding-inline: 2px; }
}

/* Scroll beyond the last staff without adding blank measures to the music. */
#preview-score:not(:empty)::after, #practice-score:not(:empty)::after {
  content: ""; display: block; height: var(--score-tail-space, 30dvh);
  pointer-events: none;
}
#set-empty { flex: none; font-size: 14px; line-height: 1.4; margin-top: 8px; }
.phone-layout #set-empty { font-size: 13px; }

/* Keep version selection and adding together; the extra action wraps on phones. */
#preview-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; }
#preview-actions select { width: 100%; max-width: 13rem; }
.phone-layout #preview-actions { grid-template-columns: minmax(0, 1fr) auto; }
.phone-layout #preview-actions select { width: 100%; }
.phone-layout #add-to-set { grid-column: 2; grid-row: 1; }
.phone-layout #export-abc { grid-column: 2; grid-row: 2; }

#set-full-menu { width: min(25rem, calc(100% - 2rem)); border: 1px solid #a6baad; border-radius: .8rem; color: inherit; padding: 20px; }
#set-full-menu::backdrop { background: #19382e66; }
#set-full-menu p { margin-top: 12px; line-height: 1.45; }
#set-full-menu form { margin-top: 16px; text-align: right; }

#library-panel #library-title { margin-bottom: 0; }
.library-source { color: #637168; font-size: 12px; line-height: 1.3; margin: 2px 0 8px; }
