/* En tu archivo CSS principal (por ejemplo, style.css) */
html {
    overscroll-behavior-y: none;
    /* O 'contain' si prefieres un ligero efecto de rebote sin refresco */
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, white 20%, rgb(244, 255, 252) 100%);
    min-height: 100vh;
    color: #333;
    overscroll-behavior-y: none;
    /* O 'contain' */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 10px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.header h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.header-subtitle {
    margin: 0;
}


.file-input {
    display: none;
}

.library {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.book-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    cursor: pointer;
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.book-cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    /* 👈 formato libro */

    border-radius: 10px;
    margin-bottom: 15px;

    background-color: #eee;
    background-size: cover;
    /* 👈 mejor para covers reales */
    background-position: center;
    background-repeat: no-repeat;
}

.book-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 8px;
    color: #333;
}

.book-author {
    color: #666;
    margin-bottom: 10px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(45deg, #4facfe, #00f2fe);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.9rem;
    color: #666;
    text-align: center;
}

.book-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.action-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.read-btn {
    background: rgb(29, 93, 220);
    color: white;
}

.delete-btn {
    background: white;
    color: lightblue;
}

.action-btn:hover {
    transform: translateY(-1px);
}

.reader {
    display: none;
    background: white;
    border-radius: 15px;
    padding: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 90vh;
    overflow: hidden;
}

.reader-header {
    background: linear-gradient(45deg, #4facfe, #00f2fe);
    color: white;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reader-title {
    font-size: 1.3rem;
    font-weight: bold;
}

.reader-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.control-btn {
    background: white;
    border: none;
    color: black;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 16px;
}

.control-btn:hover {
    background: rgb(240, 111, 111);
}

.reader-content {
    padding: 30px;
    max-height: 75vh;
    overflow-y: auto;
    line-height: 1.8;
    font-size: 1rem;
}

.reader-content h1,
.reader-content h2,
.reader-content h3 {
    margin: 20px 0 15px 0;
    color: #333;
}

.reader-content p {
    margin-bottom: 15px;
    text-align: justify;
}

.reader-navigation {
    background: #f8f9fa;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #e0e0e0;
}

.nav-btn {
    background: linear-gradient(45deg, #074c87, #b4efd7);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 25px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.nav-btn:hover {
    transform: translateY(-2px);
}

.nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.chapter-info {
    font-weight: bold;
    color: #333;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #4facfe;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

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

.empty-library {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.empty-library h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.stats {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 10px;
    margin-bottom: 10px;
    color: brown;
    text-align: center;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: bold;
    display: block;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

.tooltip {
    position: fixed;
    background: rgba(3, 97, 173, 0.95);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 1rem;
    max-width: 70vw;
    max-height: 90vh;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    line-height: 1.4;
    display: none;
    overflow-y: auto;
    word-wrap: break-word;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 20px;
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.reader-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 20px auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.reader-content a[href^="#"] {
    color: #667eea;
    text-decoration: underline;
    cursor: pointer;
    position: relative;
}

.reader-content a[href^="#"]:hover {
    color: #764ba2;
}


/* Navigation Panel Styles */
.navigation-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 300px;
    height: 100%;
    background: white;
    border-right: 1px solid #e0e0e0;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.nav-tabs {
    display: flex;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.nav-tab {
    flex: 1;
    padding: 12px 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
}

.nav-tab.active {
    background: white;
    border-bottom-color: #4facfe;
    color: #4facfe;
    font-weight: bold;
}

.nav-tab:hover {
    background: #e9ecef;
}

.nav-content {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chapter-item {
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
}

.chapter-item:hover {
    background: #f8f9ff;
    border-color: #4facfe;
}

.chapter-item.current {
    background: #4facfe;
    color: white;
    border-color: #4facfe;
}

.chapter-title {
    font-weight: bold;
    margin-bottom: 4px;
}

.chapter-progress {
    font-size: 0.8rem;
    opacity: 0.7;
}

.toc-list {
    font-size: 0.9rem;
    line-height: 1.6;
}

.toc-item {
    padding: 8px 12px;
    margin: 4px 0;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.toc-item:hover {
    background: #f0f4ff;
}

.toc-level-1 {
    margin-left: 0;
    font-weight: bold;
}

.toc-level-2 {
    margin-left: 20px;
}

.toc-level-3 {
    margin-left: 40px;
    font-size: 0.85rem;
}

.goto-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.goto-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.goto-section label {
    font-weight: bold;
    color: #333;
}

.goto-section input[type="number"] {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

.goto-section button {
    padding: 10px 20px;
    background: linear-gradient(45deg, #4facfe, #00f2fe);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    transition: transform 0.2s ease;
}

.goto-section button:hover {
    transform: translateY(-1px);
}

.goto-section input[type="range"] {
    width: 100%;
    margin: 10px 0;
}

#progressValue {
    text-align: center;
    font-weight: bold;
    color: #4facfe;
}

/* Theme Panel Styles */
.theme-panel {
    position: absolute;
    top: 60px;
    right: 20px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 10;
    min-width: 200px;
}

/* Highlighter Panel Styles */
.highlighter-panel {
    position: absolute;
    top: 60px;
    right: 20px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 10;
    min-width: 250px;
}

.highlighter-colors {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 15px;
}

.color-btn {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: #333;
}

.color-btn.active {
    border-color: #333;
    transform: scale(1.1);
}

.color-btn.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #333;
    font-weight: bold;
    font-size: 16px;
}

.color-yellow {
    background: #ffeb3b;
}

.color-green {
    background: #4caf50;
}

.color-blue {
    background: #2196f3;
}

.color-pink {
    background: #e91e63;
}

.color-orange {
    background: #ff9800;
}

.color-purple {
    background: #9c27b0;
}

.highlighter-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.highlight-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.highlight-btn.primary {
    background: linear-gradient(45deg, #4facfe, #00f2fe);
    color: white;
}

.highlight-btn.secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.highlight-btn:hover {
    transform: translateY(-1px);
}

.highlight-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Highlight Styles */
.highlight {
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.highlight:hover {
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.highlight-yellow {
    background: rgba(255, 235, 59, 0.4);
}

.highlight-green {
    background: rgba(76, 175, 80, 0.4);
}

.highlight-blue {
    background: rgba(33, 150, 243, 0.4);
}

.highlight-pink {
    background: rgba(233, 30, 99, 0.4);
}

.highlight-orange {
    background: rgba(255, 152, 0, 0.4);
}

.highlight-purple {
    background: rgba(156, 39, 176, 0.4);
}

/* Highlight Context Menu */
.highlight-context-menu {
    position: fixed;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    min-width: 200px;
    border: 1px solid #e0e0e0;
}

.highlight-menu-title {
    font-weight: bold;
    color: #333;
    margin-bottom: 12px;
    text-align: center;
    font-size: 0.9rem;
}

.highlight-menu-colors {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 8px;
}

.highlight-menu-color {
    width: 32px;
    height: 32px;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    margin: 0 auto;
}

.highlight-menu-color:hover {
    transform: scale(1.1);
    border-color: #333;
}

.highlight-menu-color.current {
    border-color: #333;
    transform: scale(1.1);
}

.highlight-menu-color.current::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #333;
    font-weight: bold;
    font-size: 14px;
}

.highlight-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.highlight-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    text-align: left;
}

.highlight-menu-btn.copy {
    background: #e3f2fd;
    color: #1976d2;
}

.highlight-menu-btn.copy:hover {
    background: #bbdefb;
}

.highlight-menu-btn.delete {
    background: #ffebee;
    color: #d32f2f;
}

.highlight-menu-btn.delete:hover {
    background: #ffcdd2;
}

.highlight-menu-btn.cancel {
    background: #f5f5f5;
    color: #666;
}

.highlight-menu-btn.cancel:hover {
    background: #eeeeee;
}

.highlight-menu-icon {
    font-size: 1rem;
}

.selection-mode {
    cursor: crosshair !important;
}

.selection-mode * {
    cursor: crosshair !important;
}

.theme-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.theme-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.theme-btn:hover {
    border-color: #4facfe;
    transform: translateY(-2px);
}

.theme-btn.active {
    border-color: #4facfe;
    background: #f8f9ff;
    color: #4facfe;
    font-weight: bold;
}

.theme-preview {
    width: 40px;
    height: 30px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.light-preview {
    background: linear-gradient(to bottom, #ffffff 50%, #f8f9fa 50%);
}

.dark-preview {
    background: linear-gradient(to bottom, #3e72cc 50%, #03328f 50%);
}

.sepia-preview {
    background: linear-gradient(to bottom, #f5e9cb 50%, #ebd7b0 50%);
}

.night-preview {
    background: linear-gradient(to bottom, #016606 50%, #020617 50%);
}

.gray-preview {
    background: linear-gradient(to bottom, #6b7280 50%, #4b5563 50%);
}

.blue-preview {
    background: linear-gradient(to bottom, #1e3a8a 50%, #1e1b4b 50%);
}

.brown-preview {
    background: linear-gradient(to bottom, #796d4e 50%, #9c6e11 50%);
}

/* Theme Styles */
.reader.theme-light {
    background: white;
    color: #333;
}

.reader.theme-dark {
    background: #536b96;
    color: #e2e8f0;
}

.reader.theme-dark {
    background: #536b96;
    color: #e2e8f0;
}

.reader.theme-dark .reader-content {
    background: #465f8a;
    color: #e2e8f0;
}

.reader.theme-dark .navigation-panel {
    background: #42609b;
    border-right-color: #6083c0;
    color: #e2e8f0;
}

.reader.theme-dark .nav-tabs {
    background: #4a6799;
}

.reader.theme-dark .nav-tab {
    color: #a0aec0;
}

.reader.theme-dark .nav-tab.active {
    background: #46629b;
    color: #667eea;
}

.reader.theme-dark .chapter-item {
    background: #405f94;
    border-color: #35558d;
    color: #e2e8f0;
}

.reader.theme-dark .chapter-item:hover {
    background: #5772a0;
}

.reader.theme-sepia {
    background: #ece0c0;
    color: #5d4e37;
}

.reader.theme-sepia .reader-content {
    background: #f7f3e9;
    color: #5d4e37;
}

.reader.theme-sepia .navigation-panel {
    background: #f7e9cc;
    color: #5d4e37;
}

.reader.theme-sepia .nav-tabs {
    background: #f0dec6;
}

.reader.theme-sepia .chapter-item {
    background: #f3e7ce;
    border-color: #d4c4a8;
}

.reader.theme-night {
    background: #e1ffeb;
    color: #eaedf0;
}

.reader.theme-night .reader-content {
    background: #dcf3e0;
    color: #088f30;
}

.reader.theme-night .navigation-panel {
    background: #1d7515;
    border-right-color: #334155;
    color: #e2f3e2;
}


.reader.theme-night .nav-tabs {
    background: #137023;
}

.reader.theme-night .nav-tab {
    color: #e0fcd3;
}


.reader.theme-night .nav-tab.active {
    background: #216310;
    color: #e4f5dd;
}

.reader.theme-night .chapter-item {
    background: #3d7c24;
    border-color: #216e3b;
    color: #52d652;
}

.reader.theme-night .chapter-item:hover {
    background: #3c7218;
}

.reader.theme-gray {
    background: #e3e6e0;
    color: #636463;
}

.reader.theme-gray .reader-content {
    background: #6b7280;
    color: #f9fafb;
}

.reader.theme-gray .navigation-panel {
    background: #d9dbd7;
    color: #626362;
}

.reader.theme-gray .nav-tabs {
    background: #cfd6d0;
}

.reader.theme-gray .nav-tab {
    color: #d1d5db;
}

.reader.theme-gray .nav-tab.active {
    background: #4b5563;
    color: #667eea;
}

.reader.theme-gray .chapter-item {
    background: #d1d4d0;
    border-color: #acb3ab;
}

.reader.theme-gray .chapter-item:hover {
    background: #6b7280;
}

.reader.theme-blue {
    background: #1e3a8a;
    color: #f1f5f9;
}

.reader.theme-blue .reader-content {
    background: #1e3a8a;
    color: #f1f5f9;
}

.reader.theme-blue .navigation-panel {
    background: #1e1b4b;
    border-right-color: #1e3a8a;
    color: #f1f5f9;
}

.reader.theme-blue .nav-tabs {
    background: #312e81;
}

.reader.theme-blue .nav-tab {
    color: #cbd5e1;
}

.reader.theme-blue .nav-tab.active {
    background: #1e1b4b;
    color: #fbbf24;
}

.reader.theme-blue .chapter-item {
    background: #312e81;
    border-color: #1e3a8a;
    color: #f1f5f9;
}

.reader.theme-blue .chapter-item:hover {
    background: #1e3a8a;
}

.reader.theme-brown {
    background: #947f4b;
    color: #5f3d0a;
}

.reader.theme-brown .reader-content {
    background: #a16207;
    color: #fef3c7;
}

.reader.theme-brown .navigation-panel {
    background: #bea470;
    color: #835612;
}

.reader.theme-brown .nav-tabs {
    background: #c79b62;
}

.reader.theme-brown .nav-tab {
    color: #fde68a;
}

.reader.theme-brown .nav-tab.active {
    background: #78350f;
    color: #667eea;
}

.reader.theme-brown .chapter-item {
    background: #dfb86a;
    border-color: #80663b;
}

.reader.theme-brown .chapter-item:hover {
    background: #a16207;
}

.reader-content a[href^="#"] {
    display: inline-block;
    margin: 4px;
    padding: 3px 5px;
    /*background: white;/ *#4facfe;*/
    color: blue;
    /*white;*/
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
}

.reader-content a[href^="#"]:hover {
    background: #00c6ff;
}

/* Menú dropdown */
.dropdown {
    display: inline-block;
}


.dropdown-btn {
    position: fixed;
    top: 10px;
    right: 17%;
    cursor: pointer;
    background: brown;
    color: white;
    border: none;
    padding: 8px;
    font-size: 12px;
    border-radius: 20px;
    display: flex;
    gap: 5px;
    transition: background-color 0.3s;
}

.dropdown-btn:hover {
    background-color: black;
}

.dropdown-content {
    display: none;
    position: fixed;
    top: 50px;
    /* Justo debajo del botón */
    right: 17%;
    background-color: white;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
    padding: 2px;
    border-radius: 8px;
    z-index: 1000;
}

.dropdown-content a {
    color: black;
    padding: 6px 8px;
    text-decoration: none;
    display: flex;
    gap: 10px;
    transition: background-color 0.2s;
}

.dropdown-content a:hover {
    background-color: #f1f1f1;
}

.show {
    display: block;
}

.dropdown-hidden {
    display: none;
}

.dropdown-visible {
    display: block;
}

.piepagina {
    max-width: 1000px;
    margin: 40px auto;
    padding: 20px;
    background: #fdfdfd;
    border-radius: 8px;
    font-size: 0.9em;
    color: #444;
}

.upload-btn {
    /* Colores y Fondo */
    background-color: lightyellow;
    /* Un azul moderno, o usa var(--accent-color) */
    color: brown;

    /* Dimensiones y Espaciado */
    padding: 12px 12px;
    min-width: 80px;

    /* Tipografía */
    font-size: 24px;
    font-weight: 600;
    font-family: inherit;

    /* Bordes y Bordes Redondeados */
    border: none;
    border-radius: 8px;

    /* Interactividad */
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    /* Animaciones */
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Efecto al pasar el mouse */
.upload-btn:hover {
    background-color: lightblue;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Efecto al hacer clic */
.upload-btn:active {
    transform: translateY(0);
    background-color: #1e40af;
}

/* Estilo por si el botón está dentro de un contenedor centrado */
.upload-section {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
}

/* Estilo para el triángulo del sistema */
.custom-summary::marker,
.custom-summary::-webkit-details-marker {
    color: #ef4444;
    /* Rojo (text-red-500) */
    font-size: 1.8rem;
    /* Tamaño grande para el triángulo */
}

/* Asegura que el triángulo y el texto se alineen correctamente */
.custom-summary {
    list-style-position: inside;
    display: list-item;
    /* Necesario en algunos navegadores para ver el marker */
}

/* Si usas Flexbox en el summary, a veces el marker desaparece. 
    Esta es la forma de recuperarlo y darle espacio: */
details[open] summary.custom-summary {
    margin-bottom: 1rem;
}

@media (max-width: 768px) {

    /* --- Estructura y Header --- */
    .container {
        padding: 10px;
    }

    .header {
        margin-bottom: 10px;
    }

    .header h1 {
        font-size: 1.6rem;
        margin-bottom: 5px;
    }

    .header-subtitle {
        display: none;
    }

    /* --- Biblioteca y Cards --- */
    .library {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .book-card {
        padding: 15px;
    }

    .book-cover {
        height: 160px;
        font-size: 2rem;
    }



    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    /* --- Lector (Reader) --- */
    .reader {
        max-height: 95vh;
        margin: 0 -10px;
        border-radius: 0;
    }

    .reader-header {
        padding: 4px 5px;
        flex-direction: column;
        gap: 5px;
        text-align: center;
        flex-shrink: 0;
    }

    .reader-title {
        font-size: 0.9rem;
        order: 1;
        text-align: center;
        line-height: 1.2;
        max-height: 2.4em;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }

    .reader-controls {
        order: 2;
        justify-content: center;
    }

    .reader-content {
        padding: 15px;
        font-size: 0.8rem;
        max-height: 80vh;
    }

    .reader-navigation {
        padding: 4px 5px;
        flex-direction: row;
        gap: 5px;
        align-items: center;
        justify-content: space-between;
        flex-shrink: 0;
    }

    .nav-btn {
        padding: 2px 3px;
        font-size: 0.85rem;
        flex: 0 0 auto;
        min-width: 60px;
    }

    .chapter-info {
        flex: 1;
        text-align: center;
        font-size: 0.85rem;
        margin: 0 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* --- Paneles y Menús --- */
    .navigation-panel {
        width: 100%;
        height: 50%;
        top: auto;
        bottom: 0;
        border-right: none;
        border-top: 1px solid #e0e0e0;
    }

    .theme-panel,
    .highlighter-panel {
        right: 10px;
        top: 70px;
    }

    .theme-panel {
        min-width: 180px;
    }

    .highlighter-panel {
        min-width: 220px;
    }

    .theme-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .theme-btn {
        padding: 8px;
        font-size: 0.8rem;
    }

    .theme-preview {
        width: 30px;
        height: 20px;
    }

    /* --- Tooltips y Botones Especiales --- */
    .tooltip {
        max-width: 90vw !important;
        /* Aprovechamos un poco más el ancho */
        max-height: 40vh !important;
        /* Evitamos que tape más de un cuarto de pantalla */
        font-size: 0.9rem;
        /* Un tamaño legible para móvil */

        /* ¡ESTO FIJA EL TOOLTIP ABAJO EN MÓVIL E IGNORA AL SCRIPT! */
        position: fixed !important;
        bottom: 20px !important;
        top: auto !important;
        /* Cancela el 'top' que le inyecta JS */
        left: 5vw !important;
        right: 5vw !important;
        width: auto !important;

        /* Aseguramos scroll fluido por si el texto desborda */
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;

        /* Pequeña elevación visual */
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
    }

    /* Ocultamos la flechita del tooltip en móviles porque ya no apunta a una palabra */
    .tooltip::after {
        display: none !important;
    }

    .dropdown-btn {
        top: 30px;
        right: 5px;
        padding: 5px;
    }

    .apps-btn {
        left: 10px;
    }

    /* --- Menú de Resaltado --- */
    .highlight-context-menu {
        min-width: 180px;
        padding: 12px;
    }

    .highlight-menu-colors {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .highlight-menu-color {
        width: 28px;
        height: 28px;
    }

    .highlight-menu-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    @media (max-width: 480px) {
        .header h1 {
            font-size: 1.8rem;
        }

        .stats {
            padding: 15px;
        }


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

        .reader-content {
            padding: 12px;
            font-size: 0.95rem;
        }

        .control-btn {
            padding: 6px 10px;
            font-size: 0.7rem;
        }

        .navigation-panel {
            height: 60%;
        }

        .nav-tab {
            padding: 8px 4px;
            font-size: 0.8rem;
        }

        .theme-options {
            grid-template-columns: 1fr;
            gap: 6px;
        }
    }
}

/* --- Estilos para el Help Modal Corregido con Scroll --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    /* Fondo oscuro semitransparente */
    display: none;
    /* Oculto por defecto */
    justify-content: center;
    align-items: center;
    z-index: 9999;
    /* Asegura que esté por encima de todo */
    padding: 10px;
    /* Evita que el modal pegue con los bordes de la pantalla */
}

.modal-overlay.active {
    display: flex;
    /* Se muestra centrado al activarse */
}

.modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;

    /* ¡ESTA ES LA CLAVE PARA EL SCROLL EN MÓVIL! */
    max-height: 85vh;
    /* El modal nunca ocupará más del 85% de la altura de la pantalla */
    overflow-y: auto;
    /* Si el contenido no cabe, activa el scroll vertical dentro del cuadro blanco */

    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: modalFadeIn 0.3s ease;
}

.modal-close-btn {
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    margin-top: 15px;
    display: block;
    /* Asegura que se comporte como bloque */
    width: 100%;
    /* En móviles es más cómodo presionar un botón ancho */
    text-align: center;
    transition: background 0.2s;
}

.modal-close-btn:hover {
    background-color: #dc2626;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}
