@layer reader-base, publisher;
/* reset.css */
@layer reader-base {
:root {
    --size-step-0: 1rem;
    --size-step-0: clamp(1rem, calc(0.96rem + 0.22vw), 1.13rem);
    --size-step-1: clamp(1.25rem, calc(1.16rem + 0.43vw), 1.5rem);
    --size-step-2: clamp(1.56rem, calc(1.41rem + 0.76vw), 2rem);
    --size-step-3: clamp(1.95rem, calc(1.71rem + 1.24vw), 2.66rem);
    --size-step-4: clamp(2.44rem, calc(2.05rem + 1.93vw), 3.55rem);
}

body {
    padding: 0;
    margin: 0;

    font-family: Inter, Roboto, sans-serif;
    font-size: var(--size-step-1);
    line-height: 1.6;
}

h1,
h2,
h3 {
    font-family: Inter, sans-serif;
    font-weight: 800;
    line-height: 1.1;
}

h1 {
    font-size: var(--size-step-4);
}

h2 {
    font-size: var(--size-step-3);
}

h3 {
    font-size: var(--size-step-2);
}

/* Reading settings apply to all publication text, including elements whose
   typographic scale is otherwise expressed in root-relative units. */
main h1,
main h2,
main h3 {
    font-family: inherit;
}

main h1 {
    font-size: calc(var(--size-step-4) * var(--webbook-font-scale, 1));
}

main h2 {
    font-size: calc(var(--size-step-3) * var(--webbook-font-scale, 1));
}

main h3 {
    font-size: calc(var(--size-step-2) * var(--webbook-font-scale, 1));
}

ul,
ol {
    padding-inline-start: 1em;
}

blockquote {
    padding-inline-start: 1em;
    border-inline-start: 0.3em solid;
    font-size: calc(var(--size-step-1) * var(--webbook-font-scale, 1));
    font-style: italic;
}

blockquote {
    max-width: 50ch;
}

}

/* tokens.css */
:root {
    --offblack: #111;
    --theme-bg: #fafafa;
    --theme-fg: #111;
    --webbook-chrome-bg: var(--offblack);
    --webbook-chrome-fg: white;
    --webbook-focus-color: #005fcc;
    --webbook-panel-border: 1px solid color-mix(in srgb, var(--theme-fg) 18%, transparent);
    /* #6e6e6e on the light background (#fafafa) is ~4.9:1; #767676, the usual AA gray, only passes
       on pure white (4.54:1) and was 4.35:1 here */
    --webbook-muted-fg: #6e6e6e;
    --webbook-search-highlight-bg: #005fcc;
    --webbook-search-highlight-fg: white;
}
:root.webbook-dark,
body.webbook-dark {
    --theme-bg: black;
    --theme-fg: white;
    --webbook-focus-color: #8ec5ff;
    /* lighter gray needed for AA on a black background */
    --webbook-muted-fg: #a8a8a8;
    --webbook-search-highlight-bg: #d65db1;
    --webbook-search-highlight-fg: black;
    color-scheme: dark;
}
:root.webbook-light,
body.webbook-light {
    --theme-bg: #fafafa;
    --theme-fg: #111;
    --webbook-focus-color: #005fcc;
    --webbook-muted-fg: #6e6e6e;
    --webbook-search-highlight-bg: #005fcc;
    --webbook-search-highlight-fg: white;
    color-scheme: light;
}

/* layout.css */
/* scrolling to a link's target, a search result or a focused element stops short of the toolbars
   that sit over the text (WCAG 2.4.11), with a little room to spare */
:root {
    scroll-padding-top: calc(var(--webbook-top-toolbar-height, 4rem) + .5rem);
    scroll-padding-bottom: calc(var(--webbook-toolbar-height, 8.5rem) + .5rem);
}
/* page container */
:root {
    --webbook-page-arrow-gutter: 0px;
}
/* An arrow is 3rem wide, .75rem in from the edge (spine-nav.css); .75rem more to the text */
@media (min-width: 45.0625rem) {
    :root:is(.webbook-dark, .webbook-light, .webbook-js) {
        --webbook-page-arrow-gutter: calc(4.5rem + env(safe-area-inset-left, 0px));
    }
}
body {
    background: var(--theme-bg);
    color: var(--theme-fg);
    min-height: 100dvh;

    display: grid;
    grid-template-areas:
        "topbar topbar topbar"
        ". main ."
        "toolbar toolbar toolbar";
    /* The spine arrows are fixed in the side columns, outside the flow. The text keeps clear of
       them, and the Line length setting's fractions are of the width between them (Wide is all of
       it). Without JavaScript there are no arrows, and on a small screen they're in the top
       toolbar, so the columns close. */
    grid-template-columns: var(--webbook-page-arrow-gutter) minmax(0, 1fr) var(--webbook-page-arrow-gutter);
    /* without this, a short page stretches every row to fill the viewport, toolbar rows included */
    grid-template-rows: auto 1fr auto;
}
/* The reader adds the top toolbar when it starts (reader-shell.js); until then its row keeps the
   toolbar's room, so the text doesn't drop into place a moment after the page shows */
:root.webbook-js body {
    grid-template-rows: minmax(var(--webbook-top-toolbar-height, 4rem), auto) 1fr auto;
}
[hidden] {
    display: none !important;
}
.webbook-ui-nav-fallback {
    color: var(--webbook-chrome-fg);
    background: var(--webbook-chrome-bg);
    font: inherit;
    padding: .5rem;
    min-height: 2.75rem;
}
#webbook-source-metadata pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: .85em;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* text spacing settings (text-spacing.js): set only when the reader chooses a step, and then over
   the book's own CSS. Line spacing brings paragraph spacing (WCAG 1.4.12: 2 times the font size). */
:root:not([data-webbook-appearance="published"])[data-webbook-line-height] main,
:root:not([data-webbook-appearance="published"])[data-webbook-line-height] main * {
    line-height: var(--webbook-line-height) !important;
}
:root:not([data-webbook-appearance="published"])[data-webbook-line-height] main p {
    margin-block-end: 2em !important;
}
:root:not([data-webbook-appearance="published"])[data-webbook-letter-spacing] main,
:root:not([data-webbook-appearance="published"])[data-webbook-letter-spacing] main * {
    letter-spacing: var(--webbook-letter-spacing) !important;
}
:root:not([data-webbook-appearance="published"])[data-webbook-word-spacing] main,
:root:not([data-webbook-appearance="published"])[data-webbook-word-spacing] main * {
    word-spacing: var(--webbook-word-spacing) !important;
}

/* publication text */
@layer reader-base {
main {
    grid-area: main;
    box-sizing: border-box;
    width: 100%;
    /* the Line length setting (text-spacing.js): characters a line, within the width the text has */
    max-width: var(--webbook-line-length, 45rem);
    margin: auto;
    /* clear of the fixed bottom toolbar */
    padding-bottom: 9rem;
    font-family: var(--webbook-main-font-family, system-ui);
    font-size: var(--webbook-main-font-size, 100%);
    /* book content must not widen the page past the screen: on a phone that zooms the page */
    min-width: 0;
    overflow-wrap: anywhere;

    img, svg, video {
        max-width: 100%;
        height: auto;
    }

    /* the anchor links at chapter headings — hidden until hover/focus so headings
       don't read as link-cluttered by default; :focus-within also reveals it when
       the heading itself is the landing target of a same-page jump. */
    a[rel=bookmark].webbook {
        color: var(--theme-fg);
        opacity: 0;
        transition: opacity 0.15s;
        svg {
            height: 2rem;
        }
    }
    :is(h1, h2, h3, h4, h5, h6):hover a[rel=bookmark].webbook,
    :is(h1, h2, h3, h4, h5, h6):focus-within a[rel=bookmark].webbook {
        opacity: 1;
    }
    table {
        width: 100%;
        margin: 1.5rem 0;
        border-collapse: collapse;
        font-size: calc(.95rem * var(--webbook-font-scale, 1));
    }
    caption {
        margin-bottom: .4rem;
        font-weight: 700;
        text-align: left;
    }
    th,
    td {
        border: 1px solid color-mix(in srgb, var(--theme-fg) 25%, transparent);
        padding: .45rem .55rem;
        text-align: left;
        vertical-align: top;
    }
    th {
        font-weight: 700;
    }
    .epubtype_pagebreak {
        display: block;
        width: fit-content;
        margin: 1.5rem auto;
        padding: .1rem .45rem;
        border-top: 1px solid color-mix(in srgb, var(--theme-fg) 30%, transparent);
        border-bottom: 1px solid color-mix(in srgb, var(--theme-fg) 30%, transparent);
        color: var(--webbook-muted-fg);
        font-size: calc(.85rem * var(--webbook-font-scale, 1));
    }
}

}
/* The frame stays with the reader even when publisher typography is retained. */
main { position: relative; isolation: isolate; z-index: 0; grid-area: main; box-sizing: border-box; width: 100%; min-width: 0; margin: auto; padding-bottom: 9rem; }
:root:not([data-webbook-appearance="published"])[data-webbook-line-length] main { max-width: var(--webbook-line-length, 45rem); }
:root:not([data-webbook-appearance="published"])[data-webbook-font-family] main { font-family: var(--webbook-main-font-family); }
:root:not([data-webbook-appearance="published"])[data-webbook-font-size] main { font-size: var(--webbook-main-font-size) !important; }
/* Publisher defaults sit below its stylesheet. Every saved reader value stays available,
   but cannot influence the publication while the design is on. */
:root[data-webbook-appearance="published"] {
    --webbook-main-font-family: serif !important;
    --webbook-main-font-size: 1rem !important;
    --webbook-font-scale: 1 !important;
    --webbook-line-length: 100% !important;
}
/* A publisher percentage/em font starts from the browser's root size, not the UI's
   larger body text. Reader controls keep their own inherited typography. */
:root[data-webbook-appearance="published"] body { font-size: 1rem; }
:root[data-webbook-appearance="published"] body > :not(main) { font-size: var(--size-step-1); }
@layer reader-base {
    :root[data-webbook-appearance="published"] main { font-family: serif; font-size: 1rem; line-height: normal; color: #000; background: #fff; max-width: none; }
    :root[data-webbook-appearance="published"] main :not([data-webbook-reader], .webbook, .webbook *) { all: revert-layer; }
}
/* Publication tables remain intact and scroll instead of widening a phone-sized page. JS removes
   the region and tab stop when the table fits, but the wrapper works without JS too. */
.webbook-table-scroll {
    max-width: 100%;
    overflow-x: auto;
}
.webbook-table-scroll:focus-visible {
    outline: 3px solid var(--theme-fg);
    outline-offset: 2px;
}
/* the reader's text and background colors (page-colors.js): one palette for the publication and
   the reader UI. As under forced colors, backgrounds inside the text go, so a sidebar's own can't
   leave the chosen text unreadable. */
:root:not([data-webbook-appearance="published"])[data-webbook-colors],
:root:not([data-webbook-appearance="published"])[data-webbook-colors] body {
    --theme-bg: var(--webbook-page-bg);
    --theme-fg: var(--webbook-page-fg);
    --webbook-chrome-bg: var(--webbook-page-bg);
    --webbook-chrome-fg: var(--webbook-page-fg);
    --webbook-muted-fg: var(--webbook-page-muted);
    --webbook-focus-color: var(--webbook-page-focus);
    --webbook-search-highlight-bg: var(--webbook-page-search-bg);
    --webbook-search-highlight-fg: var(--webbook-page-search-fg);
    color-scheme: var(--webbook-page-scheme);
}
:root:not([data-webbook-appearance="published"])[data-webbook-colors] body {
    background: var(--webbook-page-bg);
    color: var(--webbook-page-fg);
}
:root:not([data-webbook-appearance="published"])[data-webbook-colors] :is(main, main :not(svg *, img)) {
    color: var(--webbook-page-fg) !important;
    background-color: transparent !important;
    background-image: none !important;
    border-color: color-mix(in srgb, var(--webbook-page-fg) 40%, transparent) !important;
}
/* As published, the reader's UI takes the book's own colors (published-colors.js), so the page is one
   surface. The text inside <main> keeps the publisher's colors. */
:root[data-webbook-appearance="published"][data-webbook-published-colors],
:root[data-webbook-appearance="published"][data-webbook-published-colors] body {
    --theme-bg: var(--webbook-published-bg);
    --theme-fg: var(--webbook-published-fg);
    --webbook-chrome-bg: var(--webbook-published-bg);
    --webbook-chrome-fg: var(--webbook-published-fg);
    --webbook-muted-fg: var(--webbook-published-muted);
    --webbook-focus-color: var(--webbook-published-focus);
    --webbook-search-highlight-bg: var(--webbook-published-search-bg);
    --webbook-search-highlight-fg: var(--webbook-published-search-fg);
    color-scheme: var(--webbook-published-scheme);
}
:root[data-webbook-appearance="published"][data-webbook-published-colors] body {
    background: var(--webbook-published-bg);
    color: var(--webbook-published-fg);
}
/* the browser's own focus ring may not stand out on the chosen background (WCAG 1.4.11) */
:root:not([data-webbook-appearance="published"])[data-webbook-colors] main :focus-visible {
    outline: 3px solid var(--webbook-focus-color) !important;
    outline-offset: 2px;
}
/* links can't be told apart by color any more (WCAG 1.4.1) */
:root:not([data-webbook-appearance="published"])[data-webbook-colors] main a:any-link {
    text-decoration-line: underline !important;
}
/* small screens */
@media(max-width: 45rem) {
    main {
        padding-left: var(--size-step-0);
        padding-right: var(--size-step-0);
    }
}
/* The publisher styles has no line length, so its text would run up to the app's edges: a little room
   left and right at every width (user, 2026-11-16). Physical sides, also in vertical text. Unlayered,
   so the publisher's CSS can't take it away. */
:root[data-webbook-appearance="published"] main {
    padding-left: var(--size-step-0);
    padding-right: var(--size-step-0);
}

/* Reading without JavaScript. The reader's script is running when <html> has webbook-dark or
   webbook-light (set by the head's appearance script before the first paint, so nothing flashes)
   or webbook-js (set by toolbar.js, for when storage is blocked and the head script can't run).
   Without it, there's a plain header with the table of contents and the previous and next pages,
   and the browser's own audio player instead of the toolbars. */
#webbook-basic-nav {
    grid-area: topbar;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 2.5rem;
    padding: .75rem max(1rem, env(safe-area-inset-left));
    border-bottom: var(--webbook-panel-border);

    button {
        font: inherit;
        padding: .4rem .9rem;
        border: 1px solid currentColor;
        border-radius: 4px;
        background: var(--theme-bg);
        color: var(--theme-fg);
        cursor: pointer;
    }
    a {
        color: var(--theme-fg);
    }
    /* next page at the far end, apart from previous */
    #webbook-basic-next {
        margin-inline-start: auto;
    }
}
:root:is(.webbook-dark, .webbook-light, .webbook-js) :is(#webbook-basic-nav, .webbook-basic-close) {
    display: none;
}
:root:not(.webbook-dark):not(.webbook-light):not(.webbook-js) {
    #webbook-top-toolbar,
    #webbook-spine-nav {
        display: none;
    }
    #webbook-toolbar {
        display: block;
        opacity: 1;
        padding: .5rem max(1rem, env(safe-area-inset-left)) max(.5rem, env(safe-area-inset-bottom));
    }
    #webbook-toolbar:not(:has(audio)) {
        display: none;
    }
    /* !important: the toolbar's own rules for its controls are more specific */
    #webbook-toolbar > :not(audio),
    #webbook-toolbar :is(#webbook-narration-position, #webbook-audio-controls) {
        display: none !important;
    }
    #webbook-toolbar audio {
        display: block;
        width: 100%;
    }
}
.webbook-basic-close {
    font: inherit;
    padding: .4rem .9rem;
    border: 1px solid currentColor;
    border-radius: 4px;
    background: var(--theme-bg);
    color: var(--theme-fg);
}

/* title-page.css */
.webbook-title-page {
    min-height: calc(100dvh - 7rem);
    display: grid;
    justify-items: center;
    align-content: center;
    gap: .75rem;
    padding: 2rem 1rem 5rem;
    text-align: center;
}
.webbook-title-cover {
    width: min(18rem, 80%);
    max-height: 55vh;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    border: 1px solid color-mix(in srgb, var(--theme-fg) 20%, transparent);
    border-radius: 6px;
    box-shadow: 0 1rem 2rem rgb(0 0 0 / 20%);
}
.webbook-title-kicker {
    margin: .5rem 0 0;
    color: var(--webbook-muted-fg);
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.webbook-title-page h1,
.webbook-title-page p {
    margin: 0;
}
.webbook-title-page p {
    max-width: 32rem;
}

/* narration-highlight.css */
/* synchronized narration highlight (highlight-settings.js): a background, an underline or both. The
   colors are worked out against the page behind the phrase; Mark/MarkText are the fallback. */
:root:not([data-webbook-highlight-style="underline"]) ::highlight(narration) {
    background-color: var(--webbook-highlight-bg, Mark);
    color: var(--webbook-highlight-fg, MarkText);
}
/* the text keeps its own color under an underline alone */
:root:is([data-webbook-highlight-style="underline"], [data-webbook-highlight-style="both"]) ::highlight(narration) {
    text-decoration: underline 3px var(--webbook-highlight-line, Mark);
    text-underline-offset: .2em;
}
/* with the background too, the underline falls below the background, on the page (its color is
   chosen for that, see highlightColors) */
:root[data-webbook-highlight-style="both"] ::highlight(narration) {
    text-underline-offset: .3em;
}
/* forced colors (Windows high contrast and the like): the system's own highlight colors */
@media (forced-colors: active) {
    :root ::highlight(narration) {
        background-color: Mark;
        color: MarkText;
        text-decoration-color: MarkText;
    }
}
::highlight(search) {
    background-color: var(--webbook-search-highlight-bg);
    color: var(--webbook-search-highlight-fg);
}

/* caption-mode.css */
/* caption mode */
:root.webbook-caption-mode main,
body.webbook-caption-mode main {
    opacity: 0;
    pointer-events: none;
}
#webbook-caption-view {
    display: none;
    position: fixed;
    inset: 0 0 4.75rem;
    z-index: 6;
    align-items: center;
    justify-content: center;
    padding: 4rem 1.5rem;
    background: var(--theme-bg);
    color: var(--theme-fg);
    text-align: center;
    overflow-y: auto;
    pointer-events: none;
}
body.webbook-caption-mode #webbook-caption-view {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
#webbook-caption-text {
    /* the text spacing settings (text-spacing.js); line length in the caption's own em, so it
       gives about as many characters a line as in the book's text */
    max-width: var(--webbook-line-length, 42rem);
    margin: 0;
    font-family: var(--webbook-main-font-family, system-ui);
    font-size: calc(2rem * var(--webbook-font-scale, 1));
    line-height: var(--webbook-line-height, 1.25);
    letter-spacing: var(--webbook-letter-spacing, normal);
    word-spacing: var(--webbook-word-spacing, normal);
}
@media(max-width: 45rem) {
    #webbook-caption-view {
        padding: 3rem 1rem;
    }
    #webbook-caption-text {
        font-size: calc(1.5rem * var(--webbook-font-scale, 1));
    }
}
/* Caption mode keeps working while the publisher design pauses text preferences. */
:root[data-webbook-appearance="published"] #webbook-caption-text {
    font-family: system-ui;
    line-height: 1.25;
    letter-spacing: normal;
    word-spacing: normal;
}

/* popover-base.css */
/* webbook's pop over screens */
.webbook[popover]:popover-open {
    box-sizing: border-box;
    background: var(--theme-bg);
    color: var(--theme-fg);
    overflow: scroll;
    border-radius: 5px;
    border: thin solid gray;

    &::backdrop {
        background: rgb(0 0 0 / 65%);
    }
}
body.webbook-dialog-backdrop-blur .webbook[popover]:popover-open::backdrop {
    backdrop-filter: blur(3px);
}
.webbook[popover]:popover-open > .webbook-popover-close {
    position: absolute;
    top: .5rem;
    right: .5rem;
    z-index: 4;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
}
.webbook-popover-close {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--theme-bg);
    color: var(--theme-fg);
    border: 1px solid color-mix(in srgb, var(--theme-fg) 30%, transparent);
    border-radius: 5px;
    cursor: pointer;
}
.webbook-popover-close svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* escapability.css */
/* escapability */
#webbook-escape-container {
    position: fixed;
    /* above the bottom toolbar, which appears on any touch and would otherwise cover it */
    bottom: calc(var(--webbook-toolbar-height, 8.5rem) + .75rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: .5rem;
    width: max-content;
    max-width: calc(100vw - 1.5rem);
}
#webbook-escape-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
#webbook-escape-btn {
    background: var(--webbook-chrome-bg);
    color: var(--webbook-chrome-fg);
    border: 2px solid var(--webbook-chrome-fg);
    border-radius: 2rem;
    min-height: 2.75rem;
    padding: .5rem 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: var(--size-step-0);
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgb(0 0 0 / 40%);
}

/* notes-in-place.css */
/* prompts floating above the toolbar: bordered and bold, so they stand out from the text */
#webbook-note-phrase-btn,
#webbook-back-to-text {
    background: var(--webbook-chrome-bg);
    color: var(--webbook-chrome-fg);
    border: 2px solid var(--webbook-chrome-fg);
    border-radius: 2rem;
    min-height: 2.75rem;
    padding: .5rem 1.25rem;
    font-size: var(--size-step-0);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgb(0 0 0 / 40%);
}
/* the key that does the same (showShortcutHint), for keyboards only */
.webbook-shortcut-hint {
    padding: .05rem .4rem;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-family: inherit;
    font-size: .8em;
    font-weight: 400;
}
@media (any-hover: none) {
    .webbook-shortcut-hint {
        display: none;
    }
}
#webbook-note-status { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#webbook-back-to-text { flex: 0 0 auto; }
#webbook-note-menu:popover-open { padding: .5rem; }
#webbook-note-menu h2 { font-size: 1rem; margin: .25rem .5rem .5rem; }
#webbook-note-menu ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .25rem; }
#webbook-note-menu button { width: 100%; text-align: start; padding: .5rem .75rem; }
.webbook-note-menu-label,
.webbook-note-menu-context { display: block; }
.webbook-note-menu-label { font-weight: 700; }
.webbook-note-menu-context { margin-block-start: .15rem; font-size: .9em; font-weight: 400; }
/* the reader's Back to text replaces a book's own back links while it shows */
.webbook-note-return main :is([role="doc-backlink"], .epubtype_backlink) { display: none; }

/* resume-banner.css */
/* "loaded last position" toast */
#webbook-resume-banner {
    position: fixed;
    top: 4.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    background: var(--webbook-chrome-bg);
    color: var(--webbook-chrome-fg);
    border-radius: 2rem;
    padding: .4rem 1rem;
    font-size: var(--size-step-0);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgb(0 0 0 / 40%);
}

/* what a shortcut or other reader action just did, shown for a few seconds (reader-actions.js);
   at the top, because Skip past is just above the bottom toolbar */
#webbook-action-notice {
    position: fixed;
    /* It's a popover (to show above open panels): undo the browser's popover position */
    inset: auto;
    margin-block: 0;
    top: calc(var(--webbook-top-toolbar-height, 4rem) + .75rem);
    /* Centered by its margins, not left: 50% and a transform: in a vertical book at phone width,
       left: 50% put it off the screen. It wraps long text rather than overflowing. */
    left: 1rem;
    right: 1rem;
    margin-inline: auto;
    z-index: 30;
    box-sizing: border-box;
    width: fit-content;
    max-width: min(40rem, calc(100% - 2rem));
    max-height: calc(100dvh - var(--webbook-top-toolbar-height, 4rem) - 1.5rem);
    overflow-y: auto;
    overflow-wrap: anywhere;
    writing-mode: horizontal-tb;
    background: var(--webbook-chrome-bg);
    color: var(--webbook-chrome-fg);
    border: 2px solid var(--webbook-chrome-fg);
    border-radius: 1rem;
    padding: .5rem 1rem;
    font-size: var(--size-step-0);
    text-align: center;
    box-shadow: 0 2px 8px rgb(0 0 0 / 40%);
    cursor: pointer;
}
#webbook-action-notice[hidden] {
    display: none;
}
/* Not the panels' backdrop (popover-base.css): the notice mustn't dim or blur the page or the
   panel it's about */
#webbook-action-notice:popover-open::backdrop {
    background: none;
    backdrop-filter: none;
}
#webbook-action-notice button {
    font: inherit;
    font-weight: 600;
    min-height: 2.75rem;
    padding: .25rem .65rem;
    margin-inline: .25rem;
    border: 1px solid currentColor;
    border-radius: .4rem;
    background: var(--theme-bg);
    color: var(--theme-fg);
    cursor: pointer;
}
#webbook-action-notice button:focus-visible {
    outline: 3px solid var(--webbook-focus-color);
    outline-offset: 3px;
}

/* spine-nav.css */
/* spine nav arrows — fixed in the viewport margins */
#webbook-spine-nav {
    position: fixed;
    top: 45vh;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    pointer-events: none;

    opacity: 0;
    transition: opacity 0.4s;

    /* Kept off the screen edges: with VoiceOver on, iOS puts the page's scroll bar along the right
       edge, and touching there found the scroll bar instead of the next-page arrow */
    a {
        pointer-events: auto;
        color: var(--theme-fg);
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 3rem;
        min-height: 3rem;
    }
    #webbook-previous-document {
        margin-left: max(.75rem, env(safe-area-inset-left));
    }
    #webbook-next-document {
        margin-left: auto;
        margin-right: max(.75rem, env(safe-area-inset-right));
    }
}
#webbook-spine-nav.visible,
#webbook-spine-nav:focus-within {
    opacity: 1;
}
/* small screens: in the top toolbar, at its left end, instead of floating over the text, which a
   phone has no margin to spare for */
@media (max-width: 45rem) {
    #webbook-spine-nav {
        top: 0;
        right: auto;
        z-index: 21;
        height: 4rem;
        align-items: center;
        gap: .25rem;
        padding-left: max(.5rem, env(safe-area-inset-left));

        a {
            /* on the toolbar background */
            color: var(--webbook-chrome-fg);
        }
        #webbook-previous-document,
        #webbook-next-document {
            margin: 0;
        }
    }
}

/* toc.css */
/* 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;
    }
}

/* settings-panel.css */
.webbook-appearance-hidden { display: none !important; }
#webbook-settings #webbook-publisher-appearance { margin: 0; padding: 0; border: 0; gap: .25rem; }
/* A hint, like the panel's "These settings apply to every book" */
#webbook-publisher-appearance-note { margin: .25rem 0 0; color: var(--webbook-muted-fg); }
#webbook-publisher-appearance-scope { margin: 0 0 .25rem; color: var(--webbook-muted-fg); }
#webbook-settings #webbook-publisher-appearance > div { display: flex; align-items: center; justify-content: flex-start; gap: .6rem; }
#webbook-publisher-appearance input { inline-size: 1.25rem; block-size: 1.25rem; }
#webbook-publisher-appearance label { padding-block: .5rem; }
/* Settings stay open, with headings for screen readers and links for short screens. */
#webbook-settings:popover-open {
    margin: 0;
    inset: 0 0 0 auto;
    width: min(36rem, 92vw);
    height: 100dvh;
    max-height: none;
    padding: 0 1.5rem 2rem;
    border-radius: 5px 0 0 5px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-padding-block: 1rem;
    overflow-wrap: anywhere;

    h2 {
        margin: 0 -1.5rem;
        padding: 1.25rem 3.75rem 1rem 1.5rem;
        border-bottom: var(--webbook-panel-border);
    }
    .webbook-settings-scope {
        margin: 1rem 0;
        color: var(--webbook-muted-fg);
    }
    /* Find a setting (settings-filter.js) */
    .webbook-settings-filter {
        display: grid;
        gap: .5rem;
        margin-bottom: 1.25rem;
        label { font-weight: 600; }
        input {
            box-sizing: border-box;
            width: 100%;
            min-height: 2.75rem;
            padding: .4rem .6rem;
            font: inherit;
            font-size: 1rem;
            background: var(--theme-bg);
            color: var(--theme-fg);
            border: 1px solid color-mix(in srgb, var(--theme-fg) 65%, var(--theme-bg));
            border-radius: 4px;
        }
        p { color: var(--webbook-muted-fg); }
        p:empty { display: none; }
    }
    .webbook-settings-filtered { display: none !important; }
    /* While filtering, the sections that are left are the list: Jump to and Back to top lead to
       hidden sections */
    &.webbook-settings-filtering :is(.webbook-settings-jump, .webbook-settings-top) { display: none; }
    &.webbook-settings-filtering .webbook-settings-section { padding-block: 1rem; }
    .webbook-settings-jump {
        padding-bottom: 1.25rem;
        border-bottom: var(--webbook-panel-border);
        p { margin: 0 0 .5rem; font-weight: 600; scroll-margin-block-start: 1rem; }
        ul {
            display: flex;
            flex-wrap: wrap;
            gap: .4rem .5rem;
            list-style: none;
            padding: 0;
            margin: 0;
        }
        a {
            display: inline-flex;
            align-items: center;
            font-size: 1rem;
            line-height: 1.5;
            min-height: 2.75rem;
            padding: .25rem .75rem;
            border: var(--webbook-panel-border);
            border-radius: 4px;
            color: var(--theme-fg);
            text-underline-offset: .2em;
        }
        a:hover { background: color-mix(in srgb, var(--theme-fg) 8%, var(--theme-bg)); }
    }
    .webbook-settings-section {
        padding-block: 1.5rem;
        border-bottom: var(--webbook-panel-border);
        &:last-child { border-bottom: none; padding-bottom: 0; }
    }
    /* Back to the Jump to list, at the end of each section */
    .webbook-settings-top {
        display: inline-flex;
        align-items: center;
        font-size: 1rem;
        line-height: 1.5;
        min-height: 2.75rem;
        margin-top: .75rem;
        color: var(--theme-fg);
        text-underline-offset: .2em;
    }
    h3 {
        margin: 0 0 1.25rem;
        font-size: 1.25rem;
        font-weight: 700;
        line-height: 1.4;
        scroll-margin-block-start: 1rem;
    }
    .webbook-settings-rows, fieldset {
        display: flex;
        flex-direction: column;
        gap: 1.25rem;
        min-width: 0;
    }
    fieldset {
        border: 0;
        padding: 0;
        margin: .25rem 0 0;
    }
    legend {
        margin-bottom: 1rem;
        padding: 0;
        font-size: 1rem;
        font-weight: 600;
    }
    /* Labels can wrap without pushing their controls beyond the panel. */
    .webbook-settings-rows > div, fieldset > div {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: .5rem 1rem;
        min-width: 0;
    }
    .webbook-settings-rows > div:has(> select), fieldset > div:has(> select) {
        grid-template-columns: minmax(0, 1fr) minmax(0, 60%);
    }
    .webbook-settings-rows > div:has(input[type=range]) {
        grid-template-columns: minmax(0, 1fr) auto auto;
        input[type=range] { grid-column: 1 / -1; grid-row: 2; width: 100%; }
        p { grid-column: 2; grid-row: 1; }
        button { grid-column: 3; grid-row: 1; }
    }
    #webbook-colors-custom p { grid-column: 1 / -1; }
    label, select, button, p { font-size: 1rem; line-height: 1.5; }
    label { cursor: pointer; }
    select, button, input[type=color] {
        background: var(--theme-bg);
        color: var(--theme-fg);
        border: 1px solid color-mix(in srgb, var(--theme-fg) 65%, var(--theme-bg));
        border-radius: 4px;
        min-height: 2.75rem;
        max-width: 100%;
    }
    select { width: 100%; min-width: 0; padding: .4rem; }
    input[type=color] { width: 2.75rem; height: 2.75rem; padding: .15rem; cursor: pointer; }
    input[type=checkbox] { width: 1.5rem; height: 1.5rem; justify-self: end; cursor: pointer; }
    input[type=range] { accent-color: var(--theme-fg); min-height: 1.5rem; margin: 0; }
    input:disabled { opacity: .5; cursor: not-allowed; }
    button { padding: .4rem .75rem; cursor: pointer; white-space: normal; }
    button:hover { background: color-mix(in srgb, var(--theme-fg) 8%, var(--theme-bg)); }
    p { margin: 0; }
    #webbook-font-size-value, #webbook-rate-value, #webbook-colors-contrast { color: var(--webbook-muted-fg); }
    :is(a, button, input, select):focus-visible, h3:focus {
        outline: 2px solid var(--webbook-focus-color);
        outline-offset: 3px;
    }
    .webbook-keyboard-shortcuts-row button { width: 100%; grid-column: 1 / -1; }
    #webbook-settings-transfer {
        grid-template-columns: minmax(0, 1fr);
        gap: .75rem;
    }
    #webbook-settings-reset-confirmation {
        display: flex;
        flex-wrap: wrap;
        gap: .75rem;
        border-inline-start: 3px solid var(--theme-fg);
        padding: .75rem;
        p { flex-basis: 100%; }
    }
    #webbook-settings-result:empty { display: none; }
    #webbook-settings-result { margin-top: .25rem; }
    /* Preserve the HTML hidden attribute even on flex/grid containers. */
    [hidden] { display: none; }
}
#webbook-settings:popover-open > .webbook-popover-close { background: var(--theme-bg); }

@media(max-width: 45rem) {
    #webbook-settings:popover-open {
        inset: 0;
        width: auto;
        height: auto;
        max-width: none;
        border: none;
        border-radius: 0;
    }
    /* Mobile panels cover the whole page, leaving no backdrop to blur. */
    #webbook-settings .webbook-settings-rows > div:has(#webbook-dialog-blur-toggle) { display: none; }
}
@media(max-width: 30rem) {
    #webbook-settings:popover-open {
        padding-inline: 1rem;
        h2 { margin-inline: -1rem; padding-inline-start: 1rem; }
        .webbook-settings-rows > div:has(> select), fieldset > div:has(> select) {
            grid-template-columns: minmax(0, 1fr);
        }
    }
}

/* keyboard-shortcuts.css */
#webbook-keyboard-shortcuts:popover-open {
    box-sizing: border-box;
    margin: 0;
    inset: 0 0 0 auto;
    width: min(34rem, 92vw);
    height: 100dvh;
    max-height: none;
    padding: 0 1.5rem 2rem;
    border-radius: 5px 0 0 5px;
    overflow-y: auto;
    color: var(--theme-fg);

    h2 {
        margin: 0 -1.5rem 1rem;
        padding: 1rem 3.75rem 1rem 1.5rem;
        border-bottom: var(--webbook-panel-border);
    }
    h3 {
        font-size: var(--size-step-1);
        margin: 1.5rem 0 .5rem;
    }
    ul {
        list-style: none;
        padding: 0;
        margin: 0 0 1rem;
    }
    li {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        gap: .5rem 1rem;
        padding-block: .75rem;
        border-bottom: var(--webbook-panel-border);
        overflow-wrap: anywhere;
    }
    .webbook-shortcut-find {
        display: grid;
        gap: .25rem;
        margin-block: 1rem;
        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;
        }
        p { margin: 0; font-size: .9rem; }
        p:empty { display: none; }
    }
    .webbook-shortcut-label {
        font-weight: 600;
    }
    .webbook-shortcut-keys {
        min-width: 0;
        text-align: right;
    }
    kbd {
        font: inherit;
    }
    .webbook-shortcut-controls {
        grid-column: 1 / -1;
        display: flex;
        flex-wrap: wrap;
        gap: .5rem;
    }
    button {
        min-width: 2.75rem;
        min-height: 2.75rem;
        max-width: 100%;
        padding: .2rem .75rem;
        background: none;
        color: var(--theme-fg);
        border: 1px solid gray;
        border-radius: 4px;
        font-size: var(--size-step-0);
        white-space: normal;
        overflow-wrap: anywhere;
        cursor: pointer;
    }
    p {
        grid-column: 1 / -1;
        margin: 0;
        color: var(--theme-fg);
        font-size: var(--size-step-0);
        text-align: left;
        overflow-wrap: anywhere;
    }
    .webbook-shortcut-instructions {
        margin-bottom: 1rem;
        color: var(--webbook-muted-fg);
    }
    .webbook-shortcut-conflict-warning {
        padding: .5rem;
        border-inline-start: .25rem solid var(--webbook-focus-color);
    }
    .webbook-shortcut-warning {
        font-size: .875rem;
    }
    #webbook-shortcut-status:empty {
        display: block;
        height: 0;
    }
    :is(button):focus-visible {
        outline: 2px solid var(--webbook-focus-color);
        outline-offset: 3px;
    }
}

@media(max-width: 45rem) {
    #webbook-keyboard-shortcuts:popover-open {
        inset: 0;
        width: auto;
        height: auto;
        max-width: none;
        border: none;
        border-radius: 0;
    }
}

@media(max-width: 22rem) {
    #webbook-keyboard-shortcuts:popover-open li {
        grid-template-columns: minmax(0, 1fr);
    }
    #webbook-keyboard-shortcuts:popover-open .webbook-shortcut-keys {
        text-align: left;
    }
}

/* info-panel.css */
/* webbook's about panel */
#webbook-info:popover-open {
    margin: 0;
    inset: 0 0 0 auto;
    /* Wide enough for its metadata and accessibility text; long values wrap rather than being cut
       off (user, 2026-11-16: "some text gets cut off") */
    width: min(30rem, 92vw);
    height: 100dvh;
    padding: 0;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    overflow: hidden;
    border-radius: 5px 0 0 5px;

    #webbook-cover {
        width: 100%;
        height: 100%;
        min-height: 0;
        object-fit: contain;
        display: block;
        border-bottom: var(--webbook-panel-border);
    }
    .webbook-info-body {
        overflow-wrap: anywhere;
        padding: 1.5rem;
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        min-height: 0;
        max-height: 100dvh;
        overflow-y: auto;
    }
    #webbook-cover[hidden] + .webbook-info-body {
        grid-row: 1 / -1;
    }
    h2 {
        margin: 0;
    }
    dl {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: .25rem 1.5rem;
        margin: 0;
    }
    dt {
        font-size: 0.75rem;
        font-weight: 600;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--webbook-muted-fg);
        padding-top: .15em;
    }
    dd {
        margin: 0;
        font-size: var(--size-step-0);
    }
    .webbook-cover-page-link {
        width: fit-content;
        border: 1px solid color-mix(in srgb, var(--theme-fg) 30%, transparent);
        border-radius: 4px;
        padding: .4rem .7rem;
        color: var(--theme-fg);
        background: var(--theme-bg);
        font-size: var(--size-step-0);
        font-weight: 600;
        text-decoration: none;
    }
    dt:not(:first-child) {
        margin-top: .75rem;
    }
    #webbook-progress {
        h3 {
            font-size: 0.75rem;
            font-weight: 600;
            letter-spacing: 0.08em;
            text-transform: uppercase;
            color: var(--webbook-muted-fg);
            margin: 0 0 .75rem;
        }
        p {
            margin: 0;
            font-size: var(--size-step-0);
        }
        progress {
            appearance: none;
            width: 100%;
            height: .75rem;
            margin: .75rem 0 .35rem;
            overflow: hidden;
            border: 1px solid var(--theme-fg);
            border-radius: 999px;
            background: var(--theme-bg);
            accent-color: var(--theme-fg);
        }
        progress::-webkit-progress-bar {
            background: var(--theme-bg);
        }
        progress::-webkit-progress-value {
            background: var(--theme-fg);
        }
        progress::-moz-progress-bar {
            background: var(--theme-fg);
        }
        #webbook-progress-count {
            color: var(--theme-fg);
            font-size: var(--size-step-0);
            font-weight: 700;
            text-align: end;
        }
    }
}
/* small screens */
@media(max-width: 45rem) {
    #webbook-info:popover-open {
        width: 100vw;
        border-radius: 0;
    }
}
/* The publication's accessibility information can be long: with it, the panel scrolls as a whole
   and the cover takes less of the height */
#webbook-info:popover-open:has(#webbook-accessibility) {
    display: block;
    overflow-y: auto;

    #webbook-cover {
        height: auto;
        max-height: 45vh;
    }
    /* One scrolling area, the panel, which has focusable controls; a body that also scrolled would
       be a scroll region keyboard users can't reach */
    .webbook-info-body {
        max-height: none;
        overflow: visible;
    }
}
#webbook-accessibility {
    border-top: var(--webbook-panel-border);
    padding-top: 1.25rem;

    h3 {
        margin: 0;
        font-size: 1.15rem;
    }
    .webbook-accessibility-source {
        margin: .25rem 0 0;
        font-size: .9rem;
    }
    h4 {
        margin: 1.1rem 0 .3rem;
        font-size: 1rem;
    }
    ul {
        margin: 0;
        padding-inline-start: 1.1rem;
    }
    li {
        margin-block: .25rem;
        line-height: 1.4;
        font-size: var(--size-step-0);
    }
}

/* toolbar.css */
/* Safari on iOS darkens whatever is tapped with its own gray box, which flashed dark over the time
   button on light pages. The reader's controls show their own state; focus keeps its outline. */
#webbook-toolbar,
#webbook-top-toolbar,
#webbook-spine-nav,
.webbook {
    -webkit-tap-highlight-color: transparent;
}
/* webbook's toolbar: the time and the timeline on their own rows, and large buttons under them */
#webbook-toolbar {
    --webbook-toolbar-button: 3rem;
    background: var(--webbook-chrome-bg);
    display: grid;
    /* the empty column after TOC balances the two buttons on the right, so play stays centered */
    grid-template-areas:
        'time time time time time time time time time'
        'seek seek seek seek seek seek seek seek seek'
        'toc . . prev play next . about settings';
    grid-template-columns:
        var(--webbook-toolbar-button) minmax(0, var(--webbook-toolbar-button)) 1fr
        auto auto auto
        1fr var(--webbook-toolbar-button) var(--webbook-toolbar-button);
    align-items: center;
    column-gap: 0;
    row-gap: .125rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    grid-area: toolbar;
    z-index: 20;

    padding: .5rem max(.5rem, env(safe-area-inset-right)) max(.5rem, env(safe-area-inset-bottom)) max(.5rem, env(safe-area-inset-left));

    opacity: 0;
    transition: opacity 0.4s;

    button {
        background: none;
        color: var(--webbook-chrome-fg);
        border: none;
        border-radius: 5px;
        min-width: var(--webbook-toolbar-button);
        min-height: var(--webbook-toolbar-button);
        padding: .5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
    button svg {
        width: 2rem;
        height: 2rem;
    }
    audio {
        display: none;
    }
    /* The groups span all the rows and hand their controls to the toolbar's own columns */
    #webbook-narration-position,
    #webbook-audio-controls {
        grid-row: 1 / 4;
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: subgrid;
        grid-template-rows: subgrid;
        align-items: center;
        /* it overlaps the toolbar's other buttons, so only its controls take clicks */
        pointer-events: none;
    }
    :is(#webbook-narration-position, #webbook-audio-controls) > * {
        pointer-events: auto;
    }
    :is(#webbook-narration-position, #webbook-audio-controls)[hidden] {
        display: none;
    }
    #webbook-previous-phrase {
        grid-area: prev;
    }
    #webbook-audio-playpause {
        grid-area: play;
        --webbook-toolbar-button: 3.75rem;
    }
    #webbook-audio-playpause svg {
        width: 2.5rem;
        height: 2.5rem;
    }
    #webbook-next-phrase {
        grid-area: next;
    }
    #webbook-audio-controls button:disabled {
        opacity: .45;
        cursor: default;
    }
    #webbook-seek {
        grid-area: seek;
        width: 100%;
        min-width: 0;
        min-height: 2rem;
        margin: 0;
        accent-color: var(--webbook-chrome-fg);
    }
    #webbook-book-timeline {
        grid-area: seek;
        position: relative;
        width: 100%;
        min-width: 0;
        min-height: 2rem;
        display: flex;
        align-items: center;

        #webbook-seek {
            width: 100%;
            position: relative;
            z-index: 2;
        }
    }
    #webbook-timeline-label {
        box-sizing: border-box;
        position: absolute;
        z-index: 5;
        bottom: calc(100% + .5rem);
        width: max-content;
        max-width: min(24rem, calc(100vw - 1rem));
        padding: .4rem .6rem;
        border: 2px solid var(--theme-fg);
        border-radius: 4px;
        background: var(--theme-bg);
        color: var(--theme-fg);
        font-size: .875rem;
        line-height: 1.25;
        text-align: center;
        overflow-wrap: anywhere;
        transform: translateX(-50%);
        box-shadow: 0 2px 8px rgb(0 0 0 / 35%);
        pointer-events: auto;
    }
    #webbook-time,
    #webbook-time-mode {
        grid-area: time;
        color: var(--webbook-chrome-fg);
        font-size: .875rem;
        font-variant-numeric: tabular-nums;
        line-height: 1.15;
        max-width: none;
        white-space: normal;
        text-wrap: balance;
        min-width: 0;
        min-height: 1.5rem;
        padding: 0 .5rem;
        justify-content: flex-end;
        text-align: end;
    }
    #webbook-time-mode[hidden] {
        display: none;
    }
    #webbook-time-mode #webbook-time {
        grid-area: auto;
        min-height: 0;
        max-width: none;
        padding: 0;
    }
    button[popovertarget=webbook-toc-nav] {
        grid-area: toc;
    }
    button[popovertarget=webbook-settings] {
        grid-area: settings;
    }
    button[popovertarget=webbook-info] {
        grid-area: about;
    }
    button[popovertarget].open {
        border: thin solid color-mix(in srgb, var(--webbook-chrome-fg) 45%, transparent);
    }
}
/* no narration on this page: one row of buttons */
#webbook-toolbar:not(:has(#webbook-audio-controls:not([hidden]))) {
    grid-template-areas: 'toc . about settings';
    grid-template-columns: auto 1fr auto auto;
}
#webbook-toolbar.visible,
#webbook-toolbar:focus-within {
    opacity: 1;
}
/* first on the page, shown when it has focus */
#webbook-skip-link {
    position: fixed;
    top: .5rem;
    left: max(.5rem, env(safe-area-inset-left));
    z-index: 40;
    padding: .75rem 1rem;
    border: 2px solid var(--webbook-chrome-fg);
    border-radius: 4px;
    background: var(--webbook-chrome-bg);
    color: var(--webbook-chrome-fg);
    font-size: var(--size-step-0);
    transform: translateY(calc(-100% - 1rem));
}
#webbook-skip-link:focus {
    transform: none;
}
/* top toolbar */
#webbook-top-toolbar {
    background: var(--webbook-chrome-bg);
    display: flex;
    justify-content: flex-end;
    position: sticky;
    top: 0;
    grid-area: topbar;
    padding: .5rem 0;
    z-index: 20;

    opacity: 0;
    transition: opacity 0.4s;

    button {
        background: none;
        color: var(--webbook-chrome-fg);
        border: none;
        border-radius: 5px;
        min-width: 3rem;
        min-height: 3rem;
        padding: .5rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
    button svg {
        width: 2rem;
        height: 2rem;
    }
    button[popovertarget].open {
        border: thin solid color-mix(in srgb, var(--webbook-chrome-fg) 45%, transparent);
    }
    #webbook-current-print-page {
        font-size: .875rem;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }
}
#webbook-top-toolbar.visible,
#webbook-top-toolbar:focus-within {
    opacity: 1;
}
/* shown only when the browser won't start narration on a new page by itself */
#webbook-continue-playing {
    position: fixed;
    left: 50%;
    bottom: 9rem;
    transform: translateX(-50%);
    z-index: 30;
    min-height: 3.5rem;
    padding: .75rem 1.5rem;
    border: 2px solid var(--webbook-chrome-fg);
    border-radius: 2rem;
    background: var(--webbook-chrome-bg);
    color: var(--webbook-chrome-fg);
    font: inherit;
    font-size: var(--size-step-1);
    font-weight: 700;
    box-shadow: 0 2px 8px rgb(0 0 0 / 40%);
    cursor: pointer;
}

/* motion.css */
@media (prefers-reduced-motion: reduce) {
    #webbook-spine-nav,
    #webbook-toolbar,
    #webbook-top-toolbar,
    main a[rel=bookmark].webbook {
        transition: none;
    }
}

/* menu-popover.css */
/* webbook's go-to-page popover — anchored top-left */
#webbook-menu:popover-open {
    display: flex;
    align-items: center;
    gap: .5rem;

    margin: 0;
    inset: 3.5rem .5rem auto auto;
    width: max-content;
    height: min-content;
    padding: .75rem 1rem;

    label {
        font-size: medium;
        color: var(--theme-fg);
        white-space: nowrap;
    }
    input {
        width: 5rem;
        font-size: medium;
    }
    input[aria-invalid="true"] {
        outline: 2px solid #c1121f;
        outline-offset: 2px;
    }
    button {
        background: none;
        border: none;
        color: var(--theme-fg);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }
    .webbook-popover-close {
        position: static;
        flex-shrink: 0;
        margin-left: .25rem;
        border: 1px solid color-mix(in srgb, var(--theme-fg) 30%, transparent);
        order: 10;
    }
}
/* small screens */
@media(max-width: 45rem) {
    #webbook-menu:popover-open {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        width: auto;
        height: auto;
        inset: 3.75rem .75rem auto .75rem;
        gap: .5rem;
        padding: 1rem;
        label {
            flex-basis: 100%;
            font-size: var(--size-step-1);
        }
        input {
            flex: 1;
            min-width: 0;
            min-height: 2.75rem;
            box-sizing: border-box;
            padding: .35rem .5rem;
            font-size: 1.25rem;
        }
        #webbook-goto-page-go,
        .webbook-popover-close {
            flex-shrink: 0;
            width: 2.75rem;
            height: 2.75rem;
            padding: 0;
            margin: 0;
        }
    }
}

/* search-popover.css */
/* webbook's search popover — anchored top-right */
#webbook-search:popover-open {
    margin: 0;
    inset: 3.5rem .5rem auto auto;
    width: min(420px, calc(100vw - 1rem));
    height: min-content;
    padding: 1.25rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;

    h2 {
        margin: 0 0 .25rem;
        padding-right: 3.25rem;
        font-size: var(--size-step-1, 1.125rem);
    }
    #webbook-search-form {
        display: flex;
        gap: .5rem;
        align-items: center;
        input {
            flex: 1;
            min-width: 0;
            font-size: medium;
            padding: .3rem .5rem;
            border: 1px solid gray;
            border-radius: 4px;
            background: var(--theme-bg);
            color: var(--theme-fg);
        }
        button {
            background: none;
            border: none;
            color: var(--theme-fg);
            display: flex;
            align-items: center;
            cursor: pointer;
            padding: .3rem;
        }
    }
    #webbook-search-results {
        margin: 0;
        padding: 0;
        list-style: none;
        max-height: 50vh;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: .5rem;
        li {
            min-width: 0;
        }
        a {
            display: block;
            padding: .75rem;
            border: 1px solid color-mix(in srgb, var(--theme-fg) 25%, transparent);
            border-radius: 5px;
            color: var(--theme-fg);
            text-decoration: none;
            overflow-wrap: anywhere;
        }
        a:hover {
            border-color: var(--webbook-focus-color);
        }
        a:focus-visible {
            outline: 2px solid var(--webbook-focus-color);
            outline-offset: 2px;
        }
        mark {
            background: Mark;
            color: MarkText;
        }
    }
    #webbook-search-status {
        margin: 0;
        min-height: 1.5em;
        color: var(--webbook-muted-fg);
        font-size: var(--size-step-0);
    }
    .webbook-search-context,
    .webbook-search-snippet {
        display: block;
    }
    .webbook-search-context {
        margin-bottom: .25rem;
        color: var(--webbook-muted-fg);
        font-size: .875rem;
    }
}
/* small screens */
@media(max-width: 45rem) {
    #webbook-search:popover-open {
        inset: 0;
        width: 100vw;
        height: 100dvh;
        padding: 0;
        border-radius: 0;
        gap: 0;
        h2 {
            margin: 0;
            padding: 1rem 3.75rem 1rem 1rem;
            border-bottom: var(--webbook-panel-border);
            font-size: var(--size-step-2);
        }
        #webbook-search-form {
            padding: 1rem;
            border-bottom: var(--webbook-panel-border);
            input {
                min-width: 0;
                min-height: 2.75rem;
                font-size: 1.125rem;
            }
            button {
                min-width: 2.75rem;
                min-height: 2.75rem;
                border: 1px solid color-mix(in srgb, var(--theme-fg) 30%, transparent);
                border-radius: 5px;
                justify-content: center;
            }
        }
        #webbook-search-results {
            flex: 1;
            min-height: 0;
            max-height: none;
            padding: 1rem;
        }
        #webbook-search-status {
            padding: .75rem 1rem 0;
        }
    }
}

/* copy-content.css */
/* Copy controls follow the expression/listing, never float over its content. The source can
   scroll if a two-dimensional equation or a long code line can't reflow. */
main .webbook-copy-unit {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
    max-width: 100%;
    min-width: 0;
    vertical-align: middle;
}
main .webbook-copy-source {
    display: inline-block;
    box-sizing: border-box;
    padding: .25rem;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
}
main .webbook-copy-code {
    display: flex;
    /* A long pre must not become the grid's intrinsic minimum width. */
    contain: inline-size;
    margin-block: 1em;
    pre { max-width: 100%; min-width: 0; overflow-x: auto; margin: 0; }
}
main .webbook-copy-button {
    flex: 0 0 auto;
    display: inline-grid;
    place-items: center;
    box-sizing: border-box;
    min-width: 2rem;
    min-height: 2rem;
    padding: .25rem;
    border: 1px solid var(--theme-fg);
    border-radius: 4px;
    background: var(--theme-bg);
    color: var(--theme-fg);
    font: 400 .875rem/1.4 system-ui, sans-serif;
    cursor: pointer;
    user-select: none;
}
/* A copy icon (two sheets, like the reader's other icons), drawn by CSS so the book's text gets no
   word; the button's name is its aria-label and title (user, 2026-11-11: an icon, not "Copy") */
main .webbook-copy-button::before {
    content: '';
    width: 1.25rem;
    height: 1.25rem;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5.503 4.627 5.5 6.75v10.504a3.25 3.25 0 0 0 3.25 3.25h8.616a2.251 2.251 0 0 1-2.122 1.5H8.75A4.75 4.75 0 0 1 4 17.254V6.75c0-.98.627-1.815 1.503-2.123ZM17.75 2A2.25 2.25 0 0 1 20 4.25v13a2.25 2.25 0 0 1-2.25 2.25h-9a2.25 2.25 0 0 1-2.25-2.25v-13A2.25 2.25 0 0 1 8.75 2h9Zm0 1.5h-9a.75.75 0 0 0-.75.75v13c0 .414.336.75.75.75h9a.75.75 0 0 0 .75-.75v-13a.75.75 0 0 0-.75-.75Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
@media (forced-colors: active) {
    main .webbook-copy-button::before { forced-color-adjust: none; background: ButtonText; }
}
@media (hover: hover) and (pointer: fine) {
    main .webbook-copy-button { opacity: 0; }
    main .webbook-copy-unit:hover .webbook-copy-button,
    main .webbook-copy-unit:focus-within .webbook-copy-button { opacity: 1; }
}
main math:focus-visible,
main [data-webbook-copy-scroll]:focus-visible,
main .webbook-copy-button:focus-visible {
    outline: 2px solid var(--webbook-focus-color);
    outline-offset: 3px;
}

/* equations.css */
/* A semantic equation/number pair, identified during conversion without publisher classes.
   Grid placement changes the visual order only; the publication's DOM order stays intact. */
main math {
    max-width: 100%;
}
/* Only an equation wider than its line scrolls: responsive-equations.js marks it and gives it a Tab
   stop. Scrolling every inline equation (as overflow-x: auto did) also made each one scroll
   vertically by the height of its glyphs, so nearly every equation needed a Tab stop. */
main math[data-webbook-math-wide] {
    overflow-x: auto;
}
/* Display equations already have an outer scrolling region. Keep their natural
   width inside it instead of nesting another scrollbar on the MathML root. */
main :is(table, .webbook-equation-scroll, .webbook-copy-source) math {
    max-width: none;
    overflow: visible;
}
main .webbook-equation {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: .5em .75em;
    max-width: 100%;
    min-width: 0;
    margin-block: 1em;
    container-type: inline-size;
}
main .webbook-equation-number {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    white-space: nowrap;
}
main .webbook-equation-scroll {
    display: block;
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    max-width: 100%;
    overflow-x: auto;
    text-align: center;
    padding-block: .25em;
}
main .webbook-equation-scroll:focus-visible {
    outline: 3px solid var(--webbook-focus-color);
    outline-offset: 2px;
}
main .webbook-equation[data-webbook-equation-stacked] > .webbook-equation-number {
    grid-column: 1 / -1;
    grid-row: 2;
}
main .webbook-equation[data-webbook-equation-stacked] > .webbook-equation-scroll {
    grid-column: 1 / -1;
}
/* Useful even without JavaScript, and follows the containing equation's font size. */
@container (max-width: 30em) {
    main .webbook-equation-number { grid-column: 1 / -1; grid-row: 2; }
    main .webbook-equation-scroll { grid-column: 1 / -1; }
}

/* writing-modes.css */
:root:not([data-webbook-appearance="published"]) {
/* Writing modes and the book's writing styles (plan 28). The converter keeps what a book states
   about how its text is written (its -epub- properties and their standard forms) as these
   classes and <html> data attributes; this is the standard CSS for them. */

/* --- The book's writing styles --- */
/* Tate-chū-yoko: a few characters (usually digits) set side by side in a vertical line */
.webbook-style-combine {
    -webkit-text-combine: horizontal;
    text-combine-upright: all;
}
.webbook-style-combine-none {
    -webkit-text-combine: none;
    text-combine-upright: none;
}
.webbook-style-glyphs-upright { text-orientation: upright; }
.webbook-style-glyphs-sideways { text-orientation: sideways; }
.webbook-style-glyphs-mixed { text-orientation: mixed; }

/* Emphasis marks (bōten): beside each character, the East Asian counterpart of italics. In the
   text's color: the reader's colors own color, and marks in another color could fail contrast. */
.webbook-style-emphasis-dot { -webkit-text-emphasis-style: filled dot; text-emphasis-style: filled dot; }
.webbook-style-emphasis-dot-open { -webkit-text-emphasis-style: open dot; text-emphasis-style: open dot; }
.webbook-style-emphasis-circle { -webkit-text-emphasis-style: filled circle; text-emphasis-style: filled circle; }
.webbook-style-emphasis-circle-open { -webkit-text-emphasis-style: open circle; text-emphasis-style: open circle; }
.webbook-style-emphasis-double-circle { -webkit-text-emphasis-style: filled double-circle; text-emphasis-style: filled double-circle; }
.webbook-style-emphasis-double-circle-open { -webkit-text-emphasis-style: open double-circle; text-emphasis-style: open double-circle; }
.webbook-style-emphasis-triangle { -webkit-text-emphasis-style: filled triangle; text-emphasis-style: filled triangle; }
.webbook-style-emphasis-triangle-open { -webkit-text-emphasis-style: open triangle; text-emphasis-style: open triangle; }
.webbook-style-emphasis-sesame { -webkit-text-emphasis-style: filled sesame; text-emphasis-style: filled sesame; }
.webbook-style-emphasis-sesame-open { -webkit-text-emphasis-style: open sesame; text-emphasis-style: open sesame; }
.webbook-style-emphasis-filled { -webkit-text-emphasis-style: filled; text-emphasis-style: filled; }
.webbook-style-emphasis-open { -webkit-text-emphasis-style: open; text-emphasis-style: open; }
.webbook-style-emphasis-none { -webkit-text-emphasis-style: none; text-emphasis-style: none; }
[class*="webbook-style-emphasis-"] {
    -webkit-text-emphasis-color: currentColor;
    text-emphasis-color: currentColor;
}
.webbook-style-emphasis-over { -webkit-text-emphasis-position: over right; text-emphasis-position: over right; }
.webbook-style-emphasis-under { -webkit-text-emphasis-position: under right; text-emphasis-position: under right; }
.webbook-style-emphasis-left { -webkit-text-emphasis-position: over left; text-emphasis-position: over left; }
.webbook-style-emphasis-under-left { -webkit-text-emphasis-position: under left; text-emphasis-position: under left; }
/* Full-width forms of letters and digits (Chrome doesn't support it, and shows them as they are) */
.webbook-style-fullwidth { text-transform: full-width; }

}
.webbook-style-horizontal { writing-mode: horizontal-tb; }
.webbook-style-vertical-rl { writing-mode: vertical-rl; }
.webbook-style-vertical-lr { writing-mode: vertical-lr; }

/* A language's line-breaking rules, for the whole page */
:root[data-webbook-line-break="strict"] main { line-break: strict; }
:root[data-webbook-line-break="loose"] main { line-break: loose; }
:root[data-webbook-line-break="anywhere"] main { line-break: anywhere; }
:root[data-webbook-word-break="keep-all"] main { word-break: keep-all; }
:root[data-webbook-word-break="break-all"] main { word-break: break-all; }

/* --- Vertical text --- */
/* The page itself is vertical, so it scrolls sideways from the start of the text and the
   browser's own scrolling, Find and scroll-into-view work. Everything but the text (toolbars,
   arrows, panels, notices) stays horizontal. html.webbook-vertical is set by the head script
   before the first paint, from the book's writing mode and the Writing direction setting. */
:root.webbook-vertical,
:root.webbook-vertical body {
    writing-mode: vertical-rl;
}
:root.webbook-vertical.webbook-vertical-lr,
:root.webbook-vertical.webbook-vertical-lr body {
    writing-mode: vertical-lr;
}
:root.webbook-vertical body > :not(main) {
    writing-mode: horizontal-tb;
}
:root.webbook-vertical {
    scroll-padding: 0 1rem;
}
:root.webbook-vertical body {
    display: block;
    min-height: 0;
    height: 100dvh;
}
/* In the flow beside the text otherwise */
:root.webbook-vertical #webbook-top-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
}
:root.webbook-vertical main {
    /* The column height is the Line length setting, centered between the toolbars. Padding
       percentages are of the page's height here (its inline size). */
    --webbook-column-top: calc(var(--webbook-top-toolbar-height, 4rem) + 1rem);
    --webbook-column-bottom: calc(var(--webbook-toolbar-height, 8.5rem) + 1rem);
    box-sizing: border-box;
    width: auto;
    max-width: none;
    height: 100%;
    margin: 0;
    padding-block: 0;
    padding-inline-start: max(var(--webbook-column-top), calc((100% - var(--webbook-column-length, 100%)) / 2));
    padding-inline-end: max(var(--webbook-column-bottom), calc((100% - var(--webbook-column-length, 100%)) / 2));
    /* a margin at the start, and room to finish reading at the end */
    padding-block-start: max(1rem, env(safe-area-inset-right));
    padding-block-end: max(3rem, env(safe-area-inset-left));
}
/* Each character is about 1em tall, so the steps are characters a column */
:root:not([data-webbook-appearance="published"]).webbook-vertical[data-webbook-line-length="narrow"] main { --webbook-column-length: 20em; }
:root.webbook-vertical:not([data-webbook-line-length]) main,
:root:not([data-webbook-appearance="published"]).webbook-vertical[data-webbook-line-length="medium"] main { --webbook-column-length: 30em; }
:root:not([data-webbook-appearance="published"]).webbook-vertical[data-webbook-line-length="wide"] main { --webbook-column-length: 100%; }
:root.webbook-vertical main {
    img, svg, video {
        max-width: none;
        max-height: 100%;
        width: auto;
        height: auto;
    }
    table {
        width: auto;
    }
}
/* The page arrows go in the top toolbar, as on a phone: beside vertical text they would sit on
   it, since it runs the whole width of the window */
:root.webbook-vertical {
    --webbook-page-arrow-gutter: 0px;
}
:root.webbook-vertical #webbook-spine-nav {
    top: 0;
    right: auto;
    z-index: 21;
    height: 4rem;
    align-items: center;
    gap: .25rem;
    padding-left: max(.5rem, env(safe-area-inset-left));

    a {
        color: var(--webbook-chrome-fg);
    }
    #webbook-previous-document,
    #webbook-next-document {
        margin: 0;
    }
}
@media (max-width: 45rem) {
    :root.webbook-vertical main {
        padding-left: 0;
        padding-right: 0;
    }
}

/* --- Page progression right to left (Japanese, Arabic, Hebrew books) --- */
/* Next page is on the left, as the book's pages turn. Not when the reader has set a vertical book
   horizontal (user, 2026-11-13: "the arrows should look correct"): horizontal text turns pages left
   to right. A horizontal right-to-left book (Arabic, Hebrew) keeps its direction. */
:root[data-webbook-page-progression="rtl"]:not([data-webbook-writing-mode^="vertical"]:not(.webbook-vertical)) #webbook-spine-nav {
    flex-direction: row-reverse;

    #webbook-previous-document {
        margin-left: 0;
        margin-right: max(.75rem, env(safe-area-inset-right));
    }
    #webbook-next-document {
        margin-left: max(.75rem, env(safe-area-inset-left));
        margin-right: auto;
    }
    a svg {
        transform: scaleX(-1);
    }
}
@media (max-width: 45rem) {
    :root[data-webbook-page-progression="rtl"]:not([data-webbook-writing-mode^="vertical"]:not(.webbook-vertical)) #webbook-spine-nav {
        #webbook-previous-document,
        #webbook-next-document {
            margin: 0;
        }
    }
}

/* book-styles.css */
:root:not([data-webbook-appearance="published"]) {
/* Meaningful publisher styles translated into reader-controlled classes. */
.webbook-style-italic { font-style: italic; }
.webbook-style-not-italic { font-style: normal; }
.webbook-style-bold { font-weight: 700; }
.webbook-style-unbold { font-weight: 400; }
.webbook-style-small-caps { font-variant-caps: small-caps; }
.webbook-style-no-small-caps { font-variant-caps: normal; }
.webbook-style-underline { text-decoration-line: underline; }
.webbook-style-strike { text-decoration-line: line-through; }
.webbook-style-underline.webbook-style-strike { text-decoration-line: underline line-through; }
.webbook-style-super { vertical-align: super; font-size: .8em; }
.webbook-style-sub { vertical-align: sub; font-size: .8em; }
.webbook-style-center { text-align: center; }
.webbook-style-end { text-align: end; }
.webbook-style-start { text-align: start; }
.webbook-style-indent-1 { margin-inline-start: min(1em, 20%); }
.webbook-style-indent-2 { margin-inline-start: min(2em, 20%); }
.webbook-style-indent-3 { margin-inline-start: min(3em, 20%); }
.webbook-style-indent-4 { margin-inline-start: min(4em, 20%); }
.webbook-style-hang { padding-inline-start: min(2em, 20%); text-indent: calc(-1 * min(2em, 20%)); --webbook-text-indent: 0px; }
.webbook-style-pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.webbook-style-uppercase { text-transform: uppercase; }
.webbook-style-uppercase.webbook-style-fullwidth { text-transform: uppercase full-width; }
.webbook-style-no-transform { text-transform: none; }
.webbook-style-list-upper-roman { list-style-type: upper-roman; }
.webbook-style-list-lower-roman { list-style-type: lower-roman; }
.webbook-style-list-upper-alpha { list-style-type: upper-alpha; }
.webbook-style-list-lower-alpha { list-style-type: lower-alpha; }
.webbook-style-list-none { list-style-type: none; }
.webbook-style-list-decimal { list-style-type: decimal; }
.webbook-style-list-disc { list-style-type: disc; }
.webbook-style-list-circle { list-style-type: circle; }
.webbook-style-list-square { list-style-type: square; }
.webbook-box, main .epubtype_sidebar {
    border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
    background-color: color-mix(in srgb, var(--theme-fg) 5%, var(--theme-bg));
    padding: 1em; margin-block: 1em; margin-inline: 0; box-sizing: border-box; max-inline-size: 100%;
    overflow-wrap: anywhere;
}
@media (forced-colors: active) {
    .webbook-box, main .epubtype_sidebar { border-color: CanvasText; background: Canvas; color: CanvasText; }
}

.webbook-style-no-text-indent { text-indent: 0; --webbook-text-indent: 0px; }
.webbook-style-text-indent-1 { text-indent: min(1em, 20%); --webbook-text-indent: min(1em, 20%); }
.webbook-style-padding-1 { padding-inline-start: min(1em, 20%); }
.webbook-style-text-indent-2 { text-indent: min(2em, 20%); --webbook-text-indent: min(2em, 20%); }
.webbook-style-padding-2 { padding-inline-start: min(2em, 20%); }
.webbook-style-text-indent-3 { text-indent: min(3em, 20%); --webbook-text-indent: min(3em, 20%); }
.webbook-style-padding-3 { padding-inline-start: min(3em, 20%); }
.webbook-style-text-indent-4 { text-indent: min(4em, 20%); --webbook-text-indent: min(4em, 20%); }
.webbook-style-padding-4 { padding-inline-start: min(4em, 20%); }

/* An inline image can fill a paragraph's width, so its first-line indent must be
   deducted from that space. Otherwise a formula/thumbnail overflows at large text. */
main :is(img, svg, video):not(.webbook-copy-button *, a.webbook *) {
    max-inline-size: min(100%, calc(100% - var(--webbook-text-indent, 0px)));
}

/* Physical publisher sides remain physical in RTL and vertical text. */
.webbook-style-left { text-align: left; }
.webbook-style-right { text-align: right; }
.webbook-style-margin-left-1 { margin-left: min(1em, 20%); }
.webbook-style-padding-left-1 { padding-left: min(1em, 20%); }
.webbook-style-margin-left-2 { margin-left: min(2em, 20%); }
.webbook-style-padding-left-2 { padding-left: min(2em, 20%); }
.webbook-style-margin-left-3 { margin-left: min(3em, 20%); }
.webbook-style-padding-left-3 { padding-left: min(3em, 20%); }
.webbook-style-margin-left-4 { margin-left: min(4em, 20%); }
.webbook-style-padding-left-4 { padding-left: min(4em, 20%); }
.webbook-publisher-only { display: none !important; }
}
.webbook-style-hidden { display: none !important; }
.webbook-style-invisible { visibility: hidden !important; }
.webbook-style-visible { visibility: visible !important; }

/* offline.css */
#webbook-offline {
    border-top: var(--webbook-panel-border);
    padding-top: 1rem;
    font-size: 1rem;
    line-height: 1.5;
    h3 { font-size: 1.15rem; margin: 0 0 .75rem; }
    p { margin-block: .5rem; }
    progress { width: 100%; accent-color: var(--theme-fg); }
    .webbook-offline-controls { display: flex; flex-wrap: wrap; gap: .5rem; }
    button { font: inherit; min-height: 2.75rem; border: 1px solid var(--theme-fg); border-radius: 4px; padding: .4rem .7rem; color: var(--theme-fg); background: var(--theme-bg); cursor: pointer; }
    button:disabled { opacity: .6; cursor: default; }
    #webbook-offline-storage { font-size: .9rem; }
}
#webbook-offline-indicator { font: 600 .875rem system-ui, sans-serif; padding: .35rem .6rem; }

/* dialog-surfaces.css */
/* Reader dialogs share three levels: panel, section and confirmation. Derive
   surfaces from the reader colors so every color choice keeps the same hierarchy. */
:root {
    --webbook-panel-surface: color-mix(in srgb, var(--theme-fg) 4%, var(--theme-bg));
    --webbook-panel-raised: color-mix(in srgb, var(--theme-fg) 8%, var(--theme-bg));
    --webbook-panel-edge: color-mix(in srgb, var(--theme-fg) 32%, var(--theme-bg));
    --webbook-panel-shadow: 0 12px 40px rgb(0 0 0 / 28%), 0 2px 8px rgb(0 0 0 / 18%);
}
.webbook[popover]:popover-open {
    border: 1px solid var(--webbook-panel-edge);
    border-radius: .75rem;
    box-shadow: var(--webbook-panel-shadow);
    overflow: auto;
    /* Muted text must still contrast on the slightly deeper section surfaces. */
    --webbook-muted-fg: color-mix(in srgb, var(--theme-fg) 78%, var(--theme-bg));
}
:is(#webbook-info, #webbook-settings, #webbook-keyboard-shortcuts):popover-open {
    border-radius: .75rem 0 0 .75rem;
}
#webbook-toc-nav:popover-open { border-radius: 0 .75rem .75rem 0; }
:is(#webbook-settings, #webbook-keyboard-shortcuts):popover-open h2,
#webbook-toc-nav:popover-open #webbook-toc-header {
    background: var(--webbook-panel-surface);
    border-bottom-color: var(--webbook-panel-edge);
    box-shadow: 0 2px 5px rgb(0 0 0 / 5%);
}
#webbook-info:popover-open h2 {
    padding: .75rem 2.75rem .75rem 1rem;
    margin: -.25rem -.5rem 0;
    border-radius: .5rem;
    background: var(--webbook-panel-surface);
    border-bottom: var(--webbook-panel-border);
}
#webbook-settings:popover-open .webbook-settings-section {
    margin-block: 1rem;
    padding: 1rem;
    border: var(--webbook-panel-border);
    border-radius: .6rem;
    background: var(--webbook-panel-surface);
    box-shadow: 0 1px 2px rgb(0 0 0 / 7%);
}
#webbook-info:popover-open :is(#webbook-offline, #webbook-accessibility, #webbook-progress, #webbook-reader-updates) {
    padding: 1rem;
    border: var(--webbook-panel-border);
    border-radius: .6rem;
    background: var(--webbook-panel-surface);
    box-shadow: 0 1px 2px rgb(0 0 0 / 7%);
}
.webbook[popover]:popover-open .webbook-popover-close {
    border: 1px solid var(--webbook-panel-edge);
    border-radius: .5rem;
    background: var(--theme-bg);
    box-shadow: 0 2px 4px rgb(0 0 0 / 12%);
}
.webbook[popover]:popover-open .webbook-popover-close:hover {
    background: var(--webbook-panel-raised);
}
.webbook[popover] :is(button, a, input, select):focus-visible {
    outline: 3px solid var(--webbook-focus-color);
    outline-offset: 3px;
}
/* Inline confirmation is a separate decision, visibly nested within the panel. */
:is(#webbook-offline, #webbook-settings) .webbook-confirmation {
    margin-block-start: 1rem;
    padding: 1rem;
    border: 1px solid var(--webbook-panel-edge);
    border-inline-start: 4px solid var(--theme-fg);
    border-radius: .5rem;
    background: var(--theme-bg);
    box-shadow: 0 3px 10px rgb(0 0 0 / 14%);
    p { margin: 0 0 1rem; line-height: 1.5; font-weight: 600; }
    button { margin-block: .25rem; margin-inline-end: .5rem; }
}
#webbook-offline #webbook-offline-remove-confirm,
#webbook-settings #webbook-settings-reset-confirm {
    background: var(--theme-fg);
    color: var(--theme-bg);
    font-weight: 600;
}
@media (max-width: 45rem) {
    :is(#webbook-info, #webbook-settings, #webbook-keyboard-shortcuts, #webbook-toc-nav):popover-open { border-radius: 0; }
}
@media (forced-colors: active) {
    .webbook[popover]:popover-open,
    :is(#webbook-offline, #webbook-settings) .webbook-confirmation { border: 2px solid CanvasText; }
}
#webbook-reader-updates h3 { margin: 0 0 .5rem; font-size: 1.15rem; }
#webbook-reader-updates p { margin: 0 0 .75rem; }
#webbook-reader-updates button {
    font: inherit;
    min-height: 2.75rem;
    padding: .5rem .75rem;
    border: 1px solid var(--theme-fg);
    border-radius: .4rem;
    color: var(--theme-fg);
    background: var(--theme-bg);
    cursor: pointer;
}

