/**
 * 电子书层板书架（修改 A · 第1步 CSS/DOM）
 * PC：每层多本；手机：每层 1 本、水平居中
 */
:root {
    --ebook-accent: #cf9c7e;
    --ebook-accent-dark: #b88464;
    --ebook-shelf: #c4a484;
    --ebook-shelf-dark: #a88868;
    --ebook-shelf-edge: #8b6b4a;
    --ebook-text: #2c2420;
    --ebook-muted: #8a7a70;
    --ebook-book-h: 168px;
    --ebook-spine: 7px;
}

/* 中性壳：整页底色与书橱区一致，无站点顶栏/页脚 */
body.ebook-neutral-shell,
body.ebook-neutral-shell #pjax-container,
body.ebook-neutral-shell .container-fluid {
    background: linear-gradient(180deg, #f7f2ec 0%, #ebe3d8 100%) !important;
    min-height: 100vh;
}

body.ebook-neutral-shell .container-fluid {
    padding-left: clamp(16px, 2.5vw, 40px);
    padding-right: clamp(16px, 2.5vw, 40px);
}

.ebook-neutral-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 0 18px;
}

.ebook-neutral-mark {
    width: 36px;
    height: 36px;
    display: block;
}

.ebook-neutral-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--ebook-text);
}

/* 书橱页不出现全站音乐播放器与客服悬浮球 */
body.ebook-neutral-shell #musicPlayer,
body.ebook-neutral-shell .coze-guest-floating-ball,
body.ebook-neutral-shell .coze-websdk-asstBtn,
body.ebook-neutral-shell #coze-chat-container {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* 工具栏：深木色底条，浅米色字，选中为浅驼金 */
body.ebook-neutral-shell .ebook-bookshelf-zone .toolbar {
    margin-bottom: 96px !important;
    padding: 10px 16px;
    border-radius: 12px;
    background: linear-gradient(180deg, #7a5c40 0%, #6e5238 55%, #5c4330 100%);
    box-shadow: 0 8px 18px rgba(60, 40, 24, 0.18);
}

body.ebook-neutral-shell .ebook-toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: nowrap;
}

@media (max-width: 768px) {
    body.ebook-neutral-shell .ebook-bookshelf-zone .toolbar {
        padding: 8px 12px !important;
    }

    body.ebook-neutral-shell .ebook-toolbar-row {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
    }

    body.ebook-neutral-shell .ebook-bookshelf-zone .toolbar-info {
        width: auto !important;
        margin: 0 !important;
        text-align: left !important;
        flex: 1 1 auto;
        min-width: 0;
        white-space: nowrap !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.ebook-neutral-shell .ebook-bookshelf-zone .toolbar .ebook-sort.btn-group,
    body.ebook-neutral-shell .ebook-bookshelf-zone .ebook-sort {
        flex-direction: row !important;
        width: auto !important;
        flex: 0 0 auto !important;
    }

    body.ebook-neutral-shell .ebook-bookshelf-zone .ebook-sort .btn {
        flex: 0 0 32px !important;
        width: 32px !important;
        margin: 0 !important;
    }
}

body.ebook-neutral-shell .ebook-bookshelf-zone .toolbar-info,
body.ebook-neutral-shell .ebook-bookshelf-zone .toolbar-info .text-muted {
    color: #f3e6d4 !important;
    font-size: 14px;
}

body.ebook-neutral-shell .ebook-bookshelf-zone .toolbar-info strong,
body.ebook-neutral-shell .ebook-bookshelf-zone .toolbar-info .text-primary {
    color: #f0d2b0 !important;
    font-weight: 600;
}

body.ebook-neutral-shell .ebook-bookshelf-zone .btn-filter-minimal,
body.ebook-neutral-shell .ebook-bookshelf-zone .filter-dimension-btn {
    color: #f7f2ec !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(243, 230, 212, 0.35) !important;
    border-radius: 999px !important;
    height: 32px;
    box-shadow: none !important;
}

body.ebook-neutral-shell .ebook-bookshelf-zone .btn-filter-minimal:hover,
body.ebook-neutral-shell .ebook-bookshelf-zone .filter-dimension-btn:hover,
body.ebook-neutral-shell .ebook-bookshelf-zone .filter-dimension-btn.selected {
    color: #3d2a1c !important;
    background: #f0d2b0 !important;
    border-color: #f0d2b0 !important;
}

body.ebook-neutral-shell .ebook-bookshelf-zone #searchInput {
    width: 180px;
    height: 32px;
    background: rgba(255, 255, 255, 0.12) !important;
    border: 1px solid rgba(243, 230, 212, 0.35) !important;
    color: #f7f2ec !important;
    border-radius: 999px !important;
    box-shadow: none !important;
}

body.ebook-neutral-shell .ebook-bookshelf-zone #searchInput::placeholder {
    color: rgba(243, 230, 212, 0.65);
}

body.ebook-neutral-shell .ebook-bookshelf-zone .ebook-search-btn {
    height: 32px;
    width: 36px;
    padding: 0;
    color: #3d2a1c !important;
    background: #f0d2b0 !important;
    border: 1px solid #f0d2b0 !important;
    border-radius: 999px !important;
}

body.ebook-neutral-shell .ebook-bookshelf-zone .ebook-search-btn:hover {
    background: #f7e2cc !important;
    border-color: #f7e2cc !important;
}

/* PC：右下角独立分享浮标，不挤占木色工具条 */
body.ebook-neutral-shell .ebook-shelf-share {
    display: none;
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 1500;
    height: 48px;
    padding: 0 18px 0 16px;
    border: none;
    border-radius: 999px;
    background: #6e5238;
    color: #f7f2ec;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(60, 40, 24, 0.28);
    font-size: 14px;
    line-height: 1;
}
body.ebook-neutral-shell .ebook-shelf-share i {
    font-size: 16px;
}
body.ebook-neutral-shell .ebook-shelf-share:hover {
    background: #5c4330;
    color: #fff;
}
@media (min-width: 768px) {
    body.ebook-neutral-shell .ebook-shelf-share {
        display: inline-flex;
    }
}
body.ebook-neutral-shell .ebook-shelf-share-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(60, 40, 24, 0.45);
}
body.ebook-neutral-shell .ebook-shelf-share-overlay[hidden] {
    display: none !important;
}
body.ebook-neutral-shell .ebook-shelf-share-modal {
    position: relative;
    width: 100%;
    max-width: 320px;
    padding: 28px 24px 22px;
    border-radius: 16px;
    background: #f7f2ec;
    color: #3d2a1c;
    text-align: center;
    box-shadow: 0 16px 40px rgba(60, 40, 24, 0.22);
}
body.ebook-neutral-shell .ebook-shelf-share-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #8a7564;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
body.ebook-neutral-shell .ebook-shelf-share-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}
body.ebook-neutral-shell .ebook-shelf-share-hint {
    margin: 0 0 16px;
    font-size: 13px;
    line-height: 1.5;
    color: #6e5a48;
}
body.ebook-neutral-shell .ebook-shelf-share-qr {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    margin: 0 auto 16px;
}
body.ebook-neutral-shell .ebook-shelf-share-qr img,
body.ebook-neutral-shell .ebook-shelf-share-qr canvas {
    display: block;
}
body.ebook-neutral-shell .ebook-shelf-share-copy {
    width: 100%;
    height: 40px;
    border: none;
    border-radius: 999px;
    background: #6e5238;
    color: #f7f2ec;
    cursor: pointer;
}
body.ebook-neutral-shell .ebook-shelf-share-copy:hover {
    background: #5c4330;
}

body.ebook-neutral-shell .ebook-bookshelf-zone .ebook-sort {
    display: inline-flex !important;
    flex-wrap: nowrap !important;
    flex: 0 0 auto;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(243, 230, 212, 0.28);
    border-radius: 999px;
    overflow: hidden;
    padding: 2px;
}

body.ebook-neutral-shell .ebook-bookshelf-zone .ebook-sort .btn {
    color: #f7f2ec !important;
    background: transparent !important;
    border: none !important;
    border-radius: 999px !important;
    box-shadow: none !important;
    width: 32px;
    height: 32px;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    line-height: 1;
}

body.ebook-neutral-shell .ebook-bookshelf-zone .ebook-sort .btn:hover {
    background: rgba(240, 210, 176, 0.2) !important;
    color: #f7f2ec !important;
}

body.ebook-neutral-shell .ebook-bookshelf-zone .ebook-sort .btn.active {
    background: #f0d2b0 !important;
    color: #3d2a1c !important;
}

body.ebook-neutral-shell .ebook-bookshelf-zone .filter-dropdown {
    background: #f7f2ec !important;
    border: 1px solid rgba(196, 164, 132, 0.6) !important;
    box-shadow: 0 10px 24px rgba(80, 50, 30, 0.12) !important;
}

body.ebook-neutral-shell .ebook-bookshelf-zone .filter-dropdown-item {
    background: rgba(255, 255, 255, 0.7) !important;
    border-color: rgba(196, 164, 132, 0.35) !important;
    color: #2c2420 !important;
}

body.ebook-neutral-shell .ebook-bookshelf-zone .filter-dropdown-item:hover,
body.ebook-neutral-shell .ebook-bookshelf-zone .filter-dropdown-item.active {
    background: #c4a484 !important;
    color: #fff !important;
    border-color: #c4a484 !important;
}

/* 书橱暖色内容区（与整页底色一致） */
.ebook-bookshelf-zone {
    background: transparent;
    border-radius: 0;
    padding: 4px 0 28px;
    margin-top: 0;
}

.ebook-bookshelf-zone .toolbar-info,
.ebook-bookshelf-zone .toolbar-info .text-muted {
    color: var(--ebook-muted) !important;
}

.ebook-bookshelf-zone .toolbar-info strong,
.ebook-bookshelf-zone .toolbar-info .text-primary {
    color: var(--ebook-accent-dark) !important;
}

.ebook-bookshelf {
    max-width: none;
    margin: 0 auto;
    width: 100%;
}

.ebook-shelf-tier {
    margin: 0;
}

.ebook-shelf-row {
    display: flex;
    justify-content: space-evenly;
    align-items: flex-end;
    flex-wrap: nowrap;
    gap: clamp(16px, 2.4vw, 48px);
    padding: 0;
    width: 100%;
    min-height: calc(var(--ebook-book-h) + 6px);
}

@media (min-width: 768px) {
    :root {
        /* 按屏宽放大封面，层板本身已 100% 宽 */
        --ebook-book-h: clamp(168px, 18vw, 240px);
    }
}

.ebook-shelf-board {
    position: relative;
    height: 22px;
    margin: 0 4px 36px;
    border-radius: 2px 2px 4px 4px;
    background: linear-gradient(180deg, #d4b896 0%, var(--ebook-shelf) 35%, var(--ebook-shelf-dark) 100%);
    box-shadow:
        0 10px 18px rgba(80, 50, 30, 0.18),
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}

.ebook-shelf-board::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -10px;
    height: 10px;
    background: linear-gradient(180deg, var(--ebook-shelf-edge), #6e5238);
    border-radius: 0 0 3px 3px;
    opacity: 0.85;
}

.ebook-shelf-board::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    top: 100%;
    height: 28px;
    background: radial-gradient(ellipse at top, rgba(0, 0, 0, 0.18), transparent 70%);
    pointer-events: none;
}

/* 单本书：--ratio 为封面宽/高，默认偏竖版占位 */
.ebook-book {
    --ratio: 0.72;
    text-decoration: none;
    color: var(--ebook-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.25s ease;
    min-width: max(calc(var(--ebook-book-h) * var(--ratio)), 7.5em);
    max-width: 100%;
}

.ebook-book:hover {
    transform: translateY(-12px);
    color: var(--ebook-text);
    text-decoration: none;
}

.ebook-book-cover-wrap {
    position: relative;
    height: var(--ebook-book-h);
    width: calc(var(--ebook-book-h) * var(--ratio) + var(--ebook-spine));
    padding-left: var(--ebook-spine);
    box-sizing: border-box;
    background: transparent;
}

.ebook-book-cover-wrap::before {
    content: "";
    position: absolute;
    left: 0;
    top: 2px;
    bottom: 2px;
    width: var(--ebook-spine);
    border-radius: 2px 0 0 2px;
    background: linear-gradient(90deg, #6a4e38, #9a7a5a 60%, #b89572);
}

.ebook-book-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 2px 3px 3px 2px;
    box-shadow: 4px 6px 14px rgba(40, 28, 18, 0.28);
    background: #ddd;
}

.ebook-book-title {
    margin-top: 10px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 0 2px;
    color: var(--ebook-text);
}

.ebook-book-meta {
    margin-top: 3px;
    font-size: 12px;
    color: var(--ebook-muted);
    white-space: nowrap;
}

.ebook-book-meta .bi-eye {
    font-size: 12px;
    margin-right: 2px;
    vertical-align: -1px;
}

.ebook-book[data-orient="landscape"] {
    --ebook-book-h: min(210px, calc((100vw - 240px) / 6.2));
}

.ebook-book[data-orient="square"] {
    --ebook-book-h: min(220px, calc((100vw - 200px) / 5));
}

.ebook-book[data-orient="portrait"] {
    --ebook-book-h: min(260px, 28vh);
}

/* —— 手机：每层 1 本，水平居中 —— */
@media (max-width: 767.98px) {
    body.ebook-neutral-shell {
        --ebook-book-h: 168px;
    }

    .ebook-bookshelf-zone {
        padding: 8px 0 24px;
        border-radius: 0;
        margin: 0;
    }

    .ebook-bookshelf {
        padding: 0 8px;
    }

    .ebook-shelf-tier {
        display: contents;
    }

    .ebook-shelf-row {
        display: contents;
    }

    .ebook-shelf-board {
        display: none;
    }

    .ebook-book {
        width: 100%;
        min-width: 0;
        margin: 0 auto 0;
        align-items: center;
    }

    .ebook-book:hover {
        transform: none;
    }

    .ebook-book-cover-wrap {
        margin: 0 auto;
    }

    .ebook-book-title {
        font-size: 13px;
        margin-top: 8px;
        width: max-content;
        max-width: 100%;
    }

    /* 每本书下方自带层板 */
    .ebook-book::after {
        content: "";
        display: block;
        width: 100%;
        height: 16px;
        margin: 14px 0 22px;
        border-radius: 2px 2px 4px 4px;
        background: linear-gradient(180deg, #d4b896 0%, var(--ebook-shelf) 35%, var(--ebook-shelf-dark) 100%);
        box-shadow:
            0 8px 14px rgba(80, 50, 30, 0.16),
            inset 0 1px 0 rgba(255, 255, 255, 0.35);
        position: relative;
    }

    .ebook-book[data-orient="landscape"] {
        --ebook-book-h: 140px;
    }

    .ebook-book[data-orient="square"] {
        --ebook-book-h: 170px;
    }

    .ebook-book[data-orient="portrait"] {
        --ebook-book-h: 200px;
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .ebook-shelf-row {
        gap: 20px;
    }

    .ebook-book[data-orient="landscape"],
    .ebook-book {
        --ebook-book-h: 140px;
    }
}
