/**
 * CSC Library - Frontend Custom Styles
 */

/* Anti-CLS cho khung quảng cáo */
.csc-ad-placeholder {
    background-color: #f8fafc;
    border: 1px dashed #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    overflow: hidden;
}

/* Bo góc chuẩn */
.radius-md {
    border-radius: 8px !important;
}

/* Line clamp 2 dòng cho tiêu đề sách */
.csc-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.7em;
}

/* ==========================================================
   CARD SÁCH PHẲNG MINIMALIST (Tối ưu bo góc & Padding thoáng)
   ========================================================== */
.csc-flat-book-card {
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    background: #ffffff !important;
}

.csc-flat-book-card:hover {
    border-color: #cbd5e1 !important;
    transform: translateY(-3px);
    box-shadow: 0 12px 20px -5px rgba(0, 0, 0, 0.08) !important;
}

/* Định dạng chuẩn tỷ lệ dọc đứng (Book Aspect Ratio 1:1.4) cho tất cả bìa sách */
.csc-flat-book-card .box-image {
    position: relative !important;
    width: 100% !important;
    padding-top: 140% !important;
    /* Chuẩn tỷ lệ đứng 1 : 1.4 của bìa sách */
    height: 0 !important;
    background: #f8fafc;
    overflow: hidden !important;
    border-top-left-radius: 8px !important;
    border-top-right-radius: 8px !important;
}

.csc-flat-book-card .box-image a {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

.csc-flat-book-card .box-image img,
.csc-flat-book-card .box-image .csc-cover-img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
}

/* Tăng padding thoáng đãng cho phần nội dung card, không dính viền */
.csc-book-card-body {
    padding: 16px 18px !important;
    background: #ffffff !important;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

/* ==========================================================
   BẢNG THÔNG SỐ SÁCH TRANG CHI TIẾT (csc-spec-grid & Cột Trái)
   ========================================================== */
.csc-book-sidebar-card {
    padding: 0 !important;
    background: #ffffff !important;
    border-radius: 8px !important;
    overflow: visible !important;
    /* Cho phép cửa sổ zoom flyout bung ra ngoài */
    position: relative;
}

.csc-book-sidebar-card .csc-book-cover {
    margin: 0 !important;
    padding: 0 !important;
    background: #f8fafc;
    position: relative;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    overflow: visible !important;
    /* Không cắt mất cửa sổ zoom */
}

.csc-book-sidebar-card .csc-book-cover img {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 auto !important;
    border: none !important;
    border-radius: 0 !important;
}

.csc-spec-grid {
    border-top: 1px solid #f1f5f9;
    padding: 20px 22px 16px 22px !important;
    background: #ffffff !important;
    font-size: 13px;
}


@media (max-width: 550px) {
    .csc-single-main-card {
        padding: 18px 16px !important;
    }
}

/* ==========================================================
   HEADER / TOOLBAR ĐẦU DANH SÁCH SÁCH (Cột Phải)
   ========================================================== */
.csc-archive-header-box {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    width: 100% !important;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 16px !important;
    margin-bottom: 20px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
    gap: 12px;
}

.csc-archive-counter-text {
    font-size: 13px;
    color: #64748b;
}

#csc-sort-select {
    padding-right: 28px !important;
    cursor: pointer;
    background-color: #f8fafc !important;
    border-color: #e2e8f0 !important;
    transition: border-color 0.15s ease;
}

#csc-sort-select:hover,
#csc-sort-select:focus {
    border-color: #cbd5e1 !important;
    background-color: #ffffff !important;
}

/* ==========================================================
   VIEW SWITCHER (1 Nút chuyển trạng thái Grid / List)
   ========================================================== */
.csc-toggle-btn {
    width: 38px;
    height: 38px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s ease;
}

.csc-toggle-btn:hover {
    background: #ffffff;
    border-color: #cbd5e1;
    color: #0f172a;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.csc-toggle-btn svg {
    display: block;
}

/* ==========================================================
   GIAO DIỆN DANH SÁCH (LIST VIEW): CỘT TRÁI ẢNH BÌA, CỘT PHẢI NỘI DUNG
   ========================================================== */
#csc-books-container.csc-list-view .csc-book-col {
    flex-basis: 100% !important;
    max-width: 100% !important;
    width: 100% !important;
}

#csc-books-container.csc-list-view .csc-flat-book-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    min-height: 150px;
}

#csc-books-container.csc-list-view .box-image {
    width: 140px !important;
    min-width: 140px !important;
    max-width: 140px !important;
    height: auto !important;
    padding-top: 0 !important;
    position: relative !important;
    border-top-left-radius: 8px !important;
    border-bottom-left-radius: 8px !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    overflow: hidden !important;
    align-self: stretch !important;
}

#csc-books-container.csc-list-view .box-image a {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

#csc-books-container.csc-list-view .box-image img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

#csc-books-container.csc-list-view .csc-book-card-body {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    padding: 18px 24px !important;
    border-top-right-radius: 8px !important;
    border-bottom-right-radius: 8px !important;
    border-bottom-left-radius: 0 !important;
}

@media (max-width: 550px) {
    #csc-books-container.csc-list-view .box-image {
        width: 100px !important;
        min-width: 100px !important;
        max-width: 100px !important;
    }

    #csc-books-container.csc-list-view .csc-book-card-body {
        padding: 12px 14px !important;
    }
}

/* ==========================================================
   BỘ LỌC CỘT TRÁI (SIDEBAR FILTER)
   ========================================================== */
.csc-sidebar-filter {
    padding: 22px 18px !important;
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.csc-filter-group {
    margin-bottom: 22px !important;
}

.csc-filter-label {
    display: block !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.6px !important;
    color: #475569 !important;
    margin-bottom: 9px !important;
}

/* ==========================================================
   MENU THỂ LOẠI (DẠNG MENU TỐI GIẢN, KHÔNG BO VIỀN HỘP)
   ========================================================== */
.csc-sidebar-filter ul.csc-category-menu,
ul.csc-category-menu {
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    list-style-type: none !important;
}

.csc-sidebar-filter ul.csc-category-menu li,
.csc-category-menu .csc-cat-menu-item {
    margin: 0 !important;
    padding: 0 !important;
    border-bottom: 1px dashed #f1f5f9;
    list-style: none !important;
    list-style-type: none !important;
}

.csc-sidebar-filter ul.csc-category-menu li::before,
.csc-category-menu .csc-cat-menu-item::before {
    content: none !important;
    display: none !important;
}

.csc-cat-menu-item:last-child {
    border-bottom: none;
}

.csc-cat-menu-link {
    display: flex !important;
    align-items: center !important;
    padding: 8px 10px !important;
    font-size: 13px !important;
    color: #475569 !important;
    border-radius: 6px;
    text-decoration: none !important;
    transition: all 0.15s ease;
}

.csc-cat-menu-link:hover {
    background-color: #f1f5f9;
    color: var(--primary-color, #446084) !important;
    padding-left: 14px !important;
}

.csc-cat-menu-link.active {
    background-color: #f8fafc;
    color: var(--primary-color, #446084) !important;
    font-weight: 700;
}

.csc-cat-menu-link::before,
.csc-cat-menu-link.active::before {
    content: none !important;
    display: none !important;
}

/* Tag Pills 1-Chạm trong Bộ Lọc */
.csc-tag-pills .csc-pill-badge {
    display: inline-block;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #475569;
    background-color: #f1f5f9;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none !important;
}

.csc-tag-pills .csc-pill-badge:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

.csc-tag-pills .csc-pill-badge.active {
    background-color: var(--primary-color, #446084);
    color: #ffffff !important;
    border-color: var(--primary-color, #446084);
}

.csc-tag-pills .csc-pill-badge.is-small {
    padding: 3px 10px;
    font-size: 11px;
}

/* Đồng hồ đếm ngược trang gate */
.csc-timer-number {
    font-size: 52px;
    line-height: 1;
    letter-spacing: -2px;
    color: var(--primary-color, #446084);
    transition: transform 0.2s ease;
}

.csc-timer-number.pulse-tick {
    transform: scale(1.08);
}

/* Thanh progress bar */
.csc-timer-progress {
    width: 100%;
    max-width: 260px;
    height: 6px;
    background-color: #e2e8f0;
    border-radius: 999px;
    margin: 12px auto 0;
    overflow: hidden;
}

.csc-timer-progress .csc-progress-bar {
    display: block;
    height: 100%;
    width: 0%;
    background-color: var(--primary-color, #446084);
    transition: width 1s linear;
}

@keyframes cscPulseEffect {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
    }

    70% {
        box-shadow: 0 0 0 12px rgba(74, 222, 128, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }
}

#csc-btn-download.pulse {
    animation: cscPulseEffect 1.8s infinite;
}

.hide {
    display: none !important;
}

/* ==========================================================
   CSC MODAL SYSTEM (CỐ ĐỊNH SCROLL TRANG NỀN TUYỆT ĐỐI)
   ========================================================== */
html.csc-modal-locked,
body.csc-modal-locked {
    overflow: hidden !important;
    height: 100% !important;
    touch-action: none;
    -ms-touch-action: none;
}

.csc-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999999;
    overflow: hidden;
    padding: 20px 15px;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
}

.csc-modal-overlay.is-open {
    display: flex !important;
    animation: cscFadeIn 0.2s ease-out;
}

.csc-modal-container {
    position: relative;
    background: #ffffff;
    width: 100%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25);
    padding: 28px 24px 20px;
    box-sizing: border-box;
    margin: auto;
    animation: cscScaleUp 0.2s ease-out;
    max-height: 95vh;
    overflow-y: auto;
}

/* Đảm bảo tag trạng thái server không bị vỡ layout bởi class .badge của theme */
.csc-server-tag,
#csc-modal-server-tag,
span#csc-modal-server-tag,
.csc-gate-header .csc-server-tag {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    line-height: 1.4 !important;
    padding: 4px 14px !important;
    border-radius: 999px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    position: static !important;
    margin: 0 auto 8px auto !important;
    background-color: #f1f5f9 !important;
    color: #334155 !important;
    border: 1px solid #e2e8f0 !important;
    text-transform: none !important;
    box-sizing: border-box !important;
}

.csc-modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    background: transparent !important;
    border: none !important;
    font-size: 22px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    color: #64748b !important;
    cursor: pointer;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease-in-out;
    padding: 0 !important;
    margin: 0 !important;
    z-index: 10;
    box-sizing: border-box !important;
    outline: none !important;
    box-shadow: none !important;
    aspect-ratio: 1 / 1 !important;
}

.csc-modal-close:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}

/* Nút báo link hỏng không viền dạng inline SVG bên phải nút tải */
.csc-report-link-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 4px 8px !important;
    margin: 0 !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #64748b !important;
    cursor: pointer !important;
    text-decoration: none !important;
    line-height: 1.4 !important;
    transition: color 0.15s ease-in-out;
}

.csc-report-link-btn:hover:not(:disabled) {
    color: #dc2626 !important;
    background: transparent !important;
}

.csc-report-link-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed !important;
}

.csc-report-link-btn svg {
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ==========================================================
   MODAL ĐỌC TRỰC TUYẾN ONLINE (ZERO GAP 2 ĐẦU & ZOOM KHÔNG GIỚI HẠN)
   ========================================================== */
#csc-read-online-overlay {
    padding: 0 !important;
}

.csc-read-online-container {
    max-width: 100vw !important;
    width: 100vw !important;
    height: 100vh !important;
    padding: 0 !important;
    background: #ffffff !important;
    border-radius: 0 !important;
    border: none !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: none !important;
}

.csc-reader-header {
    height: 44px;
    min-height: 44px;
    padding: 0 16px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    box-sizing: border-box;
}

#csc-reader-wrapper {
    flex: 1;
    width: 100%;
    height: calc(100% - 44px);
    background: #ffffff;
    position: relative;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    text-align: center;
    padding: 0 0 70px;
}

#csc-pdf-canvas-container {
    display: inline-block;
    margin: 0 auto;
    min-width: 100%;
}

.csc-pdf-page-canvas {
    display: block !important;
    margin: 0 auto !important;
    box-shadow: none !important;
    border: none !important;
    border-radius: 0 !important;
    background: #ffffff !important;
    max-width: none !important;
    height: auto !important;
    transition: width 0.15s ease-out;
}

.csc-reader-floating-toolbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 41, 59, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    z-index: 9999999;
    user-select: none;
}

.csc-reader-floating-toolbar button {
    background: transparent;
    border: none;
    color: #ffffff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s ease;
    padding: 0;
    margin: 0;
}

.csc-reader-floating-toolbar button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.csc-page-pill {
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.csc-divider-vertical {
    width: 1px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
}

@media screen and (max-width: 767px) {
    .csc-reader-header {
        height: 40px;
        min-height: 40px;
        padding: 0 10px;
    }

    .csc-reader-header strong {
        font-size: 13px !important;
        max-width: 80%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #csc-reader-wrapper {
        height: calc(100% - 40px) !important;
        padding: 0 0 65px;
    }

    .csc-reader-floating-toolbar {
        bottom: 14px;
        padding: 4px 10px;
        gap: 8px;
    }
}

@keyframes cscFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes cscScaleUp {
    from {
        transform: scale(0.97);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   CSC SERVER LIST (Dạng danh sách hàng dọc tối ưu hiển thị)
   ========================================================================== */
.csc-server-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.csc-server-row-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 18px;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.csc-server-row-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    background-color: #f8fafc;
}

.csc-server-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    min-width: 0;
}

.csc-server-name-title {
    display: inline-flex;
    align-items: center;
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
}

.csc-server-meta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.csc-format-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #f1f5f9;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
    letter-spacing: 0.5px;
}

.csc-size-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

.csc-server-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    margin-left: 12px;
}

.csc-server-actions .button {
    margin-bottom: 0 !important;
    white-space: nowrap !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 0 16px !important;
    height: 38px !important;
    line-height: 38px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    border-radius: 6px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.3px !important;
}

.csc-server-actions .csc-btn-read-online {
    border: 1px solid #cbd5e1 !important;
    color: #334155 !important;
    background: #ffffff !important;
}

.csc-server-actions .csc-btn-read-online:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #94a3b8 !important;
}

.csc-server-actions .csc-open-download-modal {
    background-color: var(--primary-color, #446084) !important;
    border-color: var(--primary-color, #446084) !important;
    color: #ffffff !important;
}

.csc-server-actions .csc-open-download-modal:hover {
    opacity: 0.92;
    transform: translateY(-1px);
}

/* Responsive Mobile cho Danh sách Server */
@media (max-width: 640px) {
    .csc-server-row-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 14px;
    }

    .csc-server-info {
        width: 100%;
        justify-content: space-between;
    }

    .csc-server-actions {
        width: 100%;
        margin-left: 0;
        display: flex;
        gap: 8px;
    }

    .csc-server-actions .button {
        flex: 1 1 50%;
        text-align: center;
        padding: 0 10px !important;
    }
}

/* ==========================================================================
   CSC BOOK FAVORITES (Nút Yêu Thích & Hiệu ứng)
   ========================================================================== */
.csc-fav-btn {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    max-width: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    border: 1px solid rgba(226, 232, 240, 0.8) !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08) !important;
    color: #94a3b8 !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 !important;
    z-index: 5 !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    outline: none !important;
}

.csc-fav-btn:hover {
    background: #ffffff !important;
    color: #e11d48 !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 10px rgba(225, 29, 72, 0.2) !important;
}

.csc-fav-btn.is-favorited {
    background: #ffffff !important;
    color: #e11d48 !important;
    border-color: #fecdd3 !important;
}

.csc-fav-btn.is-favorited .csc-fav-heart-icon {
    fill: #e11d48 !important;
    stroke: #e11d48 !important;
}

.csc-fav-btn .csc-fav-heart-icon {
    transition: transform 0.2s ease, fill 0.2s ease;
}

/* Animation khi bấm tym */
@keyframes cscHeartBounce {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.35);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

.csc-heart-bounce {
    animation: cscHeartBounce 0.35s ease-out forwards;
}

/* Toast / Popover thông báo Thêm / Xóa Yêu thích */
.csc-fav-popover {
    position: absolute;
    z-index: 99999;
    background: #0f172a;
    color: #ffffff;
    padding: 6px 12px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.35;
    border-radius: 6px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 4px 8px -2px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px) scale(0.95);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.csc-fav-popover.is-active {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.csc-fav-popover::after {
    content: '';
    position: absolute;
    bottom: -4px;
    right: 14px;
    width: 8px;
    height: 8px;
    background: #0f172a;
    transform: rotate(45deg);
}

.csc-fav-popover.csc-fav-popover-below::after {
    bottom: auto;
    top: -4px;
}

.csc-fav-popover-added {
    background: #0f172a;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.csc-fav-popover-added .csc-popover-icon {
    color: #f43f5e;
}

.csc-fav-popover-removed {
    background: #1e293b;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.csc-fav-popover-removed .csc-popover-icon {
    color: #94a3b8;
}

/* Tùy chỉnh danh sách shortcode [csc_favorites] */
.csc-favorites-container {
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

/* ==========================================================================
   AMAZON STYLE: Nút Đọc thử, Nghe thử & Ribbon Thông số sách
   ========================================================================== */
.csc-cover-action-buttons {
    display: flex !important;
    gap: 10px !important;
    padding: 0 16px !important;
    margin-top: 14px !important;
    margin-bottom: 12px !important;
    width: 100% !important;
    box-sizing: border-box !important;
    align-items: stretch !important;
}

.csc-pill-action-btn {
    flex: 1 1 0 !important; /* Mỗi nút chiếm 50% đều đặn, hoặc 100% nếu chỉ có 1 nút */
    min-width: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 0 14px !important;
    height: 42px !important;
    line-height: 42px !important;
    border-radius: 999px !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    outline: none !important;
    border: 1px solid #cbd5e1 !important;
    background: #ffffff !important;
    color: #1e293b !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    box-sizing: border-box !important;
    white-space: nowrap !important;
}

.csc-pill-action-btn:hover {
    border-color: #94a3b8 !important;
    background: #f8fafc !important;
    color: #0f172a !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08) !important;
}

.csc-pill-action-btn svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: currentColor;
}

.csc-pill-action-btn span {
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.csc-pill-action-btn.csc-btn-read-online {
    color: #0284c7 !important;
    border-color: #bae6fd !important;
    background: #f0f9ff !important;
}

.csc-pill-action-btn.csc-btn-read-online:hover {
    background: #0284c7 !important;
    color: #ffffff !important;
    border-color: #0284c7 !important;
}

.csc-pill-action-btn.csc-btn-audio-sample {
    color: #b45309 !important;
    border-color: #fde68a !important;
    background: #fffbeb !important;
}

.csc-pill-action-btn.csc-btn-audio-sample:hover {
    background: #f59e0b !important;
    color: #ffffff !important;
    border-color: #f59e0b !important;
}

/* Khung thông số Ribbon Amazon ngang */
.csc-amazon-specs-bar {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.csc-amazon-specs-track {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    min-width: 520px;
}

.csc-spec-col {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 14px;
    position: relative;
}

.csc-spec-col:not(:last-child)::after {
    content: "";
    position: absolute;
    right: 0;
    top: 20%;
    bottom: 20%;
    width: 1px;
    background-color: #f1f5f9;
}

.csc-spec-title {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    margin-bottom: 6px;
    white-space: nowrap;
}

.csc-spec-icon-wrap {
    color: #334155;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.csc-spec-value {
    font-size: 13px;
    color: #0f172a;
    line-height: 1.3;
    white-space: nowrap;
}

/* ==========================================================================
   AUDIBLE CLOUD PLAYER MODAL (AMAZON STYLE)
   ========================================================================== */
.csc-audible-player-modal {
    max-width: 420px !important;
    width: 92% !important;
    background: #ffffff !important;
    border-radius: 16px !important;
    padding: 24px 20px 18px !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35) !important;
}

.csc-audible-header {
    margin-bottom: 12px;
}

.csc-audible-cover-wrap {
    width: 170px;
    height: 170px;
    margin: 0 auto 16px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    background: #f1f5f9;
}

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

.csc-audible-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e2e8f0;
}

.csc-audible-btn-get {
    background: #f59e0b !important;
    border: none !important;
    color: #111827 !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    padding: 7px 24px !important;
    border-radius: 999px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    outline: none !important;
    box-shadow: 0 2px 5px rgba(245, 158, 11, 0.3) !important;
}

.csc-audible-btn-get:hover {
    background: #d97706 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(217, 119, 6, 0.4) !important;
}

.csc-audible-preview-badge {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 4px;
}

.csc-audible-book-name {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.35;
}

.csc-audible-author-name {
    font-size: 13px;
    color: #64748b;
    margin-top: 2px;
}

/* Thanh tua bài nhạc kiểu Audible màu cam */
.csc-audible-progress-bar-wrap {
    position: relative;
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
}

.csc-audible-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #f59e0b;
    border-radius: 999px;
    pointer-events: none;
}

.csc-audible-progress-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    background: #f59e0b;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    transition: transform 0.1s ease;
}

.csc-audible-progress-bar-wrap:hover .csc-audible-progress-thumb {
    transform: translate(-50%, -50%) scale(1.2);
}

.csc-audible-time-row {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    user-select: none;
}

.csc-audible-time-left {
    font-weight: 600;
    color: #334155;
}

/* Nút điều khiển Tua & Play/Pause */
.csc-audible-ctrl-btn {
    position: relative;
    background: transparent !important;
    border: none !important;
    color: #334155 !important;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0 !important;
    margin: 0 14px !important;
    transition: all 0.15s ease;
}

.csc-audible-ctrl-btn:hover {
    background: #f1f5f9 !important;
    color: #0f172a !important;
}

.csc-audible-ctrl-btn .csc-ctrl-num {
    position: absolute;
    font-size: 9px;
    font-weight: 700;
    top: 52%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

.csc-audible-play-pause-btn {
    width: 58px !important;
    height: 58px !important;
    min-width: 58px !important;
    min-height: 58px !important;
    border-radius: 50% !important;
    background: #0f172a !important;
    color: #ffffff !important;
    border: none !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 8px 18px -4px rgba(15, 23, 42, 0.35) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
}

.csc-audible-play-pause-btn:hover {
    background: #1e293b !important;
    transform: scale(1.06);
    box-shadow: 0 12px 22px -4px rgba(15, 23, 42, 0.45) !important;
}

.csc-audible-play-pause-btn .csc-icon-play {
    margin-left: 3px;
}

/* Thanh công cụ dưới cùng: Speed, Restart, Bookmark */
.csc-audible-bottom-bar {
    border-top: 1px solid #f1f5f9;
}

.csc-audible-tool-btn {
    background: transparent !important;
    border: none !important;
    color: #64748b !important;
    cursor: pointer !important;
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 6px 12px !important;
    margin: 0 !important;
    border-radius: 8px !important;
    transition: all 0.15s ease !important;
    outline: none !important;
    min-width: 60px;
}

.csc-audible-tool-btn:hover {
    color: #0f172a !important;
    background: #f8fafc !important;
}

.csc-speed-text {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    color: #0f172a;
}

.csc-tool-label {
    font-size: 11px;
    font-weight: 500;
    margin-top: 2px;
}

/* ==========================================================================
   AMAZON AUDIBLE: CHAPTERS PANEL (DANH SÁCH CHƯƠNG THEO HÌNH MẪU AMAZON)
   ========================================================================== */
.csc-audible-player-modal {
    position: relative;
    overflow: hidden;
}

.csc-audible-chapters-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    z-index: 10;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    border-radius: 12px;
    animation: cscSlideUpPanel 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cscSlideUpPanel {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.csc-chapters-header {
    border-bottom: 1px solid #e2e8f0;
    padding: 14px 18px !important;
}

.csc-close-chapters-btn {
    background: transparent !important;
    border: none !important;
    font-size: 26px !important;
    color: #64748b !important;
    cursor: pointer !important;
    line-height: 1 !important;
    padding: 0 4px !important;
}

.csc-close-chapters-btn:hover {
    color: #0f172a !important;
}

.csc-chapters-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.csc-chapter-item {
    padding: 12px 18px !important;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s ease;
}

.csc-chapter-item:hover {
    background: #f8fafc;
}

.csc-chapter-item.is-active {
    background: #fef3c7;
}

.csc-chapter-item.is-active .csc-chapter-name {
    color: #b45309;
}

.csc-chapter-name {
    font-size: 14px;
    color: #1e293b;
    flex: 1;
}

.csc-chapter-time {
    font-size: 13px;
    color: #64748b;
    margin-left: 12px;
}

/* ==========================================================================
   AMAZON STYLE: IMAGE HOVER ZOOM FLYOUT (KÍNH LÚP PHÓNG TO)
   ========================================================================== */
.csc-zoom-container {
    position: relative;
    cursor: crosshair;
    overflow: hidden;
    border-radius: 6px;
    display: block;
}

/* Thấu kính mờ trên ảnh gốc */
.csc-zoom-lens {
    position: absolute;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(15, 23, 42, 0.3);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
    display: none;
    pointer-events: none;
    z-index: 4;
}

/* Cửa sổ phóng to bên phải bao phủ khu vực nội dung giống hệt Amazon */
.csc-zoom-flyout {
    position: absolute;
    top: 0;
    left: calc(100% + 18px);
    width: 480px;
    height: 520px;
    background-repeat: no-repeat;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08);
    display: none;
    z-index: 999999 !important;
    pointer-events: none;
    animation: cscFadeIn 0.15s ease-out;
    background-color: #fff;
    overflow: hidden;
}

/* Ẩn tính năng zoom kính lúp trên màn hình nhỏ hoặc cảm ứng mobile */
@media (max-width: 850px) {

    .csc-zoom-flyout,
    .csc-zoom-lens {
        display: none !important;
    }

    .csc-zoom-container {
        cursor: default;
    }
}

/* ==========================================================================
   AMAZON MOBILE CAROUSEL: NATIVE CSS SCROLL-SNAP SLIDER (CHUẨN VUỐT CHẠM CẢM ỨNG)
   ========================================================================== */
.csc-mobile-slider-wrapper {
    position: relative;
    width: 100%;
}

/* Mặc định trên Desktop: Chỉ hiện bìa sách bình thường, KHÔNG trượt kéo */
.csc-mobile-carousel {
    display: block;
    width: 100%;
}

.csc-cell-cover {
    width: 100%;
}

.csc-cell-details {
    display: none !important;
}

.csc-carousel-dots-wrap {
    display: none;
}

/* Trên Mobile / Tablet (< 850px): Chuyển thành CSS Scroll-Snap Swipe Slider */
@media (max-width: 850px) {
    .csc-mobile-slider-wrapper {
        overflow: hidden;
    }

    .csc-mobile-carousel {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-snap-type: x mandatory !important;
        scroll-behavior: smooth !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        /* Firefox */
        -ms-overflow-style: none !important;
        /* IE/Edge */
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .csc-mobile-carousel::-webkit-scrollbar {
        display: none !important;
        /* Chrome / Safari */
    }

    .csc-carousel-cell {
        flex: 0 0 100% !important;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        scroll-snap-align: start !important;
        scroll-snap-stop: always !important;
        box-sizing: border-box !important;
    }

    .csc-cell-cover {
        display: block !important;
    }

    .csc-cell-details {
        display: block !important;
        box-sizing: border-box !important;
    }

    .csc-amazon-details-card {
        background: #ffffff;
        border-radius: 8px;
        border: 1px solid #e2e8f0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        overflow-y: auto;
        box-sizing: border-box;
        height: 100%;
    }

    .csc-detail-row {
        gap: 12px;
        align-items: flex-start;
    }

    .csc-detail-icon {
        color: #475569;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 24px;
        height: 24px;
        flex-shrink: 0;
    }

    /* Hiển thị dãy chấm tròn Dots phân trang kiểu Amazon dưới slider */
    .csc-carousel-dots-wrap {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 6px !important;
        margin: 12px 0 6px 0 !important;
        padding: 0 !important;
    }

    .csc-carousel-dots-wrap .csc-dot {
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: #cbd5e1;
        cursor: pointer;
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
        display: inline-block;
    }

    .csc-carousel-dots-wrap .csc-dot.is-active {
        background: #0f172a;
        transform: scale(1.3);
    }
}

/* ==========================================================================
   CSC BOOK DESCRIPTION: EXPAND / COLLAPSE (EQUAL HEIGHT SIDEBAR)
   ========================================================================== */
.csc-book-desc-section {
    position: relative;
    margin-bottom: 16px !important;
}

.csc-book-desc-wrapper {
    position: relative;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.csc-book-desc-wrapper.is-collapsed {
    max-height: 180px;
}

.csc-book-desc-wrapper.is-collapsed .csc-desc-fade-overlay {
    display: block;
}

.csc-desc-fade-overlay {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.85) 60%, #ffffff 100%);
    pointer-events: none;
    z-index: 2;
}

.csc-desc-toggle-wrap {
    margin-top: 10px !important;
    margin-bottom: 12px !important;
    position: relative;
    z-index: 5;
    text-align: center;
}

.csc-desc-toggle-btn {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    color: #1e293b !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 7px 18px !important;
    border-radius: 20px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
    line-height: 1.4 !important;
}

.csc-desc-toggle-btn:hover {
    background: #eff6ff !important;
    border-color: #3b82f6 !important;
    color: #1d4ed8 !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(37, 99, 235, 0.15) !important;
}

.csc-desc-chevron-icon {
    transition: transform 0.25s ease;
}

.csc-desc-section.is-expanded .csc-desc-chevron-icon {
    transform: rotate(180deg);
}

.csc-amazon-specs-bar {
    clear: both;
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   AMAZON KINDLE CLOUD READER: FULLSCREEN MODAL (READ SAMPLE)
   UI/UX PRO MAX: Tối ưu chuẩn Amazon, hỗ trợ Themes hoàn hảo, không viền trắng
   ========================================================================== */
.csc-kindle-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #ffffff;
    z-index: 9999999;
    display: flex;
    flex-direction: column;
}

.csc-kindle-app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #ffffff;
    color: #111827;
    position: relative;
    overflow: hidden;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* 1. Theme Trắng chuẩn */
.csc-kindle-app.theme-white {
    background: #ffffff !important;
    color: #111827 !important;
}

.csc-kindle-app.theme-white .csc-kindle-topbar,
.csc-kindle-app.theme-white .csc-kindle-bottombar {
    background: #f8fafc !important;
    border-color: #e2e8f0 !important;
    color: #1e293b !important;
}

/* 2. Theme Sepia (Vàng giấy cổ dịu mắt) */
.csc-kindle-app.theme-sepia {
    background: #fbf0d9 !important;
    color: #382c1e !important;
}

.csc-kindle-app.theme-sepia .csc-kindle-topbar,
.csc-kindle-app.theme-sepia .csc-kindle-bottombar {
    background: #f2e3c6 !important;
    border-color: #e5d1a8 !important;
    color: #382c1e !important;
}

.csc-kindle-app.theme-sepia .csc-kindle-aa-panel,
.csc-kindle-app.theme-sepia .csc-kindle-toc-drawer {
    background: #fbf0d9 !important;
    border-color: #e5d1a8 !important;
    color: #382c1e !important;
}

.csc-kindle-app.theme-sepia .csc-kindle-nav-btn {
    background: rgba(56, 44, 30, 0.08) !important;
    border-color: rgba(56, 44, 30, 0.15) !important;
    color: #382c1e !important;
}

.csc-kindle-app.theme-sepia .csc-kindle-nav-btn:hover {
    background: rgba(56, 44, 30, 0.16) !important;
}

/* 3. Theme Dark (Tối chuẩn AMOLED chống mỏi mắt) */
.csc-kindle-app.theme-dark {
    background: #121212 !important;
    color: #e2e8f0 !important;
}

.csc-kindle-app.theme-dark .csc-kindle-topbar,
.csc-kindle-app.theme-dark .csc-kindle-bottombar {
    background: #1e1e1e !important;
    border-color: #2d2d2d !important;
    color: #e2e8f0 !important;
}

.csc-kindle-app.theme-dark .csc-kindle-aa-panel,
.csc-kindle-app.theme-dark .csc-kindle-toc-drawer {
    background: #1e1e1e !important;
    border-color: #333333 !important;
    color: #e2e8f0 !important;
}

.csc-kindle-app.theme-dark .csc-aa-label,
.csc-kindle-app.theme-dark .csc-toc-header strong,
.csc-kindle-app.theme-dark .csc-toc-entry {
    color: #e2e8f0 !important;
}

.csc-kindle-app.theme-dark .csc-toc-entry:hover {
    background: #2a2a2a !important;
}

.csc-kindle-app.theme-dark .csc-kindle-nav-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.15) !important;
    color: #ffffff !important;
}

.csc-kindle-app.theme-dark .csc-kindle-nav-btn:hover {
    background: rgba(255, 255, 255, 0.22) !important;
}

.csc-kindle-app.theme-dark .csc-aa-btn {
    background: #2a2a2a !important;
    border-color: #444444 !important;
    color: #ffffff !important;
}

/* 1. Header Kindle trên cùng */
.csc-kindle-topbar {
    height: 52px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.csc-kindle-back-btn {
    background: transparent !important;
    border: none !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: inherit !important;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.15s ease;
    margin: 0px;
}

.csc-kindle-back-btn:hover {
    background: rgba(0, 0, 0, 0.06) !important;
}

.csc-kindle-title-center {
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
}

.csc-kindle-book-title {
    font-weight: 700;
}

.csc-kindle-actions-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.csc-kindle-icon-btn {
    background: transparent !important;
    border: none !important;
    color: inherit !important;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s ease;
    margin: 0px;
}

.csc-kindle-icon-btn:hover {
    background: rgba(0, 0, 0, 0.08) !important;
}

/* 2. Sân khấu đọc sách (Stage & Viewport) */
.csc-kindle-stage {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0;
    background: transparent;
}

.csc-kindle-viewport-wrapper {
    width: 100%;
    max-width: 1240px;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.csc-kindle-viewer {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Iframe lồng bên trong ePub.js: Ép nền trong suốt hoặc theo theme */
.csc-kindle-viewer iframe {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

/* NÚT LẬT TRANG TRÒN CÂN ĐỐI (UI/UX PRO MAX: Rõ ràng, to đẹp, căn giữa) */
.csc-kindle-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    min-width: 52px;
    min-height: 52px;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(0, 0, 0, 0.12);
    color: #1e293b;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 15;
    padding: 0 !important;
    margin: 0 !important;
    outline: none !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.csc-kindle-nav-btn:hover {
    background: #ffffff !important;
    transform: translateY(-50%) scale(1.12);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    color: #0284c7;
}

.csc-kindle-nav-btn svg {
    display: block;
    width: 26px;
    height: 26px;
}

.csc-nav-prev {
    left: 24px;
}

.csc-nav-next {
    right: 24px;
}

/* Spinner Loading */
.csc-kindle-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #64748b;
    font-size: 13px;
    z-index: 6;
}

.csc-spinner-ring {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top: 3px solid #0284c7;
    border-radius: 50%;
    animation: cscSpin 0.8s linear infinite;
}

@keyframes cscSpin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 3. Footer Kindle Scrubber */
.csc-kindle-bottombar {
    height: 48px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 30px;
    flex-shrink: 0;
    z-index: 10;
}

.csc-kindle-scrubber-track {
    position: relative;
    width: 100%;
    max-width: 680px;
    height: 5px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    margin: 0 auto;
    cursor: pointer;
}

.csc-kindle-scrubber-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: #0284c7;
    border-radius: 3px;
}

.csc-kindle-scrubber-thumb {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 13px;
    height: 13px;
    background: #0284c7;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.csc-kindle-loc-info {
    text-align: center;
    font-size: 11px;
    color: inherit;
    opacity: 0.8;
    margin-top: 4px;
    font-weight: 500;
}

/* Dropdown Aa Settings: Căn chỉnh tròn trịa tỉ lệ 1:1 */
.csc-kindle-aa-panel {
    position: absolute;
    top: 54px;
    right: 20px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.22);
    z-index: 30;
    width: 280px;
}

.csc-aa-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.csc-aa-label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
}

.csc-aa-font-size-ctrls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.csc-aa-btn {
    border: 1px solid #cbd5e1 !important;
    background: #f8fafc !important;
    padding: 6px 12px !important;
    border-radius: 6px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    font-size: 13px !important;
    line-height: 1 !important;
}

.csc-aa-btn:hover {
    background: #f1f5f9 !important;
    color: #0284c7 !important;
}

.csc-aa-themes {
    display: flex;
    gap: 14px;
}

/* Các nút hình tròn chọn Theme 1:1 chuẩn xác */
.csc-theme-circle {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    min-height: 32px !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.csc-theme-circle:hover {
    transform: scale(1.1);
}

.csc-theme-circle.is-white {
    background: #ffffff !important;
    border: 2px solid #cbd5e1 !important;
}

.csc-theme-circle.is-sepia {
    background: #fbf0d9 !important;
    border: 2px solid #d6be96 !important;
}

.csc-theme-circle.is-dark {
    background: #121212 !important;
    border: 2px solid #475569 !important;
}

.csc-theme-circle.is-active {
    box-shadow: 0 0 0 3px #0284c7 !important;
    border-color: transparent !important;
}

/* Drawer Mục lục TOC */
.csc-kindle-toc-drawer {
    position: absolute;
    top: 52px;
    left: 0;
    width: 340px;
    height: calc(100% - 52px);
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.12);
    z-index: 25;
    display: flex;
    flex-direction: column;
}

.csc-toc-content-list {
    flex: 1;
    overflow-y: auto;
}

.csc-toc-entry {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    color: inherit;
}

.csc-toc-entry:hover {
    background: rgba(0, 0, 0, 0.04);
    color: #0284c7;
}

/* Mobile responsive */
@media (max-width: 850px) {
    .csc-kindle-topbar {
        padding: 0 10px;
        height: 48px;
    }

    /* Thu nhỏ nút và cho nút lật trang nằm thấp ở 2 mép dưới hoặc cạnh thanh tiến trình để không đè lên giữa trang sách */
    .csc-kindle-nav-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        top: auto;
        bottom: 24px;
        transform: none;
        background: rgba(255, 255, 255, 0.88);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
        opacity: 0.85;
    }

    .csc-kindle-nav-btn:hover,
    .csc-kindle-nav-btn:active {
        transform: scale(1.08);
        opacity: 1;
    }

    .csc-kindle-nav-btn svg {
        width: 18px;
        height: 18px;
    }

    .csc-nav-prev {
        left: 16px;
    }

    .csc-nav-next {
        right: 16px;
    }

    .csc-kindle-title-center {
        display: none;
    }

    /* Đảm bảo dropdown panel Aa trên mobile có kích thước vừa vặn màn hình */
    .csc-kindle-aa-panel {
        top: 50px;
        right: 10px;
        width: calc(100vw - 20px);
        max-width: 320px;
        padding: 14px;
    }

    .csc-kindle-viewport-wrapper {
        padding: 0;
        box-sizing: border-box;
    }

    .csc-kindle-toc-drawer {
        width: 85vw;
        max-width: 300px;
    }
}