:root {
  --ink: #242827;
  --muted: #555b56;
  --line: #d3d5ce;
  --blue: #245e83;
  --orange: #97421b;
  --magenta: #b00068;
  --paper: #fff;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #f4f2ec; font: 15px/1.5 var(--sans); }
button, select, input { font: inherit; min-height: 36px; }
button, select, summary { cursor: pointer; }
button { border: 0; background: none; color: inherit; padding: 6px 10px; border-radius: 2px; }
button:hover, summary:hover { background: #eff1ed; }
button:disabled { opacity: .4; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible, [tabindex="0"]:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 3px;
}
select { background: var(--paper); color: var(--ink); border: 1px solid #9ba199; border-radius: 2px; padding: 4px 24px 4px 8px; }
input[type=checkbox] { accent-color: var(--blue); min-height: 0; width: 16px; height: 16px; }
[hidden] { display: none !important; }
.visually-hidden, .skip-link:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
.skip-link:focus { position: fixed; top: 8px; left: 12px; padding: 10px; background: white; z-index: 10; }
main { max-width: 1680px; height: 100dvh; display: flex; flex-direction: column; margin: 0 auto; padding: 0 32px 20px; }
h1 { font: normal 30px/1.2 Georgia, 'Times New Roman', serif; margin: 0 0 8px; }
h2 { font: 500 18px/1.3 var(--sans); margin: 0; }
a { color: var(--blue); text-underline-offset: 3px; }
.atlas-masthead { display: flex; align-items: center; gap: 16px; padding: 12px 0; margin-bottom: 18px; border-bottom: 1px solid var(--ink); }
.atlas-name { font: 19px Georgia, serif; white-space: nowrap; margin-right: auto; }
.atlas-masthead button { border: 1px solid var(--ink); padding-inline: 18px; }
.piece-picker { min-width: 0; }
#piece-select { max-width: 400px; font-size: 13px; }
.work-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.composer { margin: 0 0 4px; font-size: 13px; }
#movement-nav { display: flex; gap: 6px; flex-wrap: wrap; }
#movement-nav button { border-bottom: 2px solid transparent; border-radius: 0; padding: 5px 12px; font-size: 14px; }
#movement-nav button:first-child { padding-left: 0; }
#movement-nav [aria-current=true] { border-color: var(--ink); font-weight: 600; }
.file-actions { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.file-menu { position: relative; }
.file-menu summary { padding: 6px 12px; }
.file-menu summary::marker { font-size: 9px; }
.file-options { position: absolute; top: 35px; right: 0; width: 170px; z-index: 5; padding: 5px; border: 1px solid var(--line); background: white; box-shadow: 0 4px 14px #00000010; }
.file-options button { display: block; width: 100%; text-align: left; padding: 8px; }
.status { margin: 0 0 12px; }
.workspace { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.score-column { display: flex; flex-direction: column; flex: 1; min-height: 0; min-width: 0; background: var(--paper); border: 1px solid var(--line); }
.toolbar { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.mode-tabs { display: flex; align-self: stretch; margin-right: auto; gap: 4px; }
.mode-tabs button { position: relative; border-radius: 0; padding: 10px 12px; font-size: 14px; }
.mode-tabs button[aria-pressed=true] { font-weight: 600; }
.mode-tabs button[aria-pressed=true]::after { content: ''; position: absolute; bottom: -1px; height: 2px; left: 12px; right: 12px; background: var(--ink); }
.zoom-controls { display: flex; align-items: center; font-size: 13px; }
.zoom-controls button { font-size: 18px; padding: 3px 10px; }
.zoom-controls output { min-width: 42px; text-align: center; font-variant-numeric: tabular-nums; }
.mode-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 10px 18px; }
.mode-controls > div, .mode-controls label { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.mode-controls select { max-width: min(360px, 60vw); }
#compare-controls { gap: 16px; flex-wrap: wrap; }
#compare-controls select { max-width: 280px; }
#explore-controls { flex-wrap: wrap; }
#scan-button { margin-left: auto; border: 1px solid #9ba199; padding: 5px 13px; font-size: 13px; }
.text-button { font-size: 13px; white-space: nowrap; text-decoration: underline; text-underline-offset: 4px; }
.key-a { color: var(--blue); font-weight: 600; }
.key-b { color: var(--magenta); font-weight: 600; }
.key-difference { color: var(--orange); font-weight: 600; }
.check { font-size: 13px; }
.score-navigation { display: flex; align-items: center; gap: 8px; padding: 6px 18px; border-bottom: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.score-navigation label { display: flex; align-items: center; gap: 8px; }
.score-navigation input, .scan-controls input[type=number] { width: 70px; padding: 4px 7px; border: 1px solid #9ba199; background: white; }
#coverage-label { margin-left: 4px; }
#reading-status { color: #70400e; }
#reading-status:empty { display: none; }
#comparison-key { display: flex; align-items: center; gap: 12px; margin-left: auto; }
#next-difference { font-weight: 500; }
.reader-help { position: relative; font-size: 13px; }
.reader-help > summary { padding: 7px 9px; min-height: 36px; }
.reader-help > summary::marker { font-size: 10px; }
.reader-help-content { position: absolute; right: 0; top: calc(100% + 5px); z-index: 7; width: 340px; max-width: calc(100vw - 48px); padding: 18px 20px; border: 1px solid #9ba199; background: white; box-shadow: 0 5px 20px #18241b18; color: var(--ink); }
.reader-help-content h3 { margin: 0 0 12px; font-size: 15px; }
.reader-help-content p { margin: 10px 0; line-height: 1.6; }
.reader-help-content p:last-child { margin-bottom: 0; }
.notation-definitions { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; }
.notation-definitions dt { font-weight: 600; }
.notation-definitions dd { margin: 0; }
.legend { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.legend-gradient { width: 72px; height: 6px; }
.overview { padding: 0 2px 20px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.overview-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.overview-heading h2 { font: 500 14px var(--sans); }
.overview-actions { display: flex; align-items: center; gap: 12px; }
.entropy-guide { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 20px; margin: 4px 0 8px; font-size: 12px; }
#entropy-first { font-size: 13px; }
.profile-lane { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 12px; padding-top: 10px; }
.profile-axis { position: relative; color: var(--muted); font-size: 10px; }
.staff-label { position: absolute; left: 0; top: 42px; font-size: 11px; }
.axis-top { position: absolute; top: -4px; right: 0; }
.axis-middle { position: absolute; top: 45px; right: 0; }
.axis-zero { position: absolute; bottom: 14px; right: 0; }
.profile-bars { display: grid; grid-template-columns: repeat(var(--bars), minmax(0, 1fr)); gap: 4px; min-width: 0; }
.profile-bar { position: relative; height: 118px; min-height: 0; min-width: 0; padding: 0; border-radius: 0; color: var(--muted); font-size: 10px; }
.profile-bar:hover .profile-plot, .profile-bar:focus-visible .profile-plot { background: #e9eee9; }
.profile-bar[aria-pressed=true] .profile-plot { outline: 2px solid var(--ink); outline-offset: 2px; }
.profile-bar:disabled { opacity: 1; }
.profile-plot { position: absolute; inset: 0 0 18px; border-top: 1px solid #eff0ed; border-bottom: 1px solid #dce0da; background: linear-gradient(transparent 49%, #f0f1ee 49%, #f0f1ee 51%, transparent 51%); }
.bar-fill { position: absolute; bottom: 0; left: 0; right: 0; height: max(1px, var(--height, 0%)); background: var(--bar-color); }
.bar-unavailable .bar-fill { height: 1px; background: repeating-linear-gradient(90deg, #717673 0 2px, transparent 2px 4px); }
.bar-number { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; }
.score-panel { flex: 1; min-height: 200px; overflow: auto; padding: 20px 16px; scrollbar-width: thin; scrollbar-color: #a9b1a7 transparent; }
#score { min-height: 350px; position: relative; max-width: 960px; margin-inline: auto; }
#score > svg { display: block; width: 100%; height: auto; overflow: visible; }
g.note { cursor: pointer; outline: none; }
.atlas-selection { pointer-events: none; fill: none; stroke: #242827; stroke-width: 24; }
g.note:focus-visible .atlas-selection { stroke: var(--blue); stroke-width: 24; }
g.note:focus-visible .notehead { outline: 2px solid var(--blue); outline-offset: 5px; }
g.fing, g.atlas-instruction { cursor: pointer; }
g.atlas-instruction text, g.atlas-instruction tspan { font-style: normal; }
body[data-reading-mode=single] #score g.fing, body[data-reading-mode=single] #score g.atlas-instruction { fill: var(--ink); color: var(--ink); }
body[data-reading-mode=compare] #score .atlas-a { color: var(--blue); fill: var(--blue); }
body[data-reading-mode=compare] #score .atlas-b { color: var(--magenta); fill: var(--magenta); }
body[data-reading-mode=compare] #score .atlas-shared { color: var(--ink); fill: var(--ink); }
.note-popup { position: fixed; z-index: 8; width: 310px; max-width: calc(100vw - 24px); max-height: min(440px, 70vh); overflow: auto; padding: 16px 18px; background: #fff; border: 1px solid #9ba199; box-shadow: 0 5px 24px #18241b24; }
.note-popup h2 { padding-right: 20px; font: 18px/1.4 Georgia, serif; }
.popup-close { position: absolute; top: 4px; right: 5px; font-size: 22px; }
.popup-group { margin-top: 12px; }
.popup-group h3 { margin: 0 0 8px; font-size: 12px; font-weight: 500; }
.popup-choice { display: grid; grid-template-columns: 32px 1fr; gap: 10px; align-items: start; margin: 8px 0; }
.popup-finger { font: 22px/1.15 Georgia, serif; text-align: center; }
.popup-finger small { display: block; font: 11px/1.5 var(--sans); }
.popup-sources { font-size: 12px; line-height: 1.5; }
.popup-caption { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.popup-draft { border-top: 1px solid var(--line); padding-top: 10px; }
dialog { width: min(580px, calc(100vw - 32px)); max-height: 85vh; padding: 28px; border: 1px solid #9ba199; border-radius: 2px; color: var(--ink); background: white; box-shadow: 0 16px 60px #0002; }
dialog::backdrop { background: #26302a66; }
body:has(dialog[open]) { overflow: hidden; }
dialog h2 { margin-bottom: 18px; font: 26px Georgia, serif; }
dialog h3 { margin: 22px 0 6px; font-size: 14px; font-weight: 600; }
dialog p { font-size: 14px; line-height: 1.7; }
dialog details { font-size: 14px; margin-top: 20px; }
dialog summary { padding-block: 5px; }
.source-explanation { color: var(--muted); margin-top: 0; font-size: 14px; }
dialog .source-item { margin: 8px 0; }
.source-path { overflow-wrap: anywhere; }
.dialog-close { position: absolute; top: 8px; right: 10px; font-size: 24px; }
.file-label { display: block; margin: 20px 0; font-size: 14px; }
.file-label input { display: block; margin-top: 8px; max-width: 100%; font-size: 13px; }
.dialog-actions { display: flex; gap: 10px; margin-top: 24px; }
.primary { background: var(--ink); color: white; padding: 7px 22px; }
.primary:hover { background: #414943; }
.error { color: #a3332c; background: #fff1ed; padding: 9px; }
.help-modes { display: grid; grid-template-columns: auto 1fr; gap: 18px; font-size: 14px; margin: 24px 0; }
.help-modes dt { font-weight: 600; }
.help-modes dd { margin: 0; }
/* The catalogue is a workspace of its own; its controls stay put while browsing. */
#library-dialog { width: min(1440px, calc(100vw - 48px)); max-width: none; height: calc(100dvh - 48px); max-height: none; padding: 28px 32px 0; overflow: hidden; }
#library-dialog[open] { display: flex; flex-direction: column; }
.library-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.library-eyebrow { margin: 0 0 4px; font: 14px Georgia, serif; }
.library-heading h2 { margin: 0; font-size: 34px; }
.library-close { font-size: 14px; }
.library-close span { margin-left: 12px; font-size: 23px; vertical-align: middle; }
.library-collections { display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
.library-collections button { padding: 10px 0; border-radius: 0; border-bottom: 3px solid transparent; font-size: 15px; text-align: left; }
.library-collections button[aria-pressed=true] { border-color: var(--ink); font-weight: 600; }
.library-collections span { margin-left: 8px; font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
#library-description { margin: 14px 0 20px; font-size: 13px; max-width: 850px; }
.library-filters { display: grid; grid-template-columns: minmax(220px, 1fr) 190px; gap: 18px; margin-top: 18px; }
.library-filters label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; }
.library-filters input, .library-filters select { width: 100%; height: 42px; font-size: 14px; font-weight: 400; }
.library-search input { padding: 8px 12px; border: 1px solid #9ba199; border-radius: 2px; background: white; color: var(--ink); }
.library-result-heading { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
#library-count { margin: 0; font-size: 13px; }
#library-results { min-height: 0; flex: 1; overflow: auto; overscroll-behavior: contain; margin: 0 -6px; padding: 0 6px 24px; scrollbar-width: thin; }
.library-table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; font-size: 13px; }
.library-table thead th { position: sticky; top: 0; z-index: 1; background: #f4f2ec; border-block: 1px solid var(--line); padding: 10px 12px; font-size: 12px; font-weight: 500; }
.library-table td, .library-table tbody th { border-bottom: 1px solid var(--line); padding: 16px 12px; vertical-align: top; }
.library-table tbody th { width: 31%; font-weight: 400; }
.library-table td:nth-child(2) { width: 10%; }
.library-table td:nth-child(3) { width: 14%; }
.library-table td:last-child { width: 45%; }
.library-row:hover { background: #f8f7f3; }
.library-row:focus-within { background: #eff3f3; }
.library-work { display: block; font: 18px/1.4 Georgia, serif; text-align: left; padding: 0; min-height: 30px; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px; }
.library-work:hover { text-decoration-color: currentColor; background: none; }
.library-current { background: #f1f0eb; }
.library-current th { border-left: 3px solid var(--ink); padding-left: 9px; }
.library-detail { display: block; margin-top: 5px; font-size: 12px; }
.library-empty { padding: 40px 0; font-size: 16px; }
#scan-dialog { width: min(1200px, calc(100vw - 24px)); }
.scan-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.scan-controls label { display: flex; align-items: center; gap: 8px; }
#scan-viewport { max-height: 55vh; min-height: 120px; overflow: auto; border: 1px solid var(--line); background: #faf7ef; }
#scan-image img, #scan-image svg { display: block; width: 100%; height: auto; }
.source-records { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; max-height: 360px; overflow: auto; }
.source-reading { border-top: 1px solid var(--line); margin-top: 18px; }
@media (max-width: 1000px) {
  main { padding-inline: 20px; }
  #library-dialog { padding: 20px 20px 0; }
  .library-filters { grid-template-columns: minmax(180px, 1fr) 150px; gap: 12px; }
  .library-table td, .library-table tbody th { padding: 14px 8px; }
  .library-current th { padding-left: 5px; }
}
@media (max-width: 800px) {
  main { padding: 0 12px 16px; height: auto; display: block; }
  .workspace, .score-column { display: block; }
  .atlas-masthead { gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
  .piece-picker { flex-basis: 100%; }
  #piece-select { width: 100%; max-width: none; }
  h1 { font-size: 25px; }
  .work-heading { gap: 8px; flex-wrap: wrap; }
  .mode-controls, .score-navigation { padding: 8px 10px; }
  #compare-controls { gap: 10px; }
  .score-panel { min-height: 380px; height: 65vh; padding: 16px 6px; }
  #library-dialog { width: 100vw; height: 100dvh; border: 0; padding: 18px 18px 0; }
  .library-heading { margin-bottom: 14px; }
  .library-table, .library-table tbody { display: block; }
  .library-table thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .library-table .library-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; padding: 18px 0; border-bottom: 1px solid var(--line); }
  .library-table tbody th { grid-column: 1 / -1; width: auto; border: 0; padding: 0; }
  .library-table td { display: block; width: auto !important; border: 0; padding: 0; white-space: normal; }
  .library-table td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
  .library-table td:last-child { grid-column: 1 / -1; }
  .library-work { font-size: 20px; }
  .library-current th { border-left: 3px solid var(--ink); padding-left: 10px; }
}
@media (max-width: 560px) {
  .mode-tabs { gap: 0; }
  .mode-tabs button { padding: 10px 8px; }
  .toolbar { padding: 0 6px; gap: 4px; }
  .mode-controls select, #compare-controls select { max-width: calc(100vw - 110px); }
  #scan-button { margin-left: 0; }
  #comparison-key { flex-basis: 100%; justify-content: space-between; margin-left: 0; }
  #coverage-label { margin-left: 0; }
  .overview-heading { gap: 4px; }
  .overview-actions { width: 100%; justify-content: space-between; gap: 0; }
  .profile-lane { grid-template-columns: 75px minmax(0, 1fr); gap: 8px; }
  .staff-label { font-size: 10px; }
  .profile-bars { gap: 2px; }
  dialog { padding: 24px 16px; }
  .scan-controls select { max-width: 200px; }
  #imslp-menu .reader-help-content { position: fixed; left: 12px; right: 12px; top: auto; width: auto; max-width: none; max-height: 55vh; overflow: auto; }
  .library-heading h2 { font-size: 30px; }
  .library-collections { gap: 14px; }
  .library-collections button { font-size: 13px; flex: 1; }
  .library-collections span { display: block; margin: 2px 0 0; }
  #library-description { margin: 12px 0; font-size: 12px; }
  .library-filters { grid-template-columns: 1fr 1fr; gap: 10px; }
  .library-search { grid-column: 1 / -1; }
  .library-close { font-size: 13px; padding-right: 0; }
}
@media (max-height: 600px) and (min-width: 561px) {
  #library-dialog { height: 100dvh; padding-top: 12px; }
  .library-heading { margin-bottom: 6px; }
  .library-eyebrow { display: none; }
  .library-heading h2 { font-size: 26px; }
  #library-description { margin: 8px 0; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
