/* webbook's TOC */
#webbook-toc-nav:popover-open {
    margin: 0;
    inset: 0 auto 0 0;
    width: min(36rem, 92vw);
    height: 100dvh;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    border-radius: 0 5px 5px 0;

    a {
        background: var(--theme-bg);
        color: var(--theme-fg);
    }
    ol {
        list-style-type: none;
    }
    & > ol {
        /* the panel's own padding is enough; more here plus each level's indent left long titles a
           narrow column */
        padding-inline: 0 .25rem;
        margin: 0;
        overflow-y: auto;
        flex: 1;
    }
    li > a {
        display: inline-block;
        padding: .2rem .35rem;
        border-inline-start: .3rem solid transparent;
        border-radius: 2px;
        overflow-wrap: anywhere;
    }
    li > a:focus-visible {
        outline: 3px solid var(--webbook-focus-color);
        outline-offset: 2px;
    }
    li > a[aria-current="page"] {
        border-inline-start-color: var(--webbook-focus-color);
        font-weight: 700;
        background: color-mix(in srgb, var(--webbook-focus-color) 12%, var(--theme-bg));
        scroll-margin-top: 20vh;
    }
    li {
        margin-block: .35rem;
    }
    ol ol {
        padding-top: .25rem;
        padding-bottom: .5rem;
        padding-inline-start: 1.25rem;
    }
    ol ol a {
        font-size: .9em;
    }
    #webbook-toc-header {
        width: calc(100% + 2rem);
        box-sizing: border-box;
        display: flex;
        /* the Cover link sits on the heading's baseline row, not centered on a wrapped title */
        align-items: flex-end;
        justify-content: space-between;
        gap: 1rem;
        position: sticky;
        top: 0;
        background: var(--theme-bg);
        margin: 0 -1rem 1rem;
        padding: 1rem;
        border-bottom: var(--webbook-panel-border);
    }
    #webbook-toc-nav-hd {
        margin: 0;
        /* clear of the close button; the rows below can use the full width */
        padding-inline-end: 2.75rem;
    }
    #webbook-toc-header {
        flex-wrap: wrap;
        row-gap: .6rem;
    }
    #webbook-toc-nav-hd {
        flex-basis: 100%;
    }
    #webbook-toc-find {
        order: 2;
        flex-basis: 100%;
        display: grid;
        gap: .25rem;
        font-size: .95rem;

        label {
            font-weight: 600;
        }
        input {
            min-height: 2.25rem;
            padding: .25rem .5rem;
            font: inherit;
            color: var(--theme-fg);
            background: var(--theme-bg);
            border: 1px solid color-mix(in srgb, var(--theme-fg) 55%, transparent);
            border-radius: 4px;
        }
        #webbook-toc-find-status {
            margin: 0;
            font-size: .9rem;
        }
        #webbook-toc-find-status:empty {
            display: none;
        }
    }
    #webbook-toc-depth-control {
        order: 3;
        flex-basis: 100%;
        display: flex;
        align-items: center;
        gap: .5rem;
        font-size: .95rem;

        label {
            font-weight: 600;
        }
        select {
            min-height: 2rem;
            max-width: 100%;
            font: inherit;
        }
    }
}
/* small screens */
@media(max-width: 45rem) {
    #webbook-toc-nav:popover-open {
        width: 100vw;
        border-radius: 0;

        #webbook-toc-header {
            flex-wrap: wrap;
        }
        #webbook-toc-nav-hd {
            flex-basis: 100%;
        }
    }
}
/* Marks the narrated entries in a book narrated in part */
#webbook-toc-nav {
    .webbook-narrated-mark svg,
    #webbook-toc-narration-key svg {
        width: 1em;
        height: 1em;
        vertical-align: -.125em;
    }
    .webbook-narrated-mark {
        margin-inline-start: .4em;
    }
    #webbook-toc-narration-key {
        margin: -.5rem 0 .75rem;
        padding-inline: 1rem;
        font-size: .9rem;
    }
}
