:root {
    --bg-base: #fbf9f6;
    --text-main: #2c2523;
    --accent-terracotta: #c87a65;
    --accent-rose: #e6b3a8;
    --card-bg: #ffffff;
    --border-color: #eee7e1;
    --status-free: #689f38;
    --status-busy: #b94a3a;

    /* Variables para las sombras neomórficas claras */
    --nm-shadow-dark: rgb(225, 218, 211);
    --nm-shadow-light: rgb(255, 255, 255);
}

/* --- NUEVAS VARIABLES PARA EL MODO OSCURO --- */
/* --- REFINAMIENTO PREMIUM PARA MODO OSCURO --- */
body.dark-theme {
    --bg-base: #22252a;        /* Un gris azulado oscuro muy elegante */
    --text-main: #f0f4f8;      /* Texto claro con excelente contraste */
    --card-bg: #22252a;        /* OBLIGATORIO: Mismo color que bg-base para el neomorfismo */
    --border-color: #2b3036;
    --accent-terracotta: #e5876d; /* Terracota ligeramente más vibrante para destacar en oscuro */
    --accent-rose: #f3c6bd;

    /* Sombras tridimensionales calibradas para fondo oscuro (#22252a) */
    --nm-shadow-dark: rgb(24, 26, 30);       /* Sombra profunda abajo-derecha */
    --nm-shadow-light: rgb(44, 48, 54);     /* Brillo suave arriba-izquierda */
}

/* --- AJUSTES EXTRA PARA COMPONENTES EN MODO OSCURO --- */

/* Asegura que las tarjetas cambien de color de fondo y usen las sombras correctas */
body.dark-theme .book-card {
    background: var(--bg-base) !important;
    box-shadow: 9px 9px 16px var(--nm-shadow-dark), -9px -9px 16px var(--nm-shadow-light) !important;
}

body.dark-theme .book-card:hover {
    box-shadow: 12px 12px 20px var(--nm-shadow-dark), -12px -12px 20px var(--nm-shadow-light) !important;
}

/* Los botones de filtro en modo oscuro */
body.dark-theme .btn-filter {
    background: var(--bg-base);
    color: #a0aec0;
    border: none;
    box-shadow: 4px 4px 8px var(--nm-shadow-dark), -4px -4px 8px var(--nm-shadow-light);
}

body.dark-theme .btn-filter.active {
    background-color: var(--accent-terracotta);
    color: white;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.2); /* Efecto hundido al estar activo */
}

/* El input de contraseña de admin y botones del modal en modo oscuro */
body.dark-theme .login-input,
body.dark-theme .modal-input {
    background: #1a1c20;
    border-color: #2b3036;
    color: white;
}

/* Los textos secundarios de autor y subtítulos que se veían muy oscuros */
body.dark-theme .book-author,
body.dark-theme header p {
    color: #a0aec0 !important;
}

/* La etiqueta de género */
body.dark-theme .book-genre {
    background: #2b3036;
    color: #e2e8f0;
}

/* Botón de ver detalles en modo oscuro */
body.dark-theme .btn-detalles {
    background-color: #2b3036;
    border-color: #2b3036;
    color: white;
    box-shadow: 3px 3px 6px var(--nm-shadow-dark), -3px -3px 6px var(--nm-shadow-light);
}

body.dark-theme .btn-detalles:hover {
    background-color: var(--accent-terracotta);
    border-color: var(--accent-terracotta);
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.6;
    padding: 40px 20px;
}

.container { max-width: 1000px; margin: 0 auto; position: relative; }

/* Barra superior de login */
/* --- Barra superior compacta + menú lateral (hamburguesa) --- */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 30px;
}

.btn-hamburguesa {
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    font-size: 1.3rem;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 3px 3px 6px var(--nm-shadow-dark), -3px -3px 6px var(--nm-shadow-light);
}

.top-bar-derecha {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.saludo-mini {
    font-size: 0.85rem;
    color: #8c827f;
}

.menu-lateral-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 37, 35, 0.4);
    z-index: 1990;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.menu-lateral-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.menu-lateral {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 82vw;
    background: var(--bg-base);
    z-index: 2000;
    box-shadow: 6px 0 24px rgba(44, 37, 35, 0.2);
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.menu-lateral.active {
    transform: translateX(0);
}

.menu-lateral-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    color: var(--text-main);
    flex-shrink: 0;
}

.menu-lateral-cerrar {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: #8c827f;
    cursor: pointer;
    line-height: 1;
}

.menu-lateral-cuerpo {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-menu-lateral {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    color: var(--text-main);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-menu-lateral:hover {
    background-color: var(--accent-rose);
    color: white;
}

.menu-lateral-separador {
    height: 1px;
    background: var(--border-color);
    margin: 8px 4px;
}

/* --- Filtro de géneros: fila fija + desplegable con buscador --- */
.filter-panel {
    display: block;
    margin-bottom: 30px;
}

.filtros-fijos {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.generos-desplegable {
    max-width: 480px;
    margin: 14px auto 0 auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 8px 20px rgba(44, 37, 35, 0.08);
}

.generos-desplegable-lista {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.login-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

@media (max-width: 600px) {
    .login-bar {
        justify-content: center;
    }
    .btn-register-top, .btn-login-toggle {
        font-size: 0.82rem;
        padding: 9px 14px;
    }
    .login-input-wrapper {
        flex: 1 1 100%;
    }
    .login-input {
        width: 100%;
    }
}

.btn-register-top {
    background-color: var(--accent-rose);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

.btn-register-top:hover {
    opacity: 0.9;
}

.login-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input {
    border: 1px solid var(--border-color);
    padding: 10px 40px 10px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-main);
    outline: none;
    width: 200px;
    background: white;
}

.toggle-password {
    position: absolute;
    right: 14px;
    cursor: pointer;
    color: #8c827f;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-login-toggle {
    background-color: #2c2523;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.btn-login-toggle:hover {
    background-color: #453b38;
}

/* Encabezado Principal */
header {
    text-align: center;
    margin-bottom: 50px;
}

.logo-frame {
    width: 120px;
    height: 120px;
    max-width: 120px;
    max-height: 120px;
    margin: 0 auto 12px auto;
    display: block;
}

.logo-frame img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(44, 37, 35, 0.08);
}

header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2.8rem;
    font-weight: 400;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

header p {
    font-size: 1.1rem;
    color: #8c827f;
    font-style: italic;
}

/* Panel de Filtros */
.marquee-banner {
    background: #2c2523;
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 32px;
    box-shadow: 0 4px 14px rgba(44, 37, 35, 0.15);
}

.marquee-track {
    display: flex;
    width: max-content;
    animation: marquee-scroll 26s linear infinite;
}

.marquee-banner:hover .marquee-track {
    animation-play-state: paused;
}

.marquee-group {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.marquee-group span {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 0.95rem;
    color: #f5efe8;
    padding: 12px 20px;
    white-space: nowrap;
}

.marquee-sep {
    font-family: 'Plus Jakarta Sans', sans-serif !important;
    font-style: normal !important;
    color: var(--accent-rose) !important;
    padding: 0 !important;
    opacity: 0.8;
}

@keyframes marquee-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
    .marquee-track {
        animation: none;
    }
}

.search-bar {
    max-width: 420px;
    margin: 0 auto 20px auto;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 16px;
    font-size: 0.95rem;
    opacity: 0.6;
    pointer-events: none;
}

.search-input {
    padding-left: 42px !important;
}

/* Efecto de relieve hundido para la barra de búsqueda (probado primero en Biblioteca Casa) */
.search-bar .search-input {
    border: none;
    background: var(--bg-base);
    box-shadow: inset 4px 4px 8px var(--nm-shadow-dark), inset -4px -4px 8px var(--nm-shadow-light);
}

.search-bar .search-input:focus {
    box-shadow: inset 5px 5px 10px var(--nm-shadow-dark), inset -5px -5px 10px var(--nm-shadow-light);
}

.filter-panel {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.btn-filter {
    background: white;
    border: 1px solid var(--border-color);
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #645855;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-filter:hover {
    border-color: var(--accent-terracotta);
    color: var(--accent-terracotta);
}

.btn-filter.active {
    background-color: var(--accent-terracotta);
    border-color: var(--accent-terracotta);
    color: white;
}

/* Botón flotante para el Dark Mode */
.btn-dark-mode {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: var(--bg-base);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    box-shadow: 4px 4px 10px var(--nm-shadow-dark), -4px -4px 10px var(--nm-shadow-light);
    transition: all 0.3s ease;
}

/* Grid de Libros (Estilo Neomórfico) */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 30px;
    margin-bottom: 60px;
}

@media (max-width: 400px) {
    .books-grid {
        grid-template-columns: 1fr;
    }
}

.book-card {
    background: var(--bg-base);
    border: none;
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    /* Ahora las sombras usan variables dinámicas */
    box-shadow: 9px 9px 16px var(--nm-shadow-dark), -9px -9px 16px var(--nm-shadow-light);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.book-card:hover {
    transform: translateY(-2px);
    box-shadow: 12px 12px 20px var(--nm-shadow-dark), -12px -12px 20px var(--nm-shadow-light);
}

.book-status {
    align-self: flex-start;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 12px;
    margin-bottom: 14px;
}

.status-disponible { background-color: #edf7ed; color: var(--status-free); }
.status-prestado { background-color: #fdeded; color: var(--status-busy); }
.status-reservado { background-color: #fdf3e1; color: #a86f12; }
.status-mio { background-color: #eef3fb; color: #4a6fa5; }
body.dark-theme .status-reservado { background-color: rgba(217, 164, 65, 0.2); color: #f0c674; }
body.dark-theme .status-mio { background-color: rgba(74, 111, 165, 0.25); color: #9db8e0; }

/* Filtros de estado (Reservados / Prestados) */
.btn-filter.filtro-reservados { border-color: #d9a441; color: #a86f12; }
.btn-filter.filtro-prestados { border-color: var(--status-busy); color: var(--status-busy); }
.btn-filter.filtro-reservados.active { background-color: #d9a441; color: white; }
.btn-filter.filtro-prestados.active { background-color: var(--status-busy); color: white; }

.book-cover-mini {
    width: 60px;
    height: 84px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(44, 37, 35, 0.15);
}

.book-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    font-weight: 400;
    margin-bottom: 4px;
    color: var(--text-main);
}

.book-author {
    font-size: 0.95rem;
    color: #8c827f;
    margin-bottom: 12px;
}

.book-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 20px;
}

.book-genre {
    font-size: 0.8rem;
    background: #eee7e1;
    padding: 3px 8px;
    border-radius: 4px;
    color: #5a4f4d;
}

/* Acciones y Botones del Grid */
.actions-panel {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-action {
    flex: 1;
    padding: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-prestamo {
    border-color: var(--accent-terracotta);
    color: var(--accent-terracotta);
}

.btn-prestamo:hover:not(:disabled) {
    background-color: var(--accent-terracotta);
    color: white;
}

.btn-devolucion {
    background-color: #fcf8f7;
    color: #5a4f4d;
    border-color: #d1c7c3;
}

.btn-devolucion:hover:not(:disabled) {
    background-color: var(--status-busy);
    color: white;
    border-color: var(--status-busy);
}

.btn-detalles {
    background-color: var(--text-main);
    border-color: var(--text-main);
    color: white;
    min-width: 100%;
    font-weight: 600;
    margin-bottom: 5px;
}

.btn-detalles:hover {
    background-color: #f4ede7;
    color: var(--text-main);
}

.btn-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--border-color);
    color: #a89e9b;
    background: #fdfcfb;
}

/* Botones de Editar/Eliminar, solo visibles con sesión admin */
.admin-actions-panel {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.btn-editar {
    border-color: #8c827f;
    color: #5a4f4d;
}

.btn-editar:hover:not(:disabled) {
    background-color: #5a4f4d;
    color: white;
}

.btn-eliminar {
    border-color: var(--status-busy);
    color: var(--status-busy);
}

.btn-eliminar:hover:not(:disabled) {
    background-color: var(--status-busy);
    color: white;
}

/* Listas dentro de los modales de gestión (lectores / préstamos) */
.manage-list {
    max-height: 340px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.manage-list-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

body.dark-theme .manage-list-item {
    background: #1a1c20;
    border-color: #2b3036;
}

.manage-list-info {
    font-size: 0.85rem;
    line-height: 1.4;
}

.manage-list-info strong {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: 1rem;
}

.manage-list-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.manage-list-actions .btn-action {
    flex: none;
    padding: 6px 12px;
    font-size: 0.78rem;
}

.manage-list-empty {
    font-size: 0.85rem;
    color: #8c827f;
    font-style: italic;
    text-align: center;
    padding: 20px 0;
}

.estado-devuelto { color: var(--status-free); font-weight: 600; }
.estado-pendiente { color: var(--status-busy); font-weight: 600; }

/* Estructuras Modales */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(44, 37, 35, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--bg-base);
    width: 100%;
    max-width: 460px;
    border-radius: 24px;
    padding: 32px;
    box-shadow: 0 20px 40px rgba(44, 37, 35, 0.15);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    max-height: 88vh;
    overflow-y: auto;
}

.modal-overlay.active .modal-box {
    transform: translateY(0);
}

.modal-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.6rem;
    margin-bottom: 20px;
    color: var(--text-main);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: #645855;
}

.modal-input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.95rem;
    outline: none;
    background: white;
    color: var(--text-main);
    transition: border-color 0.2s;
}

.modal-input:focus {
    border-color: var(--accent-terracotta);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 28px;
}

.btn-modal-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #645855;
}

.btn-modal-action {
    background-color: var(--accent-terracotta);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Sección de reseñas dentro de Detalles */
.reviews-section {
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
    max-height: 180px;
    overflow-y: auto;
}

.review-item {
    background: white;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
}

.review-header {
    display: flex;
    justify-content: space-between;
    color: #8c827f;
    margin-bottom: 4px;
    font-weight: 500;
}

.stars { color: #f59e0b; }

/* Pantalla inicial: pedir el código de librería */
.tenant-gate {
    position: fixed;
    inset: 0;
    background-color: var(--bg-base);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.tenant-gate-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 22px 20px;
    flex-shrink: 0;
}

.tenant-gate-header img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}

.tenant-gate-header span {
    font-family: 'Playfair Display', serif;
    font-size: 1.15rem;
    color: var(--text-main);
}

.tenant-gate-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
}

.tenant-gate-heading {
    font-family: 'Playfair Display', serif;
    font-weight: 400;
    font-size: 2.1rem;
    color: var(--text-main);
    margin-bottom: 14px;
}

.tenant-gate-intro {
    max-width: 460px;
    color: #8c827f;
    font-size: 0.95rem;
    line-height: 1.65;
    margin-bottom: 32px;
}

.tenant-gate-box {
    background: var(--bg-base);
    width: 100%;
    max-width: 380px;
    border-radius: 24px;
    padding: 36px 32px;
    text-align: center;
    box-shadow: 9px 9px 16px var(--nm-shadow-dark), -9px -9px 16px var(--nm-shadow-light);
}

.tenant-gate-error {
    color: var(--status-busy);
    font-size: 0.85rem;
    margin-top: 10px;
    min-height: 1.2em;
}

.tenant-gate-footer {
    flex-shrink: 0;
    text-align: center;
    padding: 26px 20px;
    border-top: 1px solid var(--border-color);
}

.tenant-gate-cta {
    font-size: 0.9rem;
    color: #8c827f;
    margin-bottom: 12px;
}

.tenant-gate-cta a {
    color: var(--accent-terracotta);
    font-weight: 600;
    text-decoration: none;
}

.tenant-gate-cta a:hover {
    text-decoration: underline;
}

.tenant-gate-legal {
    font-size: 0.78rem;
    color: #a89e9b;
}

.tenant-gate-legal a {
    color: #8c827f;
    text-decoration: underline;
}

/* Paneles horizontales sobre el buscador: noticias/eventos y frase del día */
.paneles-superiores {
    margin: 0 auto 24px auto;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.panel-superior {
    flex: 1 1 45%;
    background: var(--bg-base);
    border-radius: 16px;
    padding: 18px 22px;
    box-shadow: 6px 6px 12px var(--nm-shadow-dark), -6px -6px 12px var(--nm-shadow-light);
    font-size: 1.02rem;
    line-height: 1.5;
    border-left: 4px solid transparent;
    text-align: center;
}

#panel-noticias {
    border-left-color: var(--accent-terracotta);
    background: linear-gradient(135deg, rgba(200, 122, 101, 0.12), var(--bg-base) 65%);
}

#panel-frase {
    border-left-color: var(--accent-rose);
    background: linear-gradient(135deg, rgba(230, 179, 168, 0.16), var(--bg-base) 65%);
}

#panel-versiculo {
    flex-basis: 100%;
}

.panel-superior-titulo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: 'Playfair Display', serif;
    font-size: 1.12rem;
    font-weight: 600;
    color: var(--accent-terracotta);
    margin-bottom: 8px;
}

#panel-frase .panel-superior-titulo {
    color: #b8534a;
}

#panel-frase p {
    font-style: italic;
    font-size: 1.05rem;
    color: var(--text-main);
}

#panel-versiculo {
    border-left-color: var(--status-free);
    background: linear-gradient(135deg, rgba(104, 159, 56, 0.12), var(--bg-base) 65%);
}

#panel-versiculo .panel-superior-titulo {
    color: var(--status-free);
}

#panel-versiculo p {
    font-style: italic;
    font-size: 1.05rem;
    color: var(--text-main);
}

/* Panel de devoluciones (admin: lo que vence pronto; socio: sus préstamos) */
#panel-devoluciones {
    flex-basis: 100%;
    border-left-color: #d9a441;
    background: linear-gradient(135deg, rgba(217, 164, 65, 0.14), var(--bg-base) 65%);
}

#panel-devoluciones .panel-superior-titulo {
    color: #b7832a;
}

.aviso-devolucion {
    font-size: 0.95rem;
    margin: 4px 0;
}

.aviso-devolucion-btn {
    margin-top: 10px;
    font-size: 0.85rem;
    padding: 6px 14px;
}

.chip-plazo {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 10px;
    margin-right: 4px;
    white-space: nowrap;
}

.plazo-ok { background: #edf7ed; color: var(--status-free); }
.plazo-pronto { background: #fdf3e1; color: #a86f12; }
.plazo-retrasado { background: #fdeded; color: var(--status-busy); }

body.dark-theme .plazo-ok { background: rgba(104, 159, 56, 0.2); color: #a5d17a; }
body.dark-theme .plazo-pronto { background: rgba(217, 164, 65, 0.2); color: #f0c674; }
body.dark-theme .plazo-retrasado { background: rgba(185, 74, 58, 0.25); color: #f19a8c; }

/* Eventos de la agenda dentro del panel de Noticias */
.noticia-evento {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}

/* Si no hay texto libre encima, el primer evento no necesita separador */
#panel-noticias-texto[style*="none"] + #panel-noticias-eventos .noticia-evento:first-child {
    border-top: none;
    padding-top: 0;
}

.evento-cuenta {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: white;
    background: var(--accent-terracotta);
    padding: 2px 10px;
    border-radius: 10px;
    margin-bottom: 4px;
}

.noticia-evento strong {
    display: block;
    font-family: 'Playfair Display', serif;
    font-weight: 600;
    font-size: 1.08rem;
}

.noticia-evento-fecha {
    font-size: 0.88rem;
    color: #8c827f;
}

.noticia-evento-desc {
    font-size: 0.92rem;
    margin-top: 4px;
}

/* Agenda de eventos (modal de administración) */
.evento-fila {
    display: flex;
    gap: 12px;
}

.evento-fila .form-group {
    flex: 1;
}

.chip-estado {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.estado-anunciado { background: rgba(200, 122, 101, 0.16); color: var(--accent-terracotta); }
.estado-programado { background: #eef3fb; color: #4a6fa5; }
.estado-interno { background: #f1eeec; color: #6f6461; }
.estado-pasado { background: #f1eeec; color: #a89e9b; }

body.dark-theme .estado-programado { background: rgba(74, 111, 165, 0.25); color: #9db8e0; }
body.dark-theme .estado-interno,
body.dark-theme .estado-pasado { background: #2b3036; color: #a0aec0; }

.agenda-nota {
    font-size: 0.8rem;
    font-style: italic;
    color: #8c827f;
    margin-top: 4px;
}

.agenda-pasado {
    opacity: 0.55;
}

/* Tarjetas de la página de ebooks */
.ebook-card .actions-panel .btn-action {
    flex: 1 1 auto;
}

/* =========================================================
   CABECERA CON SESIÓN: pestañas, Entrar/Salir, tema sol/luna
   ========================================================= */
.top-bar-izquierda {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.top-bar-nav {
    display: flex;
    gap: 6px;
}

.nav-enlace {
    text-decoration: none;
    color: var(--text-main);
    font-size: 0.9rem;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid transparent;
    transition: background-color 0.2s, border-color 0.2s;
}

.nav-enlace:hover {
    border-color: var(--border-color);
}

.nav-enlace.activo {
    background: var(--bg-base);
    border-color: var(--border-color);
    box-shadow: inset 2px 2px 5px var(--nm-shadow-dark), inset -2px -2px 5px var(--nm-shadow-light);
    font-weight: 600;
}

.btn-entrar-top {
    background-color: var(--accent-terracotta);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    transition: opacity 0.2s;
}

.btn-entrar-top:hover { opacity: 0.9; }

.btn-salir-top {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.88rem;
}

.btn-salir-top:hover {
    border-color: var(--accent-terracotta);
    color: var(--accent-terracotta);
}

/* Selector de tema: dos botoncitos juntos, el activo "hundido" */
.selector-tema {
    display: inline-flex;
    padding: 3px;
    gap: 2px;
    border-radius: 20px;
    background: var(--bg-base);
    box-shadow: 3px 3px 6px var(--nm-shadow-dark), -3px -3px 6px var(--nm-shadow-light);
}

.tema-opcion {
    width: 34px;
    height: 30px;
    border: none;
    border-radius: 16px;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    opacity: 0.55;
    transition: opacity 0.2s, box-shadow 0.2s;
}

.tema-opcion:hover { opacity: 0.85; }

.tema-opcion.activo {
    opacity: 1;
    box-shadow: inset 3px 3px 6px var(--nm-shadow-dark), inset -3px -3px 6px var(--nm-shadow-light);
}

.tema-opcion:focus-visible,
.nav-enlace:focus-visible,
.btn-arriba:focus-visible {
    outline: 2px solid var(--accent-terracotta);
    outline-offset: 2px;
}

/* Botón "volver arriba" (donde antes estaba la luna) */
.btn-arriba {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    background: var(--bg-base);
    color: var(--text-main);
    font-size: 1.3rem;
    cursor: pointer;
    z-index: 1500;
    box-shadow: 4px 4px 10px var(--nm-shadow-dark), -4px -4px 10px var(--nm-shadow-light);
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.btn-arriba.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Formulario "Entrar" */
.entrar-enlaces {
    font-size: 0.82rem;
    color: #8c827f;
    margin-bottom: 6px;
}

.entrar-enlaces a {
    color: var(--accent-terracotta);
    font-weight: 600;
}

/* Buscador de socios (préstamo) */
.combo-socios {
    position: relative;
}

.combo-socios-lista {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 220px;
    overflow-y: auto;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(44, 37, 35, 0.12);
    z-index: 10;
    display: none;
    list-style: none;
    margin: 0;
    padding: 4px;
}

.combo-socios-lista.abierta { display: block; }

.combo-socios-lista li {
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.combo-socios-lista li .combo-id {
    color: #8c827f;
    font-size: 0.8rem;
}

.combo-socios-lista li:hover,
.combo-socios-lista li.resaltado {
    background: var(--border-color);
}

.combo-socios-lista li.combo-vacio {
    cursor: default;
    color: #8c827f;
}

.combo-socios-elegido {
    font-size: 0.85rem;
    color: var(--status-free);
    margin-top: 6px;
    min-height: 1.2em;
}

@media (max-width: 600px) {
    .top-bar { flex-wrap: wrap; }
    .top-bar-derecha { gap: 8px; }
    .nav-enlace { padding: 7px 10px; font-size: 0.85rem; }
    .btn-arriba { bottom: 18px; right: 18px; width: 44px; height: 44px; }
}

/* =========================================================
   TEST DE DONES (test-dones.html)
   ========================================================= */
.test-app {
    max-width: 760px;
    margin: 0 auto 60px auto;
    padding: 0 4px;
}

.test-tarjeta {
    background: var(--bg-base);
    border-radius: 20px;
    padding: 26px;
    margin-bottom: 24px;
    box-shadow: 9px 9px 16px var(--nm-shadow-dark), -9px -9px 16px var(--nm-shadow-light);
    color: var(--text-main);
    line-height: 1.6;
}

.test-tarjeta p { margin-bottom: 10px; }

.test-centro { text-align: center; }
.test-centro .btn-modal-action { margin-top: 8px; }

.test-icono { font-size: 2.2rem; margin-bottom: 6px; }

.test-titulo {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: 12px;
}

.test-nota {
    font-size: 0.85rem;
    color: #8c827f;
}

.test-enlace {
    background: none;
    border: none;
    color: var(--accent-terracotta);
    font-weight: 600;
    cursor: pointer;
    font-size: 0.88rem;
    padding: 6px 4px;
}

.test-detalles summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--accent-terracotta);
    margin-top: 6px;
}

.test-detalles ol, .test-pasos { padding-left: 20px; margin-top: 10px; }
.test-detalles li, .test-pasos li { margin-bottom: 8px; }

.test-opciones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.test-opcion { display: flex; flex-direction: column; margin-bottom: 0; }
.test-opcion .test-botones { margin-top: auto; }

.test-etiqueta {
    align-self: flex-start;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--border-color);
    margin-bottom: 10px;
}

.test-resumen { font-weight: 600; }

.test-botones {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
}

.test-centro.test-botones { justify-content: center; }

/* Preguntas */
.test-progreso-cabecera {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: #8c827f;
    margin-bottom: 8px;
}

.test-progreso {
    height: 8px;
    border-radius: 8px;
    background: var(--border-color);
    overflow: hidden;
    margin-bottom: 24px;
}

.test-progreso-barra {
    height: 100%;
    width: 0;
    background: var(--accent-terracotta);
    transition: width 0.3s ease;
}

.test-enunciado {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-terracotta);
    margin-bottom: 4px !important;
}

.test-pregunta {
    font-family: 'Playfair Display', serif;
    font-size: 1.35rem;
    line-height: 1.45;
    min-height: 3.2em;
    margin-bottom: 20px !important;
}

.test-respuestas {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.test-respuesta {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    padding: 13px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-base);
    color: var(--text-main);
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.test-respuesta:hover { border-color: var(--accent-terracotta); }

.test-respuesta.elegida {
    border-color: var(--accent-terracotta);
    background: var(--accent-terracotta);
    color: white;
}

.test-respuesta:focus-visible {
    outline: 2px solid var(--accent-terracotta);
    outline-offset: 2px;
}

.test-tecla {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid currentColor;
    font-size: 0.75rem;
    opacity: 0.6;
    flex-shrink: 0;
}

.test-respuesta-extra { font-size: 0.85rem; color: #8c827f; border-style: dashed; }

.test-navegacion {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
}

.test-navegacion button:disabled { opacity: 0.4; cursor: default; }

.test-ayuda {
    font-size: 0.78rem;
    color: #8c827f;
    text-align: center;
    margin-top: 14px;
}

@media (hover: none) { .test-ayuda, .test-tecla { display: none; } }

/* Resultado */
.cuadro-titulo {
    font-family: 'Playfair Display', serif;
    font-size: 1.25rem;
    font-weight: 400;
    margin-bottom: 4px;
}

.dones-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-top: 14px;
}

.don-tarjeta {
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
}

.don-tarjeta h4 {
    font-size: 1rem;
    margin-bottom: 6px;
    color: var(--accent-terracotta);
}

.don-tarjeta p { font-size: 0.88rem; margin-bottom: 8px; }
.don-citas { color: #8c827f; font-size: 0.8rem !important; }

.don-servir-titulo {
    font-weight: 600;
    font-size: 0.82rem !important;
    margin-bottom: 4px !important;
}

.don-servir {
    padding-left: 18px;
    font-size: 0.85rem;
}

.barras { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.barra-fila {
    display: grid;
    grid-template-columns: 170px 1fr 86px;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.barra-pistas { display: flex; flex-direction: column; gap: 3px; }

.barra-pista {
    height: 7px;
    border-radius: 4px;
    background: var(--border-color);
    overflow: hidden;
}

.barra { height: 100%; border-radius: 4px; }
.barra-a, .leyenda-a { background: var(--accent-terracotta); }
.barra-b, .leyenda-b { background: var(--status-free); }

.barra-valor { color: #8c827f; font-size: 0.78rem; text-align: right; }

.leyenda {
    display: inline-block;
    width: 12px;
    height: 8px;
    border-radius: 3px;
    vertical-align: middle;
}

.test-consentimiento {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 0.88rem;
    margin: 12px 0 16px 0;
    cursor: pointer;
}

.test-consentimiento input { margin-top: 5px; accent-color: var(--accent-terracotta); }

/* Resumen de la administración */
.test-filtros {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 12px 0;
}

.test-filtros label {
    flex: 1;
    min-width: 180px;
    font-size: 0.82rem;
    color: #8c827f;
}

.resumen-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px 0; }

.tabla-scroll { overflow-x: auto; }

.tabla-resumen {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.tabla-resumen th, .tabla-resumen td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.tabla-resumen th { font-size: 0.78rem; color: #8c827f; font-weight: 600; }

.don-chip {
    display: inline-block;
    font-size: 0.78rem;
    padding: 3px 9px;
    border-radius: 10px;
    margin: 2px 4px 2px 0;
    background: rgba(200, 122, 101, 0.15);
}

.don-chip-b { background: rgba(104, 159, 56, 0.15); }
.don-chip.resaltado { outline: 2px solid var(--accent-terracotta); }

body.dark-theme .test-nota,
body.dark-theme .test-ayuda,
body.dark-theme .barra-valor,
body.dark-theme .don-citas { color: #a9b0ba; }

@media (max-width: 600px) {
    .test-tarjeta { padding: 20px; }
    .test-pregunta { font-size: 1.15rem; }
    .barra-fila { grid-template-columns: 1fr 70px; }
    .barra-nombre { grid-column: 1 / -1; }
}

@media print {
    .top-bar, .menu-lateral, .menu-lateral-overlay, .no-imprimir, .marquee-banner { display: none !important; }
    body { background: white !important; }
    .test-tarjeta { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
}
