/*
 * Ionbase library theme (public reader surface).
 *
 * The four custom properties the shell emits per library are the only branding
 * hook: --lib-primary, --lib-accent, --lib-font-heading, --lib-font-body.
 * Everything else below is fixed. A generated cover additionally reads
 * --lb-cover-hue, an integer the cover_card partial sets per card.
 *
 * Plain CSS, no framework, no preprocessor.
 */

:root {
    --lib-primary: #1F3B69;
    --lib-accent: #E6D094;
    --lib-title: #1C355F;
    --lib-text: #30353E;
    --lib-muted: #6b7280;
    --lib-border: #e7ebf1;
    --lib-surface: #ffffff;
    --lib-surface-alt: #f7f9fc;
    --lib-font-heading: 'Georgia', 'Times New Roman', serif;
    --lib-font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --lib-radius: 10px;
    --lib-shell-max: 1120px;
}

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

html { -webkit-text-size-adjust: 100%; }

body.lb-body {
    margin: 0;
    background: var(--lib-surface);
    color: var(--lib-text);
    font-family: var(--lib-font-body);
    font-size: 16px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: var(--lib-font-heading);
    color: var(--lib-title);
    line-height: 1.25;
    margin: 0 0 .5rem;
}

a { color: var(--lib-primary); }

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

.lb-shell {
    width: 100%;
    max-width: var(--lib-shell-max);
    margin: 0 auto;
    padding: 0 1.25rem;
}

.lb-skip {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--lib-primary);
    color: #fff;
    padding: .6rem 1rem;
    z-index: 20;
}
.lb-skip:focus { left: 0; }

/* ---- header ---- */

.lb-header {
    background: var(--lib-primary);
    color: #fff;
    border-bottom: 3px solid var(--lib-accent);
}

.lb-header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 64px;
    flex-wrap: wrap;
}

.lb-brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    color: #fff;
    text-decoration: none;
    font-family: var(--lib-font-heading);
    font-size: 1.15rem;
    margin-right: auto;
}
.lb-brand-logo { max-height: 34px; width: auto; display: block; }

.lb-nav-toggle {
    display: none;
    background: none;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 6px;
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    padding: .35rem .5rem;
    cursor: pointer;
}

.lb-nav {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    flex-wrap: wrap;
}
.lb-nav a {
    color: #fff;
    text-decoration: none;
    font-size: .95rem;
    padding: .25rem 0;
    border-bottom: 2px solid transparent;
}
.lb-nav a:hover,
.lb-nav a:focus { border-bottom-color: var(--lib-accent); }

/* ---- page furniture ---- */

.lb-main { flex: 1 1 auto; padding: 2rem 0 3rem; }

.lb-page-head { margin-bottom: 1.5rem; }
.lb-page-head h1 { font-size: 2rem; }
.lb-page-lede { color: var(--lib-muted); margin: 0; }

.lb-empty {
    background: var(--lib-surface-alt);
    border: 1px solid var(--lib-border);
    border-radius: var(--lib-radius);
    color: var(--lib-muted);
    padding: 2rem;
    text-align: center;
}

.lb-button {
    display: inline-block;
    background: var(--lib-primary);
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    padding: .6rem 1.1rem;
}

.lb-notfound { padding-top: 1rem; }

.lb-listing-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.lb-listing-count { color: var(--lib-muted); margin: 0; font-size: .9rem; }

/* ---- view switch ---- */

.lb-viewswitch {
    display: inline-flex;
    border: 1px solid var(--lib-border);
    border-radius: 8px;
    overflow: hidden;
}
.lb-viewswitch-btn {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .75rem;
    font-size: .85rem;
    color: var(--lib-text);
    text-decoration: none;
    background: var(--lib-surface);
    border-right: 1px solid var(--lib-border);
}
.lb-viewswitch-btn:last-child { border-right: 0; }
.lb-viewswitch-btn.is-active {
    background: var(--lib-primary);
    color: #fff;
}

/* ---- cards ---- */

.lb-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1.25rem;
}

.lb-card { margin: 0; }

.lb-card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--lib-border);
    border-radius: var(--lib-radius);
    overflow: hidden;
    background: var(--lib-surface);
    transition: box-shadow .15s ease, transform .15s ease;
}
.lb-card-link:hover,
.lb-card-link:focus {
    box-shadow: 0 6px 18px rgba(31, 59, 105, .12);
    transform: translateY(-2px);
}

.lb-card-cover {
    display: block;
    position: relative;
    aspect-ratio: 3 / 2;
    background: var(--lib-surface-alt);
    overflow: hidden;
}
.lb-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* The generated fallback cover: initials over a branded gradient, rotated per
   record so a grid of coverless books does not read as one flat block. */
.lb-card-generated {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: linear-gradient(135deg, var(--lib-primary) 0%, var(--lib-accent) 100%);
    filter: hue-rotate(calc(var(--lb-cover-hue, 0) * 1deg));
}
.lb-card-initials {
    font-family: var(--lib-font-heading);
    font-size: 2.4rem;
    letter-spacing: .06em;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

.lb-card-body { padding: .9rem 1rem 1.1rem; }
.lb-card-name {
    display: block;
    font-family: var(--lib-font-heading);
    font-size: 1.05rem;
    color: var(--lib-title);
}
.lb-card-tagline {
    display: block;
    margin-top: .25rem;
    color: var(--lib-muted);
    font-size: .9rem;
}

/* ---- the three view modes ---- */

.lb-cards-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

.lb-cards-covers { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.lb-cards-covers .lb-card-cover { aspect-ratio: 3 / 4; }
.lb-cards-covers .lb-card-tagline { display: none; }

.lb-cards-list { grid-template-columns: 1fr; gap: .6rem; }
.lb-cards-list .lb-card-link { flex-direction: row; align-items: stretch; }
.lb-cards-list .lb-card-cover {
    flex: 0 0 96px;
    aspect-ratio: auto;
    width: 96px;
}
.lb-cards-list .lb-card-initials { font-size: 1.4rem; }
.lb-cards-list .lb-card-body { flex: 1 1 auto; }

/* ---- book home ---- */

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

.lb-book-head {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1.75rem;
    align-items: start;
    margin-bottom: 1.75rem;
}

.lb-book-cover {
    position: relative;
    aspect-ratio: 3 / 4;
    border: 1px solid var(--lib-border);
    border-radius: var(--lib-radius);
    background: var(--lib-surface-alt);
    overflow: hidden;
}
.lb-book-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

.lb-book-intro h1 { font-size: 2rem; }
.lb-book-description { margin: .75rem 0 0; }
.lb-book-meta { color: var(--lib-muted); font-size: .9rem; margin: .75rem 0 0; }
.lb-book-meta-note { margin-left: .35rem; }
.lb-book-actions { margin: 1.1rem 0 0; }

.lb-button-quiet {
    background: var(--lib-surface);
    color: var(--lib-primary);
    border: 1px solid var(--lib-border);
}

.lb-tagcloud {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: 1.75rem;
}
.lb-tag {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    background: var(--lib-surface-alt);
    border: 1px solid var(--lib-border);
    border-radius: 999px;
    padding: .2rem .7rem;
    font-size: .82rem;
    color: var(--lib-text);
}
.lb-tag-count { color: var(--lib-muted); font-size: .75rem; }

.lb-book-contents { border-top: 1px solid var(--lib-border); padding-top: 1.25rem; }
.lb-book-contents-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}
.lb-book-contents-head h2 { font-size: 1.2rem; margin: 0; }

/* ---- reader layout ---- */

.lb-reader-grid {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr) 210px;
    gap: 2rem;
    align-items: start;
}

/* A page with no contents list (or one the server dropped as furniture -
   fewer than two entries) reclaims the column rather than leaving a 210px
   hole beside the article. */
.lb-reader-grid.has-no-toc { grid-template-columns: 250px minmax(0, 1fr); }
.lb-reader-grid.has-no-toc .lb-reader-toc { display: none; }

.lb-reader-side,
.lb-reader-toc {
    position: sticky;
    top: 1.25rem;
    max-height: calc(100vh - 2.5rem);
    overflow-y: auto;
}

.lb-reader-side-head { margin-bottom: .75rem; }
.lb-reader-book {
    display: block;
    font-family: var(--lib-font-heading);
    color: var(--lib-title);
    text-decoration: none;
    font-size: 1.05rem;
    margin-bottom: .6rem;
}

.lb-palette-open {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: var(--lib-surface-alt);
    border: 1px solid var(--lib-border);
    border-radius: 8px;
    color: var(--lib-muted);
    font: inherit;
    font-size: .85rem;
    padding: .4rem .6rem;
    cursor: pointer;
    text-align: left;
}
/* Full width only in the sidebar, where it sits above the tree and reads as a
   field. On the book home it is a button beside a heading. */
.lb-reader-side-head .lb-palette-open { width: 100%; }

.lb-palette-open kbd {
    margin-left: auto;
    background: var(--lib-surface);
    border: 1px solid var(--lib-border);
    border-radius: 4px;
    padding: 0 .3rem;
    font-size: .75rem;
}

/* ---- the page tree ---- */

.lb-tree-list { list-style: none; margin: 0; padding: 0 0 0 .75rem; }
.lb-tree > .lb-tree-list { padding-left: 0; }
.lb-tree-item { margin: 0; }
.lb-tree-link {
    display: block;
    padding: .25rem .4rem;
    border-radius: 5px;
    color: var(--lib-text);
    text-decoration: none;
    font-size: .92rem;
    border-left: 2px solid transparent;
}
.lb-tree-link:hover { background: var(--lib-surface-alt); }
.lb-tree-item.is-current > .lb-tree-link {
    color: var(--lib-primary);
    font-weight: 600;
    border-left-color: var(--lib-accent);
    background: var(--lib-surface-alt);
}
.lb-tree-link.is-addressless { color: var(--lib-muted); cursor: default; }
.lb-tree-empty { color: var(--lib-muted); font-size: .9rem; }

/* ---- breadcrumbs, article, meta ---- */

.lb-crumbs { margin-bottom: .75rem; }
.lb-crumbs ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin: 0;
    padding: 0;
    font-size: .85rem;
    color: var(--lib-muted);
}
.lb-crumbs li + li::before { content: "/"; margin-right: .35rem; opacity: .6; }
.lb-crumbs a { color: var(--lib-muted); text-decoration: none; }
.lb-crumbs a:hover { text-decoration: underline; }

.lb-article-head { margin-bottom: 1.25rem; }
.lb-article-head h1 { font-size: 2rem; }
.lb-article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .9rem;
    color: var(--lib-muted);
    font-size: .85rem;
    margin: 0 0 .6rem;
}

.lb-preview-banner {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: #fdf6e3;
    border: 1px solid var(--lib-accent);
    border-radius: var(--lib-radius);
    padding: .7rem 1rem;
    margin: 0 0 1.25rem;
    font-size: .9rem;
}

.lb-share { display: flex; align-items: center; gap: .4rem; }
.lb-share-label { color: var(--lib-muted); font-size: .8rem; }
.lb-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--lib-border);
    border-radius: 6px;
    background: var(--lib-surface);
    color: var(--lib-primary);
    text-decoration: none;
    cursor: pointer;
}
.lb-share-btn:hover { border-color: var(--lib-primary); }
.lb-share-btn.is-copied { background: var(--lib-primary); color: #fff; }

/* ---- the rendered article body ---- */

.lb-article { font-size: 1.02rem; }
.lb-article h2, .lb-article h3, .lb-article h4 {
    position: relative;
    margin-top: 2rem;
    scroll-margin-top: 1.5rem;
}
.lb-article h2 { font-size: 1.5rem; }
.lb-article h3 { font-size: 1.22rem; }
.lb-article h4 { font-size: 1.05rem; }
.lb-article p { margin: 0 0 1rem; }
.lb-article ul, .lb-article ol { margin: 0 0 1rem; padding-left: 1.4rem; }
.lb-article blockquote {
    margin: 0 0 1rem;
    padding: .6rem 1rem;
    border-left: 3px solid var(--lib-accent);
    background: var(--lib-surface-alt);
    color: var(--lib-text);
}
.lb-article table {
    border-collapse: collapse;
    width: 100%;
    margin: 0 0 1rem;
    font-size: .92rem;
}
.lb-article th, .lb-article td {
    border: 1px solid var(--lib-border);
    padding: .45rem .6rem;
    text-align: left;
}
.lb-article th { background: var(--lib-surface-alt); }
.lb-article code {
    background: var(--lib-surface-alt);
    border-radius: 4px;
    padding: .1rem .3rem;
    font-size: .9em;
}
.lb-article pre {
    background: #f5f7fa;
    border: 1px solid var(--lib-border);
    border-radius: var(--lib-radius);
    padding: .9rem 1rem;
    overflow-x: auto;
    margin: 0;
}
.lb-article pre code { background: none; padding: 0; }

.lb-heading-link {
    background: none;
    border: 0;
    color: var(--lib-muted);
    cursor: pointer;
    font-size: .8em;
    margin-left: .4rem;
    opacity: 0;
    padding: 0 .2rem;
    transition: opacity .12s ease;
}
.lb-article h2:hover .lb-heading-link,
.lb-article h3:hover .lb-heading-link,
.lb-article h4:hover .lb-heading-link,
.lb-heading-link:focus { opacity: 1; }
.lb-heading-link.is-copied { color: var(--lib-primary); opacity: 1; }

.lb-code-wrap { position: relative; margin: 0 0 1rem; }
.lb-code-copy {
    position: absolute;
    top: .5rem;
    right: .5rem;
    background: var(--lib-surface);
    border: 1px solid var(--lib-border);
    border-radius: 5px;
    color: var(--lib-muted);
    cursor: pointer;
    padding: .2rem .4rem;
}
.lb-code-copy:hover { color: var(--lib-primary); border-color: var(--lib-primary); }
.lb-code-copy.is-copied { background: var(--lib-primary); color: #fff; }

/* ---- in-page contents ---- */

.lb-toc { font-size: .86rem; }
.lb-toc-title {
    color: var(--lib-muted);
    font-size: .75rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    margin: 0 0 .4rem;
}
/* Blogmark's _build_toc() emits nested <ol>, not <ul>: the markers are what
   the heading hierarchy already says, so they are dropped here. */
.lb-toc .post-toc ol { list-style: none; margin: 0; padding: 0 0 0 .6rem; }
.lb-toc .post-toc > ol { padding-left: 0; }
.lb-toc .post-toc a {
    display: block;
    padding: .2rem 0;
    color: var(--lib-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    padding-left: .5rem;
}
.lb-toc .post-toc a:hover { color: var(--lib-primary); border-left-color: var(--lib-accent); }

/* ---- previous / next, panels ---- */

.lb-article-actions { margin: 1.5rem 0 0; }

.lb-prevnext {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    border-top: 1px solid var(--lib-border);
    padding-top: 1.25rem;
    flex-wrap: wrap;
}
.lb-prevnext-link {
    flex: 1 1 220px;
    border: 1px solid var(--lib-border);
    border-radius: var(--lib-radius);
    padding: .7rem .9rem;
    text-decoration: none;
    color: var(--lib-title);
}
.lb-prevnext-link:hover { border-color: var(--lib-primary); }
.lb-prevnext-next { text-align: right; }
.lb-prevnext-label {
    display: block;
    color: var(--lib-muted);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}
.lb-prevnext-name { display: block; font-family: var(--lib-font-heading); }

.lb-panel { margin-top: 2rem; }
.lb-panel-title {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: 1rem;
    margin-bottom: .5rem;
}
.lb-panel-list { list-style: none; margin: 0; padding: 0; }
.lb-panel-list li { padding: .3rem 0; border-bottom: 1px solid var(--lib-border); }
.lb-panel-list li:last-child { border-bottom: 0; }
.lb-panel-note { display: block; color: var(--lib-muted); font-size: .85rem; }

/* ---- quick-search palette ---- */

.lb-palette {
    position: fixed;
    inset: 0;
    background: rgba(28, 53, 95, .35);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 8vh 1rem 1rem;
    z-index: 40;
}
.lb-palette[hidden] { display: none; }

.lb-palette-box {
    background: var(--lib-surface);
    border-radius: var(--lib-radius);
    box-shadow: 0 20px 50px rgba(28, 53, 95, .3);
    width: 100%;
    max-width: 560px;
    overflow: hidden;
}
.lb-palette-input {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--lib-border);
    padding: .9rem 1rem;
    font: inherit;
    font-size: 1rem;
    color: var(--lib-text);
}
.lb-palette-input:focus { outline: 2px solid var(--lib-accent); outline-offset: -2px; }

.lb-palette-results {
    list-style: none;
    margin: 0;
    padding: .35rem 0;
    max-height: 50vh;
    overflow-y: auto;
}
.lb-palette-item {
    display: block;
    padding: .4rem .9rem;
    color: var(--lib-text);
    text-decoration: none;
    font-size: .92rem;
}
.lb-palette-item.is-active,
.lb-palette-item:hover { background: var(--lib-surface-alt); color: var(--lib-primary); }
.lb-palette-empty { color: var(--lib-muted); padding: .9rem 1rem; margin: 0; font-size: .9rem; }

/* ---- footer ---- */

.lb-footer {
    border-top: 1px solid var(--lib-border);
    background: var(--lib-surface-alt);
    color: var(--lib-muted);
    font-size: .85rem;
    padding: 1.25rem 0;
}
.lb-footer-inner {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.lb-footer a { color: var(--lib-muted); }
.lb-dot { opacity: .6; }

/* ---- narrow screens ---- */

@media (max-width: 720px) {
    .lb-nav-toggle { display: inline-flex; }
    .lb-nav {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        align-items: flex-start;
        gap: .4rem;
        padding-bottom: .75rem;
    }
    .lb-nav.is-open { display: flex; }
    .lb-page-head h1 { font-size: 1.6rem; }
    .lb-cards-grid,
    .lb-cards-covers { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* The reader's third column goes first, because a table of contents that has
   to be scrolled past to reach the article is worse than no table of contents
   at all on a phone. The sidebar tree follows the article for the same
   reason: on a narrow screen the page a reader asked for comes before the
   navigation to the ones they did not. */
@media (max-width: 1080px) {
    .lb-reader-grid { grid-template-columns: 230px minmax(0, 1fr); }
    .lb-reader-toc { display: none; }
}

@media (max-width: 860px) {
    .lb-reader-grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .lb-reader-side {
        position: static;
        max-height: none;
        order: 2;
        border-top: 1px solid var(--lib-border);
        padding-top: 1rem;
    }
    .lb-reader-main { order: 1; }
    .lb-book-head { grid-template-columns: 1fr; }
    .lb-book-cover { max-width: 200px; }
    .lb-article-head h1,
    .lb-book-intro h1 { font-size: 1.6rem; }
    /* Always visible rather than hover-revealed: there is no hover here. */
    .lb-heading-link { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .lb-card-link { transition: none; }
    .lb-card-link:hover,
    .lb-card-link:focus { transform: none; }
    .lb-heading-link { transition: none; }
}

/* -----------------------------------------------------------------
   Task 27: the category and tag listings, and the search page.

   No new custom properties and no new colour literals: everything below
   reads the same six tokens the rest of this file does, so a library that
   restyles its shell restyles these screens with it.
   ----------------------------------------------------------------- */

.lb-eyebrow {
    margin: 0 0 .15rem;
    font-size: .78rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--lib-muted);
}

/* A chip that is a link. The span form (a tag with no address) keeps the
   cursor and colour it always had, so the two are told apart by behaviour
   rather than only by looks. */
a.lb-tag {
    text-decoration: none;
    transition: background-color .12s ease, border-color .12s ease;
}
a.lb-tag:hover,
a.lb-tag:focus {
    background: var(--lib-surface);
    border-color: var(--lib-primary);
}

.lb-categorystrip { margin-bottom: 1.5rem; }

.lb-card-context {
    display: block;
    margin-top: .15rem;
    font-size: .78rem;
    color: var(--lib-muted);
}
.lb-cards-covers .lb-card-context { display: none; }

.lb-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.75rem 0 .5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--lib-border);
}
.lb-pager-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .4rem .8rem;
    border: 1px solid var(--lib-border);
    border-radius: var(--lib-radius);
    text-decoration: none;
    color: var(--lib-primary);
    background: var(--lib-surface);
}
.lb-pager-link:hover,
.lb-pager-link:focus { border-color: var(--lib-primary); }
.lb-pager-link.is-disabled {
    color: var(--lib-muted);
    background: var(--lib-surface-alt);
    border-color: var(--lib-border);
}
.lb-pager-count { color: var(--lib-muted); font-size: .9rem; }

.lb-searchform {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.5rem;
}
.lb-searchform-input {
    flex: 1 1 260px;
    min-width: 0;
    padding: .55rem .8rem;
    border: 1px solid var(--lib-border);
    border-radius: var(--lib-radius);
    font-family: inherit;
    font-size: 1rem;
    color: var(--lib-text);
    background: var(--lib-surface);
}
.lb-searchform-scope {
    padding: .55rem .8rem;
    border: 1px solid var(--lib-border);
    border-radius: var(--lib-radius);
    font-family: inherit;
    font-size: .95rem;
    color: var(--lib-text);
    background: var(--lib-surface);
    max-width: 260px;
}
.lb-searchform-input:focus,
.lb-searchform-scope:focus {
    outline: 2px solid var(--lib-primary);
    outline-offset: 1px;
}

.lb-notice {
    margin: 0 0 1.25rem;
    padding: .7rem 1rem;
    border: 1px solid var(--lib-border);
    border-left: 3px solid var(--lib-accent);
    border-radius: var(--lib-radius);
    background: var(--lib-surface-alt);
    color: var(--lib-text);
}

.lb-results {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: .6rem;
}
.lb-result { margin: 0; }
.lb-result-link {
    display: flex;
    gap: .9rem;
    align-items: flex-start;
    padding: .8rem;
    border: 1px solid var(--lib-border);
    border-radius: var(--lib-radius);
    background: var(--lib-surface);
    text-decoration: none;
    color: inherit;
}
.lb-result-link:hover,
.lb-result-link:focus { border-color: var(--lib-primary); }
.lb-result-cover {
    flex: 0 0 64px;
    width: 64px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--lib-surface-alt);
    /* REQUIRED, not decoration: .lb-card-generated is position:absolute /
       inset:0, so without a positioned ancestor the fallback cover escapes its
       box and paints over the whole page. */
    display: block;
    position: relative;
}
.lb-result-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lb-result-cover .lb-card-initials { font-size: 1.1rem; }
.lb-result-body { flex: 1 1 auto; min-width: 0; }
.lb-result-name {
    display: block;
    font-family: var(--lib-font-heading);
    color: var(--lib-title);
    font-size: 1.05rem;
}
.lb-result-book { display: block; font-size: .8rem; color: var(--lib-muted); }
.lb-result-summary {
    display: block;
    margin-top: .3rem;
    font-size: .9rem;
    color: var(--lib-text);
}

@media (max-width: 640px) {
    .lb-pager { flex-wrap: wrap; justify-content: center; }
    .lb-searchform-scope { max-width: none; flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
    a.lb-tag { transition: none; }
}

/* -----------------------------------------------------------------
   Task 28: the public comment thread and its form.

   No new custom properties and no new colour literals: everything below
   reads the same six tokens the rest of this file does, so a library that
   restyles its shell restyles its comments with it.
   ----------------------------------------------------------------- */

.lb-comments {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--lib-border);
}

.lb-comment-notice {
    margin: 0 0 1.25rem;
    padding: .7rem 1rem;
    border: 1px solid var(--lib-border);
    border-left: 3px solid var(--lib-accent);
    border-radius: var(--lib-radius);
    background: var(--lib-surface-alt);
    color: var(--lib-text);
}
/* An error keeps the same shape and swaps the marker for the primary, so the
   two are told apart without a colour this palette does not have. */
.lb-comment-notice-error { border-left-color: var(--lib-primary); }

.lb-comment-list {
    list-style: none;
    margin: 0 0 1.75rem;
    padding: 0;
}
.lb-comment {
    padding: .9rem 0;
    border-bottom: 1px solid var(--lib-border);
}
.lb-comment:last-child { border-bottom: 0; }

.lb-comment-meta {
    margin: 0 0 .35rem;
    font-size: .85rem;
    color: var(--lib-muted);
}
.lb-comment-author { font-weight: 600; color: var(--lib-title); }
.lb-comment-dot { margin: 0 .35rem; }

.lb-comment-body { color: var(--lib-text); overflow-wrap: anywhere; }

.lb-comment-empty { margin: 0 0 1.75rem; color: var(--lib-muted); }

.lb-comment-form { max-width: 40rem; }
.lb-comment-form-label {
    margin: 0 0 .75rem;
    font-family: var(--lib-font-heading);
    font-size: 1.05rem;
    color: var(--lib-title);
}

/* The honeypot. Off-screen rather than display:none, because a form filler
   that skips hidden inputs would never trip it. aria-hidden and tabindex="-1"
   in the markup keep it away from readers who are not looking at the screen. */
.lb-comment-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.lb-comment-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.lb-field { margin: 0 0 1rem; }
.lb-field label {
    display: block;
    margin-bottom: .25rem;
    font-size: .85rem;
    font-weight: 600;
    color: var(--lib-title);
}
.lb-field input,
.lb-field textarea {
    display: block;
    width: 100%;
    padding: .55rem .8rem;
    border: 1px solid var(--lib-border);
    border-radius: var(--lib-radius);
    font-family: inherit;
    font-size: 1rem;
    color: var(--lib-text);
    background: var(--lib-surface);
}
.lb-field textarea { resize: vertical; min-height: 7rem; }
.lb-field input:focus,
.lb-field textarea:focus {
    outline: 2px solid var(--lib-primary);
    outline-offset: 1px;
}
.lb-field-hint {
    display: block;
    margin-top: .2rem;
    font-size: .8rem;
    color: var(--lib-muted);
}

.lb-comment-identity { margin: 0 0 1rem; color: var(--lib-text); }

.lb-comment-submit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
}
.lb-comment-note { font-size: .85rem; color: var(--lib-muted); }

@media (max-width: 640px) {
    .lb-comment-fields { grid-template-columns: minmax(0, 1fr); }
}

/* -----------------------------------------------------------------
   Bookmarks (Task 29)

   No new custom properties and no new colour literals: the control reads
   the same tokens the rest of this file does, so a library that restyles
   its shell restyles its bookmark button with it. The notice reuses
   .lb-comment-notice outright rather than growing a second one - both are
   the same flash-message shape from the same surface.
   ----------------------------------------------------------------- */

.lb-bookmark { margin: .75rem 0 0; }
.lb-bookmark form { margin: 0; }

.lb-bookmark-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .8rem;
    border: 1px solid var(--lib-border);
    border-radius: 6px;
    background: var(--lib-surface);
    color: var(--lib-primary);
    font-family: inherit;
    font-size: .9rem;
    line-height: 1.3;
    cursor: pointer;
}
.lb-bookmark-btn:hover { border-color: var(--lib-primary); }

/* Kept is a state, not an accent, so it fills rather than recolours: the
   accent gold is reserved for the shell's own highlights. */
.lb-bookmark-btn.is-bookmarked {
    background: var(--lib-primary);
    border-color: var(--lib-primary);
    color: #fff;
}

/* On the reader's article header the control sits beside the share row. */
.lb-article-head .lb-bookmark { display: inline-block; margin: .75rem .75rem 0 0; vertical-align: middle; }
.lb-article-head .lb-share { display: inline-flex; vertical-align: middle; }
