/* Public library: warm shelves and a two-panel story page. */
body.library-layout {
    --library-accent: var(--color-primary);
    --library-surface: var(--color-bg);
    --library-border: var(--color-border-light);
    --library-shadow: 0 4px 22px rgba(96, 28, 28, .045);
    background: #fdf8f4;
}
html[data-theme="dark"] body.library-layout { background: var(--color-bg-secondary); }
.library-layout .container { max-width: 1200px; }
.library-home { padding-bottom: 48px; }
.library-section {
    padding: 28px;
    margin-bottom: 28px;
    background: var(--library-surface);
    border: 1px solid var(--library-border);
    border-radius: 18px;
    box-shadow: var(--library-shadow);
}
.library-section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.library-section-brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.library-section-icon { display: grid; place-items: center; flex: 0 0 56px; width: 56px; height: 56px; border-radius: 18px; background: var(--color-primary-light); color: var(--library-accent); }
.library-section-icon .hdk-icon { width: 28px; height: 28px; }
.library-section-heading h2 { font-size: 24px; font-weight: 700; line-height: 1.3; color: var(--library-accent); text-transform: uppercase; }
.library-section-heading p { font-size: 14px; color: var(--color-text-muted); margin-top: 5px; }
.library-more { display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex-shrink: 0; min-height: 42px; padding: 9px 16px; border: 1px solid var(--library-accent); border-radius: 999px; color: var(--library-accent); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.library-more:hover { background: var(--color-primary); color: var(--color-on-primary); }
.library-book-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 26px 20px; }
.library-book { display: block; min-width: 0; color: var(--color-text-primary); }
.library-book-cover { position: relative; aspect-ratio: 2/3; border-radius: 10px; background: var(--color-bg-tertiary); box-shadow: 0 3px 10px rgba(0,0,0,.10); overflow: hidden; }
.library-book-cover img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease; }
.library-book:hover img { transform: scale(1.035); }
.library-book h3 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 14px; font-weight: 600; line-height: 1.5; margin: 12px 0 7px; min-height: 42px; }
.library-book:hover h3 { color: var(--library-accent); }
.library-book-stats { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--color-text-muted); font-size: 12px; }
.library-book-stats span { display: inline-flex; align-items: center; gap: 4px; }
.library-book-stats .hdk-icon { width: 14px; height: 14px; }
.library-book-ribbon { position: absolute; top: 10px; left: 0; padding: 4px 10px; border-radius: 0 4px 4px 0; background: var(--color-primary); color: var(--color-on-primary); font-size: 10px; font-weight: 700; letter-spacing: .06em; }
.library-updates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; }
.library-update { display: flex; gap: 15px; padding: 18px 0; border-bottom: 1px solid var(--library-border); min-width: 0; }
.library-update:nth-last-child(-n+2) { border-bottom: 0; }
.library-update-cover { position: relative; flex: 0 0 90px; width: 90px; align-self: flex-start; }
.library-update-cover img { display: block; width: 100%; aspect-ratio: 2/3; height: auto; object-fit: cover; border-radius: 8px; }
.library-update-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.library-update h3 { font-size: 15px; line-height: 1.5; margin-bottom: 8px; }
.library-update h3 a { color: var(--color-text-primary); }
.library-update-chapters { display: grid; gap: 5px; }
.library-update-chapters a { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 32px; font-size: 13px; color: var(--color-text-secondary); }
.library-update-chapters a:hover, .library-update h3 a:hover { color: var(--library-accent); }
.library-update-chapters span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; min-width: 0; }
.library-update-chapters time { flex: 0 0 auto; color: var(--color-text-muted); font-size: 12px; }
.library-update-author { color: var(--color-text-muted); font-size: 12px; margin-top: auto; padding-top: 10px; }
.library-resume { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 24px; margin-bottom: 24px; padding: 16px 22px; border: 1px solid var(--library-border); border-radius: 12px; background: var(--library-surface); font-size: 13px; }
.library-resume > span { display: inline-flex; align-items: center; gap: 6px; color: var(--library-accent); font-weight: 700; }
.library-resume a { color: var(--color-text-secondary); }
.library-resume small { color: var(--color-text-muted); }
/* Keep the site's configured banner and announcement above the shelves. */
.library-layout .hero-banner { padding-block: 22px 28px; }
.library-layout .banner-shell { border-radius: 18px; }
/* Story information follows the same card rhythm as the homepage. */
.library-layout .story-detail-page { padding-top: 24px; padding-bottom: 48px; }
.library-layout .story-breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.library-layout .story-breadcrumb .hdk-icon { width: 14px; height: 14px; flex-shrink: 0; }
.library-layout .story-header { padding: 32px 40px; gap: 40px; background: var(--library-surface); border: 1px solid var(--library-border); border-radius: 18px; box-shadow: var(--library-shadow); }
.library-layout .story-cover { width: 240px; flex-basis: 240px; }
.library-layout .story-cover img { border-radius: 12px !important; }
.library-layout .story-title { font-size: 28px; line-height: 1.35; color: var(--library-accent); text-transform: uppercase; margin-bottom: 20px; font-weight: 700; }
.story-meta-list { margin: 0 0 18px; display: grid; gap: 9px; font-size: 14px; }
.story-meta-list > div { display: grid; grid-template-columns: 145px minmax(0, 1fr); align-items: baseline; gap: 12px; }
.story-meta-list dt { color: var(--color-text-muted); }
.story-meta-list dd { margin: 0; font-weight: 500; }
.library-layout .story-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.library-layout .story-badges .badge { border-radius: 999px; padding: 5px 12px; }
.library-layout .story-actions { gap: 10px; }
.library-layout .story-actions .btn { border-radius: 999px; min-height: 44px; font-size: 13px; }
.library-layout .story-actions .combo-btn { color: var(--color-text-primary) !important; }
.story-content-columns { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; margin-top: 24px; align-items: start; }
.library-layout .story-detail-page .panel { background: var(--library-surface); border: 1px solid var(--library-border); border-radius: 18px; box-shadow: var(--library-shadow); }
.library-layout .story-detail-page .panel-pad { padding: 26px; min-width: 0; }
.story-panel-title { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; color: var(--library-accent); font-size: 20px; font-weight: 700; padding-bottom: 16px; margin-bottom: 18px; border-bottom: 1px solid var(--library-border); }
.story-panel-title > .hdk-icon { width: 22px; height: 22px; }
.story-panel-title > span { font-size: 12px; color: var(--color-text-muted); font-weight: 400; margin-left: auto; }
.story-summary { color: var(--color-text-secondary); font-size: 14px; line-height: 1.95; }
.story-summary.is-collapsed { max-height: 390px; overflow: hidden; -webkit-mask-image: linear-gradient(#000 85%, transparent); mask-image: linear-gradient(#000 85%, transparent); }
.story-summary-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 12px 0 0; min-height: 44px; border: 0; background: transparent; color: var(--library-accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.story-summary-toggle[hidden] { display: none; }
.library-layout .story-chapter-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 0; }
.library-layout .story-chapter-item { min-height: 52px; padding: 10px 0; gap: 10px; border: 0; border-bottom: 1px solid var(--library-border); border-radius: 0; background: transparent; }
.library-layout .story-chapter-item:hover { background: var(--color-primary-light); }
.library-layout .story-chapter-link { font-size: 13px; line-height: 1.5; font-weight: 500; }
.story-chapter-date { flex: 0 0 auto; color: var(--color-text-muted); font-size: 10px; }
.library-layout .chapter-access-label { margin-left: 0; font-size: 10px; padding: 5px 7px; }
.library-layout .story-toc .pagination { margin-top: 20px; }
.library-layout .story-toc .pagination-links { flex-wrap: wrap; gap: 5px; }
.library-layout .story-toc .pagination .btn { min-width: 34px; min-height: 36px; padding: 6px 10px; border-radius: 9px; font-size: 11px; }
.library-layout .story-toc .pagination-summary { font-size: 11px; }
.library-layout .story-comments { margin-top: 24px; }
.story-chapters-empty { font-size: 14px; color: var(--color-text-muted); }
@media (max-width: 1024px) {
    .library-book-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
    .library-layout .story-header { padding: 26px; gap: 28px; }
    .library-layout .story-cover { width: 200px; flex-basis: 200px; }
    .library-layout .story-title { font-size: 24px; }
    .story-content-columns { gap: 18px; }
    .library-layout .story-detail-page .panel-pad { padding: 20px; }
    .story-chapter-date { display: none; }
}
@media (max-width: 768px) {
    .library-section { padding: 22px; }
    .library-section-heading { align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
    .library-section-heading h2 { font-size: 20px; }
    .library-section-heading p { font-size: 12px; }
    .library-section-icon { width: 44px; height: 44px; flex-basis: 44px; border-radius: 14px; }
    .library-updates { grid-template-columns: minmax(0,1fr); }
    .library-update:nth-last-child(2) { border-bottom: 1px solid var(--library-border); }
    .library-layout .story-header { gap: 22px; }
    .library-layout .story-cover { width: 160px; flex: 0 0 auto; }
    .library-layout .story-title { font-size: 22px; }
    .story-meta-list { text-align: left; max-width: 440px; margin-inline: auto; }
    .story-meta-list > div { grid-template-columns: 130px minmax(0,1fr); }
    .story-content-columns { grid-template-columns: minmax(0,1fr); }
    .library-layout .story-actions .btn { border-radius: 12px; }
    .story-chapter-date { display: block; }
}
@media (max-width: 540px) {
    .library-layout .container { padding-inline: 16px; }
    .library-section { padding: 18px; margin-bottom: 20px; border-radius: 14px; }
    .library-book-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px 16px; }
    .library-section-brand { gap: 10px; }
    .library-section-heading h2 { font-size: 17px; }
    .library-section-icon { width: 36px; height: 36px; flex-basis: 36px; }
    .library-section-icon .hdk-icon { width: 22px; height: 22px; }
    .library-more { min-height: 36px; padding: 7px 12px; font-size: 10px; }
    .library-update { gap: 12px; }
    .library-update-cover { flex-basis: 68px; width: 68px; }
    .library-update h3 { font-size: 13px; }
    .library-update-chapters time { display: none; }
    .library-layout .story-header { padding: 22px 18px; }
    .library-layout .story-detail-page .panel-pad { padding: 18px; }
    .story-meta-list { font-size: 13px; }
    .story-meta-list > div { grid-template-columns: 112px minmax(0,1fr); gap: 8px; }
    .story-chapter-date { display: none; }
    .story-panel-title { font-size: 18px; }
}
@media (max-width: 375px) { .library-layout .story-cover { width: 140px; } }
@media (prefers-reduced-motion: reduce) { .library-book-cover img { transition: none; } }
/* Grid children must shrink before chapter titles can ellipsize. */
.library-update-chapters, .library-update-chapters a { min-width: 0; max-width: 100%; }
.library-layout .banner-content { min-width: 0; width: 100%; }
@media (max-width: 540px) {
    .library-layout .site-header > .container { padding-inline: 10px; }
    .library-layout .hero-banner .banner-content { width: 100%; max-width: 100%; }
}
.story-comment-invitation { padding: 28px 18px; margin-bottom: 24px; border-radius: 12px; text-align: center; background: var(--color-primary-light); }
.story-comment-invitation strong { color: var(--library-accent); font-size: 16px; }
.story-comment-invitation p { margin: 8px 0 18px; color: var(--color-text-secondary); font-size: 13px; }
.story-comment-invitation .btn { border-radius: 999px; font-size: 13px; }
@media (min-width: 1025px) { .library-layout .site-header { border-radius: 999px; } }
.library-layout .site-header > .container { max-width: none; }
/* Join the introduction and contents into one card on desktop. */
@media (min-width: 769px) {
    .story-content-columns { gap: 0; align-items: stretch; background: var(--library-surface); border: 1px solid var(--library-border); border-radius: 18px; box-shadow: var(--library-shadow); }
    .library-layout .story-content-columns > .panel { border: 0; border-radius: 18px; box-shadow: none; }
    .library-layout .story-content-columns > .story-introduction { border-right: 1px solid var(--library-border); border-radius: 18px 0 0 18px; }
    .library-layout .story-content-columns > .story-toc { border-radius: 0 18px 18px 0; }
}

html[data-theme="dark"] body.library-layout { --library-accent: #f0b4a2; }
.library-layout .story-meta-list a { color: var(--library-accent); }
html[data-theme="dark"] .library-layout .story-badges .badge-primary { color: var(--library-accent); }

/* Image carousel: panoramic on desktop, a separate crop/artwork on mobile. */
.library-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body.library-layout .image-banner .banner-shell { display: block; position: relative; height: auto; min-height: 0; padding: 0; aspect-ratio: 21/9; overflow: hidden; border: 1px solid var(--library-border); border-radius: 16px; background: var(--color-bg-tertiary); box-shadow: var(--library-shadow); isolation: isolate; }
.banner-image-slide { position: absolute; inset: 0; }
.banner-image-slide[hidden] { display: none; }
.banner-image-link { display: block; width: 100%; height: 100%; position: relative; overflow: hidden; color: #fff8ed; }
.banner-image-link picture, .banner-image-link img { display: block; width: 100%; height: 100%; }
.banner-image-link img { object-fit: cover; object-position: center 30%; }
.banner-image-link.has-banner-art img { object-position: center; }
.banner-slide-caption { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 32px 8%; background: linear-gradient(90deg, rgba(21,17,20,.8), rgba(21,17,20,.45) 48%, transparent 85%); }
.has-banner-art .banner-slide-caption { display: none; }
.banner-slide-kicker { color: #f0d3a7; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 16px; }
.banner-slide-caption h2 { color: #fff8ed; font-family: 'Literata', 'Noto Serif', Georgia, serif; font-size: clamp(26px, 4vw, 52px); line-height: 1.18; letter-spacing: -.025em; font-weight: 600; max-width: 65%; text-wrap: balance; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 2px 20px rgba(0,0,0,.3); }
.banner-slide-cta { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 10px 22px; margin-top: 22px; border: 1px solid #f0d3a7; border-radius: 999px; background: #f0d3a7; color: #3a2430; font-size: 13px; font-weight: 700; letter-spacing: normal; }
.banner-slide-cta .hdk-icon { width: 16px; height: 16px; }
.banner-image-link:hover .banner-slide-cta { background: #ffe5bc; }
body.library-layout .image-banner .banner-nav { top: 50%; bottom: auto; transform: translateY(-50%); z-index: 4; display: grid; place-items: center; width: 44px; height: 44px; background: rgba(255,255,255,.92); border: 1px solid rgba(125,85,59,.18); border-radius: 50%; color: #804c30; opacity: 1; box-shadow: 0 3px 12px rgba(0,0,0,.08); }
body.library-layout .image-banner .banner-nav:hover { background: #fff; }
body.library-layout .image-banner .banner-nav-prev { left: 12px; right: auto; }
body.library-layout .image-banner .banner-nav-next { right: 12px; }
.banner-image-controls { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 0; min-height: 44px; }
body.library-layout .image-banner .banner-indicators { position: static; transform: none; display: flex; flex-wrap: wrap; justify-content: center; min-width: 0; max-width: calc(100% - 52px); gap: 0; }
body.library-layout .image-banner .banner-indicator { position: relative; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 0; background: transparent; }
body.library-layout .image-banner .banner-indicator::after { content: ''; display: block; width: 7px; height: 7px; margin: auto; border-radius: 999px; background: var(--color-border); transition: width .2s; }
body.library-layout .image-banner .banner-indicator.active::after { width: 20px; background: var(--library-accent); }
body.library-layout .image-banner .hero-announcement { margin: 0 0 12px; border-radius: 12px; }
.banner-empty-link { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 16px; padding: 24px; text-align: center; color: var(--color-text-primary); background: var(--color-primary-light); }
.banner-empty-link strong { font-family: var(--font-serif); font-size: clamp(24px, 4vw, 48px); }
.banner-empty-link span { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; }
@media (max-width: 768px) {
    body.library-layout .image-banner .banner-shell { aspect-ratio: 16/9; border-radius: 12px; }
    .banner-slide-caption { padding: 24px 9%; }
    .banner-slide-caption h2 { font-size: clamp(24px, 4.5vw, 34px); max-width: 78%; }
    .banner-slide-kicker { font-size: 10px; margin-bottom: 10px; }
    .banner-slide-cta { margin-top: 14px; }
    body.library-layout .image-banner .banner-nav { width: 36px; height: 44px; }
    body.library-layout .image-banner .banner-nav-prev { left: 4px; }
    body.library-layout .image-banner .banner-nav-next { right: 4px; }
}
@media (max-width: 540px) {
    body.library-layout .image-banner .banner-shell { aspect-ratio: 4/3; }
    .banner-slide-caption { justify-content: flex-end; padding: 22px 38px; background: linear-gradient(0deg, rgba(21,17,20,.92), rgba(21,17,20,.35) 65%, rgba(21,17,20,.05)); }
    .banner-slide-caption h2 { font-size: clamp(21px, 5.6vw, 28px); max-width: 100%; -webkit-line-clamp: 3; }
    .banner-slide-kicker { font-size: 9px; margin-bottom: 8px; }
    .banner-slide-cta { min-height: 44px; padding: 8px 16px; margin-top: 12px; font-size: 11px; }
    .banner-image-controls { padding-block: 4px; }
}
@media (prefers-reduced-motion: reduce) { body.library-layout .image-banner .banner-indicator::after { transition: none; } }
/* Preserve text already designed into uploaded banner artwork. */
.banner-image-link.has-banner-art img { object-fit: contain; }
@media (max-width: 768px) {
    .banner-image-link.has-mobile-art img { object-fit: contain; }
    .has-mobile-art .banner-slide-caption { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
    .banner-image-slide.is-active.is-entering { animation: banner-image-enter .35s ease; }
}
@keyframes banner-image-enter { from { opacity: .35; } to { opacity: 1; } }

/* One Lucide set: stable sizing and alignment for shelf headings and metadata. */
.library-section-icon .hdk-icon { display: block; stroke-width: 1.75; }
.library-book-stats .hdk-icon, .library-more .hdk-icon { flex-shrink: 0; }
.library-more .hdk-icon { width: 16px; height: 16px; }
.library-update-chapters a:focus-visible { outline: 2px solid var(--library-accent); outline-offset: 2px; border-radius: 4px; }

/* Size a sparse completed shelf to its real contents; six or more keep the full grid. */
@media (min-width: 1025px) {
    .library-section--compact { max-width: calc(var(--library-book-count) * 192px + (var(--library-book-count) - 1) * 20px + 56px); }
    .library-section--compact .library-book-grid { grid-template-columns: repeat(var(--library-book-count), minmax(0, 1fr)); }
    .library-section--compact .library-section-heading { flex-wrap: wrap; gap: 12px; }
    .library-section--compact .library-section-brand > div { min-width: 0; }
    .library-section--compact .library-section-heading h2 { font-size: 20px; }
    .library-section--compact .library-section-icon { width: 44px; height: 44px; flex-basis: 44px; border-radius: 14px; }
}

/* Approved announcement theme: identical geometry in light and dark modes. */
body.library-layout .image-banner .hero-announcement {
    --announcement-surface: #fff3d6;
    --announcement-text: #583617;
    --announcement-border: #d6b071;
    --announcement-badge: #f2d397;
    --announcement-badge-text: #583617;
    --announcement-control: #fffaf0;
    background: var(--announcement-surface);
    color: var(--announcement-text);
    border: 1px solid var(--announcement-border);
    border-radius: 12px;
    min-height: 58px;
    padding: 10px 14px;
    gap: 12px;
    box-shadow: none;
}
html[data-theme="dark"] body.library-layout .image-banner .hero-announcement {
    --announcement-surface: #352718;
    --announcement-text: #ffe8bc;
    --announcement-border: #b88a48;
    --announcement-badge: #f2cc83;
    --announcement-badge-text: #352718;
    --announcement-control: #49351f;
}
body.library-layout .image-banner .hero-announcement-label {
    background: var(--announcement-badge);
    color: var(--announcement-badge-text);
    min-height: 34px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
}
body.library-layout .image-banner .hero-announcement-track { font-size: 14px; font-weight: 500; line-height: 1.6; }
body.library-layout .image-banner .hero-announcement-copy a:focus-visible { outline: 2px solid var(--announcement-text); outline-offset: 3px; }
@media (max-width: 480px) {
    body.library-layout .image-banner .hero-announcement { padding: 8px 10px; gap: 8px; }
    body.library-layout .image-banner .hero-announcement-label { padding: 8px; }
}
