body {
    font-family: 'Roboto';
    margin: 0 3em;
    font-size: medium;
    font-weight: 400;
    box-sizing: border-box;
}
body.songbody {
    margin: 0;
}
@media print {
    body {
        margin: 0;
    }
    @page {
        margin: var(--page-margin)
    }
    div.page {
        width: calc(var(--page-width) - 2*var(--page-margin));
        transform: none !important;
        margin-bottom: 0 !important;
    }
}
@media screen {
    div.pagecontainer {
        width: 100%;
        background: #ddd;
        display: flex;
        flex-direction: row;
        justify-content: center;
        overflow-x: hidden;
    }
    div.page {
        background: white;
        border: 1px solid gray;
        width: calc(var(--page-width) - 2*var(--page-margin));
        padding: var(--page-margin);
        flex-shrink: 0;
        transform-origin: top center;
    }
}
body.book {
    background-color: #eee;
}
.book .song {
    background: white;
    margin: 5px 0px;
    padding: 1ex 1em;
    box-shadow: 1px 1px 6px -1px gray;
}
h1 {
    font-weight: 700;
    margin: 0 0 0.33em 0;
}
h3 {
    font-size: larger;
    font-weight: 400;
    margin-top: 0;
    margin-bottom: 0;
}
.meta {
    font-size: small;
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.meta span {
    display: inline-block;
    padding-right: 1em;
}
.lyrics {
    margin-top: 1em;
    column-count: max(var(--page-columns), 1);
}
.lyrics p {
    margin-top: 0;
    break-inside: avoid;
}
.err {
    color: red
}
p.haschords {
    line-height: 2.3em;
    margin-top: 1em;
}
.melody {
    margin: 16px 0;
}
/* .melody img {
    object-fit: none;
    max-width: 100%
} */
.chorus {
    margin-left: 1em;
}
h3 a {
    text-decoration: none;
    color: gray;
}
span[data-chord]:before {
    position: relative;
    top: -1em;
    display: inline-block;
    content: attr(data-chord);
    width: 0;
}
.music {
    font-family: 'Noto Music', sans-serif;
}

.chords {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
}

.label {
    padding-right: 1em;
    grid-column: label;
}

.chordblock {
    --barcount: 1;

    display: grid;
    grid-template-columns: [label] 1fr [rptb] auto [barstart] repeat(var(--barcount), 2fr) [barend rpte] auto [post] 1fr;
    margin: 10px 0;
    line-height: 28px;
}

.chordblock > div {
    padding-top: 4px;
    padding-bottom: 4px;
}

.bars4 { --barcount: 4; }
.bars5 { --barcount: 5; }
.bars6 { --barcount: 6; }
.bars7 { --barcount: 7; }
.bars8 { --barcount: 8; }
.bars12 { --barcount: 12; }

sup {
    line-height: 0;
    font-size: x-small;
}

sup.music {
    font-size: small;
}

.repeat {
    font-size: 28px;
    padding: 0 0.5ch;
}

.bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    align-items: center;
    outline: 2px solid black;
    text-align: center;
    min-width: 4em;
    margin: 1px;
}

.beat-span-4 {
    grid-column: span 4;
    text-align: center;
}

.beat-span-2 {
    grid-column: span 2;
    text-align: center;
}

.beat-span-1 {
    grid-column: span 1;
    text-align: center;
}

/* Web Server UI Layout */
body.serverbody {
    font-family: sans-serif;
    background-color: #eee;
    margin: 0;
    padding: 0;
}

#top {
    display: grid;
    grid-template-columns: 1fr 2fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
}

#head {
    grid-row: 1;
    grid-column: 2;
    display: flex;
    padding: 4px;
}

#options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 0;
}

#left {
    grid-row: 1 / 3;
    overflow: auto;
}

#songlist-toggle {
    display: none;
}

#sheet {
    grid-row: 2;
    grid-column: 2;
    height: calc(100% - 10px);
    width: calc(100% - 10px);
    margin: 4px;
    border: 1px solid #ddd;
    background: white;
}

@media (max-width: 768px) {
    #top {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }

    #left {
        grid-row: 1;
        grid-column: 1;
        overflow: visible;
        position: relative;
        z-index: 10;
        border-bottom: 1px solid #ccc;
        background: #fff;
    }

    #songlist-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 8px 12px;
        border: none;
        background: #0066cc;
        color: white;
        font-size: 1rem;
        font-weight: bold;
        text-align: left;
        cursor: pointer;
    }

    #songlist-toggle .artist {
        color: #d0e0f0;
        font-weight: normal;
    }

    #current-song-label {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-right: 8px;
    }

    #left.open #songlist-toggle .toggle-arrow {
        transform: rotate(180deg);
    }

    #left .songlist {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-height: 65vh;
        overflow-y: auto;
        background: #f8f8f8;
        border-bottom: 2px solid #999;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    #left.open .songlist {
        display: block;
    }

    #head {
        grid-row: 2;
        grid-column: 1;
    }

    #sheet {
        grid-row: 3;
        grid-column: 1;
    }
}

#sheet.fullscreen {
    position: fixed;
    margin: 0;
}

iframe {
    height: 100%;
    width: 100%;
}

label {
    display: inline-block;
}

th {
    text-align: left;
}

input {
    margin-left: 1em;
}

.transpose-controls {
    display: inline-flex;
    align-items: center;
    margin: 0 0.5em;
    gap: 2px;
}

.transpose-controls button {
    padding: 0 6px;
    cursor: pointer;
}

#tuning-display {
    display: inline-block;
    min-width: 2.2em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.artist {
    color: #999;
}

.float {
    position: absolute;
    right: 0;
}

.songlist {
    list-style: none;
    margin: 0;
    padding: 0;
}

.songlist li {
    padding: 4px 8px;
    cursor: pointer;
    border-radius: 3px;
}

.songlist li:hover {
    background-color: #ddd;
}

.songlist li.selected {
    background-color: #0066cc;
    color: white;
    font-weight: bold;
}

.songlist li.selected .artist {
    color: #d0e0f0;
}
