/* Prevent text selection on btn-add-text */
.btn-add-text {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Completely disable hover effects for btn-add */
#btn-add {
    pointer-events: auto !important;
}

/* Bootstrap Banner Custom Styles */
.custom-carousel-width {
    max-width: 1168px;
    margin: 0 auto;
}

.carousel-item img {
    width: 100%;
    /* 1168 / 380.42 approx ratio from user reference */
    aspect-ratio: 1168 / 380.42;
    object-fit: cover;
}


/* Mobile Category Button & Grid Adjustments to match reference image */
@media (max-width: 768px) {
    .categories {
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 10px 0 !important;
        overflow: visible !important;
    }

    .categories button {
        flex: 0 0 auto !important;
        min-width: 80px !important;
        padding: 6px 12px !important;
        font-weight: 800 !important;
        font-size: 15px !important;
        height: 38px !important;
        border-radius: 999px !important;
        margin-bottom: 2px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Match the 2-column grid in user screenshot */
    .grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .card .cover {
        height: 200px !important;
        /* Adjust height for 2-column layout */
    }

    .card .body {
        padding: 12px !important;
    }

    .card h3 {
        font-size: 14px !important;
        font-weight: 800 !important;
    }

    /* Hide carousel navigation arrows on mobile */
    .carousel-control-prev,
    .carousel-control-next {
        display: none !important;
    }
}

/* Global Bold for Categories (Desktop & Mobile) */
.categories button {
    font-weight: 700 !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Announcement Button Responsive Display */
/* Desktop: Show absolute positioned button, hide mobile button */
@media (min-width: 769px) {
    #announcement-float-btn {
        display: flex !important;
    }

    #announcement-float-btn-mobile {
        display: none !important;
    }
}

/* Mobile: Hide desktop button, show mobile button */
@media (max-width: 768px) {
    #announcement-float-btn {
        display: none !important;
    }

    #announcement-float-btn-mobile {
        display: flex !important;
    }
}

/* --- Bookcase Refinement V4 (CSS Buttons) --- */

/* Main Tab Styles */
.main-tab-btn {
    background: transparent;
    border: none;
    border-bottom: none;
    color: #999;
    padding: 0 24px;
    height: 48px;
    font-size: 18px;
    font-weight: bold;
    cursor: default;
    margin-right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    min-width: 100px;
    position: relative;
    margin-bottom: 0;
}

.bookcase-list-clean {
    list-style: none;
    padding-left: 0;
    margin-left: 0;
}

.book-list-row {
    margin-bottom: 8px;
}

.book-list-title {
    font-weight: bold;
    color: #311C20;
    text-decoration: none;
}

.book-list-title:hover {
    text-decoration: underline;
}

.book-list-author {
    font-weight: normal;
    color: #6A7282;
}

.main-tab-btn.active {
    width: 248px !important;
    height: 53px !important;
    background: #FFFFFF !important;
    color: #FF9F43 !important;
    /* Orange Text */
    border: 1px solid transparent !important;
    /* Clear other borders */
    border-bottom: 3px solid #FF9F43 !important;
    /* Specific Bottom Stroke */
    border-radius: 10px 10px 0 0 !important;
    /* Top Radius 10px */

    /* Layout */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    /* Reset padding to assume fixed size handles it */
    margin-right: 0 !important;

    /* Ensure it sits correctly */
    z-index: 5 !important;
    box-sizing: border-box !important;
    /* Include border in height/width */
}

.main-tab-btn.active img {
    height: 24px !important;
    width: auto !important;
    display: block !important;
}

/* Global Banner Style Refinement */
.banner {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    max-width: 992px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Account Section Layout */
.account {
    max-width: 992px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* Card Container */
.account-card {
    background: #fff;
    border: none !important;
    border-top: 1px solid rgba(74, 85, 101, 0.2) !important;
    border-radius: 0 12px 12px 12px;
    padding: 24px 30px 30px 30px;
    /* Top padding 24px (White) */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
    min-height: 500px;
    position: relative;
    z-index: 1;
    margin-top: 0;
}

/* Sub-tabs (Unified Toggle Button Group) */
.sub-tabs-container {
    display: inline-flex;
    gap: 0;
    background: #E4E6EB !important;
    border-radius: 20px !important;
    overflow: hidden !important;
    margin-top: 0 !important;
    margin-bottom: 24px;
    border: none;
    box-sizing: border-box;
    width: auto !important;
    height: auto !important;
}

.sub-tab-btn {
    appearance: none;
    border: none !important;
    background: transparent !important;
    /* Default inactive transparent */
    color: #333 !important;
    font-size: 14px !important;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s ease;
    padding: 8px 16px !important;
    border-radius: 20px !important;
    white-space: nowrap;
}

.sub-tab-btn.published,
.sub-tab-btn.collection {
    width: auto !important;
    flex: none !important;
}

/* Active State (Orange Pill) */
.sub-tab-btn.active {
    background: #FFA94D !important;
    color: #FFFFFF !important;
}

.sub-tab-btn svg {
    width: 16px !important;
    height: 16px !important;
}

.sub-tab-btn.active svg {
    stroke: #FFFFFF;
}

/* Heart Icon specific logic */
.sub-tab-btn.collection svg {
    fill: currentColor;
    stroke: none;
}

/* Book List Text Styles */
.bookcase-list-clean {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.book-list-row {
    font-size: 15px;
    color: #333;
    padding-bottom: 4px;
    display: flex;
    align-items: baseline;
}

.book-list-title {
    font-weight: 500;
    color: #111;
    margin-right: 8px;
    text-decoration: none;
}

.book-list-title:hover {
    color: #FFA94D;
}

.book-list-author {
    color: #999;
    font-size: 14px;
}

.bookcase-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px 16px;
}

.bookcase-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bookcase-cover-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 140/200;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.bookcase-cover-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.bookcase-cover-wrap:hover img {
    transform: scale(1.05);
}

/* Parity with homepage heart icon positioning on covers (No white background as requested) */
.bookcase-cover-wrap .btn-icon.fav {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: 35px !important;
    /* User Spec: 35px */
    height: 35px !important;
    /* User Spec: 35px */
    background-size: 20px 20px !important;
    /* Slightly larger icon for 35x35 container */
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
    /* Add a small drop shadow to the icon itself for visibility on covers */
}

/* Mobile Refinements */
@media (max-width: 768px) {

    .banner,
    .account {
        max-width: 345px !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    .container>section:first-of-type {
        margin-top: 0 !important;
    }

    #back-home {
        margin-top: 8px !important;
        margin-bottom: 8px !important;
    }

    .banner {
        padding: 24px 12px !important;
        margin-bottom: 24px !important;
    }

    .account-card {
        padding: 24px 12px 30px 12px !important;
    }

    .main-tab-btn.active {
        width: 86px !important;
        height: 37px !important;
        font-size: 14px !important;
    }

    .main-tab-btn.active img {
        height: 16px !important;
        width: 16px !important;
        margin-right: 4px !important;
    }

    .sub-tabs-container {
        width: auto !important;
        /* 移除固定寬度 */
        margin-left: 0 !important;
        margin-right: auto !important;
        height: auto !important;
        border-radius: 20px !important;
        margin-bottom: 24px !important;
        gap: 0 !important;
        overflow: hidden !important;
    }

    .sub-tab-btn {
        font-size: 14px !important;
        gap: 6px !important;
        letter-spacing: normal !important;
        height: auto !important;
        flex: 1 !important;
        width: auto !important;
        min-width: 0 !important;
        padding: 8px 12px !important;
    }

    .sub-tab-btn svg {
        width: 16px !important;
        height: 16px !important;
    }

    .bookcase-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 16px 12px;
    }

    .bookcase-cover-wrap {
        width: 80px !important;
        height: 110px !important;
        aspect-ratio: 80/110 !important;
    }

    .bookcase-title {
        font-size: 13px !important;
    }

    .bookcase-author {
        font-size: 11px !important;
    }
}