:root {
    --tsbdp-bg: #fbfaf7;
    --tsbdp-card: #fffdf9;
    --tsbdp-ink: #111;
    --tsbdp-muted: #626262;
    --tsbdp-accent: #f7b719;
    --tsbdp-accent-deep: #b96900;
    --tsbdp-line: #ebe5dc;
}

body.single-book,
body.single-books,
body:has(.tsbdp-related-archive-page) {
    background: var(--tsbdp-bg) !important;
}

.tsbdp-page {
    min-height: 100vh;
    background: var(--tsbdp-bg) !important;
    background-image: none !important;
    color: var(--tsbdp-ink);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.tsbdp-page::before,
.tsbdp-page::after,
.tsbdp-shell::before,
.tsbdp-shell::after {
    content: none !important;
    display: none !important;
}

.tsbdp-mobile-topbar { display: none; }

.tsbdp-shell {
    position: relative;
    width: min(1120px, calc(100% - 40px));
    margin: 0 auto;
    padding: 28px 0 48px;
    background: transparent !important;
    box-shadow: none !important;
}

.tsbdp-back {
    position: absolute;
    top: 28px;
    left: 0;
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    background: #2b2b2b;
    color: #fff;
    text-decoration: none;
    font-size: 32px;
    line-height: 1;
    z-index: 3;
}

.tsbdp-back-labelled {
    width: auto;
    padding: 0 17px;
    display: inline-flex;
    gap: 8px;
    font-size: 16px;
    font-weight: 750;
}

.tsbdp-book-detail {
    max-width: 820px;
    margin: 0 auto;
    text-align: center;
}

.tsbdp-cover-wrap {
    width: min(230px, 40vw);
    margin: 0 auto 16px;
}

.tsbdp-cover {
    display: block;
    width: 100%;
    height: auto;
    max-height: 340px;
    object-fit: contain;
    background: transparent;
    border: 1px solid rgba(17, 17, 17, .16);
    border-radius: 13px;
    box-shadow: 0 14px 30px rgba(17, 17, 17, .14);
}

.tsbdp-cover-fallback {
    aspect-ratio: 2 / 3;
    display: grid;
    place-items: center;
    padding: 20px;
    background: #ececec;
    font-weight: 800;
}

.tsbdp-title {
    margin: 0;
    font-size: clamp(29px, 3vw, 42px);
    line-height: 1.15;
    font-weight: 850;
}

.tsbdp-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    max-width: 620px;
    margin: 22px auto 24px;
}

.tsbdp-action-button {
    min-height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffca2f, var(--tsbdp-accent));
    color: #111;
    text-decoration: none;
    font-size: clamp(18px, 1.8vw, 23px);
    font-weight: 800;
    box-shadow: 0 9px 18px rgba(247, 183, 25, .20);
}

.tsbdp-facts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    max-width: 690px;
    margin: 0 auto 22px;
}

.tsbdp-fact {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    padding: 13px 15px;
    border-radius: 16px;
    background: rgba(255, 253, 249, .76);
}

.tsbdp-fact-icon,
.tsbdp-summary-icon {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: #fbf4e8;
    font-size: 21px;
}

.tsbdp-fact-copy { display: grid; gap: 4px; min-width: 0; }
.tsbdp-fact-copy strong { font-size: 15px; }
.tsbdp-fact-copy span { font-size: 16px; color: #222; overflow-wrap: anywhere; }

.tsbdp-summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 15px;
    text-align: left;
    padding: 19px 0 22px;
    border-top: 1px solid var(--tsbdp-line);
    border-bottom: 1px solid var(--tsbdp-line);
}

.tsbdp-summary h2 {
    margin: 0 0 7px;
    font-size: 21px;
}

.tsbdp-summary-text {
    position: relative;
    max-height: 6.6em;
    overflow: hidden;
    font-size: 16px;
    line-height: 1.65;
    color: #252525;
    transition: max-height .28s ease;
}

.tsbdp-summary-text p { margin: 0; }
.tsbdp-summary-text::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2.7em;
    background: linear-gradient(transparent, var(--tsbdp-bg));
    pointer-events: none;
}

.tsbdp-summary-text.is-expanded {
    max-height: 120rem;
}

.tsbdp-summary-text.is-expanded::after { display: none; }

.tsbdp-summary-toggle {
    margin-top: 8px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--tsbdp-accent-deep);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
}

.tsbdp-related {
    margin-top: 18px;
}

.tsbdp-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.tsbdp-section-heading h2 {
    margin: 0;
    font-size: clamp(22px, 2.3vw, 29px);
}

.tsbdp-section-heading a {
    color: var(--tsbdp-accent-deep);
    text-decoration: none;
    font-size: 17px;
    font-weight: 800;
    white-space: nowrap;
}

/* A compact horizontal rail prevents related covers from becoming too tall. */
.tsbdp-related-track {
    display: flex;
    gap: 13px;
    overflow-x: auto;
    padding: 1px 2px 12px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
}

.tsbdp-related-card {
    flex: 0 0 116px;
    min-width: 0;
    color: var(--tsbdp-ink);
    text-decoration: none;
    scroll-snap-align: start;
}

.tsbdp-related-card img,
.tsbdp-related-placeholder {
    display: block;
    width: 116px;
    height: 166px;
    object-fit: cover;
    border-radius: 11px;
    background: #e8e8e8;
    box-shadow: 0 7px 16px rgba(17, 17, 17, .10);
}

.tsbdp-related-placeholder {
    display: grid;
    place-items: center;
    padding: 10px;
    text-align: center;
    font-weight: 700;
}

.tsbdp-related-title {
    display: -webkit-box;
    margin-top: 7px;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 12px;
    line-height: 1.3;
    font-weight: 750;
}

.tsbdp-related-author {
    display: block;
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--tsbdp-muted);
    font-size: 11px;
}

/* Related archive */
.tsbdp-related-archive-shell { padding-top: 92px; }
.tsbdp-archive-header { text-align: center; margin: 0 auto 28px; }
.tsbdp-archive-header p { margin: 0 0 4px; color: var(--tsbdp-muted); }
.tsbdp-archive-header h1 { margin: 0; font-size: clamp(24px, 3vw, 39px); }
.tsbdp-archive-header h2 { margin: 10px 0 0; color: var(--tsbdp-accent-deep); font-size: 20px; }

.tsbdp-related-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 24px 16px;
}

.tsbdp-related-grid .tsbdp-related-card { width: 100%; }
.tsbdp-related-grid .tsbdp-related-card img,
.tsbdp-related-grid .tsbdp-related-placeholder {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
}

.tsbdp-empty-related {
    padding: 40px 20px;
    border: 1px solid var(--tsbdp-line);
    border-radius: 18px;
    background: var(--tsbdp-card);
    text-align: center;
    color: var(--tsbdp-muted);
}

.tsbdp-pagination { margin-top: 34px; }
.tsbdp-pagination .page-numbers {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0;
    list-style: none;
}
.tsbdp-pagination a,
.tsbdp-pagination span {
    display: grid;
    place-items: center;
    min-width: 42px;
    height: 42px;
    padding: 0 12px;
    border-radius: 12px;
    background: #fff;
    color: #111;
    text-decoration: none;
}
.tsbdp-pagination .current { background: var(--tsbdp-accent); font-weight: 800; }

@media (max-width: 900px) {
    .tsbdp-related-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    body.single-book .site-header,
    body.single-books .site-header { display: none !important; }

    .tsbdp-mobile-topbar {
        position: sticky;
        top: 0;
        z-index: 50;
        display: grid;
        grid-template-columns: 52px 1fr 52px;
        align-items: center;
        min-height: 68px;
        padding: env(safe-area-inset-top) 12px 0;
        background: #050505;
        color: #fff;
    }

    .tsbdp-menu-button,
    .tsbdp-search-button {
        display: grid;
        place-items: center;
        width: 46px;
        height: 46px;
        border: 0;
        background: transparent;
        color: #fff;
        text-decoration: none;
        font-size: 30px;
    }

    .tsbdp-brand {
        justify-self: center;
        color: #0689e8;
        text-decoration: none;
        font-size: 24px;
        font-weight: 850;
        letter-spacing: .03em;
    }

    .tsbdp-shell {
        width: 100%;
        padding: 18px 16px 32px;
        overflow: hidden;
    }

    .tsbdp-back {
        top: 22px;
        left: 16px;
        width: 42px;
        height: 42px;
        font-size: 29px;
    }

    .tsbdp-back-labelled {
        width: auto;
        padding: 0 14px;
        font-size: 14px;
    }

    .tsbdp-book-detail { max-width: none; }

    .tsbdp-cover-wrap {
        width: min(48vw, 195px);
        margin-bottom: 14px;
    }

    .tsbdp-cover {
        max-height: 290px;
        border-radius: 11px;
    }

    .tsbdp-title {
        font-size: clamp(25px, 7vw, 32px);
        padding: 0 6px;
    }

    .tsbdp-actions {
        gap: 11px;
        margin: 18px 0;
    }

    .tsbdp-action-button {
        min-height: 49px;
        font-size: 17px;
    }

    .tsbdp-facts {
        grid-template-columns: 1fr;
        gap: 9px;
        margin-bottom: 16px;
    }

    .tsbdp-fact {
        padding: 11px 13px;
        background: #fffaf3;
    }

    .tsbdp-summary {
        gap: 11px;
        padding: 15px 0 18px;
    }

    .tsbdp-summary h2 { font-size: 20px; }
    .tsbdp-summary-text { font-size: 15px; max-height: 5.1em; }
    .tsbdp-summary-text.is-expanded { max-height: 120rem; }

    .tsbdp-related { margin-top: 16px; }
    .tsbdp-section-heading h2 { font-size: 21px; }
    .tsbdp-section-heading a { font-size: 15px; }

    .tsbdp-related-track {
        gap: 10px;
        padding-bottom: 10px;
        scrollbar-width: none;
    }
    .tsbdp-related-track::-webkit-scrollbar { display: none; }

    .tsbdp-related-card { flex-basis: 94px; }
    .tsbdp-related-card img,
    .tsbdp-related-placeholder {
        width: 94px;
        height: 136px;
        border-radius: 9px;
    }

    .tsbdp-related-title { font-size: 11px; }
    .tsbdp-related-author { font-size: 10px; }

    .tsbdp-related-archive-shell { padding-top: 78px; overflow: visible; }
    .tsbdp-related-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 10px; }
}

@media (max-width: 390px) {
    .tsbdp-shell { padding-inline: 12px; }
    .tsbdp-cover-wrap { width: min(47vw, 178px); }
    .tsbdp-actions { gap: 8px; }
    .tsbdp-action-button { font-size: 16px; }
    .tsbdp-related-card { flex-basis: 88px; }
    .tsbdp-related-card img,
    .tsbdp-related-placeholder { width: 88px; height: 128px; }
    .tsbdp-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
