/* ==================== 1. Core Styles ==================== */
:root {
    --cream: #FFF9F0;
    --parchment: #E8DCC4;
    --gold: #B8956A;
    --charcoal: #3D3D3D;
    --cherry: #B83232;
    --white: #FFFFFF;
    --shadow: rgba(0,0,0,0.1);
    --overlay-bg: rgba(0,0,0,0.6);
    --wood: #5D4037;
    --z-modal: 9999;
    --z-overlay: 9998;
    --z-ui: 9997;
    --reading-font: 'Lora', serif;
    --reading-font-size: 16px;
    --reading-line-height: 1.6;
    --reading-align: left;
    --reading-width: 820px;
    --reading-letter-spacing: 0px;
}

[data-theme="dark"] {
    --cream: #1A1714;
    --parchment: #2C2824;
    --gold: #D4B896;
    --charcoal: #E8DCC4;
    --white: #25211D;
    --shadow: rgba(0,0,0,0.5);
    --overlay-bg: rgba(0,0,0,0.9);
}

[data-theme="sepia"] {
    --cream: #f4ecd8;
    --parchment: #e6d5b5;
    --gold: #b88b4a;
    --charcoal: #4a3b2a;
    --white: #fbf4e5;
    --shadow: rgba(0,0,0,0.2);
    --overlay-bg: rgba(50,30,10,0.7);
}

[data-theme="deepsea"] {
    --cream: #0f1b22;
    --parchment: #162632;
    --gold: #6fb1c9;
    --charcoal: #d6ecf5;
    --white: #0b141a;
    --shadow: rgba(0,0,0,0.6);
    --overlay-bg: rgba(0,10,18,0.85);
}

body {
    background-color: var(--cream);
    color: var(--charcoal);
    font-family: 'Lora', serif;
    margin: 0;
    transition: background 0.5s, color 0.5s;
    overflow-x: hidden;
}

body.high-contrast {
    --cream: #000000;
    --parchment: #0a0a0a;
    --gold: #ffd400;
    --charcoal: #ffffff;
    --white: #000000;
    --shadow: rgba(255,255,255,0.2);
    --overlay-bg: rgba(0,0,0,0.95);
}

body[data-anim="reduced"] *, body[data-anim="reduced"] *::before, body[data-anim="reduced"] *::after {
    animation-duration: 0.2s !important;
    transition-duration: 0.2s !important;
}

body[data-anim="none"] *, body[data-anim="none"] *::before, body[data-anim="none"] *::after {
    animation: none !important;
    transition: none !important;
}

h1, h2, h3, .btn-primary { font-family: 'Playfair Display', serif; }
button { cursor: pointer; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ==================== 2. Candle Animation & Header ==================== */
.header { padding: 20px 0; background: var(--cream); box-shadow: 0 2px 10px var(--shadow); position: sticky; top:0; z-index: 100; }
.header-content { display: flex; justify-content: space-between; align-items: center; }

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 2rem; }
.logo-text h1 { font-size: 1.2rem; margin: 0; color: var(--charcoal); }
.logo-text p { font-size: 0.8rem; color: var(--gold); letter-spacing: 2px; text-transform: uppercase; }

.header-actions { display: flex; align-items: center; gap: 20px; }

/* Qiriri i avancuar */
.candle-container {
    width: 30px; height: 50px; position: relative; cursor: pointer;
    display: flex; align-items: flex-end; justify-content: center;
}

.candle {
    width: 12px; height: 30px; background: #d45d5d; border-radius: 2px;
    position: relative; transition: height 0.3s;
}
.candle.off .flame { opacity:0; animation:none; }
.candle.off .smoke { opacity:1; animation: smokePuff 0.9s ease-out; }
.candle.on .flame { opacity:1; animation: flicker 1s infinite alternate; }
.candle.on .sparkle { animation: sparkle 1.2s ease-out; }

.wick {
    width: 2px; height: 6px; background: #333;
    position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
}

.flame {
    width: 10px; height: 18px;
    background: radial-gradient(ellipse at bottom, #ffd700, #ff4500);
    border-radius: 50% 50% 20% 20%;
    position: absolute; top: -20px; left: 50%; transform: translateX(-50%);
    box-shadow: 0 0 10px #ff4500, 0 0 20px #ffd700;
    animation: flicker 1s infinite alternate;
    opacity: 1; transition: opacity 0.3s ease;
}

.smoke {
    width: 12px; /* Bigger */
    height: 12px;
    background: rgba(200, 200, 200, 0.8);
    position: absolute;
    top: -15px;
    left: 50%;
    border-radius: 50%;
    filter: blur(4px); /* Softer smoke look */
    opacity: 0;
    pointer-events: none;
}

@keyframes smokeRise {
    0% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    30% { opacity: 0.8; transform: translate(-70%, -20px) scale(2); }
    100% { opacity: 0; transform: translate(-30%, -60px) scale(5); }
}

@keyframes sparkle {
    0% { box-shadow: 0 0 0 transparent; }
    50% { 
        box-shadow: 
            -15px -15px 5px #ffd700, 
            15px -20px 8px #ff4500, 
            0px -30px 10px #ffffff,
            -10px -40px 4px #ffd700; 
    }
    100% { box-shadow: none; }
}
@keyframes flicker { 0% { transform: translateX(-50%) scale(1); opacity: 1; } 100% { transform: translateX(-50%) scale(0.9); opacity: 0.8; } }
@keyframes smokeRise { 0% { opacity: 0.8; transform: translateX(-50%) scale(1); top: -15px; } 100% { opacity: 0; transform: translateX(-60%) scale(3); top: -45px; } }
@keyframes smokePuff { 0% { opacity:0.9; transform: translate(-50%,0) scale(0.8);} 60% {opacity:0.5; transform: translate(-55%,-25px) scale(1.4);} 100% {opacity:0; transform: translate(-60%,-45px) scale(1.8);} }
@keyframes sparkle { 0% { box-shadow: 0 0 0 #fff; } 50% { box-shadow: -10px -15px 0 #ffd700, 10px -20px 0 #ff4500, 0 -25px 0 #fff; } 100% { box-shadow: none; } }
.shelf-trigger {
    background: none; border: none; font-size: 1.5rem; position: relative; transition: transform 0.2s;
}
.shelf-trigger:hover { transform: scale(1.1); }
#shelfCount {
    position: absolute; top: -5px; right: -5px; background: var(--cherry); color: white;
    font-size: 0.7rem; width: 18px; height: 18px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; font-weight: bold;
}

/* ==================== 3. Hero & Stats ==================== */
.hero { padding: 60px 0; background: var(--parchment); text-align: center; }
.hero-badge { background: var(--gold); color: white; padding: 5px 15px; border-radius: 20px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; }
.hero-title { font-size: 3rem; margin: 20px 0; color: var(--charcoal); }
.highlight { color: var(--cherry); font-style: italic; }
.daily-quote-box { margin: 20px auto; max-width: 600px; font-style: italic; color: var(--wood); }

.hero-buttons { margin-top: 30px; display: flex; gap: 15px; justify-content: center; }
.btn-primary, .btn-secondary {
    padding: 12px 30px; border-radius: 30px; font-size: 1rem; cursor: pointer; transition: 0.3s;
}
.btn-primary { background: var(--cherry); color: white; border: none; }
.btn-primary:hover { background: #962828; }
.btn-secondary { background: transparent; border: 2px solid var(--charcoal); color: var(--charcoal); }
.btn-secondary:hover { background: var(--charcoal); color: var(--white); }

.stats { padding: 30px 0; background: var(--white); border-bottom: 1px solid #ddd; }
.stats-grid { display: flex; justify-content: center; gap: 50px; text-align: center; }
.stat-card .stat-icon { font-size: 2rem; display: block; margin-bottom: 10px; }
.stat-number { font-size: 1.5rem; font-weight: bold; color: var(--gold); display: block; }
.stat-label { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; }

/* ==================== 4. Categories & Books ==================== */
.categories { padding: 40px 0; }
.section-title { text-align: center; margin-bottom: 30px; font-size: 2rem; position: relative; display: inline-block; width: 100%; }
.categories-grid { display: flex; justify-content: center; gap: 15px; flex-wrap: wrap; }
.category-card {
    background: var(--white); padding: 15px 25px; border-radius: 12px; cursor: pointer;
    box-shadow: 0 4px 10px var(--shadow); display: flex; align-items: center; gap: 10px;
    transition: transform 0.2s, background 0.2s; border: 1px solid transparent;
}
.category-card:hover { transform: translateY(-3px); border-color: var(--gold); }
.category-card.active { background: var(--gold); color: white; }

.books-section { padding: 40px 0; min-height: 600px; }
.books-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; flex-wrap: wrap; gap: 20px; }
.books-controls { display: flex; gap: 15px; }

.search-box {
    display: flex; align-items: center; background: var(--white); border: 1px solid #ccc;
    padding: 5px 15px; border-radius: 20px; width: 1000px;
}
.search-input { border: none; outline: none; background: transparent; width: 100%; color: var(--charcoal); }
.sort-select { padding: 8px; border-radius: 20px; border: 1px solid #ccc; background: var(--white); color: var(--charcoal); }
    

.book-card {
    background: var(--white); border-radius: 8px; overflow: hidden;
    box-shadow: 0 5px 15px var(--shadow); transition: transform 0.3s;
    cursor: pointer; position: relative; height: 100%; display: flex; flex-direction: column;
}
.book-card:hover { transform: translateY(-5px); }
.book-image-wrapper { height: 280px; overflow: hidden; position: relative; background: #eee; }
.book-image { width: 100%; height: 100%; object-fit: cover; }
.book-badge { position: absolute; top: 10px; right: 10px; background: var(--gold); color: white; padding: 4px 8px; font-size: 0.7rem; border-radius: 4px; font-weight: bold; }
.book-info { padding: 15px; flex: 1; display: flex; flex-direction: column; }
.book-category { font-size: 0.75rem; color: var(--gold); text-transform: uppercase; }
.book-title { font-size: 1.1rem; margin: 5px 0; color: var(--charcoal); flex: 1; }
.book-author { font-size: 0.9rem; color: #888; font-style: italic; margin-bottom: 10px; }
.book-add-btn {
    align-self: flex-end; width: 30px; height: 30px; border-radius: 50%; border: none;
    background: var(--parchment); color: var(--charcoal); font-size: 1.2rem;
    display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.book-add-btn:hover { background: var(--cherry); color: white; }

/* ==================== 5. Music Box (Rregulluar) ==================== */
.music-box {
    position: fixed;
    top: 20px; /* Moved from bottom to top */
    left: 20px;
    width: 280px;
    background: rgba(93, 64, 55, 0.92);
    backdrop-filter: blur(6px);
    border: 4px solid #3E2723; border-radius: 12px;
    box-shadow: 5px 10px 25px rgba(0,0,0,0.5); z-index: 10001; /* Higher than modal */
    color: #EFEBE9;
    overflow: visible; /* allow drag handle to work without clipping */
    user-select: none;
    touch-action: none; /* needed for pointer events drag */
}

.music-box.minimized { height: 45px; width: 180px; }

.wood-texture {
    position: absolute; top:0; left:0; width:100%; height:100%;
    background: repeating-linear-gradient(45deg, rgba(255,255,255,0.05) 0px, rgba(255,255,255,0.05) 2px, transparent 2px, transparent 4px);
    pointer-events: none;
}

.win-header {
    background: #3E2723; padding: 10px 15px; display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid #795548; position: relative; z-index: 2;
}
.win-title { font-size: 0.9rem; font-weight: bold; letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
.win-min-btn { background: none; border: none; color: #D7CCC8; font-size: 1.5rem; padding: 0; line-height: 1; }

.win-body { padding: 15px; display: flex; flex-direction: column; gap: 15px; position: relative; z-index: 2; }
.music-box.minimized .win-body { display: none; }

/* Vinyl Animation */
.vinyl-record-container { display: flex; justify-content: center; margin-bottom: 5px; }
.vinyl-record {
    width: 80px; height: 80px; background: #111; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    background: repeating-radial-gradient(#111 0, #111 2px, #222 3px, #222 4px);
}
.playing .vinyl-record { animation: spin 4s linear infinite; }
.vinyl-label { width: 30px; height: 30px; background: var(--cherry); border-radius: 50%; border: 2px solid white; }

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

.music-info marquee { font-size: 0.8rem; color: #D7CCC8; background: rgba(0,0,0,0.3); padding: 4px; border-radius: 4px; }

/* Custom Select Styling */
.music-select {
    width: 100%; padding: 8px; border: 1px solid #8D6E63; border-radius: 4px;
    background: #3E2723; color: #D7CCC8; font-family: 'Lora', serif; cursor: pointer; outline: none;
}
.music-select:hover { border-color: #D7CCC8; }

.music-controls { display: flex; justify-content: center; }
.play-circle {
    width: 45px; height: 45px; border-radius: 50%; border: 2px solid #D7CCC8;
    background: transparent; color: #D7CCC8; font-size: 1.2rem;
    display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.play-circle:hover { background: #D7CCC8; color: #3E2723; transform: scale(1.1); }

/* ==================== 6. Shelf Sidebar (Updated) ==================== */
.shelf-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: var(--z-overlay);
    display: none; opacity: 0; transition: opacity 0.3s;
}
.shelf-overlay.active { display: block; opacity: 1; }

.shelf-sidebar {
    position: fixed; top: 0; right: -350px; width: 320px; height: 100%;
    background: rgba(255,255,255,0.92); z-index: var(--z-ui);
    box-shadow: -5px 0 20px rgba(0,0,0,0.2);
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column;
    backdrop-filter: blur(6px);
}
.shelf-sidebar.active { right: 0; }

.shelf-header {
    padding: 20px; background: var(--parchment); border-bottom: 2px solid var(--gold);
    display: flex; justify-content: space-between; align-items: center;
}
.close-btn-simple { background: none; border: none; font-size: 1.5rem; color: var(--charcoal); }

.shelf-items { flex: 1; overflow-y: auto; padding: 20px; }
.empty-msg { text-align: center; color: #888; font-style: italic; margin-top: 50px; }

.shelf-item-row {
    display: flex; align-items: center; gap: 10px; margin-bottom: 15px;
    padding-bottom: 10px; border-bottom: 1px dashed var(--gold);
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.shelf-thumb { width: 50px; height: 75px; object-fit: cover; border-radius: 4px; box-shadow: 1px 1px 5px rgba(0,0,0,0.2); }
.shelf-details { flex: 1; }
.shelf-title { font-size: 0.9rem; font-weight: bold; display: block; color: var(--charcoal); margin-bottom: 5px; }
.shelf-btn-read {
    background: var(--cherry); color: white; border: none; padding: 5px 12px;
    border-radius: 4px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px;
}
.shelf-remove { color: #aaa; background: none; border: none; font-size: 1.2rem; padding: 5px; }
.shelf-remove:hover { color: var(--cherry); }

/* Old modal block removed â€” see bottom of file for correct .modal */
.btn-add-shelf {
    width: 100%; 
    margin-top: 10px; 
    padding: 12px; 
    background: var(--white); /* Dark background so white text pops */
    color: charcoal !important; 
    border: none; 
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-add-shelf:hover {
    opacity: 0.9;
}

/* ==================== 8. Focus Mode (Reading) ==================== */
.focus-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #1a1a1a; z-index: 4000;
    display: none; flex-direction: column;
}
.focus-overlay.active { display: flex; }
.focus-header {
    height: 50px; background: #000; color: #fff;
    display: flex; justify-content: space-between; align-items: center; padding: 0 20px;
    border-bottom: 1px solid #333;
}
.close-focus-btn {
    background: var(--cherry); color: white; border: none; padding: 6px 15px;
    border-radius: 4px; cursor: pointer; font-weight: bold;
}
.close-focus-btn:hover { background: #ff4d4d; }
#pdfFrame { width: 100%; height: 100%; border: none; background: #fff; }

/* ==================== 9. Toast ==================== */
.toast {
    position: fixed; bottom: -100px; right: 20px;
    background: var(--white); border-left: 5px solid var(--cherry);
    padding: 15px 25px; border-radius: 8px; box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    transition: bottom 0.5s; z-index: 6000;
}
.toast.show { bottom: 30px; }
.toast strong { display: block; margin-bottom: 5px; color: var(--charcoal); }
.toast p { margin: 0; font-size: 0.9rem; color: #666; }
/* ==================== Search Bar: Full Width ==================== */
.search-container { 
    display: flex; 
    gap: 10px; 
    width: 100%; /* Takes up the whole row */
    margin: 20px 0; 
}

.search-box { 
    display: flex; 
    align-items: center; 
    background: var(--white); 
    border: 1px solid var(--gold); 
    border-radius: 8px; 
    padding: 0 15px; 
    flex: 1; /* Spans the remaining space */
}



/* ==================== Button Styling ==================== */
/* duplicate modal-close removed */

/* Class for the 'Shto ne Cante' button in JS */

/* ============================================================
   CRITICAL FIX: Modal must use display:none not visibility:hidden
   The old .modal{display:flex;visibility:hidden} is WRONG because
   the absolute-positioned overlay covers the container.
   We now handle display entirely via JS (modal.style.display).
   ============================================================ */
.modal {
    display: none;  /* JS sets display:flex when open */
    position: fixed; top:0; left:0; width:100%; height:100%;
    align-items: flex-start; /* Aligned to top */
    justify-content: center;
    z-index: var(--z-modal);
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(3px);
    padding: 40px 20px; /* More top padding */
    box-sizing: border-box;
}
/* Override the broken old rule */
.modal-overlay { display: none !important; }

.modal-box {
    background: #F5EFE6; /* Always light â€” never var(--white) which is dark in dark mode */
    width: 100%; max-width: 820px;
    border-radius: 14px;
    padding: 30px;
    position: relative;
    max-height: 88vh; overflow-y: auto;
    box-shadow: 0 25px 70px rgba(0,0,0,0.6);
    animation: modalIn 0.25s ease;
}
@keyframes modalIn {
    from { transform: scale(0.92) translateY(20px); opacity:0; }
    to   { transform: scale(1)    translateY(0);    opacity:1; }
}
.modal-close {
    position: absolute; top: 14px; right: 14px;
    background: #222; color: #fff;
    border: none; width: 32px; height: 32px;
    border-radius: 50%; font-size: 1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    z-index: 10; transition: background 0.2s;
}
.modal-close:hover { background: var(--cherry); }

/* Modal Layout */
.modal-layout { display: flex; gap: 24px; align-items: flex-start; }
@media (max-width:580px) { .modal-layout { flex-direction:column; align-items:center; } }
.modal-cover-col { flex-shrink: 0; }
.modal-cover-img {
    width: 155px; border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    display: block;
}
.modal-info-col { flex: 1; min-width: 0; }
.modal-cat-tag {
    display: inline-block; background: var(--parchment); color: var(--gold);
    font-size: 0.72rem; padding: 3px 10px; border-radius: 20px;
    text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px;
}
.modal-title { font-family:'Playfair Display',serif; font-size:1.5rem; margin:0 0 6px; color:var(--charcoal); line-height:1.3; }
.modal-author { color:var(--gold); margin:0 0 4px; font-size:0.9rem; }
.modal-level { font-size:0.8rem; color:#888; margin:0 0 12px; }
.modal-desc { line-height:1.75; font-size:0.9rem; color:var(--charcoal); margin-bottom:18px; }
.modal-actions { display:flex; flex-direction:column; gap:10px; }
.modal-read-btn {
    width:100%; padding:13px; background:var(--cherry); color:#fff;
    border:none; border-radius:8px; font-size:1rem; font-family:'Playfair Display',serif;
    cursor:pointer; transition:0.2s;
}
.modal-read-btn:hover { background:#962828; transform:translateY(-1px); }
.modal-shelf-btn {
    width:100%; padding:10px; background:transparent;
    border:2px solid var(--gold); color:var(--gold);
    border-radius:8px; font-size:0.9rem; cursor:pointer; transition:0.2s;
}
.modal-shelf-btn:hover { background:var(--gold); color:#fff; }

/* Volume Variant Chips */
.variants-label { font-family:'Playfair Display',serif; font-size:0.88rem; color:var(--gold); margin:0 0 10px; font-weight:bold; }
.variants-grid {
    display: flex; flex-wrap: wrap; gap: 8px;
    max-height: 200px; overflow-y: auto; padding: 2px;
}
.variants-grid::-webkit-scrollbar { width: 4px; }
.variants-grid::-webkit-scrollbar-thumb { background: var(--gold); border-radius:4px; }
.variant-chip {
    padding: 6px 14px;
    background: var(--parchment);
    border: 1.5px solid var(--gold);
    border-radius: 20px;
    font-size: 0.78rem;
    font-family: 'Lora', serif;
    color: var(--charcoal);
    cursor: pointer;
    transition: all 0.18s;
}
.variant-chip:hover { background:var(--gold); color:#fff; transform:translateY(-2px); box-shadow:0 4px 10px rgba(0,0,0,0.15); }

/* ===== BOOK CARD IMPROVEMENTS ===== */
:root { --cover-h: 260px; }
.book-cover-wrap { position:relative; height:var(--cover-h); overflow:hidden; background:var(--parchment); }
.book-cover { width:100%; height:100%; object-fit:cover; transition:transform 0.4s; display:block; }
.book-card:hover .book-cover { transform:scale(1.06); }
.badge-pdf {
    position:absolute; top:8px; left:8px;
    background:#2d6a4f; color:#fff;
    font-size:0.62rem; padding:3px 7px; border-radius:4px; font-weight:bold;
}
.badge-pop {
    position:absolute; top:8px; right:8px;
    background:var(--gold); color:#fff;
    font-size:0.65rem; padding:3px 7px; border-radius:4px;
}
.vol-tag {
    display:inline-block; background:var(--parchment); color:var(--gold);
    font-size:0.7rem; padding:3px 8px; border-radius:4px; margin-top:5px;
}

/* Compact grid mode */
.compact-grid { grid-template-columns: repeat(auto-fill, minmax(140px,1fr)) !important; gap:16px !important; }
.compact-grid .book-cover-wrap { height:180px; }
.compact-grid .book-title { font-size:0.85rem; }
.compact-grid .book-author { font-size:0.75rem; }

/* No animations mode */
.no-anim *, .no-anim *::before, .no-anim *::after {
    animation: none !important;
    transition: none !important;
}

/* ===== FOCUS OVERLAY ===== */
.focus-overlay {
    display: none;
    position: fixed; top:0; left:0; width:100%; height:100%;
    background:#111; z-index:var(--z-modal); flex-direction:column;
}
.focus-overlay[style*="flex"] { display:flex !important; }
.focus-header {
    height:52px; background:#000; color:#fff; flex-shrink:0;
    display:flex; justify-content:space-between; align-items:center;
    padding:0 24px; border-bottom:1px solid #333;
    font-family:'Playfair Display',serif;
}
.close-focus-btn { background:var(--cherry); color:#fff; border:none; padding:7px 16px; border-radius:6px; cursor:pointer; font-weight:bold; }
.close-focus-btn:hover { background:#ff4d4d; }
#pdfFrame { flex:1; border:none; background:#fff; }

/* ===== VINYL SPINNING ===== */
.vinyl-record.spinning { animation: spin 4s linear infinite; }

/* ===== LEFT SIDEBAR ===== */
.sidebar-overlay {
    position:fixed; top:0; left:0; width:100%; height:100%;
    background:rgba(0,0,0,0.52); z-index:var(--z-overlay);
    opacity:0; pointer-events:none; transition:opacity 0.3s;
}
.sidebar-overlay.open { opacity:1; pointer-events:all; }
.left-sidebar {
    position:fixed; top:0; left:-320px; width:300px; height:100%;
    background:rgba(255,255,255,0.92); z-index:var(--z-modal);
    box-shadow:4px 0 30px rgba(0,0,0,0.22);
    transition:left 0.35s cubic-bezier(0.4,0,0.2,1);
    display:flex; flex-direction:column;
    overflow-y: auto; /* lejo rrotullimin e cilësimeve */
    backdrop-filter: blur(8px);
}
.left-sidebar.open { left:0; }
/* Scrollable inner body - settings scroll inside sidebar, page doesn't move */
.sidebar-scroll-body {
    flex: 1; overflow-y: auto; overflow-x: hidden;
}
.sidebar-scroll-body::-webkit-scrollbar { width: 4px; }
.sidebar-scroll-body::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll-body::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 4px; }
.sidebar-top {
    display:flex; justify-content:space-between; align-items:center;
    padding:18px 20px; background:var(--parchment);
    border-bottom:2px solid var(--gold);
    font-family:'Playfair Display',serif; font-size:1.05rem; font-weight:bold; color:var(--charcoal);
    flex-shrink: 0;
}
.sidebar-close-btn { background:none; border:none; font-size:1.3rem; color:var(--charcoal); cursor:pointer; }
.sidebar-close-btn:hover { color:var(--cherry); }
.sidebar-section { padding:16px 20px; border-bottom:1px solid var(--parchment); }
.sidebar-section-title { font-size:0.72rem; text-transform:uppercase; letter-spacing:2px; color:var(--gold); margin:0 0 12px; }
.library-list { display:flex; flex-direction:column; gap:8px; }
.library-btn {
    display:flex; align-items:center; gap:12px;
    padding:11px 14px; border-radius:10px;
    background:var(--cream); border:2px solid transparent;
    cursor:pointer; text-align:left; transition:0.2s;
    font-family:'Lora',serif; color:var(--charcoal);
}
.library-btn:hover { border-color:var(--gold); }
.library-btn.active { background:var(--gold); color:#fff; border-color:var(--gold); }
.library-btn.active strong, .library-btn.active small { color:#fff; }
.library-btn small { display:block; font-size:0.73rem; opacity:0.8; margin-top:1px; }
.lib-icon { font-size:1.5rem; }
.setting-row { margin-bottom:14px; }
.setting-label { display:flex; justify-content:space-between; font-size:0.83rem; color:var(--charcoal); margin-bottom:7px; }
.setting-slider {
    -webkit-appearance:none; appearance:none;
    width:100%; height:5px; background:var(--parchment); border-radius:5px; outline:none; cursor:pointer;
}
.setting-slider::-webkit-slider-thumb {
    -webkit-appearance:none; width:18px; height:18px;
    background:var(--gold); border-radius:50%; cursor:pointer;
    box-shadow:0 2px 6px rgba(0,0,0,0.2);
}
.font-size-btns { display:flex; gap:7px; }
.fs-btn {
    flex:1; padding:7px; border:1.5px solid var(--parchment); border-radius:6px;
    background:var(--cream); color:var(--charcoal); cursor:pointer;
    font-family:'Lora',serif; transition:0.18s; font-size:0.85rem;
}
.fs-btn.active { background:var(--gold); color:#fff; border-color:var(--gold); }
.fs-btn:hover:not(.active) { border-color:var(--gold); }
.toggle-switch {
    width:44px; height:24px; background:var(--parchment); border-radius:12px;
    cursor:pointer; position:relative; transition:background 0.3s;
}
.toggle-switch.on { background:var(--gold); }
.toggle-knob {
    position:absolute; top:2px; left:2px;
    width:20px; height:20px; background:#fff; border-radius:50%;
    transition:transform 0.28s; box-shadow:0 1px 4px rgba(0,0,0,0.2);
}
.toggle-switch.on .toggle-knob { transform:translateX(20px); }
.color-swatches { display:flex; gap:8px; padding-top:4px; }
.color-dot {
    width:26px; height:26px; border-radius:50%; cursor:pointer;
    border:3px solid transparent; transition:0.2s;
    box-shadow:0 1px 4px rgba(0,0,0,0.2);
}
.color-dot:hover { transform:scale(1.15); }
.color-dot.active { border-color:var(--charcoal); transform:scale(1.15); }
.font-select {
    width:100%; padding:7px 10px; border:1.5px solid var(--parchment); border-radius:7px;
    background:var(--cream); color:var(--charcoal); font-family:'Lora',serif;
    font-size:0.85rem; cursor:pointer; outline:none;
}
.font-select:hover { border-color:var(--gold); }
.quick-nav { display:flex; flex-direction:column; gap:5px; }
.quick-nav a {
    padding:9px 12px; border-radius:8px; color:var(--charcoal);
    text-decoration:none; font-size:0.88rem; transition:background 0.18s;
}
.quick-nav a:hover { background:var(--parchment); color:var(--gold); }
.sidebar-footer { margin-top:auto; padding:18px 20px; text-align:center; font-size:0.72rem; color:#aaa; border-top:1px solid var(--parchment); }
.sidebar-footer p { margin:2px 0; }

/* ===== HAMBURGER ===== */
.hamburger-btn {
    background:none; border:none; cursor:pointer;
    display:flex; flex-direction:column; gap:5px; padding:7px;
    border-radius:6px; transition:background 0.2s;
}
.hamburger-btn:hover { background:var(--parchment); }
.hamburger-btn span { display:block; width:22px; height:2px; background:var(--charcoal); border-radius:2px; }

/* ===== TOAST ===== */
.toast {
    position:fixed; bottom:-120px; right:20px;
    background:var(--white); border-left:5px solid var(--cherry);
    padding:14px 22px; border-radius:10px;
    box-shadow:0 6px 24px rgba(0,0,0,0.22);
    transition:bottom 0.45s cubic-bezier(0.34,1.56,0.64,1); z-index:9500;
    min-width:220px;
}
.toast.show { bottom:30px; }
#toastTitle { display:block; margin-bottom:4px; color:var(--charcoal); font-size:0.9rem; }
#toastMsg { margin:0; font-size:0.82rem; color:#666; }

/* ===== QUOTE BOX ===== */
.daily-quote-box {
    background:rgba(255,255,255,0.55); backdrop-filter:blur(6px);
    padding:18px 28px; border-radius:12px; border-left:4px solid var(--gold);
    max-width:600px; margin:20px auto; font-style:italic;
}
.quote-author { display:block; margin-top:8px; font-size:0.83rem; color:var(--gold); font-style:normal; }

/* ===== NEW SETTINGS OVERRIDES ===== */
.legacy-settings { display: none; }

.settings-subtitle {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--gold);
    margin: 18px 0 10px;
}

.segmented-btns { display: flex; gap: 6px; }
.segmented-btn {
    flex: 1;
    padding: 7px;
    border: 1.5px solid var(--parchment);
    border-radius: 6px;
    background: var(--cream);
    color: var(--charcoal);
    cursor: pointer;
    font-family: 'Lora', serif;
    transition: 0.18s;
    font-size: 0.82rem;
}
.segmented-btn.active { background: var(--gold); color: #fff; border-color: var(--gold); }
.segmented-btn:hover:not(.active) { border-color: var(--gold); }

.modal-box {
    background: rgba(245,239,230,0.96);
    max-width: var(--reading-width);
    backdrop-filter: blur(6px);
}
.modal-title, .modal-author, .modal-level, .modal-cat-tag { font-family: var(--reading-font); }
.modal-desc {
    font-family: var(--reading-font);
    font-size: var(--reading-font-size);
    line-height: var(--reading-line-height);
    text-align: var(--reading-align);
    letter-spacing: var(--reading-letter-spacing);
}

/* Glass Effect */
body.glass-effect .header,
body.glass-effect .left-sidebar,
body.glass-effect .shelf-sidebar,
body.glass-effect .music-box,
body.glass-effect .modal-box {
    background: rgba(255, 255, 255, 0.6) !important;
    backdrop-filter: blur(15px) !important;
    -webkit-backdrop-filter: blur(15px) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

[data-theme="dark"].glass-effect .header,
[data-theme="dark"].glass-effect .left-sidebar,
[data-theme="dark"].glass-effect .shelf-sidebar,
[data-theme="dark"].glass-effect .music-box,
[data-theme="dark"].glass-effect .modal-box {
    background: rgba(30, 30, 30, 0.6) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.books-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.books-grid.list-view .book-card {
    flex-direction: row;
    align-items: stretch;
}
.books-grid.list-view .book-cover-wrap {
    width: 120px;
    height: 160px;
    flex-shrink: 0;
}
.books-grid.list-view .book-info { padding: 12px 16px; }

.progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--parchment);
    border-radius: 6px;
    overflow: hidden;
}
.progress-bar span {
    display: block;
    height: 100%;
    background: var(--gold);
}
.progress-text {
    font-size: 0.72rem;
    color: var(--gold);
    min-width: 34px;
    text-align: right;
}

.audio-visualizer {
    display: none;
    gap: 4px;
    height: 18px;
    align-items: flex-end;
    margin-top: 8px;
}
.audio-visualizer span {
    width: 6px;
    height: 6px;
    background: var(--gold);
    animation: viz 0.9s ease-in-out infinite;
    animation-play-state: paused;
}
#musicPlayer.visualizer-on .audio-visualizer { display: flex; }
#musicPlayer.playing.visualizer-on .audio-visualizer span { animation-play-state: running; }
@keyframes viz {
    0% { height: 4px; opacity: 0.6; }
    50% { height: 18px; opacity: 1; }
    100% { height: 6px; opacity: 0.7; }
}

.toast { z-index: var(--z-ui); }

[data-theme="dark"] .left-sidebar,
[data-theme="dark"] .shelf-sidebar {
    background: rgba(28, 24, 20, 0.92);
}
[data-theme="deepsea"] .left-sidebar,
[data-theme="deepsea"] .shelf-sidebar {
    background: rgba(14, 24, 30, 0.92);
}

/* ===== HARD LOCK (always on screen, always above grid) ===== */
#musicPlayer.music-box {
    position: fixed !important;
    left: 20px;
    top: 100px; /* Moved from bottom to top as requested */
    z-index: var(--z-ui) !important;
}
#bookModal.modal {
    position: fixed !important;
    inset: 0 !important;
    z-index: var(--z-modal) !important;
    align-items: flex-start; /* Aligned to top */
    padding-top: 40px;
}
#focusOverlay.focus-overlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: var(--z-modal) !important;
}
#leftSidebar.left-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: -320px;
    z-index: var(--z-modal) !important;
}
#leftSidebar.left-sidebar.open {
    left: 0 !important;
}



/* ==================== OVERRIDE FINAL v5 ====================
   Këto rrule vendosen FUNDIT dhe kanë prioritet mbi çdo gjë */

/* ===== MODAL: GJITHMONË NË MES TË EKRANIT ===== */
/* Backdrop */
#bookModal.modal {
    display: none;
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    background: rgba(0,0,0,0.72) !important;
    backdrop-filter: blur(4px) !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 16px !important;
    box-sizing: border-box !important;
    overflow-y: auto !important;
}
/* Kuti e bardhë — e centralizuar me transform */
#bookModal.modal .modal-box {
    position: relative !important;
    margin: auto !important;
    top: auto;
    left: auto !important;
    transform: none !important;
    max-width: 820px !important;
    width: 100% !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    background: #F5EFE6 !important;
    border-radius: 14px !important;
    padding: 30px !important;
    box-shadow: 0 25px 80px rgba(0,0,0,0.65) !important;
    animation: modalBounce 0.28s cubic-bezier(0.34,1.56,0.64,1) !important;
}
@keyframes modalBounce {
    from { transform: scale(0.88) translateY(30px); opacity: 0; }
    to   { transform: scale(1) translateY(0); opacity: 1; }
}
[data-theme="dark"] #bookModal.modal .modal-box {
    background: #2C2824 !important;
}

/* ===== MUSIC PLAYER: GJITHMONË FIXED ===== */
#musicPlayer.music-box {
    position: fixed !important;
    bottom: 20px;
    left: 20px;
    top: auto;
    right: auto;
    z-index: 10002 !important;
    transition: width 0.3s ease, height 0.3s ease,
                border-radius 0.3s ease, padding 0.3s ease !important;
}

/* ===== MINIMIZE: RRETHI ME NOTËN MUZIKORE ===== */
#musicPlayer.music-box.minimized {
    width: 56px !important;
    height: 56px !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    cursor: pointer !important;
    padding: 0 !important;
    background: var(--cherry, #B83232) !important;
    border: 3px solid var(--gold, #B8956A) !important;
    box-shadow: 0 6px 28px rgba(0,0,0,0.55) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
#musicPlayer.music-box.minimized:hover {
    transform: scale(1.12);
    box-shadow: 0 8px 32px rgba(0,0,0,0.7) !important;
}
#musicPlayer.music-box.minimized .win-header {
    width: 100% !important;
    height: 100% !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    pointer-events: none;
}
#musicPlayer.music-box.minimized .win-title { display: none !important; }
#musicPlayer.music-box.minimized #musicBody { display: none !important; }
#musicPlayer.music-box.minimized #minBtn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: transparent !important;
    border: none !important;
    font-size: 1.5rem !important;
    color: white !important;
    pointer-events: all !important;
    cursor: pointer !important;
    width: 100% !important;
    height: 100% !important;
    padding: 0 !important;
}
#musicPlayer.music-box.minimized #musicBody { display: none !important; }
#musicPlayer.music-box.minimized .wood-texture { display: none !important; }

/* Animacion rrotullimi kur luan muzikë */
#musicPlayer.music-box.minimized.playing #minBtn {
    animation: spinNote 2.5s linear infinite;
}
@keyframes spinNote {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ===== FOKUS OVERLAY ===== */
#focusOverlay {
    position: fixed !important;
    inset: 0 !important;
    z-index: 10000 !important;
    background: var(--reader-bg, #111) !important;
    display: none;
    flex-direction: column;
}
#focusOverlay[style*="flex"] { display: flex !important; }
#focusOverlay .focus-header {
    background: var(--reader-header-bg, #000) !important;
}
#focusOverlay iframe {
    flex: 1;
    width: 100%;
    border: none;
    background: var(--reader-bg, #111);
}

/* ===== MODAL FAQESHËNUES ===== */
.bm-ribbon {
    position: absolute;
    top: 10px; left: 0;
    background: var(--gold);
    color: #fff;
    font-size: 0.72rem;
    padding: 4px 10px 4px 8px;
    border-radius: 0 10px 10px 0;
    font-family: 'Lora', serif;
    letter-spacing: 0.5px;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.2);
}
.modal-cover-col { position: relative; }
.modal-pages {
    font-size: 0.8rem;
    color: #888;
    margin: 0 0 10px;
}

/* ===== BADGE FAQESHËNUES NË KARTË ===== */
.badge-bm {
    position: absolute;
    top: 6px; left: 6px;
    background: var(--gold);
    border-radius: 50%;
    width: 26px; height: 26px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    z-index: 3;
}

/* ===== PANELI I FAQESHËNUESVE ===== */
#bmOverlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9990;
    display: none; opacity: 0;
    transition: opacity 0.3s;
}
#bmOverlay.active { display: block; opacity: 1; }

#bmPanel {
    position: fixed;
    top: 0; right: -360px;
    width: 340px; height: 100%;
    background: var(--white, #fff);
    z-index: 9991;
    box-shadow: -4px 0 30px rgba(0,0,0,0.25);
    display: flex; flex-direction: column;
    transition: right 0.35s cubic-bezier(0.4,0,0.2,1);
    backdrop-filter: blur(8px);
}
#bmPanel.active { right: 0; }

.bm-header {
    padding: 18px 20px;
    background: var(--parchment);
    border-bottom: 2px solid var(--gold);
    display: flex; justify-content: space-between; align-items: center;
    font-family: 'Playfair Display', serif;
    font-size: 1rem; font-weight: bold;
    color: var(--charcoal); flex-shrink: 0;
}
.bm-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--charcoal); }
.bm-close:hover { color: var(--cherry); }

#bmList {
    flex: 1; overflow-y: auto; padding: 12px;
}
#bmList::-webkit-scrollbar { width: 4px; }
#bmList::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 4px; }

.bm-item {
    display: flex; gap: 12px; align-items: center;
    padding: 10px; border-radius: 10px;
    cursor: pointer; transition: background 0.18s;
    border: 1px solid transparent;
    margin-bottom: 8px;
}
.bm-item:hover { background: var(--parchment); border-color: var(--gold); }
.bm-thumb {
    width: 44px; height: 64px;
    object-fit: cover; border-radius: 5px;
    box-shadow: 1px 1px 6px rgba(0,0,0,0.2);
    flex-shrink: 0;
}
.bm-info { flex: 1; min-width: 0; }
.bm-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem; font-weight: bold;
    color: var(--charcoal);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bm-author { font-size: 0.75rem; color: var(--gold); margin-top: 2px; }
.bm-date { font-size: 0.7rem; color: #aaa; margin-top: 3px; }
.bm-del {
    background: none; border: none; color: #cc3333;
    font-size: 1.1rem; cursor: pointer; padding: 4px 6px;
    border-radius: 50%; transition: background 0.15s; flex-shrink: 0;
}
.bm-del:hover { background: rgba(180,0,0,0.1); }

/* ===== BUTONI I FAQESHËNUESVE NË HEADER ===== */
.bm-trigger {
    background: none; border: none;
    font-size: 1.3rem; cursor: pointer;
    position: relative; transition: transform 0.2s;
}
.bm-trigger:hover { transform: scale(1.15); }
#bmCount {
    position: absolute; top: -5px; right: -5px;
    background: var(--gold); color: white;
    font-size: 0.65rem; width: 17px; height: 17px;
    border-radius: 50%; display: flex;
    align-items: center; justify-content: center;
    font-weight: bold;
}

/* ===== CILËSIMET E REJA CSS ===== */
body { font-size: var(--page-font-size, 16px); }

/* ===== HERO SPICE: particles efekt ===== */
.hero {
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at 20% 50%, rgba(184,149,106,0.12) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 20%, rgba(184,50,50,0.08) 0%, transparent 50%);
    pointer-events: none;
}

/* ===== BOOK CARD HOVER SPICE ===== */
.book-card {
    transition: transform 0.22s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.22s ease !important;
}
.book-card:hover {
    transform: translateY(-6px) scale(1.02) !important;
    box-shadow: 0 16px 40px rgba(0,0,0,0.18) !important;
}

/* ===== SECTION TITLE UNDERLINE ===== */
.section-title::after {
    content: '';
    display: block;
    width: 60px; height: 3px;
    background: var(--gold);
    border-radius: 2px;
    margin: 8px auto 0;
}

/* ===== SEARCH BOX FOCUS ===== */
.search-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(184,149,106,0.25) !important;
}

/* ===== TOAST SPICE ===== */
.toast {
    border-left: 4px solid var(--gold) !important;
    border-radius: 12px !important;
}

/* ===== KATEGORI HOVER ===== */
.category-card {
    transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1),
                background 0.18s, border-color 0.18s !important;
}
.category-card:hover { transform: translateY(-3px) scale(1.04) !important; }
.category-card.active {
    background: var(--gold) !important;
    color: white !important;
}

/* ===== MOBILE ===== */
@media (max-width: 580px) {
    #musicPlayer.music-box {
        bottom: 12px;
        left: 12px;
    }
    #bookModal.modal { padding: 8px !important; }
}

/* ===== OVERRIDE: Bookmark panel class names ===== */
.bm-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.52);
    z-index: 9990;
    display: none; opacity: 0;
    transition: opacity 0.3s;
}
.bm-overlay.active { display: block !important; opacity: 1 !important; }
.bm-panel {
    position: fixed;
    top: 0; right: -380px;
    width: 350px; height: 100%;
    background: var(--white, #FAF7F2);
    z-index: 9991;
    box-shadow: -4px 0 32px rgba(0,0,0,0.28);
    display: flex; flex-direction: column;
    transition: right 0.35s cubic-bezier(0.4,0,0.2,1);
}
.bm-panel.active { right: 0 !important; }
.bm-list { flex: 1; overflow-y: auto; padding: 12px; }
.bm-list::-webkit-scrollbar { width: 4px; }
.bm-list::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 4px; }

/* ===== OVERRIDE: bm-trigger position fix ===== */
.bm-trigger {
    background: none; border: none;
    font-size: 1.3rem; cursor: pointer;
    position: relative; transition: transform 0.2s;
    padding: 0 4px;
}
.bm-trigger:hover { transform: scale(1.15); }

/* ===== MUSIC MINI NOTE override ===== */
#musicPlayer.music-box.minimized #musicMiniNote {
    display: block !important;
    pointer-events: none;
}
#musicPlayer.music-box:not(.minimized) #musicMiniNote {
    display: none !important;
}
#musicPlayer.music-box:not(.minimized) #minBtn {
    display: flex !important;
    font-size: 1.5rem !important;
}

/* ===== MUSIC BOX: pozicion fillestar PA !important (drag punon) ===== */
#musicPlayer.music-box {
    position: fixed !important;
    bottom: 20px;
    left: 20px;
    top: auto;
    right: auto;
    z-index: 10002 !important;
    transition: width 0.3s, height 0.3s, border-radius 0.3s !important;
}

/* ══════════════════════════════════════
   v6 — MEGA UPDATE CSS
   ══════════════════════════════════════ */

/* ── Stats grid: 6 karta ── */
.stats-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
    gap: 14px !important;
}

/* ── Side panels & overlays (profile / history) ── */
.side-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.52);
    z-index: 9986;
    display: none; opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.side-overlay.active {
    display: block !important;
    opacity: 1 !important;
    pointer-events: all !important;
}
.side-panel {
    transition: right 0.35s cubic-bezier(0.4,0,0.2,1) !important;
}
.side-panel.active { right: 0 !important; }

/* ── Shelf tabs ── */
.shelf-tab {
    font-family: 'Lora', serif;
    border-bottom: 2px solid transparent !important;
    margin-bottom: -2px;
    transition: border-color 0.2s, color 0.2s !important;
}
.shelf-tab.active {
    border-bottom-color: var(--gold) !important;
    color: var(--gold) !important;
    font-weight: bold;
}

/* ── Shelf item rows v2 ── */
.shelf-item-row2 {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px; border-radius: 10px;
    border: 1px solid transparent;
    transition: background 0.18s, border-color 0.18s;
    margin-bottom: 6px; cursor: grab;
}
.shelf-item-row2:hover { background: var(--parchment); border-color: var(--gold); }
.shelf-item-row2:active { cursor: grabbing; }
.shelf-thumb {
    width: 44px; height: 64px;
    object-fit: cover; border-radius: 5px;
    box-shadow: 1px 1px 6px rgba(0,0,0,0.2);
    flex-shrink: 0;
}
.st-btn {
    border: none; border-radius: 6px;
    padding: 3px 7px; cursor: pointer;
    font-size: 0.85rem; transition: transform 0.15s;
}
.st-btn:hover { transform: scale(1.15); }

/* ── History panel items ── */
.hist-item {
    display: flex; gap: 10px; align-items: center;
    padding: 10px 8px; border-radius: 8px;
    cursor: pointer; transition: background 0.15s;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}
.hist-item:hover { background: var(--parchment); }
.hist-icon { font-size: 1.1rem; flex-shrink: 0; }
.hist-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem; font-weight: bold;
    color: var(--charcoal);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hist-time { font-size: 0.72rem; color: #aaa; margin-top: 2px; }
.hist-arr { color: var(--gold); font-size: 1.2rem; flex-shrink: 0; }

/* ── Music equalizer bars ── */
.music-eq {
    display: none;
    gap: 2px; align-items: flex-end;
    height: 16px;
}
#musicPlayer.playing .music-eq { display: flex !important; }
.music-eq span {
    display: block; width: 3px; border-radius: 2px;
    background: rgba(255,255,255,0.7);
    animation: eqBar 0.8s ease-in-out infinite alternate;
    transform-origin: bottom;
}
.music-eq span:nth-child(1) { height: 6px;  animation-duration: 0.6s; }
.music-eq span:nth-child(2) { height: 12px; animation-duration: 0.4s; }
.music-eq span:nth-child(3) { height: 16px; animation-duration: 0.5s; }
.music-eq span:nth-child(4) { height: 10px; animation-duration: 0.7s; }
.music-eq span:nth-child(5) { height: 8px;  animation-duration: 0.45s; }
@keyframes eqBar {
    from { transform: scaleY(0.3); opacity: 0.5; }
    to   { transform: scaleY(1);   opacity: 1;   }
}
#musicPlayer:not(.playing) .music-eq span { animation-play-state: paused; }

/* ── Clock në music box ── */
#musicClock {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.65);
    font-family: 'Lora', serif;
    letter-spacing: 1px;
}

/* ── 3D Book card flip effect ── */
.book-card {
    perspective: 800px;
}

.book-card:hover 

/* Efekt hije 3D për libra */

.book-card:hover 

/* Spine effect (shtylla e librit) */


/* ── Komunitar stars ── */
.comm-star {
    transition: opacity 0.15s, transform 0.15s;
    color: #f39c12;
}
.comm-star.lit { opacity: 1 !important; }

/* ── Rekomandime scroll ── */
.modal-info-col::-webkit-scrollbar { width: 4px; }
.modal-info-col::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 4px; }

/* ── PDF filter button active ── */
#pdfFilterBtn.active-filter {
    background: var(--cherry) !important;
    color: #fff !important;
    border-color: var(--cherry) !important;
}

/* ── Focus overlay header ── */
.focus-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px);
    color: white;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* ── Stats cards hover ── */
.stat-card {
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.2s !important;
    cursor: default;
}
.stat-card:hover {
    transform: translateY(-4px) scale(1.04) !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12) !important;
}

/* ── Dark theme adjustments ── */
[data-theme="dark"] .side-panel,
[data-theme="dark"] .bm-panel,
[data-theme="dark"] #shelfSidebar {
    background: #1e1a17 !important;
    color: #e8dcc4 !important;
}
[data-theme="dark"] .hist-title,
[data-theme="dark"] .bm-title { color: #e8dcc4 !important; }
[data-theme="dark"] .shelf-item-row2:hover { background: #2a2520 !important; }
[data-theme="dark"] .st-btn { color: #ccc !important; }

/* ── Bookmark dialog dark ── */
[data-theme="dark"] #bmDialog > div {
    background: #2C2824 !important;
    color: #e8dcc4 !important;
}
[data-theme="dark"] #bmDialog textarea,
[data-theme="dark"] #bmDialog input[type="number"] {
    background: #3a3530 !important;
    color: #e8dcc4 !important;
    border-color: #5a5048 !important;
}

/* ── Modal pages info ── */
.modal-pages {
    font-size: 0.78rem; color: #999; margin: 0 0 8px;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr) !important; }
    #profilePanel, #histPanel { width: 100% !important; right: -100% !important; }
    #profilePanel.active, #histPanel.active { right: 0 !important; }
    .bm-panel { width: 100% !important; right: -100% !important; }
    .bm-panel.active { right: 0 !important; }
}


/* ══ DEEP SEA THEME: modal fix ══ */
[data-theme="deepsea"] .modal-box {
    background: #0d1e2a !important;
    color: #b8d9ea !important;
    border: 1px solid #1e4060;
}
[data-theme="deepsea"] .modal-title { color: #d6ecf5 !important; }
[data-theme="deepsea"] .modal-author { color: #7fb5cc !important; }
[data-theme="deepsea"] .modal-desc { color: #9fc8db !important; }
[data-theme="deepsea"] .modal-level { color: #6fa8c0 !important; }
[data-theme="deepsea"] .modal-cat-tag { background: #1a3a52 !important; color: #6fb1c9 !important; }
[data-theme="deepsea"] .modal-pages { color: #5a8fa5 !important; }
[data-theme="deepsea"] .variants-label { color: #7fb5cc !important; }
[data-theme="deepsea"] .variant-chip { 
    background: #1a3a52 !important; 
    color: #b8d9ea !important; 
    border-color: #2a5a7a !important;
}
[data-theme="deepsea"] .variant-chip:hover { 
    background: #2a5a7a !important; 
    color: #fff !important;
}
[data-theme="deepsea"] .modal-shelf-btn {
    background: transparent !important;
    color: #6fb1c9 !important;
    border-color: #2a5a7a !important;
}
[data-theme="deepsea"] .modal-read-btn { background: #1a5a8a !important; }

/* ══════════════════════════════════════════════
   GRAMOPHONE PLAYER — Circle Minimize Style
   ══════════════════════════════════════════════ */

.gram-player {
    position: fixed !important;
    bottom: 20px;
    right: 20px;
    bottom: auto;
    left: 20px;
    z-index: 10002 !important;
    user-select: none;
    touch-action: none;
}

/* ── Mini circle (stato minimized) ── */
.gram-circle {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #8b4a2a, #3d1f10);
    border: 3px solid var(--gold, #B8956A);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 2px;
    transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}
.gram-circle:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 28px rgba(0,0,0,0.65);
}
/* Horn decoration */
.gram-circle::after {
    content: '';
    position: absolute;
    top: 4px; right: 4px;
    width: 20px; height: 20px;
    background: radial-gradient(circle, rgba(184,149,106,0.3), transparent);
    border-radius: 50%;
    pointer-events: none;
}

.gram-vinyl-mini {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: repeating-radial-gradient(circle at 50%, #111 0, #111 2px, #222 2px, #222 4px, #1a1a1a 4px, #1a1a1a 5px);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    transition: animation 0.3s;
}
.gram-player.playing .gram-vinyl-mini {
    animation: spinVinyl 3s linear infinite;
}
.gram-vinyl-center {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: radial-gradient(circle, #f0d080, #c8a020);
    box-shadow: 0 0 4px rgba(200,160,32,0.6);
}

.gram-eq-mini {
    display: none;
    gap: 2px;
    align-items: flex-end;
    height: 10px;
}
.gram-player.playing .gram-eq-mini { display: flex !important; }
.gram-eq-mini span {
    display: block; width: 2px;
    background: var(--gold, #B8956A);
    border-radius: 1px;
    animation: eqBar 0.6s ease-in-out infinite alternate;
}
.gram-eq-mini span:nth-child(1) { height: 4px;  animation-duration: 0.5s; }
.gram-eq-mini span:nth-child(2) { height: 8px;  animation-duration: 0.35s; }
.gram-eq-mini span:nth-child(3) { height: 5px;  animation-duration: 0.55s; }

/* ── Expanded panel ── */
.gram-panel {
    position: absolute;
    bottom: 0; left: 0;
    width: 272px;
    background: rgba(42, 22, 10, 0.96);
    backdrop-filter: blur(12px);
    border: 2px solid var(--cherry, #B83232);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    color: #EFEBE9;
    overflow: hidden;
    transform-origin: bottom left;
    transition: transform 0.4s cubic-bezier(0.34,1.4,0.64,1),
                opacity 0.35s ease;
    /* Visible by default */
}
/* gram-panel visibility by JS */
/* gram-circle show/hide controlled by JS */

.gram-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px 8px;
    background: var(--cherry, #B83232);
    cursor: grab;
}
.gram-panel-header:active { cursor: grabbing; }
.gram-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem; font-weight: bold;
    letter-spacing: 0.3px;
}
.gram-clock {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.75);
    font-family: 'Lora', serif;
    letter-spacing: 1px;
}
.gram-min-btn {
    background: rgba(255,255,255,0.15);
    border: none; border-radius: 50%;
    width: 22px; height: 22px;
    color: white; cursor: pointer;
    font-size: 0.85rem;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.gram-min-btn:hover { background: rgba(255,255,255,0.3); }

.gram-vinyl-wrap {
    display: flex; justify-content: center;
    padding: 12px 0 6px;
}
.gram-vinyl-wrap .vinyl-record { width: 80px !important; height: 80px !important; }

.gram-eq {
    display: none !important;
    gap: 3px; align-items: flex-end; justify-content: center;
    height: 18px; padding: 0 0 6px;
}
.gram-player.playing .gram-eq { display: flex !important; }
.gram-eq span {
    display: block; width: 3px;
    background: var(--gold, #B8956A);
    border-radius: 2px;
    animation: eqBar 0.7s ease-in-out infinite alternate;
}
.gram-eq span:nth-child(1) { height: 6px;  animation-duration: 0.6s; }
.gram-eq span:nth-child(2) { height: 14px; animation-duration: 0.4s; }
.gram-eq span:nth-child(3) { height: 18px; animation-duration: 0.5s; }
.gram-eq span:nth-child(4) { height: 12px; animation-duration: 0.65s; }
.gram-eq span:nth-child(5) { height: 8px;  animation-duration: 0.45s; }

.gram-controls {
    display: flex; justify-content: center;
    padding: 8px 0 14px;
}
.gram-play-btn {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--cherry, #B83232);
    border: 2px solid var(--gold, #B8956A);
    color: white; font-size: 1rem;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 3px 12px rgba(0,0,0,0.4);
}
.gram-play-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 5px 18px rgba(0,0,0,0.5);
}

/* vinyl spin */
@keyframes spinVinyl {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
#vinylRecord.spinning { animation: spinVinyl 3s linear infinite !important; }

/* Hide old music-box class rules (compatibility) */
#musicPlayer.music-box { display: none !important; }

/* Visitors counter animation */
.stat-readers-card .stat-number {
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1), color 0.3s;
}
.stat-readers-card .stat-number.bump {
    transform: scale(1.4) !important;
    color: var(--cherry) !important;
}

/* ── CSS VARS: apliko setting-et tek body ── */
body {
    font-size: var(--page-font-size, 16px);
    font-family: var(--body-font, 'Lora', serif);
    letter-spacing: var(--reading-letter-spacing, 0px);
}
/* PDF reader iframe container */
#focusOverlay iframe {
    font-size: var(--reading-font-size, 16px);
}
/* Sidebar content */
.sidebar-scroll-body,
.setting-row,
.settings-subtitle {
    font-size: var(--page-font-size, 16px);
}

/* Apply reading vars to modal content (where text is read) */
.modal-desc, .modal-title, .modal-author, .modal-box {
    font-family: var(--reading-font, 'Lora', serif) !important;
    font-size: var(--reading-font-size, 16px);
    line-height: var(--reading-line-height, 1.6);
    text-align: var(--reading-align, left);
}


/* ══════════════════════════════════════════════════════
   TEMAT E REJA — v9
   ══════════════════════════════════════════════════════ */

/* 🌿 PYLL */
[data-theme="forest"] {
    --cream:    #1a2a1a;
    --parchment:#213121;
    --gold:     #7ec87e;
    --cherry:   #4a9e6a;
    --charcoal: #d4f0d4;
    --white:    #141f14;
    --shadow:   rgba(0,0,0,0.5);
    --overlay-bg: rgba(0,12,0,0.82);
}
[data-theme="forest"] body { background: #1a2a1a; color: #d4f0d4; }
[data-theme="forest"] .header { background: rgba(26,42,26,0.95) !important; }
[data-theme="forest"] .book-card { background: #213121; border-color: #2d4a2d; }
[data-theme="forest"] .book-card:hover { background: #253525; }
[data-theme="forest"] .modal-box { background: #1e301e !important; color: #d4f0d4 !important; }
[data-theme="forest"] .modal-title { color: #a0e0a0 !important; }
[data-theme="forest"] .modal-desc { color: #b8d8b8 !important; }
[data-theme="forest"] .left-sidebar { background: #1a2a1a; }
[data-theme="forest"] .stats { background: #213121; }
[data-theme="forest"] .stat-card { background: #2a3e2a; color: #d4f0d4; }

/* 🌹 TRËNDAFIL */
[data-theme="rose"] {
    --cream:    #fff0f3;
    --parchment:#fde8ec;
    --gold:     #c0617a;
    --cherry:   #a03050;
    --charcoal: #3a1525;
    --white:    #fff8f9;
    --shadow:   rgba(160,48,80,0.15);
    --overlay-bg: rgba(60,10,20,0.7);
}
[data-theme="rose"] body { background: #fff0f3; }
[data-theme="rose"] .header { background: rgba(255,240,243,0.95) !important; border-bottom-color: #c0617a !important; }
[data-theme="rose"] .hero { background: linear-gradient(135deg, #ffe0e6 0%, #ffd0d8 100%); }
[data-theme="rose"] .book-card { background: #fde8ec; border-color: #f0b8c4; }
[data-theme="rose"] .book-card:hover { background: #fcd8e0; box-shadow: 0 8px 28px rgba(192,97,122,0.2) !important; }
[data-theme="rose"] .modal-box { background: #fff0f3 !important; }
[data-theme="rose"] .modal-title { color: #a03050 !important; }
[data-theme="rose"] .stats { background: #fde8ec; }
[data-theme="rose"] .stat-card { background: #fff0f3; }
[data-theme="rose"] .left-sidebar { background: #fff0f3; border-right-color: #f0b8c4; }
[data-theme="rose"] .category-card { background: #fde8ec; border-color: #f0b8c4; }
[data-theme="rose"] .section-title .highlight { color: #c0617a; }

/* 🔮 MESNATË */
[data-theme="midnight"] {
    --cream:    #0d0d1a;
    --parchment:#12122a;
    --gold:     #9b8dff;
    --cherry:   #6b5bcc;
    --charcoal: #e0dcff;
    --white:    #080812;
    --shadow:   rgba(0,0,0,0.7);
    --overlay-bg: rgba(0,0,20,0.88);
}
[data-theme="midnight"] body { background: #0d0d1a; color: #e0dcff; }
[data-theme="midnight"] .header { background: rgba(13,13,26,0.95) !important; border-bottom-color: #9b8dff !important; }
[data-theme="midnight"] .hero { background: linear-gradient(135deg, #12122a 0%, #1a1a3a 100%); }
[data-theme="midnight"] .book-card { background: #12122a; border-color: #2a2a4a; }
[data-theme="midnight"] .book-card:hover { background: #18183a; box-shadow: 0 8px 28px rgba(155,141,255,0.25) !important; }
[data-theme="midnight"] .modal-box { background: #10102a !important; color: #e0dcff !important; border-color: #2a2a4a; }
[data-theme="midnight"] .modal-title { color: #c0b8ff !important; }
[data-theme="midnight"] .modal-desc { color: #b0a8f0 !important; }
[data-theme="midnight"] .stats { background: #12122a; }
[data-theme="midnight"] .stat-card { background: #18183a; color: #e0dcff; }
[data-theme="midnight"] .left-sidebar { background: #0d0d1a; border-right-color: #2a2a4a; }
[data-theme="midnight"] .category-card { background: #12122a; border-color: #2a2a4a; color: #e0dcff; }
[data-theme="midnight"] .stats-grid .stat-number { color: #9b8dff !important; }

/* 💜 LAVANDË */
[data-theme="lavender"] {
    --cream:    #f4f0ff;
    --parchment:#ece4ff;
    --gold:     #7c5cbf;
    --cherry:   #5a3a9a;
    --charcoal: #2a1a4a;
    --white:    #faf8ff;
    --shadow:   rgba(90,58,154,0.12);
    --overlay-bg: rgba(30,10,60,0.72);
}
[data-theme="lavender"] body { background: #f4f0ff; }
[data-theme="lavender"] .header { background: rgba(244,240,255,0.95) !important; border-bottom-color: #7c5cbf !important; }
[data-theme="lavender"] .hero { background: linear-gradient(135deg, #ede0ff 0%, #ddd0f8 100%); }
[data-theme="lavender"] .book-card { background: #ece4ff; border-color: #d8c8ff; }
[data-theme="lavender"] .book-card:hover { background: #e4d8ff; }
[data-theme="lavender"] .modal-box { background: #f4f0ff !important; }
[data-theme="lavender"] .modal-title { color: #5a3a9a !important; }
[data-theme="lavender"] .stats { background: #ece4ff; }
[data-theme="lavender"] .stat-card { background: #f4f0ff; }
[data-theme="lavender"] .left-sidebar { background: #f4f0ff; border-right-color: #d8c8ff; }
[data-theme="lavender"] .category-card { background: #ece4ff; border-color: #d8c8ff; }

/* 🌅 PERËNDIM */
[data-theme="sunset"] {
    --cream:    #1a1010;
    --parchment:#2a1818;
    --gold:     #ff9944;
    --cherry:   #cc4422;
    --charcoal: #ffe8d8;
    --white:    #120a08;
    --shadow:   rgba(0,0,0,0.6);
    --overlay-bg: rgba(20,5,0,0.85);
}
[data-theme="sunset"] body { background: linear-gradient(180deg, #1a1010 0%, #120808 100%); color: #ffe8d8; }
[data-theme="sunset"] .header { background: rgba(26,16,16,0.95) !important; border-bottom-color: #ff9944 !important; }
[data-theme="sunset"] .hero { background: linear-gradient(135deg, #2a1515 0%, #3a1a10 50%, #1a1010 100%); }
[data-theme="sunset"] .book-card { background: #2a1818; border-color: #3a2020; }
[data-theme="sunset"] .book-card:hover { background: #321e1e; box-shadow: 0 8px 28px rgba(255,153,68,0.2) !important; }
[data-theme="sunset"] .modal-box { background: #231212 !important; color: #ffe8d8 !important; }
[data-theme="sunset"] .modal-title { color: #ff9944 !important; }
[data-theme="sunset"] .modal-desc { color: #f0d0b0 !important; }
[data-theme="sunset"] .stats { background: #2a1818; }
[data-theme="sunset"] .stat-card { background: #321e1e; color: #ffe8d8; }
[data-theme="sunset"] .left-sidebar { background: #1a1010; border-right-color: #3a2020; }
[data-theme="sunset"] .stats-grid .stat-number { color: #ff9944 !important; }

/* 📄 LETËR E VJETËR */
[data-theme="paper"] {
    --cream:    #f2e8d5;
    --parchment:#e8dac0;
    --gold:     #8b6914;
    --cherry:   #6b3a1a;
    --charcoal: #2a1a08;
    --white:    #faf4e8;
    --shadow:   rgba(80,40,0,0.15);
    --overlay-bg: rgba(40,20,0,0.72);
}
[data-theme="paper"] body { background: #f2e8d5; }
[data-theme="paper"] .header { background: rgba(242,232,213,0.97) !important; border-bottom-color: #8b6914 !important; }
[data-theme="paper"] .hero { background: linear-gradient(135deg, #ede0c4 0%, #e0d0b0 100%); }
[data-theme="paper"] .book-card { background: #e8dac0; border-color: #d4c098; }
[data-theme="paper"] .book-card:hover { background: #e0d0b0; }
[data-theme="paper"] .modal-box { background: #f2e8d5 !important; }
[data-theme="paper"] .modal-title { color: #6b3a1a !important; }
[data-theme="paper"] .stats { background: #e8dac0; }
[data-theme="paper"] .stat-card { background: #f2e8d5; }
[data-theme="paper"] .left-sidebar { background: #f2e8d5; border-right-color: #d4c098; }


/* ══════════════════════════════════════════════════════
   MOBILE FIX — PAMJA E TELEFONIT
   ══════════════════════════════════════════════════════ */

/* ── Phone View mode (toggle nga settings) ── */
body.phone-view {
    --phone-mode: 1;
}

/* ── Responsive base fix ── */
@media (max-width: 768px) {

    /* Header i kompaktuar */
    .header { padding: 0 12px !important; height: 50px !important; }
    .logo-text h1 { font-size: 1rem !important; }
    .logo-text p, #libraryName { font-size: 0.7rem !important; }
    .header-actions { gap: 6px !important; }
    .header-actions button { font-size: 1.1rem !important; padding: 0 3px !important; }

    /* Hero seksion */
    .hero { padding: 24px 16px !important; }
    .hero h2 { font-size: 1.4rem !important; }
    .hero p  { font-size: 0.85rem !important; }
    .hero-actions { flex-direction: column !important; gap: 8px !important; }
    .hero-actions .btn-primary,
    .hero-actions .btn-secondary { width: 100% !important; text-align: center !important; justify-content: center !important; }

    /* Stats grid — 3 kolona në 2 rreshta */
    .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
        justify-items: center !important;
    }
    .stat-card { padding: 10px 6px !important; }
    .stat-card .stat-icon { font-size: 1.3rem !important; margin-bottom: 4px !important; }
    .stat-number { font-size: 1.1rem !important; }
    .stat-label { font-size: 0.6rem !important; }

    /* Kategorite — scroll horizontal */
    .categories-grid {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        gap: 8px !important;
        padding-bottom: 6px !important;
        scrollbar-width: none !important;
    }
    .categories-grid::-webkit-scrollbar { display: none !important; }
    .category-card {
        flex-shrink: 0 !important;
        min-width: 80px !important;
        padding: 8px 10px !important;
        font-size: 0.78rem !important;
    }

    /* Books controls */
    .books-controls {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .search-box { flex: 1 1 100% !important; }
    .sort-select { flex: 1 !important; min-width: 100px !important; }
    #pdfFilterBtn { padding: 7px 10px !important; font-size: 0.78rem !important; }

    /* Grid librave — 2 kolona */
    
    .book-card { padding: 8px !important; }
    .book-title { font-size: 0.75rem !important; }
    .book-author { font-size: 0.65rem !important; }

    /* Music player — jo jashtë ekranit */
    .gram-player {
        bottom: 10px !important;
        left: 10px !important;
    }
    .gram-panel { width: 240px !important; }

    /* Modal — full width */
    .modal-box {
        margin: 8px !important;
        max-height: 92vh !important;
        overflow-y: auto !important;
    }
    .modal-layout {
        flex-direction: column !important;
        gap: 14px !important;
    }
    .modal-cover-col { display: flex !important; justify-content: center !important; }
    .modal-cover-img { max-height: 200px !important; width: auto !important; }

    /* Sidebar — full width në mobile */
    .left-sidebar { width: 100% !important; max-width: 340px !important; }

    /* Section padding */
    .books-section { padding: 16px !important; }
    .books-section .container { padding: 0 !important; }
    section.stats { padding: 16px 12px !important; }

    /* Focus overlay header */
    .focus-header { padding: 8px 12px !important; }
    .focus-header span { font-size: 0.85rem !important; }
}

/* ── Extra small (< 400px) ── */
@media (max-width: 400px) {
    
    .gram-panel { width: 220px !important; }
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .hero h2 { font-size: 1.2rem !important; }
}

/* ── PHONE VIEW aktiv (nga settings toggle) ── */
body.phone-view 
body.phone-view .modal-layout { flex-direction: column !important; }
body.phone-view .modal-cover-img { max-height: 180px !important; width: auto !important; }
body.phone-view .gram-panel { width: 240px !important; }
body.phone-view .stats-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 8px !important; }
body.phone-view .categories-grid {
    display: flex !important;
    overflow-x: auto !important;
    flex-wrap: nowrap !important;
    scrollbar-width: none !important;
}
body.phone-view .category-card { flex-shrink: 0 !important; }
body.phone-view .books-controls { flex-wrap: wrap !important; }
body.phone-view .search-box { flex: 1 1 100% !important; }
body.phone-view .hero-actions { flex-direction: column !important; }
body.phone-view .hero-actions button { width: 100% !important; }
body.phone-view .book-title { font-size: 0.75rem !important; }
body.phone-view .book-author { font-size: 0.65rem !important; }


/* Gram circle spin kur luan */
.gram-circle.playing .gram-vinyl-mini {
    animation: spinVinyl 2.5s linear infinite !important;
}
.gram-circle .gram-vinyl-mini {
    animation: none;
}

/* ════════════════════════════════════════
   3D BOOK BUTTON on card hover
   ════════════════════════════════════════ */
.btn-3d {
    opacity: 0;
    transition: opacity 0.2s, transform 0.15s !important;
}
.book-card:hover .btn-3d {
    opacity: 1 !important;
}
.btn-3d:hover {
    transform: scale(1.2) !important;
    background: rgba(184,149,106,0.9) !important;
}

/* 3D overlay scene */
#book3dScene {
    filter: drop-shadow(0 20px 40px rgba(0,0,0,0.7));
}

/* Book card position relative (per btn-3d absolute) */
.book-cover-wrap {
    position: relative;
}

/* Series badge on card */
.series-badge {
    position: absolute;
    bottom: 6px;
    left: 4px;
    background: rgba(0,0,0,0.65);
    color: #e8d5b5;
    font-size: 0.58rem;
    padding: 2px 6px;
    border-radius: 99px;
    font-family: 'Lora', serif;
    white-space: nowrap;
    max-width: 90%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* btn-3d-modal in modal */
.btn-3d-modal:hover {
    background: rgba(0,0,0,0.12) !important;
    border-color: var(--gold) !important;
}
.btn-series:hover {
    background: var(--parchment) !important;
    border-color: var(--gold) !important;
}

/* ═══ 3D BOOK CARDS (Three.js) ═══ */
.book-card-3d { padding: 0 !important; background: transparent !important; box-shadow: none !important; border: none !important; }
.book-card-3d:hover { transform: translateY(-5px) scale(1.02) !important; }
.book-3d-wrap { position:relative; width:100%; cursor:pointer; }
.book-3d-canvas { display:block; width:100% !important; border-radius:4px; }
.book-3d-badges { position:absolute; inset:0; pointer-events:none; }
.badge-progress { position:absolute; bottom:6px; right:6px; background:rgba(0,0,0,0.72); color:#fff; font-size:0.6rem; padding:2px 6px; border-radius:99px; font-weight:bold; }
.book-card-3d .book-info { padding:8px 4px 6px !important; }
.book-card-3d:hover .book-3d-wrap { filter: drop-shadow(0 14px 28px rgba(0,0,0,0.4)); }



/* ════════════════════════════════════════════════════════
   CSS 3D BOOK SYSTEM — qysh nga fillimi
   ════════════════════════════════════════════════════════ */

/* Grid */

#booksGrid.list-view { display: flex !important; flex-direction: column !important; gap: 10px !important; }

/* Card wrapper — zero padding */
.book-3d-card {
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    cursor: pointer;
}
.book-3d-card:hover {
    transform: translateY(-6px) !important;
    box-shadow: none !important;
}

/* 3D Scene — perspective container */
.b3d-scene {
    perspective: 600px;
    perspective-origin: 35% 45%;
    width: 100%;
    cursor: grab;
    user-select: none;
    touch-action: none;
}

/* The book — 3D rotatable */
.b3d-book {
    position: relative;
    transform-style: preserve-3d;
    transform: rotateX(5deg) rotateY(-25deg);
    transition: filter 0.3s, transform 0.05s;
    width: 100%;
    padding-bottom: 148%;
    /* Spine hapësiara: lë vend majtas për spinën e dukshme */
    margin-left: calc(var(--spine-w, 22px) * 0.6);
    width: calc(100% - var(--spine-w, 22px) * 0.6);
}
.b3d-scene:hover .b3d-book {
    filter: drop-shadow(0 18px 32px rgba(0,0,0,0.45));
}

/* ── FACES ── */
.b3d-face {
    position: absolute;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Front cover */
.b3d-front {
    inset: 0;
    border-radius: 0 3px 3px 0;
    transform: translateZ(0);
    background: var(--parchment);
}
.b3d-cover-img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 0 3px 3px 0;
}

/* Spine — larguara nga gjerësia e spinës */
.b3d-spine {
    position: absolute;
    top: 0; bottom: 0;
    /* Spine sits to the LEFT of front face */
    right: 100%;
    width: var(--spine-w, 22px);
    background: var(--spine-c, #5c2d0a);
    /* Rotate 90deg around left edge of front cover */
    transform: rotateY(-90deg);
    transform-origin: right center;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: inset -6px 0 16px rgba(0,0,0,0.4), inset 2px 0 6px rgba(255,255,255,0.08);
    backface-visibility: hidden;
}
.b3d-spine-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    color: rgba(255,255,255,0.88);
    font-family: 'Playfair Display', serif;
    font-size: clamp(7px, calc(var(--spine-w, 22px) * 0.45), 13px);
    font-weight: bold;
    letter-spacing: 0.5px;
    padding: 8px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-height: 90%;
}

/* Top edge — faqet */
.b3d-top {
    left: 0; right: 0;
    top: 0;
    height: var(--spine-w, 22px);
    background: linear-gradient(
        90deg,
        #c8bc9a 0%,
        #e8dcc4 30%,
        #f0e8d0 60%,
        #e0d4b8 100%
    );
    transform: rotateX(90deg);
    transform-origin: top center;
    /* Lines — faqet e librit */
    background-image: repeating-linear-gradient(
        90deg,
        transparent 0px,
        transparent 2px,
        rgba(0,0,0,0.04) 2px,
        rgba(0,0,0,0.04) 3px
    ), linear-gradient(90deg, #c8bc9a 0%, #e8dcc4 30%, #f0e8d0 60%, #e0d4b8 100%);
}

/* Badges mbi cover */
.b3d-front .badge-pdf,
.b3d-front .badge-pop,
.b3d-front .badge-bm {
    position: absolute;
    z-index: 5;
    pointer-events: none;
}
.b3d-prog-badge {
    position: absolute;
    bottom: 6px; right: 6px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 99px;
    font-weight: bold;
    font-family: 'Lora', serif;
}

/* Series tag */
.series-tag {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--gold);
    font-family: 'Lora', serif;
    font-style: italic;
    margin-bottom: 2px;
}

/* Book info */
.book-3d-card .book-info {
    padding: 8px 2px 4px !important;
}

/* List view fallback */
#booksGrid.list-view .book-3d-card {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 14px !important;
    padding: 10px 12px !important;
    background: var(--white) !important;
    border: 1px solid rgba(0,0,0,0.06) !important;
    border-radius: 10px !important;
}
#booksGrid.list-view .b3d-scene {
    width: 56px !important;
    flex-shrink: 0 !important;
    perspective: 600px !important;
}
#booksGrid.list-view .b3d-book {
    padding-bottom: 145% !important;
}
#booksGrid.list-view .book-info {
    flex: 1 !important;
    padding: 0 !important;
}

/* Dark theme */
[data-theme="dark"] .b3d-front {
    background: #2a2018;
}
[data-theme="dark"] .book-3d-card {
    background: transparent !important;
}

/* Compact mode */
.book-3d-card.compact .b3d-book { padding-bottom: 135%; }
.book-3d-card.compact .b3d-spine-title { font-size: clamp(6px, calc(var(--spine-w,18px)*0.38), 10px); }
.book-3d-card.compact .book-author { display: none !important; }
.book-3d-card.compact .vol-tag { display: none !important; }
#booksGrid.compact-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)) !important; }

/* Remove old 3D CSS leftovers */
.book-card-inner { transform: none !important; }
.book-cover-wrap::before { display: none !important; }
.btn-3d { display: none !important; }

/* Hover transition on card level */
.book-3d-card { transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1) !important; }

/* ══ GRID — 4 libra për rresht ══ */
@media (max-width: 900px) {
    }
@media (max-width: 600px) {
    }
#booksGrid.list-view {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
}


/* ══ GRID FIX — 4 per row, force override .books-grid ══ */
#booksGrid,
div#booksGrid,
.books-grid@media (max-width: 1000px) {
    #booksGrid, div}
@media (max-width: 650px) {
    #booksGrid, div}

/* ══ BACK FACE — e zezë me info libri ══ */
.b3d-back {
    position: absolute;
    inset: 0;
    border-radius: 0 3px 3px 0;
    transform: rotateY(180deg);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: #111;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 10px;
    box-sizing: border-box;
    text-align: center;
    overflow: hidden;
    border-left: 3px solid var(--spine-c, #5c2d0a);
}
.b3d-back-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(0.55rem, 1.8vw, 0.78rem);
    font-weight: bold;
    color: #e8d5b5;
    margin-bottom: 6px;
    line-height: 1.3;
}
.b3d-back-author {
    font-family: 'Lora', serif;
    font-size: clamp(0.48rem, 1.5vw, 0.65rem);
    color: #b8956a;
    margin-bottom: 8px;
    font-style: italic;
}
.b3d-back-desc {
    font-family: 'Lora', serif;
    font-size: clamp(0.42rem, 1.3vw, 0.58rem);
    color: rgba(255,255,255,0.55);
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}
.b3d-back-meta {
    margin-top: 8px;
    font-size: clamp(0.4rem, 1.2vw, 0.55rem);
    color: rgba(255,255,255,0.35);
    font-family: 'Lora', serif;
}
.b3d-back-line {
    width: 30px;
    height: 1px;
    background: var(--spine-c, #5c2d0a);
    margin: 6px auto;
    opacity: 0.7;
}

.modal-copies {
    font-size: 0.78rem;
    color: var(--gold);
    margin: 0 0 6px;
    font-family: 'Lora', serif;
}
