/* =============================================
   Library 2.5D — CSS 3D Bookshelf Experience
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;600;700;800;900&family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --lib3d-font: 'Noto Sans Thai', 'Inter', system-ui, sans-serif;
    --lib3d-accent: #7c3aed;
    --lib3d-accent-light: #a78bfa;
    --lib3d-accent-glow: rgba(124, 58, 237, 0.4);
    --lib3d-glass-bg: rgba(15, 10, 30, 0.65);
    --lib3d-glass-border: rgba(255, 255, 255, 0.08);
    --lib3d-glass-blur: 20px;
    --lib3d-wood-light: #c4915a;
    --lib3d-wood-mid: #8b5e3c;
    --lib3d-wood-dark: #6b4226;
    --lib3d-shelf-height: 260px;
    --lib3d-book-w: 130px;
    --lib3d-book-h: 180px;
    --lib3d-spine-w: 22px;
    --lib3d-transition: cubic-bezier(0.23, 1, 0.32, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Page Base ─── */
body.lib3d-body {
    font-family: var(--lib3d-font);
    background: #0a0a1a;
    color: #fff;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Background Scene ─── */
.lib3d-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 0.8s ease;
}

.lib3d-bg-overlay {
    position: fixed;
    inset: 0;
    z-index: 1;
    background: linear-gradient(
        180deg,
        rgba(10, 10, 26, 0.55) 0%,
        rgba(10, 10, 26, 0.45) 30%,
        rgba(10, 10, 26, 0.65) 70%,
        rgba(10, 10, 26, 0.85) 100%
    );
    pointer-events: none;
}

/* ─── Navbar ─── */
.lib3d-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: rgba(10, 10, 26, 0.6);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lib3d-nav-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.15rem;
    color: #fff;
    text-decoration: none;
}

.lib3d-nav-brand i {
    background: linear-gradient(135deg, #7c3aed, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 1.3rem;
}

.lib3d-nav-links {
    display: flex;
    gap: 4px;
}

.lib3d-nav-links a {
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.25s;
}

.lib3d-nav-links a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.lib3d-nav-links a.active {
    color: #fff;
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.3), rgba(59, 130, 246, 0.3));
}

/* ─── Scene Picker ─── */
.lib3d-scene-picker {
    position: fixed;
    top: 72px;
    right: 20px;
    z-index: 90;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.lib3d-scene-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--lib3d-glass-bg);
    backdrop-filter: blur(var(--lib3d-glass-blur));
    -webkit-backdrop-filter: blur(var(--lib3d-glass-blur));
    border: 1px solid var(--lib3d-glass-border);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-family: var(--lib3d-font);
}

.lib3d-scene-toggle:hover {
    background: rgba(124, 58, 237, 0.25);
    border-color: rgba(124, 58, 237, 0.4);
    color: #fff;
}

.lib3d-scene-toggle i {
    color: var(--lib3d-accent-light);
}

.lib3d-scene-panel {
    display: none;
    background: var(--lib3d-glass-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--lib3d-glass-border);
    border-radius: 16px;
    padding: 14px;
    width: 290px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    animation: scenePanelIn 0.3s var(--lib3d-transition);
}

.lib3d-scene-panel.open {
    display: block;
}

@keyframes scenePanelIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.lib3d-scene-panel-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding: 0 4px;
}

.lib3d-scene-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.lib3d-scene-item {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 16 / 10;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s;
}

.lib3d-scene-item:hover {
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.lib3d-scene-item.active {
    border-color: var(--lib3d-accent);
    box-shadow: 0 0 12px var(--lib3d-accent-glow);
}

.lib3d-scene-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lib3d-scene-item-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 3px 6px;
    font-size: 0.62rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    text-align: center;
}

/* ─── Main Container ─── */
.lib3d-main {
    position: relative;
    z-index: 2;
    padding-top: 64px;
    min-height: 100vh;
}

/* ─── Page Header ─── */
.lib3d-page-header {
    text-align: center;
    padding: 40px 20px 20px;
}

.lib3d-page-title {
    font-size: 2.2rem;
    font-weight: 900;
    margin-bottom: 6px;
    background: linear-gradient(135deg, #fff, #c4b5fd, #7c3aed);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
}

.lib3d-page-subtitle {
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 400;
}

/* ─── Category Tabs ─── */
.lib3d-cat-wrap {
    padding: 10px 20px 20px;
    display: flex;
    justify-content: center;
}

.lib3d-cat-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 6px;
    background: var(--lib3d-glass-bg);
    backdrop-filter: blur(var(--lib3d-glass-blur));
    -webkit-backdrop-filter: blur(var(--lib3d-glass-blur));
    border: 1px solid var(--lib3d-glass-border);
    border-radius: 14px;
    scrollbar-width: none;
    max-width: 100%;
}

.lib3d-cat-tabs::-webkit-scrollbar { display: none; }

.lib3d-cat-tab {
    flex-shrink: 0;
    padding: 8px 18px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    font-family: var(--lib3d-font);
    display: flex;
    align-items: center;
    gap: 6px;
}

.lib3d-cat-tab:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.06);
}

.lib3d-cat-tab.active {
    color: #fff;
    background: linear-gradient(135deg, var(--lib3d-accent), #6d28d9);
    box-shadow: 0 4px 12px var(--lib3d-accent-glow);
}

.lib3d-cat-tab .cat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lib3d-cat-tab .cat-count {
    font-size: 0.72rem;
    opacity: 0.6;
}

/* ─── Shelves Container ─── */
.lib3d-shelves {
    padding: 10px 20px 60px;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    overflow: visible;
}

/* ─── 3D Carousel Stage ─── */
.lib3d-carousel-stage {
    position: relative;
    width: 100%;
    margin: 0 auto;
    perspective: 1600px;
    perspective-origin: 50% 30%;
    overflow: visible;
    min-height: 400px;
    transition: height 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.lib3d-carousel {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ─── Shelf Section (per category) ─── */
.lib3d-shelf-section {
    margin-bottom: 50px;
    animation: shelfFadeIn 0.6s ease both;
}

.lib3d-shelf-section.hidden {
    display: none;
}

/* Shelf sections in 3D Carousel mode */
.lib3d-carousel:not(.flat-view) .lib3d-shelf-section {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    margin-bottom: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), 
                opacity 0.6s ease, 
                filter 0.6s ease;
    opacity: 0.15;
    filter: blur(2px) grayscale(30%);
    pointer-events: none;
}

/* Active shelf section in front */
.lib3d-carousel:not(.flat-view) .lib3d-shelf-section.active-shelf {
    opacity: 1;
    filter: none;
    pointer-events: auto;
    z-index: 10;
}

/* Flat View mode (when 'All' is selected) */
.lib3d-carousel.flat-view {
    transform: none !important;
    display: flex;
    flex-direction: column;
    gap: 40px;
}

.lib3d-carousel.flat-view .lib3d-shelf-section {
    position: relative !important;
    transform: none !important;
    opacity: 1 !important;
    filter: none !important;
    pointer-events: auto !important;
    display: block !important;
}

/* Carousel Navigation Arrows */
.lib3d-carousel-nav {
    position: absolute;
    top: 130px; /* Aligned roughly with the shelf books */
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(15, 10, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), 0 0 10px rgba(124, 58, 237, 0.2);
}

.lib3d-carousel-nav:hover {
    background: var(--lib3d-accent);
    border-color: var(--lib3d-accent-light);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.6);
    transform: scale(1.1);
}

.lib3d-carousel-nav.prev {
    left: -25px;
}

.lib3d-carousel-nav.next {
    right: -25px;
}

.lib3d-carousel-nav.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

@keyframes shelfFadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.lib3d-shelf-label {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 0 8px;
}

.lib3d-shelf-label-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

.lib3d-shelf-label-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
}

.lib3d-shelf-label-count {
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 400;
}

/* ─── Single Shelf Unit ─── */
.lib3d-shelf {
    position: relative;
    margin-bottom: 12px;
}

/* Books container - horizontal scrollable */
.lib3d-shelf-books {
    display: flex;
    gap: 8px;
    padding: 20px 16px 12px;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
    min-height: var(--lib3d-shelf-height);
    align-items: flex-end;
    position: relative;
    z-index: 2;
}

.lib3d-shelf-books::-webkit-scrollbar {
    height: 4px;
}
.lib3d-shelf-books::-webkit-scrollbar-track {
    background: transparent;
}
.lib3d-shelf-books::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
}

/* Wooden shelf plank */
.lib3d-shelf-plank {
    position: relative;
    height: 22px;
    background: linear-gradient(
        180deg,
        #d4a574 0%,
        #c4915a 15%,
        #b07d4a 50%,
        #8b5e3c 80%,
        #6b4226 100%
    );
    border-radius: 0 0 4px 4px;
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.5),
        0 2px 6px rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.15),
        inset 0 -1px 0 rgba(0, 0, 0, 0.2);
    z-index: 1;
}

/* Plank front lip */
.lib3d-shelf-plank::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(180deg, #6b4226, #4a2e1f);
    border-radius: 0 0 3px 3px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}

/* Shelf side brackets */
.lib3d-shelf-plank::after {
    content: '';
    position: absolute;
    top: -4px;
    left: 10px;
    right: 10px;
    height: 4px;
    background: linear-gradient(180deg, rgba(196, 145, 90, 0.3), rgba(196, 145, 90, 0.6));
    border-radius: 2px 2px 0 0;
}

/* ─── 3D Book ─── */
.lib3d-book {
    flex-shrink: 0;
    width: var(--lib3d-book-w);
    cursor: pointer;
    perspective: 800px;
    transition: transform 0.4s var(--lib3d-transition);
}

.lib3d-book:hover {
    transform: translateY(-12px);
    z-index: 10;
}

.lib3d-book-inner {
    position: relative;
    width: var(--lib3d-book-w);
    height: var(--lib3d-book-h);
    transform-style: preserve-3d;
    transform: rotateY(-22deg);
    transition: transform 0.5s var(--lib3d-transition);
}

.lib3d-book:hover .lib3d-book-inner {
    transform: rotateY(-8deg) scale(1.06);
}

/* Book Cover (front face) */
.lib3d-book-cover {
    position: absolute;
    inset: 0;
    border-radius: 0 3px 3px 0;
    overflow: hidden;
    background: linear-gradient(135deg, #2a1f3f, #1a1230);
    box-shadow:
        3px 3px 12px rgba(0, 0, 0, 0.4),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    backface-visibility: hidden;
}

.lib3d-book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s var(--lib3d-transition);
}

.lib3d-book:hover .lib3d-book-cover img {
    transform: scale(1.05);
}

/* Cover placeholder (no image) */
.lib3d-book-cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    text-align: center;
}

.lib3d-book-cover-placeholder .placeholder-icon {
    font-size: 2rem;
    opacity: 0.6;
}

.lib3d-book-cover-placeholder .placeholder-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* Book Spine (left face) */
.lib3d-book-spine {
    position: absolute;
    top: 0;
    left: 0;
    width: var(--lib3d-spine-w);
    height: 100%;
    transform: rotateY(90deg) translateZ(0px);
    transform-origin: left center;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 3px;
    border-radius: 3px 0 0 3px;
    overflow: hidden;
    box-shadow: inset -2px 0 4px rgba(0, 0, 0, 0.3);
}

.lib3d-book-spine-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 0.62rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-height: 90%;
    line-height: 1;
}

/* Spine decorative lines */
.lib3d-book-spine::before,
.lib3d-book-spine::after {
    content: '';
    position: absolute;
    left: 3px;
    right: 3px;
    height: 1px;
    background: rgba(255, 220, 150, 0.35);
}
.lib3d-book-spine::before { top: 12px; }
.lib3d-book-spine::after { bottom: 12px; }

/* Book Pages (right edge) */
.lib3d-book-pages {
    position: absolute;
    top: 2px;
    right: 0;
    width: var(--lib3d-spine-w);
    height: calc(100% - 4px);
    transform: rotateY(-90deg) translateX(var(--lib3d-spine-w));
    transform-origin: right center;
    background: repeating-linear-gradient(
        to right,
        #f5f0e6 0px,
        #ede5d5 1px,
        #f5f0e6 2px
    );
    border-radius: 0 2px 2px 0;
    box-shadow: inset 2px 0 4px rgba(0, 0, 0, 0.15);
}

/* Book Top edge */
.lib3d-book-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--lib3d-spine-w);
    transform: rotateX(90deg);
    transform-origin: top center;
    background: linear-gradient(to bottom, #f5f0e6, #e0d8c8);
    border-radius: 2px;
}

/* Book shadow on shelf */
.lib3d-book-shadow {
    width: 90%;
    height: 10px;
    margin: 2px auto 0;
    background: radial-gradient(ellipse, rgba(0, 0, 0, 0.35) 0%, transparent 70%);
    transition: all 0.4s var(--lib3d-transition);
}

.lib3d-book:hover .lib3d-book-shadow {
    width: 100%;
    height: 14px;
    background: radial-gradient(ellipse, rgba(0, 0, 0, 0.5) 0%, transparent 70%);
}

/* Book info on hover */
.lib3d-book-info {
    position: absolute;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    width: 150px;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 20;
}

.lib3d-book:hover .lib3d-book-info {
    opacity: 1;
    bottom: -55px;
}

.lib3d-book-info-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

.lib3d-book-info-author {
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* ─── Empty State ─── */
.lib3d-empty {
    text-align: center;
    padding: 60px 20px;
    color: rgba(255, 255, 255, 0.4);
}

.lib3d-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.lib3d-empty-text {
    font-size: 1rem;
    font-weight: 500;
}

/* ─── Book Detail Modal ─── */
.lib3d-modal {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 26, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    animation: modalFadeIn 0.3s ease;
}

.lib3d-modal.open {
    display: flex;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lib3d-modal-inner {
    position: relative;
    background: linear-gradient(145deg, rgba(30, 20, 50, 0.95), rgba(20, 15, 40, 0.98));
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 24px;
    padding: 36px;
    max-width: 580px;
    width: 92%;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 40px rgba(124, 58, 237, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    animation: modalSlideIn 0.35s var(--lib3d-transition);
}

@keyframes modalSlideIn {
    from { transform: translateY(30px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.lib3d-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.lib3d-modal-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: rotate(90deg);
}

.lib3d-modal-content {
    display: flex;
    gap: 28px;
    align-items: flex-start;
}

.lib3d-modal-cover {
    flex-shrink: 0;
    width: 170px;
    height: 240px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.4),
        0 0 20px rgba(124, 58, 237, 0.15);
    background: linear-gradient(135deg, #2a1f3f, #1a1230);
}

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

.lib3d-modal-cover-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: rgba(124, 58, 237, 0.4);
}

.lib3d-modal-info {
    flex: 1;
    min-width: 0;
}

.lib3d-modal-cat {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 8px;
    background: rgba(124, 58, 237, 0.2);
    color: #a78bfa;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

.lib3d-modal-title {
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 6px;
    line-height: 1.4;
    background: linear-gradient(120deg, #fff, #c4b5fd);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lib3d-modal-author {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 18px;
}

.lib3d-modal-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.lib3d-modal-meta-item {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
}

.lib3d-modal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.lib3d-modal-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.25s;
    border: none;
    font-family: var(--lib3d-font);
}

.lib3d-modal-btn.primary {
    color: #fff;
    background: linear-gradient(135deg, #7c3aed, #3b82f6);
    box-shadow: 0 6px 20px var(--lib3d-accent-glow);
}

.lib3d-modal-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.5);
}

.lib3d-modal-btn.secondary {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.lib3d-modal-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: translateY(-2px);
}

/* ─── Book Stats Bar ─── */
.lib3d-stats-bar {
    display: flex;
    justify-content: center;
    gap: 32px;
    padding: 16px 20px;
    margin-bottom: 10px;
}

.lib3d-stat {
    text-align: center;
}

.lib3d-stat-value {
    font-size: 1.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, #fff, var(--lib3d-accent-light));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.lib3d-stat-label {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.35);
    font-weight: 500;
    margin-top: 2px;
}

/* ─── Scroll Animations ─── */
.lib3d-shelf-section {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.lib3d-shelf-section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    :root {
        --lib3d-book-w: 100px;
        --lib3d-book-h: 140px;
        --lib3d-spine-w: 16px;
        --lib3d-shelf-height: 200px;
    }

    .lib3d-navbar { padding: 10px 16px; }
    .lib3d-nav-links a { padding: 5px 10px; font-size: 0.78rem; }
    .lib3d-page-title { font-size: 1.6rem; }
    .lib3d-page-subtitle { font-size: 0.82rem; }

    .lib3d-scene-picker { top: 64px; right: 12px; }
    .lib3d-scene-panel { width: 240px; }
    .lib3d-scene-toggle { padding: 6px 12px; font-size: 0.75rem; }

    .lib3d-cat-wrap { padding: 8px 12px 16px; }
    .lib3d-cat-tab { padding: 6px 14px; font-size: 0.8rem; }

    .lib3d-shelves { padding: 10px 12px 60px; }
    .lib3d-shelf-books { padding: 14px 10px 8px; gap: 6px; }

    .lib3d-shelf-label-text { font-size: 0.95rem; }

    .lib3d-book-info { display: none; }

    .lib3d-stats-bar { gap: 20px; }
    .lib3d-stat-value { font-size: 1.4rem; }

    .lib3d-modal-inner { padding: 24px; }
    .lib3d-modal-content { flex-direction: column; align-items: center; text-align: center; }
    .lib3d-modal-cover { width: 140px; height: 200px; }
    .lib3d-modal-meta { justify-content: center; }
    .lib3d-modal-actions { justify-content: center; }
    .lib3d-modal-title { font-size: 1.15rem; }

    /* Carousel Navigation overrides on mobile */
    .lib3d-carousel-stage {
        perspective: 1200px;
        perspective-origin: 50% 25%;
        min-height: 250px;
    }
    .lib3d-carousel-nav {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        top: 90px;
    }
    .lib3d-carousel-nav.prev {
        left: 0px;
    }
    .lib3d-carousel-nav.next {
        right: 0px;
    }
}

@media (max-width: 480px) {
    :root {
        --lib3d-book-w: 85px;
        --lib3d-book-h: 120px;
        --lib3d-spine-w: 14px;
    }

    .lib3d-page-header { padding: 28px 16px 14px; }
    .lib3d-page-title { font-size: 1.3rem; }
    .lib3d-nav-brand { font-size: 1rem; }
    .lib3d-scene-toggle span { display: none; }
}

/* ─── Infographic Board ─── */
.lib3d-infoboard-container {
    padding: 10px 20px 40px 20px;
    display: flex;
    justify-content: center;
}
.lib3d-infoboard-inner {
    background: rgba(20, 20, 30, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 30px;
    backdrop-filter: blur(12px);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.6);
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
}
.lib3d-infoboard-header {
    text-align: center;
    margin-bottom: 25px;
}
.lib3d-infoboard-header h3 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: #ff9f43;
    text-shadow: 0 2px 10px rgba(255, 159, 67, 0.3);
}
.lib3d-infoboard-header p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    margin: 0;
}
.lib3d-infoboard-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 25px;
}
.lib3d-info-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    width: 220px;
    aspect-ratio: 210 / 297; /* A4 aspect ratio */
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    cursor: pointer;
    background: #1e1e2d;
}
.lib3d-info-item:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 15px 35px rgba(0,0,0,0.7);
    z-index: 2;
}
.lib3d-info-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

