.che-book-reader {
    --che-book-line: #d8dee6;
    --che-book-blue: #173a67;
    --che-book-controls-top: calc(var(--che-site-top, 0px) + var(--che-book-bar-size, 0px));
    --che-article-sticky-top: var(--che-book-controls-top);
    scroll-margin-block-start: var(--che-site-top, 0px);
    color: #23334a;
    margin: .55rem 0 1.25rem;
    border: 1px solid var(--che-book-line);
    font: 15px/1.45 system-ui, sans-serif;
    min-width: 0;
}
.che-book-reader *,
.che-book-reader *::before,
.che-book-reader *::after { box-sizing: border-box; }
.che-book-reader [hidden] { display: none !important; }
.che-book-reader .che-book-bar,
.che-book-reader :is(.che-book-step, .che-book-bar .che-reader-links) {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .45rem;
}
.che-book-reader .che-book-bar {
    background: var(--che-book-blue);
    color: #fff;
    border-bottom: 2px solid #b8860b;
    padding: .35rem .65rem;
    position: sticky;
    inset-block-start: var(--che-site-top, 0px);
    z-index: 24;
}
.che-book-reader .che-book-current {
    flex: 1 1 12rem;
    min-width: 0;
    padding-inline: .35rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}
.che-book-reader .che-book-bar :is(button, .che-book-permalink, .che-reader-link) {
    font: inherit;
    text-transform: none;
    letter-spacing: normal;
    text-decoration: none;
    white-space: nowrap;
    color: #fff;
    background: #244971;
    border: 1px solid #8599b2;
    border-radius: 4px;
    box-shadow: none;
    padding: .24em .62em;
}
.che-book-reader.che-book-combined .che-book-bar { flex-wrap: nowrap; }
.che-book-reader.che-book-combined .che-book-bar > :not(.che-book-current, .che-book-article-tools) { flex: none; }
.che-book-reader.che-book-combined .che-book-current {
    flex: 0 1 20rem;
    min-width: 4rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.che-book-reader .che-book-article-tools { flex: 1 1 28rem; min-width: 0; }
.che-book-reader .che-book-article-tools .che-article-ribbon {
    flex-wrap: nowrap;
    gap: .45rem;
    background: transparent;
    padding: 0;
    border: 0;
}
.che-book-reader .che-book-article-tools :is(.che-article-search, .che-article-search-fields, .che-article-search-nav) {
    flex-wrap: nowrap;
    gap: .35rem;
}
.che-book-reader .che-book-article-tools .che-article-ribbon .che-article-search { flex: 1 1 16rem; }
.che-book-reader .che-book-article-tools .che-article-ribbon .che-article-search-fields { flex: 1 1 auto; }
.che-book-reader .che-book-article-tools .che-article-ribbon .che-article-search :is(.che-article-search-nav, button, select) { flex: none; }
.che-book-reader .che-book-article-tools .che-article-ribbon .che-article-search input[type="search"] {
    flex: 1 1 9rem;
    min-width: 6rem;
}
.che-book-reader .che-book-article-tools .che-article-ribbon :is(button, input, select) {
    min-height: 30px;
    padding-block: .22rem;
}
.che-book-reader .che-book-bar button:disabled { opacity: .55; }
.che-book-reader .che-book-bar :is(button, a):focus-visible,
.che-book-reader .che-book-toc :is(input, a):focus-visible {
    outline: 2px solid #b8860b;
    outline-offset: 2px;
}
.che-book-reader .che-book-layout { min-width: 0; }
.che-book-reader .che-book-layout:has(> .che-book-toc:not([hidden]) ~ .che-book-pane:not([hidden])) {
    display: grid;
    grid-template-columns: clamp(10rem, var(--che-book-toc-width, 23%), min(32rem, 50%)) .75rem minmax(0, 1fr);
}
.che-book-reader .che-book-splitter {
    position: relative;
    min-width: 0;
    cursor: col-resize;
    touch-action: none;
    background: #f7f8fa;
    border-inline-end: 1px solid var(--che-book-line);
}
.che-book-reader .che-book-splitter::before {
    content: "";
    position: absolute;
    inset-block: 0;
    inset-inline-start: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: #96a7bc;
}
.che-book-reader .che-book-splitter:is(:hover, :focus-visible)::before,
.che-book-reader .che-book-layout.che-book-resizing > .che-book-splitter::before {
    background: var(--che-book-blue);
}
.che-book-reader .che-book-splitter:focus-visible { outline: 2px solid #b8860b; outline-offset: -2px; }
.che-book-reader .che-book-layout.che-book-resizing { cursor: col-resize; user-select: none; }
.che-book-reader .che-book-toc {
    position: sticky;
    inset-block-start: var(--che-book-controls-top);
    z-index: 20;
    align-self: start;
    display: flex;
    flex-direction: column;
    max-block-size: max(0px, calc(100vh - var(--che-book-controls-top) - .5rem));
    max-block-size: max(0px, calc(100dvh - var(--che-book-controls-top) - .5rem));
    min-width: 0;
    background: #f7f8fa;
    border-inline-end: 1px solid var(--che-book-line);
    padding: .65rem;
}
.che-book-reader .che-book-toc h3 {
    margin: 0 0 .55rem;
    font: 700 1em/1.4 system-ui, sans-serif;
    color: inherit;
}
.che-book-reader .che-book-filter {
    font: inherit;
    width: 100%;
    border: 1px solid var(--che-book-line);
    padding: .42em .55em;
    border-radius: 4px;
    background: #fff;
    color: #23334a;
}
.che-book-reader .che-book-filter-empty { margin: .6em 0 0; }
.che-book-reader .che-book-toc > :not(ol) { flex: none; }
.che-book-reader .che-book-toc ol {
    list-style: none;
    margin: .55rem 0 0;
    padding: 0;
    min-block-size: 0;
    overflow: auto;
    overscroll-behavior: contain;
}
.che-book-reader .che-book-toc li { margin: 0; padding: 0; }
.che-book-reader .che-book-toc a {
    display: block;
    padding: .35em .48em;
    color: var(--che-book-blue);
    text-decoration: none;
    border-radius: 3px;
    overflow-wrap: anywhere;
}
.che-book-reader .che-book-toc a:hover { background: #e8eef5; }
.che-book-reader .che-book-toc [aria-current="true"] {
    background: #fff0b9;
    font-weight: 700;
}
.che-book-reader .che-book-pane { min-width: 0; overflow-wrap: anywhere; }
.che-book-reader .che-book-status { margin: .6em .85em; }
.che-book-reader .che-book-status:has(span:empty) { display: none; }
.che-book-reader .che-book-content > .che-article-reader { margin: 0; }

@media (max-width: 720px) {
    .che-book-reader {
        --che-article-sticky-top: calc(var(--che-book-controls-top) + var(--che-book-toc-size, 0px));
    }
    .che-book-reader .che-book-layout:has(> .che-book-toc:not([hidden]) ~ .che-book-pane:not([hidden])) { display: block; }
    .che-book-reader .che-book-splitter { display: none; }
    .che-book-reader .che-book-toc {
        border-inline-end: 0;
        border-bottom: 1px solid var(--che-book-line);
        max-block-size: min(42vh, max(0px, calc(100vh - var(--che-book-controls-top) - .5rem)));
        max-block-size: min(42dvh, max(0px, calc(100dvh - var(--che-book-controls-top) - .5rem)));
    }
}


/* Trim the surrounding post layout only where a book reader is present. */
body:has(.che-book-reader) #primary:has(.che-book-reader) {
    margin-block-start: .6rem;
    padding-block-start: 0;
}
body:has(.che-book-reader) article:has(.che-book-reader),
body:has(.che-book-reader) .wp-site-blocks main:has(.che-book-reader) {
    padding-block-start: .35rem;
}
body:has(.che-book-reader) :is(article, main):has(.che-book-reader) > .entry-header,
body:has(.che-book-reader) article:has(.che-book-reader) .entry-header,
body:has(.che-book-reader) .ast-single-entry-banner {
    margin-block: 0 .35rem;
    padding-block: 0;
}
body:has(.che-book-reader) :is(article, main):has(.che-book-reader) :is(.entry-title, .wp-block-post-title),
body:has(.che-book-reader) .ast-single-entry-banner .entry-title {
    margin-block: 0 .25rem;
    font-size: clamp(1.35rem, 2.5vw, 1.85rem);
    line-height: 1.2;
}
body:has(.che-book-reader) :is(article, main):has(.che-book-reader) .entry-header .entry-meta,
body:has(.che-book-reader) .ast-single-entry-banner .entry-meta,
body:has(.che-book-reader) :is(.entry-content, .wp-block-post-content):has(.che-book-reader) :is(.che-inline-toolbar-placeholder, .book-action-buttons) {
    display: none !important;
}
body:has(.che-book-reader) :is(.entry-content, .wp-block-post-content):has(.che-book-reader) .book-meta-inline {
    font-size: .85rem;
    line-height: 1.35;
    margin-block: 0 .35rem;
}
.che-book-reader .che-book-content .che-article-ribbon { padding-block: .3rem; }
.che-book-reader .che-book-content .che-article-ribbon :is(button, select, input, .che-reader-link) {
    min-height: 30px;
    padding-block: .22rem;
}
.che-book-reader .che-book-content .che-article-body { padding-block-start: .4em; }
.che-book-reader .che-book-content .che-article-body > :first-child,
.che-book-reader .che-book-content .che-article-body > :first-child > :first-child,
.che-book-reader .che-book-content .che-article-body .che-commentary-panel > h2:first-child {
    margin-block-start: 0;
}

body.che-book-hide-top:has(.che-book-reader) :is(#masthead, #ast-fixed-header, #page > .site-header, .wp-site-blocks > header),
body.che-book-hide-top:has(.che-book-reader) > .site-header,
body.che-book-hide-top:has(.che-book-reader) .ast-single-entry-banner,
body.che-book-hide-top:has(.che-book-reader) article:has(.che-book-reader) .entry-header,
body.che-book-hide-top:has(.che-book-reader) main:has(.che-book-reader) > :is(.entry-header, .wp-block-post-title),
body.che-book-hide-top:has(.che-book-reader) :is(.entry-content, .wp-block-post-content):has(.che-book-reader) .book-meta-inline {
    display: none !important;
}
body.che-book-hide-top:has(.che-book-reader) :is(#content, #primary, .wp-site-blocks main):has(.che-book-reader) {
    margin-block-start: 0;
    padding-block-start: 0;
}
body.che-book-hide-top:has(.che-book-reader) .che-book-reader { margin-block-start: .25rem; }



.che-book-reader .che-book-toc > .che-book-groups {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}
.che-book-reader .che-book-group { border-bottom: 1px solid #d8e0e8; }
.che-book-reader .che-book-group summary {
    cursor: pointer;
    color: #183555;
    font-weight: 650;
    padding: .55rem .5rem;
}
.che-book-reader .che-book-group summary:focus-visible {
    outline: 2px solid #265a90;
    outline-offset: -2px;
}
.che-book-reader .che-book-group[open] summary { background: #e8eef5; }
.che-book-reader .che-book-group ol { padding-inline-start: .35rem; }
