* {
    box-sizing: border-box;
}

.header {
    margin-bottom: 15px;
}
.header-title h1 a {
    color: inherit;
    text-decoration: none;
}
.chapter-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
}
.chapter-content th,
.chapter-content td {
    border: 1px solid #64748b;
    padding: 6px 8px;
    vertical-align: top;
}

.main-container {
    position: relative;
    width: 95%;
    max-width: none;
    min-height: 600px;
    background-color: rgba(15, 23, 42, 0.8);
    border: 1px solid #6366f1;
    border-radius: 15px;
    margin: 50px auto;
    padding: 30px;
    text-align: center;
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.book-detail {
    padding: 10px 30px 20px;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    min-height: 600px;
}

.book-header {
    display: flex;
    align-items: center;
    gap: 30px;
    margin-bottom: 15px;
}

.book-icon {
    width: 80px;
    height: 80px;
    border-radius: 2px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.book-icon-galaxy {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #2e1065 100%);
}

.book-icon-globe {
    background: linear-gradient(135deg, #082f49 0%, #1e3a8a 50%, #3b0764 100%);
}

.icon-scaler {
    display: flex;
    align-items: center;
    justify-content: center;
    transform-origin: center center;
}

.icon-scaler.globe-scale {
    transform: scale(0.57);
    width: 140px;
    height: 140px;
}

.icon-scaler.galaxy-scale {
    transform: scale(0.5);
    width: 160px;
    height: 160px;
}

.book-icon .globe, 
.book-icon .galaxy {
    margin-top: 0 !important;
}

.book-info {
    text-align: left;
}

.book-info h2 {
    font-size: 32px;
    margin-bottom: 5px;
    background: linear-gradient(135deg, #f8fafc 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(165, 180, 252, 0.3);
}
.book-info h2 a {
    text-decoration: none;
    color: inherit;
    -webkit-text-fill-color: inherit;
}

.content-container {
    display: flex;
    gap: 30px;
    flex-grow: 1;
    margin-bottom: 15px;
}

.table-of-contents {
    width: 280px;
    flex-shrink: 0;
    background: rgba(15, 23, 42, 0.7);
    border-radius: 12px;
    padding: 15px;
    border: 1px solid rgba(99, 102, 241, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    height: calc(100vh - 60px);
    position: sticky;
    top: 30px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.toc-title {
    font-size: 18px;
    font-weight: bold;
    color: #f8fafc;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.4);
    position: relative;
    position: sticky;
    top: 0;
    background: #0f172a; /* solid to prevent see-through */
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    z-index: 10;
}

.toc-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.5);
    color: #c7d2fe;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
}
.toc-toggle:hover {
    background: rgba(99, 102, 241, 0.25);
}

.toc-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 4px; /* space for scrollbar */
    margin-top: 8px;
}

.table-of-contents.collapsed {
    width: 48px;
    padding: 12px 10px;
}
.table-of-contents.collapsed .toc-title {
    padding-bottom: 0;
    border-bottom: none;
    text-indent: -9999px;
    height: 28px;
}
.table-of-contents.collapsed .toc-title .toc-toggle {
    right: 6px;
    text-indent: 0;
    position: absolute;
}
.table-of-contents.collapsed .toc-list {
    display: none;
}

.chapter-content .ql-align-center { text-align: center; }
.chapter-content .ql-align-right { text-align: right; }
.chapter-content .ql-align-justify { text-align: justify; }
.chapter-content .ql-direction-rtl { direction: rtl; }
.chapter-content .first-line-indent, 
.chapter-content p.first-line-indent { text-indent: 30px; }
.chapter-content p { 
    tab-size: 4; 
    -moz-tab-size: 4; 
    white-space: pre-wrap; 
    margin: 0 0 0.5em;
}
.chapter-content p:has(> br:only-child) {
    margin: 0;
}
.chapter-content img { max-width: 100%; height: auto; display: block; }
.chapter-content .ql-align-center img { margin-left: auto; margin-right: auto; }
.chapter-content .ql-align-right img { margin-left: auto; }


.toc-title::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 40%;
    height: 2px;
    background: linear-gradient(90deg, #6366f1, transparent);
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.toc-list li {
    margin-bottom: 1px;
    text-align: left;
}

.toc-chapter {
    display: block;
    color: #e2e8f0;
    font-weight: 500;
    padding: 1px 2px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    margin-bottom: 3px;
    cursor: pointer;
    position: relative;
    text-align: left;
    font-size: 15px;
}

.toc-chapter:hover {
    background: rgba(99, 102, 241, 0.2);
    color: #f8fafc;
    transform: translateX(5px);
}

.toc-chapter.active {
    background: rgba(99, 102, 241, 0.3);
    color: #f8fafc;
    font-weight: bold;
}

.toc-chapter.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: #6366f1;
    border-radius: 3px;
}

.toc-section {
    padding-left: 15px;
}

.toc-section .toc-chapter {
    font-size: 14px;
    padding: 6px 10px;
}

.chapter-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    padding: 25px 30px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    position: relative;
    max-height: 700px;
    font-size: 14px;
    line-height: 1.42;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding-bottom: 80px;
    text-align: left !important;
    font-family: Arial, Helvetica, sans-serif;
}
/* Make content area take remaining vertical space so nav sticks to bottom */
#chapter-content {
    flex: 1 1 auto;
}

.chapter {
    /* display: none; */
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    text-align: left;    
}

.chapter.active {
    /* display: block; */
    opacity: 1;
    pointer-events: auto;
    /* animation: fadeIn 0.5s ease; */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chapter h3 {
    font-size: 28px;
    margin-bottom: 20px;
    color: inherit;
    position: relative;
    padding-bottom: 10px;
    background: none;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: initial;
    text-shadow: none;
}

.chapter h3::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 60px;
    height: 2px;
    background: linear-gradient(90deg, #6366f1, transparent);
}

.chapter h4 {
    font-size: 22px;
    margin: 25px 0 15px;
    color: #e2e8f0;
}

.chapter p {
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

.reading-progress {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #a5b4fc);
    z-index: 10;
    transition: width 0.2s ease;
}

.nav-button {
    padding: 8px 16px;
    background: rgba(99, 102, 241, 0.2);
    color: #e2e8f0;
    border: 1px solid #6366f1;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    justify-content: center;
    font-size: 14px;
}

.nav-button:hover {
    background: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.nav-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.back-button {
    display: inline-block;
    padding: 10px 20px;
    margin-top: 20px;
    background: rgba(99, 102, 241, 0.2);
    color: #e2e8f0;
    border: 1px solid #6366f1;
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.back-button:hover {
    background: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

@media (max-width: 768px) {
    body {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
        overflow-x: hidden;
    }

    .detail-page .main-container {
        width: 96%;
        max-width: 96vw;
        margin: 10px auto;
        padding: 15px;
        border: 1px solid rgba(99, 102, 241, 0.3);
        border-radius: 12px;
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(10px);
        overflow-x: hidden;
        box-sizing: border-box;
    }

    .book-detail { padding: 5px; }
    
    .content-container { flex-direction: column; width: 100%; gap: 16px; }
    
    .table-of-contents { width: 100%; margin-bottom: 12px; height: auto; position: relative; top: 0; }
    
    .chapter-content { max-height: none; width: 100%; padding: 16px; margin: 0; scroll-margin-top: 20px; }
    
    .book-info h2 {
        font-size: 24px;
    }
    
    .chapter h3 {
        font-size: 24px;
    }
    
    .chapter h4 {
        font-size: 20px;
    }
}

@media (min-width: 1600px) {
    .table-of-contents {
        width: 320px;
        font-size: 16px;
    }
    
    .book-icon {
        width: 100px;
        height: 100px;
    }
    
    .book-info h2 {
        font-size: 36px;
    }
    
    .chapter h3 {
        font-size: 32px;
    }
    
    .chapter h4 {
        font-size: 24px;
    }
}

/* --- TOC LEVEL STYLES (giống admin/edit-book) --- */
.toc-item.level-0 {
    font-size: 1.15em;
    font-weight: 600;
    padding-left: 0px;
}
.toc-item.level-1 {
    font-size: 1.15em;
    font-weight: 600;
    padding-left: 0px;
}
.toc-item.level-2 {
    font-size: 1em;
    font-weight: 600;
    padding-left: 10px;
}
.toc-item.level-3 {
    font-size: 0.95em;
    font-weight: 500;
    font-style: italic;
    padding-left: 20px;
}
.toc-item.level-4 {
    font-size: 0.9em;
    font-weight: 500;
    padding-left: 20px;
}
.toc-item.level-5 {
    font-size: 0.9em !important;
    font-weight: 400;
    padding-left: 20px;
}
.toc-item.level-6 {
    font-size: 0.9em !important;
    font-weight: 350;
    padding-left: 10px;
}
/* CSS di chuyển từ views/detail.ejs */
.toc-item-header {
    display: flex;
    align-items: flex-start;
}

/* Tooltip content from editor */
#chapter-content .custom-tooltip {
    border-bottom: 1px dotted #3b82f6;
    color: #2563eb;
    cursor: help;
    position: relative;
    text-decoration: none;
}
#chapter-content .custom-tooltip:hover::after,
#chapter-content .custom-tooltip[data-open="1"]::after {
    content: attr(data-title);
    position: absolute;
    left: 0;
    bottom: 100%;
    background: rgba(30, 41, 59, 0.95);
    color: #e5e7eb;
    padding: 10px 14px;
    border-radius: 6px;
    white-space: pre-line;
    display: block;
    text-align: left;
    line-height: 1.6;
    overflow-wrap: anywhere;
    transform: translateY(-6px);
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 10;
}
.expand-toggle {
    display: inline-flex;
    align-items: flex-start;
    justify-content: center;
    width: 20px;
    height: 1.4em;
    margin-top: 2px;
    margin-right: 2px;
    cursor: pointer;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.toc-chapter {
    display: inline-block;
    vertical-align: top;
    line-height: 1.4;
    word-break: break-word;
}
.chapter-content {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
}
.font-size-controls {
    margin-bottom: 10px;
    text-align: right;
}
#decrease-font, #increase-font {
    font-size: 1.1em;
}
#increase-font {
    font-size: 1.2em;
}
.search-result-content {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
    word-break: break-word;
    display: block;
    max-width: 100%;
}
.search-result-item:hover {
    cursor: pointer;
}

.chapter-content .chapter-navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: auto;
    margin-bottom: 0;
    padding-top: 20px;
}

.share-container {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 12px;
    padding-top: 8px;
}

.desktop-copy-btn,
.mobile-share-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid rgba(148, 163, 184, 0.45);
    background: rgba(15, 23, 42, 0.52);
    color: #e2e8f0;
    border-radius: 8px;
    padding: 6px 10px;
    min-height: 34px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    box-shadow: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.desktop-copy-btn:hover,
.mobile-share-trigger:hover {
    border-color: rgba(148, 163, 184, 0.7);
    background: rgba(15, 23, 42, 0.68);
    color: #e2e8f0;
}

.desktop-copy-btn:active,
.mobile-share-trigger:active {
    background: rgba(15, 23, 42, 0.36);
}

.desktop-copy-btn:focus-visible,
.mobile-share-trigger:focus-visible {
    outline: none;
    border-color: rgba(99, 102, 241, 0.85);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.22);
}

.desktop-copy-btn i,
.mobile-share-trigger i {
    color: #cbd5e1;
    font-size: 13px;
}

.desktop-copy-btn:hover i,
.mobile-share-trigger:hover i {
    color: #f8fafc;
}

.chapter-content.light-theme .desktop-copy-btn,
.chapter-content.light-theme .mobile-share-trigger {
    border-color: rgba(148, 163, 184, 0.55);
    background: #e2e8f0;
    color: #334155;
}

.chapter-content.light-theme .desktop-copy-btn i,
.chapter-content.light-theme .mobile-share-trigger i {
    color: #475569;
}

.chapter-content.light-theme .desktop-copy-btn:hover,
.chapter-content.light-theme .mobile-share-trigger:hover {
    border-color: rgba(100, 116, 139, 0.65);
    background: #cbd5e1;
    color: #1e293b;
}

.chapter-content.light-theme .desktop-copy-btn:hover i,
.chapter-content.light-theme .mobile-share-trigger:hover i {
    color: #334155;
}

.mobile-share-trigger {
    display: none;
}

/* Toast thông báo copy thành công */
.copy-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: #10b981;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.copy-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

@media (max-width: 768px) {
    .desktop-copy-btn {
        display: none;
    }

    .mobile-share-trigger {
        display: inline-flex;
        min-width: auto;
    }

    .share-container {
        justify-content: flex-end;
        margin-top: 10px;
        padding-top: 8px;
        border-top: none;
    }
}

span[title] {
    border-bottom: 1px dotted #6366f1;
    color: #3b82f6;
    cursor: help;
    transition: color 0.2s;
    text-decoration: none;
    font-size: inherit !important;
}
span[title]:hover {
    color: #1e293b;
    background: #e0e7ff;
}

span[data-tooltip] {
    border-bottom: 1px dotted #6366f1;
    color: #3b82f6;
    cursor: help;
    transition: color 0.2s;
    text-decoration: none;
    font-size: inherit !important;
    position: relative;
}
span[data-tooltip]:hover::after,
span[data-tooltip][data-open="1"]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.98);
    color: #e2e8f0;
    padding: 10px 16px;
    border-radius: 7px;
    white-space: pre-line;
    z-index: 10000;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    min-width: 360px;
    width: auto;
    max-width: min(960px, 90vw);
    box-sizing: border-box;
    display: block;
    text-align: left;
    line-height: 1.6;
    overflow-wrap: anywhere;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
    opacity: 1;
    pointer-events: none;
}
span[data-tooltip]:hover {
    color: #1e293b;
    background: #e0e7ff;
} 

/* Portal tooltip (rendered at body, never clipped) */
#tooltip-portal {
    position: fixed;
    left: 0;
    top: 0;
    display: none;
    z-index: 100000;
    background: rgba(15, 23, 42, 0.98);
    color: #e2e8f0;
    padding: 10px 16px;
    border-radius: 7px;
    white-space: pre-line;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    max-width: min(960px, 90vw);
    min-width: 160px;
    box-sizing: border-box;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
    line-height: 1.6;
    overflow-wrap: anywhere;
    pointer-events: none;
}
body.portal-tooltips span[data-tooltip]::after,
body.portal-tooltips .custom-tooltip::after {
    display: none !important;
}
/* Portal tooltip theme overrides for contrast */
body.portal-tooltip-dark #tooltip-portal {
    background: rgba(15, 23, 42, 0.98);
    color: #e2e8f0;
    border: 1px solid rgba(99,102,241,0.18);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
body.portal-tooltip-light #tooltip-portal {
    background: #f8fafc;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 12px rgba(180, 190, 220, 0.35);
}

.custom-tooltip {
    border-bottom: 1px dotted #6366f1;
    color: #3b82f6;
    cursor: help;
    transition: color 0.2s;
    text-decoration: none;
    font-size: inherit !important;
    position: relative;
}
.custom-tooltip:hover::after,
.custom-tooltip[data-open="1"]::after {
    content: attr(data-title);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.98);
    color: #e2e8f0;
    padding: 10px 16px;
    border-radius: 7px;
    white-space: pre-line;
    z-index: 10000;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    /*min-width: 160px;*/
    width: auto;
    max-width: min(960px, 90vw);
    box-sizing: border-box;
    display: block;
    text-align: left;
    line-height: 1.6;
    overflow-wrap: anywhere;
    box-shadow: 0 2px 12px rgba(0,0,0,0.18);
    opacity: 1;
    pointer-events: none;
}
.custom-tooltip:hover {
    color: #1e293b;
    background: #e0e7ff;
}

.chapter-content .ql-indent-1:not(.ql-direction-rtl) { padding-left: 3em; }
.chapter-content .ql-indent-1.ql-direction-rtl { padding-right: 3em; }
.chapter-content .ql-indent-2:not(.ql-direction-rtl) { padding-left: 6em; }
.chapter-content .ql-indent-2.ql-direction-rtl { padding-right: 6em; }
.chapter-content .ql-indent-3:not(.ql-direction-rtl) { padding-left: 9em; }
.chapter-content .ql-indent-3.ql-direction-rtl { padding-right: 9em; }
.chapter-content .ql-indent-4:not(.ql-direction-rtl) { padding-left: 12em; }
.chapter-content .ql-indent-4.ql-direction-rtl { padding-right: 12em; }
.chapter-content .ql-indent-5:not(.ql-direction-rtl) { padding-left: 15em; }
.chapter-content .ql-indent-5.ql-direction-rtl { padding-right: 15em; }
.chapter-content .ql-indent-6:not(.ql-direction-rtl) { padding-left: 18em; }
.chapter-content .ql-indent-6.ql-direction-rtl { padding-right: 18em; }
.chapter-content .ql-indent-7:not(.ql-direction-rtl) { padding-left: 21em; }
.chapter-content .ql-indent-7.ql-direction-rtl { padding-right: 21em; }
.chapter-content .ql-indent-8:not(.ql-direction-rtl) { padding-left: 24em; }
.chapter-content .ql-indent-8.ql-direction-rtl { padding-right: 24em; }
.chapter-content .ql-indent-9:not(.ql-direction-rtl) { padding-left: 27em; }
.chapter-content .ql-indent-9.ql-direction-rtl { padding-right: 27em; }
.chapter-content .ql-indent-10:not(.ql-direction-rtl) { padding-left: 30em; }
.chapter-content .ql-indent-10.ql-direction-rtl { padding-right: 30em; }
.ql-fraction { display: inline-flex; align-items: center; vertical-align: middle; line-height: 1.2; margin: 0 2px; }
.ql-frac-num { border-bottom: 1px solid currentColor; padding: 0 2px; text-align: center; font-size: 0.85em; white-space: nowrap; }
.ql-frac-den { padding: 0 2px; text-align: center; font-size: 0.85em; white-space: nowrap; }

/* Tooltip colors in light theme: use dark tooltip for contrast */
.chapter-content.light-theme span[data-tooltip]:hover::after,
.chapter-content.light-theme .custom-tooltip:hover::after,
.chapter-content.light-theme #chapter-content .custom-tooltip:hover::after {
    background: rgba(15, 23, 42, 0.98);
    color: #e5e7eb;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    border: 1px solid rgba(99,102,241,0.18);
}

/* Tooltip colors in dark theme: use light tooltip for contrast */
.chapter-content:not(.light-theme) span[data-tooltip]:hover::after,
.chapter-content:not(.light-theme) .custom-tooltip:hover::after,
.chapter-content:not(.light-theme) #chapter-content .custom-tooltip:hover::after {
    background: #f8fafc;
    color: #1f2937;
    box-shadow: 0 2px 12px rgba(180, 190, 220, 0.35);
    border: 1px solid #e5e7eb;
}

/* Heading color by theme */
.chapter-content.light-theme .chapter h3 {
    color: #0f172a;
}
.chapter-content:not(.light-theme) .chapter h3 {
    color: #e2e8f0;
}

/* Ensure headings inside chapter-content follow theme (Quill output) */
.chapter-content h1,
.chapter-content h2,
.chapter-content h3,
.chapter-content h4,
.chapter-content h5,
.chapter-content h6 {
    background: none;
    -webkit-text-fill-color: initial;
}
.chapter-content sup {
    font-size: 0.8em;
    line-height: 0;
    vertical-align: super;
}
.chapter-content sub {
    font-size: 0.8em;
    line-height: 0;
    vertical-align: sub;
}
.chapter-content.light-theme h1,
.chapter-content.light-theme h2,
.chapter-content.light-theme h3,
.chapter-content.light-theme h4,
.chapter-content.light-theme h5,
.chapter-content.light-theme h6 {
    color: #0f172a;
}
.chapter-content:not(.light-theme) h1,
.chapter-content:not(.light-theme) h2,
.chapter-content:not(.light-theme) h3,
.chapter-content:not(.light-theme) h4,
.chapter-content:not(.light-theme) h5,
.chapter-content:not(.light-theme) h6 {
    color: #e2e8f0;
}
