/* =============================================================================
   BIBLIOTECA PERSONAL - HOJA DE ESTILOS MODERNA Y EDITORIAL
   Paleta Pastel: Blanco Roto, Rosa Empolvado, Lavanda Suave y Verde Salvia.
   Tipografía: Playfair Display + Plus Jakarta Sans
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap');

:root {
    /* Paleta de Colores Pastel */
    --bg-main: #FAF7F5;          /* Blanco roto / Crema sutil */
    --bg-surface: #FFFFFF;       /* Superficie de tarjetas */
    --bg-surface-alt: #F6F2EE;   /* Superficie secundaria / Hover sutil */
    
    --rose-primary: #E8B4B8;     /* Rosa empolvado */
    --rose-hover: #DC9FA4;
    --rose-light: #FBF0F1;
    --rose-border: #F3D2D5;

    --lavender-primary: #D4C5E2; /* Lavanda suave */
    --lavender-hover: #C3B1D4;
    --lavender-light: #F4EFF8;
    --lavender-border: #E5DAF0;

    --sage-primary: #C1D7C7;     /* Verde salvia apagado */
    --sage-hover: #AFC8B6;
    --sage-light: #EDF5F0;
    --sage-border: #D7E7DC;

    --gold-star: #DFC589;        /* Oro suave para valoración */
    --gold-star-active: #D4B368;
    --gold-star-bg: #EAE5D9;

    --text-main: #3E3A39;        /* Gris grafito cálido */
    --text-muted: #7A7471;       /* Texto secundario */
    --text-subtle: #A8A19D;      /* Texto de apoyo / placeholders */
    --border-color: #EFEAE6;     /* Bordes sutiles */
    --border-hover: #DFD7D1;

    /* Tipografías */
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    /* Sombras sutiles y suaves */
    --shadow-sm: 0 2px 10px rgba(62, 58, 57, 0.03);
    --shadow-md: 0 8px 24px rgba(62, 58, 57, 0.05);
    --shadow-lg: 0 16px 40px rgba(62, 58, 57, 0.08);
    --shadow-rose: 0 10px 30px rgba(232, 180, 184, 0.28);
    --shadow-hover: 0 14px 35px rgba(62, 58, 57, 0.09);

    /* Radios */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 999px;

    /* Transiciones */
    --transition-fast: 0.15s ease;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================================================
   RESETEO Y BASE
   ============================================================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    max-width: 100%;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    outline: none;
}

.btn-text-short {
    display: none;
}

/* =============================================================================
   LAYOUT Y CONTENEDOR PRINCIPAL
   ============================================================================= */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    box-sizing: border-box;
}

.main-content {
    flex: 1;
    padding: 32px 0 60px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* =============================================================================
   ENCABEZADO / NAVBAR
   ============================================================================= */
.site-header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 100%;
}

.header-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    min-width: 0;
    flex-shrink: 1;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--rose-light), var(--lavender-light));
    border: 1px solid var(--rose-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--rose-hover);
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
    line-height: 1.1;
    white-space: nowrap;
}

.brand-text p {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 500;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* =============================================================================
   BOTONES Y ELEMENTOS DE ACCIÓN
   ============================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.92rem;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--rose-primary);
    color: #2F2A29;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--rose-hover);
    box-shadow: var(--shadow-rose);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-alt);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.btn-lavender {
    background-color: var(--lavender-light);
    color: #4C3C5C;
    border-color: var(--lavender-border);
}

.btn-lavender:hover {
    background-color: var(--lavender-primary);
    color: #2D1E3D;
}

.btn-sage {
    background-color: var(--sage-light);
    color: #2E4735;
    border-color: var(--sage-border);
}

.btn-sage:hover {
    background-color: var(--sage-primary);
    color: #1F3626;
}

.btn-amber {
    background-color: #FDF4E3;
    color: #634C1B;
    border-color: #F4E2BD;
}

.btn-amber:hover {
    background-color: var(--gold-star);
    color: #2F240C;
}

.btn-terracotta {
    background-color: #FBF0EC;
    color: #5C3224;
    border-color: #F3D3C6;
}

.btn-terracotta:hover {
    background-color: #EBB6A2;
    color: #381A10;
}

.btn-danger {
    background-color: #FDE8E9;
    color: #D3525E;
    border-color: #F8CAD0;
}

.btn-danger:hover {
    background-color: #D3525E;
    color: #FFFFFF;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.82rem;
    border-radius: var(--radius-full);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-muted);
}

.btn-icon:hover {
    background: var(--bg-surface-alt);
    color: var(--text-main);
    border-color: var(--border-hover);
}

/* =============================================================================
   ESTADÍSTICAS Y HERO SUMMARY
   ============================================================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.rose { background: var(--rose-light); color: #C47980; }
.stat-icon.lavender { background: var(--lavender-light); color: #8A72A4; }
.stat-icon.sage { background: var(--sage-light); color: #6D8E76; }
.stat-icon.gold { background: #FAF3E3; color: #B39247; }

.stat-info h3 {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.1;
    font-family: var(--font-heading);
}

.stat-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* =============================================================================
   PANEL DE FILTROS Y BÚSQUEDA
   ============================================================================= */
.filters-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 36px;
    box-shadow: var(--shadow-sm);
}

.search-bar-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 14px 16px 14px 46px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text-main);
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    background: var(--bg-surface);
    border-color: var(--rose-primary);
    box-shadow: 0 0 0 3px var(--rose-light);
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.filter-group-inline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.filter-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 4px;
}

.pill-filter {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.84rem;
    font-weight: 500;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.pill-filter:hover {
    background: var(--bg-surface-alt);
    color: var(--text-main);
}

.pill-filter.active {
    background: var(--rose-primary);
    border-color: var(--rose-hover);
    color: #2F2A29;
    font-weight: 600;
}

.filter-select {
    padding: 8px 32px 8px 14px;
    background: var(--bg-main) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%237A7471' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E") no-repeat calc(100% - 12px) center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    color: var(--text-main);
    cursor: pointer;
    appearance: none;
    transition: var(--transition);
}

.filter-select:focus {
    outline: none;
    border-color: var(--rose-primary);
}

.filter-section-block {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

.filter-section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.filter-hint {
    font-size: 0.76rem;
    color: var(--text-muted);
    font-weight: 500;
}

.practice-levels-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.practice-level-filter-pill {
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 600;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: #615745;
    cursor: pointer;
    transition: var(--transition);
    border-left: 4px solid #DFC589;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.practice-level-filter-pill:hover {
    background: #FCF8F2;
    border-color: #D4B368;
    color: #383120;
}

.practice-level-filter-pill.active {
    background: #F7E9C8;
    border-color: #C29B47;
    color: #382705;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(194, 155, 71, 0.2);
}

.practice-level-filter-pill.active::before {
    content: "✓";
    font-weight: 800;
    margin-right: 2px;
    color: #8C6615;
}

.genres-pills-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.genre-tag-filter {
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.genre-tag-filter:hover {
    border-color: var(--lavender-primary);
    color: var(--text-main);
    background: var(--bg-surface-alt);
}

.genre-tag-filter.active {
    background: var(--lavender-light);
    border-color: var(--lavender-primary);
    color: #432E56;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
}

.genre-tag-filter.active::before {
    content: "✓";
    font-weight: 800;
    margin-right: 2px;
    color: #62437C;
}

.meta-practice-tag {
    background: #FCF5E5;
    color: #6B541C;
    border: 1px solid #EBD6A7;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* =============================================================================
   GRID DE TARJETAS DE LIBROS (CATÁLOGO)
   ============================================================================= */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 28px;
}

.book-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
}

.book-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--rose-border);
}

.book-cover-wrap {
    height: 290px;
    background: linear-gradient(180deg, #FAF7F3 0%, #EDE6DE 100%);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-color);
}

.cover-badges-bar {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    z-index: 10;
    pointer-events: none;
}

.cover-badges-bar > * {
    pointer-events: auto;
}

.badge-spacer {
    display: inline-block;
    width: 1px;
    height: 1px;
}

.book-cover-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    text-decoration: none;
    padding-top: 22px;
    box-sizing: border-box;
}

.book-cover-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px 7px 7px 4px;
    box-shadow: -2px 4px 14px rgba(45, 35, 30, 0.22), 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: var(--transition-slow);
}

.book-card:hover .book-cover-img {
    transform: translateY(-3px) scale(1.03);
    box-shadow: -3px 6px 18px rgba(45, 35, 30, 0.3), 0 2px 5px rgba(0, 0, 0, 0.12);
}

/* Portada decorativa fallback si no hay imagen */
.book-cover-placeholder {
    width: 110px;
    height: 160px;
    background: linear-gradient(135deg, var(--rose-primary), var(--lavender-primary));
    border-radius: 4px 10px 10px 4px;
    box-shadow: -3px 4px 15px rgba(62, 58, 57, 0.18), inset -4px 0 6px rgba(0, 0, 0, 0.08);
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #FFFFFF;
    text-align: center;
    border-left: 4px solid rgba(255, 255, 255, 0.4);
    position: relative;
}

.placeholder-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.placeholder-author {
    font-size: 0.68rem;
    font-weight: 500;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-status {
    position: static;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.74rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
    z-index: 10;
    cursor: pointer;
    border: 1px solid transparent;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    white-space: nowrap;
    transition: var(--transition);
}

.badge-status.read {
    background: rgba(228, 238, 230, 0.95);
    color: #1E4627;
    border-color: #BCD3C2;
}

.badge-status.unread {
    background: rgba(243, 237, 246, 0.95);
    color: #4C3761;
    border-color: #D3C4DF;
}

.badge-epub-tag {
    position: static;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.74rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.95);
    color: #234839;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
    z-index: 10;
    text-decoration: none;
    transition: var(--transition);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.badge-epub-tag:hover {
    background: #234839;
    color: #FFFFFF;
    transform: scale(1.05);
}

.badge-epub-tag:hover {
    background: #2D4A3E;
    color: #FFFFFF;
    transform: scale(1.06);
}

.epub-badge-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--sage-light);
    color: var(--sage-hover);
    padding: 3px 8px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid var(--sage-border);
    transition: var(--transition);
}

.epub-badge-link:hover {
    background: var(--sage-primary);
    color: #1A311F;
    transform: translateY(-1px);
}

/* Modal de Compartir */
.share-social-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.btn-share-social {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--border-color);
    background: var(--bg-main);
    color: var(--text-main);
    transition: var(--transition);
    cursor: pointer;
}

.btn-share-social:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-share-social.whatsapp {
    background: #E8F7EE;
    color: #0E7A3E;
    border-color: #C3EBD1;
}
.btn-share-social.whatsapp:hover {
    background: #D4F2DE;
}

.btn-share-social.telegram {
    background: #EAF4FD;
    color: #1769AA;
    border-color: #BDE0F9;
}
.btn-share-social.telegram:hover {
    background: #D7ECFB;
}

.btn-share-social.email {
    background: #FFF3E8;
    color: #A0520C;
    border-color: #FCE1C8;
}
.btn-share-social.email:hover {
    background: #FEE7D0;
}

.btn-share-native {
    background: var(--lavender-light);
    color: var(--lavender-hover);
    border-color: var(--lavender-border);
    grid-column: 1 / -1;
}
.btn-share-native:hover {
    background: var(--lavender-primary);
}

.book-card-body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

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

.genre-pill {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    background: var(--bg-main);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.book-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.25;
    margin-bottom: 4px;
}

.book-title a:hover {
    color: var(--rose-hover);
}

.book-author {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    font-weight: 500;
}

.book-synopsis-preview {
    font-size: 0.86rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 16px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-card-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Componente de Estrellas */
.star-rating-display {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    color: var(--gold-star);
}

.star-rating-display svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.star-rating-display .star-empty {
    color: var(--gold-star-bg);
}

.book-meta-quick {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* =============================================================================
   VISTA DETALLADA DEL LIBRO (libro.php)
   ============================================================================= */
.book-detail-header {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 36px;
    margin-bottom: 36px;
    box-shadow: var(--shadow-sm);
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 36px;
    position: relative;
}

.detail-cover-box {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    height: 350px;
    background: linear-gradient(145deg, #F8F5F1, #ECE5DE);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    border: 1px solid var(--border-color);
}

.detail-cover-box img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px 8px 8px 4px;
    box-shadow: -3px 5px 16px rgba(45, 35, 30, 0.25), 0 2px 6px rgba(0, 0, 0, 0.1);
}

.detail-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.breadcrumb-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.breadcrumb-nav a:hover {
    color: var(--rose-hover);
}

.detail-title {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.15;
    margin-bottom: 6px;
}

.detail-author {
    font-size: 1.15rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 18px;
}

.detail-specs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 14px;
    margin: 20px 0;
    padding: 16px;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.spec-item {
    display: flex;
    flex-direction: column;
}

.spec-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-subtle);
    font-weight: 600;
}

.spec-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    margin-top: 2px;
}

.detail-actions-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color);
}

/* Rating Interactivo */
.interactive-stars {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.star-btn {
    color: var(--gold-star-bg);
    transition: var(--transition-fast);
    padding: 2px;
}

.star-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.star-btn.filled, .star-btn.hovered {
    color: var(--gold-star);
}

.star-btn:hover {
    transform: scale(1.18);
}

/* =============================================================================
   PESTAÑAS Y SECCIONES DE CONTENIDO
   ============================================================================= */
.tabs-wrapper {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.content-tabs-nav {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 28px;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    padding-bottom: 2px;
}

.tab-btn {
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: var(--text-main);
    border-color: var(--rose-primary);
}

.tab-badge {
    background: var(--bg-surface-alt);
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    color: var(--text-muted);
}

.tab-btn.active .tab-badge {
    background: var(--rose-light);
    color: #4A3A3B;
}

.tab-content-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content-panel.active {
    display: block;
}

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

/* Tarjetas de Ficha y Opinión */
.editorial-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.editorial-card-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.editorial-text {
    font-size: 1rem;
    color: #4A4543;
    line-height: 1.8;
    white-space: pre-line;
}

/* =============================================================================
   SECCIÓN DE FRAGMENTOS Y CITAS
   ============================================================================= */
.section-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
}

.fragments-masonry {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.quote-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.quote-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--lavender-border);
}

.quote-decor {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    line-height: 1;
    color: var(--rose-primary);
    opacity: 0.5;
    margin-bottom: -10px;
    user-select: none;
}

.quote-text {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.12rem;
    color: #383332;
    line-height: 1.6;
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.quote-notes {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-main);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    border-left: 3px solid var(--lavender-primary);
}

.quote-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-subtle);
    padding-top: 12px;
    border-top: 1px dashed var(--border-color);
}

/* Tarjeta de Fragmento con Imagen */
.fragment-image-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.fragment-image-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--sage-border);
}

.fragment-thumb-box {
    height: 220px;
    background: var(--bg-main);
    overflow: hidden;
    cursor: zoom-in;
    position: relative;
}

.fragment-thumb-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.fragment-thumb-box:hover img {
    transform: scale(1.03);
}

.zoom-overlay-hint {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: #FFF;
    padding: 4px 8px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0.8;
}

.fragment-body {
    padding: 16px;
}

/* =============================================================================
   SECCIÓN DE IDEAS EXTRAÍDAS / DIARIO DE REFLEXIÓN
   ============================================================================= */
.ideas-journal-list {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.idea-journal-entry {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    position: relative;
    border-left: 5px solid var(--rose-primary);
    transition: var(--transition);
}

.idea-journal-entry:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--rose-border);
    border-left-color: var(--rose-hover);
}

.idea-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.idea-date-tag {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.idea-content-text {
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.7;
    white-space: pre-line;
}

/* =============================================================================
   SECCIÓN DE PRÁCTICAS EN EL AULA (DIDÁCTICA Y PEDAGOGÍA)
   ============================================================================= */
.practices-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.practice-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    position: relative;
    border-left: 5px solid #DFC589;
    transition: var(--transition);
}

.practice-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #EBD6A7;
    border-left-color: #D4B368;
}

.practice-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.practice-title-wrapper {
    flex: 1;
}

.practice-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 10px;
    line-height: 1.3;
}

.practice-badges-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.practice-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-full);
}

.practice-badge.level {
    background: #F4EFF8;
    color: #5C4A6E;
    border: 1px solid #E5DAF0;
}

.practice-badge.duration {
    background: #EDF5F0;
    color: #2E4735;
    border: 1px solid #D7E7DC;
}

.practice-badge.date {
    background: var(--bg-main);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.practice-block {
    margin-bottom: 18px;
}

.practice-block:last-child {
    margin-bottom: 0;
}

.practice-block-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.practice-block-content {
    font-size: 0.98rem;
    color: #433E3D;
    line-height: 1.75;
    white-space: pre-line;
}

.practice-block-content.objectives {
    background: #FCF8F2;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border-left: 3px solid #DFC589;
    font-size: 0.95rem;
}

.practice-block-content.materials {
    background: var(--bg-main);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

/* =============================================================================
   MODALES Y FORMULARIOS
   ============================================================================= */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(47, 42, 41, 0.45);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-backdrop.open .modal-container {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 24px 28px 18px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 10;
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-main);
}

.modal-body {
    padding: 28px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

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

.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-label .required {
    color: #D3525E;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.94rem;
    color: var(--text-main);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    background: var(--bg-surface);
    border-color: var(--rose-primary);
    box-shadow: 0 0 0 3px var(--rose-light);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.file-upload-box {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 24px 20px;
    text-align: center;
    background: var(--bg-main);
    transition: var(--transition);
    position: relative;
}

.file-upload-box.drag-over {
    border-color: var(--rose-primary);
    background: var(--rose-light);
    transform: scale(1.01);
}

.upload-buttons-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.upload-buttons-row .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.file-input-hidden {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.preview-container {
    margin-top: 14px;
    max-height: 220px;
    display: none;
    border-radius: var(--radius-sm);
    overflow: hidden;
    text-align: center;
}

.preview-container img {
    max-height: 200px;
    max-width: 100%;
    margin: 0 auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    object-fit: contain;
}

/* Previsualización múltiple en rejilla */
.multi-preview-container {
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
}

.preview-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.preview-counter-badge {
    display: inline-flex;
    align-items: center;
    background: var(--lavender-light);
    color: var(--lavender-hover);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

.btn-clear-previews {
    background: none;
    border: none;
    font-size: 0.78rem;
    font-weight: 500;
    color: #D3525E;
    cursor: pointer;
    text-decoration: underline;
    transition: var(--transition);
}

.btn-clear-previews:hover {
    color: #a82330;
}

.multi-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
}

.preview-thumb-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 2px solid var(--card-border);
    background: var(--bg-card);
}

.preview-thumb-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-remove-thumb {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
}

.btn-remove-thumb:hover {
    background: #D3525E;
    transform: scale(1.15);
}

.genres-checkbox-grid,
.levels-checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding: 12px;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    padding: 6px 10px;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.checkbox-label:hover {
    border-color: var(--rose-primary);
    background: var(--rose-light);
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--rose-primary);
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* =============================================================================
   LIGHTBOX PARA IMÁGENES
   ============================================================================= */
.lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(20, 18, 17, 0.88);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.lightbox-modal.open {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
}

.lightbox-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.lightbox-close-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.08);
}

/* =============================================================================
   TOAST NOTIFICATIONS (ALERTAS FLOTANTES)
   ============================================================================= */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 3000;
    pointer-events: none;
}

.toast-item {
    pointer-events: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    max-width: 420px;
    font-size: 0.9rem;
    font-weight: 500;
    animation: toastSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-item.success {
    border-left: 4px solid var(--sage-primary);
    color: #1F3626;
}

.toast-item.error {
    border-left: 4px solid #D3525E;
    color: #6C1E26;
}

.toast-item.info {
    border-left: 4px solid var(--lavender-primary);
    color: #3C2A4D;
}

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

/* =============================================================================
   ESTADOS VACÍOS (EMPTY STATES)
   ============================================================================= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-color);
    margin: 20px 0;
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    background: var(--rose-light);
    color: var(--rose-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state h3 {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    margin-bottom: 6px;
    color: var(--text-main);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.92rem;
    max-width: 420px;
    margin: 0 auto 18px;
}

/* =============================================================================
   FOOTER
   ============================================================================= */
.site-footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 28px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: auto;
}

.footer-quote {
    font-family: var(--font-heading);
    font-style: italic;
    color: var(--text-main);
    font-size: 0.95rem;
    margin-bottom: 6px;
}

/* =============================================================================
   RESPONSIVIDAD Y MEDIA QUERIES OPTIMIZADAS PARA MÓVIL
   ============================================================================= */

/* Evitar desbordamiento en todos los bloques editoriales */
.editorial-card,
.quote-card,
.fragment-image-card,
.idea-journal-entry,
.practice-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Tablets y pantallas medianas (<= 992px) */
@media (max-width: 992px) {
    .book-detail-header {
        grid-template-columns: 200px 1fr;
        gap: 24px;
        padding: 28px;
    }

    .detail-cover-box {
        height: 280px;
    }

    .fragments-masonry {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

/* Tablets pequeñas y teléfonos grandes (<= 768px) */
@media (max-width: 768px) {
    .main-content {
        padding: 16px 0 40px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .book-detail-header {
        grid-template-columns: 1fr;
        padding: 22px 16px;
        text-align: center;
        gap: 20px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }

    .detail-cover-box {
        max-width: 180px;
        height: 250px;
        margin: 0 auto 12px;
    }

    .detail-info {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .breadcrumb-nav {
        justify-content: center;
        font-size: 0.8rem;
    }

    .detail-title {
        font-size: clamp(1.4rem, 5vw, 1.8rem);
        word-break: break-word;
        overflow-wrap: break-word;
        line-height: 1.2;
    }

    .detail-author {
        font-size: 1rem;
        word-break: break-word;
    }

    .book-genres {
        justify-content: center;
    }

    .detail-specs-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 10px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .spec-item {
        min-width: 0;
    }

    .spec-label {
        font-size: 0.68rem;
    }

    .spec-value {
        font-size: 0.85rem;
        word-break: break-word;
    }

    .badge-status {
        position: static;
        max-width: 100%;
        white-space: normal;
        text-align: center;
    }

    .detail-actions-bar {
        justify-content: center;
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .detail-actions-bar > div {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
    }

    .detail-actions-bar form {
        margin-left: 0 !important;
        width: 100%;
    }

    .detail-actions-bar form button {
        width: 100%;
    }

    .form-row-2 {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .tabs-wrapper {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        overflow: hidden;
    }

    .content-tabs-nav {
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0 2px 4px;
        gap: 6px;
        width: 100%;
        max-width: 100%;
    }

    .content-tabs-nav::-webkit-scrollbar {
        display: none;
    }

    .tab-btn {
        flex-shrink: 0;
        padding: 10px 14px;
        font-size: 0.88rem;
        gap: 6px;
    }

    .section-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .section-toolbar .btn {
        width: 100%;
    }

    .quote-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    .practice-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .practice-header form {
        align-self: flex-end;
    }
}

/* Teléfonos móviles estándar (<= 640px) */
@media (max-width: 640px) {
    .container {
        padding: 0 16px;
    }

    .btn-text-full {
        display: none;
    }

    .btn-text-short {
        display: inline;
    }

    /* Encabezado y menú superior con márgenes amplios y safe-area */
    .site-header {
        padding: calc(10px + env(safe-area-inset-top, 0px)) 0 10px 0;
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .header-wrapper {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 2px 0;
        gap: 10px;
        width: 100%;
        max-width: 100%;
    }

    .brand-logo {
        gap: 10px;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .logo-icon svg {
        width: 19px;
        height: 19px;
    }

    .brand-text h1 {
        font-size: 1.18rem;
        letter-spacing: -0.01em;
    }

    .brand-text p {
        display: none; /* Ocultar subtítulo en móvil para ganar espacio */
    }

    .header-actions {
        gap: 8px;
    }

    .header-actions .btn {
        padding: 7px 13px;
        font-size: 0.84rem;
        gap: 6px;
        border-radius: var(--radius-full);
    }

    .header-actions .btn svg {
        width: 15px;
        height: 15px;
    }

    /* Pestañas de menú de contenido (libro.php) */
    .tabs-wrapper {
        margin-bottom: 22px;
    }

    .content-tabs-nav {
        gap: 8px;
        padding: 4px 2px 8px 2px;
        margin-bottom: 18px;
    }

    .tab-btn {
        padding: 9px 13px;
        font-size: 0.86rem;
        gap: 6px;
    }

    .tab-badge {
        font-size: 0.72rem;
        padding: 2px 6px;
    }

    /* Estadísticas en cuadrícula de 2 columnas compacta */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 20px;
    }

    .stat-card {
        padding: 14px 12px;
        gap: 10px;
        min-width: 0;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }

    .stat-icon svg {
        width: 17px;
        height: 17px;
    }

    .stat-info {
        min-width: 0;
    }

    .stat-info h3 {
        font-size: 1.18rem;
    }

    .stat-info p {
        font-size: 0.72rem;
    }

    /* Panel de filtros móvil */
    .filters-panel {
        padding: 16px 14px;
        border-radius: var(--radius-md);
        margin-bottom: 24px;
        width: 100%;
        box-sizing: border-box;
    }

    .search-input {
        padding: 12px 14px 12px 40px;
        font-size: 16px; /* Evita zoom de iOS Safari */
    }

    .filters-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .filter-group-inline {
        width: 100%;
        justify-content: space-between;
    }

    .filter-select {
        flex: 1;
        font-size: 16px; /* Evita zoom iOS */
    }

    .status-filter-pill {
        flex: 1;
        text-align: center;
        padding: 8px 8px;
        font-size: 0.8rem;
    }

    /* Cuadrícula de libros en móvil */
    .books-grid {
        grid-template-columns: 1fr;
        gap: 16px;
        width: 100%;
    }

    .book-card {
        width: 100%;
        box-sizing: border-box;
    }

    .book-cover-wrap {
        height: 270px;
        padding: 8px;
    }

    .cover-badges-bar {
        top: 6px;
        left: 6px;
        right: 6px;
        gap: 6px;
    }

    .badge-status {
        padding: 4px 8px;
        font-size: 0.70rem;
    }

    .badge-epub-tag {
        padding: 4px 8px;
        font-size: 0.70rem;
    }

    .book-cover-link {
        padding-top: 20px;
    }

    /* Ficha técnica del libro */
    .book-detail-header {
        padding: 18px 14px;
        border-radius: var(--radius-md);
        margin-bottom: 22px;
    }

    .detail-cover-box {
        max-width: 170px;
        height: 250px;
        padding: 8px;
    }

    .detail-title {
        font-size: 1.35rem;
    }

    .detail-author {
        font-size: 0.95rem;
        margin-bottom: 10px;
    }

    .detail-specs-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding: 8px;
        margin: 12px 0;
    }

    .spec-label {
        font-size: 0.65rem;
    }

    .spec-value {
        font-size: 0.8rem;
    }

    .fragments-masonry {
        grid-template-columns: 1fr;
        gap: 14px;
        width: 100%;
    }

    .quote-card {
        padding: 16px 14px;
    }

    .quote-text {
        font-size: 0.96rem;
    }

    .editorial-card {
        padding: 16px 14px;
    }

    .idea-journal-entry {
        padding: 16px 14px;
    }

    .practice-card {
        padding: 16px 14px;
    }

    .practice-title {
        font-size: 1.1rem;
    }

    .practice-badges-row {
        gap: 4px;
    }

    .practice-badge {
        font-size: 0.74rem;
        padding: 2px 8px;
    }

    .practice-block-content {
        font-size: 0.9rem;
    }

    .practice-block-content.objectives {
        padding: 10px 12px;
    }

    .practice-block-content.materials {
        padding: 8px 10px;
    }

    /* Modales adaptados a Bottom Sheet en móvil y Pixel 9 */
    .modal-backdrop {
        padding: 0;
        align-items: flex-end;
        justify-content: center;
        height: 100vh;
        height: 100dvh;
        z-index: 2000;
    }

    .modal-container {
        max-width: 100vw;
        width: 100vw;
        border-radius: 22px 22px 0 0;
        max-height: 85vh;
        max-height: 85dvh;
        border-bottom: none;
        margin: 0;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.25);
    }

    .modal-header {
        padding: 16px 20px 12px;
        flex-shrink: 0;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border-color);
        z-index: 10;
    }

    .modal-header h2 {
        font-size: 1.25rem;
    }

    .modal-body {
        padding: 16px 18px 16px;
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .modal-actions {
        position: sticky;
        bottom: -16px;
        background: var(--bg-surface);
        margin: 20px -18px -16px -18px;
        padding: 12px 18px calc(14px + env(safe-area-inset-bottom, 24px));
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
        z-index: 20;
    }

    .modal-actions .btn {
        flex: 1;
        padding: 12px 16px;
        font-size: 0.94rem;
        font-weight: 700;
    }

    .form-control {
        font-size: 16px; /* Previene auto-zoom en iOS Safari */
    }

    /* Toasts en móvil */
    .toast-container {
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .toast-item {
        min-width: 100%;
        max-width: 100%;
        font-size: 0.82rem;
        padding: 10px 14px;
    }

    /* Botones de estrellas táctiles */
    .star-btn {
        padding: 3px;
    }

    .star-btn svg {
        width: 22px;
        height: 22px;
    }
}

/* Teléfonos muy compactos (<= 380px) */
@media (max-width: 380px) {
    .container {
        padding: 0 12px;
    }

    .brand-text h1 {
        font-size: 1.05rem;
    }

    .header-actions .btn {
        padding: 6px 10px;
        font-size: 0.78rem;
        gap: 4px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .detail-specs-grid {
        grid-template-columns: 1fr;
    }

    .tab-btn {
        padding: 8px 11px;
        font-size: 0.82rem;
    }
}

/* =============================================================================
   11. ESTILOS DE GESTIÓN DE CATEGORÍAS Y GÉNEROS (generos.php)
   ============================================================================= */
.genres-management-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.genre-admin-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    transition: var(--transition);
}

.genre-admin-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--rose-border);
}

.genre-admin-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.genre-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.06);
}

.genre-admin-name {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
    margin: 0;
    word-break: break-word;
}

.genre-books-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    white-space: nowrap;
    flex-shrink: 0;
}

.genre-books-badge.has-books {
    background: var(--sage-light);
    color: var(--sage-hover);
    border: 1px solid var(--sage-border);
}

.genre-books-badge.empty {
    background: var(--bg-main);
    color: var(--text-subtle);
    border: 1px solid var(--border-color);
}

.genre-admin-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}

.genre-color-hex {
    font-family: monospace;
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 600;
}

.genre-admin-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Selector de color y swatches pastel */
.color-picker-input {
    width: 44px;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg-surface);
}

.color-swatches-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
    gap: 6px;
    margin-top: 8px;
    padding: 10px;
    background: var(--bg-main);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.color-swatch-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0, 0, 0, 0.12);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    padding: 0;
}

.color-swatch-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

/* =============================================================================
   SISTEMA DE AUTENTICACIÓN (LOGIN EDITORIAL)
   ============================================================================= */

.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #FAF7F5;
    position: relative;
    overflow-x: hidden;
    padding: 24px 16px;
}

/* Orbes de fondo decorativos sutiles */
.auth-bg-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.auth-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.45;
    animation: floatOrb 18s ease-in-out infinite alternate;
}

.auth-orb-1 {
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, #FDE2E4 0%, rgba(253, 226, 228, 0) 70%);
    top: -100px;
    right: -50px;
}

.auth-orb-2 {
    width: 420px;
    height: 420px;
    background: radial-gradient(circle, #E2ECE9 0%, rgba(226, 236, 233, 0) 70%);
    bottom: -120px;
    left: -80px;
    animation-delay: -6s;
}

.auth-orb-3 {
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, #DFE7FD 0%, rgba(223, 231, 253, 0) 70%);
    top: 45%;
    left: 15%;
    animation-delay: -12s;
}

@keyframes floatOrb {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -25px) scale(1.08); }
    100% { transform: translate(-25px, 20px) scale(0.95); }
}

.auth-container {
    width: 100%;
    max-width: 460px;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin: auto;
}

.auth-card {
    width: 100%;
    background: #FFFFFF;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 16px 45px rgba(62, 58, 57, 0.07), 0 4px 12px rgba(62, 58, 57, 0.03);
    padding: 40px 36px;
    transition: var(--transition);
}

@media (max-width: 480px) {
    .auth-card {
        padding: 30px 22px;
        border-radius: var(--radius-md);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo-badge {
    width: 58px;
    height: 58px;
    border-radius: 18px;
    background: linear-gradient(135deg, #FBF0F1 0%, #F4EFF8 100%);
    color: var(--rose-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 6px 18px rgba(232, 180, 184, 0.25);
    border: 1px solid var(--rose-border);
}

.auth-title {
    font-family: var(--font-heading);
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.auth-subtitle {
    font-size: 0.92rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.auth-alert {
    margin-bottom: 20px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

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

.password-input-wrapper .form-control {
    padding-right: 46px;
}

.btn-toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-subtle);
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}

.btn-toggle-password:hover {
    color: var(--text-main);
    background: var(--bg-surface-alt);
}

.auth-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: -4px;
}

.custom-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 0.88rem;
    color: var(--text-muted);
}

.custom-checkbox input {
    accent-color: var(--rose-hover);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.btn-auth-submit {
    margin-top: 6px;
    padding: 13px 20px;
    font-size: 0.96rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-rose);
    transition: var(--transition);
}

.btn-auth-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(232, 180, 184, 0.4);
}

.auth-footer-hint {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px dashed var(--border-color);
}

.hint-pill {
    background: #FDF9EE;
    border: 1px solid #F5E8BE;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.hint-icon {
    font-size: 1.2rem;
    line-height: 1;
}

.hint-text {
    font-size: 0.82rem;
    color: #6C5B32;
    line-height: 1.5;
}

.hint-text code {
    background: #FAF0D2;
    color: #4A3E1F;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    font-weight: 600;
}

.hint-text small {
    display: block;
    color: #8C7B53;
    margin-top: 3px;
}

.auth-footer-copyright {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-subtle);
}

/* =============================================================================
   MENÚ DE USUARIO EN EL ENCABEZADO
   ============================================================================= */

.user-header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 6px;
}

.user-profile-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    padding: 4px 12px 4px 5px;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
    transition: var(--transition);
}

.user-profile-chip:hover {
    background: var(--rose-light);
    border-color: var(--rose-border);
    color: var(--text-main);
    transform: translateY(-1px);
}

.user-avatar-initial {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose-primary), var(--lavender-primary));
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
    box-shadow: 0 2px 6px rgba(232, 180, 184, 0.35);
}

.user-name-label {
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-surface-alt);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-logout-icon:hover {
    background: #FEE8E9;
    border-color: #F8B4B8;
    color: #D3525E;
    transform: scale(1.05);
}

.btn-logout-danger {
    background: #FDF1F2;
    color: #C2424E;
    border: 1px solid #F5C7CB;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-logout-danger:hover {
    background: #F9DCDE;
    color: #A32D38;
}

@media (max-width: 640px) {
    .user-name-label {
        display: none;
    }
    .user-profile-chip {
        padding: 3px;
    }
}

/* =============================================================================
   VISTA: PERFIL Y AJUSTES DE USUARIO
   ============================================================================= */

.profile-main-container {
    padding-top: 30px;
    padding-bottom: 60px;
    max-width: 960px;
}

.profile-hero-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 32px;
    display: flex;
    align-items: center;
    gap: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 30px;
    background-image: radial-gradient(circle at top right, rgba(232, 180, 184, 0.12), transparent 45%);
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--rose-primary) 0%, var(--lavender-primary) 100%);
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(232, 180, 184, 0.35);
    flex-shrink: 0;
}

.profile-hero-info h2 {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    color: var(--text-main);
    margin-bottom: 4px;
}

.profile-hero-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
}

@media (max-width: 768px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }
    .profile-hero-card {
        flex-direction: column;
        text-align: center;
        padding: 24px;
    }
}

.profile-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 30px 28px;
    box-shadow: var(--shadow-sm);
}

.profile-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.profile-card-header h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--text-main);
    margin-bottom: 2px;
}

.profile-card-header p {
    font-size: 0.83rem;
    color: var(--text-muted);
}

.profile-icon-pill {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.icon-rose {
    background: var(--rose-light);
    color: var(--rose-hover);
    border: 1px solid var(--rose-border);
}

.icon-lavender {
    background: var(--lavender-light);
    color: #8C72A8;
    border: 1px solid var(--lavender-border);
}

.profile-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.alert-float {
    margin-bottom: 24px;
}


