/**
 * SumatraItinerary - Distraction-Free Reader Mode ("Mode Baca")
 * Responsive, Accessible, Themed (Light / Sepia / Dark) Typographic Canvas
 * High-Contrast Overhaul ensuring zero dark-on-dark blending and complete min-h-screen/bg-sand transparency.
 */

/* ==========================================================================
   1. Theme Variables & Base Settings
   ========================================================================== */
:root {
    --reader-scale: 1;
    --rm-font-serif: 'Fraunces', 'Merriweather', Georgia, 'Times New Roman', serif;
    --rm-font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Light Theme (Default) */
body.reader-mode-active,
body.reader-mode-active[data-reader-theme="light"] {
    --rm-bg: #FFFFFF;
    --rm-text: #1E293B;
    --rm-heading: #0F172A;
    --rm-muted: #64748B;
    --rm-card-bg: #F8FAFC;
    --rm-border: #E2E8F0;
    --rm-accent: #F26B3A;
    --rm-link: #0D7463;
    --rm-toolbar-bg: rgba(255, 255, 255, 0.95);
    --rm-toolbar-border: #E2E8F0;
    --rm-toolbar-btn-bg: #F1F5F9;
    --rm-toolbar-btn-hover: #E2E8F0;
    --rm-toolbar-btn-text: #334155;
    --rm-toolbar-btn-active-bg: #0D7463;
    --rm-toolbar-btn-active-text: #FFFFFF;
}

/* Sepia Theme (Warm Vintage Book) */
body.reader-mode-active[data-reader-theme="sepia"] {
    --rm-bg: #FBF0D9;
    --rm-text: #3F3222;
    --rm-heading: #2A1F13;
    --rm-muted: #6B5438;
    --rm-card-bg: #F3E3C4;
    --rm-border: #E3D1AE;
    --rm-accent: #B45309;
    --rm-link: #9A3412;
    --rm-toolbar-bg: rgba(251, 240, 217, 0.95);
    --rm-toolbar-border: #E3D1AE;
    --rm-toolbar-btn-bg: #EFE0C0;
    --rm-toolbar-btn-hover: #E4D2AE;
    --rm-toolbar-btn-text: #4A3A26;
    --rm-toolbar-btn-active-bg: #6B4E26;
    --rm-toolbar-btn-active-text: #FFF9EE;
}

/* Dark Theme (OLED Night Mode) */
body.reader-mode-active[data-reader-theme="dark"] {
    --rm-bg: #121212;
    --rm-text: #E2E8F0;
    --rm-heading: #F8FAFC;
    --rm-muted: #94A3B8;
    --rm-card-bg: #1E1E24;
    --rm-border: #2D2D38;
    --rm-accent: #F59E0B;
    --rm-link: #38BDF8;
    --rm-toolbar-bg: rgba(18, 18, 18, 0.95);
    --rm-toolbar-border: #2D2D38;
    --rm-toolbar-btn-bg: #27272F;
    --rm-toolbar-btn-hover: #353540;
    --rm-toolbar-btn-text: #CBD5E1;
    --rm-toolbar-btn-active-bg: #F59E0B;
    --rm-toolbar-btn-active-text: #121212;
}

/* ==========================================================================
   2. Distraction Elimination (Hides non-reading clutter)
   ========================================================================== */
body.reader-mode-active > header,
body.reader-mode-active > footer,
body.reader-mode-active #floating-actions,
body.reader-mode-active #mobile-sticky-bottom-bar,
body.reader-mode-active .mobile-sticky-bottom-bar,
body.reader-mode-active #pwa-install-mini-prompt,
body.reader-mode-active #pwa-offline-toast,
body.reader-mode-active .reader-hide,
body.reader-mode-active #sticky-package-bar,
body.reader-mode-active .site-header,
body.reader-mode-active .site-footer,
body.reader-mode-active #more-apps-modal,
body.reader-mode-active .booking-sidebar-col,
body.reader-mode-active .cost-calculator-card,
body.reader-mode-active #reg-slide-prev,
body.reader-mode-active #reg-slide-next,
body.reader-mode-active #article-toc-sticky-bar,
body.reader-mode-active .site-top-banner {
    display: none !important;
}

/* Reader Mode Exclusives */
.reader-mode-only {
    display: none !important;
}

body.reader-mode-active .reader-mode-only {
    display: block !important;
}

/* ==========================================================================
   3. Body & Viewport Adjustments (Fixes min-h-screen & bg-sand-50 on tools)
   ========================================================================== */
html.reader-mode-active,
body.reader-mode-active {
    background-color: var(--rm-bg) !important;
    color: var(--rm-text) !important;
    transition: background-color 0.25s ease, color 0.25s ease;
    overflow-x: hidden !important;
}

html.reader-mode-active[data-reader-theme="dark"] {
    color-scheme: dark;
}
html.reader-mode-active[data-reader-theme="light"],
html.reader-mode-active[data-reader-theme="sepia"] {
    color-scheme: light;
}

body.reader-mode-active {
    padding-top: 64px !important;
    min-height: 100vh;
}

/* Crucial: Reset tool <main> elements with min-h-screen / min-vh-100 and bg-sand-50 to transparent */
body.reader-mode-active main,
body.reader-mode-active main[data-readable],
body.reader-mode-active [data-readable],
body.reader-mode-active [data-readable].min-h-screen,
body.reader-mode-active [data-readable].min-vh-100,
body.reader-mode-active [data-readable][class*="bg-sand-"],
body.reader-mode-active [data-readable][class*="bg-white"],
body.reader-mode-active .min-h-screen,
body.reader-mode-active .min-vh-100 {
    min-height: auto !important;
    background: transparent !important;
    background-color: transparent !important;
}

/* Breadcrumbs inside readable containers are cleaned up in Reader Mode */
body.reader-mode-active [data-readable] nav[aria-label="Breadcrumb"],
body.reader-mode-active [data-readable] .no-print {
    display: none !important;
}

/* Content Width Management */
body.reader-mode-active [data-readable] {
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100% !important;
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    box-sizing: border-box;
}

body.reader-mode-active [data-readable="blog"] {
    max-width: 50rem !important;
}

body.reader-mode-active [data-readable="destination"],
body.reader-mode-active [data-readable="itinerary"],
body.reader-mode-active [data-readable="trekking"],
body.reader-mode-active [data-readable="booking"] {
    max-width: 62rem !important;
}

body.reader-mode-active [data-readable="legal"] {
    max-width: 54rem !important;
}

body.reader-mode-active [data-readable="tool"] {
    max-width: 68rem !important;
}

/* Ensure inner container wrappers span full 100% width without double padding */
body.reader-mode-active [data-readable] > form#trekking-form,
body.reader-mode-active [data-readable] > .max-w-7xl,
body.reader-mode-active [data-readable] > .max-w-6xl,
body.reader-mode-active [data-readable] > .max-w-5xl,
body.reader-mode-active [data-readable] > .max-w-4xl {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Critical Desktop Layout Fix: Convert 12-column layout grids into 100% full-width blocks on desktop */
body.reader-mode-active [data-readable] .grid.grid-cols-1.lg\:grid-cols-12,
body.reader-mode-active [data-readable] .grid.lg\:grid-cols-12,
body.reader-mode-active [data-readable] form.grid.lg\:grid-cols-12,
body.reader-mode-active [data-readable] .lg\:grid-cols-12 {
    display: block !important;
    width: 100% !important;
    grid-template-columns: 1fr !important;
}

/* Force left columns (which are .lg:col-span-8 or .lg:col-span-7) to occupy the entire 100% width */
body.reader-mode-active [data-readable] .lg\:col-span-8,
body.reader-mode-active [data-readable] .lg\:col-span-7,
body.reader-mode-active [data-readable] .lg\:col-span-9,
body.reader-mode-active [data-readable] .lg\:col-span-12,
body.reader-mode-active [data-readable] div.lg\:col-span-8,
body.reader-mode-active [data-readable] div.lg\:col-span-7,
body.reader-mode-active [data-readable] article.lg\:col-span-7 {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    grid-column: auto !important;
}

/* Hero Header Section in Reader Mode (book-trekking.php) */
body.reader-mode-active [data-readable="booking"] .book-trekking-hero-section,
body.reader-mode-active [data-readable="booking"] section.book-trekking-hero-section {
    background: transparent !important;
    background-color: transparent !important;
    border-bottom: 1px solid var(--rm-border) !important;
    padding-top: 1.5rem !important;
    padding-bottom: 2rem !important;
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    margin-bottom: 1.5rem !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

@media (min-width: 640px) {
    body.reader-mode-active [data-readable="booking"] .book-trekking-hero-section,
    body.reader-mode-active [data-readable="booking"] section.book-trekking-hero-section {
        padding-left: 1.75rem !important;
        padding-right: 1.75rem !important;
    }
}

@media (min-width: 1024px) {
    body.reader-mode-active [data-readable="booking"] .book-trekking-hero-section,
    body.reader-mode-active [data-readable="booking"] section.book-trekking-hero-section {
        padding-left: 2rem !important;
        padding-right: 2rem !important;
    }
}

body.reader-mode-active [data-readable="booking"] .book-trekking-hero-section > div {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

body.reader-mode-active [data-readable="booking"] .book-trekking-hero-section .flex-col.lg\:flex-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1.5rem !important;
}

body.reader-mode-active [data-readable="booking"] .book-trekking-hero-section .max-w-3xl,
body.reader-mode-active [data-readable="booking"] .book-trekking-hero-section .lg\:max-w-xl {
    max-width: 100% !important;
    width: 100% !important;
}

/* Hero Section in Reader Mode (trekking-detail.php) */
body.reader-mode-active [data-readable="trekking"] .trekking-hero-section {
    background: transparent !important;
    background-color: transparent !important;
    border-bottom: 1px solid var(--rm-border) !important;
    padding-top: 1.5rem !important;
    padding-bottom: 2rem !important;
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    margin-bottom: 1.5rem !important;
    box-sizing: border-box !important;
    width: 100% !important;
    color: var(--rm-text) !important;
}

@media (min-width: 640px) {
    body.reader-mode-active [data-readable="trekking"] .trekking-hero-section {
        padding-left: 1.75rem !important;
        padding-right: 1.75rem !important;
    }
}

@media (min-width: 1024px) {
    body.reader-mode-active [data-readable="trekking"] .trekking-hero-section {
        padding-left: 2rem !important;
        padding-right: 2rem !important;
    }
}

body.reader-mode-active [data-readable="trekking"] .trekking-hero-section h1 {
    color: var(--rm-heading) !important;
    margin-top: 0.5rem !important;
}

body.reader-mode-active [data-readable="trekking"] .trekking-hero-section p {
    color: var(--rm-muted) !important;
}

/* Ensure padding on Left Column (7 cols) in Reader Mode (trekking-detail.php) */
body.reader-mode-active [data-readable="trekking"] article.lg\:col-span-7,
body.reader-mode-active [data-readable="trekking"] .lg\:col-span-7,
body.reader-mode-active [data-readable] article.lg\:col-span-7 {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    grid-column: auto !important;
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    box-sizing: border-box !important;
}

@media (min-width: 640px) {
    body.reader-mode-active [data-readable="trekking"] article.lg\:col-span-7,
    body.reader-mode-active [data-readable="trekking"] .lg\:col-span-7,
    body.reader-mode-active [data-readable] article.lg\:col-span-7 {
        padding-left: 1.75rem !important;
        padding-right: 1.75rem !important;
    }
}

@media (min-width: 1024px) {
    body.reader-mode-active [data-readable="trekking"] article.lg\:col-span-7,
    body.reader-mode-active [data-readable="trekking"] .lg\:col-span-7,
    body.reader-mode-active [data-readable] article.lg\:col-span-7 {
        padding-left: 2rem !important;
        padding-right: 2rem !important;
    }
}

/* Ensure inner card sections within article.lg:col-span-7 preserve proper internal padding */
body.reader-mode-active [data-readable="trekking"] article.lg\:col-span-7 section.rounded-3xl,
body.reader-mode-active [data-readable="trekking"] article.lg\:col-span-7 section.rounded-2xl {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    box-sizing: border-box !important;
}

@media (min-width: 640px) {
    body.reader-mode-active [data-readable="trekking"] article.lg\:col-span-7 section.rounded-3xl,
    body.reader-mode-active [data-readable="trekking"] article.lg\:col-span-7 section.rounded-2xl {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }
}

/* Package Accordion & Thumbnails in Reader Mode (book-trekking.php) */
body.reader-mode-active [data-readable="booking"] .pkg-accordion-body {
    display: block !important;
}

body.reader-mode-active [data-readable="booking"] .pkg-accordion-body img {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    border-radius: 0.75rem !important;
}

/* Photo ribbon preview & grid images: preserve flush edges */
body.reader-mode-active [data-readable] .divide-x img,
body.reader-mode-active [data-readable] .grid.grid-cols-3 img {
    border-radius: 0 !important;
}

/* Critical Image Gradient Overlays: Retain transparent gradients across ALL themes */
body.reader-mode-active [data-readable] .absolute[class*="bg-gradient-to-"],
body.reader-mode-active [data-readable] .absolute.inset-0[class*="bg-gradient-to-"],
body.reader-mode-active [data-readable] [class*="bg-gradient-to-t"][class*="from-black"],
body.reader-mode-active [data-readable] [class*="bg-gradient-to-t"][class*="via-transparent"],
body.reader-mode-active [data-readable] [class*="bg-gradient-to-t"][class*="to-transparent"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] .absolute[class*="bg-gradient-to-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] .absolute.inset-0[class*="bg-gradient-to-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] .absolute[class*="bg-gradient-to-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] .absolute.inset-0[class*="bg-gradient-to-"] {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.15) 50%, transparent 100%) !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

/* Prevent underline clutter on buttons, pills, and badges */
body.reader-mode-active [data-readable] a.rounded-full,
body.reader-mode-active [data-readable] a[class*="rounded-"],
body.reader-mode-active [data-readable] a[class*="inline-flex"],
body.reader-mode-active [data-readable] a[class*="btn"] {
    text-decoration: none !important;
}

/* ==========================================================================
   4. Typographic Hierarchy & Font Controls
   ========================================================================== */
body.reader-mode-active[data-reader-font="serif"] [data-readable],
body.reader-mode-active[data-reader-font="serif"] [data-readable] p,
body.reader-mode-active[data-reader-font="serif"] [data-readable] li,
body.reader-mode-active[data-reader-font="serif"] [data-readable] blockquote,
body.reader-mode-active[data-reader-font="serif"] [data-readable] .article-body-content,
body.reader-mode-active[data-reader-font="serif"] [data-readable] .article-excerpt-content,
body.reader-mode-active[data-reader-font="serif"] [data-readable] .article-takeaway-content,
body.reader-mode-active[data-reader-font="serif"] [data-readable] table td {
    font-family: var(--rm-font-serif) !important;
}

body.reader-mode-active[data-reader-font="sans"] [data-readable],
body.reader-mode-active[data-reader-font="sans"] [data-readable] p,
body.reader-mode-active[data-reader-font="sans"] [data-readable] li,
body.reader-mode-active[data-reader-font="sans"] [data-readable] blockquote,
body.reader-mode-active[data-reader-font="sans"] [data-readable] .article-body-content,
body.reader-mode-active[data-reader-font="sans"] [data-readable] .article-excerpt-content,
body.reader-mode-active[data-reader-font="sans"] [data-readable] .article-takeaway-content,
body.reader-mode-active[data-reader-font="sans"] [data-readable] table td {
    font-family: var(--rm-font-sans) !important;
}

/* Scalable font sizing - Root Container */
body.reader-mode-active [data-readable] {
    font-size: calc(1.0625rem * var(--reader-scale, 1)) !important;
    line-height: 1.85 !important;
}

/* Scalable font sizing - Main Article Body, Excerpt, Takeaways, Paragraphs & Quotes */
body.reader-mode-active [data-readable] p,
body.reader-mode-active [data-readable] .article-body-content,
body.reader-mode-active [data-readable] .article-excerpt-content,
body.reader-mode-active [data-readable] .article-takeaway-content,
body.reader-mode-active [data-readable="blog"] .article-chapters-container > div > div,
body.reader-mode-active [data-readable="blog"] .space-y-8 > div > div,
body.reader-mode-active [data-readable] blockquote,
body.reader-mode-active [data-readable] blockquote p,
body.reader-mode-active [data-readable] [data-readable-body],
body.reader-mode-active [data-readable] .prose p,
body.reader-mode-active [data-readable] .prose div {
    font-size: calc(1.0625rem * var(--reader-scale, 1)) !important;
    line-height: 1.85 !important;
}

body.reader-mode-active [data-readable] .article-body-content strong,
body.reader-mode-active [data-readable] .article-body-content em,
body.reader-mode-active [data-readable] .article-body-content a,
body.reader-mode-active [data-readable] .article-body-content span:not([class*="badge"]):not([class*="pill"]):not([data-idr-price]):not([data-usd-price]) {
    font-size: inherit !important;
}

body.reader-mode-active [data-readable] p {
    margin-bottom: 1.5rem;
}

body.reader-mode-active [data-readable] li {
    font-size: calc(1.025rem * var(--reader-scale, 1)) !important;
    line-height: 1.75 !important;
}

/* Tables in Reader Mode */
body.reader-mode-active [data-readable] table td,
body.reader-mode-active [data-readable] table th {
    font-size: calc(0.95rem * var(--reader-scale, 1)) !important;
    line-height: 1.6 !important;
}

/* Headings Hierarchy */
body.reader-mode-active [data-readable] h1 {
    font-size: calc(2.25rem * var(--reader-scale, 1)) !important;
    line-height: 1.25 !important;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

body.reader-mode-active [data-readable] h2 {
    font-size: calc(1.65rem * var(--reader-scale, 1)) !important;
    line-height: 1.35 !important;
    margin-top: 2rem;
    margin-bottom: 0.85rem;
}

body.reader-mode-active [data-readable] .article-body-content h3,
body.reader-mode-active [data-readable] h3 {
    font-size: calc(1.35rem * var(--reader-scale, 1)) !important;
    line-height: 1.4 !important;
    margin-top: 1.75rem;
    margin-bottom: 0.65rem;
}

body.reader-mode-active [data-readable] .article-body-content h4,
body.reader-mode-active [data-readable] h4 {
    font-size: calc(1.15rem * var(--reader-scale, 1)) !important;
    line-height: 1.45 !important;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

body.reader-mode-active [data-readable] h5 {
    font-size: calc(1.05rem * var(--reader-scale, 1)) !important;
    line-height: 1.5 !important;
}

body.reader-mode-active [data-readable] h6 {
    font-size: calc(0.95rem * var(--reader-scale, 1)) !important;
    line-height: 1.5 !important;
}

body.reader-mode-active [data-readable] a {
    color: var(--rm-link) !important;
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    transition: color 0.15s ease;
}

body.reader-mode-active [data-readable] a:hover {
    color: var(--rm-accent) !important;
}

/* Images in Theme */
body.reader-mode-active img {
    border-radius: 1rem;
    transition: filter 0.25s ease;
}

body.reader-mode-active[data-reader-theme="sepia"] img {
    filter: sepia(0.08) contrast(0.98);
}

body.reader-mode-active[data-reader-theme="dark"] img {
    filter: brightness(0.92) contrast(1.02);
}

/* ==========================================================================
   5. Dark Theme Ultra-High Contrast Rules (No Dark-on-Dark blending)
   ========================================================================== */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] {
    color: #E2E8F0 !important;
}

/* Force all headings in dark mode to crisp luminous white */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] h1,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] h2,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] h3,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] h4,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] h5,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] h6 {
    color: #F8FAFC !important;
}

/* Force all text-jungle-* and dark slate classes to bright readable color */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-jungle-950"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-jungle-900"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-jungle-850"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-jungle-800"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-jungle-700"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-jungle-600"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-slate-800"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-slate-900"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-gray-800"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-gray-900"] {
    color: #E2E8F0 !important;
}

/* Secondary muted text */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-jungle-900/"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-jungle-800/"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-jungle-700/"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-gray-600"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-gray-500"] {
    color: #94A3B8 !important;
}

/* High-contrast accents in dark mode */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-sunset-"] {
    color: #FB923C !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-emerald-"] {
    color: #34D399 !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-amber-"] {
    color: #FBBF24 !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-sand-"] {
    color: #CBD5E1 !important;
}

/* Transform all light background surfaces into dark OLED cards with clear borders */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] .bg-white,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-white/"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-sand-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] section[class*="bg-gradient-to-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] article[class*="bg-gradient-to-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] form[class*="bg-gradient-to-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] div:not(.absolute)[class*="bg-gradient-to-"] {
    background: #1E1E24 !important;
    background-color: #1E1E24 !important;
    border-color: #2D2D38 !important;
    color: #E2E8F0 !important;
    box-shadow: none !important;
}

/* Callouts, excerpts, quote blocks */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] blockquote,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] .border-l-4 {
    background-color: #25252E !important;
    border-color: #F59E0B !important;
    color: #F1F5F9 !important;
}

/* Borders across elements */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="border-sand-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="border-jungle-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] .border {
    border-color: #2D2D38 !important;
}

/* Badges, cards, and pills in dark mode */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-sunset-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-orange-"] {
    background-color: rgba(249, 115, 22, 0.18) !important;
    color: #FB923C !important;
    border-color: rgba(249, 115, 22, 0.35) !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-emerald-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-green-"] {
    background-color: rgba(16, 185, 129, 0.14) !important;
    color: #34D399 !important;
    border-color: rgba(52, 211, 153, 0.3) !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-indigo-"] {
    background-color: rgba(99, 102, 241, 0.18) !important;
    color: #A5B4FC !important;
    border-color: rgba(129, 140, 248, 0.35) !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-jungle-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-jungle-800"] {
    background-color: #2D2D38 !important;
    color: #F8FAFC !important;
    border-color: #3E3E4C !important;
}

/* Specific & Robust Styling for Included Tubing & Emerald Banner Elements */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-emerald-50"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-emerald-50/"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] .bg-emerald-50\/60 {
    background: rgba(16, 185, 129, 0.12) !important;
    background-color: rgba(16, 185, 129, 0.12) !important;
    border-color: rgba(52, 211, 153, 0.3) !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-emerald-50"] [class*="text-jungle-900"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] .bg-emerald-50\/60 [class*="text-jungle-900"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] .bg-emerald-50\/60 span.font-bold {
    color: #F8FAFC !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-emerald-50"] [class*="text-jungle-900/"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] .bg-emerald-50\/60 [class*="text-jungle-900/"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] .bg-emerald-50\/60 p {
    color: #94A3B8 !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-emerald-100"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-emerald-100/"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] .bg-emerald-50\/60 .bg-emerald-100 {
    background: rgba(16, 185, 129, 0.25) !important;
    background-color: rgba(16, 185, 129, 0.25) !important;
    border-color: rgba(52, 211, 153, 0.45) !important;
    color: #34D399 !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-emerald-700"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] svg.text-emerald-700 {
    color: #34D399 !important;
    stroke: #34D399 !important;
}

/* Warning & Alert Strips (e.g. visa scams, first-aid alerts) */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-rose-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-red-"] {
    background-color: rgba(225, 29, 72, 0.15) !important;
    border-color: rgba(244, 63, 94, 0.4) !important;
    color: #FECDD3 !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-rose-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-red-"] {
    color: #FDA4AF !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-amber-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-yellow-"] {
    background-color: rgba(245, 158, 11, 0.15) !important;
    border-color: rgba(251, 191, 36, 0.4) !important;
    color: #FDE68A !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-amber-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-yellow-"] {
    color: #FCD34D !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-blue-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-indigo-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="bg-purple-"] {
    background-color: rgba(99, 102, 241, 0.15) !important;
    border-color: rgba(129, 140, 248, 0.4) !important;
    color: #C7D2FE !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-blue-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-indigo-"],
body.reader-mode-active[data-reader-theme="dark"] [data-readable] [class*="text-purple-"] {
    color: #93C5FD !important;
}

/* Form inputs & buttons (book-trekking and interactive tools) */
body.reader-mode-active[data-reader-theme="dark"] [data-readable] input,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] select,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] textarea {
    background-color: #272730 !important;
    color: #F8FAFC !important;
    border-color: #3E3E4C !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] label {
    color: #CBD5E1 !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] button:not(.rm-btn):not(.rm-pill-btn) {
    background-color: #272730 !important;
    color: #E2E8F0 !important;
    border-color: #3E3E4C !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] button:not(.rm-btn):not(.rm-pill-btn):hover {
    background-color: #353540 !important;
    color: #FFFFFF !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] table,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] tr,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] th,
body.reader-mode-active[data-reader-theme="dark"] [data-readable] td {
    border-color: #2D2D38 !important;
    color: #E2E8F0 !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] th {
    background-color: #272730 !important;
    color: #F8FAFC !important;
}

body.reader-mode-active[data-reader-theme="dark"] [data-readable] code {
    background-color: #272730 !important;
    color: #F8FAFC !important;
    border-color: #3E3E4C !important;
}

/* ==========================================================================
   6. Sepia Theme High-Contrast Vintage Book Rules
   ========================================================================== */
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] {
    color: #3F3222 !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] h1,
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] h2,
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] h3,
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] h4 {
    color: #2A1F13 !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="text-jungle-"] {
    color: #3F3222 !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="text-jungle-900/"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="text-jungle-800/"] {
    color: #6B5438 !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] .bg-white,
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-white/"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-sand-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] section[class*="bg-gradient-to-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] article[class*="bg-gradient-to-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] form[class*="bg-gradient-to-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] div:not(.absolute)[class*="bg-gradient-to-"] {
    background: #F3E3C4 !important;
    background-color: #F3E3C4 !important;
    border-color: #E3D1AE !important;
    color: #3F3222 !important;
    box-shadow: none !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="border-sand-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="border-jungle-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] .border {
    border-color: #E3D1AE !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] blockquote,
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] .border-l-4 {
    background-color: #EFE0BD !important;
    border-color: #B45309 !important;
    color: #2A1F13 !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-rose-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-red-"] {
    background-color: #F8E2E2 !important;
    border-color: #E2A8A8 !important;
    color: #5C1D1D !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-amber-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-yellow-"] {
    background-color: #F8EED8 !important;
    border-color: #E0CFA4 !important;
    color: #5A4315 !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-emerald-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-green-"] {
    background-color: #E2EFE7 !important;
    border-color: #A8CEB7 !important;
    color: #19452B !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="text-emerald-"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] svg.text-emerald-700 {
    color: #065F46 !important;
    stroke: #065F46 !important;
}

/* Sepia theme tubing element & emerald callouts */
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-emerald-50"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-emerald-50/"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] .bg-emerald-50\/60 {
    background: #E3EDE6 !important;
    background-color: #E3EDE6 !important;
    border-color: #A4C8B2 !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-emerald-50"] [class*="text-jungle-900"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] .bg-emerald-50\/60 [class*="text-jungle-900"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] .bg-emerald-50\/60 span.font-bold {
    color: #064E3B !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-emerald-50"] [class*="text-jungle-900/"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] .bg-emerald-50\/60 [class*="text-jungle-900/"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] .bg-emerald-50\/60 p {
    color: #14532D !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-emerald-100"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] [class*="bg-emerald-100/"],
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] .bg-emerald-50\/60 .bg-emerald-100 {
    background: #C7E2D2 !important;
    background-color: #C7E2D2 !important;
    border-color: #82B899 !important;
    color: #065F46 !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] input,
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] select,
body.reader-mode-active[data-reader-theme="sepia"] [data-readable] textarea {
    background-color: #FAF2E3 !important;
    color: #2A1F13 !important;
    border-color: #D8C39E !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] button:not(.rm-btn):not(.rm-pill-btn) {
    background-color: #EFE0C0 !important;
    color: #3F3222 !important;
    border-color: #D8C39E !important;
}

body.reader-mode-active[data-reader-theme="sepia"] [data-readable] button:not(.rm-btn):not(.rm-pill-btn):hover {
    background-color: #E5D2AE !important;
}

/* ==========================================================================
   7. Light Theme Clean Normalization
   ========================================================================== */
body.reader-mode-active[data-reader-theme="light"] [data-readable] [class*="text-jungle-"] {
    color: #1E293B !important;
}

body.reader-mode-active[data-reader-theme="light"] [data-readable] h1,
body.reader-mode-active[data-reader-theme="light"] [data-readable] h2,
body.reader-mode-active[data-reader-theme="light"] [data-readable] h3 {
    color: #0F172A !important;
}

body.reader-mode-active[data-reader-theme="light"] [data-readable] .bg-white,
body.reader-mode-active[data-reader-theme="light"] [data-readable] [class*="bg-sand-"] {
    background-color: #F8FAFC !important;
    border-color: #E2E8F0 !important;
    box-shadow: none !important;
}

body.reader-mode-active[data-reader-theme="light"] [data-readable] .bg-emerald-50\/60 span.font-bold,
body.reader-mode-active[data-reader-theme="light"] [data-readable] [class*="bg-emerald-50"] span.font-bold {
    color: #064E3B !important;
}

body.reader-mode-active[data-reader-theme="light"] [data-readable] .bg-emerald-50\/60 p,
body.reader-mode-active[data-reader-theme="light"] [data-readable] [class*="bg-emerald-50"] p {
    color: #166534 !important;
}

/* ==========================================================================
   8. Pinned Reader Toolbar (#reader-toolbar)
   ========================================================================== */
#reader-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    z-index: 99999;
    background-color: var(--rm-toolbar-bg);
    border-bottom: 1px solid var(--rm-toolbar-border);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

body.reader-mode-active #reader-toolbar {
    display: flex;
}

/* Reading Progress Bar (Fixed directly beneath toolbar) */
#reader-progress-bar-container {
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background-color: transparent;
    pointer-events: none;
}

#reader-progress-bar {
    height: 100%;
    width: 0%;
    background-color: var(--rm-accent);
    transition: width 0.08s linear;
}

/* Toolbar Control Buttons */
.rm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    background-color: var(--rm-toolbar-btn-bg);
    color: var(--rm-toolbar-btn-text);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.rm-btn:hover {
    background-color: var(--rm-toolbar-btn-hover);
}

.rm-btn:active {
    transform: scale(0.96);
}

.rm-btn.active {
    background-color: var(--rm-toolbar-btn-active-bg);
    color: var(--rm-toolbar-btn-active-text);
}

.rm-btn-icon {
    width: 34px;
    padding: 0;
}

/* Exit button with highlight */
.rm-exit-btn {
    background-color: var(--rm-toolbar-btn-bg);
    color: var(--rm-toolbar-btn-text);
    border: 1px solid var(--rm-toolbar-border);
    font-weight: 700;
}

.rm-exit-btn:hover {
    background-color: #EF4444;
    color: #FFFFFF;
    border-color: #EF4444;
}

/* Theme Pills Group */
.rm-pill-group {
    display: inline-flex;
    align-items: center;
    background-color: var(--rm-toolbar-btn-bg);
    padding: 2px;
    border-radius: 10px;
    border: 1px solid var(--rm-toolbar-border);
}

.rm-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 28px;
    padding: 0 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 8px;
    background: transparent;
    color: var(--rm-toolbar-btn-text);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.rm-pill-btn.active {
    background-color: var(--rm-toolbar-btn-active-bg);
    color: var(--rm-toolbar-btn-active-text);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Mobile Toolbar Responsiveness */
@media (max-width: 640px) {
    #reader-toolbar {
        padding: 0 0.5rem;
        height: 52px;
    }
    body.reader-mode-active {
        padding-top: 58px !important;
    }
    .rm-hide-mobile {
        display: none !important;
    }
    .rm-pill-btn {
        padding: 0 6px;
    }
}
