/* ==========================================================================
   Base
   ========================================================================== */

:root {
    --color-bg: #10131a;
    --color-bg-soft: #171c26;
    --color-panel: #f4efe6;
    --color-panel-soft: #fffaf0;
    --color-panel-muted: #e6dccb;

    --color-text: #1f1a14;
    --color-text-muted: #6b5d4b;
    --color-text-inverse: #f6efe4;

    --color-accent: #9f6b32;
    --color-accent-dark: #70471d;
    --color-line: #d8c8ae;

    --shadow-soft: 0 1.25rem 3rem rgba(0, 0, 0, 0.32);
    --shadow-panel: 0 0.5rem 1.5rem rgba(42, 27, 11, 0.15);

    --font-body: Verdana, Geneva, Tahoma, sans-serif;
    --font-heading: "Book Antiqua", Palatino, Georgia, serif;
    --font-ui: Verdana, Geneva, Tahoma, sans-serif;

    --nav-breakpoint: 56.25rem; /* 900px */
    --layout-breakpoint-tablet-min: 40rem; /* 640px */
    --layout-breakpoint-narrow-desktop: 72rem; /* 1152px */
    /*
     * Book edition detail: cover scans + metadata sit side by side at these
     * widths and above. Below the threshold, covers stack above metadata.
     * Editions with flap scans use the higher value (class --has-flaps on record).
     */
    --book-edition-record-breakpoint: 90rem; /* 1440px — front / back / spine only */
    --book-edition-record-breakpoint-flaps: 130rem; /* 2080px — includes flap scans */

    /*
     * Layout spacing — tweak these to taste:
     *   --layout-gutter     outer margin between viewport edge and site shell
     *   --panel-padding-*   inner padding of the main content panel (.page-wrapper)
     */
    --layout-gutter: clamp(1.75rem, 3.5vw, 4rem);
    --layout-width: calc(100% - 2 * var(--layout-gutter));
    --panel-padding-inline: clamp(1.5rem, 2.5vw, 3rem);
    --panel-padding-block: clamp(1.75rem, 2.5vw, 2.75rem);
    --sticky-top-navigation: clamp(1rem, 2.5vw, 1.5rem);
    --book-sticky-subhead-top: 3.35rem;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 100%;
    background: var(--color-bg);
    scroll-padding-top: 8rem;
}

body {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(159, 107, 50, 0.35), transparent 32rem),
        linear-gradient(135deg, #111620 0%, #17110d 55%, #0d1017 100%);
    color: var(--color-text);
    font-family: var(--font-body);
    line-height: 1.6;
}

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

a {
    color: var(--color-accent-dark);
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

a:hover {
    color: #3d230d;
}


/* ==========================================================================
   Site Shell
   ========================================================================== */

/* Local development: viewport border (body.env-local from header.php). */
body.env-local::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    border: 4px solid red;
    box-sizing: border-box;
    pointer-events: none;
}

@media print {
    body.env-local::before {
        display: none;
    }
}

.site-header {
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(16, 19, 26, 0.92);
    color: var(--color-text-inverse);
    /* backdrop-filter: blur(10px); */
}

.site-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem 2.5rem;
    width: var(--layout-width);
    margin-inline: auto;
    padding: 1.25rem 0;
}

.site-header__quote {
    flex: 1 1 56rem;
    max-width: min(140ch, 100%);
}

.site-nav-toggle {
    display: none;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    padding: 0.45rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 0.45rem;
    background: rgba(255, 255, 255, 0.08);
    color: inherit;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    line-height: 1.2;
    cursor: pointer;
}

.site-nav-toggle__arrow {
    display: none;
    font-size: 1.15rem;
    line-height: 1;
}

.site-nav-toggle[aria-expanded="true"] .site-nav-toggle__icon,
.site-nav-toggle[aria-expanded="true"] .site-nav-toggle__label-open {
    display: none;
}

.site-nav-toggle[aria-expanded="true"] .site-nav-toggle__arrow,
.site-nav-toggle[aria-expanded="true"] .site-nav-toggle__label-close {
    display: inline;
}

.site-nav-toggle__label-close {
    display: none;
}

.site-nav-toggle:hover {
    background: rgba(255, 255, 255, 0.14);
}

.site-nav-toggle__icon {
    display: block;
    width: 1rem;
    height: 0.65rem;
    border-top: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    background: linear-gradient(currentColor, currentColor) center / 100% 2px no-repeat;
}

.site-header__title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: clamp(1.85rem, 3.2vw, 2.65rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: 0.03em;
    text-transform: lowercase;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.site-title {
    color: inherit;
    text-decoration: none;
}

.site-title:hover,
.site-title:focus-visible {
    color: #fff8ec;
}

.site-tagline {
    margin: 0;
    color: rgba(246, 239, 228, 0.72);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    line-height: 1.55;
}

.site-tagline--quote {
    --site-tagline-quote-lines: 3;
    border: 0;
    padding: 0 0 0 1rem;
}

.site-tagline__text {
    margin: 0;
    min-height: calc(var(--site-tagline-quote-lines) * 1.55em);
}

.site-tagline__text q {
    quotes: "\201C" "\201D" "\2018" "\2019";
}

.site-tagline__attribution {
    margin-top: 0.5rem;
    min-height: 1.15em;
    font-size: 0.72rem;
    font-style: normal;
    line-height: 1.55;
    color: rgba(246, 239, 228, 0.48);
}

.site-tagline__attribution a {
    color: inherit;
}

.site-shell {
    display: grid;
    grid-template-columns: minmax(16rem, 18rem) minmax(0, 1fr);
    gap: clamp(1.25rem, 2vw, 2.5rem);
    width: var(--layout-width);
    margin: 2rem auto;
    align-items: start;
}

.site-nav-overlay {
    display: none;
}

.site-sidebar {
    position: sticky;
    top: var(--sticky-top-navigation);
    max-height: calc(100vh - 2 * var(--sticky-top-navigation));
    overflow: auto;
    border: 1px solid rgba(216, 200, 174, 0.35);
    border-radius: 1rem;
    background: rgba(244, 239, 230, 0.95);
    box-shadow: var(--shadow-soft);
}

.site-main {
    min-width: 0;
}


/* ==========================================================================
   Navigation
   ========================================================================== */

.site-nav {
    --nav-toggle-size: 1.35rem;
    --nav-toggle-gap: 0.2rem;
    --nav-row-inset: calc(var(--nav-toggle-size) + var(--nav-toggle-gap));

    padding: 1rem;
    font-family: var(--font-ui);
}

.site-nav__heading {
    margin: 0 0 0.9rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-line);
    color: var(--color-text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.site-nav ul {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.site-nav ul ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav ul.site-nav__sublist {
    margin-block: 0.2rem 0.45rem;
    margin-inline-start: calc(var(--nav-toggle-size) * 0.42);
    padding-block: 0.3rem 0.35rem;
    padding-inline: 0.55rem 0 0 calc(var(--nav-row-inset) - 0.15rem);
    border-left: 2px solid var(--color-line);
    border-radius: 0 0.45rem 0.45rem 0;
    background: color-mix(in srgb, var(--color-panel-muted) 38%, transparent);
}

.site-nav li {
    margin: 0.1rem 0;
}

.site-nav li.nav-leaf > a,
.site-nav li.nav-leaf > span {
    margin-inline-start: var(--nav-row-inset);
}

.site-nav a,
.site-nav span {
    display: block;
    padding: 0.32rem 0.45rem;
    border-radius: 0.45rem;
    font-size: 0.88rem;
    line-height: 1.35;
}

.site-nav a {
    color: var(--color-text);
    text-decoration: none;
}

.site-nav a:hover {
    background: var(--color-panel-muted);
    color: var(--color-accent-dark);
}

.site-nav span {
    color: var(--color-text-muted);
    font-weight: 700;
}

.site-nav li.is-current > a,
.site-nav li.is-current > span,
.site-nav li.is-current > .nav-branch__row > a,
.site-nav li.is-current > .nav-branch__row > span {
    background: var(--color-accent-dark);
    color: #fff;
    font-weight: 700;
}

.site-nav li.is-current > a:hover,
.site-nav li.is-current > .nav-branch__row > a:hover {
    background: var(--color-accent-dark);
    color: #fff;
}

.site-nav li.is-ancestor > a,
.site-nav li.is-ancestor > span,
.site-nav li.is-ancestor > .nav-branch__row > a,
.site-nav li.is-ancestor > .nav-branch__row > span {
    background: rgba(159, 107, 50, 0.14);
    color: var(--color-accent-dark);
    font-weight: 700;
}

.site-nav li.nav-parent.is-expanded:not(.is-current) > .nav-branch__row > a,
.site-nav li.nav-parent.is-expanded:not(.is-current) > .nav-branch__row > span,
.site-nav li.nav-parent:not(.nav-branch):not(.is-current) > a,
.site-nav li.nav-parent:not(.is-current):not(.nav-branch) > span {
    color: var(--color-text);
    font-weight: 700;
}

.site-nav li.is-ancestor > ul.site-nav__sublist,
.site-nav li.nav-branch.is-expanded > ul.site-nav__sublist {
    border-left-color: color-mix(in srgb, var(--color-accent) 72%, var(--color-line));
    background: color-mix(in srgb, var(--color-accent) 9%, var(--color-panel-soft));
}

.site-nav li.nav-branch > .nav-branch__row {
    display: flex;
    align-items: center;
    gap: var(--nav-toggle-gap);
}

.site-nav .nav-branch__toggle {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: var(--nav-toggle-size);
    height: var(--nav-toggle-size);
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-line);
    border-radius: 0.3rem;
    background: var(--color-panel-soft);
    color: var(--color-text-muted);
    font: inherit;
    line-height: 1;
    cursor: pointer;
}

.site-nav .nav-branch__toggle:hover {
    background: var(--color-panel-muted);
    border-color: var(--color-accent);
    color: var(--color-accent-dark);
}

.site-nav .nav-branch__icon {
    display: block;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1;
    transform: translateY(0.02em);
    transition: transform 0.15s ease;
}

.site-nav li.nav-branch.is-expanded > .nav-branch__row .nav-branch__icon {
    transform: rotate(90deg) translateX(0.04em);
}

.site-nav .nav-branch__label,
.site-nav .nav-branch__row > a,
.site-nav .nav-branch__row > span {
    flex: 1 1 auto;
    min-width: 0;
}


/* ==========================================================================
   Breadcrumbs
   ========================================================================== */

.breadcrumbs {
    position: sticky;
    z-index: 8;
    top: 0;

    margin-bottom: 0.85rem;
    padding: 0.7rem 1rem;
    border: 1px solid rgba(216, 200, 174, 0.4);
    border-radius: 0.85rem;
    background: rgba(244, 239, 230, 0.96);
    box-shadow: var(--shadow-panel);
    font-family: var(--font-ui);
    font-size: 0.82rem;
}

.breadcrumbs ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.breadcrumbs li {
    display: flex;
    align-items: center;
    color: var(--color-text-muted);
}

.breadcrumbs li + li::before {
    content: "›";
    margin-right: 0.35rem;
    color: var(--color-accent);
}

.breadcrumbs a {
    color: var(--color-accent-dark);
    text-decoration: none;
}

.breadcrumbs a:hover {
    text-decoration: underline;
}

.breadcrumbs [aria-current="page"] {
    color: var(--color-text);
    font-weight: 700;
}


/* ==========================================================================
   Main Content
   ========================================================================== */

.page-wrapper {
    min-height: 70vh;
    padding: var(--panel-padding-block) var(--panel-padding-inline);
    border: 1px solid rgba(216, 200, 174, 0.45);
    border-radius: 1.15rem;
    background:
        linear-gradient(180deg, rgba(255, 250, 240, 0.98), rgba(244, 239, 230, 0.98));
    box-shadow: var(--shadow-soft);
}

.page-wrapper img {
    display: block;

    max-width: 100%;
    height: auto;

    margin: 1.5rem auto;

    border-radius: 0.75rem;

    box-shadow: var(--shadow-panel);
}

.page-wrapper img.img--square,
.figure img.img--square {
    border-radius: 0;
}

.page-wrapper img.img--inline {
    display: inline;
    max-width: none;
    height: auto;
    margin: 0 0.15em;
    vertical-align: middle;
    box-shadow: none;
}

.page-wrapper img.img--diagram {
    box-shadow: none;
}

.page-wrapper img.img--png,
.figure img.img--png,
.comic-strip__image img.img--png,
.page-wrapper .book-cover-card__image.img--png,
.page-wrapper .book-edition__cover-link img.img--png,
.page-wrapper .book-edition__cover-image.img--png,
.page-wrapper .book-color-cover__image.img--png {
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

.figure--png img {
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

.page-wrapper > :first-child {
    margin-top: 0;
}

.page-wrapper :is(h2, h3, h4, h5, h6),
.news-entry__body :is(h2, h3, h4, h5, h6) {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    padding: 0;
}

/* Legacy news bodies may still contain h1; render like a page title (h2). */
.page-wrapper h1,
.news-entry__body h1 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    padding: 0;
    margin-top: 1.75rem;
    margin-bottom: 0.5rem;
    padding: 0.35rem;
    color: #432811;
    font-size: clamp(1.45rem, 2vw, 1.85rem);
}

.page-wrapper h2,
.news-entry__body h2 {
    margin-top: 1.75rem;
    margin-bottom: 0.5rem;
    padding: 0.35rem;
    color: #432811;
    font-size: clamp(1.45rem, 2vw, 1.85rem);
}

.page-wrapper h3,
.news-entry__body h3 {
    margin-top: 1.25rem;
    margin-bottom: 0.35rem;
    padding: 0 1.25rem;
    color: #563719;
    font-size: clamp(1.15rem, 1.6vw, 1.45rem);
}

.page-wrapper h4,
.news-entry__body h4 {
    margin-top: 1rem;
    margin-bottom: 0.25rem;
    padding: 0.35rem;
    color: #6a4828;
    font-size: 1.15rem;
}

.page-wrapper h5,
.news-entry__body h5 {
    margin-top: 0.85rem;
    margin-bottom: 0.2rem;
    padding: 0.35rem;
    color: #7a5530;
    font-size: 1.05rem;
    font-variant: small-caps;
    letter-spacing: 0.04em;
}

.page-wrapper h6,
.news-entry__body h6 {
    margin-top: 0.75rem;
    margin-bottom: 0.2rem;
    padding: 0.35rem;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.page-wrapper p,
.page-wrapper ul,
.page-wrapper ol,
.page-wrapper dl {
    max-width: none;
}

.page-wrapper blockquote,
.page-wrapper blockquote.lyrics {
    margin: 0 0 1.5rem;
    max-width: none;
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--color-line);
    border-radius: 0 0.65rem 0.65rem 0;
    background: var(--color-panel-soft);
}

.page-wrapper blockquote > :last-child {
    margin-bottom: 0;
}

.page-wrapper dl dt {
    margin-top: 1.25rem;
    font-weight: 600;
}

.page-wrapper dl dt:first-child {
    margin-top: 0;
}

.page-wrapper code {
    padding: 0.1rem 0.25rem;
    border-radius: 0.25rem;
    background: #eadfca;
    font-size: 0.92em;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.page-wrapper code.code-good {
    background: rgba(198, 221, 181, 0.85);
    color: #2f4a24;
}

.page-wrapper code.code-bad {
    background: rgba(235, 198, 198, 0.85);
    color: #6b3030;
}

.page-wrapper code span.code-good,
.page-wrapper code span.code-bad {
    padding-block: 0.1rem;
    padding-inline: 0;
    margin-block: -0.1rem;
    margin-inline: 0;
    border-radius: 0.25rem;
    vertical-align: baseline;
    line-height: inherit;
    font: inherit;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

.page-wrapper code span.code-good {
    background: rgba(198, 221, 181, 0.85);
    color: #2f4a24;
}

.page-wrapper code span.code-bad {
    background: rgba(235, 198, 198, 0.85);
    color: #6b3030;
}

.page-wrapper code.block span.code-good,
.page-wrapper code.block span.code-bad {
    padding-block: 0.05rem;
    padding-inline: 0;
    margin-block: -0.05rem;
    margin-inline: 0;
}

.page-wrapper code.block span.code-good {
    background: rgba(198, 221, 181, 0.22);
    color: #cfe8bc;
}

.page-wrapper code.block span.code-bad {
    background: rgba(235, 198, 198, 0.22);
    color: #f5d0d0;
}

.page-wrapper code.block {
    display: block;
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    margin: 0 0 1.5rem;
    padding: 1rem 1.15rem;
    border: 1px solid rgba(42, 27, 11, 0.2);
    border-radius: 0.65rem;
    background: #1d1a17;
    color: #fff4df;
    font-size: 0.92rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.page-wrapper code.block.bad {
    background: #3f1f1f;
    border-color: #b85c5c;
    color: #ffe3e3;
}

.page-wrapper pre:has(> code.block) {
    width: fit-content;
    max-width: 100%;
    margin: 0 0 1.5rem;
    padding: 0;
    background: none;
    color: inherit;
}

.page-wrapper pre:has(> code.block) > code.block {
    margin-bottom: 0;
}

.page-wrapper .tt {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

.page-wrapper del {
    color: var(--color-text-muted);
    font-style: italic;
    text-decoration: line-through;
}

.page-wrapper ins {
    color: #8a2a2a;
    font-weight: 700;
    text-decoration: none;
    background: rgba(255, 220, 180, 0.45);
}

.page-wrapper kbd {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border: 1px solid #bababa;
    border-bottom-width: 3px;
    border-radius: 0.25rem;
    background: #efefef;
    font-family: var(--font-ui);
    font-size: 0.85em;
    line-height: 1.2;
}

.page-wrapper ul:not([class]),
.page-wrapper ol:not([class]),
.news-entry__body ul:not([class]),
.news-entry__body ol:not([class]) {
    margin: 0 0 1.25rem;
    padding-left: 1.75rem;
}

.page-wrapper ul:not([class]),
.news-entry__body ul:not([class]) {
    list-style-type: disc;
}

.page-wrapper ol:not([class]),
.news-entry__body ol:not([class]) {
    list-style-type: decimal;
}

.page-wrapper ul:not([class]) ul,
.page-wrapper ol:not([class]) ol,
.page-wrapper ul:not([class]) ol,
.page-wrapper ol:not([class]) ul,
.news-entry__body ul:not([class]) ul,
.news-entry__body ol:not([class]) ol {
    margin-top: 0.35rem;
    margin-bottom: 0;
}

.page-wrapper :is(ul, ol):not([class]) > li,
.news-entry__body :is(ul, ol):not([class]) > li {
    margin-bottom: 0.35rem;
}

.page-wrapper ol.roman,
.news-entry__body ol.roman {
    list-style-type: upper-roman;
}

.page-wrapper ol.alpha,
.news-entry__body ol.alpha {
    list-style-type: upper-alpha;
}

.page-wrapper ul.no-style,
.page-wrapper ol.no-style,
.page-wrapper li.no-style {
    list-style: none;
    padding-left: 0;
}

.site-map {
    margin: 0 0 1.5rem;
}

.site-map__list {
    margin: 0;
    padding-left: 1.5rem;
    list-style-type: disc;
}

.site-map__list .site-map__list {
    margin-top: 0.5rem;
    margin-bottom: 0;
}

.site-map__item {
    margin-bottom: 0.85rem;
}

.site-map__item:last-child {
    margin-bottom: 0;
}

.site-map__link {
    font-weight: 600;
}

.site-map__label {
    font-weight: 600;
}

.site-map__description {
    margin: 0.2rem 0 0;
    max-width: 42rem;
    color: var(--color-text-muted, #555);
    font-size: 0.95em;
}

.page-wrapper table:not(.grid):not(.nono):not(.sudoku) {
    width: auto;
    max-width: 100%;
    margin: 1.25rem 0 1.5rem;
    border: 2px solid var(--color-line);
    border-collapse: collapse;
    font-size: 0.95rem;
}

.page-wrapper table:not(.grid):not(.nono):not(.sudoku) th,
.page-wrapper table:not(.grid):not(.nono):not(.sudoku) td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-line);
    text-align: left;
    vertical-align: top;
}

.page-wrapper table:not(.grid):not(.nono):not(.sudoku) th {
    background: var(--color-panel-muted);
    font-weight: 700;
}

.page-wrapper table:not(.grid):not(.nono):not(.sudoku) caption {
    caption-side: top;
    margin-bottom: 0.5rem;
    font-weight: 700;
    text-align: left;
}

.page-wrapper pre {
    width: fit-content;
    max-width: 100%;
    overflow: auto;
    padding: 1rem;
    border-radius: 0.65rem;
    background: #1d1a17;
    color: #fff4df;
}

.page-wrapper .code {
    overflow-x: auto;
    max-width: none;
    padding: 1rem;
    border-radius: 0.65rem;
    background: #1d1a17;
    color: #fff4df;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 0.92rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.page-wrapper .cipher-input {
    display: block;
    width: 100%;
    max-width: none;
    min-height: 20rem;
    padding: 0.75rem;
    border: 1px solid var(--color-line);
    border-radius: 0.65rem;
    background: var(--color-panel-soft);
    color: var(--color-text);
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 0.92rem;
    line-height: 1.45;
    resize: vertical;
}


/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
    width: var(--layout-width);
    margin: 0 auto 2rem;
    color: rgba(246, 239, 228, 0.65);
    font-family: var(--font-ui);
    font-size: 0.82rem;
}

.site-footer__dates {
    margin: 0 0 0.35rem;
}


/* ==========================================================================
   Site Version Timeline
   ========================================================================== */

.site-version {
    position: relative;
    margin: 2rem 0 2rem 2rem;
    padding: 1.25rem;
    border: 1px solid var(--color-line);
    border-radius: 0.85rem;
    background: var(--color-panel-soft);
    box-shadow: var(--shadow-panel);
}

.site-version + .site-version {
    margin-top: 2rem;
}

.site-version::before {
    content: "";
    position: absolute;
    left: -1.45rem;
    top: 1.25rem;
    width: 0.8rem;
    height: 0.8rem;
    border: 2px solid var(--color-panel-soft);
    border-radius: 50%;
    background: var(--color-accent);
}

.site-version::after {
    content: "";
    position: absolute;
    left: -1.1rem;
    top: 2rem;
    width: 2px;
    height: calc(100% + 1.5rem);
    background: var(--color-line);
}

.site-version:last-child::after {
    display: none;
}

.site-version h3 {
    margin-top: 0;
    margin-bottom: 0.25rem;
    font-size: 1.25rem;
}

.site-version p {
    margin-top: 0;
}

.site-version em {
    color: var(--color-text-muted);
}

.site-version dl {
    margin: 1.25rem 0 0;
}

.site-version dt {
    margin-top: 1rem;
    color: #3a2613;
    font-weight: bold;
}

.site-version dt:first-child {
    margin-top: 0;
}

.site-version dd {
    margin: 0.25rem 0 0;
}

.site-version dd.release-notes {
    padding: 0.75rem;
    border-left: 4px solid var(--color-accent);
    border-radius: 0.35rem;
    background: #efe4d0;
}

.version-badge {
    display: inline-block;
    margin-right: 0.5rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: var(--color-accent-dark);
    color: #fff;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: normal;
}

/* ==========================================================================
   News entries
   ========================================================================== */

.news-entry {
    margin: 2rem 0;
    padding: 1.25rem;
    border: 1px solid var(--color-line);
    border-radius: 0.85rem;
    background: var(--color-panel-soft);
    box-shadow: var(--shadow-panel);
}

.news-entry__header {
    margin-bottom: 0.75rem;
}

.news-entry__time {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
}

.news-entry__time a {
    text-decoration: none;
}

.news-entry__time a:hover,
.news-entry__time a:focus-visible {
    text-decoration: underline;
}

.news-entry__body--preview {
    position: relative;
    overflow: hidden;
    padding-bottom: 0.25rem;
}

.news-entry__body--preview::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3.5rem;
    pointer-events: none;
    background: linear-gradient(to bottom, transparent, var(--color-panel-soft));
}

.news-entry__preview-more {
    margin: 0.75rem 0 0;
}

.news-entry__body > :first-child {
    margin-top: 0;
}

.news-entry__body > :last-child {
    margin-bottom: 0;
}

.news-archive-index.column {
    margin-top: 0.5rem;
    columns: 1 auto;
    column-gap: clamp(1.75rem, 3vw, 3rem);
}

@media (min-width: 72rem) {
    .news-archive-index.column {
        columns: 2 auto;
    }
}

@media (min-width: 90rem) {
    .news-archive-index.column {
        columns: 3 auto;
    }
}

.news-archive-year.column_element {
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
}

.news-archive-year.column_element h2 {
    margin-top: 0;
    padding-left: 0;
}

.news-archive-year.column_element > :last-child {
    margin-bottom: 0;
}

.news-archive-list {
    padding-left: 1.25rem;
}

.news-archive-list li {
    margin-bottom: 0.35rem;
}

.news-archive-nav {
    margin-inline: auto;
    padding: 1rem 1.25rem;
    text-align: center;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    line-height: 1.5;
    border: 1px solid var(--color-line);
    border-radius: 0.9rem;
    background: var(--color-panel-soft);
    box-shadow: var(--shadow-panel);
}

.news-archive-nav--top {
    margin-bottom: 2rem;
}

.news-archive-nav--bottom {
    margin-top: 2.5rem;
}

.news-archive-nav__row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.35rem 0.75rem;
    margin: 0 0 0.85rem;
}

.news-archive-nav__sep {
    color: var(--color-text-muted);
    user-select: none;
}

.news-archive-nav__edge,
.news-archive-nav__adjacent,
.news-archive-nav__back-link {
    text-decoration: none;
}

.news-archive-nav__edge {
    font-weight: 700;
    letter-spacing: 0.04em;
}

.news-archive-nav__adjacent:hover,
.news-archive-nav__adjacent:focus-visible,
.news-archive-nav__edge:hover,
.news-archive-nav__edge:focus-visible,
.news-archive-nav__back-link:hover,
.news-archive-nav__back-link:focus-visible {
    text-decoration: underline;
}

.news-archive-nav__empty {
    color: var(--color-text-muted);
    font-style: italic;
}

.news-archive-nav__back {
    margin: 0;
    padding-top: 0.85rem;
    border-top: 1px solid var(--color-line);
}

.news-archive-nav__back-link {
    font-weight: 600;
}

.news-tag-filter {
    margin: 0 0 1.75rem;
}

.news-tag-filter__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.news-tag {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border: 1px solid var(--color-line);
    border-radius: 999px;
    background: var(--color-panel-soft);
    color: inherit;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
}

.news-tag:hover,
.news-tag:focus-visible {
    border-color: var(--color-accent);
    text-decoration: none;
}

.news-tag--active {
    border-color: var(--color-accent);
    background: var(--color-accent-soft, var(--color-panel));
    color: var(--color-accent-text, inherit);
}

.news-entry__footer {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-line);
}

.news-entry__tags {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    line-height: 1.5;
}

.news-entry__tags-label {
    font-weight: 600;
}

.news-entry__tags .news-tag--inline + .news-tag--inline {
    margin-left: 0.15rem;
}

.figure {
    margin: 2rem 0;
    padding: 0.75rem;
    border: 1px solid var(--color-line);
    border-radius: 0.9rem;
    background: var(--color-panel-soft);
    box-shadow: var(--shadow-panel);
}

.figure img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 0.55rem;
}

.figure--square {
    border-radius: 0;
}

.figure--square img {
    border-radius: 0;
}

.figure figcaption {
    margin-top: 0.75rem;
    color: var(--color-text-muted);
    font-family: var(--font-ui);
    font-size: 0.86rem;
    line-height: 1.45;
    text-align: center;
}

.figure-gallery {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;

    margin: 2rem 0;
    padding: 1.25rem;

    border: 2px solid rgba(159, 107, 50, 0.35);
    border-radius: 1.1rem;

    background:
        linear-gradient(
            180deg,
            rgba(255, 250, 240, 0.82),
            rgba(239, 228, 208, 0.82)
        );

    box-shadow: var(--shadow-panel);
}

.figure-gallery .figure {
    margin: 0;
    padding: 0.6rem;

    border-width: 1px;
    box-shadow: none;
}

.figure-gallery .figure figcaption {
    font-size: 0.78rem;
}

.figure-gallery--compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.figure-gallery--compact .figure {
    padding: 0.45rem;
}

.figure-gallery--compact .figure figcaption {
    font-size: 0.72rem;
}


/* ==========================================================================
   Nonogram grids (table.grid.nono)
   ========================================================================== */

.page-wrapper table.grid.nono {
    --nono-size: 1.25rem;

    width: max-content;
    max-width: 100%;
    margin: 1.25rem 0;
    border-collapse: separate;
    border-spacing: 0;
    font-family: var(--font-ui);
}

.page-wrapper table.grid.nono caption {
    caption-side: top;
    margin-bottom: 0.4rem;
    color: var(--color-text-muted);
    font-size: 0.82rem;
    line-height: 1.4;
    text-align: left;
}

.page-wrapper table.grid.nono th,
.page-wrapper table.grid.nono td {
    padding: 0;
    border: 1px solid #8a7355;
    vertical-align: top;
    line-height: 0;
}

.page-wrapper table.grid.nono th {
    border-color: transparent;
}

.page-wrapper table.grid.nono th.empty {
    width: calc(var(--nono-size) * 3);
    border: none;
}

.page-wrapper table.grid.nono .nono-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--nono-size);
    height: var(--nono-size);
    box-sizing: border-box;
    font-size: 0.7rem;
    line-height: 1;
}

.page-wrapper table.grid.nono th .nono-cell {
    background: #e6dccb;
    color: var(--color-text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.page-wrapper table.grid.nono td .nono-cell {
    background: #fffaf0;
}

.page-wrapper table.grid.nono td.filled .nono-cell {
    background: #1f1a14;
}

.page-wrapper table.grid.nono td.half .nono-cell {
    background: #b8aa96;
}

.page-wrapper table.grid.nono td.error .nono-cell {
    background: #c44b4b;
    color: #fff;
}

.page-wrapper table.grid.nono td.non .nono-cell,
.page-wrapper table.grid.nono td.nonhalf .nono-cell {
    color: #6b5d4b;
}

.page-wrapper table.grid.nono td.topleft {
    border-top: 2px solid #432811;
    border-left: 2px solid #432811;
}

.page-wrapper table.grid.nono td.top {
    border-top: 2px solid #432811;
}

.page-wrapper table.grid.nono td.topright {
    border-top: 2px solid #432811;
    border-right: 2px solid #432811;
}

.page-wrapper table.grid.nono td.left {
    border-left: 2px solid #432811;
}

.page-wrapper table.grid.nono td.right {
    border-right: 2px solid #432811;
}

.page-wrapper table.grid.nono td.bottomleft {
    border-bottom: 2px solid #432811;
    border-left: 2px solid #432811;
}

.page-wrapper table.grid.nono td.bottom {
    border-bottom: 2px solid #432811;
}

.page-wrapper table.grid.nono td.bottomright {
    border-bottom: 2px solid #432811;
    border-right: 2px solid #432811;
}

/* ==========================================================================
   Books
   ========================================================================== */

/* Grid cover cards and edition detail scans share base image framing. */
.page-wrapper .book-cover-card__image,
.page-wrapper .book-edition__cover-link img,
.page-wrapper .book-edition__cover-image {
    margin: 0;
    border-radius: 0.2rem;
    box-shadow: 0 0.2rem 0.65rem rgba(42, 27, 11, 0.14);
}

/* --- Edition detail ---------------------------------------------------- */

.book-edition {
    margin-block: 2rem 0;
    padding-block: 1.75rem 0;
    border-top: 1px solid var(--color-line);
}

.book-edition__header {
    margin-bottom: 1.25rem;
}

.book-edition__title {
    margin: 0;
    max-width: none;
}

.book-edition__read-status {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.book-edition__record {
    display: grid;
    gap: 1.5rem;
    margin: 0 0 1.75rem;
}

.book-edition__record--no-covers {
    grid-template-columns: 1fr;
}

.book-edition__meta {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-line);
    border-radius: 0.75rem;
    background: var(--color-panel-soft);
    align-self: start;
    overflow: hidden;
}

.book-edition__meta-row {
    display: grid;
    grid-template-columns: minmax(9rem, 12rem) minmax(0, 1fr);
    gap: 0 1.25rem;
    padding: 0.55rem 1.25rem;
    border-bottom: 1px solid var(--color-line);
    align-items: baseline;
}

.book-edition__meta-row:last-child {
    border-bottom: none;
}

.page-wrapper .book-edition__meta dt {
    margin-top: 0;
}

.book-edition__meta dt {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--color-text-muted);
}

.book-edition__meta dd {
    margin: 0;
    min-width: 0;
}

.book-edition__identifiers {
    margin: 0;
    padding-left: 1.15rem;
}

.book-edition__identifiers li + li {
    margin-top: 0.3rem;
}

.book-copy-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.15rem;
    padding: 0.15rem;
    border: 1px solid transparent;
    border-radius: 0.3rem;
    background: transparent;
    color: var(--color-text-muted);
    vertical-align: middle;
    line-height: 0;
    cursor: pointer;
}

.book-copy-button:hover,
.book-copy-button:focus-visible {
    color: var(--color-text);
    border-color: var(--color-line);
    background: var(--color-panel-muted);
}

.book-copy-button:focus-visible {
    outline: 2px solid var(--color-accent, #2a6f97);
    outline-offset: 1px;
}

.book-copy-button--copied {
    color: var(--color-ok, #2f7d32);
}

.book-copy-button--error {
    color: var(--color-error, #b00020);
}

.book-copy-button__icon {
    display: block;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.book-edition__covers {
    margin: 0;
    padding: 1rem 1.25rem;
    border: 1px solid var(--color-line);
    border-radius: 0.75rem;
    background: var(--color-panel-muted);
    min-width: 0;
}

.book-edition__covers-heading {
    margin: 0 0 0.85rem;
    padding: 0;
    font-size: clamp(1rem, 1.4vw, 1.15rem);
}

.book-edition__cover-gallery {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    gap: 0;
    width: 100%;
    min-width: 0;
}

.book-edition__cover-item {
    flex: 0 1 auto;
    min-width: 0;
    margin: 0;
    /* Allow the flex item to shrink below the image’s intrinsic width. */
    overflow: hidden;
}

.book-edition__cover-link {
    display: block;
    line-height: 0;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0.35rem;
    border: 1px solid rgba(216, 200, 174, 0.85);
    border-radius: 0.45rem;
    background: var(--color-panel-soft);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.book-edition__cover-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-panel);
}

.book-edition__cover-link:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.book-edition__cover-image {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: contain;
}

.book-edition__cover-hint {
    margin: 0.75rem 0 0;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.book-edition__hires {
    margin-top: 1.35rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--color-line);
}

.book-edition__covers-heading + .book-edition__hires {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.book-edition__hires-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.65rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.book-edition__hires-links li {
    margin: 0;
}

.book-edition__hires-links a {
    display: inline-block;
    padding: 0.35rem 0.7rem;
    border: 1px dashed rgba(120, 104, 82, 0.55);
    border-radius: 0.35rem;
    background: rgba(255, 255, 255, 0.45);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    line-height: 1.3;
    text-decoration: none;
    color: var(--color-text);
}

.book-edition__hires-links a:hover {
    border-color: var(--color-accent);
    border-style: solid;
    background: #fff;
}

/*
 * Side-by-side cover scans + metadata — see --book-edition-record-breakpoint*
 * in :root. Match the rem values to those variables (media queries can't use var()).
 */
@media (min-width: 90rem) {
    .book-edition__record:not(.book-edition__record--no-covers):not(.book-edition__record--has-flaps) {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
        gap: 1.5rem 1.75rem;
        align-items: start;
    }

    .book-edition__record:not(.book-edition__record--no-covers):not(.book-edition__record--has-flaps)
        .book-edition__meta {
        min-width: 0;
    }
}

@media (min-width: 130rem) {
    .book-edition__record--has-flaps:not(.book-edition__record--no-covers) {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
        gap: 1.5rem 1.75rem;
        align-items: start;
    }

    .book-edition__record--has-flaps:not(.book-edition__record--no-covers) .book-edition__meta {
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .book-edition__cover-link {
        transition: none;
    }

    .book-edition__cover-link:hover {
        transform: none;
    }
}

.book-edition__synopsis,
.book-edition__review,
.book-edition__structure {
    margin-top: 1.5rem;
    padding: 1rem 1.25rem;
    border-left: 3px solid var(--color-accent);
    border-radius: 0 0.65rem 0.65rem 0;
    background: var(--color-panel-soft);
}

.book-edition__synopsis h3,
.book-edition__review h3,
.book-edition__structure h3 {
    margin-top: 0;
    padding-left: 0;
}

.book-edition__prose > :first-child {
    margin-top: 0;
}

.book-edition__prose > :last-child {
    margin-bottom: 0;
}

/* --- Shared book typography / counts ----------------------------------- */

.book,
.game,
.ship,
.movie,
.series,
.story,
.essay,
.periodical,
.poem {
    font-style: italic;
}

.book-count,
.number_amount {
    color: var(--color-text-muted);
    font-family: var(--font-ui);
    font-size: 0.75rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    opacity: 0.88;
}

.book-series-complete {
    color: var(--color-text-muted);
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-style: italic;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: lowercase;
}

.small.grey {
    color: var(--color-text-muted);
    font-size: 0.9em;
}

.strong {
    font-weight: 700;
}

/* --- Edition lists ----------------------------------------------------- */

.book-list {
    margin: 0 0 1.5rem;
    padding-left: 1.25rem;
}

.book-list li {
    margin-bottom: 0.35rem;
}

.book-list__pseudonym-note {
    font-size: 0.88em;
    color: var(--color-muted, #6b6560);
    font-style: italic;
}

.book-list.column li {
    break-inside: avoid;
    margin-bottom: 0.5rem;
}

/* --- Cover grid (browse) ----------------------------------------------- */

.book-edition-section {
    margin: 0 0 1.75rem;
    padding: 1rem 1.15rem 1.15rem;
    border: 1px solid var(--color-line);
    border-radius: 0.85rem;
    background: linear-gradient(180deg, rgba(255, 252, 246, 0.92), var(--color-panel-soft));
    box-shadow: 0 0.15rem 0.45rem rgba(42, 27, 11, 0.05);
}

.book-edition-section > h3 {
    margin: 0 0 0.85rem;
    padding: 0 0 0.45rem;
    border-bottom: 1px solid rgba(216, 200, 174, 0.45);
}

.book-edition-section > h4 {
    margin: 1rem 0 0.5rem;
    font-size: clamp(0.95rem, 1.2vw, 1.05rem);
}

.book-edition-section .book-cover-grid,
.book-edition-section .book-list {
    margin-bottom: 0;
}

.book-cover-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 1rem 0.85rem;
    margin: 0 0 1.5rem;
}

/* --- Library hub lead layout -------------------------------------------- */

.library-hub__lead {
    margin: 0 0 1.25rem;
}

.library-hub__prose > :last-child {
    margin-bottom: 0;
}

.library-hub__current {
    margin: 0 0 1.25rem;
}

.library-hub__current > h2 {
    margin-top: 0;
}

.library-hub__previews {
    display: grid;
    grid-template-columns: 1fr;
    row-gap: 0.85rem;
    margin: 0 0 1.5rem;
}

.library-hub__previews > .column_element {
    margin-bottom: 0;
}

@media (min-width: 72rem) {
    .library-hub__previews {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        column-gap: clamp(1.5rem, 2.5vw, 2.75rem);
    }

    .library-hub__lead {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(13rem, 18rem);
        gap: 1.5rem 2rem;
        align-items: start;
    }

    .library-hub__current {
        margin-bottom: 0;
        padding: 0.85rem 1rem;
        border: 1px solid var(--color-line);
        border-radius: 0.75rem;
        background: var(--color-panel-soft);
        align-self: start;
    }
}

.book-cover-grid--hub-compact {
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: 0.65rem;
    margin-bottom: 0;
}

@media (min-width: 72rem) {
    .book-cover-grid--hub-compact {
        grid-template-columns: 1fr;
    }
}

.book-cover-grid--hub-compact .book-cover-card {
    padding: 0.55rem 0.5rem 0.45rem;
    contain-intrinsic-size: 9rem 15rem;
}

.book-cover-grid--hub-compact .book-cover-card__image {
    height: 120px;
}

.page-wrapper .book-cover-grid--hub-compact .book-cover-card .book-cover-card__title {
    font-size: 1.1rem;
}

/* --- Library portal (redesigned hub) ------------------------------------- */

.library-portal {
    /* Tweak Browse column width here (Cards/Compact/Covers side-by-side). */
    --library-portal-browse-width: 36rem;
    margin: 0 0 1.5rem;
}

.library-portal__lede {
    max-width: 40rem;
    margin: 0 0 1.25rem;
}

.library-portal__search {
    margin: 0 0 1.5rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--color-line);
    border-radius: 0.75rem;
    background: linear-gradient(180deg, rgba(255, 252, 246, 0.95), var(--color-panel-soft));
}

.library-portal__search-label {
    display: block;
    font-weight: 600;
    margin: 0 0 0.35rem;
}

.library-portal__search-hint {
    margin: 0 0 0.65rem;
    color: var(--color-text-muted, #5c5346);
    font-size: 0.95rem;
}

.library-portal__search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 0.65rem;
    align-items: center;
}

.library-portal__search-row input[type="search"] {
    flex: 1 1 14rem;
    min-width: 0;
    max-width: 100%;
}

.library-portal__lead {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin: 0 0 1.75rem;
    align-items: start;
}

.library-portal__browse {
    width: 100%;
    max-width: var(--library-portal-browse-width);
    padding: 1.1rem 1.15rem 1.2rem;
    border: 1px solid var(--color-line);
    border-radius: 0.85rem;
    background: linear-gradient(180deg, #fffdf8, var(--color-panel-soft));
    box-shadow: 0 1px 0 rgb(255 255 255 / 0.65) inset;
}

.library-portal__browse > h3 {
    margin-top: 0;
    font-size: 1.45rem;
}

.library-portal__browse-count {
    margin: 0 0 0.65rem;
}

.library-portal__sidebar {
    display: grid;
    gap: 1.25rem;
    min-width: 0;
}

.library-portal__views {
    margin: 0.35rem 0 0;
}

.library-portal__view-examples {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem 0.75rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.library-portal__view-example {
    display: flex;
    flex-direction: column;
    /* Stacked default (< 36rem): left-align pills + previews. */
    align-items: flex-start;
    text-align: left;
    gap: 0.55rem;
    margin: 0;
    min-width: 0;
}

.library-portal__view-example--list {
    width: 100%;
}

.library-portal__view-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.95rem;
    min-height: 2.25rem;
    border: 1px solid var(--color-line);
    border-radius: 999px;
    background: var(--color-panel-muted);
    color: var(--color-text-muted);
    font-family: var(--font-ui);
    font-size: 0.88rem;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.library-portal__view-pill:hover,
.library-portal__view-pill:focus-visible {
    color: var(--color-accent-dark);
    background: var(--color-panel-soft);
    box-shadow: 0 0.1rem 0.35rem rgba(42, 27, 11, 0.12);
    text-decoration: none;
}

.library-portal__view-desc {
    margin: 0;
    color: var(--color-text-muted, #5c5346);
    font-size: 0.95rem;
}

.library-portal__view-preview {
    width: 100%;
    min-width: 0;
}

.library-portal__view-preview .book-list,
.library-portal__view-preview .book-cover-grid {
    margin: 0;
}

.library-portal__view-preview--list .book-list,
.library-portal__view-preview--list .book-list.column {
    width: 100%;
    max-width: none;
    /* Beat later .book-list.column multi-column rules (3/4/5 cols). */
    columns: 1;
    column-count: 1;
}

.library-portal__view-preview .book-cover-grid {
    grid-template-columns: minmax(0, 11rem);
    justify-content: flex-start;
}

.library-portal__view-preview--compact .book-cover-grid {
    grid-template-columns: minmax(0, 6.5rem);
}

.library-portal__view-preview--covers .book-cover-grid {
    grid-template-columns: minmax(0, 5rem);
}

@media (min-width: 36rem) {
    .library-portal__view-examples {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: start;
    }

    /* Side-by-side columns: center each example in its track. */
    .library-portal__view-example:not(.library-portal__view-example--list) {
        align-items: center;
        text-align: center;
    }

    .library-portal__view-example--list {
        grid-column: 1 / -1;
    }

    .library-portal__view-preview .book-cover-grid {
        justify-content: center;
    }
}

.library-portal__current {
    padding: 0.95rem 1rem;
    border: 1px solid var(--color-line);
    border-radius: 0.75rem;
    background: var(--color-panel-soft);
}

.library-portal__current > h3 {
    margin-top: 0;
}

.library-portal__explore {
    margin: 0;
}

.library-portal__explore > h3 {
    margin-top: 0;
}

.library-portal__explore-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.library-portal__explore-item {
    margin: 0;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--color-line);
    border-radius: 0.7rem;
    background: var(--color-panel-soft);
}

.library-portal__explore-title {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
    font-weight: 600;
}

.library-portal__explore-desc {
    margin: 0;
    font-size: 0.95rem;
}

.library-portal__explore-secondary {
    list-style: none;
    margin: 0.55rem 0 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    font-size: 0.95rem;
}

.library-portal__notes {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin: 0 0 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--color-line);
}

.library-portal__about > h3,
.library-portal__spoiler > h3 {
    margin-top: 0;
}

/* Browse width when lead is still stacked (same as <768px column layout). */
@media (min-width: 56rem) {
    .library-portal {
        --library-portal-browse-width: 36rem;
    }

    .library-portal__notes {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.5rem 2rem;
    }
}

@media (min-width: 72rem) {
    .library-portal {
        --library-portal-browse-width: 40rem;
    }
}

/*
 * Side-by-side Browse | sidebar only above ~1400px.
 * At ~1400px and below, stack like the narrow (<768px) layout to avoid overlap.
 */
@media (min-width: 90rem) {
    .library-portal {
        --library-portal-browse-width: 40rem;
    }

    .library-portal__lead {
        grid-template-columns: var(--library-portal-browse-width) minmax(12rem, 1fr);
        gap: 1.35rem 1.5rem;
    }
}

/* Explore destination cards: two columns when wider than 2000px. */
@media (min-width: 125.0625rem) {
    .library-portal__explore-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/*
 * Library Compact / Covers views — use stored compact (128px) / covers (80px) JPEGs.
 * Images render at intrinsic size (no CSS scaling of thumbs).
 */
/* Two classes so Compact wins over later single-class .book-cover-grid media tweaks. */
.book-cover-grid.book-cover-grid--compact-view {
    grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
    gap: 0.5rem 0.4rem;
}

.book-cover-grid--compact-view .book-cover-card {
    gap: 0.25rem;
    padding: 0.4rem 0.3rem 0.3rem;
    border-radius: 0.55rem;
    contain-intrinsic-size: 6.5rem 11rem;
}

.book-cover-grid--compact-view .book-cover-card__image {
    height: auto;
}

.page-wrapper .book-cover-grid--compact-view .book-cover-card .book-cover-card__title {
    font-size: 0.95rem;
    line-height: 1.2;
}

.book-cover-grid--compact-view .book-cover-card__title a {
    -webkit-line-clamp: 2;
}

.book-cover-grid--covers-view {
    /* Flex wrap keeps each tile cover-width; grid minmax columns were adding side gutters. */
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    justify-content: flex-start;
    gap: 0.12rem 0.08rem;
}

.book-cover-grid--covers-view .book-cover-card {
    flex: 0 0 auto;
    width: fit-content;
    gap: 0;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    content-visibility: visible;
    contain-intrinsic-size: none;
}

.book-cover-grid--covers-view .book-cover-card:hover {
    transform: none;
    box-shadow: none;
    border-color: transparent;
}

.book-cover-grid--covers-view .book-cover-card__media {
    align-self: flex-start;
}

.book-cover-grid--covers-view .book-cover-card__image {
    width: auto;
    max-width: none;
    height: auto;
}

.book-cover-grid--covers-view .book-cover-card__media:focus-visible {
    outline-offset: 1px;
}

.book-cover-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    min-width: 0;
    min-height: 100%;
    overflow: hidden;
    padding: 0.75rem 0.65rem 0.55rem;
    border: 1px solid var(--color-line);
    border-radius: 0.85rem;
    background: linear-gradient(180deg, var(--color-panel-soft), var(--color-panel-muted));
    box-shadow: 0 0.15rem 0.45rem rgba(42, 27, 11, 0.06);
    text-align: center;
    content-visibility: auto;
    contain-intrinsic-size: 11rem 20rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.book-cover-card:hover {
    transform: translateY(-2px);
    border-color: rgba(159, 107, 50, 0.45);
    box-shadow: var(--shadow-panel);
}

.book-cover-card__media {
    display: block;
    line-height: 0;
    align-self: center;
}

.book-cover-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    width: 100%;
    min-width: 0;
}

.book-cover-card__heading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    min-width: 0;
}

.page-wrapper .book-cover-card :is(
    .book-cover-card__title,
    .book-cover-card__sort-meta,
    .book-cover-card__byline,
    .book-cover-card__series-number,
    .book-cover-card__read-status
) {
    margin: 0;
    padding: 0;
}

.page-wrapper .book-cover-card .book-cover-card__title {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    line-height: 1.15;
    width: 100%;
    min-width: 0;
}

.book-cover-card__title a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    overflow-wrap: anywhere;
    word-break: normal;
    min-width: 0;
    text-decoration: none;
}

.book-cover-card__title a:hover {
    text-decoration: underline;
}

.book-cover-card__sort-meta {
    line-height: 1.05;
    text-align: center;
}

.book-cover-card__sort-meta .book-count {
    font-size: 0.72rem;
}

.book-cover-card__footer {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    width: 100%;
    margin-top: auto;
    padding-top: 0.2rem;
}

.book-cover-card__media:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 3px;
    border-radius: 0.25rem;
}

.book-cover-card__image {
    display: block;
    width: auto;
    max-width: 100%;
    height: 200px;
    object-fit: contain;
}

.book-cover-card__series-number {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.book-cover-card__byline {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    line-height: 1.25;
    color: var(--color-text-muted);
    text-align: center;
    width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
}

.book-cover-card__byline a {
    text-decoration: none;
}

.book-cover-card__byline a:hover {
    text-decoration: underline;
}

/* --- List / grid toggle ------------------------------------------------ */

.book-list-display-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0;
    margin: -0.15rem 0 1.25rem;
    padding: 0.2rem;
    border: 1px solid var(--color-line);
    border-radius: 999px;
    background: var(--color-panel-muted);
    font-family: var(--font-ui);
    font-size: 0.88rem;
}

.book-list-display-toggle__label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.book-list-display-toggle__option {
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.book-list-display-toggle__option:hover {
    color: var(--color-accent-dark);
}

.book-list-display-toggle__option.is-active {
    background: var(--color-panel-soft);
    color: var(--color-accent-dark);
    box-shadow: 0 0.1rem 0.35rem rgba(42, 27, 11, 0.12);
    font-weight: 700;
    text-decoration: none;
}

/* Local-only markers (nav, breadcrumbs, site map, page panel); matches body.env-local. */
.is-local-only {
    box-sizing: border-box;
    outline: 3px solid red;
    outline-offset: 1px;
}

/* Local-only Per page → Unlimited; matches body.env-local viewport marker. */
.book-list-options__per-page-select--local-only {
    box-sizing: border-box;
    outline: 3px solid red;
    outline-offset: 1px;
}

/* Local-only Quick filter row (e.g. cover nudity). */
.book-list-options__local-only {
    box-sizing: border-box;
    display: inline-block;
    max-width: 100%;
    margin: 0.35rem 0 0;
    padding: 0.25rem 0.35rem;
    outline: 3px solid red;
    outline-offset: 1px;
}

.book-list-display-toggle__sep {
    display: none;
}

.page-wrapper h2 + .book-list-display-toggle {
    margin-top: 0.35rem;
}

.book-series-reading-order-toggle + .book-list-display-toggle {
    margin-top: 0.35rem;
}

.page-wrapper h3 + .book-list,
.page-wrapper h3 + .book-cover-grid {
    margin-top: 0.35rem;
}

.book-alpha-index {
    margin-bottom: 1.5rem;
}

.books-alpha-none .book-alpha-rolodex,
.books-alpha-sticky .book-alpha-rolodex {
    display: none;
}

.books-alpha-rolodex .book-alpha-rolodex {
    position: sticky;
    z-index: 7;
    top: var(--book-sticky-subhead-top);

    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.45rem;

    margin: 0 0 0.75rem;
    padding: 0.35rem 0 0.55rem;
    border-bottom: 1px solid rgba(216, 200, 174, 0.55);
    background: rgba(244, 239, 230, 0.96);
}

.book-alpha-rolodex:empty,
.book-alpha-rolodex:not(:has(.book-alpha-rolodex__chip:not([hidden]))) {
    padding-bottom: 0;
    border-bottom: 0;
}

.book-alpha-rolodex__chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 1.65rem;
    padding: 0.18rem 0.5rem;

    border: 1px solid var(--color-line);
    border-radius: 0.45rem;
    background: var(--color-panel-soft);
    box-shadow: var(--shadow-panel);

    font-family: var(--font-ui);
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    color: var(--color-accent-dark);
}

.book-alpha-rolodex__chip[hidden] {
    display: none;
}

.book-alpha-rolodex__chip:hover,
.book-alpha-rolodex__chip:focus-visible {
    background: var(--color-panel-muted);
    text-decoration: none;
}

.book-alpha-rolodex__chip.is-current {
    border-color: rgba(159, 107, 50, 0.45);
    background: var(--color-panel-muted);
}

.books-alpha-rolodex .book-alpha-section {
    scroll-margin-top: calc(var(--book-sticky-subhead-top) + 3.5rem);
}

.books-alpha-sticky .book-alpha-section {
    scroll-margin-top: calc(var(--book-sticky-subhead-top) + 0.5rem);
}

.book-alpha-section + .book-alpha-section {
    margin-top: 1.5rem;
}

.book-alpha-heading {
    margin: 0 0 0.65rem;
    padding: 0 0 0.35rem;
    border-bottom: 1px solid rgba(216, 200, 174, 0.35);
}

.books-alpha-sticky .book-alpha-heading {
    position: sticky;
    z-index: 7;
    top: var(--book-sticky-subhead-top);
    padding: 0.45rem 0 0.35rem;
    border-bottom-color: rgba(216, 200, 174, 0.55);
    background: rgba(244, 239, 230, 0.96);
}

/* --- Search / filter forms --------------------------------------------- */

.book-search,
.book-list-options {
    margin: 1rem 0 1.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--color-line);
    border-radius: 0.75rem;
    background: var(--color-panel-soft);
}

.book-list-options h2 {
    display: block;
    margin: 0 0 0.75rem;
    padding: 0;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-weight: 700;
    text-align: left;
}

.book-list-options__columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
    min-width: 0;
}

@media (max-width: 52rem) {
    .book-list-options__columns {
        grid-template-columns: 1fr;
    }
}

.book-list-options__panel {
    min-width: 0;
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-line);
    border-radius: 0.5rem;
    background: #fff;
}

/* Fieldsets default to min-content width; nowrap option pairs then refuse to wrap. */
.book-list-options fieldset {
    min-width: 0;
}

.book-list-options__panel-actions {
    margin: 0.85rem 0 0;
}

.book-list-options__panel-actions a {
    font-family: var(--font-ui);
    font-size: 0.92rem;
}

.book-list-options label,
.book-search label {
    display: inline;
    margin-right: 1rem;
    font-family: var(--font-ui);
    font-size: 0.92rem;
}

/* Keep each control + its text as one wrap unit on wide viewports. */
.book-list-options label:has(input[type="checkbox"]),
.book-list-options label:has(input[type="radio"]) {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    white-space: nowrap;
    vertical-align: top;
}

.book-list-options__section-headings,
.book-list-options__alpha-headings {
    display: block;
    margin: 0.65rem 0 0.75rem;
}

.book-list-options__list-group,
.book-list-options__list-sort,
.book-list-options__list-dir,
.book-list-options__day-cycle-presentation,
.book-list-options__busy-filter {
    display: block;
    margin: 0.65rem 0 0.75rem;
}

.book-list-options__sort-category {
    display: block;
    margin: 0 0 0.55rem;
}

.book-list-options__sort-category:last-child {
    margin-bottom: 0;
}

.book-list-options__within-sort {
    display: block;
    margin: 0.65rem 0 0.75rem;
}

.book-list-options__role-filter {
    margin: 0.85rem 0 0.5rem;
    padding: 0.65rem 0.75rem 0.55rem;
    border: 1px solid var(--color-line);
    border-radius: 0.5rem;
}

.book-list-options__role-filter legend {
    padding: 0 0.35rem;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-weight: 700;
}

.book-list-options__select-all {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0 0.85rem 0.45rem 0;
    font-family: var(--font-ui);
    font-weight: 700;
}

.book-list-options__hint {
    margin: 0 0 0.45rem;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.book-list-options__group-label {
    display: inline;
    margin-right: 0.35rem;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-weight: 700;
}

.book-list-options__radio {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-right: 0.85rem;
    max-width: 100%;
    white-space: nowrap;
    vertical-align: top;
}

@media (max-width: 52rem) {
    /*
     * Placed after base .book-list-options rules so cascade wins.
     * Spacing comes only from parent gap (no per-label vertical margins).
     */
    .book-list-options label:has(input[type="checkbox"]),
    .book-list-options label:has(input[type="radio"]),
    .book-list-options label:has(input[type="number"]),
    .book-list-options__select,
    .book-list-options__radio {
        display: flex;
        align-items: center;
        gap: 0.35rem;
        width: fit-content;
        max-width: 100%;
        min-width: 0;
        margin: 0;
        white-space: nowrap;
    }

    .book-list-options__group-label {
        display: block;
        margin: 0 0 0.25rem;
    }

    .book-list-options__list-sort,
    .book-list-options__list-dir,
    .book-list-options__day-cycle-presentation,
    .book-list-options__busy-filter,
    .book-list-options__section-headings,
    .book-list-options__within-sort,
    .book-list-options__role-filter,
    .book-list-options__sort-category {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }

    .book-list-options__range {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.35rem 0.75rem;
    }

    .book-list-options__range legend {
        flex: 1 0 100%;
        margin-bottom: 0;
    }
}

/* From narrow-desktop down: allow long label text to wrap inside a pair. */
@media (max-width: 72rem) {
    .book-list-options label:has(input[type="checkbox"]),
    .book-list-options label:has(input[type="radio"]),
    .book-list-options__radio {
        width: auto;
        max-width: 100%;
        white-space: normal;
        align-items: flex-start;
    }
}

.book-search input[type="search"],
.book-search select,
.book-list-options input[type="checkbox"] {
    accent-color: var(--color-accent);
}

.book-search input[type="search"] {
    min-width: min(100%, 16rem);
    padding: 0.35rem 0.55rem;
    border: 1px solid var(--color-line);
    border-radius: 0.35rem;
    background: #fff;
}

.book-search select,
.book-list-options input[type="submit"],
.book-search input[type="submit"] {
    font-family: var(--font-ui);
    font-size: 0.92rem;
}

.book-list-options input[type="submit"],
.book-search input[type="submit"] {
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--color-accent);
    border-radius: 0.35rem;
    background: var(--color-accent);
    color: var(--color-text-inverse);
    cursor: pointer;
}

.book-list-options input[type="submit"]:hover,
.book-search input[type="submit"]:hover {
    background: var(--color-accent-dark);
    border-color: var(--color-accent-dark);
}

.book-list-options__facets {
    margin: 0;
    padding: 0;
    border: 0;
}

.book-list-options__facets legend {
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.book-list-options__advanced {
    margin: 0.75rem 0 1rem;
    min-width: 0;
    max-width: 100%;
}

.book-list-options__advanced summary {
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-weight: 600;
}

/* Advanced numeric ranges: each From/To label+input wraps as one unit. */
.book-list-options__range,
.book-list-options__title-meta {
    margin: 0.55rem 0 0;
    padding: 0;
    border: 0;
    min-width: 0;
    max-width: 100%;
}

.book-list-options__range legend,
.book-list-options__title-meta legend {
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    padding: 0;
}

/* Keep label text + control together (same idea as Quick filter pairs). */
.book-list-options label:has(input[type="number"]),
.book-list-options__select {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
    min-width: 0;
    margin-right: 1rem;
    margin-bottom: 0.35rem;
    white-space: nowrap;
    vertical-align: top;
    box-sizing: border-box;
}

.book-list-options input[type="number"],
.book-list-options input[type="text"],
.book-list-options select {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.book-list-options label:has(input[type="number"]) input[type="number"] {
    flex: 1 1 auto;
    width: 5.5rem;
    min-width: 0;
    max-width: 100%;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--color-line);
    border-radius: 0.35rem;
    background: #fff;
    font-family: var(--font-ui);
    font-size: 0.92rem;
}

.book-list-options__select select {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-list-options__per-page {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
    margin: 0.5rem 0 1rem;
    font-family: var(--font-ui);
    font-size: 0.92rem;
}

.book-list-options__per-page-label {
    font-weight: 600;
}

.book-list-options__per-page-select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--color-line);
    border-radius: 0.35rem;
    background: #fff;
    font-family: var(--font-ui);
    font-size: 0.92rem;
}

.book-list-options__per-page-submit {
    padding: 0.3rem 0.75rem;
    border: 1px solid var(--color-accent);
    border-radius: 0.35rem;
    background: var(--color-accent);
    color: var(--color-text-inverse);
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
}

.book-list-options__per-page-submit:hover {
    background: var(--color-accent-dark);
    border-color: var(--color-accent-dark);
}

.book-pagination {
    margin: 1rem 0 1.25rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--color-line);
    border-radius: 0.75rem;
    background: var(--color-panel-soft);
}

.book-pagination-summary {
    margin: 0 0 0.65rem;
    font-family: var(--font-ui);
    font-size: 0.95rem;
}

.book-pagination__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1rem;
}

.book-pagination__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    list-style: none;
    margin: 0;
    padding: 0;
    font-family: var(--font-ui);
    font-size: 0.92rem;
}

.book-pagination__item a,
.book-pagination__item span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--color-line);
    border-radius: 0.35rem;
    background: #fff;
    color: inherit;
    text-decoration: none;
    line-height: 1.2;
}

.book-pagination__item a:hover {
    border-color: var(--color-accent);
    color: var(--color-accent-dark);
}

.book-pagination__item--nav a,
.book-pagination__item--nav span {
    min-width: auto;
    padding: 0.35rem 0.85rem;
    font-weight: 600;
}

.book-pagination__item--current span {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-text-inverse);
    font-weight: 700;
}

.book-pagination__item--ellipsis span {
    min-width: auto;
    padding: 0.35rem 0.25rem;
    border: 0;
    background: transparent;
    color: var(--color-text-muted);
}

.book-pagination__item--disabled span {
    opacity: 0.45;
    cursor: default;
}

.book-pagination__meta {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 0.88rem;
    color: var(--color-text-muted);
}

.book-active-filters {
    margin: 0 0 1rem;
}

.book-active-filters__list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
}

.book-active-filters__list li {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.55rem;
    border: 1px solid var(--color-line);
    border-radius: 0.4rem;
    background: var(--color-panel-soft);
    font-family: var(--font-ui);
    font-size: 0.88rem;
}

.book-search-match-context {
    color: var(--color-muted, #666);
    font-size: 0.9em;
}

.book-list-options select {
    font-family: var(--font-ui);
    font-size: 0.92rem;
    padding: 0.25rem 0.4rem;
    border: 1px solid var(--color-line);
    border-radius: 0.35rem;
    background: #fff;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

/* --- Essay catalog ----------------------------------------------------- */

.essay-catalog {
    margin: 0 0 1.5rem;
}

.essay-catalog dt {
    margin-top: 1rem;
    font-weight: 700;
}

.essay-catalog dt:first-child {
    margin-top: 0;
}

.essay-catalog dd {
    margin: 0.35rem 0 0;
    padding: 0 0 0 1rem;
    border-left: 3px solid rgba(159, 107, 50, 0.35);
}

.essay-catalog dd > :first-child {
    margin-top: 0;
}

.essay-catalog dd > :last-child {
    margin-bottom: 0;
}

/* --- Links page -------------------------------------------------------- */

.outline-nav {
    margin: 0 0 1.5rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--color-line);
    border-radius: 0.75rem;
    background: var(--color-panel-soft);
}

.outline-nav ul {
    margin: 0.35rem 0 0;
    padding-left: 1.25rem;
}

.outline-nav > ul {
    margin-top: 0;
    padding-left: 1rem;
}

.outline-nav li {
    margin: 0.2rem 0;
}

.link-catalog-column {
    columns: 2 auto;
}

.column.link-catalog-column {
    columns: 2 auto;
}

.link-catalog-column .column_element {
    break-inside: avoid;
}

.link-catalog-column .essay-catalog.link-entry {
    margin: 0;
}

.link-catalog-column .essay-catalog.link-entry dt:first-child {
    margin-top: 0;
}

.site-hidden-local-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.45rem;
    border-radius: 0.25rem;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    vertical-align: middle;
    color: #6b4a12;
    background: rgba(220, 160, 40, 0.22);
    border: 1px solid rgba(180, 120, 20, 0.35);
}

.site-wip-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.45rem;
    border-radius: 0.25rem;
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    vertical-align: middle;
    color: #5a4a1f;
    background: rgba(159, 107, 50, 0.16);
}

.page-wip-notice {
    margin: 0 0 1.25rem;
}

/* --- Llamaphobia comic ------------------------------------------------- */

.comic-strip__image {
    margin: 1rem 0;
}

.comic-strip__image img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 0;
}

.comic-strip__extra {
    margin-top: 1rem;
}

.comic-archive-list {
    margin: 0;
    padding-left: 1.25rem;
}

.comic-news-list,
.comic-news-item {
    margin-bottom: 1.25rem;
}

.comic-news-item__date {
    margin: 0 0 0.35rem;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    color: var(--color-text-muted);
}

.comic-news-item__body > :first-child {
    margin-top: 0;
}

.comic-news-item__body > :last-child {
    margin-bottom: 0;
}

/* --- USN ---------------------------------------------------------------- */

.comic-strip-nav,
.usn-series-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    margin: 1rem 0;
    padding: 0;
    list-style: none;
}

.comic-strip-nav li,
.usn-series-nav li {
    display: flex;
    align-items: center;
}

.comic-strip-nav li:not(:last-child)::after,
.usn-series-nav li:not(:last-child)::after {
    content: '|';
    margin: 0 0.65rem;
    color: var(--color-text-muted);
    user-select: none;
}

.comic-strip-nav a,
.comic-strip-nav .na,
.usn-series-nav a,
.usn-series-nav .na {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border: 1px solid var(--color-line);
    border-radius: 0.65rem;
    background: var(--color-panel-soft);
    box-shadow: var(--shadow-panel);
    font-family: var(--font-ui);
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none;
    color: var(--color-accent-dark);
    white-space: nowrap;
}

.comic-strip-nav a:hover,
.comic-strip-nav a:focus-visible,
.usn-series-nav a:hover,
.usn-series-nav a:focus-visible {
    background: var(--color-panel-muted);
    text-decoration: none;
}

.comic-strip-nav .na,
.usn-series-nav .na {
    border-color: rgba(107, 93, 75, 0.25);
    background: rgba(216, 200, 174, 0.35);
    color: var(--color-text-muted);
    cursor: default;
}

.usn-series-nav__current {
    margin: 0 0 1rem;
    text-align: center;
    font-family: var(--font-ui);
    font-size: 0.92rem;
    color: var(--color-text-muted);
}

.usn-series-nav__fallback {
    margin: 0 0 1rem;
    text-align: center;
}

.usn-math .video {
    margin: 1.5rem 0;
    text-align: center;
}

.usn-math .video iframe {
    display: block;
    max-width: 100%;
    margin: 0 auto;
    border: 0;
}

.usn-math .math_def,
.usn-math .math_example {
    margin: 1.25rem auto;
    padding: 1rem 1.25rem;
    max-width: 42rem;
    border: 1px solid var(--color-line);
    border-radius: 0.85rem;
    background: var(--color-panel-soft);
    box-shadow: var(--shadow-panel);
}

.usn-math .math_def img,
.usn-math .math_example img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1rem auto;
    border-radius: 0;
    box-shadow: none;
}

.usn-math table {
    width: 100%;
    max-width: 100%;
    margin: 1.25rem 0;
    border-collapse: collapse;
    border: 1px solid var(--color-line);
}

.usn-math th,
.usn-math td {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-line);
}

.usn-math th {
    background: var(--color-panel-muted);
    text-align: left;
}

.usn-math td {
    text-align: center;
}

.usn-physics__credit {
    margin: 0 0 1rem;
    font-size: 0.92rem;
    color: var(--color-text-muted);
}

.usn-physics__stage {
    margin: 1rem 0;
    text-align: center;
}

.usn-physics__canvas {
    display: inline-block;
}

.usn-physics__canvas-element {
    display: block;
    max-width: 100%;
    height: auto;
    border: 1px solid var(--color-line);
    border-radius: 0;
    box-shadow: var(--shadow-panel);
}

.usn-physics__controls {
    width: auto;
    max-width: 100%;
    margin: 1.25rem auto;
    border-collapse: collapse;
}

.usn-physics__controls th {
    padding-right: 0.75rem;
    text-align: left;
    white-space: nowrap;
}

.usn-physics__controls td {
    padding: 0.35rem 0.5rem;
}

.usn-physics__slider {
    width: min(100%, 16rem);
}

.usn-physics #amplitudeValue,
.usn-physics #frequencyValue,
.usn-physics #vValue {
    width: 3rem;
}

/* Snell's Law / Fermat interactive demo */
.snell-fermat {
    --snell-accent-2: color-mix(in srgb, var(--color-accent) 35%, #5a6b8a);
    --snell-air: color-mix(in srgb, var(--color-panel-soft) 88%, var(--color-accent) 12%);
    --snell-water: color-mix(in srgb, var(--color-panel-muted) 70%, var(--color-panel) 30%);
    --snell-disabled: 0.48;
    /* Match the standalone prototype content width so the wave surface does not
       grow without bound on ultra-wide layouts (Phase 2A). */
    max-width: 1100px;
}

.snell-fermat .intro {
    color: var(--color-text-muted);
    margin-bottom: 2rem;
    max-width: 75ch;
}

.snell-fermat .interactive {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 1rem;
    align-items: start;
    background: var(--color-panel-soft);
    border: 1px solid color-mix(in srgb, var(--color-line) 70%, transparent);
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1.25rem 0;
}

/* Paint containment on the animated card forces full-card rasterization each
   frame at large widths; keep it only on static sections. */
.snell-fermat .interactive:not([data-view="wave"]) {
    contain: layout paint style;
    content-visibility: auto;
    contain-intrinsic-size: auto 420px;
}

.snell-fermat .visual {
    min-width: 0;
}

.snell-fermat .visual h3 {
    margin-top: 0;
    margin-bottom: 0.65rem;
    line-height: 1.2;
}

.snell-fermat svg {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 0.4rem;
    background: linear-gradient(to bottom, var(--snell-air) 0 50%, var(--snell-water) 50% 100%);
    border: 1px solid color-mix(in srgb, var(--color-line) 65%, transparent);
    color: var(--color-text);
}

.snell-fermat .medium-band--air {
    fill: var(--snell-air);
}

.snell-fermat .medium-band--water {
    fill: var(--snell-water);
}

/* Keep animated-wave invalidation on the SVG surface; whole-card containment
   previously forced large rasterization each frame. */
.snell-fermat .interactive[data-view="wave"] .visual > svg {
    contain: paint;
}

.snell-fermat .caption {
    margin: 0.65rem 0.25rem 0;
    color: var(--color-text-muted);
    font-size: 0.95rem;
    max-width: 75ch;
}

.snell-fermat .controls {
    margin: 0;
    padding: 0.85rem;
    border: 1px solid color-mix(in srgb, var(--color-line) 70%, transparent);
    border-radius: 0.4rem;
    background: color-mix(in srgb, var(--color-panel) 55%, var(--color-panel-soft));
}

.snell-fermat .controls legend {
    padding: 0 0.35rem;
    font-weight: 700;
    color: var(--color-text);
}

.snell-fermat .control {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.3rem 0.75rem;
    margin-bottom: 0.8rem;
}

.snell-fermat .control:last-of-type {
    margin-bottom: 0.35rem;
}

.snell-fermat .control label {
    font-weight: 600;
    color: var(--color-text);
}

.snell-fermat .control output {
    font-variant-numeric: tabular-nums;
    color: var(--color-text-muted);
}

.snell-fermat .control input[type="range"] {
    grid-column: 1 / -1;
    width: 100%;
}

.snell-fermat .control.checkbox {
    grid-template-columns: 1fr auto;
    align-items: center;
}

.snell-fermat .control.checkbox input {
    width: 1.1rem;
    height: 1.1rem;
}

.snell-fermat .control.is-disabled {
    opacity: var(--snell-disabled);
}

.snell-fermat .derived {
    border-top: 1px solid color-mix(in srgb, var(--color-line) 65%, transparent);
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.snell-fermat .derived strong {
    color: var(--color-text);
}

.snell-fermat .status {
    margin-top: 0.35rem;
}

.snell-fermat .boundary {
    stroke: color-mix(in srgb, var(--color-text) 55%, var(--color-text-muted));
    stroke-width: 2;
}

.snell-fermat .normal {
    stroke: var(--color-text-muted);
    stroke-width: 1.5;
    stroke-dasharray: 7 7;
}

.snell-fermat .ray {
    stroke: var(--color-accent);
    stroke-width: 3;
    fill: none;
}

.snell-fermat .wave {
    stroke: var(--color-accent);
    stroke-width: 2.5;
    fill: none;
    stroke-linecap: round;
}

.snell-fermat .muted-path {
    stroke: var(--color-text-muted);
    stroke-width: 4;
    fill: none;
    opacity: 0.55;
}

.snell-fermat .trial-path {
    stroke: var(--snell-accent-2);
    stroke-width: 4;
    fill: none;
}

.snell-fermat .angle {
    stroke: color-mix(in srgb, var(--color-text) 45%, var(--color-text-muted));
    stroke-width: 1.5;
    fill: none;
}

.snell-fermat .point {
    fill: var(--color-text);
}

.snell-fermat .point.trial {
    fill: var(--snell-accent-2);
    cursor: ew-resize;
    touch-action: none;
}

.snell-fermat .point.optimal {
    fill: var(--color-text-muted);
}

.snell-fermat .label {
    fill: var(--color-text);
    font: 15px Georgia, "Times New Roman", serif;
}

.snell-fermat .small-label {
    fill: var(--color-text-muted);
    font: 13px Georgia, "Times New Roman", serif;
}

.snell-fermat .graph-axis {
    stroke: color-mix(in srgb, var(--color-text) 40%, var(--color-text-muted));
    stroke-width: 1.4;
}

.snell-fermat .graph-line {
    stroke: var(--color-accent);
    stroke-width: 2.5;
    fill: none;
}

.snell-fermat .graph-guide {
    stroke: var(--color-line);
    stroke-width: 1;
    stroke-dasharray: 4 5;
}

.snell-fermat .graph-trial {
    fill: var(--snell-accent-2);
}

.snell-fermat .graph-optimal {
    fill: var(--color-text-muted);
}

.snell-fermat .nojs {
    padding: 0.8rem 1rem;
    border: 1px solid color-mix(in srgb, var(--color-accent) 55%, var(--color-line));
    border-radius: 0.35rem;
    background: color-mix(in srgb, var(--color-accent) 12%, var(--color-panel-soft));
    color: var(--color-accent-dark);
    margin: 1rem 0;
}

@media (max-width: 800px) {
    .snell-fermat .interactive {
        grid-template-columns: 1fr;
    }
}

.essay-hosting-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.45rem;
    border-radius: 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    vertical-align: middle;
}

.essay-hosting-badge--on-site {
    color: #1f5f2e;
    background: rgba(47, 125, 70, 0.14);
}

.essay-hosting-badge--external {
    color: #5a4a1f;
    background: rgba(159, 107, 50, 0.16);
}

/* --- Read / status chips (books) --------------------------------------- */

span.yes,
span.no,
span.na,
span.current {
    display: inline-block;
    padding: 0.12rem 0.5rem;
    border: 1px solid transparent;
    border-radius: 999px;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}

span.yes {
    border-color: rgba(74, 107, 58, 0.25);
    background: rgba(198, 221, 181, 0.65);
    color: #2f4a24;
}

span.no {
    border-color: rgba(122, 58, 58, 0.2);
    background: rgba(235, 198, 198, 0.65);
    color: #6b3030;
}

span.na {
    border-color: rgba(107, 93, 75, 0.2);
    background: rgba(216, 200, 174, 0.45);
    color: var(--color-text-muted);
}

span.current {
    border-color: rgba(159, 107, 50, 0.35);
    background: rgba(255, 236, 176, 0.85);
    color: #5c3d12;
}

/* --- Status cells in comparison tables (e.g. Ninja Gaiden miscellanea) --- */

.page-wrapper table td.yes,
.page-wrapper table td.no,
.page-wrapper table td.na,
.page-wrapper table td.current {
    text-align: center;
}

.page-wrapper table td.yes {
    background: rgba(198, 221, 181, 0.65);
}

.page-wrapper table td.no {
    background: rgba(235, 198, 198, 0.65);
}

.page-wrapper table td.na {
    background: rgba(216, 200, 174, 0.45);
}

.page-wrapper table td.current {
    background: rgba(255, 236, 176, 0.85);
}

/* --- Multi-column browse indexes --------------------------------------- */

.column,
.book-list.column {
    columns: 3 auto;
    column-gap: clamp(1.5rem, 2.5vw, 2.75rem);
    column-rule: 1px solid var(--color-line);
    list-style: none;
    margin: 0;
    padding: 0;
}

@media (min-width: 90rem) {
    .column,
    .book-list.column {
        columns: 4 auto;
    }

    .column.link-catalog-column {
        columns: 2 auto;
    }

    .book-cover-grid:not(.book-cover-grid--compact-view):not(.book-cover-grid--covers-view) {
        grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
    }

    .figure-gallery {
        max-width: 100%;
    }
}

@media (min-width: 120rem) {
    .column,
    .book-list.column {
        columns: 5 auto;
    }

    .column.link-catalog-column {
        columns: 2 auto;
    }
}

.column_element {
    break-inside: avoid;
    margin-bottom: 0.85rem;
    padding: 0.85rem 1rem;
    border: 1px solid rgba(216, 200, 174, 0.75);
    border-radius: 0.65rem;
    background: rgba(255, 250, 240, 0.55);
}

.column_element h3 {
    margin-top: 0;
    padding-left: 0;
}

.column_element > :last-child {
    margin-bottom: 0;
}

/* --- Contributor entity header ----------------------------------------- */

.contributor_info,
.author_info {
    margin: 0 0 1.5rem;
    padding: 0;
    border: 1px solid var(--color-line);
    border-radius: 0.75rem;
    background: var(--color-panel-soft);
    overflow: hidden;
}

.contributor_info h2,
.author_info h2 {
    margin: 0;
    padding: 1rem 1.25rem 0.75rem;
    font-size: clamp(1.15rem, 1.6vw, 1.35rem);
}

.contributor_info .book-edition__meta,
.author_info .book-edition__meta {
    border: 0;
    border-radius: 0;
    background: transparent;
}

.clear_both {
    clear: both;
}

/* Scroll to top */

.scroll-to-top {
    position: fixed;
    z-index: 15;
    right: clamp(1rem, 2vw, 2rem);
    bottom: clamp(1rem, 2vw, 2rem);

    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 2.5rem;
    height: 2.5rem;
    margin: 0;
    padding: 0;

    border: 1px solid rgba(216, 200, 174, 0.65);
    border-radius: 0.55rem;

    background: rgba(244, 239, 230, 0.96);
    box-shadow: var(--shadow-panel);

    color: var(--color-accent-dark);
    font-family: var(--font-ui);
    font-size: 1.35rem;
    line-height: 1;
    text-decoration: none;

    cursor: pointer;

    transition: opacity 0.15s ease, transform 0.15s ease;
}

.scroll-to-top[hidden] {
    display: none;
}

.scroll-to-top:hover,
.scroll-to-top:focus-visible {
    background: var(--color-panel-soft);
    color: #3d230d;
    transform: translateY(-2px);
}

/* Sudoku grids (puzzle pages) */

.page-wrapper table.sudoku {
    border-collapse: collapse;
    margin: 1.25rem 0;
}

.page-wrapper table.sudoku td {
    border: 1px solid #aaa;
    padding: 0.35rem;
    text-align: center;
}

.page-wrapper table.sudoku td.subtop {
    border-top: 1px solid #000;
}

.page-wrapper table.sudoku td.subtopright {
    border-top: 1px solid #000;
    border-right: 1px solid #000;
}

.page-wrapper table.sudoku td.subright {
    border-right: 1px solid #000;
}

.page-wrapper table.sudoku td.subbottomright {
    border-right: 1px solid #000;
    border-bottom: 1px solid #000;
}

.page-wrapper table.sudoku td.subbottom {
    border-bottom: 1px solid #000;
}

.page-wrapper table.sudoku td.subbottomleft {
    border-bottom: 1px solid #000;
    border-left: 1px solid #000;
}

.page-wrapper table.sudoku td.subleft {
    border-left: 1px solid #000;
}

.page-wrapper table.sudoku td.subtopleft {
    border-left: 1px solid #000;
    border-top: 1px solid #000;
}


/* ==========================================================================
   Responsive — sidebar drawer
   ========================================================================== */

@media (max-width: 56.25rem) {
    .site-nav-toggle {
        display: inline-flex;
        order: -1;
    }

    .site-header__inner {
        align-items: center;
    }

    .site-header__quote {
        flex: 1 1 100%;
        max-width: none;
    }

    .site-tagline--quote {
        --site-tagline-quote-lines: 4;
        padding-left: 0;
    }

    .site-shell {
        display: block;
        width: var(--layout-width);
        margin-top: 1rem;
    }

    .site-nav-overlay {
        display: block;
        position: fixed;
        z-index: 18;
        inset: 0;
        border: 0;
        background: rgba(8, 10, 14, 0.55);
        cursor: pointer;
    }

    .site-nav-overlay[hidden] {
        display: none;
    }

    .site-shell.is-nav-open {
        overflow: visible;
    }

    .site-sidebar {
        position: fixed;
        z-index: 19;
        top: 0;
        left: 0;
        width: min(20rem, 88vw);
        height: 100vh;
        max-height: none;
        margin: 0;
        border-radius: 0;
        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .site-shell.is-nav-open .site-sidebar {
        transform: translateX(0);
    }

    body.has-nav-open {
        overflow: hidden;
    }

    .page-wrapper {
        padding: var(--panel-padding-block) var(--panel-padding-inline);
    }

    .column,
    .book-list.small.column,
    .link-catalog-column,
    .column.link-catalog-column {
        columns: 1;
    }

    .book-cover-grid:not(.book-cover-grid--compact-view):not(.book-cover-grid--covers-view) {
        grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
        gap: 0.75rem;
    }

    .book-edition__meta-row,
    .contributor_info .book-edition__meta-row,
    .author_info .book-edition__meta-row {
        grid-template-columns: 1fr;
        gap: 0.15rem 0;
        align-items: start;
    }

    .book-edition__meta-row dt,
    .contributor_info .book-edition__meta-row dt,
    .author_info .book-edition__meta-row dt {
        margin-top: 0;
    }

    .book-edition__meta-row:first-child dt,
    .contributor_info .book-edition__meta-row:first-child dt,
    .author_info .book-edition__meta-row:first-child dt {
        margin-top: 0;
    }

    .book-search input[type="search"] {
        display: block;
        width: 100%;
        margin: 0.35rem 0 0.65rem;
    }

    .one-column-on-mobile {
        columns: 1;
    }
}

@media (max-width: 40rem) {
    :root {
        --book-sticky-subhead-top: 4.85rem;
        /* Keep readable inset; outer shell gutter is removed below. */
        --panel-padding-inline: clamp(0.85rem, 3.5vw, 1.25rem);
        --panel-padding-block: clamp(1rem, 3.5vw, 1.5rem);
    }

    .figure-gallery,
    .figure-gallery--compact {
        grid-template-columns: 1fr;
    }

    /* Flush main column to the viewport (outer gutter + vertical shell margins). */
    .site-shell {
        width: 100%;
        margin: 0;
    }

    .breadcrumbs {
        margin-bottom: 0;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        border-bottom: 0;
    }

    .page-wrapper {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        box-shadow: none;
    }

    /* Full-bleed footer bar, same idea as .site-header. */
    .site-footer {
        width: 100%;
        margin: 0;
        padding: 1rem var(--panel-padding-inline);
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        background: rgba(16, 19, 26, 0.92);
        box-sizing: border-box;
    }
}

@media (max-width: 56.25rem) and (min-width: 40rem) {
    :root {
        --layout-gutter: clamp(1rem, 2.5vw, 1.75rem);
        --panel-padding-inline: clamp(1rem, 2vw, 1.5rem);
        --panel-padding-block: clamp(1.25rem, 2vw, 1.75rem);
    }

    .column,
    .book-list.column {
        columns: 2 auto;
    }

    .column.link-catalog-column {
        columns: 1;
    }

    .figure-gallery,
    .figure-gallery--compact {
        grid-template-columns: 1fr;
    }

    .one-column-on-tablet {
        columns: 1;
    }

    .book-cover-grid:not(.book-cover-grid--compact-view):not(.book-cover-grid--covers-view) {
        grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
        gap: 0.85rem;
    }

    .book-edition__covers {
        padding: 0.85rem 1rem;
    }

    .book-edition__cover-gallery {
        justify-content: flex-start;
    }

    .book-list-display-toggle {
        gap: 0.35rem;
    }
}

@media (max-width: 72rem) and (min-width: 56.25rem) {
    :root {
        --layout-gutter: clamp(1.15rem, 2vw, 2rem);
        --panel-padding-inline: clamp(1.1rem, 1.8vw, 2rem);
    }

    .site-shell {
        grid-template-columns: minmax(13rem, 15rem) minmax(0, 1fr);
        gap: 1.15rem;
    }

    .column,
    .book-list.column {
        columns: 2 auto;
    }

    .book-cover-grid:not(.book-cover-grid--compact-view):not(.book-cover-grid--covers-view) {
        grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
        gap: 0.85rem;
    }

    .book-edition__covers {
        padding: 0.85rem 1rem;
    }

    .book-edition__meta {
        padding: 0;
    }

    .book-edition__meta-row {
        padding-inline: 1rem;
    }
}

/* Book Color Spectrum (experimental library page) */

.book-color-lead {
    margin-block-end: 1.25rem;
}

.book-color-composer-note {
    font-size: 0.9rem;
    color: var(--text-muted, #666);
    margin-block-end: 1.25rem;
}

.book-color-messages {
    padding: 0.75rem 1rem;
    margin-block-end: 1rem;
    border: 1px solid var(--border-color, #ccc);
    background: var(--panel-bg, #f8f8f8);
}

.book-color-warning {
    padding: 0.75rem 1rem;
    margin-block-end: 1rem;
    border: 1px solid #c90;
    background: #fff8e6;
}

.book-color-tools-top {
    display: grid;
    grid-template-columns: minmax(14rem, 0.9fr) minmax(18rem, 1.35fr);
    gap: 1.25rem;
    align-items: start;
    margin-block: 1.25rem;
}

.book-color-tools-top .book-color-controls {
    margin-block: 0;
    height: 100%;
}

.book-color-controls,
.book-color-generation {
    margin-block: 1.25rem;
    padding: 1rem;
    border: 1px solid var(--border-color, #ccc);
    background: var(--panel-bg, #fafafa);
}

.book-color-generation {
    padding-block: 0.65rem 1rem;
}

.book-color-generation__summary {
    cursor: pointer;
    list-style: none;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
}

.book-color-generation__summary::-webkit-details-marker {
    display: none;
}

.book-color-generation__summary::before {
    content: '▸';
    display: inline-block;
    width: 1em;
    margin-inline-end: 0.25rem;
    font-weight: 400;
    transition: transform 0.12s ease;
}

.book-color-generation[open] > .book-color-generation__summary::before {
    transform: rotate(90deg);
}

.book-color-generation__form {
    margin-block-start: 0.75rem;
}

.book-color-generation__edition-id {
    display: inline-block;
    margin-inline-start: 0.4rem;
    max-width: 8rem;
    font-family: var(--font-ui);
}

.book-color-coverage-gap {
    color: var(--color-text-muted);
    font-size: 0.92em;
}

.book-color-controls fieldset,
.book-color-generation fieldset {
    border: 0;
    margin: 0 0 0.85rem;
    padding: 0;
}

.book-color-controls legend,
.book-color-generation legend {
    font-weight: 600;
    margin-block-end: 0.35rem;
}

@media (max-width: 50rem) {
    .book-color-tools-top {
        grid-template-columns: 1fr;
    }
}

.book-color-controls__radio {
    display: inline-block;
    margin-inline-end: 0.85rem;
    margin-block-end: 0.35rem;
    white-space: nowrap;
}

.book-color-controls__select-label {
    display: inline-block;
    margin-inline-end: 0.5rem;
    font-weight: 600;
}

.book-color-controls__select {
    min-width: 16rem;
    max-width: 100%;
}

.book-color-controls__hint {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted, #666);
}

.book-color-tuning-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-block-start: 1rem;
}

.book-color-tuning-panel {
    min-width: 0;
    padding: 0.75rem;
    border: 1px solid var(--border-color, #ccc);
    background: var(--panel-bg, #fff);
}

.book-color-tuning-panel h4 {
    margin: 0 0 0.35rem;
}

.book-color-tuning-panel h5 {
    margin: 0.75rem 0 0.35rem;
    font-size: 0.95rem;
}

@media (max-width: 50rem) {
    .book-color-tuning-compare {
        grid-template-columns: 1fr;
    }
}

.book-color-diagnostics {
    margin-block: 1.25rem;
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    border: 1px dashed var(--border-color, #bbb);
}

.book-color-tools-top > .book-color-diagnostics {
    margin-block: 0;
    height: 100%;
    border-style: solid;
    background: var(--panel-bg, #fafafa);
}

.book-color-diagnostics dl {
    margin: 0;
}

.book-color-diagnostics dt {
    font-weight: 600;
    margin-block-start: 0.5rem;
}

.book-color-diagnostics dd {
    margin: 0.15rem 0 0;
}

.book-color-selection-summary {
    margin-block: 0.75rem 1rem;
    font-size: 0.95rem;
}

.book-color-display-note {
    margin-block: 0 1rem;
    font-size: 0.9rem;
    color: var(--text-muted, #666);
}

.book-color-status {
    margin-block: 1rem;
    font-size: 0.95rem;
}

.book-color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 1rem;
    margin-block-start: 1.25rem;
}

.book-color-grid--tier-compact {
    grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
}

.book-color-grid--tier-covers {
    /* Flex wrap (same idea as Library Covers view): grid minmax columns add side gutters. */
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    justify-content: flex-start;
    gap: 0.15rem 0.12rem;
    margin-block-start: 0.65rem;
}

.book-color-grid--tier-covers .book-color-card {
    flex: 0 0 auto;
    width: fit-content;
    border: 0;
    background: transparent;
}

.book-color-grid--tier-covers .book-color-cover {
    display: block;
    width: fit-content;
    line-height: 0;
}

.book-color-grid--tier-covers .book-color-cover a {
    display: block;
    width: fit-content;
    line-height: 0;
}

.book-color-grid--tier-covers .book-color-cover__image {
    /* Override .page-wrapper img { margin: 1.5rem auto } which was causing large gutters. */
    width: auto;
    max-width: none;
    height: auto;
    margin: 0;
    box-shadow: none;
}

.book-color-grid--tier-covers .book-color-meta {
    padding: 0.35rem 0.15rem 0.15rem;
}

.book-color-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color, #ccc);
    background: var(--panel-bg, #fff);
    overflow: hidden;
}

.book-color-cover {
    aspect-ratio: 2 / 3;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
}

.book-color-grid--tier-compact .book-color-cover,
.book-color-grid--tier-covers .book-color-cover {
    aspect-ratio: auto;
    min-height: 0;
    background: transparent;
}

.book-color-cover__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.book-color-grid--tier-compact .book-color-cover__image {
    width: auto;
    height: auto;
    max-width: 100%;
    margin: 0;
    object-fit: contain;
    box-shadow: none;
}

.book-color-cover__missing {
    font-size: 0.8rem;
    color: var(--text-muted, #888);
    text-align: center;
    padding: 0.5rem;
}

.book-color-meta {
    padding: 0.65rem 0.75rem;
    font-size: 0.85rem;
}

.book-color-meta__title {
    font-size: 0.9rem;
    margin: 0 0 0.25rem;
    line-height: 1.25;
}

.book-color-meta__id,
.book-color-meta__status,
.book-color-meta__detail,
.book-color-meta__spread,
.book-color-meta__error {
    margin: 0.2rem 0;
}

.book-color-meta__error {
    color: #a33;
    font-size: 0.8rem;
}

.book-color-swatch-list {
    display: flex;
    gap: 0.35rem;
    margin: 0.45rem 0;
}

.book-color-swatch {
    display: inline-block;
    width: 1.35rem;
    height: 1.35rem;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 2px;
    background: #ddd;
}

.book-color-swatch--selected {
    outline: 2px solid #333;
    outline-offset: 1px;
}

.book-day-cycle-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1rem;
    margin-block: 0.75rem 1rem;
}

.book-day-cycle-legend__item {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    min-width: 11rem;
    max-width: 16rem;
}

.book-day-cycle-legend__swatch {
    flex: 0 0 auto;
    width: 1.35rem;
    height: 1.35rem;
    border: 1px solid var(--border-color, #999);
    border-radius: 0.2rem;
}

.book-day-cycle-legend__text {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    font-size: 0.85rem;
    line-height: 1.25;
}

.book-day-cycle-legend__meta {
    color: var(--text-muted, #666);
    font-size: 0.8rem;
}

.book-day-cycle-phase {
    margin-block: 1rem 0.5rem;
}

.book-day-cycle-phase__heading {
    margin: 0 0 0.5rem;
    font-size: 1rem;
}

@media (max-width: 40rem) {
    .book-color-grid {
        grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr));
        gap: 0.75rem;
    }

    .book-color-controls__radio {
        display: block;
        margin-inline-end: 0;
    }
}

.book-language-label {
    display: inline;
    text-decoration: inherit;
}

.book-language-label__flag {
    display: inline-block;
    vertical-align: middle;
    width: 1em;
    height: 0.75em;
    margin-inline-end: 0.35em;
    background-image: var(--book-language-flag);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 0 0 1px rgb(0 0 0 / 0.12);
}