:root { 
    --bg-color: #121212; 
    --card-bg: #1e1e1e; 
    --text-primary: #f5f5f5; 
    --text-secondary: #aaaaaa; 
    --border-color: #333;
    --accent: #ff9800; 
    --accent-hover: #f57c00; 
    --danger: #f44336;
    --wm-blend: screen;
    --wm-opacity: 0.07;
    --wm-filter: grayscale(100%) invert(1);
}

/* 🎨 TEMAS DINÂMICOS DE LEITURA (Injetados via JS no Body) 🎨 */
body.theme-light { --bg-color: #f0f3f4; --card-bg: #ffffff; --text-primary: #1a1a1a; --text-secondary: #555555; --border-color: #dddddd; --wm-blend: difference; --wm-opacity: 0.05; }
body.theme-sepia { --bg-color: #f4ecd8; --card-bg: #fdf6e3; --text-primary: #433422; --text-secondary: #7a634b; --border-color: #e2d3b6; --wm-blend: difference; --wm-opacity: 0.08; }
body.theme-oled { --bg-color: #000000; --card-bg: #000000; --text-primary: #d1d1d1; --text-secondary: #777777; --border-color: #333333; --wm-blend: screen; --wm-opacity: 0.05; --wm-filter: grayscale(100%) invert(1); } /* Borda Cinza Visível no OLED */
body.theme-dim { --bg-color: #1e2124; --card-bg: #282b30; --text-primary: #d1d5db; --text-secondary: #9ca3af; --border-color: #42454a; --wm-blend: screen; --wm-opacity: 0.06; --wm-filter: grayscale(100%) invert(1); }

/* ... (mantenha o resto do body, nav, header igual) ... */

/* =========================================================
   FORÇA BRUTA: Nuke em estilos inline antigos (#222, #333) 
   ========================================================= */
textarea, input, select { 
    background-color: var(--bg-color) !important; 
    color: var(--text-primary) !important; 
    border: 1px solid var(--border-color) !important; 
}
.admin-chap-list li { 
    background-color: var(--card-bg) !important; 
    border: 1px solid var(--border-color) !important; 
    color: var(--text-primary) !important; 
}

/* O SEGREDO PRA CAIXA DO RATING E STATS DO LIVRO ESTÁ AQUI: */
.rating-section, .comment-box, .book-details-top > div, .rating-interactive { 
    background-color: var(--card-bg) !important; 
    border: 1px solid var(--border-color) !important; 
    color: var(--text-primary) !important; 
}

/* ================================================= */
/* 🚀 PREPARAÇÃO DO BODY (Desliga a cor natural)     */
/* ================================================= */
body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background-color: transparent !important; 
    color: var(--text-primary); 
    margin: 0; 
    padding: 0; 
    line-height: 1.6; 
    -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
    
    /* Força o Body a ser a base de tudo */
    position: relative;
    z-index: 0;
    
    /* 🚀 FIX MOBILE: Cria um ambiente isolado para o Blend-Mode não bugar no celular */
    isolation: isolate;
}

.container { 
    max-width: 1000px; 
    margin: 0 auto; 
    padding: 0 20px; 
}
header { background-color: var(--card-bg); padding: 15px 0; border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 1000; box-shadow: 0 4px 6px rgba(0,0,0,0.3); transition: top 0.3s ease-in-out, background-color 0.3s; }
nav { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; position: relative; }
.logo { font-size: 1.5rem; font-weight: bold; color: var(--text-primary); text-decoration: none; display: flex; align-items: center;}
.links { display: flex; gap: 15px; align-items: center; flex-wrap: wrap;}
.links a { color: var(--text-secondary); text-decoration: none; transition: color 0.3s; font-size: 0.95rem; }
.links a:hover { color: var(--accent); }

.mobile-toggle { display: none; background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 5px; align-items: center; justify-content: center; }

.user-menu { position: relative; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.user-avatar { width: 35px; height: 35px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border-color); }
.dropdown-content { display: none; position: absolute; top: 45px; right: 0; background: var(--card-bg); min-width: 180px; box-shadow: 0 8px 16px rgba(0,0,0,0.5); z-index: 101; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-color); }
.dropdown-content a { color: var(--text-primary); padding: 12px 16px; text-decoration: none; display: block; border-bottom: 1px solid var(--border-color); }
.dropdown-content a:hover { background: var(--bg-color); color: var(--accent); }
.show { display: block !important; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 30px; }
.book-card { background-color: var(--card-bg); border-radius: 8px; overflow: hidden; text-decoration: none; color: inherit; display: block; transition: transform 0.2s; position: relative; border: 1px solid var(--border-color); }
.book-card:hover { transform: translateY(-5px); box-shadow: 0 8px 15px rgba(0,0,0,0.5); border-color: var(--accent); }
.book-cover-img { width: 100%; aspect-ratio: 3/4; object-fit: cover; background: var(--bg-color); display: block;}
.book-info { padding: 15px; }

.book-header { display: flex; gap: 40px; margin-top: 40px; flex-wrap: wrap; }
.cover-wrapper { position: relative; width: 250px; flex-shrink: 0; display: block; border-radius: 8px; }
.book-cover-large { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; background: var(--bg-color); box-shadow: 0 10px 20px rgba(0,0,0,0.5); display: block; }
.book-details-top { flex: 1; min-width: 300px; }
.heart-btn { position: absolute; bottom: 15px; right: 15px; background: rgba(34, 34, 34, 0.9); border: 2px solid #555; border-radius: 50%; width: 45px; height: 45px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 20px; transition: all 0.3s; z-index: 10; color: #888; box-shadow: 0 4px 10px rgba(0,0,0,0.5);}

.controls { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--accent); padding-bottom: 10px; margin-bottom: 20px; }
.chapter-item { display: flex; align-items: center; justify-content: space-between; background: var(--card-bg); margin-bottom: 10px; border-radius: 8px; border: 1px solid var(--border-color); transition: 0.3s; }
.chapter-item:hover { background: var(--bg-color); border-color: var(--accent); }
.chapter-item a { flex-grow: 1; padding: 15px 20px; text-decoration: none; color: var(--text-primary); font-weight: bold; }
.chapter-item span { margin-right: 15px; color: var(--text-secondary); font-size: 0.9rem; }
.pagination { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.page-btn { padding: 8px 12px; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; cursor: pointer; color: var(--text-primary); transition: 0.2s;}
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #1c1009; }

.chapter-nav { display: flex; justify-content: center; align-items: center; margin: 30px 0; gap: 15px; flex-wrap: wrap;}
.chapter-nav a, .chapter-nav button { flex: 1; text-align: center; padding: 12px; font-size: 1rem; border-radius: 8px; font-weight: bold; min-width: 120px; box-sizing: border-box; max-width: 250px;}

.sidebar { height: 100%; width: 0; position: fixed; z-index: 1000; top: 0; right: 0; background-color: var(--bg-color); overflow-x: hidden; transition: 0.3s; box-shadow: -5px 0 15px rgba(0,0,0,0.8); display:flex; flex-direction:column;}
.sidebar-header { padding: 20px; border-bottom: 1px solid var(--border-color); display:flex; justify-content:flex-start; align-items:center; background: var(--card-bg); gap: 15px;}
.sidebar-content { padding: 20px; overflow-y: auto; flex-grow: 1; position: relative;}
.close-btn { color: var(--text-secondary); font-size: 32px; line-height: 1; font-weight: bold; cursor: pointer; text-decoration: none; }
.close-btn:hover { color: var(--text-primary); }

.comment-box { background: var(--card-bg); padding: 15px; border-radius: 8px; margin-bottom: 15px; border: 1px solid var(--border-color); position:relative; }
.comment-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.comment-head img { width: 30px; height: 30px; border-radius: 50%; object-fit:cover; border: 1px solid var(--border-color);}
.comment-head a { color: var(--accent); text-decoration: none; font-weight: bold; }
.comment-head a:hover { text-decoration: underline; }
.comment-text { color: var(--text-primary); font-size: 0.95rem; margin-bottom: 10px; white-space: pre-wrap; line-height: 1.5; }
.comment-text a { color: var(--accent); text-decoration: none; font-weight: bold; }
.comment-text a:hover { text-decoration: underline; }
.comment-actions { display: flex; gap: 15px; font-size: 0.85rem; color: var(--text-secondary); }
.action-btn { cursor: pointer; transition: color 0.2s; display: flex; align-items: center; gap: 5px; }
.action-btn:hover, .action-btn.active { color: var(--accent); }
.comment-input-area { display: flex; flex-direction: column; gap: 10px; margin-bottom: 30px; position: relative; }
.comment-input-area textarea { padding: 12px; border-radius: 8px; background: var(--card-bg); border: 1px solid var(--border-color); color: var(--text-primary); resize: vertical; min-height: 80px; font-family: inherit;}

.mention-dropdown { position: absolute; top: 100%; left: 0; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; max-height: 150px; overflow-y: auto; z-index: 1000; display: none; min-width: 200px; box-shadow: 0 4px 10px rgba(0,0,0,0.5);}
.mention-item { padding: 10px 15px; cursor: pointer; color: var(--text-primary); border-bottom: 1px solid var(--border-color); font-size: 0.9rem; }
.mention-item:hover { background: var(--accent); color:#1c1009; }

.reading-area { 
    background: var(--card-bg); 
    padding: 40px; 
    border-radius: 8px; 
    margin-top: 40px; 
    font-size: 1.15rem; 
    line-height: 1.8; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
    border: 1px solid var(--border-color);
}
.content-panel { background: var(--card-bg); padding: 30px; border-radius: 8px; border: 1px solid var(--border-color); margin-top: 40px; }
.admin-section, .profile-section { background: var(--card-bg); padding: 30px; border-radius: 8px; margin-top: 40px; border: 1px solid var(--border-color); }

.admin-form { display: flex; flex-direction: column; gap: 15px; }
.admin-form input, .admin-form textarea, .admin-form select { padding: 12px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-color); color: var(--text-primary); font-family: inherit;}
button, .btn, .btn-primary, .btn-secondary, .btn-danger { padding: 10px 20px; border: none; border-radius: 8px; cursor: pointer; font-size: 1rem; font-weight: bold; transition: 0.3s; display: inline-block; text-align: center; box-sizing: border-box;}

.btn-primary, #auth-area a.btn-primary, .links a.btn-primary { background-color: var(--accent) !important; color: #3b2313 !important; font-weight: bold !important; text-decoration: none; border: 1px solid var(--accent); }
.btn-primary:hover { background-color: var(--accent-hover) !important; color: #1c1009 !important; border-color: var(--accent-hover); }

.btn-secondary { background-color: var(--bg-color); color: var(--text-primary); border: 1px solid var(--border-color); text-decoration: none;}
.btn-secondary:hover { background-color: var(--card-bg); border-color: var(--accent); color: var(--accent); }
.btn-danger { background-color: var(--danger); color: #fff; }

.loader { border: 4px solid var(--border-color); border-top: 4px solid var(--accent); border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin: 40px auto; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.tabs { display: flex; border-bottom: 2px solid var(--border-color); margin-bottom: 20px; }
.tab { flex: 1; text-align: center; padding: 10px; cursor: pointer; color: var(--text-secondary); font-weight: bold; transition: 0.3s; border-radius: 8px 8px 0 0;}
.tab.active { color: var(--accent); border-bottom: 2px solid var(--accent); margin-bottom: -2px; background: var(--card-bg); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.logo:not(.loaded)::before { content: ''; display: block; width: 28px; height: 28px; border-radius: 50%; margin-right: 10px; background: linear-gradient(90deg, var(--card-bg) 25%, var(--border-color) 50%, var(--card-bg) 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite linear; }
#auth-area:empty { display: flex; align-items: center; gap: 10px; min-height: 35px; justify-content: center; }
#auth-area:empty::before { content: ''; display: block; width: 35px; height: 35px; border-radius: 50%; border: 2px solid var(--border-color); background: linear-gradient(90deg, var(--card-bg) 25%, var(--border-color) 50%, var(--card-bg) 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite linear; }
#auth-area:empty::after { content: ''; display: block; width: 60px; height: 18px; border-radius: 4px; background: linear-gradient(90deg, var(--card-bg) 25%, var(--border-color) 50%, var(--card-bg) 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite linear; }
.float-btn { display: none !important; } 

/* 💀 SKELETONS DINÂMICOS PARA TODOS OS TEMAS (ANTI-CAMUFLAGEM) */
.skeleton-box, .skeleton {
    background-color: var(--border-color) !important;
    background-image: linear-gradient(90deg, var(--border-color) 25%, var(--card-bg) 50%, var(--border-color) 75%) !important;
    background-size: 200% 100% !important;
    animation: shimmer 1.5s infinite linear !important;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Fallback da animação antiga, pra garantir que nenhum skeleton antigo quebre */
@keyframes skeleton-loading { 
    0% { background-position: 200% 0; } 
    100% { background-position: -200% 0; } 
}

/* ❤️ BOTÃO FAVORITO E PROGRESSO DINÂMICO NO BOOK.HTML */
.heart-btn {
    background: var(--bg-color) !important;
    border: 2px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
}
.heart-btn.active {
    color: #f44336 !important;
    border-color: #f44336 !important;
}
#progressBadge {
    background: var(--bg-color) !important;
    border: 2px solid var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* ================================================= */
/* ⚙️ UI DO PAINEL DE LEITURA & AVISO DE PROGRESSO  */
/* ================================================= */
.reader-settings-btn { position: fixed; bottom: 20px; left: 20px; background: var(--card-bg); border: 2px solid var(--border-color); color: var(--text-primary); width: 45px; height: 45px; border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; z-index: 99; transition: 0.3s; box-shadow: 0 4px 10px rgba(0,0,0,0.5); font-weight: bold; font-size: 1.1rem; font-family: serif; }
.reader-settings-btn:hover { border-color: var(--accent); color: var(--accent); }

.reader-settings-panel { position: fixed; bottom: 75px; left: 20px; background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 15px; display: none; flex-direction: column; gap: 15px; z-index: 99; box-shadow: 0 10px 20px rgba(0,0,0,0.8); width: 250px; }
.reader-settings-panel.active { display: flex; }
.rs-row { display: flex; justify-content: space-between; align-items: center; color: var(--text-primary); font-size: 0.95rem; font-weight: bold; }
.rs-row select { background: var(--bg-color); color: var(--text-primary); border: 1px solid var(--border-color); padding: 8px; border-radius: 4px; outline: none; flex: 1; margin-left: 15px; cursor: pointer; }
.rs-btn { width: 35px; height: 35px; display: flex; justify-content: center; align-items: center; cursor: pointer; background: var(--bg-color); color: var(--text-primary); border: 1px solid var(--border-color); border-radius: 4px; font-weight: bold; font-size: 1.2rem; transition: 0.2s;}
.rs-btn:hover { border-color: var(--accent); color: var(--accent); }

.fab { position: fixed; bottom: 20px; right: 20px; background: var(--accent); color: #fff; width: 55px; height: 55px; border-radius: 50%; display: flex; justify-content: center; align-items: center; font-size: 24px; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,0.5); z-index: 99; border: none; transition: 0.3s; }
.fab:hover { background: var(--accent-hover); transform: scale(1.05); }

.progress-prompt { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #1c1009; padding: 15px 20px; border-radius: 8px; z-index: 1000; box-shadow: 0 10px 30px rgba(0,0,0,0.8); display: none; flex-direction: column; gap: 10px; font-weight: bold; width: 90%; max-width: 350px; text-align: center; border: 2px solid #3b2313;}
.progress-prompt-btns { display: flex; gap: 10px; justify-content: center; margin-top: 5px; }
.progress-prompt-btns button { padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; flex: 1; transition: 0.2s;}
.pp-yes { background: #1c1009; color: var(--accent); }
.pp-no { background: transparent; color: #1c1009; border: 2px solid #1c1009 !important; }
.pp-yes:hover { background: #3b2313; }
.pp-no:hover { background: rgba(0,0,0,0.1); }

/* ================================================= */
/* 💻 MONITORES GRANDES (Atração Magnética da Leitura) */
/* ================================================= */
@media (min-width: 1200px) {
    .reader-settings-btn { left: calc(50% - 570px); }
    .reader-settings-panel { left: calc(50% - 570px); }
    .fab { right: calc(50% - 570px); }
}

/* ================================================= */
/* 📱 ADAPTAÇÕES PARA MOBILE E APP (PWA) 📱          */
/* ================================================= */
* { -webkit-tap-highlight-color: transparent; }

@media (max-width: 768px) {
    .container { padding: 0 5px; } 
    .reading-area { padding: 15px 10px !important; margin-top: 0 !important; border-radius: 0 !important; box-shadow: none !important; border-top: none; border-bottom: 1px solid var(--border-color); }
    .content-panel { padding: 15px 10px !important; margin-top: 10px !important; border-radius: 0 !important; border-left: none; border-right: none; }
    .admin-section, .profile-section { padding: 15px 10px !important; margin-top: 10px !important; border-radius: 0 !important; border-left: none; border-right: none;}
    
    header { padding: 10px 15px; position: sticky; top: 0; z-index: 1000; transition: top 0.3s ease-in-out; }
    nav { flex-direction: row !important; justify-content: space-between !important; align-items: center !important; flex-wrap: wrap !important; }
    .logo { margin: 0 !important; width: auto !important; }
    .mobile-toggle { display: flex !important; width: auto !important; margin: 0 !important; padding: 5px !important; order: 2; background: transparent !important; }
    
    .links { display: none !important; position: absolute; top: 100%; left: 0; width: 100% !important; background: var(--card-bg); padding: 15px; box-sizing: border-box; border-bottom: 1px solid var(--border-color); box-shadow: 0 10px 20px rgba(0,0,0,0.5); flex-direction: column !important; gap: 15px; order: 3; z-index: 1001; }
    .links.active { display: flex !important; }
    
    .links a.btn-secondary { width: 100% !important; margin: 0 !important; padding: 12px !important; font-size: 1rem !important; }
    #auth-area { border: none !important; margin: 0 !important; padding: 0 !important; width: 100%; display: flex; justify-content: center; }
    #auth-area a.btn-primary { width: 100% !important; max-width: none !important; margin: 0 !important; }
    
    .user-menu { margin-top: 0; width: 100%; justify-content: center; background: var(--bg-color); padding: 12px; border-radius: 8px; border: 1px solid var(--border-color);}
    .dropdown-content { width: 100%; top: 60px; text-align: center; }

    .book-header { flex-direction: column; align-items: center; text-align: center; gap: 15px; margin-top: 20px;}
    .cover-wrapper { width: 180px !important; margin: 0 auto !important; }
    .book-details-top { min-width: 100%; padding: 0 10px; box-sizing: border-box; }
    
    #b-title { font-size: 2rem !important; text-align: center; margin: 0 5px 10px 5px!important; }
    #b-synopsis { text-align: justify !important; hyphens: auto; padding: 0 5px; }
    #c-title { font-size: 1.5rem !important; line-height: 1.3 !important; margin: 10px 5px 20px 5px !important; text-align: left !important; }
    #c-content { font-size: 1.15rem !important; line-height: 1.5 !important; text-align: justify !important; hyphens: auto; padding: 0 5px;}
    
    .book-details-top > div { justify-content: center; text-align: center; }
    .rating-section > div { justify-content: center; flex-direction: column; gap: 5px; }
    .rating-interactive { justify-content: center; }

    button, .btn-primary, .btn-danger { width: 100%; margin-bottom: 10px; padding: 12px 20px; font-size: 1.05rem; }
    
    .chapter-nav { flex-direction: row !important; gap: 8px; margin: 15px 5px; justify-content: center; }
    .chapter-nav a, .chapter-nav button { width: auto !important; flex: 1; padding: 10px 0 !important; margin: 0; box-sizing: border-box; min-width: unset !important; }

    .book-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 15px; padding: 0 10px; }
    .book-card h3 { font-size: 0.95rem !important; }
    .chapter-item { flex-direction: column; align-items: flex-start; text-align: left; margin: 0 10px 10px 10px; }
    .chapter-item a { padding: 15px; width: 100%; box-sizing: border-box; }
    .chapter-item span { margin: 0 0 15px 15px; display: inline-block;}
}

/* ================================================= */
/* 💬 SISTEMA DE REPLIES ANINHADOS (Nested Comments) */
/* ================================================= */
.replies-container {
    margin-left: 45px;
    padding-left: 15px;
    border-left: 2px solid var(--border-color);
    margin-top: -5px;
    margin-bottom: 20px;
}
.comment-box.is-reply {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 10px 0 !important;
}
.d-none { display: none !important; }
.toggle-replies-btn {
    background: transparent !important;
    border: none !important;
    color: var(--accent) !important;
    font-size: 0.85rem !important;
    padding: 0 !important;
    margin-top: 10px;
}
.toggle-replies-btn:hover { text-decoration: underline; background: transparent !important; }

/* ================================================= */
/* 💬 CAIXAS DE RESPOSTA INLINE E MENU MOBILE INBOX  */
/* ================================================= */
.inline-reply-container {
    margin-top: 10px;
    margin-bottom: 10px;
    display: none; 
}
.inline-reply-container.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.inbox-menu-link { 
    color: var(--text-primary); 
    padding: 12px 16px; 
    text-decoration: none; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-bottom: 1px solid var(--border-color);
}

@media (max-width: 768px) {
    .inbox-menu-link { 
        justify-content: center !important; 
        gap: 10px; 
    }
}

/* ================================================= */
/* ✨ ANIMAÇÃO DE HIGHLIGHT INFALÍVEL (Película)     */
/* ================================================= */
.unread-notif {
    background-color: rgba(255, 152, 0, 0.1) !important;
    border-left: 4px solid var(--accent) !important;
}

/* O pulo do gato: Criamos uma camada que cobre o comentário sem brigar com o background original */
.highlight-anim {
    position: relative;
    border-radius: 8px;
}

.highlight-anim::after {
    content: '';
    position: absolute;
    top: -2px; left: -2px; right: -2px; bottom: -2px;
    background-color: rgba(255, 152, 0, 0.25);
    box-shadow: 0 0 12px var(--accent);
    border: 2px solid var(--accent);
    border-radius: inherit;
    pointer-events: none; /* Permite que o usuário clique através da película */
    z-index: 10;
    animation: fadeOverlay 2.5s ease-out forwards;
}

@keyframes fadeOverlay {
    0% { opacity: 1; }
    100% { opacity: 0; visibility: hidden; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================================================= */
/* 🎨 CAMADA 1: A COR DE FUNDO (Z-INDEX -2)          */
/* ================================================= */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    
    background-color: var(--bg-color);
    z-index: -2; 
    
    /* 🚀 FIX MOBILE: Força o uso da Placa de Vídeo (GPU) */
    transform: translateZ(0);
}

/* ================================================= */
/* 🌟 CAMADA 2: A MARCA D'ÁGUA (Z-INDEX -1)          */
/* ================================================= */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    
    background-image: url('/icone.png'); 
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 125vmin; 
    
    mix-blend-mode: var(--wm-blend, soft-light);
    filter: var(--wm-filter, grayscale(100%));
    opacity: var(--wm-opacity, 0.10); 
    
    z-index: -1; 
    pointer-events: none; 
    
    /* 🚀 FIX MOBILE: Força o uso da Placa de Vídeo (GPU) */
    transform: translateZ(0);
}


/* ================================================= */
/* 🖼️ ESTILOS DA GALERIA (TRUE MASONRY INTELIGENTE)  */
/* ================================================= */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); 
    gap: 15px;
    margin-top: 20px;
}

.gallery-grid.masonry-active {
    grid-auto-rows: 5px; 
    grid-auto-flow: dense; 
    align-items: stretch;
}

.gallery-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-sizing: border-box; 
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    display: block;
    /* Sombras aplicadas na caixa parada para não pesar na placa de vídeo */
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.gallery-img {
    width: 100%;
    height: 100%; /* Força a imagem a preencher a matemática perfeita do JS */
    object-fit: cover;
    display: block;
    transition: opacity 0.3s;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.8);
    border-color: var(--accent);
    z-index: 5; 
}
.gallery-item:hover .gallery-img { opacity: 0.85; }

/* 🧩 CLASSES DE LARGURA */
.span-1 { grid-column: span 1; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; } 

@media (max-width: 768px) {
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
    .span-3 { grid-column: span 2; } 
}
@media (max-width: 480px) {
    .gallery-grid { grid-template-columns: 1fr; }
    .span-1, .span-2, .span-3 { grid-column: span 1 !important; }
}

/* 🌟 ANIMAÇÃO APLICADA APENAS NA IMAGEM (Protege a matemática da Caixa) */
@keyframes itemBirth {
    0% { transform: scale(0); opacity: 0; }
    80% { transform: scale(1.05); opacity: 1; } 
    100% { transform: scale(1); opacity: 1; }
}
.item-birth { animation: itemBirth 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards; }

/* ================================================= */
/* 💧 CARIMBOS FLUTUANTES (Scanner de Buracos)       */
/* ================================================= */
.gallery-grid {
    position: relative; 
}

.gallery-stamp-abs {
    position: absolute;
    background-color: var(--border-color) !important; 
    border: none !important; 
    border-radius: 8px; /* Arredondado pra ficar suave */
    pointer-events: none; 
    user-select: none;
    z-index: 1; 
    animation: fadeIn 0.5s ease forwards;
}

/* O Carimbo (Ícone Transparente) */
.gallery-stamp-abs::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('/icone.png');
    background-position: center center;
    background-repeat: no-repeat;
    background-size: 50px; 
    opacity: 0.15; 
    mix-blend-mode: var(--wm-blend, soft-light);
    filter: var(--wm-filter, grayscale(100%));
}

/* ================================================= */
/* 🔍 LIGHTBOX (A Verdadeira Animação ON CLICK)      */
/* ================================================= */
.lightbox {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0); 
    z-index: 10005; 
    display: flex; 
    visibility: hidden;
    pointer-events: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    transition: background 0.3s ease, visibility 0.3s;
    padding: 20px;
    box-sizing: border-box;
}

.lightbox.active {
    visibility: visible;
    pointer-events: auto;
    background: rgba(0,0,0,0.95); 
}

.lightbox-content {
    position: relative;
    max-width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.lightbox-img {
    max-width: 100%;
    max-height: 75vh;
    border-radius: 8px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    object-fit: contain;
    opacity: 0; 
}

/* 💥 ANIMAÇÃO INFALÍVEL DO PULO (ON CLICK) */
@keyframes popInImage {
    0% { transform: scale(0.3); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.lightbox.active .lightbox-img {
    /* Força o navegador a engatilhar a animação na hora que a classe .active entra */
    animation: popInImage 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.lightbox-close {
    position: absolute;
    top: -40px; right: 0px;
    color: #fff;
    font-size: 35px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
}
.lightbox-close:hover { color: var(--danger); }

/* 📝 ANIMAÇÃO DO TEXTO (Sobe Suavemente) */
@keyframes slideUpText {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.lightbox-caption {
    color: #fff;
    margin-top: 15px;
    text-align: center;
    max-width: 800px;
    opacity: 0;
}

.lightbox.active .lightbox-caption {
    animation: slideUpText 0.4s ease 0.2s forwards; /* 0.2s de delay pro texto aparecer depois da foto */
}

.lightbox-desc { font-size: 0.95rem; color: #ccc; margin-top: 5px; }