:root {
    --bg: #161310;
    --bg-deep: #0f0d0b;
    --bg-2: #1e1a16;
    --ink: #f3ece1;
    --muted: #b5a897;
    --brass: #e0b15a;
    --brass-2: #c48a2d;
    --paper: #f6efe2;
    --paper-2: #efe4cf;
    --rule: rgba(92, 64, 38, 0.16);
    --chord: #9a3412;
    --chorus: #7f1d1d;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.38);
    --bar: rgba(22, 19, 16, 0.92);
    --line: rgba(224, 177, 90, 0.14);
    --line-soft: rgba(243, 236, 225, 0.1);
    --input: #12100e;
    --card: #241f1a;
    --card-2: #1b1714;
    --star-bg: rgba(22, 19, 16, 0.72);
    --flash-fg: #f3d7a0;
    --link-hover: #f3d7a0;
    --brand: #f6efe2;
    --ghost-fg: #f6efe2;
    --ghost-line: rgba(243, 236, 225, 0.18);
    --accent-fill: rgba(224, 177, 90, 0.12);
    --accent-line: rgba(224, 177, 90, 0.38);
    --glow: rgba(224, 177, 90, 0.16);
    --sheet-ink: #1c140e;
    --lyric: #21170f;
    --comment-fg: #6b4f35;
    --diag-bg: #1a1613;
    --diag-line: #c4b49a;
    --diag-nut: #e0b15a;
    --diag-dot: #f6efe2;
    --diag-fg: #1c140e;
    --diag-mute: #9a3412;
    --theme: #161310;
    --font: "Figtree", system-ui, sans-serif;
    --serif: "Fraunces", Georgia, serif;
    --mono: "JetBrains Mono", ui-monospace, monospace;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
    color-scheme: dark;
}

html[data-theme="light"] {
    --bg: #f6f3ec;
    --bg-deep: #ebe4d6;
    --bg-2: #ffffff;
    --ink: #1c1915;
    --muted: #6b5e4e;
    --brass: #a16207;
    --brass-2: #854d0e;
    --paper: #fffdf8;
    --paper-2: #f4ecde;
    --rule: rgba(92, 64, 38, 0.12);
    --shadow: 0 14px 36px rgba(28, 25, 21, 0.1);
    --bar: rgba(255, 253, 248, 0.94);
    --line: rgba(28, 25, 21, 0.1);
    --line-soft: rgba(28, 25, 21, 0.08);
    --input: #ffffff;
    --card: #ffffff;
    --card-2: #f8f4ec;
    --star-bg: rgba(255, 255, 255, 0.92);
    --flash-fg: #854d0e;
    --link-hover: #854d0e;
    --brand: #1c1915;
    --ghost-fg: #1c1915;
    --ghost-line: rgba(28, 25, 21, 0.16);
    --accent-fill: rgba(161, 98, 7, 0.1);
    --accent-line: rgba(161, 98, 7, 0.28);
    --glow: rgba(161, 98, 7, 0.1);
    --diag-bg: #ffffff;
    --diag-line: #8a7a68;
    --diag-nut: #a16207;
    --diag-dot: #1c1915;
    --diag-fg: #fffdf8;
    --diag-mute: #9a3412;
    --theme: #f6f3ec;
    color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: clip;
}

body {
    font-family: var(--font);
    background:
        radial-gradient(1200px 500px at 50% -10%, var(--glow), transparent 55%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
    color: var(--ink);
    line-height: 1.45;
}

a { color: var(--brass); text-decoration: none; }
@media (hover: hover) and (pointer: fine) {
    a:hover { color: var(--link-hover); }
}

button, a.btn, .card, input, textarea, select {
    touch-action: manipulation;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: max(12px, var(--safe-t)) max(16px, var(--safe-r)) 12px max(16px, var(--safe-l));
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bar);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}

.brand {
    font-family: var(--serif);
    font-size: 1.35rem;
    color: var(--brand) !important;
    letter-spacing: 0.02em;
    line-height: 1;
}

.topbar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
.topbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: 40px;
    min-height: 40px;
    min-width: 40px;
    padding: 0 14px;
    margin: 0;
    border: 1px solid var(--accent-line);
    background: var(--accent-fill);
    color: var(--brass);
    font: inherit;
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1;
    border-radius: 12px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    touch-action: manipulation;
}
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border: 1px solid var(--accent-line);
    background: var(--accent-fill);
    color: var(--brass);
    border-radius: 999px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    touch-action: manipulation;
}
.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.theme-icon-moon { display: none; }
html[data-theme="light"] .theme-icon-sun { display: none; }
html[data-theme="light"] .theme-icon-moon {
    display: block;
    fill: currentColor;
    stroke: none;
}
@media (hover: hover) and (pointer: fine) {
    .theme-toggle:hover,
    .topbar-btn:hover {
        background: var(--accent-line);
        border-color: var(--brass);
        color: var(--brass);
    }
}
.nav-toggle,
.nav-drawer-head,
.nav-scrim { display: none; }

.topnav { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-left: auto; }
.topnav a {
    color: var(--muted);
    font-weight: 600;
    font-size: 0.95rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}
@media (hover: hover) and (pointer: fine) {
    .topnav a:hover { color: var(--brand); }
}

.wrap { width: min(980px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 80px; }

.hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: end;
    margin-bottom: 22px;
}
.hero h1 {
    font-family: var(--serif);
    font-size: clamp(1.8rem, 6vw, 3.1rem);
    margin: 0 0 6px;
    font-weight: 650;
}
.hero p { margin: 0; color: var(--muted); }

.install-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: -8px 0 22px;
    padding: 12px 14px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
}
.install-copy {
    flex: 1 1 auto;
    min-width: 0;
}
.install-copy strong {
    display: block;
    font-size: 0.95rem;
}
.install-copy p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}
#install-dismiss {
    min-width: 44px;
    padding-left: 10px;
    padding-right: 10px;
}
@media (display-mode: standalone) {
    .install-banner { display: none !important; }
    .topbar { padding-top: max(12px, var(--safe-t)); }
}

.search {
    width: 100%;
    margin: 8px 0 22px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--input);
    color: var(--ink);
    font: inherit;
    font-size: 16px;
}
.search:focus { outline: 2px solid var(--brass); }

.chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 14px;
}
.chip {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    font-weight: 700;
    font-size: 0.92rem;
}
.chip.is-on {
    background: var(--brass);
    border-color: var(--brass);
    color: #2a1d08;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
    gap: 14px;
}

.card-wrap {
    position: relative;
}
.star {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 3;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: var(--star-bg);
    color: var(--muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}
.star.is-on { color: var(--brass); }
.star-lg {
    position: static;
    width: auto;
    min-width: 44px;
    padding: 0 14px;
    background: rgba(224, 177, 90, 0.12);
    color: var(--muted);
    font: inherit;
    font-weight: 700;
    font-size: 1.05rem;
}
.star-lg.is-on { color: var(--brass); background: rgba(224, 177, 90, 0.22); }

.card {
    display: block;
    position: relative;
    padding: 18px 48px 16px 18px;
    border-radius: 16px;
    background: linear-gradient(180deg, var(--card), var(--card-2));
    border: 1px solid var(--line);
    color: inherit;
    min-height: 118px;
    transition: transform .15s ease, border-color .15s ease;
}
a.card { color: inherit; }
.card-hit {
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
}
.card h2,
.card .meta,
.card .key {
    position: relative;
    z-index: 0;
}
.card-artist {
    position: relative;
    z-index: 2;
    display: inline-block;
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 600;
    margin: 0 0 2px;
}
@media (hover: hover) and (pointer: fine) {
    .card:hover {
        transform: translateY(-2px);
        border-color: rgba(224, 177, 90, 0.4);
        color: inherit;
    }
    .card-artist:hover { color: var(--brass); }
    a.card-hit:hover { color: inherit; }
}
.card h2 {
    font-family: var(--serif);
    font-size: 1.28rem;
    margin: 0 0 6px;
    color: var(--paper);
}
.card .meta { color: var(--muted); font-size: 0.92rem; }
.card .key {
    display: inline-block;
    margin-top: 12px;
    margin-right: 6px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(224, 177, 90, 0.14);
    color: var(--brass);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
}
.card .key-capo {
    background: var(--brass);
    color: #2a1d08;
}

.empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed rgba(224, 177, 90, 0.28);
    border-radius: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    border-radius: 12px;
    padding: 10px 14px;
    min-height: 44px;
    background: var(--brass);
    color: #2a1d08;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
    .btn:hover { filter: brightness(1.05); color: #2a1d08; }
}
.btn.ghost {
    background: transparent;
    color: var(--ghost-fg);
    border: 1px solid var(--ghost-line);
}
.btn.ghost.is-on {
    background: var(--brass);
    color: #2a1d08;
    border-color: var(--brass);
}
.btn.danger { background: #9a3412; color: #fff; }
.btn.icon { min-width: 44px; padding-left: 11px; padding-right: 11px; }
.btn:disabled { opacity: 0.45; cursor: default; }

.flash {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
    background: rgba(224, 177, 90, 0.14);
    color: var(--flash-fg);
}
.flash.bad { background: rgba(154, 52, 18, 0.25); color: #fecaca; }

.login-card, .form-card {
    width: min(560px, 100%);
    margin: 40px auto 0;
    padding: 28px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 18px;
}
.form-card { width: min(820px, 100%); }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
input[type="text"], input[type="password"], input[type="search"], textarea, select {
    width: 100%;
    font: inherit;
    font-size: 16px;
    padding: 12px 12px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--input);
    color: var(--ink);
}
textarea {
    min-height: 320px;
    font-family: var(--mono);
    font-size: 16px;
    line-height: 1.5;
    resize: vertical;
}
code {
    font-family: var(--mono);
    font-size: 0.88em;
    background: rgba(224, 177, 90, 0.12);
    padding: 1px 6px;
    border-radius: 6px;
    word-break: break-word;
}
.row-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

.admin-h {
    font-family: var(--serif);
    font-size: 1.4rem;
    margin: 28px 0 12px;
}

.hp {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.notes {
    margin-top: 36px;
    padding-top: 8px;
    scroll-margin-top: 72px;
}
.notes h2 {
    font-family: var(--serif);
    font-size: 1.6rem;
    margin: 0 0 6px;
}
.notes-lead { margin: 0 0 16px; color: var(--muted); }

.note-form {
    margin: 0 0 22px;
    padding: 16px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 16px;
}
.note-form textarea {
    min-height: 110px;
    font-family: var(--font);
}

.kind-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}
.kind-pill {
    margin: 0;
    cursor: pointer;
}
.kind-pill input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.kind-pill span {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--muted);
    font-weight: 700;
    font-size: 0.92rem;
}
.kind-pill input:checked + span {
    background: var(--brass);
    border-color: var(--brass);
    color: #2a1d08;
}
.kind-pill input:focus-visible + span {
    outline: 2px solid var(--brass);
    outline-offset: 2px;
}

.note-list { display: flex; flex-direction: column; gap: 10px; }
.note {
    padding: 14px 16px;
    background: var(--bg-2);
    border: 1px solid var(--line);
    border-radius: 14px;
}
.note p {
    margin: 8px 0 0;
    overflow-wrap: anywhere;
}
.note-head {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    color: var(--muted);
    font-size: 0.9rem;
}
.note-head strong { color: var(--ink); }
.note-kind {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(224, 177, 90, 0.14);
    color: var(--brass);
}
.kind-suggestion {
    background: rgba(154, 52, 18, 0.18);
    color: #fecaca;
}
html[data-theme="light"] .kind-suggestion {
    background: rgba(154, 52, 18, 0.1);
    color: #9a3412;
}
.note-del { margin-left: auto; }
.note-del .btn { min-height: 36px; padding: 0 10px; font-size: 0.85rem; }
.btn.danger-ghost {
    color: #fecaca;
    border-color: rgba(254, 202, 202, 0.28);
}
html[data-theme="light"] .btn.danger-ghost {
    color: #9a3412;
    border-color: rgba(154, 52, 18, 0.28);
}
.admin-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    padding: 14px 16px;
    background: var(--bg-2);
    border-radius: 14px;
    border: 1px solid var(--line);
}
.admin-item h2 { margin: 0; font-size: 1.05rem; font-family: var(--serif); }
.admin-item form { display: inline; }

/* Song page */
.song-page .wrap { width: min(860px, calc(100% - 20px)); padding-top: 12px; }

.player {
    position: sticky;
    top: 56px;
    z-index: 15;
    margin-bottom: 16px;
    background: var(--bar);
    border: 1px solid var(--line);
    border-radius: 16px;
    backdrop-filter: blur(12px);
}
.player-bar, .player-extra {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px;
}
.player-extra {
    padding-top: 0;
    border-top: 1px solid var(--line-soft);
}
#btn-more { display: none; }
.player .group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 8px;
    border-right: 1px solid var(--line-soft);
}
.player .group:last-child { border-right: 0; padding-right: 0; }
.player .label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0 4px;
}
.player .value {
    min-width: 2.4rem;
    text-align: center;
    font-weight: 800;
    color: var(--brass);
}
#btn-capo {
    white-space: nowrap;
    padding-left: 10px;
    padding-right: 10px;
}
.speed {
    width: 92px;
    accent-color: var(--brass);
    min-height: 32px;
}

.song-head { margin: 8px 0 18px; }
.song-head h1 {
    font-family: var(--serif);
    font-size: clamp(1.5rem, 6vw, 2.7rem);
    margin: 0;
}
.song-head .meta { color: var(--muted); margin-top: 4px; }
.capo-mark {
    color: var(--brass);
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.capo-banner {
    font-family: var(--font);
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.92rem;
    color: #2a1d08;
    background: var(--brass);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 0 0 14px;
    text-align: center;
}
.capo-banner.is-off {
    background: transparent;
    color: var(--muted);
    border: 1px dashed var(--ghost-line);
    text-transform: none;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.song-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.listen-frame {
    margin: 0 0 16px;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: #000;
    max-width: 560px;
}
.listen-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

#diagrams-host[hidden] { display: none !important; }

.diagrams {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 6px 2px 14px;
    margin-bottom: 8px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
}
.diagram {
    flex: 0 0 auto;
    width: 92px;
    background: var(--diag-bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 6px 6px;
    text-align: center;
    cursor: pointer;
    scroll-snap-align: start;
}
.diagram.active { border-color: var(--brass); box-shadow: 0 0 0 1px var(--brass); }
.diagram .name {
    font-family: var(--mono);
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--brass);
    margin-bottom: 4px;
}
.diagram .alt {
    font-size: 0.62rem;
    color: var(--muted);
    font-weight: 600;
    line-height: 1.15;
    margin: -2px 0 4px;
}
.diagram svg { width: 80px; height: 96px; display: block; margin: 0 auto; }
.diagram .missing { color: var(--muted); font-size: 0.75rem; padding: 28px 4px; }

.sheet {
    background:
        linear-gradient(180deg, rgba(255,255,255,0.35), transparent 28%),
        repeating-linear-gradient(
            180deg,
            transparent,
            transparent 31px,
            var(--rule) 31px,
            var(--rule) 32px
        ),
        linear-gradient(180deg, var(--paper), var(--paper-2));
    color: var(--sheet-ink);
    border-radius: 8px 12px 14px 10px;
    box-shadow: var(--shadow);
    padding: 28px 28px 48px;
    min-height: 60vh;
    --chord: #9a3412;
    overflow-x: auto;
}

.song-body {
    font-size: var(--lyric-size, 1.12rem);
    font-family: var(--serif);
    font-optical-sizing: auto;
}

.lyric-line {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    margin: 0 0 0.08em;
    line-height: 1.25;
}
.lyric-line.empty {
    min-height: 0.55em;
    margin: 0.35em 0 0.15em;
}
.lyric-line.no-chords { min-height: 1.35em; }
.lyric-line.no-chords .chord { display: none; }
.lyric-line.chords-only { margin: 0.05em 0 0.2em; }
.lyric-line.chords-only .lyric { height: 0; overflow: hidden; }

.chunk {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    margin-right: 0.15em;
}
.chunk .chord {
    font-family: var(--mono);
    font-size: 0.78em;
    font-weight: 700;
    color: var(--chord);
    line-height: 1.1;
    min-height: 1em;
    white-space: nowrap;
    cursor: pointer;
    letter-spacing: -0.02em;
}
.chunk .chord:not([data-chord]) {
    min-height: 1em;
    cursor: default;
}
.chunk .chord.is-on { background: #fde68a; border-radius: 4px; padding: 0 3px; }
.chunk .lyric {
    white-space: pre;
    color: var(--lyric);
    line-height: 1.3;
}

.verse + .verse,
.verse + .chorus,
.chorus + .verse,
.chorus + .chorus {
    margin-top: 0.55em;
}
.chorus {
    margin: 0.45em 0;
    padding: 0.1em 0 0.1em 12px;
    border-left: 3px solid #b45309;
}
.comment {
    font-family: var(--font);
    font-style: italic;
    color: var(--comment-fg);
    margin: 0.55em 0 0.12em;
    font-size: 0.92em;
}

.preview-box {
    margin-top: 18px;
    padding: 8px;
    background: var(--input);
    border-radius: 14px;
    overflow-x: auto;
}
.preview-box .sheet { min-height: 0; padding: 18px; }

.hint { color: var(--muted); font-size: 0.85rem; margin-top: 10px; }

.playing .player { box-shadow: 0 0 0 1px var(--brass); }

html[data-theme="light"] .sheet {
    border: 1px solid var(--line);
    box-shadow: 0 8px 24px rgba(28, 25, 21, 0.06);
}
html[data-theme="light"] .card h2 { color: var(--ink); }

@media (max-width: 720px) {
    .nav-toggle { display: inline-flex; }
    .topbar {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        padding: max(8px, var(--safe-t)) max(10px, var(--safe-r)) 8px max(10px, var(--safe-l));
        z-index: 61;
    }
    .brand {
        margin-right: auto;
        font-size: 1.12rem;
    }
    .topbar-actions { gap: 6px; }
    .theme-toggle {
        width: 34px;
        height: 34px;
    }
    .theme-toggle svg { width: 16px; height: 16px; }
    .topbar-btn {
        height: 34px;
        min-height: 34px;
        padding: 0 11px;
        font-size: 0.8rem;
        border-radius: 10px;
    }
    .topnav {
        display: flex;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(300px, 84vw);
        margin: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        padding: max(12px, var(--safe-t)) max(14px, var(--safe-r)) max(20px, var(--safe-b)) 14px;
        background: var(--bg-2);
        border-left: 1px solid var(--line);
        box-shadow: -18px 0 40px rgba(0, 0, 0, 0.35);
        z-index: 62;
        transform: translateX(110%);
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.28s ease, visibility 0.28s;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .nav-open .topnav {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }
    .nav-drawer-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        margin-bottom: 8px;
        padding: 4px 2px 10px;
        border-bottom: 1px solid var(--line-soft);
    }
    .nav-drawer-head strong {
        font-family: var(--serif);
        font-size: 1.15rem;
        font-weight: 650;
        color: var(--brand);
    }
    .nav-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        padding: 0;
        border: 1px solid var(--accent-line);
        background: var(--accent-fill);
        color: var(--brass);
        border-radius: 999px;
        cursor: pointer;
        appearance: none;
        -webkit-appearance: none;
    }
    .nav-close svg {
        width: 16px;
        height: 16px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
    }
    .nav-scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 55;
        border: 0;
        padding: 0;
        margin: 0;
        background: rgba(8, 6, 5, 0.52);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity 0.28s ease, visibility 0.28s;
        cursor: pointer;
        appearance: none;
        -webkit-appearance: none;
    }
    .nav-open .nav-scrim {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    .nav-open { overflow: hidden; }
    @media (prefers-reduced-motion: reduce) {
        .topnav, .nav-scrim { transition: none; }
    }
    .topnav a {
        min-height: 44px;
        padding: 10px 12px;
        font-size: 1rem;
        color: var(--ink);
        border-top: 0;
        border-radius: 10px;
    }
    .topnav a:active { background: var(--accent-fill); color: var(--brass); }

    .wrap { width: calc(100% - 20px); padding: 12px 0 28px; }
    .hero {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-bottom: 12px;
    }
    .hero h1 { font-size: 1.5rem; margin: 0 0 2px; }
    .hero p { font-size: 0.82rem; }
    .hero .btn {
        width: auto;
        align-self: start;
        min-height: 34px;
        padding: 0 12px;
        font-size: 0.85rem;
    }

    .install-banner {
        gap: 8px;
        margin: -2px 0 12px;
        padding: 8px 10px;
        border-radius: 12px;
    }
    .install-copy strong { font-size: 0.85rem; }
    .install-copy p { font-size: 0.78rem; }
    #install-dismiss {
        min-width: 34px;
        min-height: 34px;
        padding: 0;
    }
    #install-btn { min-height: 34px; padding: 0 10px; font-size: 0.82rem; }

    .search {
        padding: 10px 12px;
        margin: 4px 0 12px;
        border-radius: 12px;
    }

    .chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 6px;
        margin: 0 0 8px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .chips::-webkit-scrollbar { display: none; }
    .chip {
        flex: 0 0 auto;
        min-height: 32px;
        padding: 0 11px;
        font-size: 0.8rem;
    }

    .grid { gap: 8px; }
    .card {
        padding: 12px 38px 11px 12px;
        min-height: 0;
        border-radius: 12px;
    }
    .card h2 { font-size: 1.05rem; margin: 0 0 2px; }
    .card .meta,
    .card-artist { font-size: 0.82rem; }
    .card .key {
        margin-top: 8px;
        font-size: 0.7rem;
        padding: 2px 7px;
    }
    .star {
        top: 4px;
        right: 4px;
        width: 34px;
        height: 34px;
        font-size: 1.05rem;
        border-radius: 10px;
    }

    .btn {
        min-height: 36px;
        padding: 7px 12px;
        font-size: 0.88rem;
        border-radius: 10px;
    }
    .btn.icon { min-width: 36px; }

    .login-card, .form-card {
        margin-top: 8px;
        padding: 14px 12px;
        border-radius: 12px;
    }
    textarea { min-height: 180px; }
    .row-actions .btn { flex: 1 1 calc(50% - 10px); }
    .admin-item .row-actions { width: 100%; }
    .admin-item .row-actions .btn { flex: 1 1 auto; }

    .notes { margin-top: 22px; }
    .notes h2 { font-size: 1.25rem; }
    .notes-lead { font-size: 0.85rem; margin-bottom: 12px; }
    .note-form { padding: 12px; }
    .kind-pill span {
        min-height: 32px;
        padding: 0 11px;
        font-size: 0.8rem;
    }
    .note { padding: 10px 12px; }

    .song-page .wrap {
        width: calc(100% - 10px);
        padding-top: 4px;
        padding-bottom: calc(64px + var(--safe-b));
    }

    .song-head { margin: 0 0 6px; }
    .song-head h1 { font-size: 1.12rem; }
    .song-head .meta { font-size: 0.78rem; margin-top: 1px; }
    .capo-banner {
        padding: 6px 8px;
        font-size: 0.7rem;
        margin: 0 0 8px;
        border-radius: 8px;
        letter-spacing: 0.03em;
    }
    .song-actions { margin-top: 6px; gap: 6px; }
    .song-actions .btn {
        min-height: 30px;
        padding: 0 8px;
        font-size: 0.75rem;
    }
    .star-lg {
        min-height: 30px;
        min-width: 30px;
        padding: 0 8px;
        font-size: 0.9rem;
    }
    .listen-frame { display: none; }

    .player {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        margin: 0;
        border-radius: 12px 12px 0 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
        z-index: 30;
        padding-bottom: var(--safe-b);
    }
    .player-bar {
        display: flex;
        flex-wrap: nowrap;
        gap: 5px;
        padding: 5px 8px;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
    }
    .player-bar::-webkit-scrollbar { display: none; }
    .player-bar > * {
        flex: 0 0 auto;
        white-space: nowrap;
    }
    .player-bar .group { border: 0; padding: 0; }
    .player .btn {
        min-height: 32px;
        padding: 0 8px;
        font-size: 0.78rem;
        border-radius: 9px;
    }
    .player .btn.icon {
        min-width: 32px;
        padding-left: 0;
        padding-right: 0;
    }
    .player .value {
        min-width: 1.8rem;
        font-size: 0.8rem;
    }
    .btn-scroll {
        width: auto;
        flex: 1 0 auto;
        min-width: 4.2rem;
    }
    #btn-more { display: inline-flex; }
    .player-extra {
        display: none;
        flex-wrap: wrap;
        gap: 6px;
        padding: 0 8px 8px;
        border-top: 0;
    }
    .player.is-open .player-extra {
        display: flex;
        border-top: 1px solid var(--line-soft);
        padding-top: 8px;
    }
    .player .group { border-right: 0; }

    #diagrams-host {
        position: static;
        margin: 0 0 6px;
        padding: 0;
        background: none;
    }
    .diagrams {
        gap: 6px;
        padding: 0 0 6px;
        margin-bottom: 0;
    }
    .diagram {
        width: 64px;
        padding: 4px 3px 3px;
        border-radius: 8px;
    }
    .diagram .name { font-size: 0.68rem; margin-bottom: 1px; }
    .diagram svg { width: 54px; height: 64px; }
    .diagram .missing { font-size: 0.62rem; padding: 10px 2px; }

    .sheet {
        padding: 8px 8px 14px;
        border-radius: 8px;
        min-height: 0;
        background: var(--paper);
        box-shadow: none;
    }
    .song-body {
        font-family: var(--font);
        font-size: var(--lyric-size, 1.12rem);
        font-weight: 500;
        letter-spacing: 0.01em;
    }
    .chunk .chord {
        font-size: 0.95em;
        font-weight: 800;
        letter-spacing: 0;
        color: #8a1f12;
    }
    .chunk .chord[data-chord] { padding: 0 1px; min-height: 1.05em; }
    .chunk .lyric {
        color: #16100b;
        line-height: 1.28;
        font-weight: 500;
    }
    .lyric-line { margin: 0 0 0.04em; }
    .lyric-line.no-chords { min-height: 1.28em; }
    .comment { margin: 0.35em 0 0.08em; font-size: 0.78em; }
    .hint { display: none; }
    .player-extra .speed {
        flex: 1 1 140px;
        width: auto;
        min-width: 120px;
        height: 24px;
        min-height: 24px;
    }
    .song-page:has(.player.is-open) .wrap {
        padding-bottom: calc(160px + var(--safe-b));
    }
}

@media (max-width: 720px) and (orientation: landscape) {
    #diagrams-host { position: static; }
    .song-head { margin: 4px 0 10px; }
    .diagram { width: 76px; }
    .diagram svg { width: 68px; height: 82px; }
}

@media print {
    body {
        background: #fff !important;
        color: #000;
    }
    .no-print, .topbar, .player, .hint, .nav-scrim { display: none !important; }
    .wrap { width: 100%; margin: 0; padding: 0; }
    .sheet {
        box-shadow: none;
        background: #fff;
        padding: 0;
        border-radius: 0;
    }
    .diagrams {
        flex-wrap: wrap;
        overflow: visible;
        page-break-inside: avoid;
    }
    .diagram {
        background: #fff;
        border: 1px solid #ddd;
    }
    .chunk .chord { color: #9a3412; }
    a { color: inherit; }
    .capo-banner {
        background: #fff !important;
        color: #000 !important;
        border: 2px solid #000;
        text-transform: uppercase;
    }
}
