/* app.css: the site's one look, layered over Bootstrap 5.3.
 *
 * Paper-grey pages, white panels outlined in ink, Figtree, a magenta accent
 * and a highlighter yellow for "you are here". One light source everywhere:
 * upper left, 30 degrees off vertical, so shadow offsets are x = 0.5d, y = 0.87d.
 *
 * Bootstrap's components are re-skinned through their --bs-* variables; the
 * site's own pieces follow, grouped by where they appear. Keep page-specific
 * rules here rather than in <style> blocks. The reader adds css/reader.css
 * on top (dark, via data-bs-theme="dark").
 */

:root {
    --paper: #EEF1F4;
    --panel: #fff;
    --ink: #1d232b;
    --muted: #5b6570;
    --line: #1d232b;
    --rule: #cfd6dd;
    --highlight: #FFE45C;
    --accent: #D1006F;
    --accent-dark: #b0005d;
    --accent-ink: #fff;
    --link: #0077A8;
    --cover-bg: #d6dce2;

    --shadow-sm: 3px 5px 10px rgba(20, 28, 38, 0.30);
    --shadow: 6px 10px 18px rgba(20, 28, 38, 0.42);
    --shadow-pop: 16px 28px 48px rgba(20, 28, 38, 0.58);

    --cbr-font: 'Figtree', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --cbr-star: #E0A800;
    --cbr-enriched: var(--link);
    --cbr-admin: var(--accent);
    --cbr-dup: #6f42c1;
    --cbr-orphan: #d63384;
    --gutter: clamp(1rem, 3vw, 2.5rem);

    --bs-body-font-family: var(--cbr-font);
    --bs-body-font-size: 0.95rem;
    --bs-body-line-height: 1.45;
    --bs-primary: var(--accent);
    --bs-primary-rgb: 209, 0, 111;
    --bs-focus-ring-color: rgba(0, 119, 168, .5);
    --bs-border-radius: 8px;
    --bs-border-radius-sm: 6px;
    --bs-border-radius-lg: 10px;
}

/* Light pages only: the reader keeps Bootstrap's dark colours. */
:root:not([data-bs-theme="dark"]) {
    --bs-body-bg: var(--paper);
    --bs-body-color: var(--ink);
    --bs-emphasis-color: var(--ink);
    --bs-secondary-color: var(--muted);
    --bs-border-color: var(--rule);
    --bs-link-color: var(--link);
    --bs-link-color-rgb: 0, 119, 168;
    --bs-link-hover-color: #005a80;
    --bs-link-hover-color-rgb: 0, 90, 128;
    --bs-primary-text-emphasis: var(--accent-dark);
    --bs-primary-bg-subtle: #fbe3ef;
    --bs-primary-border-subtle: #f0a6cb;
}

body { background: var(--bs-body-bg); }

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 800; letter-spacing: -0.01em; }

:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }

.skip-link {
    position: absolute;
    z-index: 2000;
    top: .5rem;
    left: .5rem;
    padding: .5rem 1rem;
    background: var(--panel);
    border: 2px solid var(--line);
    border-radius: 8px;
}
main:focus { outline: none; }

/* ---------- Bootstrap, re-skinned ---------- */

.btn {
    --bs-btn-font-weight: 700;
    --bs-btn-border-width: 2px;
    --bs-btn-border-radius: 8px;
    --bs-btn-padding-x: 1rem;
    --bs-btn-padding-y: .5rem;
    --bs-btn-font-size: .95rem;
    --bs-btn-line-height: 1.1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4em;
}
.btn-sm { --bs-btn-padding-x: .7rem; --bs-btn-padding-y: .3rem; --bs-btn-font-size: .85rem; --bs-btn-border-radius: 6px; }
.btn-lg { --bs-btn-padding-x: 1.3rem; --bs-btn-padding-y: .65rem; --bs-btn-font-size: 1.05rem; }
.btn:active { transform: translateY(1px); }
.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-color: var(--accent-ink);
    --bs-btn-hover-bg: var(--accent-dark);
    --bs-btn-hover-border-color: var(--accent-dark);
    --bs-btn-hover-color: var(--accent-ink);
    --bs-btn-active-bg: var(--accent-dark);
    --bs-btn-active-border-color: var(--accent-dark);
    --bs-btn-disabled-bg: var(--accent);
    --bs-btn-disabled-border-color: var(--accent);
}
.btn-outline-primary {
    --bs-btn-color: var(--accent-dark);
    --bs-btn-bg: var(--panel);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-color: var(--accent-ink);
    --bs-btn-hover-bg: var(--accent);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-active-color: var(--accent-ink);
    --bs-btn-active-bg: var(--accent-dark);
    --bs-btn-active-border-color: var(--accent-dark);
}
/* Dark and secondary buttons are the ink-outlined panel button. */
:root:not([data-bs-theme="dark"]) :is(.btn-outline-dark, .btn-outline-secondary, .btn-secondary) {
    --bs-btn-color: var(--ink);
    --bs-btn-bg: var(--panel);
    --bs-btn-border-color: var(--line);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-bg: var(--paper);
    --bs-btn-hover-border-color: var(--line);
    --bs-btn-active-color: var(--ink);
    --bs-btn-active-bg: var(--highlight);
    --bs-btn-active-border-color: var(--line);
    --bs-btn-disabled-color: var(--muted);
    --bs-btn-disabled-bg: var(--panel);
    --bs-btn-disabled-border-color: var(--rule);
}
.btn-outline-danger { --bs-btn-bg: var(--panel); }

.pagination {
    --bs-pagination-color: var(--ink);
    --bs-pagination-bg: var(--panel);
    --bs-pagination-border-color: var(--rule);
    --bs-pagination-hover-color: var(--ink);
    --bs-pagination-hover-bg: var(--panel);
    --bs-pagination-hover-border-color: var(--line);
    --bs-pagination-focus-color: var(--ink);
    --bs-pagination-focus-bg: var(--panel);
    --bs-pagination-active-color: var(--accent-ink);
    --bs-pagination-active-bg: var(--accent);
    --bs-pagination-active-border-color: var(--accent);
    --bs-pagination-disabled-bg: transparent;
    --bs-pagination-disabled-border-color: transparent;
    gap: .35rem;
    margin: 1.2rem 0 1.6rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.pagination .page-link { min-width: 2.3rem; text-align: center; border-radius: 6px !important; }

.card {
    --bs-card-bg: var(--panel);
    --bs-card-border-color: var(--rule);
    --bs-card-border-radius: 10px;
    --bs-card-inner-border-radius: 9px;
    --bs-card-cap-bg: var(--panel);
    box-shadow: var(--shadow-sm);
}
.card-header { font-weight: 700; }
a.card:hover { border-color: var(--line); }

.form-control, .form-select { border-color: var(--rule); }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--link);
    box-shadow: 0 0 0 .2rem rgba(0, 119, 168, .25);
}
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-label { font-weight: 600; }

.nav-tabs {
    --bs-nav-tabs-border-width: 2px;
    --bs-nav-tabs-border-color: var(--line);
    --bs-nav-tabs-link-active-bg: var(--highlight);
    --bs-nav-tabs-link-active-color: var(--ink);
    --bs-nav-tabs-link-active-border-color: var(--line) var(--line) var(--highlight);
    --bs-nav-tabs-link-hover-border-color: transparent;
    --bs-nav-link-color: var(--ink);
    --bs-nav-link-hover-color: var(--ink);
    --bs-nav-link-font-weight: 600;
}
.nav-tabs .nav-link:hover { background: var(--paper); }
.nav-tabs .nav-link.active { font-weight: 800; }
.card-header-tabs { --bs-nav-tabs-border-width: 0; }
.card-header-tabs .nav-link.active { border: 2px solid var(--line); border-bottom: 0; }

.nav-underline {
    --bs-nav-link-color: var(--muted);
    --bs-nav-link-hover-color: var(--ink);
    --bs-nav-underline-link-active-color: var(--ink);
    --bs-nav-underline-border-width: 3px;
    --bs-nav-link-font-weight: 600;
}
.nav-underline .nav-link.active { border-bottom-color: var(--accent); font-weight: 800; }

.table { --bs-table-bg: var(--panel); --bs-table-border-color: var(--rule); }
.table > thead th { font-weight: 700; }

.list-group { --bs-list-group-border-color: var(--rule); --bs-list-group-active-bg: var(--accent); --bs-list-group-active-border-color: var(--accent); }

.alert { --bs-alert-border-radius: 8px; }

.modal { --bs-modal-border-color: var(--line); --bs-modal-border-width: 2px; --bs-modal-border-radius: 10px; --bs-modal-box-shadow: var(--shadow-pop); }

.breadcrumb { --bs-breadcrumb-margin-bottom: .6rem; font-weight: 600; }

.progress { --bs-progress-bar-bg: var(--accent); --bs-progress-bg: #dde3e9; }
.badge { font-weight: 700; }

.toast-container { z-index: 1090; }
.toast { border-radius: 8px; box-shadow: var(--shadow); }

/* ---------- Masthead ---------- */

.masthead {
    padding: 1.1rem var(--gutter) 0;
    background: var(--panel);
    border-bottom: 2px solid var(--line);
}

.masthead-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 2rem;
}

.wordmark {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    color: var(--ink);
    text-decoration: none;
    line-height: 1;
}
.wordmark:hover { color: var(--ink); }
.wordmark-small {
    margin-bottom: 0.2rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
}
.wordmark-big {
    font-size: clamp(1.45rem, 3vw, 2rem);
    font-weight: 900;
    font-style: italic;
    letter-spacing: -0.02em;
}

.search {
    flex: 1 1 26rem;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-width: 0;
}

/* Speech balloon with a tail pointing back at the wordmark */
.balloon {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    background: var(--panel);
    border: 2px solid var(--line);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
}
.balloon::before,
.balloon::after {
    content: "";
    position: absolute;
    left: 1.6rem;
    width: 0;
    height: 0;
    border-style: solid;
}
.balloon::before {         /* outline of the tail */
    bottom: -15px;
    border-width: 15px 14px 0 0;
    border-color: var(--line) transparent transparent transparent;
}
.balloon::after {          /* fill of the tail */
    bottom: -10px;
    left: calc(1.6rem + 2px);
    border-width: 10px 9.5px 0 0;
    border-color: var(--panel) transparent transparent transparent;
}
.balloon input {
    width: 100%;
    padding: 0.6rem 1.2rem;
    font: 400 1rem var(--cbr-font);
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 999px;
}
.balloon input::placeholder { color: var(--muted); }
.balloon input:focus { outline: none; }
.balloon:focus-within { outline: 3px solid var(--link); outline-offset: 2px; }

.tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.25rem 0.3rem;
    margin-top: 1.1rem;
}
.tabs a,
.tabs-user {
    padding: 0.45rem 0.85rem 0.4rem;
    font-weight: 600;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
    border: 2px solid transparent;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
}
.tabs a:hover { color: var(--ink); background: var(--paper); }
.tabs a[aria-current="page"] {
    background: var(--highlight);
    border-color: var(--line);
    font-weight: 800;
}
.tabs .bi-shield-fill { color: var(--accent); }
.tabs-user { margin-left: auto; color: var(--muted); font-weight: 400; }

/* ---------- Page body ---------- */

.page {
    max-width: 1440px;
    margin-inline: auto;
    padding: 1.2rem var(--gutter) 3rem;
}

.page-title {
    margin: 0 0 .6rem;
    font-size: clamp(1.5rem, 2.6vw, 2rem);
    font-weight: 800;
    line-height: 1.15;
}
.page-title .bi { font-size: .85em; }
.page-blurb { margin: 0; color: var(--muted); }
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: .8rem 1.5rem;
    margin-bottom: 1.4rem;
}
.page-head-center { flex-direction: column; align-items: center; text-align: center; }
.error-status { margin: 0; font-size: clamp(4rem, 12vw, 7rem); font-weight: 900; font-style: italic; line-height: 1; color: var(--accent); }

.section-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .3rem .8rem;
    margin: 2.5rem 0 1.1rem;
    padding-bottom: .4rem;
    font-size: 1.35rem;
    border-bottom: 2px solid var(--line);
    scroll-margin-top: 1rem;
}
.section-title small { font-size: .85rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.section-title-center { justify-content: center; border-bottom: 0; color: var(--muted); font-size: 1.1rem; }
.back-to-top { margin-left: auto; font-size: 1rem; color: var(--muted); }

.result-count { margin: .4rem 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.empty-state .bi { font-size: 2.5rem; }

/* ---------- Toolbar and chips ---------- */

.toolbar-wrap {
    position: sticky;
    top: 0;
    z-index: 20;
    margin-top: -.5rem;
    padding: .7rem 0 .5rem;
    pointer-events: none;
}
.toolbar {
    pointer-events: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1.5rem;
    padding: 0.5rem 0.8rem;
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}
.toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
}
.toolbar-end { margin-left: auto; }
.toolbar-label { margin-right: 0.2rem; font-weight: 700; color: var(--muted); }

.chip-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3em;
    padding: 0.2rem 0.7rem;
    font-weight: 500;
    color: var(--ink);
    text-decoration: none;
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: 999px;
}
.chip:hover { color: var(--ink); border-color: var(--line); }
.chip.is-active { background: var(--highlight); border-color: var(--line); font-weight: 700; }
.chip .bi-x-lg, .chip .bi-caret-down-fill, .chip .bi-caret-up-fill { font-size: 0.75em; }
.chip-count { font-size: .8em; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }

.segmented .btn {
    --bs-btn-padding-x: .7rem;
    --bs-btn-padding-y: .2rem;
    --bs-btn-border-width: 1px;
    --bs-btn-color: var(--ink);
    --bs-btn-bg: var(--panel);
    --bs-btn-border-color: var(--line);
    --bs-btn-hover-color: var(--ink);
    --bs-btn-hover-bg: var(--paper);
    --bs-btn-hover-border-color: var(--line);
    --bs-btn-active-bg: var(--highlight);
    --bs-btn-active-border-color: var(--line);
    --bs-btn-active-color: var(--ink);
    --bs-btn-font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.segmented .btn.active { font-weight: 800; }

/* ---------- Cover grid ---------- */

.cover-grid {
    position: relative;         /* offset parent for peek.js's dock layout */
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 1.8rem 1.5rem;
    /* Covers top out at about 254px wide (380px tall). */
    max-width: calc(5 * 254px + 4 * 1.5rem);
    margin-inline: auto;
}
.cover-grid.is-dense {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.4rem 1.1rem;
    max-width: none;
}

.comic {
    position: relative;
    min-width: 0;
    transition: transform 0.275s cubic-bezier(0.2, 0.8, 0.3, 1);
}
/* Row neighbours of the zoomed cover are shrunk and shifted by peek.js.
   The zoomed card sits above other cards but below the sticky toolbar. */
.comic.is-peeking { z-index: 15; }

.cover {
    display: block;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: var(--cover-bg);
    /* 1px on screen even when the card is shrunk; peek.js sets --scale */
    border: calc(1px / var(--scale, 1)) solid var(--line);
    border-radius: 3px;
    box-shadow: var(--shadow);
}
.cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
}
.cover-missing {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: var(--muted);
    background: #e4e9ee;
    border-style: dashed;
    box-shadow: none;
}

.comic-name {
    margin: 0.6rem 0 0;
    overflow: hidden;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    text-overflow: ellipsis;
}
/* Bookmark and stars under the name, for screens without hover (desktops
   get them in the preview). */
.comic-actions { display: none; align-items: center; gap: .5rem; margin-top: .3rem; }
.comic-extra {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .25rem;
    margin-top: .35rem;
    font-size: .8rem;
    color: var(--muted);
}
.comic-extra .progress { align-self: stretch; }
.next-issue { width: min(220px, 60%); margin: 0 auto 1rem; }

/* "Where to buy" on the end-of-comic page and in the cover preview (services/buying.py). */
.buy-card {
    max-width: 34rem;
    margin: 0 auto 2rem;
    padding: 1rem 1.25rem;
    text-align: center;
    background: var(--bs-body-bg);
    border: 2px solid var(--bs-body-color);
    border-radius: var(--bs-border-radius-lg);
}
.buy-title { font-size: 1.1rem; font-weight: 800; margin: 0 0 .25rem; }
.buy-blurb { color: var(--muted); margin: 0 0 .75rem; }
.buy-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.peek-buy { font-size: .82rem; margin: .5rem 0 0; padding: 0; list-style: none; }
.peek-buy li { display: flex; align-items: baseline; gap: .4rem; }
.peek-buy li + li { margin-top: .15rem; }

/* ---------- Cover preview (peek.js) ---------- */

.peek {
    /* Size and offset are set by peek.js to fit the row. */
    --cover-w: 300px;
    --info-w: 300px;
    --peek-h: calc(var(--cover-w) * 1.5);
    position: absolute;
    z-index: 30;
    left: 0;
    top: 0;
    display: grid;
    grid-template-columns: var(--cover-w) var(--info-w);
    background: var(--panel);
    border: 2px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-pop);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.6);
    transition: opacity 0.175s ease, transform 0.275s cubic-bezier(0.2, 0.8, 0.3, 1), visibility 0s linear 0.275s;
}
.peek.cover-only { grid-template-columns: var(--cover-w); }
.peek.cover-only .peek-info { display: none; }
.comic.is-peeking .peek {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: scale(1);
    transition: opacity 0.175s ease, transform 0.275s cubic-bezier(0.2, 0.8, 0.3, 1), visibility 0s;
}
.comic.is-peeking > .cover,
.comic.is-peeking > .comic-name { visibility: hidden; }

.peek-cover {
    position: relative;
    height: var(--peek-h);
    overflow: hidden;
    background: var(--cover-bg);
    border-radius: 6px 0 0 6px;
}
.peek.cover-only .peek-cover { border-radius: 6px; }
.peek-cover a { display: block; height: 100%; }
.peek-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    transition: opacity .15s;
}
.peek-cover img.is-page { object-fit: contain; object-position: center; background: var(--ink); }
.peek.is-flipping .peek-cover img { opacity: .55; }

/* Page arrows along the bottom of the cover */
.peek-flip {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.6rem .6rem .6rem;
    color: #fff;
    background: linear-gradient(rgba(20, 28, 38, 0), rgba(20, 28, 38, .72));
    pointer-events: none;
}
.peek-flip .btn-icon {
    justify-content: center;
    width: 2.3rem;
    height: 2.3rem;
    font-size: 1.15rem;
    color: var(--ink);
    background: var(--panel);
    border: 2px solid var(--line);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    pointer-events: auto;
}
.peek-flip .btn-icon:hover { color: var(--accent); }
.peek-flip .btn-icon[aria-disabled="true"] { opacity: .35; cursor: default; }
.peek-page { font-size: .8rem; font-weight: 700; text-shadow: 0 1px 3px rgba(0, 0, 0, .7); font-variant-numeric: tabular-nums; }

.peek-info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    height: var(--peek-h);
    padding: 1rem 1rem 0.8rem;
    font-size: 0.85rem;
    line-height: 1.35;
}
.peek-info > * { flex-shrink: 0; margin: 0; }
.peek-title {
    display: -webkit-box;
    overflow: hidden;
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.2;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}
.peek-meta, .peek-subtitle, .peek-status, .peek-empty, .peek-stats { color: var(--muted); }
.peek-subtitle { font-style: italic; }
.peek-flag {
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
    background: #FFF6CC;
    border-left: 3px solid #E0A800;
}

/* ComicVine details: whatever doesn't fit scrolls. */
.peek-more {
    flex: 1 1 auto !important;
    min-height: 0;
    margin: .25rem -.4rem 0 0 !important;
    padding: .55rem .4rem 0 0;
    overflow-y: auto;
    border-top: 1px solid var(--rule);
    overscroll-behavior: contain;
}
.peek-facts {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 0.6rem;
    margin: 0;
}
.peek-facts dt { font-weight: 700; }
.peek-facts dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.peek-desc { margin-top: .5rem; }
.peek-desc p { margin: 0 0 .5rem; }
.peek-source { font-size: .78rem; color: var(--muted); }
.peek-source a { color: inherit; }
.peek-stats, .peek-empty { margin: .5rem 0 0; }

.peek-info .star-rating { margin-top: .35rem; }
.peek-info .star-rating .star { font-size: 1.05rem; }

.peek-actions { display: flex; gap: 0.45rem; padding-top: 0.4rem; }
.peek-actions .btn { flex: 1; --bs-btn-padding-x: .6rem; }

.peek-icons {
    position: relative;         /* captions (data-tip) span the row */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.8rem;
    padding-top: 0.5rem;
    font-size: 1.1rem;
}
.peek-icons .btn-icon { font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.peek-icons .btn-icon:hover { color: var(--accent); }
.peek-icons .enriched-badge { font-size: 1.1rem; color: var(--cbr-enriched); }
.peek-icons .peek-file { color: var(--muted); cursor: help; }
.peek-icons .delete-comic { margin-left: auto; }
.peek-icons [data-tip]:is(:hover, :focus-visible)::after {
    content: attr(data-tip);
    position: absolute;
    z-index: 2;
    left: 0;
    right: 0;
    bottom: calc(100% + .35rem);
    padding: .35rem .55rem;
    font: 600 .78rem/1.3 var(--cbr-font);
    color: #fff;
    text-align: left;
    overflow-wrap: anywhere;
    background: var(--ink);
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
    pointer-events: none;
}

/* Touch screens: the same preview in a bottom sheet. The info panel's
   pieces sit beside the cover; the ComicVine details run full width below. */
.peek-sheet {
    --bs-offcanvas-height: auto;
    --bs-offcanvas-bg: var(--panel);
    max-width: 760px;
    max-height: 88vh;
    margin-inline: auto;
    border: 2px solid var(--line) !important;
    border-bottom: 0 !important;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 40px rgba(20, 28, 38, .3);
}
.peek-sheet-handle { width: 2.6rem; height: 4px; margin: .5rem auto 0; background: var(--rule); border-radius: 2px; }
.peek-sheet-close { position: absolute; top: .6rem; right: .7rem; z-index: 1; }
.peek-sheet-body {
    display: grid;
    grid-template-columns: minmax(120px, min(40%, 240px)) minmax(0, 1fr);
    grid-template-rows: repeat(7, auto) 1fr;
    align-items: start;
    gap: .3rem 1rem;
    padding: .8rem 1rem 1.5rem;
    overscroll-behavior: contain;
}
.peek-sheet .peek-cover {
    --peek-h: auto;
    grid-column: 1;
    grid-row: 1 / 9;
    aspect-ratio: 2 / 3;
    border: 1px solid var(--line);
    border-radius: 4px;
    box-shadow: var(--shadow);
    touch-action: pan-y;
}
.peek-sheet .peek-flip { padding: 1.2rem .35rem .35rem; }
.peek-sheet .peek-flip .btn-icon { width: 2rem; height: 2rem; font-size: 1rem; }
.peek-sheet .peek-info { display: contents; }
.peek-sheet .peek-info > * { grid-column: 2; margin: 0; }
.peek-sheet .peek-title { padding-right: 2rem; font-size: 1.1rem; -webkit-line-clamp: 4; }
.peek-sheet .peek-actions { flex-wrap: wrap; }
.peek-sheet .peek-icons { gap: 1.1rem; font-size: 1.25rem; }
.peek-sheet .peek-icons .btn-icon { font-size: 1.25rem; }
.peek-sheet .peek-more {
    order: 1;                   /* after everything beside the cover */
    grid-column: 1 / -1;
    margin: .8rem 0 0 !important;
    padding: .7rem 0 0;
    overflow: visible;
    font-size: .9rem;
}
/* No hover for captions; tapping the file icon shows the path in a toast. */
.peek-sheet .peek-icons [data-tip]:is(:hover, :focus-visible)::after { content: none; }
.comic-actions .peek-open { font-size: 1.05rem; }

/* ---------- Icon buttons, stars, badges ---------- */

.btn-icon {
    display: inline-flex;
    align-items: center;
    padding: 0 .15rem;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    vertical-align: middle;
    background: none;
    border: 0;
    border-radius: .25rem;
    cursor: pointer;
}
.btn-icon:hover { color: var(--accent); }
.btn-icon:disabled, .btn-icon[aria-busy="true"] { opacity: .5; cursor: progress; }
.bookmark-toggle[aria-pressed="true"] { color: var(--accent); }
.delete-comic:hover { color: var(--bs-danger) !important; }
.flag-btn { color: var(--muted); }
.flag-btn[aria-pressed="true"], .flag-btn:hover { color: var(--bs-danger); }
.text-admin { color: var(--cbr-admin); }

.star-rating { display: inline-flex; align-items: center; line-height: 1; }
.star-rating .star {
    padding: 0 .05rem;
    color: var(--cbr-star);
    font-size: .95rem;
    background: none;
    border: 0;
    cursor: pointer;
    transition: transform .1s;
}
.star-rating .star:hover { transform: scale(1.2); }
.star-rating .star:focus-visible { outline: 2px solid var(--link); border-radius: 2px; }
/* Filled from the average, not your own rating: lighter. */
.star-rating .star.bi-star-fill:not(.is-mine) { opacity: .55; }
.star-rating-lg .star { font-size: 1.25rem; }
.star-rating.rating-loading { opacity: .5; pointer-events: none; }
.rating-count { margin-left: .3rem; font-size: .75rem; color: var(--muted); }

/* Horizontal strips of small covers (playlist previews, variant covers) */
.cover-strip { display: flex; gap: .5rem; overflow-x: auto; padding: .1rem .1rem .5rem; }
.cover-strip img { flex-shrink: 0; width: auto; height: 140px; border: 1px solid var(--line); border-radius: 3px; box-shadow: var(--shadow-sm); }
.cover-strip-more {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    height: 140px;
    padding: 0 1rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    border: 1px dashed var(--rule);
    border-radius: 8px;
}

/* ---------- Shared bits ---------- */

.file-path { color: var(--muted); word-break: break-all; }
.scroll-list { max-height: 16rem; overflow-y: auto; }
.pre-wrap { white-space: pre-wrap; }
.input-narrow { width: 6rem; }
.log-box {
    max-height: 16rem;
    overflow-y: auto;
    padding: .5rem;
    font-family: var(--bs-font-monospace);
    font-size: .78em;
    white-space: pre-wrap;
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: 8px;
}
.progress-tall { height: 1.5rem; }
.progress-mini { height: 6px; min-width: 60px; }
.text-dup { color: var(--cbr-dup); }
.text-orphan { color: var(--cbr-orphan); }
.series-group { scroll-margin-top: 4.5rem; }

/* ---------- What's new and Send a report ---------- */

.narrow-page { max-width: 44rem; }
.changelog li { margin-bottom: .45rem; }
.btn-check:checked + .chip { background: var(--highlight); border-color: var(--line); font-weight: 700; }
.btn-check:focus-visible + .chip { outline: 3px solid var(--link); outline-offset: 2px; }
.report-missing { display: none; }
.report-form:has(#kind-missing:checked) .report-missing { display: flex; }
.tabs .badge { font-size: .7em; vertical-align: .15em; }

/* ---------- Image (cover) page ---------- */

.cover-zoom { padding: 0; background: none; border: 0; cursor: zoom-in; }
.cover-zoom img { max-height: 78vh; border: 1px solid var(--line); box-shadow: var(--shadow-pop); }
.cover-zoom[aria-pressed="true"] { cursor: zoom-out; }
.cover-zoom[aria-pressed="true"] img { max-height: none; }

/* ---------- Story arcs and playlists ---------- */

.arc-thumb { flex-shrink: 0; width: 55px; height: 80px; object-fit: cover; border: 1px solid var(--line); border-radius: 3px; }
.arc-thumb-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--muted);
    background: var(--cover-bg);
}
.arc-cover { max-width: 160px; border: 1px solid var(--line); border-radius: 3px; box-shadow: var(--shadow); }
.arc-description img { max-width: 100%; }
/* Playlist reorder list (?arrange=1) */
.arrange-bar { position: sticky; top: .5rem; z-index: 20; }
.arrange-list { display: flex; flex-direction: column; gap: .4rem; max-width: 52rem; }
.arrange-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .4rem .6rem;
    background: var(--panel);
    border: 1px solid var(--rule);
    border-radius: 8px;
    transition: opacity .3s;
}
.arrange-item img { flex-shrink: 0; width: 40px; height: 60px; object-fit: cover; border: 1px solid var(--line); border-radius: 2px; }
.arrange-item.is-dragging { opacity: .4; border-style: dashed; }
.arrange-item.is-removed { opacity: 0; }
.arrange-handle { font-size: 1.2rem; color: var(--muted); cursor: grab; }
.arrange-num { min-width: 2ch; font-weight: 700; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.arrange-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.arrange-name small { display: block; font-weight: 400; color: var(--muted); }
.arrange-buttons { display: flex; flex-shrink: 0; gap: .3rem; }
@media (max-width: 640px) {
    .arrange-item { flex-wrap: wrap; }
    .arrange-handle { display: none; }   /* no drag and drop on touch: use the arrows */
    .arrange-buttons { width: 100%; justify-content: flex-end; }
}
.search-results { max-height: 300px; overflow-y: auto; }
.search-results img { flex-shrink: 0; width: 32px; height: 46px; object-fit: cover; border-radius: 2px; }

/* ---------- Admin ---------- */

.admin-nav { border-bottom: 2px solid var(--line); }
.admin-nav .nav-link { padding-bottom: .6rem; }
.admin-tool { transition: border-color .15s; }
.admin-tool:hover { border-color: var(--line); }
.admin-tool-icon { font-size: 2rem; color: var(--cbr-admin); }

.file-table td { font-size: .85rem; vertical-align: top; }
/* Keep absolutely positioned bits (visually-hidden labels) inside the scroller,
   or they widen the page on phones. */
.table-responsive { position: relative; }

.action-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
    padding: .6rem 1rem;
    color: #fff;
    background: var(--ink);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.dupe-table .col-keep { width: 50px; }
.dupe-table .col-thumb { width: 100px; }
.dupe-table .col-action { width: 100px; }
.dupe-table .thumb-cell img { width: 90px; height: 130px; object-fit: cover; border: 1px solid var(--line); border-radius: 3px; }
.dupe-table tr.row-keeper > td { background-color: var(--bs-success-bg-subtle); }
.dupe-table tr.row-pending > td { background-color: var(--bs-danger-bg-subtle); }
.dupe-table tr.cluster-head > td {
    padding: .25rem .6rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--muted);
    background-color: var(--paper);
    border-top: 2px solid var(--rule);
}
.dupe-group.is-dismissed { opacity: .25; pointer-events: none; transition: opacity .5s; }
.missing-list { font-family: var(--bs-font-monospace); font-size: .85em; line-height: 1.5; }

/* ---------- Sign-in pages ---------- */

.auth-page { min-height: 100vh; background: var(--paper); }
.auth-covers {
    position: fixed;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 1fr);
    opacity: .3;
    filter: saturate(.75);
}
.auth-covers img { width: 100%; height: 100%; object-fit: cover; }
.auth-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    border: 2px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow-pop);
}
.auth-kicker { font-size: .9rem; font-weight: 500; color: var(--muted); }
.auth-title { margin-bottom: .25rem; font-size: 2rem; font-weight: 900; font-style: italic; letter-spacing: -.02em; }
.auth-links a { white-space: nowrap; }

/* ---------- Loading indicators (core.js) ---------- */

#cbr-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(20, 28, 38, .55);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility 0s linear .2s;
}
#cbr-loading-overlay.show { opacity: 1; visibility: visible; transition: opacity .2s ease, visibility 0s; }
#cbr-loading-fetch {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 2147483001;
    display: none;
    padding: 8px;
    line-height: 0;
    background: rgba(20, 28, 38, .75);
    border-radius: 50%;
}
#cbr-loading-fetch.show { display: block; }
.cbr-spinner {
    width: 3rem;
    height: 3rem;
    border: .3rem solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cbr-spin .8s linear infinite;
}
#cbr-loading-fetch .cbr-spinner { width: 1.25rem; height: 1.25rem; border-width: .18rem; }
.cbr-loading-msg {
    margin-top: 1rem;
    padding: 0 1rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
@keyframes cbr-spin { to { transform: rotate(360deg); } }

/* ---------- Responsive, touch, motion ---------- */

@media (max-width: 900px) {
    .cover-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1.4rem 1rem; }
}

@media (hover: none), (max-width: 640px) {
    .peek { display: none; }
    .comic-actions { display: flex; }
}

@media (max-width: 640px) {
    .cover-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    .search { flex-wrap: wrap; }
    .balloon { flex-basis: 100%; }
    /* One scrolling row of tabs rather than three wrapped ones. */
    .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
    .tabs-user { margin-left: 0; }
    .toolbar-wrap { position: static; }
    .toolbar-end { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .comic,
    .peek,
    .comic.is-peeking .peek,
    .peek-cover img,
    .btn,
    .star-rating .star,
    .admin-tool,
    #cbr-loading-overlay { transition: none; }
    .peek,
    .comic.is-peeking .peek { transform: none; }
    .cbr-spinner { animation-duration: 2s; }
}
