body {
    position: relative;
    font-family: Georgia, "Times New Roman", serif;
    max-width: 40em;
    margin: 2em auto;
    padding: 0 1em;
    line-height: 1.5;
    color: #111;
    background: #fff;
    overflow-x: hidden;
}

header h1 {
    font-size: 1.3em;
    margin-bottom: 0.3em;
}

nav a {
    margin-right: 1em;
}

nav a:last-child {
    margin-right: 0;
}

hr {
    border: none;
    border-top: 1px solid #ccc;
    margin: 1.2em 0;
}

iframe.lw-widget {
    display: block;
    width: 100%;
    min-height: 400px;
    border: none;
    margin: 1.2em 0;
}

main img {
    max-width: 100%;
    height: auto;
    display: block;
}

.gallery {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2.5em;
    margin: 1.2em 0;
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    padding: 0 1em;
    box-sizing: border-box;
}

.gallery figure {
    margin: 0;
}

.gallery img {
    border-radius: 3px;
}

.gallery figcaption {
    margin-top: 0.4em;
    font-size: 0.85em;
    color: #555;
}

a {
    color: #0000cc;
}

a:visited {
    color: #660099;
}

footer {
    margin-top: 3em;
    font-size: 0.9em;
    color: #555;
}

.prevnext {
    display: flex;
    justify-content: space-between;
    margin-top: 2.5em;
    font-size: 0.95em;
}

.chapters {
    padding-left: 1.4em;
}

.chapters li {
    margin-bottom: 0.4em;
}

.sequences li {
    margin-bottom: 1em;
}

.sequences .desc {
    color: #444;
}

.poem {
    margin: 1.6em 0;
}

.poem p {
    margin: 0 0 1.4em 0;
}

.poem p:last-child {
    margin-bottom: 0;
}

.poem .note {
    font-size: 0.85em;
    color: #555;
    font-style: italic;
    margin-bottom: 2em;
}

.poem .pause {
    height: 2em;
}

.footnote-ref-wrap {
    position: relative;
}

.footnote-tooltip {
    position: absolute;
    left: 0;
    top: 1.5em;
    z-index: 10;
    width: max-content;
    max-width: min(280px, calc(100vw - 2em));
    background: #fdfdf5;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0.5em 0.7em;
    font-size: 0.85em;
    line-height: 1.4;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.footnote-tooltip.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.footnote-tooltip p {
    margin: 0;
}

.footnote-tooltip p + p {
    margin-top: 0.5em;
}

.footnote-ref-wrap a.sidenote-active {
    background: #ffe9a8;
}

.sidenote {
    display: none;
}

@media (min-width: 1220px) {
    .footnote-tooltip {
        display: none;
    }

    .sidenote {
        display: block;
        position: absolute;
        left: 100%;
        margin-left: 2em;
        width: 220px;
        font-size: 0.8em;
        line-height: 1.4;
        color: #888;
        opacity: 0.55;
        transition: opacity 0.15s ease, color 0.15s ease;
    }

    .sidenote p {
        margin: 0;
    }

    .sidenote p + p {
        margin-top: 0.5em;
    }

    .sidenote-number {
        font-weight: bold;
        margin-right: 0.3em;
        color: inherit;
    }

    .sidenote.active {
        opacity: 1;
        color: #111;
    }
}
