/* Triple-Column Reader Layout */
:root {
    --header-height: 70px;
    --sidebar-width: 320px;
    --chat-panel-width: 360px;
    --chat-panel-collapsed-width: 50px;
}

.reader-mode {
    background-color: var(--bg-primary);
    overflow-x: hidden;
}

/* ========================================
   Hamburger Menu Button Styles
   ======================================== */

/* Base hamburger - HIDDEN by default */
.header .mobile-nav-toggle {
    display: none !important;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: var(--toolbar-btn-radius, 50%);
    background: var(--hamburger-bg, var(--toolbar-btn-bg, var(--bg-secondary)));
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast, 0.2s);
    flex-shrink: 0;
}

.header .mobile-nav-toggle svg {
    stroke: var(--hamburger-icon-color, var(--toolbar-btn-color, var(--text-primary)));
    fill: var(--hamburger-icon-color, var(--toolbar-btn-color, var(--text-primary)));
}

.header .mobile-nav-toggle:hover {
    background: var(--hamburger-hover-bg, var(--toolbar-btn-hover-bg, var(--bg-tertiary)));
    transform: translateY(-2px);
}

.header .mobile-nav-toggle:hover svg {
    stroke: var(--hamburger-hover-icon-color, var(--toolbar-btn-hover-color, var(--color-primary)));
    fill: var(--hamburger-hover-icon-color, var(--toolbar-btn-hover-color, var(--color-primary)));
}

/* Show hamburger on MOBILE when enabled */
/* LOCKED: Mobile/tablet breakpoint is 965px — do NOT change without explicit consent */
@media (max-width: 964px) {
    .header .mobile-nav-toggle.show-mobile {
        display: flex !important;
    }
}

/* Show hamburger on TABLET when enabled */
/* LOCKED: Mobile/tablet breakpoint is 965px — do NOT change without explicit consent */
@media (min-width: 966px) and (max-width: 1024px) {
    .header .mobile-nav-toggle.show-tablet {
        display: flex !important;
    }
}

/* Show hamburger on DESKTOP when enabled */
@media (min-width: 1025px) {
    .header .mobile-nav-toggle.show-desktop {
        display: flex !important;
    }
}

/* Hamburger Position - LEFT */
.header.hamburger-left .mobile-nav-toggle {
    order: -1;
}

/* Hamburger Position - RIGHT */
.header.hamburger-right .mobile-nav-toggle {
    order: 99;
}

/* Header Styles */
.header {
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: relative;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: transform 0.3s ease, top 0.3s ease;
}

/* Auto-hide on scroll down */
.header.nav-hidden {
    transform: translateY(-100%);
}

/* Mobile actions panel auto-hide on scroll (same as header) */
.mobile-actions-panel.nav-hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

/* Sticky Header */
.header.header-sticky {
    position: fixed;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 var(--spacing-xl);
    gap: var(--spacing-md);
    position: relative;
}

/* Header Brand Section Positioning */
.header-brand-section {
    display: flex;
    align-items: center;
}

.header-brand-section.position-left {
    order: 0;
    margin-right: auto;
}

.header-brand-section.position-center {
    order: 1;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-brand-section.position-right {
    order: 2;
    margin-left: auto;
}

/* Header Actions Positioning */
.header-actions.position-left {
    order: 0;
    margin-right: auto;
}

.header-actions.position-center {
    order: 1;
    margin: 0 auto;
}

.header-actions.position-right {
    order: 2;
    margin-left: auto;
}

.logo {
    font-size: var(--font-size-xl);
    font-weight: 800;
    transition: transform var(--transition-normal);
}

/* Only apply default gradient if no inline style is set */
.logo:not([style]) {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo:hover {
    transform: scale(1.05);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--toolbar-gap-desktop, var(--spacing-md));
}

.header-actions button,
.header-actions .btn-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--toolbar-btn-radius, 50%) !important;
    background: var(--toolbar-btn-bg, var(--bg-secondary)) !important;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--toolbar-btn-color, var(--text-primary));
}

.header-actions button svg,
.header-actions .btn-icon svg {
    stroke: var(--toolbar-btn-color, var(--text-primary));
}

.header-actions button:hover,
.header-actions .btn-icon:hover {
    background: var(--toolbar-btn-hover-bg, var(--bg-tertiary));
    transform: translateY(-2px);
}

.header-actions button:hover svg,
.header-actions .btn-icon:hover svg {
    stroke: var(--toolbar-btn-hover-color, var(--color-primary));
}

/* Body Layout - FIXED 2025-01-28 */
.reader-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: var(--header-height);
    /* Default: add margin for sticky header */
    min-height: calc(100vh - var(--header-height));
    width: 100%;
    position: relative;
    background: transparent;
}

/* When header is NOT sticky, remove margin */
body:not(.has-sticky-header) .reader-body {
    margin-top: 0 !important;
    min-height: 100vh;
}

.reader-main {
    flex: 1;
    padding: var(--spacing-2xl) var(--spacing-xl);
    padding-top: var(--content-top-margin, var(--spacing-2xl));
    /* Use content-top-margin setting from admin, fallback to spacing-2xl */
    max-width: 786.5px;
    width: 786.5px;
    margin: 0 auto;
    position: relative;
}

@media (max-width: 850px) {
    .reader-main {
        width: 100%;
        max-width: 786.5px;
    }
}

aside.reader-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-inline-end: 1px solid var(--border-color);
    position: fixed !important;
    left: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 90;
    transition: transform 0.3s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
    margin: 0 !important;
    padding: 0 !important;
    /* Use CSS variable from UI settings - dynamically set per book */
    top: var(--header-height, 70px) !important;
    height: calc(100vh - var(--header-height, 70px)) !important;
    height: calc(100dvh - var(--header-height, 70px)) !important;
}

.rtl aside.reader-sidebar {
    left: auto;
    right: 0;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.08) !important;
}

/* Sidebar Components */
.sidebar-header {
    padding: 0;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: relative;
}

.sidebar-header.hide-search {
    padding-bottom: 0;
    border-bottom: none;
}

/* Mobile Close Button — subtle, industry-standard */
.sidebar-close-btn {
    display: flex;
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    z-index: 10;
}

.sidebar-close-btn svg {
    stroke: var(--text-secondary, #6b7280);
    width: 16px;
    height: 16px;
}

.sidebar-close-btn:hover {
    background: var(--bg-tertiary, rgba(0, 0, 0, 0.06));
}

.sidebar-close-btn:hover svg {
    stroke: var(--text-primary, #1f2937);
}

.sidebar-close-btn:active {
    background: var(--bg-tertiary, rgba(0, 0, 0, 0.1));
}

/* RTL: Move close button to left */
.rtl .sidebar-close-btn {
    right: auto;
    left: var(--spacing-md);
}

/* Sidebar search padding adjustment on mobile */
@media (max-width: 1024px) {
    .sidebar-search {
        padding-right: 50px;
    }
    
    .rtl .sidebar-search {
        padding-right: 0;
        padding-left: 50px;
    }
}

.sidebar-search {
    display: block;
    padding: 12px 16px;
}

.sidebar-search.hidden {
    display: none;
}

.sidebar-search input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-primary);
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.sidebar-search input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
}

.sidebar-toc {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 16px 32px;
    direction: ltr;
    background: var(--toc-bg-color, var(--bg-secondary));
    overscroll-behavior: contain;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
}

/* TOC Title */
.sidebar-toc-title {
    font-size: var(--toc-title-size, 0.85rem);
    font-weight: var(--toc-title-weight, 600);
    color: var(--toc-title-color, var(--text-secondary));
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 16px 0;
    padding-top: 16px; /* Breathing room at the top */
    padding-bottom: 8px;
    border-bottom: 2px solid var(--toc-title-border-color, var(--border-color));
}

.sidebar-toc-title.no-uppercase {
    text-transform: none;
    letter-spacing: normal;
}

/* LTR books - title should align left */
.ltr .sidebar-toc-title {
    text-align: left;
    direction: ltr;
}

/* RTL books - title should align right */
.rtl .sidebar-toc-title {
    text-align: right;
    direction: rtl;
}

/* Restore text direction inside */
.sidebar-toc .toc-list {
    direction: rtl;
}

.ltr .sidebar-toc {
    direction: ltr;
}

.ltr .sidebar-toc .toc-list {
    direction: ltr;
}

/* Custom scrollbar for sidebar - VISIBLE */
.sidebar-toc::-webkit-scrollbar {
    width: 8px;
}

.sidebar-toc::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0;
}

.sidebar-toc::-webkit-scrollbar-thumb {
    background: var(--toc-scrollbar-color, var(--border-color));
    border-radius: 4px;
}

.sidebar-toc::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* Show scrollbar for Firefox */
.sidebar-toc {
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: var(--toc-scrollbar-color, var(--border-color)) transparent;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-item {
    margin-bottom: var(--toc-item-spacing, var(--spacing-xs));
}

/* TOC Item Header - contains toggle and link */
.toc-item-header {
    display: flex;
    align-items: center;
    gap: 0;
}

/* Invisible spacer — same size as toggle button — keeps all siblings aligned */
.toc-toggle-spacer {
    display: inline-block;
    width: 32px;
    height: 32px;
    margin-inline-end: 4px;
    flex-shrink: 0;
}

/* Dropdown Toggle Button */
.toc-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    margin: 0;
    margin-inline-end: 4px;
    background: var(--bg-tertiary, rgba(0, 0, 0, 0.05));
    border: 1px solid var(--toc-border-color, var(--border-color, #ddd));
    cursor: pointer;
    color: var(--toc-toggle-color, var(--text-secondary));
    border-radius: var(--radius-sm, 4px);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.toc-toggle:hover {
    background: var(--bg-secondary);
    color: var(--color-primary);
    border-color: var(--color-primary);
}

/* Toggle color when chapter is active */
.toc-item.active .toc-toggle {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.toc-toggle-icon {
    transition: transform 0.3s ease;
}

/* Rotate arrow when expanded */
.toc-toggle[aria-expanded="true"] .toc-toggle-icon {
    transform: rotate(180deg);
}

/* RTL support for toggle */
.rtl .toc-toggle-icon {
    transform: rotate(0deg);
}

.rtl .toc-toggle[aria-expanded="true"] .toc-toggle-icon {
    transform: rotate(180deg);
}

.toc-link {
    display: flex;
    align-items: center;
    padding: var(--spacing-md);
    text-decoration: none;
    color: var(--toc-item-color, var(--text-secondary));
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    font-size: var(--toc-item-font-size, var(--font-size-sm));
    font-weight: 500;
    flex: 1;
}

.toc-link:hover {
    background: var(--toc-item-hover-bg, var(--bg-tertiary));
    color: var(--toc-item-hover-color, var(--text-primary));
    padding-inline-start: var(--spacing-lg);
}

.toc-link.active {
    background: var(--toc-active-bg, var(--color-primary));
    color: var(--toc-active-color, white);
    box-shadow: 0 4px 12px rgba(var(--color-primary-rgb), 0.3);
}

.toc-progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-gray-300);
    margin-inline-end: var(--spacing-md);
    flex-shrink: 0;
    transition: all 0.2s;
}

/* Hide bullet dots on all TOC items — use indentation for hierarchy */
.toc-progress-dot {
    display: none;
}

/* Keep dot visible on active item only */
.toc-link.active .toc-progress-dot {
    background: white;
    transform: scale(1.2);
}

/* Section Infusion (Sub-Navigation) */
.toc-sublist {
    margin: 0;
    padding: 0;
    padding-inline-start: var(--spacing-2xl);
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease;
    opacity: 0;
}

/* Show sublist when expanded */
.toc-sublist.expanded {
    max-height: 2000px;
    margin-top: 5px;
    opacity: 1;
}

.toc-sublink {
    display: block;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 13px;
    color: var(--toc-item-color, var(--text-muted));
    border-inline-start: 1px solid var(--toc-subitem-border-color, var(--border-color));
    transition: all 0.2s;
}

.toc-sublink:hover {
    background: var(--toc-item-hover-bg, var(--bg-tertiary));
    color: var(--toc-item-hover-color, var(--color-primary));
    border-inline-start-color: var(--color-primary);
}

/* Active section sublink */
.toc-sublink.active {
    color: var(--color-primary);
    font-weight: 600;
    border-inline-start-color: var(--color-primary);
    border-inline-start-width: 2px;
}

/* TOC Two-Line: Chapter Number + Subtitle */
.toc-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.35;
    padding: 2px 0;
}

.toc-chapter-num {
    font-size: var(--toc-item-font-size, var(--font-size-sm));
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.toc-chapter-subtitle {
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.35;
    opacity: 0.65;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Group label above chapter num in TOC (compound titles like "BOOK II. — Chapter i. — ...") */
.toc-chapter-group {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.5;
    line-height: 1.3;
    margin-bottom: 1px;
}

.toc-title-wrap:hover .toc-chapter-subtitle {
    -webkit-line-clamp: unset;
    overflow: visible;
    opacity: 0.85;
}

.toc-link.active .toc-chapter-num {
    font-weight: 700;
}

.toc-link.active .toc-chapter-subtitle {
    font-weight: 500;
    opacity: 0.85;
}

.toc-sublink .toc-title-wrap {
    gap: 1px;
}

.toc-sublink .toc-chapter-num {
    font-size: 0.82rem;
}

.toc-sublink .toc-chapter-subtitle {
    font-size: 0.68rem;
}

/* RTL adjustments for TOC two-line */
[dir="rtl"] .toc-chapter-num {
    letter-spacing: 0;
}

/* Chapter Styles */
.chapter-content {
    background: var(--bg-primary);
}

.chapter-title {
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: var(--spacing-2xl);
    text-align: center;
    font-weight: 800;
}

@media (max-width: 965px) {
    .chapter-title {
        font-size: 1.5rem;
    }
}

/* Base content-body styles - only apply when accessibility font size is NOT set */
body:not([data-font-size]) .content-body {
    font-size: var(--font-size-lg);
    line-height: var(--line-height-relaxed);
    color: var(--text-primary);
}

/* When accessibility font size IS set, only apply color (not font-size/line-height) */
body[data-font-size] .content-body {
    color: var(--text-primary);
}

/* Content body: spacing after tables and blockquotes before paragraphs */
.content-body table + p,
.content-body table + h3,
.content-body blockquote + p,
.content-body blockquote + h3 {
    margin-top: 1.5em;
}

/* Content body: all heading levels should have proper spacing */
.content-body h3 {
    margin-top: 3em;
    margin-bottom: 1.2em;
}
.content-body h4 {
    margin-top: 2.5em;
    margin-bottom: 1em;
}
.content-body h5 {
    margin-top: 2em;
    margin-bottom: 0.8em;
}
.content-body h6 {
    margin-top: 1.5em;
    margin-bottom: 0.6em;
}
/* Ensure headings followed by paragraphs have a gap */
.content-body h3 + p,
.content-body h4 + p,
.content-body h5 + p,
.content-body h6 + p {
    margin-top: 1.2em;
}

/* Custom Drop Cap Support */
/* Custom Drop Cap & First Word Support */
/* Industry-standard drop cap styling based on traditional typography */
.styling-drop-cap p:first-of-type {
    overflow: visible;
}

.styling-drop-cap p:first-of-type::first-letter {
    float: var(--direction-start);
    font-size: var(--drop-cap-size, 3.5em);
    line-height: 0.65;
    font-weight: 700;
    color: var(--styling-color, var(--color-primary));
    padding: 0.05em 0.08em 0 0;
    margin: 0;
    font-family: var(--font-family-heading);
}

/* LTR-specific adjustments */
[dir="ltr"] .styling-drop-cap p:first-of-type::first-letter {
    padding-right: 0.08em;
    padding-left: 0;
}

/* RTL-specific adjustments */
[dir="rtl"] .styling-drop-cap p:first-of-type::first-letter {
    padding-left: 0.08em;
    padding-right: 0;
}

/* Arabic-friendly first word styling - floated like traditional Arabic books */
.first-word {
    font-size: var(--first-word-size, 1.65em);
    font-weight: bold;
    color: var(--styling-color, var(--accent-color));
    font-family: var(--font-headings);
    float: right;
    line-height: 1;
    margin-left: 0.3em;
    margin-bottom: 0.1em;
    margin-top: 0.75rem;
    /* Pushe down to sit between lines */
    padding: 0.1em 0 0.1em 0.1em;
    /* display: inline-block prevents ::first-letter from applying to parent p */
    display: inline-block;
}

.rtl .first-word {
    float: right;
    margin-left: 0.3em;
    margin-right: 0;
}

.ltr .first-word {
    float: left;
    margin-right: 0.3em;
    margin-left: 0;
}

/* Responsive */
/* LOCKED: Sidebar overlay behavior for tablet/mobile — do NOT modify without explicit consent */
@media (max-width: 1024px) {
    .header-content {
        padding: 0 var(--spacing-md);
    }

    .reader-body {
        flex-direction: column;
    }

    .reader-sidebar {
        transform: translateX(-100%);
        width: 85%;
        max-width: 400px;
        z-index: 1001 !important;
        /* Higher than header (1000) and audio player (500) on mobile */
    }

    .rtl .reader-sidebar {
        transform: translateX(100%);
    }

    .reader-sidebar.active {
        transform: translateX(0);
    }

    .reader-main {
        padding: var(--spacing-xl) var(--spacing-md);
        padding-top: var(--content-top-margin, var(--spacing-xl));
        /* Use content-top-margin setting from admin, fallback to spacing-xl on mobile */
    }
}

/* Mobile sidebar: use mobile header height for correct top positioning */
/* LOCKED: Fixes white row gap between header and sidebar on mobile — do NOT modify without explicit consent */
@media (max-width: 965px) {
    aside.reader-sidebar {
        top: var(--mobile-header-height, var(--header-height, 70px)) !important;
        height: calc(100vh - var(--mobile-header-height, var(--header-height, 70px))) !important;
        height: calc(100dvh - var(--mobile-header-height, var(--header-height, 70px))) !important;
    }

    .sidebar-overlay {
        top: var(--mobile-header-height, var(--header-height, 70px));
    }
}

/* When header is hidden (scrolled away), sidebar and overlay snap to top */
/* LOCKED: Ensures sidebar fills screen when header auto-hides — do NOT modify without explicit consent */
body.header-hidden aside.reader-sidebar {
    top: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    transition: top 0.3s ease, height 0.3s ease;
}

body.header-hidden .sidebar-overlay {
    top: 0;
}

/* Desktop sidebar toggle - when hamburger is shown on desktop */
@media (min-width: 1025px) {
    .reader-sidebar.sidebar-hidden {
        transform: translateX(-100%);
    }

    .rtl .reader-sidebar.sidebar-hidden {
        transform: translateX(100%);
    }

    /* Expand main content when sidebar is hidden */
    body:has(.reader-sidebar.sidebar-hidden) .reader-main {
        max-width: 1200px;
    }
}

/* Overlay for mobile when sidebar is open */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    /* Just below sidebar (1000) */
    opacity: 0;
    transition: opacity 0.3s ease;
}

@media (max-width: 1024px) {
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
}

/* Section Separators */
.section-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: var(--spacing-2xl) auto;
    width: 100%;
    max-width: 100%;
}

/* Style: Simple Line */
.section-separator.style-line::before {
    content: "";
    flex: 1;
    display: block;
    /* Ensure block display for flex child */
    min-width: 50px;
    /* Minimum width to force rendering */
    height: 1px;
    background-color: var(--separator-color, currentColor);
    margin: 0 var(--spacing-md);
}

/* Style: Star (Line -- * -- Line) */
.section-separator.style-star::before,
.section-separator.style-star::after {
    content: "";
    flex: 1;
    display: block;
    min-width: 50px;
    height: 1px;
    background-color: var(--separator-color, currentColor);
}

.section-separator.style-star::before {
    margin-inline-end: var(--spacing-md);
}

.section-separator.style-star::after {
    margin-inline-start: var(--spacing-md);
}

.section-separator-icon {
    font-size: 1.5rem;
    line-height: 1;
    font-weight: bold;
}

/* Style: Diamond */
.section-separator.style-diamond::before,
.section-separator.style-diamond::after {
    content: "";
    flex: 1;
    display: block;
    min-width: 50px;
    height: 1px;
    background-color: var(--separator-color, currentColor);
}

.section-separator.style-diamond .section-separator-icon {
    font-size: 1.2rem;
    transform: rotate(45deg);
    display: inline-block;
    padding: 0 10px;
}

/* Style: Flower/Ornament */
.section-separator.style-flower::before,
.section-separator.style-flower::after {
    content: "";
    flex: 1;
    display: block;
    min-width: 50px;
    height: 1px;
    border-top: 1px dashed var(--separator-color, currentColor);
}

.section-separator.style-flower .section-separator-icon {
    font-size: 1.8rem;
    padding: 0 15px;
}

/* Section Heading Underline Control */
.heading-with-underline {
    position: relative;
    display: inline-block;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--underline-color, #e74c3c);
    width: auto;
    /* Allow it to fit text or full width depending on look */
    min-width: 100px;
    /* Minimum width for short titles */
}

/* ========================================
   Header Branding Styles
   ======================================== */

/* Brand container base */
.header-brand {
    display: flex;
    align-items: center;
    gap: var(--spacing-md, 1rem);
    text-decoration: none;
    transition: transform var(--transition-fast, 0.2s), opacity var(--transition-fast, 0.2s);
    /* Ensure no background bleeds through */
    background: transparent;
}

.header-brand:hover {
    transform: scale(1.02);
    opacity: 0.9;
}

/* Text-only brand (uses existing .logo styles but enhanced) */
.header-brand-text {
    font-weight: 700;
    text-decoration: none;
    transition: transform var(--transition-normal, 0.3s);
}

/* Text-only brand with border support */
.header-brand-text.has-border {
    padding: 6px 12px;
    border: 2px solid var(--brand-border-color, #e74c3c);
    display: inline-block;
}

.header-brand-text.has-border.border-solid {
    border-style: solid;
    border-radius: var(--radius-sm, 4px);
}

.header-brand-text.has-border.border-rounded {
    border-style: solid;
    border-radius: var(--radius-lg, 12px);
}

.header-brand-text.has-border.border-pill {
    border-style: solid;
    border-radius: 50px;
    padding: 6px 16px;
}

.header-brand-text.has-border.border-glow {
    border-style: solid;
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 0 10px var(--brand-border-color, #e74c3c),
        0 0 20px var(--brand-border-color, #e74c3c),
        0 0 30px color-mix(in srgb, var(--brand-border-color, #e74c3c) 30%, transparent);
    animation: brand-glow-pulse 2s ease-in-out infinite alternate;
}

/* Cover image in brand */
.header-brand-cover {
    object-fit: cover;
    border-radius: var(--radius-sm, 4px);
    transition: transform var(--transition-fast, 0.2s);
    background: var(--bg-primary, #ffffff);
    /* Remove any dark borders from images */
    box-shadow: none;
    border: none;
}

.header-brand-cover-only .header-brand-cover {
    border-radius: var(--radius-md, 8px);
}

/* Brand title text */
.header-brand-title {
    font-weight: 700;
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 320px;
    line-height: 1.2;
    display: flex;
    flex-direction: column;
}

/* Individual title lines for advanced styling */
.header-brand-title .title-line1,
.header-brand-title .title-line2 {
    display: block;
    line-height: 1.15;
}

.header-brand-title .title-line1 {
    /* First line defaults - can be overridden by inline styles */
}

.header-brand-title .title-line2 {
    /* Second line defaults - can be overridden by inline styles */
}

/* Logo image */
.header-brand-logo-img {
    object-fit: contain;
}

/* Brand border/frame styles */
.header-brand.has-border {
    padding: 4px;
    border: 2px solid var(--brand-border-color, #e74c3c);
}

.header-brand.has-border.border-solid {
    border-style: solid;
    border-radius: var(--radius-sm, 4px);
}

.header-brand.has-border.border-rounded {
    border-style: solid;
    border-radius: var(--radius-lg, 12px);
}

.header-brand.has-border.border-pill {
    border-style: solid;
    border-radius: 50px;
    padding: 4px 12px;
}

.header-brand.has-border.border-glow {
    border-style: solid;
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 0 10px var(--brand-border-color, #e74c3c),
        0 0 20px var(--brand-border-color, #e74c3c),
        0 0 30px color-mix(in srgb, var(--brand-border-color, #e74c3c) 30%, transparent);
    animation: brand-glow-pulse 2s ease-in-out infinite alternate;
}

@keyframes brand-glow-pulse {
    from {
        box-shadow: 0 0 10px var(--brand-border-color, #e74c3c),
            0 0 20px var(--brand-border-color, #e74c3c);
    }

    to {
        box-shadow: 0 0 15px var(--brand-border-color, #e74c3c),
            0 0 30px var(--brand-border-color, #e74c3c),
            0 0 40px var(--brand-border-color, #e74c3c);
    }
}

/* ========================================
   Header Decoration Styles
   ======================================== */

/* Base header with decoration support */
.header {
    --header-border-color: var(--header-bottom-color, #e74c3c);
    --header-border-thickness: var(--header-bottom-thickness, 2px);
}

/* None - no bottom decoration */
.header.header-decoration-none {
    border-bottom: none;
}

/* Simple Line */
.header.header-decoration-line {
    border-bottom: var(--header-border-thickness) solid var(--header-border-color);
}

/* Gradient Line */
.header.header-decoration-gradient {
    border-bottom: none;
    /* Don't set position here - it breaks sticky header */
}

.header.header-decoration-gradient::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--header-border-thickness);
    background: linear-gradient(90deg,
            transparent 0%,
            var(--header-border-color) 20%,
            var(--header-border-color) 80%,
            transparent 100%);
}

/* Drop Shadow */
.header.header-decoration-shadow {
    border-bottom: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15),
        0 2px 4px var(--header-border-color);
}

/* Double Line */
.header.header-decoration-double {
    border-bottom: var(--header-border-thickness) double var(--header-border-color);
}

/* Responsive adjustments for brand */
/* LOCKED: Mobile/tablet breakpoint is 965px — do NOT change without explicit consent */
@media (max-width: 965px) {

    /* Mobile Header: Absolute positioning for hamburger and actions toggle */
    .header-content {
        position: relative;
        padding: 0 !important;
        display: flex !important;
        justify-content: center !important;
        width: 100%;
    }

    /* Hamburger menu - absolute left */
    #mobile-menu-toggle {
        position: absolute !important;
        left: -8px !important;
        /* Push to edge (counteract 12px padding - 4px visual gap) */
        top: 50%;
        transform: translateY(-50%);
        z-index: 10;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        color: #ffffff !important;
        width: 40px !important;
        height: 40px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Force icon color to white for hamburger */
    #mobile-menu-toggle svg {
        stroke: #ffffff !important;
        fill: transparent !important;
        /* Ensure fill doesn't turn black if used */
        color: #ffffff !important;
    }

    /* Actions toggle - absolute right - MULTIPLE SELECTORS FOR SPECIFICITY */
    #mobile-actions-toggle,
    button#mobile-actions-toggle,
    .mobile-actions-toggle,
    .header-slot-right .mobile-actions-toggle,
    .header-slot-right #mobile-actions-toggle {
        position: absolute !important;
        right: -8px !important;
        /* Push to edge (counteract 12px padding) */
        left: auto !important;
        /* Override any left positioning */
        top: 50%;
        transform: translateY(-50%);
        z-index: 10;
        margin-right: 0 !important;
        /* Remove any margin */
    }

    /* RTL Support for Mobile Header */
    /* Swap toggle positions: Hamburger Right, Actions Left */
    html[dir="rtl"] #mobile-menu-toggle,
    body.rtl #mobile-menu-toggle {
        left: auto !important;
        right: -8px !important;
    }

    html[dir="rtl"] .mobile-actions-toggle,
    html[dir="rtl"] #mobile-actions-toggle,
    body.rtl .mobile-actions-toggle,
    body.rtl #mobile-actions-toggle {
        right: auto !important;
        left: -8px !important;
    }

    /* Center brand section - add padding to avoid overlap with absolute buttons */
    .header-slot-center,
    .header-brand-section {
        padding: 0 60px;
        /* Space for absolute buttons on both sides */
        justify-content: center;
    }

    .header-brand-title,
    .header-brand-text,
    .logo.header-brand-text {
        max-width: var(--mobile-brand-max-width, 280px);
        font-size: var(--mobile-brand-font-size, 0.9rem) !important;
        text-align: center !important;
    }

    .header-brand-cover {
        display: none !important;
    }

    .header-brand.has-border.border-pill {
        padding: 2px 8px;
    }

    /* Hide regular header actions on mobile */
    .header-actions {
        display: none !important;
    }

    /* Show mobile actions toggle */
    .mobile-actions-toggle {
        display: flex !important;
    }

    /* Mobile header height override */
    .header {
        height: var(--mobile-header-height, var(--header-height, 70px));
        padding: 0 var(--mobile-header-padding, 12px);
    }

    /* Hide brand on mobile if configured */
    .header.mobile-hide-brand .header-brand-section {
        display: none !important;
    }
}

/* Mobile actions toggle button - hidden on desktop */
.mobile-actions-toggle {
    display: none;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--toolbar-btn-radius, 50%);
    cursor: pointer;
    color: #ffffff !important;
    transition: all 0.2s;
}

.mobile-actions-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.mobile-actions-toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* ========================================
   MOBILE ACTIONS PANEL - INDUSTRY STANDARD
   ======================================== */

/* Base panel - hidden by default, positioned fixed */
.mobile-actions-panel {
    display: none;
    visibility: hidden;
    position: fixed;
    left: 0;
    right: 0;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md);
    padding-top: calc(var(--spacing-md) + 8px); /* Extra space for close button */
    z-index: 1001; /* Above header to stay visible when header hides */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
                top 0.3s ease; /* Smooth transition when header hides */
}

/* Close button - Industry standard top-right position */
.mobile-actions-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    z-index: 10;
}

.mobile-actions-close:hover {
    background: var(--bg-tertiary);
    color: var(--color-primary);
}

.mobile-actions-close svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* RTL: Move close button to left */
[dir="rtl"] .mobile-actions-close {
    right: auto;
    left: 8px;
}

/* Dropdown Style - Industry Standard (slides down from top) */
.mobile-actions-panel.mobile-actions-dropdown {
    top: 0; /* Always stick to top of viewport */
    transform: translateY(-100%);
    opacity: 0;
}

.mobile-actions-panel.mobile-actions-dropdown.active {
    transform: translateY(0);
    opacity: 1;
}

/* When header is visible, position below it */
body:not(.header-hidden) .mobile-actions-panel.mobile-actions-dropdown {
    top: var(--mobile-header-height, var(--header-height, 70px));
}

/* When header is hidden (scrolled up), stick to top */
body.header-hidden .mobile-actions-panel.mobile-actions-dropdown {
    top: 0;
}

/* Bottom Sheet Style - Material Design (slides up from bottom) */
.mobile-actions-panel.mobile-actions-bottom-sheet {
    top: auto;
    bottom: 0;
    border-top: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    opacity: 0;
    max-height: 60vh;
    overflow-y: auto;
}

.mobile-actions-panel.mobile-actions-bottom-sheet.active {
    transform: translateY(0);
    opacity: 1;
}

/* Inline Style - Always visible in header */
.mobile-actions-panel.mobile-actions-inline {
    position: static;
    display: flex;
    visibility: visible;
    opacity: 1;
    transform: none;
    border: none;
    box-shadow: none;
    padding: 0;
    background: transparent;
}

/* Mobile Actions Grid */
.mobile-actions-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--toolbar-gap-mobile, var(--spacing-sm, 0.5rem));
    flex-wrap: wrap;
}

.mobile-actions-panel.mobile-actions-inline .mobile-actions-grid {
    pointer-events: all;
}

/* Mobile Action Buttons */
.mobile-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px; /* iOS minimum touch target */
    height: 44px;
    border-radius: var(--toolbar-btn-radius, 50%);
    background: var(--toolbar-btn-bg, var(--bg-secondary));
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    text-decoration: none;
    color: var(--text-primary);
}

.mobile-action-btn:hover,
.mobile-action-btn:active {
    background: var(--toolbar-btn-hover-bg, var(--bg-tertiary));
    border-color: var(--color-primary);
    transform: scale(1.05);
}

.mobile-action-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--toolbar-btn-color, var(--text-primary));
    transition: stroke 0.2s;
}

.mobile-action-btn:hover svg {
    stroke: var(--toolbar-btn-hover-color, var(--color-primary));
}

/* Bookmark count badge */
.mobile-bookmark-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--color-primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    display: none;
}

.mobile-bookmark-count.has-bookmarks {
    display: block;
}

/* Actions divider */
.mobile-actions-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 var(--spacing-xs, 0.25rem);
}

/* Mobile: Show panel */
/* LOCKED: Mobile/tablet breakpoint is 965px — do NOT change without explicit consent */
@media (max-width: 965px) {
    .mobile-actions-panel {
        visibility: visible;
    }
    
    /* Dropdown and Bottom Sheet: show when active */
    .mobile-actions-panel.mobile-actions-dropdown.active,
    .mobile-actions-panel.mobile-actions-bottom-sheet.active {
        display: block;
    }
    
    /* Inline: always visible */
    .mobile-actions-panel.mobile-actions-inline {
        display: flex;
    }
}
    border-bottom: none;
    border-top: 2px solid var(--border-color);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    opacity: 0;
    z-index: 9999 !important;
    /* Ensure it's above everything */
}

.mobile-actions-panel.mobile-actions-bottom-sheet.active {
    transform: translateY(0) !important;
    opacity: 1 !important;
    z-index: 10000 !important;
    display: block !important;
}

/* Inline Style - always visible in header, no toggle needed */
.mobile-actions-panel.mobile-actions-inline {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height, 70px);
    border: none;
    box-shadow: none;
    padding: 0 var(--mobile-header-padding, 12px);
    transform: none;
    opacity: 1;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    background: transparent;
    z-index: 1001;
    /* Above header */
    pointer-events: none;
    /* Allow clicks to pass through to header */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

/* Inline style - hide on scroll (override transform: none) */
.mobile-actions-panel.mobile-actions-inline.nav-hidden {
    transform: translateY(-100%) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.mobile-actions-panel.mobile-actions-inline .mobile-actions-grid {
    pointer-events: all;
    /* Re-enable clicks on buttons */
    gap: var(--spacing-xs);
    padding-right: var(--spacing-sm);
    /* Add right padding to prevent touching edge */
}

.mobile-actions-panel.mobile-actions-inline .mobile-action-btn {
    width: var(--mobile-actions-btn-size, 40px);
    height: var(--mobile-actions-btn-size, 40px);
}

/* Ensure SVGs in mobile panel are always constrained */
.mobile-actions-panel svg {
    width: 20px !important;
    height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
}

.mobile-actions-panel .mobile-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--toolbar-btn-radius, 50%);
    cursor: pointer;
    color: var(--text-primary);
    text-decoration: none;
    width: var(--mobile-actions-btn-size, 40px);
    height: var(--mobile-actions-btn-size, 40px);
    transition: all 0.2s;
}

.mobile-actions-panel .mobile-action-btn:hover,
.mobile-actions-panel .mobile-action-btn:active {
    background: var(--bg-tertiary);
    border-color: var(--color-primary);
}

.mobile-actions-panel .mobile-action-btn svg {
    stroke: var(--text-primary);
}

.mobile-actions-panel .mobile-actions-grid {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--toolbar-gap-mobile, var(--spacing-sm));
    padding: 0;
}

.mobile-actions-divider {
    color: var(--border-color);
    font-size: 1.5rem;
    font-weight: 300;
    margin: 0 var(--spacing-xs);
}


/* Mobile: show panel when active */
/* LOCKED: Mobile/tablet breakpoint is 965px — do NOT change without explicit consent */
@media (max-width: 965px) {
    .mobile-actions-panel {
        visibility: visible !important;
    }

    /* Dropdown and Bottom Sheet: show when active */
    .mobile-actions-panel.mobile-actions-dropdown.active,
    .mobile-actions-panel.mobile-actions-bottom-sheet.active {
        display: block !important;
    }

    /* Inline: always visible, no toggle needed */
    .mobile-actions-panel.mobile-actions-inline {
        display: flex !important;
    }

    /* Hide toggle button when inline style is active */
    body:has(.mobile-actions-inline) .mobile-actions-toggle {
        display: none !important;
    }

    /* Clean action panel: no separators, tighter padding, close button nudged up */
    .mobile-actions-panel {
        padding-left: var(--spacing-xs, 0.25rem) !important;
        padding-right: var(--spacing-xs, 0.25rem) !important;
        padding-top: var(--spacing-sm, 0.5rem) !important;
    }

    .mobile-actions-panel .mobile-action-btn {
        border: none !important;
        background: transparent !important;
    }

    .mobile-actions-panel .mobile-action-btn:hover,
    .mobile-actions-panel .mobile-action-btn:active {
        background: var(--bg-tertiary) !important;
    }

    .mobile-actions-divider {
        display: none !important;
    }

    .mobile-actions-close {
        top: -2px !important;
        right: 4px !important;
        width: 24px !important;
        height: 24px !important;
    }

    .mobile-actions-close svg {
        width: 14px !important;
        height: 14px !important;
    }
}


/* ========================================
   Reader Footer Styles
   ======================================== */

.reader-footer {
    width: 100%;
    background: var(--footer-bg, #34495e);
    color: var(--footer-text, #ecf0f1);
    padding: var(--spacing-3xl) 0 0;
    margin-top: auto;
    position: relative;
    z-index: 1100;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-xl);
}

.footer-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-3xl);
    margin-bottom: var(--spacing-2xl);
}

.footer-column-title {
    color: var(--footer-title, #f39c12);
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
}

/* About Column */
.footer-about-text {
    font-size: var(--font-size-sm);
    line-height: 1.8;
    margin-bottom: var(--spacing-lg);
    color: var(--footer-text, #ecf0f1);
}

.footer-featured {
    margin-top: var(--spacing-lg);
    text-align: center;
}

.footer-separator {
    border: none;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--footer-link, #bdc3c7), transparent);
    margin: var(--spacing-xl) 0;
    opacity: 0.5;
}

.footer-featured a {
    display: inline-block;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.footer-featured a:hover {
    opacity: 0.9;
    transform: scale(1.02);
}

.footer-featured-label {
    font-size: var(--font-size-base);
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
    opacity: 0.9;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.footer-logo-container {
    display: inline-block;
    padding: var(--spacing-lg);
    transition: all var(--transition-normal);
}

/* Frame Styles */
.footer-logo-frame-solid {
    border: 3px solid;
    border-color: var(--frame-color, #f39c12);
    border-radius: var(--radius-md);
}

.footer-logo-frame-gradient {
    border: 3px solid transparent;
    background: linear-gradient(var(--footer-bg, #34495e), var(--footer-bg, #34495e)) padding-box,
        linear-gradient(135deg, var(--gradient-start, #f39c12), var(--gradient-end, #e74c3c)) border-box;
    border-radius: var(--radius-md);
}

.footer-logo-frame-double {
    border: 3px double;
    border-color: var(--frame-color, #f39c12);
    border-radius: var(--radius-md);
}

.footer-logo-frame-dashed {
    border: 3px dashed;
    border-color: var(--frame-color, #f39c12);
    border-radius: var(--radius-md);
}

.footer-logo-frame-dotted {
    border: 3px dotted;
    border-color: var(--frame-color, #f39c12);
    border-radius: var(--radius-md);
}

.footer-logo-frame-glow {
    border-radius: var(--radius-md);
    box-shadow: 0 0 20px var(--frame-color, #f39c12),
        0 0 40px var(--frame-color, #f39c12);
}

.footer-logo-frame-shadow {
    border-radius: var(--radius-md);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3),
        0 0 0 1px var(--frame-color, #f39c12);
}

.footer-logo-container a {
    display: inline-block;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.footer-logo-container a:hover {
    transform: scale(1.05) translateY(-2px);
    filter: brightness(1.1);
}

.footer-logo-container a:hover .footer-logo {
    animation: logo-pulse 0.6s ease-in-out;
}

@keyframes logo-pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.03);
    }
}

.footer-logo {
    max-width: 180px;
    max-height: 120px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease;
}

/* Contents Column */
.footer-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-nav-list li {
    margin-bottom: var(--spacing-sm);
}

.footer-nav-list a {
    color: var(--footer-link, #bdc3c7);
    text-decoration: none;
    font-size: var(--font-size-sm);
    transition: color var(--transition-fast);
    display: inline-block;
}

.footer-nav-list a:hover {
    color: var(--footer-link-hover, #f39c12);
}

/* Discovery Mode */
.footer-discover-section {
    margin-bottom: 16px;
}
.footer-discover-section:last-child {
    margin-bottom: 0;
}
.footer-discover-label {
    display: block;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--footer-title, #f39c12);
    opacity: 0.7;
    margin-bottom: 8px;
    font-weight: 700;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.footer-discover-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    margin: 0 -8px;
    text-decoration: none;
    color: var(--footer-link, #bdc3c7);
    font-size: 0.82rem;
    line-height: 1.35;
    transition: background 0.2s, color 0.2s;
    border-radius: 6px;
}
.reader-footer .footer-discover-item:hover,
.reader-footer .footer-discover-item:hover .footer-discover-title {
    color: var(--footer-link-hover, #f39c12) !important;
    background: rgba(255,255,255,0.04);
}
.reader-footer .footer-discover-item:hover .footer-discover-thumb {
    transform: scale(1.05);
}
.footer-discover-thumb {
    width: 40px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    transition: transform 0.2s;
}
.footer-discover-title {
    flex: 1;
    min-width: 0;
}

/* Mobile: bigger thumbnails, full titles */
@media (max-width: 768px) {
    .footer-discover-item {
        gap: 12px;
        padding: 8px;
    }
    .footer-discover-thumb {
        width: 48px;
        height: 68px;
        border-radius: 5px;
    }
    .footer-discover-title {
        font-size: 0.9rem;
    }
    .footer-discover-section {
        margin-bottom: 18px;
    }
    .footer-discover-label {
        font-size: 0.72rem;
        margin-bottom: 8px;
    }
}

/* Contact Column */
.footer-contact-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.footer-input,
.footer-textarea,
.footer-select {
    width: 100%;
    padding: var(--spacing-md);
    background: var(--footer-form-bg, rgba(255, 255, 255, 0.1));
    border: 1px solid var(--footer-form-border, rgba(255, 255, 255, 0.2));
    border-radius: var(--radius-md);
    color: var(--footer-form-text, #ffffff);
    font-size: var(--font-size-sm);
    font-family: inherit;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.footer-select {
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.6)' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--spacing-md) center;
    padding-right: calc(var(--spacing-md) + 24px);
}

[dir="rtl"] .footer-select {
    background-position: left var(--spacing-md) center;
    padding-right: var(--spacing-md);
    padding-left: calc(var(--spacing-md) + 24px);
}

.footer-select option {
    background: var(--bg-primary, #1a1a2e);
    color: var(--text-primary, #ffffff);
}

.footer-input::placeholder,
.footer-textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.footer-input:focus,
.footer-textarea:focus,
.footer-select:focus {
    outline: none;
    border-color: var(--footer-title, #f39c12);
    background: var(--footer-form-bg, rgba(255, 255, 255, 0.15));
}

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

.footer-submit-btn {
    padding: var(--spacing-md) var(--spacing-xl);
    background: var(--footer-btn-bg, #f39c12);
    color: var(--footer-btn-text, #ffffff);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.footer-submit-btn:hover {
    background: var(--footer-btn-hover-bg, #e67e22);
    transform: translateY(-2px);
}

.footer-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Form Messages */
.form-message {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    text-align: center;
}

.form-success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.form-error {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Copyright Bar */
.footer-copyright {
    background: var(--footer-copyright-bg, rgba(0, 0, 0, 0.2));
    padding: var(--spacing-lg) 0;
    text-align: center;
    margin-top: var(--spacing-2xl);
    width: 100%;
}

.footer-copyright p {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--footer-text, #ecf0f1);
}

.footer-copyright a {
    color: var(--footer-link-hover, #f39c12);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    position: relative;
}

.footer-copyright a:hover {
    color: #ffffff;
    text-shadow: 0 0 10px var(--footer-link-hover, #f39c12),
        0 0 20px var(--footer-link-hover, #f39c12);
}

/* Responsive Footer */
@media (max-width: 1024px) {
    .footer-columns {
        grid-template-columns: 1fr;
        gap: var(--spacing-2xl);
    }

    .footer-column {
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    /* Make contact form wider on mobile */
    .footer-contact-form {
        max-width: 100%;
        width: 100%;
    }

    .footer-input,
    .footer-textarea,
    .footer-select {
        font-size: 16px;
        padding: 1rem;
        width: 100%;
        box-sizing: border-box;
    }

    .footer-textarea {
        min-height: 140px;
    }
}

/* LOCKED: Mobile/tablet breakpoint is 965px — do NOT change without explicit consent */
@media (max-width: 965px) {
    .footer-content {
        padding: 0 var(--spacing-md);
    }

    .footer-logo {
        max-width: 150px;
        max-height: 100px;
    }

    /* Ensure form takes full width on small mobile */
    .footer-column {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    .footer-contact-form {
        width: 100%;
    }

    .footer-input,
    .footer-textarea,
    .footer-select {
        font-size: 16px;
        width: 100%;
        box-sizing: border-box;
    }
}


/* ========================================
   MOBILE CHAT INTEGRATION
   ======================================== */

/* When chat is open on mobile, prevent body scroll */
/* LOCKED: Mobile/tablet breakpoint is 965px — do NOT change without explicit consent */
@media (max-width: 965px) {
    body.chat-open {
        overflow: hidden;
    }

    /* Ensure reader content is accessible when chat is collapsed */
    .reader-main {
        padding-bottom: 80px;
        /* Space for FAB */
    }

    /* Adjust footer to not overlap with chat FAB */
    .reader-footer {
        padding-bottom: 80px;
    }
}

/* Chat panel overlay for mobile */
.chat-panel-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1999;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.chat-panel-overlay.active {
    display: block;
    opacity: 1;
}

/* Hide overlay on desktop */
@media (min-width: 769px) {
    .chat-panel-overlay {
        display: none !important;
    }
}

/* Ensure chat panel is always visible (not hidden by reader-layout rules) */
.chat-panel {
    display: flex !important;
    visibility: visible !important;
    z-index: 110 !important;
    /* Above progress bar (100), below header (1000) */
}

.chat-panel.collapsed {
    display: flex !important;
    visibility: visible !important;
    z-index: 110 !important;
}

/* Ensure mobile FAB and expanded panel are above overlay */
/* LOCKED: Mobile/tablet breakpoint is 965px — do NOT change without explicit consent */
@media (max-width: 965px) {
    .chat-panel {
        z-index: 2000 !important;
    }

    .chat-panel.collapsed {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        z-index: 2000 !important;
    }
}


/* ========================================
   CHAPTER NAVIGATION BUTTONS
   ======================================== */

.chapter-navigation {
    margin-top: var(--spacing-3xl);
    padding-top: var(--spacing-2xl);
    border-top: 1px solid var(--border-color);
}

.chapter-nav-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-lg);
    flex-wrap: wrap;
}

.chapter-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    font-size: var(--font-size-base);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 160px;
    text-align: center;

    /* Use CSS variables for theming */
    background: var(--nav-button-bg-color, #f39c12);
    color: var(--nav-button-text-color, #ffffff);
    border-radius: var(--nav-button-border-radius, 50px);
    border: none;
}

/* Gradient style override */
.chapter-nav-btn.gradient-style {
    background: linear-gradient(135deg, var(--nav-button-bg-color, #f39c12), var(--nav-button-bg-color-dark, #e67e22));
}

/* Solid style override */
.chapter-nav-btn.solid-style {
    background: var(--nav-button-bg-color, #f39c12);
}

/* Outline style override */
.chapter-nav-btn.outline-style {
    background: transparent;
    border: 2px solid var(--nav-button-bg-color, #f39c12);
    color: var(--nav-button-text-color, #ffffff);
}

.chapter-nav-btn {
    position: relative;
    overflow: hidden;
}

.chapter-nav-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    pointer-events: none;
    border-radius: inherit;
}

.chapter-nav-btn:hover::after {
    background: rgba(0, 0, 0, 0.12);
}

.chapter-nav-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    color: var(--nav-button-text-color, #ffffff) !important;
}

.chapter-nav-btn:active {
    transform: translateY(-1px);
}

/* RTL Support */
[dir="rtl"] .chapter-nav-buttons {
    flex-direction: row;
}

/* Responsive */
/* LOCKED: Mobile/tablet breakpoint is 965px — do NOT change without explicit consent */
@media (max-width: 965px) {
    .chapter-nav-buttons {
        flex-direction: column;
        gap: var(--spacing-md);
    }

    .chapter-nav-btn {
        width: 100%;
        max-width: 300px;
    }

    [dir="rtl"] .chapter-nav-buttons {
        flex-direction: column;
    }
}


/* ============================================
   DARK MODE OVERRIDES FOR TOC AND SIDEBAR
   ============================================ */

[data-theme="dark"] .reader-sidebar {
    background: var(--bg-primary, #1a1a1a);
    border-inline-end-color: var(--border-color, #333);
}

[data-theme="dark"] .sidebar-header {
    background: var(--bg-primary, #1a1a1a);
    border-bottom-color: var(--border-color, #333);
}

[data-theme="dark"] .sidebar-close-btn svg {
    stroke: var(--text-secondary, #9ca3af);
}

[data-theme="dark"] .sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .sidebar-close-btn:hover svg {
    stroke: var(--text-primary, #e0e0e0);
}

[data-theme="dark"] .sidebar-search input {
    background: var(--bg-secondary, #2a2a2a);
    border-color: var(--border-color, #444);
    color: var(--text-primary, #e0e0e0);
}

[data-theme="dark"] .sidebar-search input::placeholder {
    color: var(--text-muted, #888);
}

[data-theme="dark"] .sidebar-toc {
    background: var(--bg-primary, #1a1a1a);
}

[data-theme="dark"] .sidebar-toc-title {
    color: var(--text-primary, #e0e0e0);
}

[data-theme="dark"] .toc-link {
    color: var(--text-secondary, #b0b0b0);
}

[data-theme="dark"] .toc-link:hover {
    background: var(--bg-tertiary, #333);
    color: var(--text-primary, #fff);
}

[data-theme="dark"] .toc-link.active {
    background: var(--color-primary);
    color: white;
}

[data-theme="dark"] .toc-toggle {
    color: var(--text-secondary, #b0b0b0);
    border-color: var(--border-color, #444);
}

[data-theme="dark"] .toc-toggle:hover {
    background: var(--bg-secondary, #2a2a2a);
    color: var(--color-primary);
}

[data-theme="dark"] .toc-item.active .toc-toggle {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

[data-theme="dark"] .toc-progress-dot {
    background: var(--color-gray-600, #555);
}

[data-theme="dark"] .toc-sublink {
    color: var(--text-muted, #888);
    border-inline-start-color: var(--border-color, #444);
}

[data-theme="dark"] .toc-sublink:hover {
    background: var(--toc-item-hover-bg, var(--bg-tertiary, #333));
    color: var(--toc-item-hover-color, var(--color-primary));
    border-inline-start-color: var(--color-primary);
}

[data-theme="dark"] .sidebar-toc::-webkit-scrollbar-track {
    background: transparent;
}

[data-theme="dark"] .sidebar-toc::-webkit-scrollbar-thumb {
    background: var(--border-color, #444);
}

[data-theme="dark"] .sidebar-toc::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* Sepia Mode Overrides */
[data-theme="sepia"] .reader-sidebar {
    background: var(--bg-primary, #f4ecd8);
    border-inline-end-color: var(--border-color, #d4c4a8);
}

[data-theme="sepia"] .sidebar-header {
    background: var(--bg-primary, #f4ecd8);
    border-bottom-color: var(--border-color, #d4c4a8);
}

[data-theme="sepia"] .sidebar-toc {
    background: var(--bg-primary, #f4ecd8);
}

/* High Contrast Mode Overrides */
[data-theme="high-contrast"] .reader-sidebar {
    background: white;
    border-inline-end: 2px solid black;
}

[data-theme="high-contrast"] .sidebar-header {
    background: white;
    border-bottom: 2px solid black;
}

[data-theme="high-contrast"] .sidebar-toc {
    background: white;
}

[data-theme="high-contrast"] .toc-link {
    color: black;
}

[data-theme="high-contrast"] .toc-link:hover {
    background: #ffff00;
    color: black;
}

[data-theme="high-contrast"] .toc-link.active {
    background: black;
    color: white;
    border: 2px solid black;
}


/* ========================================
   CRITICAL LAYOUT FIXES
   ======================================== */

/* Fix 1: Ensure chatbot is always visible */
.chat-panel {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.chat-panel.collapsed {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* On mobile, chat panel must be above the overlay (z-index 1999) */
@media (max-width: 965px) {
    .chat-panel {
        z-index: 2000 !important;
    }
    .chat-panel.collapsed {
        z-index: 2000 !important;
    }
}

.chat-panel.collapsed .chat-collapse-bar {
    display: flex !important;
    visibility: visible !important;
}

/* Fix 2: Ensure TOC sidebar is visible */
.reader-sidebar {
    display: flex !important;
    visibility: visible !important;
}

.reader-sidebar.active {
    display: flex !important;
    visibility: visible !important;
    transform: translateX(0) !important;
}

/* Fix 3: Ensure TOC content is visible */
.sidebar-toc {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.toc-list {
    display: block !important;
    visibility: visible !important;
}

/* ========================================
   CHAPTER BOOKMARK ICON (next to H1)
   ======================================== */

/* Group label shown above chapter title for compound titles (e.g. "BOOK II. — ...") */
.chapter-group-label {
    width: 100%;
    text-align: center;
    font-size: 0.78em;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary, #888);
    margin-bottom: 0.4em;
    opacity: 0.75;
}

.chapter-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm, 8px);
    position: relative;
}

.chapter-title-row .chapter-title {
    margin-bottom: var(--spacing-2xl);
}

.chapter-bookmark-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    color: var(--text-secondary, #888);
    transition: color 0.2s, transform 0.2s;
    flex-shrink: 0;
    margin-top: 0.15em;
    line-height: 1;
}

.chapter-bookmark-btn:hover {
    color: var(--color-primary, #f39c12);
    transform: scale(1.15);
}

.chapter-bookmark-btn.bookmarked {
    color: var(--color-primary, #f39c12);
}

.chapter-bookmark-btn.bookmarked .bookmark-icon-outline {
    display: none;
}

.chapter-bookmark-btn.bookmarked .bookmark-icon-filled {
    display: block !important;
}

/* ========================================
   STORYBOOK CREATE BUTTON (children's genre)
   ======================================== */
.storybook-create-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(145deg, #e8860a, #d4690a, #c2570a);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 5px 14px 5px 8px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, filter 0.2s;
    flex-shrink: 0;
    margin-top: 0.15em;
    line-height: 1.3;
    white-space: nowrap;
    box-shadow: 0 3px 12px rgba(180, 80, 0, 0.35), inset 0 1px 0 rgba(255,255,255,0.15);
    font-family: var(--font-family-arabic, inherit);
    letter-spacing: 0.02em;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.storybook-btn-label {
    text-align: left;
}

[dir="rtl"] .storybook-btn-label {
    text-align: right;
}

[dir="rtl"] .storybook-create-btn,
.storybook-create-btn[dir="rtl"] {
    right: auto;
    left: 0;
    padding: 5px 8px 5px 14px;
}

.storybook-create-btn:hover {
    box-shadow: 0 5px 18px rgba(180, 80, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.2);
    filter: brightness(1.08);
    transform: translateY(-50%) scale(1.03);
}

.storybook-create-btn:active {
    filter: brightness(0.92);
    transform: translateY(-50%) scale(0.98);
}

.storybook-create-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: translateY(-50%);
}

.storybook-create-btn svg {
    flex-shrink: 0;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}

@media (max-width: 600px) {
    .storybook-create-btn .storybook-btn-label {
        display: none;
    }
    .storybook-create-btn {
        padding: 8px;
        border-radius: 50%;
        max-width: none;
    }
}

/* ========================================
   ANNOTATIONS DROPDOWN (matches bookmarks dropdown pattern)
   ======================================== */

.annotations-dropdown {
    position: fixed;
    top: 107px;
    right: 10px;
    width: 400px;
    max-height: calc(100vh - 127px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 99999;
}

.annotations-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* RTL positioning */
[dir="rtl"] .annotations-dropdown {
    right: auto;
    left: 10px;
}

.annotations-dropdown-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-light, #f8f9fa);
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.annotations-dropdown-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    font-family: var(--font-headings, 'Cairo', sans-serif);
}

.annotations-dropdown-close {
    background: transparent;
    border: none;
    color: var(--text-light, #7f8c8d);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    line-height: 1;
    font-weight: 300;
}

.annotations-dropdown-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-color, #2c3e50);
}

/* Annotation count badge (matches bookmark-count) */
.annotation-count {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    background: var(--accent-color, #e74c3c);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    padding: 0 4px;
    position: absolute;
    top: 2px;
    right: 2px;
}

.annotation-count:empty {
    display: none;
}

.annotations-dropdown-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.annotations-empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-light, #7f8c8d);
}

.annotations-empty-state svg {
    opacity: 0.4;
    margin-bottom: 12px;
    stroke: var(--text-light, #7f8c8d);
}

.annotations-empty-state p {
    margin: 0;
    font-size: 14px;
}

.annotation-item {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-radius: 8px;
    background: var(--bg-secondary, #f5f5f5);
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    border-left: 4px solid var(--annotation-color, #ffd54f);
}

[dir="rtl"] .annotation-item {
    border-left: none;
    border-right: 4px solid var(--annotation-color, #ffd54f);
}

.annotation-item:hover {
    background: var(--bg-tertiary, #eee);
    transform: translateY(-1px);
}

.annotation-item-content {
    flex: 1;
    min-width: 0;
}

.annotation-selected-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color, #333);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.annotation-note {
    font-size: 12px;
    color: var(--text-secondary, #666);
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.annotation-chapter {
    font-size: 11px;
    color: var(--text-light, #999);
    font-family: var(--font-headings, 'Cairo', sans-serif);
}

/* Dark Theme */
[data-theme="dark"] .annotations-dropdown {
    background: var(--bg-dark, #2c3e50);
}

[data-theme="dark"] .annotations-dropdown-header {
    background: var(--bg-darker, #1a252f);
    border-color: var(--border-dark, #3d566e);
}

[data-theme="dark"] .annotation-item {
    background: var(--bg-darker, #1a252f);
}

/* Sepia Theme */
[data-theme="sepia"] .annotations-dropdown {
    background: #f4ecd8;
}

[data-theme="sepia"] .annotations-dropdown-header {
    background: #ebe3cf;
    border-color: #d4c9a8;
}

[data-theme="sepia"] .annotation-item {
    background: #ebe3cf;
}

/* High Contrast Theme */
[data-theme="high-contrast"] .annotations-dropdown {
    background: #000;
    border: 2px solid #fff;
}

[data-theme="high-contrast"] .annotations-dropdown-header {
    background: #111;
    border-color: #fff;
}

[data-theme="high-contrast"] .annotation-item {
    background: #111;
    border-color: #fff;
}

/* LOCKED: Mobile/tablet breakpoint is 965px — do NOT change without explicit consent */
@media (max-width: 965px) {
    .annotations-dropdown {
        right: 5px;
        left: 5px;
        width: auto;
        max-width: calc(100vw - 10px);
    }

    [dir="rtl"] .annotations-dropdown {
        right: 5px;
        left: 5px;
    }
}

/* ========================================
   Gutenberg Sidenote Styling
   Preserves italic commentary from EPUB source
   ======================================== */
.content-body .sidenote {
    font-style: italic;
    font-size: 0.88em;
    font-weight: 300;
    display: block;
    margin: 0.75em 0;
    opacity: 0.7;
}
