/* ==========================================================================
    1. TOOLBAR DE LECTURA (CONTENEDOR PRINCIPAL)
    ========================================================================== */
    
    .reader-toolbar {
        position: sticky;
        top: var(--header-height, 0);
        background: rgba(255, 255, 255, 0.8);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        border-bottom: 1px solid rgba(0,0,0,0.08);
        z-index: 998;
        box-shadow: 0 2px 10px rgba(0,0,0,0.02);
        height: var(--reader-tool-bar-height);
        transition: top 0.3s ease, opacity 0.3s;
    }
    
    body.dark-mode .chapter-list-scroll li a {
        background: #d2d2d2;
        color: #444;
    }
    
    .toolbar-inner {
        display: flex;
        justify-content: space-between;
        align-items: center;
        max-width: 1200px;
        margin: 0 auto;
        padding: 0 20px;
        height: 100%;
    }
    
    .dropdown-wrapper {
        position: relative;
        z-index: 100;
    }
    
    body.dark-mode .reading-controls button,
    body.dark-mode .stat-item-inline {
        color: white;
        gap: 5px;
    }
    
    body.dark-mode .chapter-list-scroll li.is-locked {
        background: rgb(109 109 109) !important;
        opacity: 1;
    }
    
    body.dark-mode .chapter-list-scroll li.is-locked .locked-item-wrapper {
        color: rgb(217 217 217);
        font-weight: 700;
    }

    body.dark-mode .dropdown-header {
        background: #555;
    }


/* ==========================================================================
    2. SELECTOR DE NOVELA Y TRIGGER
    ========================================================================== */
   
    .novel-selector {
        position: relative;
        flex-grow: 1;
    }
    
    .dropdown-trigger {
        display: flex;
        align-items: center;
        background: none;
        border: 1px solid transparent;
        cursor: pointer;
        text-align: left;
        padding: 8px;
        border-radius: 8px;
        transition: all 0.3s ease;
    }
    
    .dropdown-trigger:hover { 
        background: rgba(0,0,0,0.05); 
    }
    
    .mini-cover {
        height: 45px;
        width: 45px;
        object-fit: cover;
        border-radius: 4px;
        margin-right: 12px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    
    .novel-info {
        display: flex;
        flex-direction: column;
        text-align: left;
        line-height: 1.2;
    }
    
    .novel-title {
        font-size: 1rem;
        font-weight: 700;
        color: #1a1a1a;
        max-width: 150px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    body.dark-mode .current-chapter-name {
        color: #888;
    }
    
    body.dark-mode .reader-content p {
        color: #d7d7d7 !important;
    }
    
    body.dark-mode .reader-content h2 {
        color: white !important;
    }
    
    .current-chapter-name {
        font-size: 0.8rem;
        color: var(--color-primary);
        font-weight: 700;
        margin-top: 2px;
    }


/* ==========================================================================
    3. DROPDOWNS (MENÚ DE CAPÍTULOS Y FUENTES)
    ========================================================================== */
        
    .chapters-dropdown, .fonts-dropdown {
        position: absolute;
        top: calc(100% + 10px);
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        border-radius: 12px;
        box-shadow: 0 10px 40px rgba(0,0,0,0.12);
        border: 1px solid rgba(240, 40, 151, 0.1);
        opacity: 0;
        visibility: hidden;
        transform: translateY(-15px);
        transition: all 0.3s;
        overflow: hidden;
        z-index: 1001;
    }

    #chapters-menu.is-visible {
    	display: block;
    	top: calc(var(--reader-tool-bar-height) - 7px) !important;
    	background: white;
    }

    .chapters-dropdown { left: 0; width: 320px; }
    .font-selector-wrapper { position: relative; }

    .fonts-dropdown.is-visible,
    .chapters-dropdown.show {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    
    .dropdown-header {
        background: var(--color-primary);
        color: #fff;
        padding: 14px;
        font-size: 12px;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 1px;
        text-align: center;
    }
    
    .chapter-list-scroll {
        list-style: none;
        padding: 0;
        margin: -1px 0 0 0;
        max-height: 380px;
        overflow-y: auto;
    }
    
    .chapter-list-scroll li a,
    .chapter-list-scroll li .locked-trigger {
        display: flex;
        padding: 12px 18px;
        font-size: 0.9rem;
        color: #444;
        text-decoration: none;
        font-weight: 600;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        box-sizing: border-box;
    }
    
    .chapter-list-scroll li:hover:not(.is-locked) {
        background-color: rgba(240, 40, 151, 0.04);
    }
    
    .chapter-list-scroll li.active {
        background-color: rgba(240, 40, 151, 0.08);
        border-left: 3px solid var(--color-primary);
    }

    .chapter-list-scroll li.is-locked {
        font-size: 14px !important;
    }

/* ==========================================================================
    4. CONTROLES (BOTONES, ESTADÍSTICAS Y FUENTES)
    ========================================================================== */

    .reading-controls {
        display: flex;
        align-items: center;
        background: rgba(0,0,0,0.03);
        padding: 4px 8px;
        border-radius: 12px;
        gap: 6px;
    }
    
    .reading-controls button {
        background: transparent;
        border: none;
        border-radius: 8px;
        height: 38px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: 0.3s ease;
        font-size: 14px;
        color: #555;
        gap: 5px;
    }
    
    .reading-controls button:hover {
        background: #fff;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        color: var(--color-primary);
    }
    
    body.dark-mode .reading-controls button:hover {
        color: black;
    }
    
    /* Like Button */
    .like-button.is-active {
        background: var(--color-primary) !important;
        color: white !important;
    }
    
    /* Font Selection */
    .font-option {
        padding: 10px 15px;
        cursor: pointer;
        font-size: 15px;
        transition: background 0.2s;
        color: #333;
        display: block;
        text-align: left;
    }
    .font-option:hover { background: #f0f0f0; }
    .font-option.active { font-weight: bold; color: var(--color-primary); }
    body.dark-mode .font-option.active {
        color: black !important;
    }


/* ==========================================================================
    5. BANNERS DENTRO DE LA TOOLBAR / DROPDOWN
    ========================================================================== */

    .advanced-chapters-banner {
        background: #1a1a1a;
        color: #fff;
        padding: 12px 15px;
        font-size: 0.85rem;
        text-align: center;
    }
    
    .buy-membership-btn {
        color: var(--color-primary) !important;
        font-weight: bold;
        text-decoration: underline;
    }



/* ==========================================================================
    6. RESPONSIVE TOOLBAR
    ========================================================================== */
        
    @media (max-width: 768px) {
        .reader-toolbar {
            height: 65px;
            padding: 0 10px;
            top: var(--header-height-mobile);
        }
    
        .reading-controls {
            background: none;
            gap: 5px;
            padding: 0;
        }
    
        .mini-cover { height: 35px; width: 35px; }
        
        .novel-title { max-width: 120px; font-size: 0.85rem; }
    
        
        #toggle-width { display: none; } /* Ocultar botones no críticos en móvil */
    }
    
    @media (max-width: 550px) {
        .chapters-dropdown {
            width: 95vw;
            left: 2.5vw;
            position: fixed;
        }
    }
    
    @media (max-width: 400px) {
        .reader-toolbar {
            height: 60px !important; /* Altura mucho más delgada */
            background: #fff !important;
            border-top: 1px solid #eee;
            padding: 0 10px !important;
        }
        
        .toolbar-inner {
            display: grid !important;
            grid-template-columns: auto 1fr auto; /* [Atrás] [Título] [Siguiente/Menú] */
            align-items: center;
            gap: 10px;
            padding: 0;
        }
        
        
        #chapters-menu.is-visible {
        	display: block;
        	top: var(--reader-tool-bar-height-mobile) !important;
        	background: white;
        }
            
            
        h2.wp-block-heading {
            font-size: 19px;
        }
        
        .current-chapter-name {
            margin-top: 0px;
            font-size: 0.65rem;
        }
    
        .novel-selector {
            flex-direction: column;
            align-items: flex-start;
            gap: 0;
        }
    
        .current-novel-name {
            font-size: 11px !important;
            color: #999;
            text-transform: uppercase;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            max-width: 140px;
        }
    
        /* Botones de navegación tipo flecha minimalista */
        .nav-btn {
            background: none !important;
            border: none !important;
            color: #333 !important;
            padding: 5px !important;
            font-size: 20px !important; /* Flechas más grandes */
        }
    
        .nav-btn span {
            display: none; /* Oculta el texto "Anterior/Siguiente" */
        }
    
        .nav-btn::before {
            content: '←'; /* O usa un icono de FontAwesome si lo tienes */
        }
        
        .nav-btn.next::before {
            content: '→';
        }
    
        /* Acciones de la derecha (Menú/Comentarios) */
        .reader-actions {
            gap: 15px;
        }
    
        .action-btn i {
            font-size: 18px;
            color: #333;
        }
    }
    
    
    
    
    
    /* ==========================================================================
        ANIMACIÓN FLUIDA DE ENTRADA Y SALIDA
       ========================================================================== */
    
    .reader-toolbar {
        /* Mantenemos una transición constante para todos los estados */
        transition: 
            transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), 
            opacity 0.3s ease,
            background 0.3s ease,
            box-shadow 0.4s ease !important;
        
        will-change: transform;
    }
    
    /* Estado cuando el usuario está scrolleando (Subiendo o Bajando) */
    .reader-toolbar.is-fixed-reading,
    .reader-toolbar.is-hidden-reading {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 100% !important;
        z-index: 9999 !important;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        background: rgba(255, 255, 255, 0.95) !important;
        /* Esto es clave: evitamos que la barra fixed parpadee al activarse */
        pointer-events: auto;
    }
    
    /* Cuando bajamos: la mandamos arriba de la pantalla */
    .reader-toolbar.is-hidden-reading {
        transform: translateY(-100%) !important;
        transition: transform 0.3s ease-in-out, opacity 0.3s !important;
        opacity: 0;
    }
    
    /* Cuando subimos: la mostramos suavemente */
    .reader-toolbar.is-fixed-reading {
        transform: translateY(0) !important;
        transition: transform 0.3s ease-out, opacity 0.3s !important;
        opacity: 1;
        box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important;
    }
    
    
    /* El ancla por defecto (Escritorio) */
    .toolbar-anchor {
        display: block;
        width: 100%;
        min-height: var(--reader-tool-bar-height, 75px);
    }
    
    /* El ancla para Móviles (Media query coincidiendo con tu diseño) */
    @media (max-width: 768px) {
        .toolbar-anchor {
            min-height: var(--reader-tool-bar-height-mobile, 60px);
        }
    }
    
    
    .reader-toolbar.is-fixed-reading,
    .reader-toolbar.is-hidden-reading {
        position: fixed !important;
        top: 0 !important; /* Siempre pegada al borde superior de la pantalla */
        left: 0;
        width: 100% !important;
        height: var(--reader-tool-bar-height); /* En escritorio */
    }
    
    @media (max-width: 768px) {
        .reader-toolbar.is-fixed-reading,
        .reader-toolbar.is-hidden-reading {
            height: var(--reader-tool-bar-height-mobile); /* En móvil */
        }
    }    









