/* Song viewer: chords sit above the lyric syllable they belong to. */
.song-sheet {
    --song-font-size: 1.15rem;
    font-size: var(--song-font-size);
    line-height: 1.35;
}
.song-line {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: .35em;
}
.song-seg {
    display: inline-flex;
    flex-direction: column;
}
.song-seg .chord {
    min-height: 1.35em;
    padding-right: .5em;
    font-family: var(--bs-font-monospace);
    font-size: .85em;
    font-weight: 700;
    color: var(--bs-danger);
    white-space: pre;
}
.song-seg .lyric {
    white-space: pre-wrap;
}
/* A chord at the end of a line has no text under it: keep a line's height so it stays level with the others. */
.song-seg .lyric:empty::after {
    content: "\200b";
}
/* A row of chords without lyrics (no chord slots on the line below): no empty lyric row under it, so the chords sit
   right above their line. */
.song-line.chords-only {
    margin-bottom: 0;
}
.song-line.chords-only .lyric {
    display: none;
}
.song-sheet.hide-chords .chords-only {
    display: none;
}
.song-sheet.hide-chords .chord {
    display: none;
}
/* No chord above this syllable: drop the reserved chord row. Segments align to the bottom
   (.song-line align-items: flex-end), so lyrics stay on one baseline next to chorded segments. */
.song-seg .chord:empty {
    display: none;
}
.song-sheet .song-spacer {
    height: 1em;
}
.song-sheet .song-comment {
    margin: .5em 0 .25em;
    font-size: .85em;
    font-style: italic;
    color: var(--bs-secondary-color);
}
.song-sheet .song-section {
    margin-top: 1em;
    font-size: .7em;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}
/* Printed repeat bars (songbooks with {start_of_repeat: N}): column 1 stands nearest the text, as on the page. */
.song-sheet:has(.repeat-bar) {
    padding-left: 3rem !important;
}
.song-row {
    position: relative;
    display: flow-root;
}
.repeat-bar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: calc(var(--repeat-column) * -.5rem);
    border-left: 2px solid var(--bs-secondary-color);
}
.song-controls .btn-check:checked + .btn {
    font-weight: 600;
}
@media print {
    .no-print, nav, footer {
        display: none !important;
    }
}

/* Statistics dashboard: server-rendered charts (no chart library). Colours from the reference data-viz palette:
   categorical slots in fixed order, one blue sequential ramp; dark mode has its own steps. */
.stat-dashboard {
    --stat-surface: #fcfcfb;
    --stat-ink: #0b0b0b;
    --stat-muted: #52514e;
    --stat-axis: #c3c2b7;
    --stat-grid: #e1e0d9;
    --stat-hover: #f0efec;
    --stat-ring: rgba(11, 11, 11, .1);
    --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4;
    --h1: #cde2fb; --h2: #9ec5f4; --h3: #6da7ec; --h4: #3987e5; --h5: #256abf; --h6: #184f95; --h7: #0d366b;
    --h-ink-light: #0b0b0b; --h-ink-dark: #ffffff;
}
@media (prefers-color-scheme: dark) {
    :root:where(:not([data-bs-theme="light"])) .stat-dashboard {
        --stat-surface: #1a1a19;
        --stat-ink: #f0efec;
        --stat-muted: #c3c2b7;
        --stat-axis: #383835;
        --stat-grid: #2c2c2a;
        --stat-hover: #262624;
        --stat-ring: rgba(255, 255, 255, .1);
        --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181;
        /* on a dark surface more is lighter */
        --h1: #184f95; --h2: #1c5cab; --h3: #256abf; --h4: #3987e5; --h5: #6da7ec; --h6: #9ec5f4; --h7: #cde2fb;
        --h-ink-light: #ffffff; --h-ink-dark: #0b0b0b;
    }
}
.stat-section {
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--stat-muted);
    margin: 1.75rem 0 .75rem;
    scroll-margin-top: 1rem;
}
.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: .75rem;
}
.stat-tile, .stat-chart {
    background: var(--stat-surface);
    border: 1px solid var(--stat-ring);
    border-radius: .5rem;
}
.stat-tile { padding: .75rem 1rem; }
.stat-tile-value { font-size: 1.75rem; font-weight: 700; color: var(--stat-ink); line-height: 1.1; }
.stat-tile-label { font-weight: 600; color: var(--stat-ink); }
.stat-tile-note, .stat-note { font-size: .8rem; color: var(--stat-muted); }
.stat-index { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .9rem; }
.stat-chart { padding: 1rem 1.25rem; scroll-margin-top: 1rem; min-width: 0; }
.stat-chart h3 { color: var(--stat-ink); }
.s1 { --c: var(--s1); } .s2 { --c: var(--s2); } .s3 { --c: var(--s3); } .s4 { --c: var(--s4); } .s5 { --c: var(--s5); }

/* donuts */
.stat-donuts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr)); gap: 1rem; }
.stat-donut-body { display: flex; align-items: center; gap: 1rem; }
.stat-donut-svg { width: 7.5rem; height: 7.5rem; flex: none; }
.stat-donut-track { fill: none; stroke: var(--stat-grid); stroke-width: 6; }
.stat-donut-slice { fill: none; stroke: var(--c); stroke-width: 6; transition: stroke-width .15s; }
.stat-donut-slice:hover { stroke-width: 7.5; }
.stat-donut-total { font-size: 7px; font-weight: 700; text-anchor: middle; fill: var(--stat-ink); }
.stat-donut-unit { font-size: 3.5px; text-anchor: middle; fill: var(--stat-muted); }
.stat-legend { list-style: none; margin: 0; padding: 0; font-size: .82rem; min-width: 0; flex: 1; }
.stat-legend li { display: flex; align-items: center; gap: .45rem; padding: .1rem 0; }
.stat-legend-label { flex: 1; color: var(--stat-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-legend-value { color: var(--stat-muted); font-variant-numeric: tabular-nums; }
.stat-legend-row { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin: .5rem 0; }
.stat-legend-row li { flex: none; }
.stat-swatch { width: .75rem; height: .75rem; border-radius: 3px; background: var(--c); flex: none; }

/* 100% stacked bars */
.stat-stack { list-style: none; margin: 0; padding: 0; }
.stat-stack li {
    display: grid; grid-template-columns: minmax(6rem, 30%) 1fr 2.5rem; align-items: center; gap: .6rem;
    padding: .2rem .25rem; border-radius: .25rem; font-size: .875rem;
}
.stat-stack li:hover { background: var(--stat-hover); }
.stat-stack-bar { display: flex; height: .9rem; gap: 2px; }
.stat-seg { background: var(--c); min-width: 2px; }
.stat-seg:first-child { border-radius: 4px 0 0 4px; }
.stat-seg:last-child { border-radius: 0 4px 4px 0; }
.stat-seg:only-child { border-radius: 4px; }

/* heatmaps */
.stat-heat-scroll { overflow-x: auto; }
.stat-heat { border-collapse: separate; border-spacing: 2px; font-size: .8rem; font-variant-numeric: tabular-nums; }
.stat-heat thead th {
    height: 7.5rem; vertical-align: bottom; padding: 0 0 .25rem; font-weight: 500; color: var(--stat-muted);
}
.stat-heat thead th span {
    display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap;
    max-height: 7.25rem; overflow: hidden; text-overflow: ellipsis;
}
.stat-heat tbody th {
    font-weight: 400; color: var(--stat-ink); padding-right: .6rem; white-space: nowrap;
    max-width: 16rem; overflow: hidden; text-overflow: ellipsis;
}
.stat-heat td {
    width: 2.6rem; min-width: 2.6rem; height: 1.9rem; text-align: center; border-radius: 3px;
    background: var(--stat-hover);
}
.stat-heat td:hover { outline: 2px solid var(--stat-ink); }
.stat-heat td.q0 { background: transparent; box-shadow: inset 0 0 0 1px var(--stat-grid); }
.stat-heat td.q1 { background: var(--h1); color: var(--h-ink-light); }
.stat-heat td.q2 { background: var(--h2); color: var(--h-ink-light); }
.stat-heat td.q3 { background: var(--h3); color: var(--h-ink-light); }
.stat-heat td.q4 { background: var(--h4); color: #ffffff; }
.stat-heat td.q5 { background: var(--h5); color: var(--h-ink-dark); }
.stat-heat td.q6 { background: var(--h6); color: var(--h-ink-dark); }
.stat-heat td.q7 { background: var(--h7); color: var(--h-ink-dark); }

/* column charts */
.stat-cols-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1rem; }
.stat-columns {
    display: flex; align-items: flex-end; gap: 4px; height: 11rem; padding-top: 1.2rem;
    border-bottom: 1px solid var(--stat-axis); margin-top: .5rem;
}
.stat-column {
    flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
    height: 100%; position: relative; min-width: 0;
}
.stat-column:hover .stat-column-bar { filter: brightness(1.15); }
.stat-column-bar { width: 100%; max-width: 2.5rem; background: var(--s1); border-radius: 4px 4px 0 0; min-height: 2px; }
.stat-column-count { font-size: .72rem; color: var(--stat-muted); font-variant-numeric: tabular-nums; }
.stat-column-label {
    position: absolute; top: 100%; margin-top: .3rem; font-size: .72rem; color: var(--stat-ink);
    width: 100%; text-align: center; line-height: 1.15;  /* "100–119" wraps after its dash on narrow columns */
}
.stat-cols-grid .stat-chart { padding-bottom: 3rem; }

/* horizontal bars */
.stat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr)); gap: 1rem;
    align-items: start;
}
.stat-bars { list-style: none; margin: .5rem 0; padding: 0; }
.stat-bars li {
    display: grid; grid-template-columns: minmax(6rem, 45%) 1fr 2.5rem; align-items: center; gap: .6rem;
    padding: .15rem .25rem; border-radius: .25rem; font-size: .875rem;
}
.stat-bars li:hover { background: var(--stat-hover); }
.stat-label {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    line-height: 1.25; color: var(--stat-ink);
}
a.stat-label { text-decoration: none; }
a.stat-label:hover { text-decoration: underline; }
.stat-track { height: .7rem; border-left: 1px solid var(--stat-axis); }
.stat-fill { display: block; height: 100%; min-width: 2px; background: var(--s1); border-radius: 0 4px 4px 0; }
.stat-count { text-align: right; font-variant-numeric: tabular-nums; color: var(--stat-muted); }
