/* ==========================================================================
   AudiobookBangla — new public site design tokens & components
   Preview: /?preview=new   |  Enable for everyone: setting frontend_variant=new
   ========================================================================== */

:root {
    --site-brand: #f97316;
    --site-brand-strong: #ea580c;
    --site-brand-soft: rgba(249, 115, 22, 0.12);
    --site-brand-ink: #201305;

    --site-bg: #f8f8f7;
    --site-surface: #ffffff;
    --site-surface-2: #f2f2f0;
    --site-text: #17181a;
    --site-muted: #6b7280;
    --site-border: #e6e6e3;

    --site-radius-sm: 10px;
    --site-radius: 16px;
    --site-radius-lg: 24px;

    --site-shadow-sm: 0 1px 2px rgba(16, 18, 22, 0.06);
    --site-shadow: 0 10px 30px -18px rgba(16, 18, 22, 0.35);

    --site-max: 1240px;
    --site-font: "Hind Siliguri", "Noto Sans Bengali", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --site-bg: #0f1113;
        --site-surface: #17191c;
        --site-surface-2: #1f2226;
        --site-text: #f2f3f5;
        --site-muted: #9aa1ab;
        --site-border: #2a2e33;
        --site-shadow: 0 12px 34px -20px rgba(0, 0, 0, 0.8);
    }
}

[data-theme="dark"] {
    --site-bg: #0f1113;
    --site-surface: #17191c;
    --site-surface-2: #1f2226;
    --site-text: #f2f3f5;
    --site-muted: #9aa1ab;
    --site-border: #2a2e33;
}

[data-theme="light"] {
    --site-bg: #f8f8f7;
    --site-surface: #ffffff;
    --site-surface-2: #f2f2f0;
    --site-text: #17181a;
    --site-muted: #6b7280;
    --site-border: #e6e6e3;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body.site {
    margin: 0;
    background: var(--site-bg);
    color: var(--site-text);
    font-family: var(--site-font);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.site a { color: inherit; text-decoration: none; }
.site img { max-width: 100%; display: block; }

.site-container {
    width: 100%;
    max-width: var(--site-max);
    margin: 0 auto;
    padding: 0 20px;
}

/* ---------- header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: color-mix(in srgb, var(--site-bg) 88%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--site-border);
}

.site-header__inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 68px;
}

.site-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.site-logo img { height: 34px; width: auto; }
.site-logo span { color: var(--site-muted); font-weight: 500; font-size: 13px; }

.site-nav { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.site-nav a {
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 15px;
    color: var(--site-muted);
    transition: background .15s ease, color .15s ease;
}
.site-nav a:hover, .site-nav a.is-active { color: var(--site-text); background: var(--site-surface-2); }

.site-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.site-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--site-surface);
    border: 1px solid var(--site-border);
    border-radius: 999px;
    padding: 7px 14px;
    min-width: 220px;
}
.site-search input {
    border: 0; outline: 0; background: transparent; color: var(--site-text);
    font-family: inherit; font-size: 14px; width: 100%;
}

.site-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--site-border);
    background: var(--site-surface);
    color: var(--site-text);
    padding: 9px 16px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.site-btn:hover { transform: translateY(-1px); }
.site-btn--brand { background: var(--site-brand); border-color: var(--site-brand); color: var(--site-brand-ink); font-weight: 700; }
.site-btn--brand:hover { background: var(--site-brand-strong); border-color: var(--site-brand-strong); }
.site-btn--ghost { background: transparent; }

.site-icon-btn {
    width: 38px; height: 38px; border-radius: 999px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--site-border); background: var(--site-surface);
    cursor: pointer; color: var(--site-text);
}

/* ---------- main ---------- */
.site-main { padding: 28px 0 64px; }

.site-section { margin-top: 44px; }
.site-section:first-child { margin-top: 0; }

.site-section__head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; margin-bottom: 16px;
}
.site-section__title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.site-section__subtitle { margin: 4px 0 0; color: var(--site-muted); font-size: 14px; }
.site-section__link { color: var(--site-brand); font-weight: 600; font-size: 14px; white-space: nowrap; }

/* ---------- channel hero ---------- */
.site-hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--site-radius-lg);
    border: 1px solid var(--site-border);
    background:
        radial-gradient(1200px 420px at 12% -10%, rgba(249, 115, 22, 0.22), transparent 60%),
        radial-gradient(900px 380px at 92% 0%, rgba(56, 132, 255, 0.16), transparent 55%),
        var(--site-surface);
    padding: 34px;
    box-shadow: var(--site-shadow);
}
.site-hero__body { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.site-hero__avatar {
    width: 96px; height: 96px; border-radius: 999px; object-fit: cover;
    border: 3px solid var(--site-surface); box-shadow: var(--site-shadow-sm);
}
.site-hero__name { margin: 0; font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; }
.site-hero__desc { margin: 8px 0 0; color: var(--site-muted); max-width: 640px; font-size: 14.5px; }
.site-hero__stats { display: flex; gap: 22px; margin-top: 14px; flex-wrap: wrap; }
.site-hero__stat strong { display: block; font-size: 17px; }
.site-hero__stat span { color: var(--site-muted); font-size: 13px; }
.site-hero__cta { margin-left: auto; display: flex; gap: 10px; }

/* ---------- grids ---------- */
.site-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.site-grid--wide { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

/* ---------- video card ---------- */
.video-card {
    background: var(--site-surface);
    border: 1px solid var(--site-border);
    border-radius: var(--site-radius);
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.video-card:hover { transform: translateY(-3px); box-shadow: var(--site-shadow); border-color: color-mix(in srgb, var(--site-brand) 35%, var(--site-border)); }
.video-card__thumb { position: relative; aspect-ratio: 16 / 9; background: var(--site-surface-2); }
.video-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.video-card__badge {
    position: absolute; right: 8px; bottom: 8px;
    background: rgba(0, 0, 0, .78); color: #fff;
    font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px;
}
.video-card__body { padding: 12px 14px 15px; }
.video-card__title {
    margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.video-card__meta { color: var(--site-muted); font-size: 12.5px; margin-top: 8px; display: flex; gap: 10px; }

/* ---------- horizontal rail ---------- */
.site-rail { position: relative; }
.site-rail__track {
    display: flex; gap: 16px; overflow-x: auto; padding-bottom: 6px;
    scroll-snap-type: x mandatory; scrollbar-width: thin;
}
.site-rail__track > * { flex: 0 0 260px; scroll-snap-align: start; }
.site-section__actions { display: flex; align-items: center; gap: 10px; }
.site-rail__nav { display: flex; gap: 6px; }
.site-rail__nav button {
    width: 34px; height: 34px; border-radius: 999px; cursor: pointer;
    border: 1px solid var(--site-border); background: var(--site-surface); color: var(--site-text);
}
.site-rail__nav button:hover { border-color: var(--site-brand); color: var(--site-brand); }

/* SVG chevrons */
.site-chevron-svg { flex: 0 0 auto; vertical-align: middle; }
.site-rail__nav button { display: inline-flex; align-items: center; justify-content: center; }
.site-section__link { display: inline-flex; align-items: center; gap: 4px; }
.site-pagination__btn { display: inline-flex; align-items: center; gap: 6px; }

.site-play-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 8px solid currentColor;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
}

/* ---------- playlist & category cards ---------- */
.playlist-card, .category-card {
    display: block;
    background: var(--site-surface);
    border: 1px solid var(--site-border);
    border-radius: var(--site-radius);
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}
.playlist-card:hover, .category-card:hover { transform: translateY(-3px); box-shadow: var(--site-shadow); }
.playlist-card img, .category-card img { aspect-ratio: 16 / 9; object-fit: cover; width: 100%; }
.playlist-card__body, .category-card__body { padding: 12px 14px 14px; }
.playlist-card__title, .category-card__title { margin: 0; font-size: 14.5px; font-weight: 600; }
.playlist-card__meta { color: var(--site-muted); font-size: 12.5px; margin-top: 4px; }

.category-card { overflow: visible; background: transparent; border: 0; }
.category-card__inner {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    padding: 22px 14px; border-radius: var(--site-radius);
    background: var(--site-surface); border: 1px solid var(--site-border);
    transition: border-color .15s ease, background .15s ease;
}
.category-card:hover .category-card__inner { border-color: var(--site-brand); background: var(--site-brand-soft); }
.category-card__icon {
    width: 54px; height: 54px; border-radius: 16px; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background: var(--site-brand-soft); color: var(--site-brand);
    font-weight: 700; font-size: 20px;
}
.category-card__icon img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- page link cards ---------- */
.page-link-card {
    display: flex; flex-direction: column;
    background: var(--site-surface);
    border: 1px solid var(--site-border);
    border-radius: var(--site-radius);
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.page-link-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--site-shadow);
    border-color: var(--site-brand);
}
.page-link-card__thumb {
    display: flex; align-items: center; justify-content: center;
    background: var(--site-brand-soft);
    color: var(--site-brand);
    font-weight: 700; font-size: 28px;
    aspect-ratio: 16 / 6;
    overflow: hidden;
}
.page-link-card__thumb img { width: 100%; height: 100%; object-fit: cover; }
.page-link-card__initial { text-transform: uppercase; }
.page-link-card__body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.page-link-card__title { margin: 0; font-size: 16px; font-weight: 700; }
.page-link-card__desc { margin: 0; color: var(--site-muted); font-size: 13px; line-height: 1.5; }
.page-link-card .site-section__link { margin-top: 4px; font-size: 13px; }

/* ---------- banner & marquee ---------- */
.site-banners { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.site-banner { border-radius: var(--site-radius); overflow: hidden; border: 1px solid var(--site-border); }
.site-banner img { width: 100%; aspect-ratio: 21 / 9; object-fit: cover; }

.site-marquee {
    display: flex; align-items: center; gap: 12px;
    border: 1px solid var(--site-border); border-radius: 999px;
    background: var(--site-surface); padding: 10px 18px; overflow: hidden;
}
.site-marquee__label {
    background: var(--site-brand); color: var(--site-brand-ink); font-size: 12px; font-weight: 700;
    padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.site-marquee__track { overflow: hidden; flex: 1; }
.site-marquee__text { display: inline-block; white-space: nowrap; animation: site-marquee 26s linear infinite; }
@keyframes site-marquee { from { transform: translateX(100%); } to { transform: translateX(-100%); } }

/* ---------- html section ---------- */
.site-html { background: var(--site-surface); border: 1px solid var(--site-border); border-radius: var(--site-radius); padding: 22px; }

/* ---------- empty ---------- */
.site-empty {
    text-align: center; padding: 56px 20px; color: var(--site-muted);
    border: 1px dashed var(--site-border); border-radius: var(--site-radius);
}

/* ---------- watch page ---------- */
.watch-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 26px;
    align-items: start;
}

.watch-player {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: var(--site-radius);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--site-border);
}

.watch-player iframe,
.watch-player .watch-player__frame,
.watch-player .watch-player__frame > iframe {
    width: 100%; height: 100%; border: 0; display: block;
}

.watch-player__poster {
    position: absolute; inset: 0; padding: 0; border: 0; cursor: pointer;
    background: #000; display: block; width: 100%;
}
.watch-player__poster img { width: 100%; height: 100%; object-fit: cover; opacity: .82; }
.watch-player__play {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.watch-player__play-btn {
    width: 74px; height: 74px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(249, 115, 22, .92);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
    transition: transform .15s ease;
}
.watch-player__play-btn svg { width: 24px; height: 24px; fill: #201305; margin-left: 3px; }
.watch-player__poster:hover .watch-player__play-btn { transform: scale(1.06); }
.watch-player__poster:hover .watch-player__play::after { transform: scale(1.06); }

.watch-title { margin: 18px 0 6px; font-size: 24px; line-height: 1.3; letter-spacing: -0.01em; }
.watch-sub { color: var(--site-muted); font-size: 14px; display: flex; gap: 14px; flex-wrap: wrap; }

.watch-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 4px; }

.watch-desc {
    margin-top: 18px;
    background: var(--site-surface);
    border: 1px solid var(--site-border);
    border-radius: var(--site-radius);
    padding: 16px 18px;
    white-space: pre-line;
    color: var(--site-text);
    font-size: 14.5px;
    line-height: 1.75;
}
.watch-desc__label { font-weight: 700; margin-bottom: 8px; display: block; }
.watch-desc.is-collapsed { max-height: 160px; overflow: hidden; position: relative; }
.watch-desc.is-collapsed::after {
    content: ""; position: absolute; inset: auto 0 0 0; height: 70px;
    background: linear-gradient(to bottom, transparent, var(--site-surface));
}

.watch-sidebar { position: sticky; top: 88px; display: grid; gap: 18px; }
.queue {
    background: var(--site-surface);
    border: 1px solid var(--site-border);
    border-radius: var(--site-radius);
    overflow: hidden;
}
.queue__head { padding: 14px 16px; border-bottom: 1px solid var(--site-border); font-weight: 700; font-size: 15px; }
.queue__list { max-height: 520px; overflow-y: auto; margin: 0; padding: 8px; list-style: none; }
.queue__item { display: flex; gap: 10px; padding: 8px; border-radius: 10px; }
.queue__item:hover { background: var(--site-surface-2); }
.queue__item.is-current { background: var(--site-brand-soft); }
.queue__item.is-current .queue__meta { color: #4b5563; }
.queue__index { width: 22px; color: var(--site-muted); font-size: 13px; text-align: right; flex: 0 0 auto; }
.queue__thumb { width: 84px; aspect-ratio: 16 / 9; border-radius: 8px; object-fit: cover; background: var(--site-surface-2); flex: 0 0 auto; }
.queue__body { min-width: 0; }
.queue__title {
    font-size: 13.5px; font-weight: 600; line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.queue__meta { color: var(--site-muted); font-size: 12px; margin-top: 3px; }

@media (max-width: 1000px) {
    .watch-layout { grid-template-columns: minmax(0, 1fr); }
    .watch-sidebar { position: static; }
}

/* ---------- browse filters ---------- */
.site-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.site-page-title { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.site-page-sub { margin: 6px 0 0; color: var(--site-muted); font-size: 14px; }

.site-filters {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
    background: var(--site-surface); border: 1px solid var(--site-border);
    border-radius: var(--site-radius); padding: 12px; margin-bottom: 22px;
}
.site-filters input[type="search"], .site-filters input[type="text"] {
    flex: 1 1 240px; min-width: 180px;
    border: 1px solid var(--site-border); background: var(--site-bg); color: var(--site-text);
    border-radius: 999px; padding: 9px 16px; font-family: inherit; font-size: 14px; outline: none;
}
.site-filters select {
    border: 1px solid var(--site-border); background: var(--site-bg); color: var(--site-text);
    border-radius: 999px; padding: 9px 14px; font-family: inherit; font-size: 14px;
}

.site-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.site-chip {
    border: 1px solid var(--site-border); background: var(--site-surface); color: var(--site-muted);
    padding: 6px 13px; border-radius: 999px; font-size: 13px; transition: all .15s ease;
}
.site-chip:hover { color: var(--site-text); border-color: var(--site-brand); }
.site-chip.is-active { background: var(--site-brand); border-color: var(--site-brand); color: var(--site-brand-ink); font-weight: 700; }

/* ---------- pagination ---------- */
.site-pagination {
    display: flex; align-items: center; justify-content: center; gap: 16px;
    margin-top: 34px; flex-wrap: wrap; font-size: 14px;
}
.site-pagination__btn {
    border: 1px solid var(--site-border); background: var(--site-surface); color: var(--site-text);
    padding: 9px 16px; border-radius: 999px; font-weight: 600;
}
.site-pagination__btn:hover { border-color: var(--site-brand); color: var(--site-brand); }
.site-pagination__btn.is-disabled { color: var(--site-muted); background: var(--site-surface); cursor: default; }
.site-pagination__info { color: var(--site-muted); }

.playlist-card__cover {
    aspect-ratio: 16 / 9;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(249, 115, 22, .85), rgba(56, 132, 255, .75));
    color: #fff; font-weight: 700; font-size: 26px; letter-spacing: -0.02em;
}

.playlist-hero__cover {
    width: 220px; aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(249, 115, 22, .9), rgba(56, 132, 255, .8));
    color: #fff; font-size: 34px; font-weight: 700;
}
.playlist-hero__cover img { width: 100%; height: 100%; object-fit: cover; }

.site-prose {
    background: var(--site-surface); border: 1px solid var(--site-border);
    border-radius: var(--site-radius); padding: 26px; line-height: 1.95; font-size: 15.5px;
}
.site-prose h1, .site-prose h2, .site-prose h3 { margin-top: 1.3em; line-height: 1.35; }
.site-prose a { color: var(--site-brand); text-decoration: underline; text-underline-offset: 3px; }
.site-prose img { border-radius: 12px; margin: 14px 0; }
.site-prose ul, .site-prose ol { padding-left: 1.4em; }

/* ---------- mobile navigation ---------- */
.site-mobile-toggle { display: none; }
.site-mobile-nav {
    display: none;
    border-top: 1px solid var(--site-border);
    background: var(--site-surface);
}
.site-mobile-nav.is-open { display: block; }
.site-mobile-nav .site-container { display: flex; flex-direction: column; padding-top: 8px; padding-bottom: 14px; }
.site-mobile-nav a {
    padding: 12px 4px; border-bottom: 1px solid var(--site-border);
    font-weight: 600; color: var(--site-text);
}
.site-mobile-nav a:last-child { border-bottom: 0; }

/* ---------- comments ---------- */
.comment-form { display: grid; gap: 10px; margin-bottom: 22px; }
.comment-form textarea {
    width: 100%; border: 1px solid var(--site-border); background: var(--site-surface);
    color: var(--site-text); border-radius: var(--site-radius-sm); padding: 12px 14px;
    font-family: inherit; font-size: 14.5px; resize: vertical;
}
.comment-form textarea:focus { outline: 2px solid var(--site-brand-soft); border-color: var(--site-brand); }
.comment-form .site-btn { justify-self: start; }
.comment-error { color: #dc2626; font-size: 13px; }

.comment-list { display: grid; gap: 14px; }
.comment {
    background: var(--site-surface); border: 1px solid var(--site-border);
    border-radius: var(--site-radius-sm); padding: 14px 16px;
}
.comment__head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.comment__avatar {
    width: 32px; height: 32px; border-radius: 999px; background: var(--site-surface-2) center/cover no-repeat;
    border: 1px solid var(--site-border); flex: 0 0 auto;
}
.comment__time { color: var(--site-muted); font-size: 12.5px; }
.comment__body { font-size: 14.5px; line-height: 1.7; white-space: pre-line; }

/* archive pages (PDF / Author) reuse the site header & footer */
.site-archive .site-main { padding-top: 24px; }

.site-flash {
    background: var(--site-brand-soft); border: 1px solid var(--site-brand);
    color: var(--site-text); border-radius: var(--site-radius-sm);
    padding: 12px 16px; margin-bottom: 18px; font-size: 14.5px;
}

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--site-border); padding: 26px 0; margin-top: 56px; color: var(--site-muted); font-size: 14px; }
.site-footer__inner { display: flex; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
.site-footer a:hover { color: var(--site-brand); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
    .site-nav { display: none; }
    .site-mobile-toggle { display: inline-flex; }
    .site-search { min-width: 0; width: 180px; }
    .site-hero { padding: 24px; }
    .site-hero__cta { margin-left: 0; }
    .site-hero__name { font-size: 24px; }
    .playlist-hero__cover { width: 160px; }
}
@media (max-width: 600px) {
    .site-search { display: none; }
    .site-rail__track > * { flex-basis: 220px; }
    .site-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
    .site-section { margin-top: 34px; }
}

/* ==========================================================================
   Book pages: cover, table of contents and reader
   ========================================================================== */

.book-cover {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
    padding: 28px 0 8px;
}

@media (max-width: 780px) {
    .book-cover { grid-template-columns: 1fr; gap: 20px; }
}

.book-cover__art {
    position: relative;
    aspect-ratio: 2 / 3;
    border-radius: var(--site-radius);
    overflow: hidden;
    background: linear-gradient(150deg, var(--site-brand), #7c2d12 85%);
    box-shadow: var(--site-shadow);
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 96px;
    font-weight: 700;
}

.book-cover__art.has-image { background: var(--site-surface-2); }

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

.book-kicker {
    display: inline-block;
    font-size: 12px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--site-brand-strong);
    font-weight: 700;
    margin-bottom: 10px;
}

.book-title { font-size: clamp(28px, 4vw, 44px); line-height: 1.2; margin: 0 0 12px; }

.book-lede { color: var(--site-muted); font-size: 17px; margin: 0 0 18px; max-width: 60ch; }

.book-facts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }

.book-facts span {
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--site-surface-2);
    color: var(--site-muted);
}

.book-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.book-resume {
    border: 1px solid var(--site-border);
    border-radius: var(--site-radius-sm);
    padding: 12px 14px;
    margin-bottom: 20px;
    max-width: 420px;
    background: var(--site-surface);
}

.book-resume__label { font-size: 12px; color: var(--site-muted); }

.book-resume__title { font-weight: 600; margin: 2px 0 8px; }

.book-resume__bar { height: 4px; border-radius: 999px; background: var(--site-surface-2); overflow: hidden; }

.book-resume__bar span { display: block; height: 100%; background: var(--site-brand); }

.book-toc { max-width: 820px; padding: 32px 0 48px; }

.book-toc__heading { font-size: 22px; margin: 0 0 18px; }

.book-toc__part { margin: 26px 0 10px; padding-left: calc(var(--depth, 0) * 16px); }

.book-toc__part-title { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--site-muted); font-weight: 700; }

.book-toc__part-sub { color: var(--site-muted); font-size: 14px; margin: 6px 0 0; }

.book-toc__item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 14px;
    align-items: baseline;
    padding: 11px 4px 11px calc(4px + var(--depth, 0) * 18px);
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--site-border);
}

.book-toc__item:hover { background: var(--site-surface-2); border-radius: 8px; }

.book-toc__item.is-empty { opacity: .5; cursor: default; }

.book-toc__title { font-weight: 600; }

.book-toc__sum { grid-column: 1; color: var(--site-muted); font-size: 14px; margin-top: 2px; }

.book-toc__meta { grid-column: 2; grid-row: 1; font-size: 12px; color: var(--site-muted); white-space: nowrap; }

/* Reader ------------------------------------------------------------------ */

.book-reader { padding-bottom: 40px; }

.book-reader__bar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    background: color-mix(in srgb, var(--site-bg) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--site-border);
}

.book-reader__back { color: var(--site-muted); text-decoration: none; font-size: 14px; }

.book-reader__back:hover { color: var(--site-text); }

.book-reader__tools { display: flex; gap: 6px; }

.book-tool {
    border: 1px solid var(--site-border);
    background: var(--site-surface);
    color: var(--site-text);
    border-radius: 999px;
    min-width: 36px;
    height: 34px;
    padding: 0 12px;
    font-size: 13px;
    cursor: pointer;
}

.book-tool:hover { border-color: var(--site-brand); color: var(--site-brand-strong); }

.book-reader__layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 36px;
    align-items: start;
    padding-top: 26px;
}

@media (max-width: 900px) {
    .book-reader__layout { grid-template-columns: 1fr; }
}

.book-reader__toc {
    position: sticky;
    top: 70px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding-right: 8px;
    border-right: 1px solid var(--site-border);
}

.book-reader__toc-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    margin-bottom: 10px;
}

.book-reader__toc-part {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--site-muted);
    font-weight: 700;
    margin: 16px 0 6px;
    padding-left: calc(var(--depth, 0) * 12px);
}

.book-reader__toc-link {
    display: block;
    padding: 7px 10px 7px calc(10px + var(--depth, 0) * 12px);
    border-radius: 8px;
    color: var(--site-muted);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.35;
}

.book-reader__toc-link:hover { background: var(--site-surface-2); color: var(--site-text); }

.book-reader__toc-link.is-current {
    background: var(--site-brand-soft);
    color: var(--site-brand-strong);
    font-weight: 700;
}

@media (max-width: 900px) {
    .book-reader__toc {
        position: fixed;
        inset: 0 0 0 auto;
        width: min(86vw, 340px);
        max-height: none;
        z-index: 60;
        background: var(--site-surface);
        border-left: 1px solid var(--site-border);
        border-right: 0;
        padding: 18px;
        transform: translateX(105%);
        transition: transform .22s ease;
        box-shadow: var(--site-shadow);
    }

    .book-reader.toc-open .book-reader__toc { transform: translateX(0); }
    .book-reader__toc-head { display: flex; }
}

.book-chapter { max-width: 72ch; }

.book-chapter__trail {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--site-muted);
    margin-bottom: 14px;
}

.book-chapter__trail span + span::before { content: "/"; margin-right: 6px; color: var(--site-border); }

.book-chapter__title {
    font-size: clamp(24px, 3.4vw, 34px);
    line-height: 1.25;
    margin: 0 0 8px;
}

.book-chapter__meta { display: flex; gap: 14px; font-size: 13px; color: var(--site-muted); margin-bottom: 22px; }

.book-chapter__summary {
    font-size: 17px;
    color: var(--site-muted);
    border-left: 3px solid var(--site-brand);
    padding: 4px 0 4px 14px;
    margin: 0 0 26px;
}

.book-prose {
    font-size: var(--reader-size, 19px);
    line-height: 1.95;
    letter-spacing: .002em;
}

.book-prose p { margin: 0 0 1.05em; text-align: justify; text-justify: inter-word; }

.book-prose h2 { font-size: 1.25em; margin: 1.8em 0 .6em; }

.book-prose h3 { font-size: 1.1em; margin: 1.6em 0 .5em; }

.book-prose blockquote {
    margin: 1.4em 0;
    padding: 4px 0 4px 16px;
    border-left: 3px solid var(--site-brand);
    color: var(--site-muted);
}

.book-prose img { max-width: 100%; height: auto; border-radius: var(--site-radius-sm); }

.book-prose__end { text-align: center; color: var(--site-border); letter-spacing: 1em; margin: 34px 0; }

.book-pager {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    border-top: 1px solid var(--site-border);
    padding-top: 20px;
    margin-top: 20px;
}

.book-pager__link {
    display: block;
    padding: 14px 16px;
    border: 1px solid var(--site-border);
    border-radius: var(--site-radius-sm);
    text-decoration: none;
    color: inherit;
    background: var(--site-surface);
}

.book-pager__link:hover { border-color: var(--site-brand); }

.book-pager__link--next { text-align: right; grid-column: 2; }

.book-pager__label { display: block; font-size: 12px; color: var(--site-muted); margin-bottom: 4px; }

.book-pager__title { font-weight: 600; }

@media (max-width: 560px) {
    .book-pager { grid-template-columns: 1fr; }
    .book-pager__link--next { grid-column: 1; }
}

.book-reader__progress {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: 3px;
    background: transparent;
    z-index: 40;
}

.book-reader__progress span { display: block; height: 100%; width: 0; background: var(--site-brand); }

/* Reading themes */
.book-reader[data-reader-theme="sepia"] .book-prose { color: #4a3a25; }

.book-reader[data-reader-theme="sepia"] {
    background: #f6efe0;
    margin: 0 -24px;
    padding: 0 24px;
    border-radius: var(--site-radius);
}

.book-reader[data-reader-theme="night"] { background: #0b0d10; color: #cfd4da; margin: -8px -24px 0; padding: 8px 24px 24px; border-radius: var(--site-radius); }

.book-reader[data-reader-theme="night"] .book-prose { color: #cfd4da; }

.book-reader[data-reader-theme="night"] .book-chapter__title { color: #f2f3f5; }

/* Wide container for the reader: the prose uses the full width like the header/footer */
.site-container--wide {
    max-width: none;
    padding-inline: clamp(16px, 2.2vw, 40px);
}

.site-container--wide .book-reader__layout {
    grid-template-columns: 240px minmax(0, 1fr);
    gap: clamp(20px, 2.5vw, 48px);
}

.site-container--wide .book-chapter { max-width: none; }

@media (min-width: 1500px) {
    .site-container--wide .book-reader__layout { grid-template-columns: 280px minmax(0, 1fr); }
}

/* Chapter audio ("listen while reading") -------------------------------- */

.book-listen {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px clamp(14px, 2vw, 32px);
    background: color-mix(in srgb, var(--site-surface) 94%, transparent);
    border-top: 1px solid var(--site-border);
    backdrop-filter: blur(12px);
    box-shadow: 0 -10px 30px -22px rgba(16, 18, 22, .5);
}

.book-reader:has(.book-listen) .book-chapter { padding-bottom: 92px; }

.book-listen__play {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 0;
    background: var(--site-brand);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.book-listen__play:hover { background: var(--site-brand-strong); }

.book-listen__body { flex: 1 1 auto; min-width: 0; }

.book-listen__head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    font-size: 13px;
    margin-bottom: 6px;
}

.book-listen__label {
    font-weight: 700;
    color: var(--site-brand-strong);
    white-space: nowrap;
}

.book-listen__title {
    color: var(--site-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.book-listen__time { margin-left: auto; color: var(--site-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.book-listen__seek {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--site-brand) var(--seek, 0%), var(--site-surface-2) var(--seek, 0%));
    cursor: pointer;
}

.book-listen__seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 999px;
    background: var(--site-brand);
    border: 2px solid var(--site-surface);
}

.book-listen__seek::-moz-range-thumb {
    width: 12px; height: 12px; border: 0; border-radius: 999px; background: var(--site-brand);
}

.book-listen__tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.book-listen__tools .book-tool { height: 32px; min-width: 44px; font-size: 12px; }

.book-listen__rate { padding: 0 8px; }

.book-listen__player {
    position: fixed;
    width: 1px;
    height: 1px;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 720px) {
    .book-listen { flex-wrap: wrap; gap: 8px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    .book-listen__body { order: 3; flex-basis: 100%; }
    .book-listen__title { display: none; }
    .book-listen__tools { margin-left: auto; }
    .book-reader:has(.book-listen) .book-chapter { padding-bottom: 132px; }
}

/* Volume control in the listen bar */
.book-listen__volume {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px;
    border: 1px solid var(--site-border);
    border-radius: 999px;
    background: var(--site-surface);
    height: 32px;
}

.book-listen__mute {
    border: 0;
    background: transparent;
    min-width: 30px;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.book-listen__vol {
    -webkit-appearance: none;
    appearance: none;
    width: 76px;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--site-brand) var(--vol, 100%), var(--site-surface-2) var(--vol, 100%));
    cursor: pointer;
}

.book-listen__vol::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: var(--site-brand);
    border: 2px solid var(--site-surface);
}

.book-listen__vol::-moz-range-thumb {
    width: 10px; height: 10px; border: 0; border-radius: 999px; background: var(--site-brand);
}

@media (max-width: 720px) {
    .book-listen__vol { display: none; }
    .book-listen__volume { border: 0; background: transparent; padding: 0; }
}

/* ==========================================================================
   Mobile: pages, book cover and reader
   ========================================================================== */

/* The header is sticky at 68px, so the reader bar and TOC start below it. */
.book-reader__bar { top: 68px; }
.book-reader__toc { top: 74px; }

@media (max-width: 900px) {
    .site-container,
    .site-container--wide { padding-inline: 16px; }
    .site-main { padding: 18px 0 40px; }

    .site-page-head { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
    .site-page-title { font-size: clamp(22px, 6vw, 28px); }
    .site-page-sub { font-size: 13.5px; }

    /* Reader shell ------------------------------------------------------- */
    .book-reader__bar {
        flex-wrap: nowrap;
        gap: 8px;
        padding: 8px 0;
    }

    .book-reader__back {
        max-width: 52vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 13px;
    }

    .book-reader__tools { overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
    .book-reader__tools::-webkit-scrollbar { display: none; }
    .book-reader__tools .book-tool { flex: 0 0 auto; height: 32px; min-width: 34px; padding: 0 10px; }

    .book-reader__layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
        padding-top: 12px;
    }

    .book-reader__toc {
        top: 0;
        height: 100%;
        border-right: 0;
        border-left: 1px solid var(--site-border);
    }

    .book-reader.toc-open .book-reader__toc {
        box-shadow: 0 0 0 100vmax rgba(10, 12, 16, .45), var(--site-shadow);
        clip-path: inset(0);
    }

    .book-reader__toc-head { position: sticky; top: 0; background: var(--site-surface); padding-bottom: 8px; }
    .book-reader__toc-link { padding: 10px 10px 10px calc(10px + var(--depth, 0) * 12px); font-size: 15px; }

    /* Chapter ------------------------------------------------------------- */
    .book-chapter { max-width: 100%; padding-bottom: 24px; overflow-wrap: anywhere; }
    .book-chapter__title { font-size: clamp(22px, 6.2vw, 30px); }
    .book-chapter__meta { gap: 10px; font-size: 12px; margin-bottom: 16px; }
    .book-chapter__summary { font-size: 15.5px; margin-bottom: 20px; }

    .book-prose { font-size: var(--reader-size, 17.5px); line-height: 1.9; }
    .book-prose p { margin-bottom: .95em; }

    .book-prose__end { margin: 26px 0; }

    /* Pager stacks -------------------------------------------------------- */
    .book-pager { grid-template-columns: minmax(0, 1fr); gap: 10px; padding-top: 16px; margin-top: 16px; }
    .book-pager__link { padding: 12px 14px; }
    .book-pager__link--next { grid-column: 1; text-align: left; }
    .book-pager__title { display: block; }

    /* The bar owns the bottom of the screen, so drop the thin progress line. */
    .book-reader:has(.book-listen) .book-reader__progress { display: none; }
    .book-reader:has(.book-listen) .book-chapter { padding-bottom: 120px; }
}

@media (max-width: 780px) {
    .book-cover {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
        padding: 8px 0 0;
    }

    .book-cover__art {
        aspect-ratio: 16 / 9;
        max-height: 240px;
        font-size: 64px;
    }

    .book-cover__art img { width: 100%; height: 100%; object-fit: cover; }

    .book-title { font-size: clamp(24px, 7vw, 32px); overflow-wrap: anywhere; }
    .book-lede { font-size: 15px; }
    .book-kicker { margin-bottom: 6px; }
    .book-facts { gap: 6px; margin-bottom: 16px; }
    .book-facts span { font-size: 12px; padding: 4px 10px; }
    .book-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .book-actions .site-btn { width: 100%; }
    .book-resume { max-width: none; margin-bottom: 16px; }

    .book-toc { padding: 22px 0 40px; }
    .book-toc__heading { font-size: 19px; margin-bottom: 12px; }
    .book-toc__part { margin: 20px 0 8px; padding-left: 0; }
    .book-toc__item {
        grid-template-columns: minmax(0, 1fr);
        padding: 12px 2px;
    }
    .book-toc__meta { grid-column: 1; grid-row: auto; margin-top: 2px; }
    .book-toc__sum {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

@media (max-width: 720px) {
    /* Listen bar: compact, two rows, thumb-friendly */
    .book-listen {
        gap: 10px;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
        align-items: center;
    }

    .book-listen__play { width: 44px; height: 44px; font-size: 16px; }
    .book-listen__label { font-size: 12px; }
    .book-listen__head { gap: 8px; margin-bottom: 8px; }
    .book-listen__time { font-size: 12px; }
    .book-listen__seek { height: 8px; }
    .book-listen__seek::-webkit-slider-thumb { width: 18px; height: 18px; }
    .book-listen__tools { gap: 4px; }
    .book-listen__tools .book-tool { height: 34px; min-width: 44px; font-size: 12px; }
}

@media (max-width: 560px) {
    .book-prose,
    .book-prose p { text-align: left; text-justify: auto; }

    .book-chapter__trail { font-size: 11px; }

    .book-listen__title { display: none; }
    .book-listen__label { white-space: nowrap; }

    .book-reader:has(.book-listen) .book-chapter { padding-bottom: 132px; }
}

/* Compact header for small phones (keeps the logo, menu, theme and login on one row) */
@media (max-width: 600px) {
    .site-header__inner { gap: 8px; height: 62px; padding-inline: 12px; }
    .site-header__inner > * { min-width: 0; }
    .site-logo { flex: 0 0 auto; }
    .site-logo img { height: 26px; }
    .site-actions { gap: 6px; margin-left: auto; }
    .site-actions .site-btn { padding: 8px 12px; font-size: 13px; }
    .site-icon-btn { width: 34px; height: 34px; }
    .site-mobile-nav a { padding: 13px 4px; font-size: 15px; }

    .book-reader__bar { top: 62px; }
    .book-reader__toc { top: 0; }

    .book-cover__art { aspect-ratio: 16 / 10; max-height: 200px; }
    .book-title { font-size: clamp(21px, 6.4vw, 27px); }
    .book-facts span { font-size: 11.5px; }
    .book-actions { gap: 8px; }
    .book-actions .site-btn { padding: 11px 14px; font-size: 14px; }

    .book-chapter__title { font-size: clamp(20px, 5.8vw, 26px); }
}

/* Reader: single column on phones (the wide-container rule above set two). */
@media (max-width: 900px) {
    .site-container--wide .book-reader__layout,
    .book-reader__layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .book-reader__toc {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        width: min(86vw, 340px);
        height: 100%;
        max-height: none;
        z-index: 60;
        padding: 18px;
        background: var(--site-surface);
        border-left: 1px solid var(--site-border);
        border-right: 0;
        transform: translateX(105%);
        transition: transform .22s ease;
        box-shadow: var(--site-shadow);
    }

    .book-reader.toc-open .book-reader__toc { transform: translateX(0); }
}

/* Drawer: guarantee the closed state wins over any later rule. */
@media (max-width: 900px) {
    .book-reader:not(.toc-open) .book-reader__toc {
        transform: translateX(105%) !important;
        visibility: hidden;
    }

    .book-reader.toc-open .book-reader__toc {
        transform: translateX(0) !important;
        visibility: visible;
    }
}

/* Featured video / playlist on the book page ---------------------------- */
.book-media {
    margin: 8px 0 28px;
    max-width: 960px;
}

.book-media__head { margin-bottom: 10px; }
.book-media__title { margin: 2px 0 0; font-size: 20px; line-height: 1.3; }

.book-media__frame {
    position: relative;
    aspect-ratio: 16 / 9;
    border-radius: var(--site-radius);
    overflow: hidden;
    background: var(--site-surface-2);
    border: 1px solid var(--site-border);
    box-shadow: var(--site-shadow);
}

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

.book-media__poster {
    width: 100%; height: 100%;
    display: grid; place-items: center;
    background: linear-gradient(150deg, var(--site-brand), #7c2d12 85%);
    color: #fff; font-size: 64px; font-weight: 700;
}

.book-media__play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 72px;
    height: 72px;
    border-radius: 999px;
    border: 0;
    display: grid;
    place-items: center;
    background: rgba(12, 14, 18, .72);
    color: #fff;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease;
}

.book-media__play:hover { transform: scale(1.06); background: var(--site-brand); }

.book-media__external {
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(12, 14, 18, .68);
    color: #fff;
    font-size: 12px;
    text-decoration: none;
}

.book-media__frame.is-playing .book-media__play,
.book-media__frame.is-playing .book-media__external,
.book-media__frame.is-playing img,
.book-media__frame.is-playing .book-media__poster { display: none; }

.book-media__frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Readers chip in the facts row */
.book-fact--readers { display: inline-flex; align-items: center; gap: 5px; }
.book-fact--readers svg { opacity: .7; }

@media (max-width: 780px) {
    .book-media { margin: 4px 0 20px; }
    .book-media__play { width: 58px; height: 58px; }
    .book-media__title { font-size: 17px; }
    .book-media__external { font-size: 11px; padding: 4px 8px; }
}