/* Novaly - digital library.
   Previously this file (and static/js/app.js) were dead: index.html carried a
   1100-line inline copy and never linked them. Both are now the real assets, so
   the browser can cache them separately from the HTML. */

:root {
    --bg-base: #080a0f;
    --bg-surface: #10131d;
    --bg-card: #151824;
    --bg-sidebar: #0f121c;
    --border: #23283b;
    --border-hover: #3b4360;
    --text-main: #f8fafc;
    --text-sub: #94a3b8;
    --text-dim: #64748b;
    --primary: #6366f1;
    --primary-soft: rgba(99, 102, 241, 0.16);
    --accent: #38bdf8;
    --accent-green: #10b981;
    --danger: #f87171;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-lg: 0 16px 36px rgba(0, 0, 0, 0.6);
    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Every interactive element must show where focus is. The previous build had no
   focus styles at all and no keyboard path into the cards. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.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;
}

.skip-link {
    position: absolute; left: 12px; top: -60px;
    background: var(--primary); color: #fff;
    padding: 10px 18px; border-radius: var(--radius-md);
    text-decoration: none; font-weight: 700; z-index: 3000;
    transition: top 0.2s;
}
.skip-link:focus { top: 12px; }

/* --- Header --------------------------------------------------------------- */

header {
    background: rgba(13, 16, 25, 0.95);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    padding: 14px 32px;
}

.header-wrap {
    max-width: 1560px; margin: 0 auto;
    display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}

.logo-box {
    display: flex; align-items: center; gap: 12px;
    text-decoration: none; color: inherit; flex-shrink: 0;
}

.logo-icon {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, #6366f1 0%, #38bdf8 100%);
    border-radius: var(--radius-md);
    display: grid; place-items: center;
    font-size: 1.2rem; font-weight: 800; color: #fff;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.35);
}

.logo-text { display: flex; flex-direction: column; line-height: 1.15; }
.logo-text strong { font-size: 1.25rem; font-weight: 800; letter-spacing: 0.5px; }
.logo-text span { font-size: 0.72rem; color: var(--text-dim); letter-spacing: 0.4px; }

.search-container { position: relative; flex: 1; max-width: 560px; margin: 0 auto; }
.search-container form { position: relative; }

.search-icon {
    position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
    width: 17px; height: 17px; pointer-events: none;
    fill: none; stroke: var(--text-dim); stroke-width: 2; stroke-linecap: round;
}

.search-container input {
    width: 100%; padding: 12px 40px 12px 44px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main); font-size: 0.92rem; font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-container input::-webkit-search-cancel-button { display: none; }
.search-container input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-clear {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-dim);
    font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 6px;
}
.search-clear:hover { color: var(--text-main); }

.suggest {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0;
    background: var(--bg-card); border: 1px solid var(--border-hover);
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    list-style: none; overflow: hidden; z-index: 200; max-height: 400px; overflow-y: auto;
}
.suggest li { display: flex; align-items: center; gap: 12px; padding: 9px 14px; cursor: pointer; }
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--primary-soft); }
.suggest img { width: 30px; height: 45px; object-fit: cover; border-radius: 4px; flex-shrink: 0; background: var(--bg-surface); }
.suggest .s-text { min-width: 0; }
.suggest .s-title { font-size: 0.86rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest .s-author { font-size: 0.75rem; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.filters-toggle {
    display: none; background: var(--bg-surface); border: 1px solid var(--border);
    color: var(--text-main); padding: 10px 16px; border-radius: var(--radius-md);
    font-family: inherit; font-weight: 600; cursor: pointer;
}

/* --- Toolbar -------------------------------------------------------------- */

main { max-width: 1560px; margin: 0 auto; width: 100%; padding: 24px 32px 64px; flex: 1; }

.main-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px; flex-wrap: wrap;
    margin-bottom: 22px; padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.media-nav {
    display: flex; background: #101420; padding: 4px;
    border-radius: 36px; border: 1px solid var(--border); gap: 4px; flex-wrap: wrap;
}

.media-nav button {
    background: transparent; border: none; color: var(--text-sub);
    padding: 9px 18px; border-radius: 30px;
    font-family: inherit; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.4px;
    cursor: pointer; display: inline-flex; align-items: center; gap: 7px;
    transition: background 0.2s, color 0.2s;
}
.media-nav button:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.05); }
.media-nav button[aria-pressed="true"] {
    background: linear-gradient(135deg, #6366f1 0%, #38bdf8 100%);
    color: #fff; box-shadow: 0 0 18px rgba(99, 102, 241, 0.4);
}
.media-nav .count { font-size: 0.72rem; opacity: 0.72; font-weight: 600; }

.toolbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.toolbar-right select {
    background: var(--bg-surface); border: 1px solid var(--border);
    color: var(--text-main); padding: 10px 14px; border-radius: var(--radius-md);
    font-family: inherit; font-size: 0.85rem; cursor: pointer;
}
.toolbar-right select:focus { outline: none; border-color: var(--primary); }

.view-toggle { display: flex; border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.view-toggle button {
    background: var(--bg-surface); border: none; color: var(--text-sub);
    padding: 10px 14px; font-family: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.view-toggle button.active { background: var(--primary); color: #fff; }

/* --- Layout --------------------------------------------------------------- */

.layout-container { display: flex; gap: 26px; align-items: flex-start; }

.left-sidebar {
    width: 254px; flex-shrink: 0;
    background: var(--bg-sidebar); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 16px 12px;
    position: sticky; top: 92px;
    max-height: calc(100vh - 116px); overflow-y: auto;
}

.sidebar-group + .sidebar-group { margin-top: 18px; }

.sidebar-header {
    font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.9px; color: var(--accent);
    margin-bottom: 8px; padding-left: 10px;
}

.sidebar-menu { display: flex; flex-direction: column; gap: 3px; }

.sidebar-link {
    background: transparent; border: 1px solid transparent; color: var(--text-sub);
    padding: 8px 12px; border-radius: var(--radius-md);
    font-family: inherit; font-size: 0.855rem; font-weight: 600; text-align: left;
    cursor: pointer; display: flex; align-items: center; gap: 9px; width: 100%;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.05); }
.sidebar-link[aria-pressed="true"] {
    background: var(--primary); color: #fff; border-color: var(--primary);
}
.sidebar-link .g-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-link .count { font-size: 0.72rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.sidebar-link[aria-pressed="true"] .count { color: rgba(255, 255, 255, 0.8); }

/* Browse filters: compact controls above, searchable genres alongside results. */
.browse-page [hidden] { display: none !important; }
.browse-page .sidebar-link .g-name { white-space: normal; overflow-wrap: anywhere; }
.genre-search-label { display: block; font-size: 0.8rem; font-weight: 700; margin: 0 8px 8px; }
#genre-search { width: 100%; min-width: 0; padding: 10px 12px; margin-bottom: 14px;
    border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--bg-surface); color: var(--text-main); font: inherit; font-size: 0.84rem; }
.clear-filters { background: transparent; border-style: dashed; }
.browse-page .results-count { white-space: nowrap; }
.browse-page .toolbar-right { max-width: 100%; }
.browse-page .media-nav { border-radius: 16px; }
@media (max-width: 860px) {
    .browse-page .main-toolbar { gap: 12px; }
    .browse-page .media-nav { flex: 1 1 100%; }
    .browse-page .media-nav button { padding: 9px 12px; letter-spacing: 0; }
    .browse-page .toolbar-right { flex: 1 1 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .browse-page .toolbar-right select { width: 100%; min-width: 0; }
    .browse-page .toolbar-right .switch { grid-column: 1 / -1; }
    .browse-page .left-sidebar { max-height: 45vh; overflow-y: auto; }
}

.header-nav { flex-wrap: wrap; }
.collection-context { color: var(--text-sub); font-size: .85rem; }
@media (max-width: 1150px) {
    .header-wrap { flex-wrap: wrap; }
    .header-nav { width: 100%; justify-content: center; gap: 16px; }
    .search-container { min-width: 200px; }
}

.right-content { flex: 1; min-width: 0; }

.results-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.results-title { font-size: 1.3rem; font-weight: 800; }
.results-count { font-size: 0.84rem; color: var(--text-sub); font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
    display: inline-flex; align-items: center; gap: 7px;
    background: var(--primary-soft); border: 1px solid rgba(99, 102, 241, 0.35);
    color: var(--text-main); padding: 5px 10px; border-radius: 20px;
    font-size: 0.78rem; font-weight: 600; font-family: inherit; cursor: pointer;
}
.chip:hover { border-color: var(--primary); }
.chip .x { font-size: 1rem; line-height: 1; opacity: 0.7; }

/* --- Cards ---------------------------------------------------------------- */

/* One fluid rule instead of a step at 860px. A tablet held upright is about
   820px wide, which fell on the phone side of that step and got 140px cards -
   the smallest cards on one of the biggest screens, with most of the width
   spent on gaps. The card now grows with the viewport and stops at the two
   sizes that were already right for a phone and for a desktop. */
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(140px, 18vw, 190px), 1fr)); gap: clamp(14px, 1.6vw, 20px); }
.books-grid:focus { outline: none; }

.book-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
    cursor: pointer; display: flex; flex-direction: column;
    text-align: left; font-family: inherit; color: inherit; padding: 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.25s, box-shadow 0.25s;
}
.book-card:hover { transform: translateY(-5px); border-color: var(--border-hover); box-shadow: var(--shadow-lg); }

.thumb-box { position: relative; width: 100%; aspect-ratio: 2 / 3; overflow: hidden; background: #151926; }
.thumb-box img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s ease; }
.book-card:hover .thumb-box img { transform: scale(1.05); }

.format-badge, .lang-badge {
    position: absolute; top: 9px;
    padding: 3px 8px; border-radius: 4px;
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.4px;
    backdrop-filter: blur(8px); color: #fff;
}
.format-badge { right: 9px; background: rgba(10, 12, 18, 0.85); }
.lang-badge { left: 9px; background: rgba(99, 102, 241, 0.85); }

.card-details { padding: 11px 12px 12px; flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }

.book-title {
    font-size: 0.9rem; font-weight: 700; line-height: 1.32;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; margin-bottom: 3px;
}
.book-author { font-size: 0.76rem; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.card-bottom {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 0.72rem; color: var(--text-dim);
    border-top: 1px solid var(--border); padding-top: 8px;
    font-variant-numeric: tabular-nums;
}
.card-bottom .genre { color: var(--accent); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* List view */
.books-grid.list { grid-template-columns: 1fr; gap: 10px; }
.books-grid.list .book-card { flex-direction: row; align-items: stretch; }
.books-grid.list .thumb-box { width: 68px; aspect-ratio: auto; flex-shrink: 0; }
.books-grid.list .format-badge, .books-grid.list .lang-badge { display: none; }
.books-grid.list .card-details { flex-direction: row; align-items: center; gap: 20px; padding: 12px 16px; }
.books-grid.list .book-title { -webkit-line-clamp: 1; margin: 0; }
.books-grid.list .card-meta { flex: 1; min-width: 0; }
.books-grid.list .card-bottom { border: none; padding: 0; gap: 18px; flex-shrink: 0; }

/* Skeleton placeholders while a page loads */
.skeleton { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.skeleton .sk-img { width: 100%; aspect-ratio: 2 / 3; background: linear-gradient(100deg, #151926 30%, #1d2130 50%, #151926 70%); background-size: 220% 100%; animation: shimmer 1.3s infinite linear; }
.skeleton .sk-line { height: 10px; margin: 12px; border-radius: 4px; background: #1d2130; }
.skeleton .sk-line.short { width: 55%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -20% 0; } }

/* --- Empty state & pagination --------------------------------------------- */

.empty-state { text-align: center; padding: 80px 20px; }
.empty-mark { font-size: 3rem; color: var(--text-dim); margin-bottom: 12px; font-weight: 800; }
.empty-state h2 { font-size: 1.35rem; margin-bottom: 6px; }
.empty-state p { color: var(--text-sub); margin-bottom: 20px; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 36px; flex-wrap: wrap; }
.page-btn {
    background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-main);
    min-width: 40px; padding: 8px 14px; border-radius: var(--radius-md);
    font-family: inherit; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums;
    transition: background 0.15s, border-color 0.15s;
}
.page-btn:hover:not(:disabled) { background: var(--primary); border-color: var(--primary); }
.page-btn[aria-current="page"] { background: var(--primary); border-color: var(--primary); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.page-gap { padding: 8px 4px; color: var(--text-dim); }

/* --- Buttons -------------------------------------------------------------- */

.btn-primary, .btn-secondary {
    padding: 12px 22px; border-radius: var(--radius-md);
    font-family: inherit; font-weight: 700; font-size: 0.92rem;
    display: inline-flex; align-items: center; gap: 8px;
    text-decoration: none; cursor: pointer; border: none;
    transition: filter 0.2s, transform 0.2s, background 0.2s;
}
.btn-primary { background: linear-gradient(135deg, #6366f1 0%, #38bdf8 100%); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-surface); border: 1px solid var(--border-hover); color: var(--text-main); font-weight: 600; }
.btn-secondary:hover { background: var(--border-hover); }

/* --- Modal ---------------------------------------------------------------- */

.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(4, 5, 8, 0.85); backdrop-filter: blur(12px);
    z-index: 1000; display: flex; justify-content: center; align-items: center; padding: 24px;
}
.modal-overlay[hidden] { display: none; }

.modal-box {
    background: var(--bg-card); border: 1px solid var(--border-hover);
    border-radius: var(--radius-xl); max-width: 840px; width: 100%;
    position: relative; overflow: hidden; max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    animation: popIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes popIn { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-close {
    position: absolute; right: 16px; top: 16px;
    background: rgba(255, 255, 255, 0.08); border: 1px solid var(--border);
    color: var(--text-main); width: 38px; height: 38px; border-radius: 50%;
    cursor: pointer; font-size: 1.3rem; line-height: 1; z-index: 10;
    display: grid; place-items: center;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.2); }

.modal-content { display: flex; overflow-y: auto; padding: 30px; gap: 30px; }
.modal-cover-wrap { width: 240px; flex-shrink: 0; }
.modal-cover-wrap img { width: 100%; border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.7); display: block; }
.modal-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.modal-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.badge-pill {
    background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border);
    padding: 4px 11px; border-radius: var(--radius-md); font-size: 0.76rem; font-weight: 600;
}
.badge-pill.cat { background: var(--primary-soft); color: var(--accent); border-color: rgba(99, 102, 241, 0.3); }
.badge-pill.sz { background: rgba(16, 185, 129, 0.15); color: var(--accent-green); border-color: rgba(16, 185, 129, 0.3); }

.modal-title-text { font-size: 1.5rem; font-weight: 800; line-height: 1.25; margin-bottom: 5px; }
.modal-author-text { font-size: 0.92rem; color: var(--text-sub); margin-bottom: 18px; }

.desc-box { background: rgba(0, 0, 0, 0.3); border: 1px solid var(--border); padding: 15px; border-radius: var(--radius-md); margin-bottom: 22px; flex: 1; }
.desc-title { font-weight: 700; font-size: 0.74rem; color: var(--accent); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.6px; }
.desc-text { font-size: 0.9rem; line-height: 1.6; color: #cbd5e1; max-height: 170px; overflow-y: auto; }
.desc-text.muted { color: var(--text-dim); font-style: italic; }

.modal-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* --- Toast ---------------------------------------------------------------- */

.toast {
    position: fixed; bottom: 28px; left: 50%;
    transform: translateX(-50%) translateY(120px);
    background: var(--accent-green); color: #fff;
    padding: 12px 22px; border-radius: var(--radius-md);
    font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1); z-index: 2000;
}
.toast[hidden] { display: block; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 1024px) {
    .header-wrap { flex-wrap: wrap; }
    .search-container { order: 3; max-width: none; width: 100%; margin: 0; }
}

@media (max-width: 860px) {
    header { padding: 12px 18px; }
    main { padding: 18px 18px 48px; }
    .filters-toggle { display: block; }
    .layout-container { flex-direction: column; }
    .left-sidebar { width: 100%; position: static; max-height: none; }
    .left-sidebar[hidden] { display: none; }
    .modal-content { flex-direction: column; align-items: center; padding: 22px; }
    .modal-cover-wrap { width: 170px; }
    .books-grid.list .card-details { flex-direction: column; align-items: flex-start; gap: 6px; }
    .results-bar { flex-direction: column; align-items: flex-start; gap: 4px; }
}

/* ===========================================================================
   Link health, editions, QR, reporting, stats page
   =========================================================================== */

.header-nav { display: flex; gap: 18px; flex: 1 1 100%; min-width: 0; justify-content: center; }
.header-nav a {
    color: var(--text-sub); text-decoration: none;
    font-size: 0.88rem; font-weight: 600; padding: 8px 4px;
}
.header-nav a:hover, .header-nav a[aria-current="page"] { color: var(--text-main); }

/* --- Working-links switch ------------------------------------------------- */

.switch {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    font-size: 0.84rem; font-weight: 600; color: var(--text-sub);
    background: var(--bg-surface); border: 1px solid var(--border);
    padding: 9px 14px; border-radius: var(--radius-md); user-select: none;
}
.switch:hover { color: var(--text-main); border-color: var(--border-hover); }
.switch input { accent-color: var(--primary); width: 15px; height: 15px; cursor: pointer; }
.switch:has(input:checked) {
    color: var(--text-main); border-color: var(--primary); background: var(--primary-soft);
}

/* --- Link status ---------------------------------------------------------- */

.link-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.2px;
    padding: 3px 8px; border-radius: 20px; border: 1px solid transparent;
    white-space: nowrap;
}
.link-badge.ok   { color: #34d399; background: rgba(16,185,129,0.13); border-color: rgba(16,185,129,0.3); }
.link-badge.unk  { color: var(--text-dim); background: rgba(148,163,184,0.1); border-color: var(--border); }
.link-badge.warn { color: #fbbf24; background: rgba(251,191,36,0.13); border-color: rgba(251,191,36,0.3); }
.link-badge.bad  { color: var(--danger); background: rgba(248,113,113,0.13); border-color: rgba(248,113,113,0.3); }

.link-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.link-dot.ok { background: #34d399; }
.link-dot.unk { background: var(--text-dim); }
.link-dot.warn { background: #fbbf24; }
.link-dot.bad { background: var(--danger); }

.card-genre {
    font-size: 0.7rem; color: var(--accent); margin-top: 6px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-size { font-variant-numeric: tabular-nums; }

.link-state { margin-bottom: 16px; }
.link-state-inner {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    font-size: 0.84rem; color: var(--text-sub);
    padding: 10px 13px; border-radius: var(--radius-md);
    background: rgba(255,255,255,0.03); border: 1px solid var(--border);
}
.link-state-inner.ok   { border-color: rgba(16,185,129,0.28); }
.link-state-inner.warn { border-color: rgba(251,191,36,0.28); }
.link-state-inner.bad  { border-color: rgba(248,113,113,0.28); }

/* --- Format chips (grouped editions) -------------------------------------- */

.fmt-chips {
    position: absolute; top: 9px; right: 9px; display: flex; gap: 3px;
    flex-wrap: wrap; justify-content: flex-end; max-width: 70%;
}
.fmt-chip {
    background: rgba(10,12,18,0.85); backdrop-filter: blur(8px); color: #fff;
    padding: 3px 6px; border-radius: 4px; font-size: 0.62rem; font-weight: 700;
    letter-spacing: 0.3px;
}

.editions { margin-bottom: 16px; }
.editions-label {
    display: block; font-size: 0.72rem; font-weight: 700; color: var(--accent);
    text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 8px;
}
.edition-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.edition-chip {
    display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
    min-width: 76px; padding: 8px 12px; text-decoration: none;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-md); color: var(--text-main);
    transition: border-color 0.2s, background 0.2s;
}
.edition-chip:hover { border-color: var(--primary); background: var(--primary-soft); }
.edition-chip strong { font-size: 0.8rem; font-weight: 700; }
.edition-chip span { font-size: 0.68rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.edition-chip.current { border-color: var(--primary); }
.edition-chip.bad { opacity: 0.55; }

/* --- QR ------------------------------------------------------------------- */

.qr-wrap {
    margin-top: 14px; text-align: center; background: #fff;
    border-radius: var(--radius-md); padding: 12px;
}
.qr-wrap[hidden] { display: none; }
.qr-wrap img { width: 100%; max-width: 170px; height: auto; display: block; margin: 0 auto; }
.qr-note { font-size: 0.7rem; color: #334155; margin-top: 8px; line-height: 1.35; }

.btn-ghost {
    padding: 12px 16px; border-radius: var(--radius-md); background: transparent;
    border: 1px solid transparent; color: var(--text-dim);
    font-family: inherit; font-weight: 600; font-size: 0.86rem; cursor: pointer;
}
.btn-ghost:hover { color: var(--danger); border-color: rgba(248,113,113,0.35); }

/* --- Report dialog -------------------------------------------------------- */

.modal-box.narrow { max-width: 460px; }
.modal-content.column { flex-direction: column; gap: 0; }
.reasons {
    border: none; display: flex; flex-direction: column; gap: 10px; margin: 18px 0 24px;
}
.reasons label {
    display: flex; align-items: center; gap: 10px; font-size: 0.9rem;
    color: var(--text-sub); cursor: pointer;
}
.reasons input { accent-color: var(--primary); width: 16px; height: 16px; }
.reasons label:hover { color: var(--text-main); }

/* --- Footer --------------------------------------------------------------- */

.site-footer {
    border-top: 1px solid var(--border); background: var(--bg-sidebar);
    padding: 20px 32px; margin-top: 40px;
}
.footer-wrap {
    max-width: 1560px; margin: 0 auto; display: flex; justify-content: space-between;
    align-items: center; gap: 16px; flex-wrap: wrap;
    font-size: 0.82rem; color: var(--text-dim);
}
.site-footer a { color: var(--text-sub); text-decoration: none; font-weight: 600; }
.site-footer a:hover { color: var(--accent); }

/* --- Stats page ----------------------------------------------------------- */

.stats-page { max-width: 1200px; }
.page-title { font-size: 1.7rem; font-weight: 800; margin-bottom: 6px; }
.page-sub { color: var(--text-sub); margin-bottom: 30px; max-width: 640px; line-height: 1.55; }
.section-heading { font-size: 1.05rem; font-weight: 800; margin: 32px 0 14px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat-tile {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 18px;
}
.stat-tile.good { border-color: rgba(16,185,129,0.35); }
.stat-tile.warn { border-color: rgba(251,191,36,0.35); }
.stat-tile.bad  { border-color: rgba(248,113,113,0.35); }
.stat-value { font-size: 1.85rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.84rem; color: var(--text-sub); margin-top: 4px; font-weight: 600; }
.stat-sub { font-size: 0.74rem; color: var(--text-dim); margin-top: 3px; }

.panel {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 18px; margin-top: 14px;
}
.panel-head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.panel-head h3 { font-size: 0.95rem; font-weight: 700; }
.panel-note { font-size: 0.75rem; color: var(--text-dim); }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }

.chart { width: 100%; overflow-x: auto; }
.chart-svg { width: 100%; height: 200px; display: block; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; font-size: 0.76rem; color: var(--text-sub); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 62px; align-items: center; gap: 10px; font-size: 0.8rem; }
.bar-label { color: var(--text-sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: rgba(255,255,255,0.05); border-radius: 4px; height: 9px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #38bdf8); border-radius: 4px; }
.bar-value { text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); gap: 14px; }
.mini-card { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
.mini-card img {
    width: 100%; aspect-ratio: 2/3; object-fit: cover; border-radius: var(--radius-md);
    border: 1px solid var(--border); background: var(--bg-surface);
}
.mini-title {
    font-size: 0.78rem; font-weight: 600; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mini-author, .mini-meta {
    font-size: 0.7rem; color: var(--text-dim);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.muted { color: var(--text-dim); font-size: 0.85rem; }

@media (max-width: 860px) {
    .header-nav { order: 2; }
    .site-footer { padding: 18px; }
    .bar-row { grid-template-columns: 96px 1fr 54px; }
}

/* ===========================================================================
   Site chrome: landing, detail, listings, prose, footer, admin
   =========================================================================== */

.page-wrap { max-width: 1560px; margin: 0 auto; width: 100%; padding: 0 32px 64px; }
.narrow-wrap { max-width: 760px; }

img.logo-icon { border-radius: var(--radius-md); display: block; }
.logo-text { display: flex; flex-direction: column; line-height: 1.15; }

/* --- Hero ----------------------------------------------------------------- */

.hero {
    background:
        radial-gradient(1000px 420px at 18% -10%, rgba(99,102,241,0.30), transparent 60%),
        radial-gradient(900px 420px at 82% 0%, rgba(56,189,248,0.20), transparent 60%),
        var(--bg-base);
    border-bottom: 1px solid var(--border);
    padding: 76px 32px 68px;
    margin-bottom: 44px;
}
.hero-inner { max-width: 780px; margin: 0 auto; text-align: center; }
.hero-eyebrow {
    font-size: 0.8rem; font-weight: 700; letter-spacing: 0.8px;
    text-transform: uppercase; color: var(--accent); margin-bottom: 16px;
}
.hero-title { font-size: clamp(2.1rem, 5.5vw, 3.6rem); font-weight: 800; line-height: 1.08; margin-bottom: 18px; }
.hero-sub { font-size: 1.06rem; line-height: 1.6; color: var(--text-sub); margin: 0 auto 30px; max-width: 620px; }

.hero-search { display: flex; gap: 10px; max-width: 580px; margin: 0 auto 18px; }
.hero-search input {
    flex: 1; min-width: 0; padding: 15px 18px;
    background: var(--bg-surface); border: 1px solid var(--border-hover);
    border-radius: var(--radius-md); color: var(--text-main);
    font-size: 1rem; font-family: inherit;
}
.hero-search input:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.hero-hints { font-size: 0.86rem; color: var(--text-dim); }
.hero-hints a { color: var(--text-sub); text-decoration: none; }
.hero-hints a:hover { color: var(--accent); text-decoration: underline; }

/* --- Value row ------------------------------------------------------------ */

.value-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; margin-bottom: 48px; }
.value-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; }
.value-card h2 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.value-card p { font-size: 0.9rem; line-height: 1.55; color: var(--text-sub); }

/* --- Shelves -------------------------------------------------------------- */

.shelf { margin-bottom: 46px; }
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.shelf-head h2 { font-size: 1.22rem; font-weight: 800; }
.shelf-more { color: var(--accent); text-decoration: none; font-size: 0.86rem; font-weight: 600; white-space: nowrap; }
.shelf-more:hover { text-decoration: underline; }
.shelf-note { font-size: 0.86rem; color: var(--text-dim); margin-bottom: 16px; }
.shelf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(128px, 15vw, 160px), 1fr)); gap: clamp(12px, 1.3vw, 16px); }

/* --- Genre tiles ---------------------------------------------------------- */

.browse-genres { margin-bottom: 48px; }
.genre-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-top: 16px; }
.genre-tile {
    display: flex; align-items: center; gap: 11px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); padding: 13px 15px;
    text-decoration: none; color: var(--text-main);
    transition: border-color 0.2s, transform 0.2s;
}
.genre-tile:hover { border-color: var(--primary); transform: translateY(-2px); }
.genre-icon { font-size: 1.15rem; flex-shrink: 0; }
.genre-name { flex: 1; font-size: 0.9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.genre-count { font-size: 0.75rem; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* --- Server-rendered cards ------------------------------------------------ */
/* The card is an <a> on server-rendered pages and a <button> in the SPA grid,
   so the shared rules must not assume either element. */

.book-card-link { display: block; }
a.book-card { text-decoration: none; color: inherit; }
a.book-card .thumb-box, a.book-card .card-details { display: flex; }
a.book-card .thumb-box { position: relative; width: 100%; aspect-ratio: 2/3; overflow: hidden; background: #151926; }
a.book-card .card-details { flex-direction: column; }
a.book-card .book-title, a.book-card .book-author,
a.book-card .card-bottom, a.book-card .card-genre, a.book-card .card-meta { display: block; }
a.book-card .card-bottom { display: flex; }
a.book-card .book-title {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* --- Breadcrumb ----------------------------------------------------------- */

.breadcrumb { padding: 20px 0 14px; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.82rem; color: var(--text-dim); }
.breadcrumb li + li::before { content: "/"; margin-right: 8px; color: var(--border-hover); }
.breadcrumb a { color: var(--text-sub); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb [aria-current] { color: var(--text-main); max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Book detail ---------------------------------------------------------- */

.detail { display: grid; grid-template-columns: 300px 1fr; gap: 44px; margin-bottom: 56px; align-items: start; }
.detail-cover img {
    width: 100%; border-radius: var(--radius-lg); border: 1px solid var(--border);
    box-shadow: 0 18px 40px rgba(0,0,0,0.6); display: block; background: var(--bg-surface);
}
.detail-qr-toggle { width: 100%; margin-top: 14px; justify-content: center; }
.detail-title { font-size: clamp(1.5rem, 3.2vw, 2.1rem); font-weight: 800; line-height: 1.2; margin-bottom: 8px; }
.detail-author { font-size: 1rem; color: var(--text-sub); margin-bottom: 22px; }
.detail-author a { color: var(--accent); text-decoration: none; }
.detail-author a:hover { text-decoration: underline; }
a.badge-pill { text-decoration: none; }
a.badge-pill:hover { border-color: var(--primary); }

.detail-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 14px; margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--border); }
.detail-facts dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); margin-bottom: 3px; }
.detail-facts dd { font-size: 0.92rem; font-weight: 600; }

/* --- Listings ------------------------------------------------------------- */

.listing-head { margin-bottom: 22px; }
.facet-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.facet-row .chip { text-decoration: none; }
.facet-row .chip .count { font-size: 0.72rem; opacity: 0.7; font-variant-numeric: tabular-nums; }
a.page-btn { text-decoration: none; display: inline-flex; align-items: center; }
.page-btn[aria-disabled="true"] { opacity: 0.35; pointer-events: none; }
.page-status { color: var(--text-sub); font-size: 0.88rem; padding: 0 12px; font-variant-numeric: tabular-nums; }
.noscript-note { margin-top: 20px; }

/* --- Prose (about, legal) ------------------------------------------------- */

.prose { padding-bottom: 40px; }
.prose h1 { font-size: 1.9rem; font-weight: 800; margin-bottom: 14px; }
.prose h2 { font-size: 1.08rem; font-weight: 700; margin: 30px 0 10px; color: var(--text-main); }
.prose p { font-size: 0.96rem; line-height: 1.72; color: var(--text-sub); margin-bottom: 14px; }
.prose .lead { font-size: 1.08rem; color: var(--text-main); margin-bottom: 22px; }
.prose ul { margin: 0 0 16px 20px; }
.prose li { font-size: 0.96rem; line-height: 1.7; color: var(--text-sub); margin-bottom: 8px; }
.prose a { color: var(--accent); }
.prose code { background: var(--bg-surface); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; font-size: 0.86em; }
.prose-meta { font-size: 0.82rem; color: var(--text-dim); margin-top: 30px; padding-top: 16px; border-top: 1px solid var(--border); }

/* --- Subscribe ------------------------------------------------------------ */

.subscribe {
    background: linear-gradient(135deg, rgba(99,102,241,0.14), rgba(56,189,248,0.09));
    border: 1px solid var(--border-hover); border-radius: var(--radius-xl);
    padding: 34px; margin: 48px 0;
}
.subscribe-inner { max-width: 560px; margin: 0 auto; text-align: center; }
.subscribe h2 { font-size: 1.24rem; font-weight: 800; margin-bottom: 8px; }
.subscribe p { color: var(--text-sub); font-size: 0.92rem; margin-bottom: 18px; }
.subscribe-form { display: flex; gap: 10px; }
.subscribe-form input[type="email"] {
    flex: 1; min-width: 0; padding: 13px 16px;
    background: var(--bg-base); border: 1px solid var(--border-hover);
    border-radius: var(--radius-md); color: var(--text-main); font-family: inherit; font-size: 0.95rem;
}
.subscribe-form input[type="email"]:focus { outline: none; border-color: var(--primary); }
.honeypot { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.subscribe-note { font-size: 0.82rem; color: var(--text-dim); margin-top: 14px; margin-bottom: 0; }
.subscribe-note a { color: var(--accent); }

/* --- Footer --------------------------------------------------------------- */

.footer-columns {
    display: grid; grid-template-columns: 1.6fr repeat(3, 1fr);
    gap: 32px; align-items: start; padding-bottom: 26px;
}
.footer-brand strong { font-size: 1.05rem; font-weight: 800; letter-spacing: 0.5px; display: block; margin-bottom: 8px; }
.footer-brand p { font-size: 0.85rem; color: var(--text-dim); line-height: 1.55; margin-bottom: 6px; }
.footer-count { font-variant-numeric: tabular-nums; }
.footer-columns nav { display: flex; flex-direction: column; gap: 7px; }
.footer-columns h2 { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.9px; color: var(--text-main); margin-bottom: 4px; }
.footer-columns a { font-size: 0.85rem; color: var(--text-dim); }
.footer-columns a:hover { color: var(--accent); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 18px; justify-content: space-between; }
.error-links { margin-top: 22px; font-size: 0.9rem; }
.error-links a { color: var(--accent); }

/* --- Admin ---------------------------------------------------------------- */

.token-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.token-form label { font-size: 0.86rem; color: var(--text-sub); font-weight: 600; }
.token-form input {
    flex: 1; min-width: 260px; padding: 11px 14px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-md); color: var(--text-main); font-family: inherit;
}
.inline-select {
    background: var(--bg-surface); border: 1px solid var(--border); color: var(--text-sub);
    border-radius: var(--radius-md); padding: 5px 9px; font-family: inherit;
    font-size: 0.78rem; font-weight: 600; margin-left: 10px;
}
.panel.highlight { border-color: rgba(251,191,36,0.35); }
.admin-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.btn-secondary.small { padding: 6px 12px; font-size: 0.78rem; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); color: var(--text-sub); }
.admin-table a { color: var(--accent); text-decoration: none; }
.bar-label a { color: inherit; text-decoration: none; }
.bar-label a:hover { color: var(--accent); }

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 1024px) {
    .footer-columns { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
    .page-wrap { padding: 0 18px 48px; }
    .hero { padding: 52px 18px 46px; margin-bottom: 32px; }
    .hero-search { flex-direction: column; }
    .detail { grid-template-columns: 1fr; gap: 26px; }
    .detail-cover { max-width: 230px; margin: 0 auto; }
    .subscribe { padding: 24px 18px; }
    .subscribe-form { flex-direction: column; }
    .footer-columns { grid-template-columns: 1fr; gap: 24px; }
    .footer-bottom { flex-direction: column; align-items: flex-start; gap: 6px; }
    .header-nav { gap: 12px; font-size: 0.85rem; }
    .admin-table { display: block; overflow-x: auto; }
}

/* --- Bulk edit form (admin) --------------------------------------------- */
.bulk-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
    padding: 1rem 1.15rem;
}
.bulk-form label {
    font-size: 0.82rem;
    color: var(--text-sub);
    margin-left: 0.3rem;
}
.bulk-form label:first-child { margin-left: 0; }
.bulk-form select,
.bulk-form input[type="text"] {
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text-main);
    font: inherit;
    font-size: 0.88rem;
    padding: 0.42rem 0.6rem;
}
.bulk-form input[type="text"] { min-width: 11rem; }
.bulk-form select:focus-visible,
.bulk-form input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.bulk-form button { margin-left: 0.25rem; }
.bulk-form button[disabled] { opacity: 0.45; cursor: not-allowed; }

#bulk-result { padding: 0 1.15rem 1.1rem; }
#bulk-result p { margin: 0 0 0.5rem; font-size: 0.9rem; }
.bulk-sample {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.86rem;
    color: var(--text-sub);
    max-height: 12rem;
    overflow-y: auto;
}
.bulk-sample li { margin-bottom: 0.2rem; }

.admin-table .nowrap { white-space: nowrap; }
.btn-secondary.small {
    padding: 0.28rem 0.6rem;
    font-size: 0.8rem;
}

/* --- Category suggestion dialog (book page) ----------------------------- */
.genre-select {
    width: 100%;
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font: inherit;
    font-size: 0.92rem;
    padding: 0.55rem 0.65rem;
    margin: 0.35rem 0 0.9rem;
}
.genre-select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.genre-select optgroup { font-style: normal; font-weight: 600; }

/* --- "Did you mean" on an empty search ---------------------------------- */
.did-you-mean {
    font-size: 1.05rem;
    margin: 0 0 0.4rem;
    color: var(--text-main);
}
.did-you-mean a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.did-you-mean a:hover { color: var(--primary); }

/* --- Browser-local reading list ----------------------------------------- */
.saved-count {
    display: inline-flex; min-width: 1.2rem; height: 1.2rem; padding: 0 0.32rem;
    align-items: center; justify-content: center; border-radius: 999px;
    background: var(--primary); color: #fff; font-size: 0.68rem; font-weight: 800;
}
.saved-head {
    display: flex; justify-content: space-between; gap: 24px; align-items: end;
    padding: 34px 0 26px; border-bottom: 1px solid var(--border); margin-bottom: 28px;
}
.saved-head h1 { margin: 3px 0 7px; font-size: clamp(2rem, 4vw, 3rem); }
.saved-head p { color: var(--text-sub); max-width: 620px; }
.saved-head .eyebrow { color: var(--accent); font-size: 0.76rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.09em; }
.saved-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
}
.saved-card {
    position: relative; min-width: 0; background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
}
.saved-card > a { display: grid; grid-template-columns: 76px 1fr; min-height: 112px; color: inherit; text-decoration: none; }
.saved-card img { width: 76px; height: 112px; object-fit: cover; background: var(--bg-elevated); }
.saved-card a > span { min-width: 0; padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.saved-card strong { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: 0.9rem; line-height: 1.35; }
.saved-card small { color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-card:hover { border-color: var(--border-hover); transform: translateY(-1px); }
.saved-remove {
    position: absolute; top: 6px; right: 6px; width: 26px; height: 26px;
    border: 1px solid var(--border-hover); border-radius: 50%; background: rgba(8,10,15,0.88);
    color: var(--text-sub); cursor: pointer;
}
.saved-remove:hover { color: #fff; border-color: var(--danger); }
.recent-section { margin-top: 48px; }

/* --- Comic hub responsive refinements ---------------------------------- */
.comics-search input { min-width: 0; }

/* --- Subgenres sit under the genre they belong to ----------------------- */
.sidebar-link.is-sub {
    padding-left: 1.9rem;
    font-size: 0.86rem;
}
.sidebar-link.is-sub .g-name { opacity: 0.88; }

@media (max-width: 600px) {
    .saved-head { align-items: flex-start; flex-direction: column; }
    .saved-grid { grid-template-columns: 1fr; }
    .comics-hero { padding: 20px !important; border-radius: 13px !important; }
    .comics-hero-row { align-items: stretch !important; }
    .comics-title-row { display: grid !important; grid-template-columns: auto 1fr; gap: 5px 10px !important; }
    .comics-title { font-size: 1.35rem !important; line-height: 1.15; }
    .comics-count { grid-column: 2; justify-self: start; }
    .comics-search { width: 100%; max-width: none !important; }
    .comics-search button { padding-left: 14px !important; padding-right: 14px !important; }
    .comics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 12px !important; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}

/* --- Pointer to the offline reader from a book page --------------------- */
.reader-hint {
    font-size: 0.88rem;
    color: var(--text-sub);
    background: var(--bg-base);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
    margin: 0 0 0.9rem;
    line-height: 1.55;
}
.reader-hint a { color: var(--accent); font-weight: 600; }

/* --- Ratings, shelves and reviews --------------------------------------- */
.review-block{border:1px solid var(--border);border-radius:12px;padding:1rem 1.1rem;
  margin:0 0 1rem;background:var(--bg-base)}
.rating-summary{display:flex;align-items:center;gap:.6rem;margin-bottom:.7rem}
.stars{color:#f0b429;letter-spacing:.08em;font-size:1.05rem}
.stars.pick{display:inline-flex;gap:.1rem}
.star{background:none;border:0;color:#7c8894;font-size:1.35rem;cursor:pointer;padding:0 .05rem;
  line-height:1}
.star.on{color:#f0b429}
.shelf-buttons{display:flex;gap:.4rem;flex-wrap:wrap;margin-bottom:.8rem}
.shelf-buttons button{font-size:.83rem;padding:.42rem .75rem}
.shelf-buttons button.on{background:var(--accent);color:#0d2a22;border-color:var(--accent);
  font-weight:600}
.my-review{display:flex;flex-direction:column;gap:.5rem;margin-bottom:.9rem}
.my-review textarea{background:var(--bg-surface);border:1px solid var(--border);
  border-radius:9px;color:var(--text-main);font:inherit;font-size:.9rem;padding:.6rem .7rem;
  resize:vertical}
.my-review button{align-self:flex-start}
.reviews-heading{font-size:.95rem;margin:.4rem 0 .6rem;color:var(--text-sub)}
.review{border-top:1px solid var(--border);padding:.7rem 0}
.review header{display:flex;align-items:baseline;gap:.55rem;flex-wrap:wrap;
  font-size:.85rem;color:var(--text-sub)}
.review header strong{color:var(--text-main)}
.review header time{margin-inline-start:auto;font-size:.78rem;color:var(--text-dim)}
.review p{margin:.4rem 0 0;font-size:.9rem;line-height:1.65;white-space:pre-line}
.report-review{background:none;border:0;color:var(--text-dim);font-size:.74rem;
  cursor:pointer;padding:0 .2rem}
.report-review:hover{color:var(--danger)}

/* --- My books ------------------------------------------------------------ */
.year-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));
  gap:.7rem;margin:.4rem 0 .6rem}
.year-tile{background:var(--bg-base);border:1px solid var(--border);border-radius:10px;
  padding:.7rem .85rem}
.year-tile b{display:block;font-size:1.5rem;font-variant-numeric:tabular-nums}
.year-tile span{display:block;font-size:.78rem;color:var(--text-sub);margin-top:.15rem}
.year-bar{height:8px;border-radius:5px;background:var(--bg-base);overflow:hidden;
  border:1px solid var(--border);margin-bottom:1.2rem}
.year-bar span{display:block;height:100%;background:var(--accent)}
.goal-row{display:flex;gap:.6rem;align-items:center;flex-wrap:wrap;margin-bottom:1.3rem;
  font-size:.86rem;color:var(--text-sub)}
.goal-row input{background:var(--bg-base);border:1px solid var(--border);border-radius:8px;
  color:var(--text-main);font:inherit;font-size:.88rem;padding:.4rem .6rem}
.goal-row input[type=number]{width:5.5rem}
.shelf-tabs{display:flex;gap:.4rem;flex-wrap:wrap;margin-bottom:1rem}
.shelf-tabs button{font-size:.85rem;padding:.45rem .85rem;border:1px solid var(--border);
  border-radius:20px;background:var(--bg-base);color:var(--text-sub);cursor:pointer}
.shelf-tabs button.on{background:var(--accent);color:#0d2a22;border-color:var(--accent);
  font-weight:600}
.book-card-body .finished,.book-card-body .progress-note{color:var(--accent)}
.book-card-body .fav{color:#f0b429}

/* --- Community ----------------------------------------------------------- */
.community-feed{display:flex;flex-direction:column;gap:1rem}
.community-review{display:flex;gap:.9rem;border:1px solid var(--border);border-radius:12px;
  padding:.85rem 1rem;background:var(--bg-base)}
.cr-cover img{width:62px;aspect-ratio:2/3;object-fit:cover;border-radius:6px;display:block}
.cr-body{flex:1;min-width:0}
.cr-body header{display:flex;align-items:baseline;gap:.5rem;flex-wrap:wrap;font-size:.84rem;
  color:var(--text-sub)}
.cr-body header strong{color:var(--text-main)}
.cr-body header time{margin-inline-start:auto;font-size:.76rem;color:var(--text-dim)}
.cr-title{display:block;font-weight:600;margin-top:.3rem;color:var(--text-main);
  text-decoration:none}
.cr-title:hover{color:var(--accent)}
.cr-body small{color:var(--text-sub);font-size:.8rem}
.cr-body p{margin:.45rem 0 .3rem;font-size:.9rem;line-height:1.65;white-space:pre-line}

.nav-toggle { display:none; padding:10px 18px; color:var(--text-main); background:var(--bg-surface); border:1px solid var(--border); border-radius:8px; }
@media(max-width:860px){.nav-enhanced .nav-toggle{display:block;margin-inline-start:auto}.nav-enhanced .header-nav:not(.is-open){display:none}.nav-enhanced .header-nav.is-open{display:flex}.header-wrap .search-container{order:3;flex-basis:100%;max-width:none}.nav-enhanced .header-nav{order:4}.header-wrap{gap:12px}}

/* Whether a file is real text or a picture of text decides whether it can be
   searched, resized or read aloud. It is shown where it is known and left off
   where the format does not settle it. */
.kind-badge { display: inline-block; margin-top: 6px; font-size: .72rem; font-weight: 600;
  letter-spacing: .01em; padding: 2px 8px; border-radius: 999px; }
.kind-searchable { background: rgba(20, 184, 166, .14); color: #5eead4; border: 1px solid rgba(20, 184, 166, .3); }
.kind-scanned { background: rgba(148, 163, 184, .12); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, .28); }
