:root {
  --paper: #fbfaf7; --ink: #1b1c20; --muted: #6a6e76; --chord: #0a57a8; --accent: #c2410c;
  --side: #f1efe9; --raised: #ffffff; --line: #dcd9d0; --hover: #e7e4db; --chorus: #f1eee4; --danger: #b3261e;
  --sheet-filter: none;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Monaco, monospace;
  --fs: 16px;
  color-scheme: light;
}
:root[data-theme="dark"] { --dark: 1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-theme="sepia"]) { --dark: 1; } }

:root[data-theme="sepia"] {
  --paper: #f4ebd9; --ink: #372c1d; --muted: #7d6d57; --chord: #8f3a0e; --accent: #8f3a0e;
  --side: #eadfc9; --raised: #fbf4e6; --line: #d6c8ad; --hover: #dfd2b8; --chorus: #ebe0c9; --danger: #a4281c;
}
:root[data-theme="dark"] {
  --paper: #121316; --ink: #eef0f3; --muted: #9096a0; --chord: #ffb454; --accent: #ffb454;
  --side: #1a1c20; --raised: #24272c; --line: #2e3137; --hover: #2a2d33; --chorus: #1c1e23; --danger: #ff7a6e;
  --sheet-filter: invert(.93) hue-rotate(180deg);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="sepia"]):not([data-theme="dark"]) {
    --paper: #121316; --ink: #eef0f3; --muted: #9096a0; --chord: #ffb454; --accent: #ffb454;
    --side: #1a1c20; --raised: #24272c; --line: #2e3137; --hover: #2a2d33; --chorus: #1c1e23; --danger: #ff7a6e;
    --sheet-filter: invert(.93) hue-rotate(180deg);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 15px/1.4 var(--font); overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, #stage:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#stage:focus { outline: none; }
[hidden] { display: none !important; }
.icon { width: 20px; height: 20px; display: block; flex: none; }
.spacer { flex: 1; }

#app { display: flex; height: 100dvh; }

/* Library */
#sidebar { width: 320px; flex: none; display: flex; flex-direction: column; background: var(--side); border-right: 1px solid var(--line); min-height: 0; }
body.side-closed #sidebar { display: none; }
.side-head { flex: none; padding: 12px 12px 10px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; border-bottom: 1px solid var(--line); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--hover); border-radius: 9px; padding: 2px; }
.tabs button { padding: 6px; border-radius: 7px; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--raised); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .18); }
.search { display: flex; align-items: center; gap: 8px; background: var(--raised); border: 1px solid var(--line); border-radius: 9px; padding: 0 10px; color: var(--muted); }
.search .icon { width: 17px; height: 17px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); font: inherit; padding: 8px 0; }

.side-scroll { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.list { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
/* Selecting: the whole sidebar scrolls as one, so only the selection bar stays and the list gets the room. */
body.picking .side-scroll { display: block; overflow-y: auto; overscroll-behavior: contain; --bar: 68px; }
body.picking .list { overflow: visible; }
body.picking .letter { top: var(--bar); }
body.picking .row { min-height: 0; padding: 5px 14px; scroll-margin-top: calc(var(--bar) + 26px); }
body.picking .version-tabs { display: none; }
body.picking .row .text { display: flex; flex-wrap: wrap; align-items: center; column-gap: 6px; }
body.picking .row .name { flex: 0 0 100%; }
body.picking .row .sub { flex: 0 1 auto; min-width: 0; }
body.picking .row-tags { flex: 0 1 auto; flex-wrap: nowrap; min-width: 0; margin-top: 0; overflow: hidden; }
.letter { position: sticky; top: 0; z-index: 1; padding: 3px 14px; font-size: 12px; font-weight: 700; color: var(--muted); background: var(--side); border-bottom: 1px solid var(--line); }
.row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 14px; text-align: left; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); min-height: 46px; }
/* Scrolling to a song must not leave it under the sticky heading. */
.row { scroll-margin-top: 30px; }
.row:hover { background: var(--hover); }
.row.current { background: var(--accent); color: var(--paper); }
.row.current .sub, .row.current .badge { color: inherit; opacity: .85; }
.row.lost { opacity: .5; cursor: default; }
.row .text { flex: 1; min-width: 0; }
.row .name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 3px; }
.row-tag { min-width: 0; max-width: 100%; padding: 0 6px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--ink); }
.row.current .row-tag { background: rgb(0 0 0 / .14); color: inherit; }
.badge { font-size: 13px; font-weight: 700; color: var(--chord); }
.empty { padding: 28px 18px; color: var(--muted); text-align: center; }
.set-row-actions { display: flex; align-items: center; }
.grip { color: var(--muted); cursor: grab; width: 18px; height: 18px; flex: none; }
.position { width: 20px; flex: none; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; opacity: .7; }
.remove { padding: 4px; border-radius: 6px; opacity: 0; color: inherit; }
.row:hover .remove, .remove:focus-visible { opacity: .7; }
.remove .icon { width: 15px; height: 15px; }
.row.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.list-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--side); z-index: 1; }
.list-head input { flex: 1; min-width: 0; font: 600 15px var(--font); color: var(--ink); background: none; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; }
.list-head input:hover, .list-head input:focus { border-color: var(--line); background: var(--raised); outline: 0; }
.list-title { padding: 10px 14px 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.new-set { display: flex; gap: 6px; padding: 10px; }
.new-set input { flex: 1; min-width: 0; font: inherit; color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; }
.small-note { padding: 8px 14px; font-size: 12.5px; color: var(--muted); }
.side-foot { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 14px; border-top: 1px solid var(--line); min-height: 44px; }
#status { flex: 1; min-width: 0; font-size: 12.5px; color: var(--muted); }
.lib-actions { display: grid; grid-template-columns: 1.1fr 1.1fr .7fr; gap: 6px; }
.lib-action.on { background: var(--accent); color: var(--paper); }
.bulk-bar { position: sticky; top: 0; z-index: 2; flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; height: 68px; align-content: center; padding: 0 10px; background: var(--side); border-bottom: 1px solid var(--line); font-size: 13px; }
.bulk-break { flex: 0 0 100%; height: 0; }
#bulkDone { background: var(--accent); color: var(--paper); }
.bulk-bar b { margin-right: auto; }
.bulk-action { padding: 4px 7px; border-radius: 7px; font-weight: 600; background: var(--hover); white-space: nowrap; }
.bulk-action:disabled { opacity: .4; cursor: default; }
#bulkDelete:not(:disabled) { color: var(--accent); }
.tick { width: 20px; height: 20px; flex: none; display: grid; place-items: center; border: 2px solid var(--line); border-radius: 6px; font-size: 13px; font-weight: 700; }
.row.picked { background: var(--hover); }
.row.picked .tick { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.install-tip { padding: 10px 14px; font-size: 13px; background: var(--chorus); border-bottom: 1px solid var(--line); }
.install-tip .row-action { display: block; margin-top: 4px; padding-left: 0; }
.start-import { max-width: 240px; margin-top: 8px; }
.drop-zone { border: 2px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; margin-bottom: 12px; }
.drop-zone .submit { max-width: 240px; margin-top: 8px; }
.guide details { border-top: 1px solid var(--line); padding: 9px 2px; }
.guide summary { font-weight: 600; cursor: pointer; }
.guide ol { margin: 8px 0 4px; padding-left: 20px; }
.guide .gets { color: var(--muted); font-size: 13.5px; margin: 4px 0 0; }
.report li { margin-bottom: 3px; }
.lib-action { display: flex; align-items: center; justify-content: center; gap: 6px; height: 34px; border-radius: 8px; font-weight: 600; font-size: 13.5px; background: var(--hover); }
.lib-action:hover { background: var(--raised); }
.lib-action:disabled { opacity: .4; cursor: default; background: var(--hover); }
.lib-action .icon { width: 16px; height: 16px; }
#status .bar { display: block; height: 3px; margin-top: 5px; background: var(--line); border-radius: 2px; overflow: hidden; }
#status .bar i { display: block; height: 100%; background: var(--accent); }

/* Bars */
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
#topbar, #transport { display: flex; align-items: center; gap: 6px; padding: 7px 10px; background: var(--side); flex: none; flex-wrap: nowrap; z-index: 2; }
#topbar { gap: 3px; border-bottom: 1px solid var(--line); container-type: inline-size; overflow-x: auto; }
#topbar .tool { min-width: 34px; }
#topbar .key-tool { padding: 0 6px; }
/* Left: what you do to the song. Right: how it looks. Words where they fit, icons where they do not. */
.tool .label { display: none; font-size: 13.5px; font-weight: 600; max-width: 13ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool.set { color: var(--chord); }
#topbar > * { flex: none; }
#topbar > .spacer { flex: 1; }
#topbar .divider { margin: 0 2px; }
/* The clearest words first: an icon alone says least for Organize. */
@container (min-width: 560px) {
  .tool.word-1 { gap: 5px; padding: 0 6px; }
  .tool.word-1 .label { display: inline; }
}
@container (min-width: 775px) {
  .tool.word-2 { gap: 5px; padding: 0 6px; }
  .tool.word-2 .label { display: inline; }
}
#organize .chevron { width: 14px; height: 14px; margin-left: -2px; }
body.side-closed #toggleSide .icon { transform: scaleX(-1); }
@container (max-width: 600px) {
  #topbar .tool { min-width: 32px; padding: 0 3px; }
  #topbar .divider { display: none; }
}
@media (max-width: 900px) { #topbar { gap: 2px; } }
#deleteSong:hover, #deleteFile:hover { color: var(--danger); }
#transport { border-top: 1px solid var(--line); }
.tool { min-width: 36px; height: 36px; padding: 0 8px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600; }
.tool:hover { background: var(--hover); }
.tool:disabled { opacity: .35; cursor: default; background: none; }
.tool.on { background: var(--accent); color: var(--paper); }
.group { display: inline-flex; align-items: center; }
.glyph { font-size: 21px; font-weight: 700; line-height: 1; }
.glyph.small { font-size: 14px; }
.key-tool { font-size: 15px; font-weight: 700; color: var(--chord); gap: 5px; white-space: nowrap; padding: 0 12px; border: 1px solid var(--line); }
.key-tool small { font-size: 12px; font-weight: 600; color: var(--muted); }
.key-tool.on { color: var(--paper); border-color: var(--accent); }
.key-tool.on small { color: inherit; }
#versionBar { display: flex; align-items: flex-start; gap: 8px; padding: 6px 10px; flex: none; background: var(--side); border-bottom: 1px solid var(--line); max-height: 112px; overflow-y: auto; z-index: 2; }
#versions { display: flex; flex-wrap: wrap; gap: 6px; flex: 0 1 auto; min-width: 0; }
#favourite { flex: none; gap: 6px; padding: 0 10px; color: var(--muted); }
#favourite.set { color: var(--chord); }
#deleteFile, #splitVersion { flex: none; gap: 6px; padding: 0 10px; color: var(--muted); }
#splitVersion:hover { color: var(--ink); }
#favourite .label, #deleteFile .label, #splitVersion .label { display: inline; max-width: none; }
@media (max-width: 600px) { #favourite .label, #deleteFile .label, #splitVersion .label { display: none; } }
#versions button { min-height: 36px; min-width: 44px; padding: 0 14px; border-radius: 8px; background: var(--hover); font-size: 15px; font-weight: 600; white-space: nowrap; }
#versions button:hover { background: var(--line); }
#versions button[aria-pressed="true"] { background: var(--accent); color: var(--paper); }
body.no-song #versionBar { display: none; }
.play { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 15px 0 11px; border-radius: 9px; background: var(--accent); color: var(--paper); font-weight: 700; }
.play.waiting { opacity: .75; }
.play:disabled { opacity: .4; cursor: default; }
output { min-width: 46px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.divider { width: 1px; height: 22px; background: var(--line); margin: 0 6px; }
#metro.beat { color: var(--accent); }
#metro.beat.accent { background: var(--accent); color: var(--paper); }
.set-nav { display: flex; align-items: center; gap: 2px; min-width: 0; }
.set-info { min-width: 0; max-width: 300px; font-size: 13px; line-height: 1.25; text-align: center; }
.set-info b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-info span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Song */
#stage { flex: 1; overflow-y: auto; scrollbar-gutter: stable; min-height: 0; background: var(--paper); container-type: size; overflow-anchor: none; }
#sheet { padding: 22px clamp(18px, 4vw, 56px) 36px; min-height: 100%; }
#progress { height: 2px; flex: none; background: transparent; }
#progress i { display: block; height: 100%; width: 0; background: var(--accent); }

.song-head { margin-bottom: calc(var(--fs) * .8); break-inside: avoid; }
.song-head h1 { margin: 0; font-size: calc(var(--fs) * 1.3); line-height: 1.15; font-weight: 750; letter-spacing: -.01em; }
.byline { font-size: max(14px, calc(var(--fs) * .72)); color: var(--muted); margin-top: 2px; }
.facts { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; font-size: max(14px, calc(var(--fs) * .56)); color: var(--muted); }
.facts b { color: var(--ink); font-weight: 650; }
.facts .sounding b { color: var(--chord); }
.flow { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.flow button { padding: 2px 9px; border-radius: 6px; font-size: 14px; font-weight: 700; background: var(--chorus); border: 1px solid var(--line); }
.flow button:disabled { opacity: .55; cursor: default; }
.body { font-size: var(--fs); line-height: 1.34; column-gap: 2.2em; column-rule: 1px solid var(--line); }
.part { margin: 0 0 1em; break-inside: avoid; }
.part h3 { margin: 0 0 .15em; font-size: .86em; font-weight: 750; }
.part.chorus { background: var(--chorus); border-left: 3px solid var(--accent); padding: .35em .6em; margin-left: -.6em; border-radius: 0 6px 6px 0; }
.line { padding-left: 1em; text-indent: -1em; overflow-wrap: anywhere; }
.line.sung, .line.chords-only { padding-left: 0; text-indent: 0; }
.line.sung + .line:not(.sung) { margin-top: .08em; }
.word { display: inline-block; white-space: nowrap; }
.seg { display: inline-block; vertical-align: bottom; }
.seg .ch { display: block; min-height: 1.2em; padding-right: .3em; line-height: 1.2; color: var(--chord); font-weight: 700; font-size: .84em; white-space: pre; }
.seg .ly { display: block; white-space: pre; }
.seg .bar { font-style: normal; font-weight: 400; color: var(--muted); padding: 0 .22em; }
.seg.solo { margin-right: .45em; }
.chords-only .ly { display: none; }
.chords-only .word { white-space: normal; max-width: 100%; }
.chords-only .seg { max-width: 100%; }
.chords-only .seg .ch { white-space: normal; }
.note { color: var(--muted); font-style: italic; font-size: .84em; }
.tab { margin: .3em 0 .6em; font: .68em/1.3 var(--mono); overflow: hidden; }

.paper { --zoom: 1; }
.paper .page { display: block; width: var(--page-width, 100%); max-width: 100%; margin: 0 auto 14px; filter: var(--sheet-filter); box-shadow: 0 1px 6px rgb(0 0 0 / .25); background: #fff; height: auto; }
.paper.fit { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.paper.fit .page { width: auto; max-width: 100%; height: calc(100cqh - 58px); margin: 0; }
.notation { background: #fff; border-radius: 4px; padding: 10px; filter: var(--sheet-filter); }
#sheet.bare { padding: 14px; }
.message { max-width: 520px; margin: 12vh auto; text-align: center; color: var(--muted); font-size: 17px; }
.message h2 { color: var(--ink); margin: 0 0 8px; }
.message code { font: 14px var(--mono); }

body.no-song .edit-hide, body.no-song #edit, body.no-song #transport, body.no-song #progress { display: none; }

.tag-filter { display: flex; flex-wrap: wrap; gap: 4px; max-height: 92px; overflow-y: auto; }
.tag-grid { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 10px; }
.tag-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--hover); color: var(--ink); }
.tag-chip small { font-size: 11px; font-weight: 500; opacity: .65; }
.tag-chip.on { background: var(--accent); color: var(--paper); }
.tag-chip.action { background: none; color: var(--chord); }
.song-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.version-tabs { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 4px; margin-top: 5px; }
.version-tab { display: grid; place-items: center; min-width: 28px; height: 24px; padding: 0 4px; border-radius: 6px 6px 0 0; border-bottom: 2px solid var(--line); background: var(--hover); color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; }
.version-tab:hover { color: var(--ink); border-bottom-color: var(--accent); }
.version-tab.on { background: var(--accent); border-bottom-color: var(--accent); color: var(--paper); }
.row.current .version-tab { background: rgb(0 0 0 / .18); border-bottom-color: transparent; color: inherit; }
.row.current .version-more { color: inherit; }
.row.current .version-tab.on { background: var(--paper); color: var(--accent); }
.version-more { margin-left: 2px; font-size: 13px; font-weight: 600; color: var(--muted); }

/* Fingers need more room than a mouse: 44 points is Apple's minimum touch target. */
@media (any-pointer: coarse) {
  #versions button { min-height: 44px; font-size: 16px; padding: 0 16px; }
  .version-tabs { gap: 6px; margin-top: 7px; }
  .version-tab { min-width: 44px; height: 44px; font-size: 16px; border-radius: 8px; }
  .version-more { font-size: 15px; }
  #versionBar { max-height: 130px; }
}

.tag-line { display: flex; align-items: center; gap: 8px; padding-left: 4px; }
.tag-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.tag-line small { color: var(--muted); white-space: nowrap; }

.folder-bar { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.folder-bar .icon { width: 18px; height: 18px; }
#folderView, #sortBy { flex: 1; min-width: 0; height: 34px; padding: 0 8px; font: 600 14px var(--font); color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: 8px; }
#manageFolders { white-space: nowrap; }
.pop .choice.chosen { background: var(--hover); font-weight: 700; }
.pop .choice.chosen::after { content: " ✓"; color: var(--accent); }
.pop .folder-form { padding: 10px 0 0; }
.folder-name { flex: 1; min-width: 0; font: 600 14px var(--font); color: var(--ink); background: none; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; }
.folder-name:hover, .folder-name:focus { border-color: var(--line); background: var(--paper); outline: 0; }
@media (any-pointer: coarse) { #folderView, #sortBy { height: 44px; font-size: 16px; } }

/* Confirmation */
#confirm { width: min(400px, calc(100vw - 32px)); padding: 24px; border-radius: 18px; text-align: center; box-shadow: 0 24px 70px rgb(0 0 0 / .4); }
#confirm::backdrop { background: rgb(0 0 0 / .45); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
#confirm[open] { animation: confirm-in .14s ease-out; }
@keyframes confirm-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.confirm-icon { width: 48px; height: 48px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%; color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.confirm-icon .icon { width: 24px; height: 24px; }
#confirm h2 { margin: 0 0 6px; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
#confirm p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.45; }
.confirm-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
.confirm-buttons.single { grid-template-columns: 1fr; }
.confirm-icon.alert { color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.confirm-buttons button { min-height: 44px; border-radius: 10px; font-weight: 700; font-size: 15px; }
.confirm-cancel { background: var(--hover); }
.confirm-cancel:hover { background: var(--line); }
.confirm-ok { background: var(--accent); color: var(--paper); }
.confirm-ok.danger-fill { background: var(--danger); }
.confirm-ok:hover { filter: brightness(1.08); }
.confirm-buttons button:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { #confirm[open] { animation: none; } }

/* Editor: source on the left, the result on the right. */
body.editing #transport, body.editing #progress, body.editing .edit-hide { display: none; }
body.editing #edit { background: var(--accent); color: var(--paper); }
body.editing #stage { overflow: hidden; }
#sheet.editing-sheet { padding: 0; height: 100%; }
.editor { height: 100%; display: grid; grid-template: auto minmax(0, 1fr) / minmax(0, 1fr) minmax(0, 1fr); }
.edit-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); min-width: 0; }
.edit-name { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-message { font-size: 13px; font-weight: 600; color: var(--accent); }
.edit-action { height: 34px; padding: 0 14px; border-radius: 8px; font-weight: 600; background: var(--side); flex: none; }
.edit-action:hover { background: var(--hover); }
.edit-action.primary { background: var(--accent); color: var(--paper); }
.source { width: 100%; height: 100%; resize: none; border: 0; border-right: 1px solid var(--line); outline: 0; padding: 16px 18px; background: var(--side); color: var(--ink); font: 14px/1.5 var(--mono); tab-size: 4; }
.preview { overflow-y: auto; padding: 16px 22px; }
.preview h2 { margin: 0 0 .7em; font-size: 1.3em; }

/* Sign-in */
#auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--side); overflow-y: auto; position: fixed; inset: 0; }
.auth-card { width: min(400px, 100%); background: var(--raised); border: 1px solid var(--line); border-radius: 16px; padding: 28px 26px; box-shadow: 0 12px 40px rgb(0 0 0 / .14); }
.auth-card h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.01em; }
.auth-card .lead { margin: 0 0 18px; color: var(--muted); }
.field { display: block; margin-bottom: 12px; font-size: 13.5px; font-weight: 600; }
.field input { display: block; width: 100%; margin-top: 4px; padding: 10px 11px; font: 16px var(--font); color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 9px; }
.hint { display: block; margin-top: 4px; font-weight: 400; color: var(--muted); font-size: 12.5px; }
.notice { margin: 0 0 14px; padding: 9px 11px; border-radius: 9px; background: var(--chorus); font-size: 14px; }
.notice.error { color: var(--accent); font-weight: 600; }
.submit { width: 100%; height: 42px; border-radius: 10px; background: var(--accent); color: var(--paper); font-weight: 700; }
.submit:disabled { opacity: .55; cursor: default; }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; font-size: 14px; }
.auth-links button { color: var(--chord); padding: 0; font-weight: 600; }
.auth-privacy { margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.auth-privacy a { color: var(--chord); font-weight: 600; }

/* Account and administration */
#panel { width: min(860px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head h2 { margin: 0; }
.panel-section { padding: 14px 0; border-top: 1px solid var(--line); }
.panel-section h3 { margin: 0 0 8px; font-size: 14.5px; }
.danger { color: var(--accent); font-weight: 600; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--muted); }
.stats b { color: var(--ink); }
.table-wrap { overflow-x: auto; }
.users { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.users th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 4px 8px; }
.users td { padding: 6px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
.users td.mail { white-space: normal; word-break: break-all; min-width: 170px; }
.tag { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--side); color: var(--muted); }
.tag.admin { background: var(--accent); color: var(--paper); }
.tag.off { color: var(--accent); }
.row-action { font-size: 12.5px; font-weight: 600; color: var(--chord); padding: 3px 6px; border-radius: 6px; }
.row-action:hover { background: var(--hover); }
.row-action.danger { color: var(--danger); }
.trash-head { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 14px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); }
.trash-head .row-action { padding-left: 0; }
.trash-row { display: flex; align-items: center; gap: 2px; padding: 8px 8px 8px 14px; min-height: 46px; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.trash-row .text { flex: 1; min-width: 0; }
.trash-row .name { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trash-row .sub { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (any-pointer: coarse) { .trash-row .row-action { min-height: 44px; padding: 0 10px; } }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 6px 0; }
.setting input[type="number"] { width: 100px; padding: 6px 8px; font: inherit; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 8px; }

/* Popover and dialog */
.pop { position: fixed; z-index: 10; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 34px rgb(0 0 0 / .32); padding: 12px; width: 280px; max-width: calc(100vw - 24px); }
.pop h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); font-weight: 700; }
.key-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 12px; }
.key-grid button { height: 40px; border-radius: 8px; font-weight: 700; background: var(--side); }
.key-grid button:hover { background: var(--hover); }
.key-grid button.on { background: var(--accent); color: var(--paper); }
.key-grid button.original:not(.on) { box-shadow: inset 0 0 0 2px var(--accent); }
.stepper { display: flex; align-items: center; justify-content: space-between; padding: 3px 0; }
.stepper .group output { min-width: 36px; }
.stepper + .stepper { border-top: 1px solid var(--line); }
.wide { width: 100%; padding: 8px; margin-top: 10px; border-radius: 8px; background: var(--side); font-weight: 600; }
.wide:hover { background: var(--hover); }
.pop .choice { display: block; width: 100%; text-align: left; padding: 7px 8px; border-radius: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop .choice:hover { background: var(--hover); }
.pop .choices { max-height: 260px; overflow-y: auto; }
.pop-note { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.details { display: grid; gap: 8px; width: 280px; max-width: 100%; }
.details .field { display: grid; gap: 3px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.details input { font: 15px var(--font); color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.details button { justify-self: end; margin-top: 2px; }
.pop .menu-item { display: flex; align-items: center; gap: 9px; min-height: 36px; width: 280px; max-width: 100%; }
.pop .menu-item span { flex: none; }
.pop .menu-item small { flex: 1; min-width: 0; text-align: right; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop .menu-item .icon { flex: none; width: 18px; height: 18px; }
.pop .menu-item:disabled { opacity: .4; cursor: default; background: none; }
.pop > input { width: 100%; font: inherit; color: var(--ink); background: var(--raised); border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; margin-bottom: 4px; }
.pop .new-set { padding: 0 0 10px; }
dialog { background: var(--raised); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; padding: 18px 22px; width: min(440px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog h2 { margin: 0 0 10px; font-size: 18px; }
dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 16px; margin: 0; }
dt { font-weight: 700; white-space: nowrap; }
dd { margin: 0; color: var(--muted); }

/* Performance mode: only the song, with bars that slide in on demand. */
body.perform #sidebar { display: none; }
body.perform #topbar, body.perform #transport { position: absolute; left: 0; right: 0; transition: transform .18s ease; }
body.perform #topbar { top: 0; transform: translateY(-101%); }
body.perform #transport { bottom: 0; transform: translateY(101%); }
body.perform.chrome #topbar, body.perform.chrome #transport { transform: none; }
body.perform #versionBar { display: none; }
body.perform.chrome #versionBar:not([hidden]) { display: flex; position: absolute; top: 52px; left: 0; right: 0; }

@media (max-width: 860px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .preview { display: none; }
  #sidebar { position: fixed; inset: 0 auto 0 0; z-index: 5; width: min(320px, 86vw); box-shadow: 8px 0 30px rgb(0 0 0 / .3); }
  .play span, .set-info, .divider { display: none; }
}
@media (max-width: 600px) {
  #transport, #topbar { overflow-x: auto; }
  #sheet { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  body.perform #topbar, body.perform #transport { transition: none; }
}
