/* Shared reflow text / tiled original PDF comparison layout. */
#reader-view.paged-mode #book-viewport.pdf-paged-viewport {
    width: min(calc(var(--max-width) * 2), calc(100vw - var(--page-gutter, 40px)));
    display: block;
    overflow-y: auto;
}

#reader-view.paged-mode #book-viewport.pdf-paged-viewport #book-content {
    height: auto !important;
    width: auto !important;
    column-width: auto !important;
    column-gap: normal !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
}

#reader-view.paged-mode .pdf-page {
    display: none !important;
}

#reader-view.paged-mode .pdf-page.active-pdf-page {
    display: block !important;
    margin: 0 auto;
}

.pdf-page {
    width: 100%;
}

#book-content.pdf-content {
    max-width: min(calc(var(--max-width) * 2), calc(100vw - var(--page-gutter, 40px))) !important;
    padding: 24px !important;
}

#book-content.pdf-content[data-pdf-layout="text-only"],
#reader-view.paged-mode #book-viewport.pdf-paged-viewport:has([data-pdf-layout="text-only"]) {
    max-width: min(var(--max-width), calc(100vw - var(--page-gutter, 40px))) !important;
}

#reader-view.paged-mode #book-viewport.pdf-paged-viewport:has([data-pdf-layout="original-only"]) {
    max-width: min(calc(var(--max-width) * 1.4), calc(100vw - var(--page-gutter, 40px))) !important;
}

/* Continuous single-scroll "original-only" view: all pages stacked vertically under one window scroll. */
html:has(#reader-view:not(.paged-mode) #book-content[data-pdf-layout="original-only"]),
body:has(#reader-view:not(.paged-mode) #book-content[data-pdf-layout="original-only"]) {
    overflow-x: auto;
}

#reader-view:not(.paged-mode) #reader-container:has(#book-content[data-pdf-layout="original-only"]) {
    padding: 16px 0 90px;
    width: max-content;
    min-width: 100%;
}

#reader-view:not(.paged-mode) #book-content.pdf-content[data-pdf-layout="original-only"] {
    max-width: none !important;
    width: max-content;
    min-width: 100%;
    padding: 0 16px !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
}

#book-content.pdf-content[data-pdf-layout="text-only"],
#reader-view.paged-mode #book-viewport.pdf-paged-viewport:has([data-pdf-layout="text-only"]) #book-content {
    padding-left: var(--side-padding, 80px) !important;
    padding-right: var(--side-padding, 80px) !important;
}

.pdf-page-comparison {
    overflow: visible;
}

.pdf-page-columns {
    display: grid;
    grid-template-columns: minmax(0, var(--pdf-left-fr, 0.465fr)) 24px minmax(0, var(--pdf-right-fr, 0.535fr));
    align-items: start;
    gap: 8px;
}

.pdf-page-image-column {
    grid-column: 1;
    grid-row: 1;
    position: sticky;
    top: 60px;
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    min-width: 0;
    min-height: 0;
}

.pdf-page-text {
    grid-column: 3;
    grid-row: 1;
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    min-height: calc(100vh - 180px);
    padding-inline: clamp(10px, calc(var(--side-padding, 80px) * 0.45), 48px);
}

[data-pdf-layout="text-left"] .pdf-page-image-column {
    grid-column: 3;
    padding-bottom: 70px;
}

[data-pdf-layout="text-left"] .pdf-page-text {
    grid-column: 1;
}

.pdf-splitter {
    grid-column: 2;
    grid-row: 1;
    align-self: stretch;
    min-height: 180px;
    position: relative;
    cursor: col-resize;
    touch-action: none;
    user-select: none;
    border-radius: 6px;
}

.pdf-splitter::after {
    content: "";
    position: absolute;
    width: 3px;
    top: 0;
    bottom: 0;
    left: calc(50% - 1.5px);
    background: var(--ui-border);
    border-radius: 3px;
}

.pdf-splitter:hover::after,
.pdf-splitter:focus-visible::after {
    background: var(--ui-primary);
}

.pdf-splitter:focus-visible {
    outline: 2px solid var(--ui-primary);
    outline-offset: 1px;
}

.pdf-split-dragging,
.pdf-split-dragging * {
    cursor: col-resize !important;
    user-select: none !important;
}

[data-pdf-layout="text-only"] .pdf-page-columns,
[data-pdf-layout="original-only"] .pdf-page-columns {
    display: block;
    min-width: 0;
}

[data-pdf-layout="text-only"] .pdf-page-image-column,
[data-pdf-layout="text-only"] .pdf-splitter,
[data-pdf-layout="original-only"] .pdf-page-text,
[data-pdf-layout="original-only"] .pdf-splitter {
    display: none;
}

[data-pdf-layout="original-only"] .pdf-image-footer {
    display: none;
}

#reader-view:not(.paged-mode) [data-pdf-layout="original-only"] .pdf-page {
    width: auto;
    display: flex;
    justify-content: center;
}

#reader-view:not(.paged-mode) [data-pdf-layout="original-only"] .pdf-page-comparison,
#reader-view:not(.paged-mode) [data-pdf-layout="original-only"] .pdf-page-columns {
    width: auto;
}

#reader-view:not(.paged-mode) [data-pdf-layout="original-only"] .pdf-page-image-column {
    position: relative;
    top: auto;
    height: auto;
    width: auto;
    padding: 0;
    margin-bottom: 16px;
    background: transparent !important;
}

#reader-view:not(.paged-mode) [data-pdf-layout="original-only"] .pdf-original-viewport {
    flex: none;
    width: auto;
    height: auto;
    overflow: visible;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    scrollbar-gutter: auto;
}

#reader-view:not(.paged-mode) [data-pdf-layout="original-only"] .pdf-original-surface {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    border-radius: 2px;
}

#reader-view.paged-mode .pdf-page-image-column {
    top: 20px;
    height: calc(100dvh - 40px);
}

#reader-view.paged-mode [data-pdf-layout="original-only"] .pdf-page-image-column {
    position: relative;
    top: auto;
    height: calc(100dvh - 40px);
    margin-bottom: 0;
}

/* Single document-wide zoom & page bar for "original-only" view. */
.pdf-original-zoom-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 70;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 20px;
    font: 12px/1.2 system-ui, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    background: var(--ui-bg);
    color: var(--ui-text);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--ui-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    opacity: 0.84;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.pdf-original-zoom-bar:hover,
.pdf-original-zoom-bar:focus-within {
    opacity: 1;
}

.pdf-original-zoom-bar[hidden] {
    display: none !important;
}

#reader-view.paged-mode .pdf-original-zoom-bar {
    bottom: 72px;
}

.pdf-original-zoom-bar .mode-btn {
    flex: 0 0 auto;
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1;
    min-height: 24px;
    border-radius: 8px;
    color: var(--ui-text);
}

.pdf-original-zoom-bar .pdf-zoom-page {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.pdf-original-zoom-bar .pdf-zoom-page[hidden],
.pdf-original-zoom-bar .pdf-zoom-sep[hidden] {
    display: none;
}

.pdf-original-zoom-bar .pdf-zoom-sep {
    width: 1px;
    height: 14px;
    background: var(--ui-border);
    margin: 0 2px;
}

.pdf-original-zoom-bar .pdf-zoom-status {
    min-width: 44px;
    font-size: 12px;
    color: var(--ui-text);
    opacity: 0.92;
}

.pdf-image-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 4px;
    font: 12px/1.4 system-ui, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    /* Floats over the original's top corner instead of taking a row: the original keeps the text's
       height, and the bottom corners hold the screen's speech and settings buttons. */
    position: absolute;
    right: 18px; /* clear of the original's own scrollbar */
    top: 8px;
    z-index: 1;
    max-width: calc(100% - 28px);
    padding: 2px 4px;
    border-radius: 6px;
    opacity: 0.85;
}

#book-content .pdf-image-footer {
    background-color: var(--ui-bg) !important;
}


.pdf-source-badge {
    font-size: 11px;
    font-weight: 500;
    color: var(--ui-text, #444444);
    opacity: 0.85;
    background: rgba(128, 128, 128, 0.12);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 55%;
}

.pdf-zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.pdf-zoom-controls .mode-btn {
    flex: 0 0 auto;
    padding: 2px 6px;
    font-size: 11px;
    line-height: 1;
    min-height: 22px;
    border-radius: 4px;
}

.pdf-zoom-status {
    min-width: 42px;
    text-align: center;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    color: var(--ui-text, #333333);
    opacity: 0.85;
}

.pdf-original-viewport {
    flex: 1;
    min-height: 0;
    width: 100%;
    position: relative;
    overflow: auto;
    background: #ffffff;
    color: #111;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    scrollbar-gutter: stable;
    touch-action: pan-x pan-y;
}

.pdf-original-viewport:focus-visible {
    outline: 2px solid var(--ui-primary);
    outline-offset: 3px;
}

.pdf-original-surface {
    position: relative;
    margin: 0 auto;
    background: #ffffff;
}
.pdf-original-surface[data-pdf-selectable="true"] {
    cursor: text;
}

/* Light-DOM PDF.js text layer used in "original-only" view (split views keep their own closed Shadow DOM). */
.pdf-source-text {
    position: absolute;
    inset: 0;
    z-index: 1;
    cursor: text;
}

.pdf-source-text .textLayer {
    position: absolute;
    inset: 0;
    overflow: clip;
    line-height: 1;
    text-align: initial;
    text-indent: 0;
    transform-origin: 0 0;
    color-scheme: only light;
    forced-color-adjust: none;
    text-size-adjust: none;
    user-select: text;
    --min-font-size: 1;
    --text-scale-factor: calc(var(--total-scale-factor) * var(--min-font-size));
    --min-font-size-inv: calc(1 / var(--min-font-size));
}

.pdf-source-text .textLayer span,
.pdf-source-text .textLayer br {
    color: transparent;
    position: absolute;
    white-space: pre;
    cursor: text;
    transform-origin: 0 0;
}

#book-content.pdf-content .pdf-source-text .textLayer,
#book-content.pdf-content .pdf-source-text .textLayer * {
    line-height: 1 !important;
}

#book-content.pdf-content .pdf-source-text .textLayer span,
#book-content.pdf-content .pdf-source-text .textLayer br {
    color: transparent !important;
}

.pdf-source-text .textLayer > :not(.markedContent),
.pdf-source-text .textLayer .markedContent span:not(.markedContent) {
    z-index: 1;
    font-size: calc(var(--text-scale-factor) * var(--font-height));
    --scale-x: 1;
    --rotate: 0deg;
    transform: rotate(var(--rotate)) scaleX(var(--scale-x)) scale(var(--min-font-size-inv));
}

.pdf-source-text .textLayer .markedContent {
    display: contents;
}

.pdf-source-text .textLayer ::selection {
    background: rgba(45, 118, 230, 0.3);
    color: transparent;
}

.pdf-tts-block-box {
    position: absolute;
    pointer-events: none;
    z-index: 2;
    box-sizing: border-box;
    border: 1px dashed #ff5722;
    border-radius: 2px;
}


.pdf-link-layer {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}

.pdf-original-link {
    position: absolute;
    display: block;
    pointer-events: auto;
    background: transparent;
    cursor: pointer;
}

.pdf-original-link:focus-visible {
    outline: 2px solid #1769d2;
    outline-offset: 1px;
}

.pdf-original-tile {
    position: absolute;
    display: block;
}

.pdf-render-status {
    font: 13px/1.4 system-ui, sans-serif;
    overflow-wrap: anywhere;
    position: absolute;
    top: 8px;
    left: 8px;
    max-width: calc(100% - 16px);
    z-index: 3;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    pointer-events: none;
}

.pdf-render-status:empty {
    display: none;
}

#book-content .pdf-text-block {
    margin: 0 0 var(--paragraph-spacing);
}

.pdf-text-block {
    white-space: normal;
}

.pdf-text-block.pdf-text-indented {
    text-indent: 1.8em;
}

/* Centred in the source (a title or copyright page, a verse): its rows as there. */
.pdf-text-block.pdf-text-centered {
    white-space: pre-line;
    text-align: center;
}

.pdf-text-block a.pdf-source-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.12em;
}

.pdf-text-block[data-preserve-whitespace="true"],
.pdf-page-text pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* A display formula read as text: its rows as in the source, centred; its number at the right. */
.pdf-text-block.pdf-formula-text {
    white-space: pre-line;
    text-align: center;
    text-indent: 0;
    margin-block: 0.8em;
}

.pdf-formula-text .pdf-equation-number {
    float: right;
    margin-inline-start: 1em;
}

/* Indices drawn apart from their row in the source keep their size (the run's font scale) and only move. */
.pdf-text-block .pdf-subscript,
.pdf-text-block .pdf-superscript {
    line-height: 0;
}

.pdf-text-block .pdf-subscript {
    vertical-align: sub;
}

.pdf-text-block .pdf-superscript {
    vertical-align: super;
}

/* A reader text-layer page as its source lays it out: the source page without its text behind, each word where it
   stands in the source's size and colour (the source's style, not the theme's: the page keeps its own paper). */
[data-text-zoomed] .pdf-page-text {
    overflow-x: auto;
}

.pdf-placed-page {
    position: relative;
    /* Pinch or Ctrl+wheel zoom (pdf-layout-view.js): the words are text, so they stay sharp. */
    width: calc(100% * var(--pdf-page-zoom, 1));
    touch-action: pan-x pan-y;
    container-type: inline-size;
    overflow: hidden;
    margin: 0 auto 1em;
    background: #fff center / 100% 100% no-repeat;
    color: #000;
    line-height: 1;
    text-indent: 0;
    white-space: normal;
}

.pdf-placed-word {
    position: absolute;
    white-space: pre;
    line-height: 1;
    transform-origin: 0 0;
}

/* A vertical CJK column: set top to bottom, as in the source; two or three digits across one cell. */
.pdf-placed-word.pdf-placed-vertical {
    writing-mode: vertical-rl;
}

.pdf-placed-across {
    text-combine-upright: all;
}

/* Each horizontal line of words sits in its own row band so mouse selection stays on the row; a furniture band has
   one sideways overflow to keep Edge Read Aloud out of it. */
.pdf-placed-page > .pdf-placed-row,
.pdf-placed-page > .pdf-placed-furniture {
    position: absolute;
}

.pdf-placed-page > .pdf-placed-furniture {
    overflow: hidden;
}

.pdf-word-sep {
    font-size: 0;
    letter-spacing: 0;
}

.pdf-placed-furniture > .pdf-placed-overflow {
    position: absolute;
    left: 0;
    top: 0;
    width: calc(100% + 4px);
    height: 1px;
}

/* Title art's text: the source drawing shows it; the text is there to read and select. */
.pdf-placed-word.pdf-placed-art {
    color: transparent;
}

/* A display formula is scaled to fit the box its source rows took (no scrolling inside the page); KaTeX's own
   display margins are no part of it. */
.pdf-placed-page > .pdf-equation {
    position: absolute;
    margin: 0;
    overflow: visible;
    white-space: nowrap;
    transform-origin: 0 0;
}

.pdf-placed-page > .pdf-equation .katex-display {
    margin: 0;
}

/* The plain text format of a text-layer page: the reader's colours, family, size and spacing, and each word at its
   source position across its row; pictures and vertical columns in scaled boxes of their own. */
.pdf-plain-page {
    position: relative;
    width: 100%;
    container-type: inline-size;
    margin: 0 0 1em;
    text-indent: 0;
}

.pdf-plain-row {
    position: relative;
    width: 100%;
    white-space: normal;
}

.pdf-plain-row.pdf-plain-break {
    margin-top: calc(var(--paragraph-spacing, 1.2em) * 0.55);
}

.pdf-plain-row.pdf-plain-break:first-child {
    margin-top: 0;
}

.pdf-plain-word {
    position: absolute;
    white-space: pre;
    line-height: 1;
    transform-origin: 0 0;
}

/* A table the layout model found, with its cells as the source's rules make them (pdf-reader.js makeTable): the
   source's columns, the reader's colours; a narrow screen scrolls the table rather than the page. */
/* A window standing clear beside the text (a margin's turned label): it takes no room, drawn over the rows' margin. */
.pdf-plain-aside {
    height: 0;
    overflow: visible;
    position: relative;
    z-index: 1;
}
.pdf-plain-aside > .pdf-plain-box { display: block; }

.pdf-plain-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    margin-block: 0.4em;
}
.pdf-plain-table {
    width: 100%;
    border-collapse: collapse;   /* auto layout: the source's column shares, a column never narrower than its longest word */
}
.pdf-plain-table td {
    border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
    padding: 0.15em 0.2em;
    vertical-align: middle;
}
.pdf-plain-table td.pdf-plain-cell-open { border-color: transparent; }
/* (A word stays whole: the page's own anywhere-wrap broke a narrow column's "how many" into how man y.) */
.pdf-plain-cell-line { white-space: pre-wrap; line-height: 1.3; overflow-wrap: normal; }

.pdf-plain-picture,
.pdf-plain-box {
    position: relative;
    container-type: inline-size;
    overflow: hidden;
    margin: 0.75em 0;
    line-height: 1;
    text-indent: 0;
    white-space: normal;
}

.pdf-plain-picture {
    background: #fff no-repeat;
    color: #000;
}

/* A picture with the rows set beside it in the source (a speech bubble beside its drawing): side by side. */
.pdf-plain-band {
    display: flex;
    gap: 0.6em;
    align-items: flex-start;
    margin: 0 0 calc(var(--paragraph-spacing, 1.2em) * 0.55);
}

.pdf-plain-band.pdf-plain-text-left { flex-direction: row-reverse; }
.pdf-plain-band > .pdf-plain-picture { flex: none; }
.pdf-plain-side { flex: 1; min-width: 0; }

.pdf-plain-probe {
    position: absolute;
    left: 0;
    top: 0;
    visibility: hidden;
    pointer-events: none;
    white-space: pre;
}

/* A text-layer PDF's format switch shows only when a text-layer page is on screen; in the white page format the
   settings that do not change a placed page (themes, colours, font size, line and paragraph spacing) hide. */
#pdf-format-setting {
    display: none;
}

body:has(#book-content :is(.pdf-placed-page, .pdf-plain-page)) #pdf-format-setting {
    display: block;
}

body:has(#book-content .pdf-placed-page) #settings-sidebar .setting-group:has(
    .theme-presets, #bg-color-picker, #container-bg-picker, #text-color-picker,
    #font-size-slider, #line-height-slider, #paragraph-spacing-slider
),
body:has(#book-content .pdf-placed-page) #settings-sidebar .setting-group:has(.theme-presets, #text-color-picker) + hr {
    display: none;
}

#book-content .pdf-figure {
    position: relative;
    margin: 1em 0;
    max-width: 100%;
}

/* A picture with its side text (a plate's legend in the margin): side by side as in the source, its rows as there;
   on a narrow screen the text above or below it, in reading order. */
#book-content .pdf-figure-row {
    display: flex;
    gap: 1em;
    align-items: flex-start;
    margin: 1em 0;
}

#book-content .pdf-figure-row.pdf-figure-text-left { flex-direction: row-reverse; }
#book-content .pdf-figure-row > .pdf-figure { flex: none; margin: 0; }
#book-content .pdf-figure-side { flex: 1; min-width: 0; }
#book-content .pdf-figure-side > .pdf-text-block { white-space: pre-line; margin-top: 0; }

@media (max-width: 600px) {
    #book-content .pdf-figure-row { flex-direction: column; }
    #book-content .pdf-figure-row.pdf-figure-text-left { flex-direction: column-reverse; }
    #book-content .pdf-figure-row > .pdf-figure { max-width: 100%; }
}

/* A figure's labels over the picture, unseen (the picture shows them): there to select and copy. */
#book-content .pdf-figure-words {
    position: absolute;
    inset: 0;
    container-type: inline-size;
    line-height: 1;
    text-indent: 0;
    white-space: normal;
}

#book-content .pdf-figure img {
    display: block;
    width: 100%;
    height: auto;
    max-height: none;
    margin: 0;
    border-radius: 0;
}

/* A phone stacks the two: the original stays on top (30% of the screen by default, set with the
   splitter below it, following the reading position) and the text scrolls below it, so nothing
   scrolls sideways and a sideways swipe turns the page. */
@media (max-width: 768px) {
    #book-content.pdf-content,
    #reader-view.paged-mode #book-viewport.pdf-paged-viewport #book-content {
        padding: 16px !important;
    }

    /* The last lines scroll clear of the bottom controls (style.css). */
    #reader-view.paged-mode #book-viewport.pdf-paged-viewport #book-content {
        padding-bottom: 76px !important;
    }

    .pdf-page-columns {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .pdf-page-image-column,
    [data-pdf-layout="text-left"] .pdf-page-image-column,
    #reader-view.paged-mode .pdf-page-image-column {
        grid-column: 1;
        grid-row: 1;
        top: 0;
        z-index: 2;
        height: calc(var(--pdf-source-share, 0.3) * 100dvh);
        padding: 4px 0 0;
    }

    #reader-view:not(.paged-mode) [data-pdf-layout="original-only"] .pdf-page-image-column {
        position: relative;
        top: auto;
        z-index: auto;
        height: auto;
        padding: 0;
        margin-bottom: 12px;
        background: transparent !important;
    }

    #reader-view:not(.paged-mode) #reader-container:has(#book-content[data-pdf-layout="original-only"]) {
        padding: 8px 0 84px;
    }

    #reader-view:not(.paged-mode) #book-content.pdf-content[data-pdf-layout="original-only"] {
        padding: 0 8px !important;
    }

    #reader-view.paged-mode [data-pdf-layout="original-only"] .pdf-page-image-column {
        position: relative;
        top: auto;
        z-index: auto;
        height: calc(100dvh - 96px);
        padding: 0;
        margin-bottom: 0;
    }

    .pdf-original-zoom-bar {
        bottom: 18px;
        padding: 4px 7px;
        gap: 3px;
        max-width: calc(100vw - 188px);
        overflow-x: auto;
    }

    #reader-view.paged-mode .pdf-original-zoom-bar {
        bottom: 68px;
        max-width: calc(100vw - 24px);
    }

    .pdf-original-zoom-bar .mode-btn {
        min-height: 22px;
        padding: 3px 6px;
        font-size: 11px;
    }

    .pdf-original-zoom-bar .pdf-zoom-status {
        min-width: 0;
        font-size: 11px;
    }

    #book-content:not([data-pdf-layout="original-only"]) .pdf-page-image-column,
    #book-content .pdf-splitter {
        background-color: var(--container-bg) !important;
    }

    .pdf-splitter {
        grid-column: 1;
        grid-row: 2;
        position: sticky;
        top: calc(var(--pdf-source-share, 0.3) * 100dvh);
        z-index: 2;
        height: 20px;
        min-height: 0;
        border-radius: 0;
        cursor: row-resize;
    }

    .pdf-splitter::after {
        width: 48px;
        height: 4px;
        top: 8px;
        bottom: auto;
        left: calc(50% - 24px);
    }

    .pdf-split-dragging,
    .pdf-split-dragging * {
        cursor: row-resize !important;
    }

    .pdf-page-text,
    [data-pdf-layout="text-left"] .pdf-page-text {
        grid-column: 1;
        grid-row: 3;
        min-height: 0;
    }

    .pdf-source-badge {
        display: none;
    }

    .pdf-image-footer {
        top: auto;
        bottom: 6px;
        right: 10px;
    }

    .pdf-zoom-controls .mode-btn {
        min-height: 20px;
        padding: 1px 5px;
        font-size: 10px;
    }

    .pdf-zoom-status {
        min-width: 0;
        font-size: 10px;
    }
}

/* Pans a zoomed text that is wider than the screen (pdf-layout-view.js): the browser's own
   scrollbar, like the original's, under the text column's visible part (on a phone above the
   bottom controls); the text's own one hidden. */
.pdf-pan-bar {
    position: fixed; /* left, width and top: the text column's (pdf-layout-view.js) */
    z-index: 60;
    overflow-x: auto;
    overflow-y: hidden;
}

.pdf-pan-bar > div {
    height: 1px;
}

/* The text's pan bar and the original's scrollbars look alike: thin grey thumbs, no arrows or track
   (drawn, so a phone's fading overlay scrollbar still shows). */
.pdf-pan-bar::-webkit-scrollbar,
.pdf-original-viewport::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.pdf-pan-bar::-webkit-scrollbar-thumb,
.pdf-original-viewport::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background: rgba(160, 160, 160, 0.75);
}

.pdf-pan-bar::-webkit-scrollbar-track,
.pdf-original-viewport::-webkit-scrollbar-track,
.pdf-original-viewport::-webkit-scrollbar-corner {
    background: transparent;
}

@supports not selector(::-webkit-scrollbar) {
    .pdf-pan-bar,
    .pdf-original-viewport {
        scrollbar-color: rgba(160, 160, 160, 0.75) transparent;
        scrollbar-width: thin;
    }
}

.pdf-pan-bar[hidden] {
    display: none;
}

[data-text-zoomed] .pdf-page-text {
    scrollbar-width: none;
}

/* Formulas (KaTeX), the same in all three versions; a click copies the LaTeX. */
.pdf-math {
    color: inherit;
    cursor: copy;
    white-space: nowrap;
}

.pdf-math .katex {
    font-size: 1em;
}

.pdf-math:focus-visible {
    outline: 2px solid var(--ui-primary);
    outline-offset: 4px;
}

.pdf-equation {
    display: flex;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    margin: 1em 0;
}

.pdf-equation .pdf-math {
    flex: 1;
    min-width: max-content;
}

.pdf-equation-number {
    flex: none;
}
