html { scroll-behavior: smooth; }

        :root {
            --primary: #2d6a4f;
            --primary-light: #40916c;
            --primary-dark: #1b4332;
            --secondary: #d4a373;
            --accent: #e76f51;
            --bg: #fefae0;
            --card-bg: #ffffff;
            --text: #333333;
            --text-light: #666666;
            --sidebar-bg: #1b4332;
            --sidebar-text: #d8e2dc;
            --sidebar-active: #40916c;
            --en-color: #2563eb;
            --en-bg: #eff6ff;
        }

        * { margin: 0; padding: 0; box-sizing: border-box; }

        /* body styles moved to NEW_CSS block */

        /* ── Main Content ── */
        .main {
            margin-left: 0;
            flex: 1;
            min-width: 0;
        }
        
        
        
        

        .content {
            max-width: 800px;
            margin: 0 auto;
            padding: 2rem 2rem 4rem;
        }
        /* moved to new CSS */
        /* moved to new CSS */
        /* moved to new CSS */
        /* moved to new CSS */
        /* moved to new CSS */
        /* moved to new CSS */

        /* ── English word highlighting ── */
        .en {
            color: var(--en-color);
            background: var(--en-bg);
            padding: 0.1em 0.35em;
            border-radius: 4px;
            cursor: pointer;
            border-bottom: 2px dotted var(--en-color);
            position: relative;
            font-weight: 500;
            transition: background 0.2s;
            white-space: nowrap;
        }
        .en:hover {
            background: #dbeafe;
        }
        .en:active {
            background: #bfdbfe;
        }
        /* Audio indicator */
        .en::before {
            content: '🔊';
            font-size: 0.6em;
            margin-right: 0.2em;
            opacity: 0;
            transition: opacity 0.2s;
        }
        .en:hover::before {
            opacity: 0.6;
        }

        /* Tooltip */
        .en::after {
            content: attr(data-th);
            position: absolute;
            bottom: 130%;
            left: 50%;
            transform: translateX(-50%);
            background: var(--sidebar-bg);
            color: white;
            padding: 0.3em 0.7em;
            border-radius: 6px;
            font-size: 0.8rem;
            white-space: nowrap;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s;
            z-index: 50;
        }
        .en:hover::after {
            opacity: 1;
        }

        /* Default: Thai mode — show Thai paragraphs, hide English */
        
        
        
        
        /* Inline headings need special handling */
        
        

        
        

        /* ── Chapter Navigation ── */
        .chapter-nav {
            display: flex;
            justify-content: space-between;
            padding: 1.5rem 0;
            margin-top: 3rem;
            border-top: 2px solid var(--primary-light);
        }
        .nav-arrow {
            color: var(--primary);
            text-decoration: none;
            font-weight: 600;
            padding: 0.6rem 1.2rem;
            border: 2px solid var(--primary);
            border-radius: 8px;
            transition: all 0.2s;
        }
        .nav-arrow:hover {
            background: var(--primary);
            color: white;
        }

        /* ── Mobile ── */
        @media (max-width: 768px) {
            
            
            
            .main {
                margin-left: 0;
            }
            
            .content {
                padding: 1.5rem 1rem 3rem;
            }
            
            
            
        }
    
        /* ── Content Sections ── */
        .content-section { margin-bottom: 1.5rem; }
        .content-section p {
            margin-bottom: 1rem;
        }

        /* ── Typography ── */
        @import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400&family=Lora:ital,wght@0,400;0,600;1,400&family=Sarabun:wght@300;400;600;700&display=swap');

        body {
            font-family: 'Sarabun', 'Lora', 'Segoe UI', Tahoma, sans-serif;
            background: var(--bg);
            color: var(--text);
            line-height: 1.8;
            display: flex;
            min-height: 100vh;
            font-size: 1.05rem;
        }

        .content h2 {
            font-family: 'Playfair Display', 'Sarabun', Georgia, serif;
            color: var(--primary-dark);
            font-size: 1.7rem;
            margin: 2.5rem 0 1rem;
            padding-bottom: 0.5rem;
            border-bottom: 2px solid var(--primary-light);
            letter-spacing: 0.02em;
        }
        .content h3 {
            font-family: 'Playfair Display', 'Sarabun', Georgia, serif;
            color: var(--primary);
            font-size: 1.25rem;
            margin: 2rem 0 0.8rem;
            letter-spacing: 0.01em;
        }
        .content h3.section-header {
            border-left: 4px solid var(--primary-light);
            padding-left: 0.8rem;
            margin-top: 2.5rem;
        }
        .content h4 {
            font-family: 'Sarabun', 'Segoe UI', sans-serif;
            color: var(--text);
            font-size: 1.05rem;
            font-weight: 600;
            margin: 1.5rem 0 0.6rem;
        }
        .content p {
            margin-bottom: 1.4rem;
            text-align: justify;
            line-height: 2;
            font-size: 1.05rem;
            text-indent: 1.5em;
        }
        .content p.drop-cap {
            text-indent: 0;
        }
        .content h3 + p {
            text-indent: 0;
        }
        .content p + p {
            text-indent: 1.5em;
        }

        /* ── Drop cap for first paragraph after chapter heading ── */
        .content > h2.p-en + h2.p-th + p.p-en::first-letter,
        .content > h2.p-en + h2.p-th + p.p-th::first-letter,
        .drop-cap::first-letter {
            font-family: 'Playfair Display', Georgia, serif;
            font-size: 3.2em;
            float: left;
            line-height: 0.8;
            padding-right: 0.1em;
            padding-top: 0.1em;
            color: var(--primary-dark);
            font-weight: 700;
        }

        /* ── Chapter hero banner ── */
        .chapter-hero {
            background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 40%, var(--primary-light) 100%);
            color: white;
            padding: 3rem 2rem 2.5rem;
            border-radius: 16px;
            margin-bottom: 2.5rem;
            position: relative;
            overflow: hidden;
        }
        .chapter-hero::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -20%;
            width: 60%;
            height: 200%;
            background: radial-gradient(ellipse, rgba(255,255,255,0.08) 0%, transparent 70%);
            pointer-events: none;
        }
        .chapter-hero h1 {
            font-family: 'Playfair Display', Georgia, serif;
            font-size: 2.2rem;
            font-weight: 700;
            margin-bottom: 0.3rem;
            letter-spacing: 0.03em;
        }
        .chapter-hero .subtitle {
            font-size: 1.1rem;
            opacity: 0.85;
            font-weight: 300;
            margin-bottom: 1rem;
        }
        .chapter-hero .chapter-meta {
            font-size: 0.85rem;
            opacity: 0.7;
            border-top: 1px solid rgba(255,255,255,0.2);
            padding-top: 0.8rem;
            margin-top: 0.5rem;
        }

        /* ── Section images ── */
        .section-image {
            width: 100%;
            border-radius: 12px;
            margin: 1.5rem 0;
            box-shadow: 0 4px 20px rgba(0,0,0,0.12);
        }
        .image-float-right {
            float: right;
            width: 45%;
            margin: 0 0 1.5rem 1.5rem;
            border-radius: 12px;
            box-shadow: 0 3px 15px rgba(0,0,0,0.1);
        }
        .image-float-left {
            float: left;
            width: 45%;
            margin: 0 1.5rem 1.5rem 0;
            border-radius: 12px;
            box-shadow: 0 3px 15px rgba(0,0,0,0.1);
        }
        .image-caption {
            text-align: center;
            font-size: 0.85rem;
            color: var(--text-light);
            font-style: italic;
            margin-top: -0.5rem;
            margin-bottom: 1.5rem;
        }
        .clearfix::after {
            content: '';
            display: table;
            clear: both;
        }

        /* ── Visual divider ── */
        .section-divider {
            text-align: center;
            margin: 2.5rem 0;
            color: var(--primary-light);
            font-size: 1.2rem;
            letter-spacing: 0.5em;
            opacity: 0.5;
        }

        /* ── Pull quote ── */
        .pull-quote {
            font-family: 'Playfair Display', Georgia, serif;
            font-size: 1.3rem;
            font-style: italic;
            color: var(--primary-dark);
            border-left: 4px solid var(--secondary);
            padding: 1rem 1.5rem;
            margin: 2rem 0;
            background: linear-gradient(90deg, rgba(212,163,115,0.08), transparent);
            line-height: 1.7;
        }
        .pull-quote .attribution {
            display: block;
            font-size: 0.85rem;
            font-style: normal;
            color: var(--text-light);
            margin-top: 0.5rem;
        }

        /* ── Reading progress bar ── */
        .progress-bar {
            position: fixed;
            top: 0;
            left: 0;
            width: 0%;
            height: 3px;
            background: linear-gradient(90deg, var(--primary), var(--secondary));
            z-index: 9999;
            transition: width 0.1s;
        }

        @media (max-width: 768px) {
            .chapter-hero h1 { font-size: 1.6rem; }
            .chapter-hero { padding: 2rem 1.5rem; }
            .image-float-right, .image-float-left {
                float: none;
                width: 100%;
                margin: 1rem 0;
            }
        }

        
/* ── Page Navigation ── */
.page-nav {
    display: flex;
    justify-content: space-between;
    padding: 1.5rem 0;
    margin-top: 2rem;
    border-top: 1px solid var(--accent-gold, #b8860b);
}
.page-nav a {
    color: var(--accent-gold, #b8860b);
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: background 0.2s;
}
.page-nav a:hover { background: rgba(184, 134, 11, 0.15); }
.page-nav-next { margin-left: auto; }

/* ── Chapter Nav Bar ── */
.chapter-nav-bar {
    background: var(--primary-dark, #1b4332);
    display: flex;
    align-items: center;
    padding: 0.4rem 0.8rem;
    gap: 0.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-home {
    font-size: 1.2rem;
    text-decoration: none;
}
.ch-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem;
    flex: 1;
    justify-content: center;
}
.ch-links a {
    color: var(--sidebar-text, #d8e2dc);
    text-decoration: none;
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}
.ch-links a:hover {
    background: rgba(255,255,255,0.1);
}
.ch-links a.ch-active {
    background: var(--primary-light, #40916c);
    color: white;
}

/* ── Accordion (collapsible sections) ── */
.accordion { margin-bottom: 0.8rem; }
.accordion-header {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    padding: 0.8rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Sarabun', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    transition: all 0.3s;
    user-select: none;
}
.accordion-header:hover { background: var(--primary-light); }
.accordion-header .arrow { transition: transform 0.3s; font-size: 0.85rem; }
.accordion.open .accordion-header { border-radius: 10px 10px 0 0; }
.accordion.open .accordion-header .arrow { transform: rotate(180deg); }
.accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease;
}
.accordion.open .accordion-body { max-height: 8000px; }
.accordion-body-inner { padding: 0.5rem 0 0; }
.accordion-body-inner > p:first-child { text-indent: 0; }
.accordion-body-inner > .pull-quote:first-child + p { text-indent: 0; }

/* ── Section Summary Box ── */
.section-summary {
    background: linear-gradient(135deg, #eff6ff, #f0fdf4);
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-left: 4px solid var(--en-color);
    border-radius: 10px;
    padding: 1rem 1.2rem;
    margin: 1.2rem 0 0.6rem;
}
.summary-en {
    color: var(--en-color);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 0.6rem;
    text-indent: 0 !important;
    font-style: italic;
}
.keyword-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.keyword-list .en {
    font-size: 0.9rem;
    padding: 0.2em 0.5em;
}

/* ── Glossary Grid ── */
.glossary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
}
.glossary-card {
    background: #f0f4e8;
    border-radius: 10px;
    padding: 0.8rem 1rem;
    border-left: 3px solid var(--primary, #2d6a4f);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.glossary-card:hover {
    background: #e0edd4;
    transform: translateY(-1px);
}
.glossary-eng {
    color: var(--primary, #2d6a4f);
    font-weight: 700;
    font-size: 1rem;
}
.glossary-thai {
    color: #555;
    font-size: 0.85rem;
    margin-top: 0.2rem;
}
@media (max-width: 600px) {
    .glossary-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
    .glossary-grid { grid-template-columns: 1fr; }
}

/* ── Callout Box ── */
.callout-box {
    background: linear-gradient(135deg, #fff8e1, #fffde7);
    border: 1px solid #f9a825;
    border-left: 4px solid #f9a825;
    border-radius: 10px;
    padding: 1.2rem 1.4rem;
    margin: 1.5rem 0;
}
.callout-title {
    font-weight: 700;
    font-size: 1rem;
    color: #e65100;
    margin-bottom: 0.6rem;
}
.callout-box p {
    margin-bottom: 0.6rem;
    text-indent: 0 !important;
}
.callout-box ul {
    margin: 0.4rem 0 0 1.2rem;
}
.callout-box li {
    margin-bottom: 0.3rem;
    font-size: 0.95rem;
}

/* ── Page nav prev (complement to page-nav-next) ── */
.page-nav-prev { margin-right: auto; }
