:root {
    /* Colors from Industrial Excellence Design System */
    --surface: #0f150f;
    --surface-container: #1b211b;
    --surface-container-high: #252c25;
    --on-surface: #dee4db;
    --on-surface-variant: #bdcabc;
    --primary: #6ee591; /* Emerald Green */
    --primary-container: #50c878;
    --secondary: #e9c349; /* Corporate Gold */
    --accent: #FF8C00; /* Vibrant Orange */
    --pearl: #fdfaf0;
    
    /* Gradients */
    --gradient-gold: linear-gradient(135deg, #B8860B 0%, #D4AF37 100%);
    --gradient-emerald: linear-gradient(135deg, #006d36 0%, #6ee591 100%);
    
    /* Spacing & Borders */
    --radius-sm: 4px;
    --radius-md: 8px;
    --glass-border: 1px solid rgba(253, 250, 240, 0.1);
    --gold-border: 1px solid rgba(212, 175, 55, 0.3);
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--surface);
    color: var(--on-surface);
    overflow: hidden; /* App feel */
    line-height: 1.6;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 320px;
    background-color: var(--surface-container);
    border-right: var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    counter-reset: chapter-counter;
}

.sidebar-header {
    padding: 2rem;
    border-bottom: var(--glass-border);
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.status-badge {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: var(--radius-sm);
    letter-spacing: 1px;
}

.chapter-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
}

.chapter-nav ul {
    list-style: none;
}

.chapter-item {
    padding: 0.75rem 2rem;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
    color: var(--on-surface-variant);
    font-size: 0.9rem;
}

.chapter-item:hover {
    background-color: var(--surface-container-high);
    color: var(--pearl);
}

.chapter-item.active {
    background-color: rgba(110, 229, 145, 0.1);
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: var(--glass-border);
}

.progress-label {
    font-size: 0.65rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
    color: var(--on-surface-variant);
}

.progress-bar-bg {
    height: 4px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-emerald);
    transition: width 0.5s ease;
}

/* Content Area Styling */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--surface);
}

.content-header {
    height: 80px;
    padding: 0 3rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: var(--glass-border);
    backdrop-filter: blur(10px);
    background-color: rgba(15, 21, 15, 0.8);
    position: sticky;
    top: 0;
    z-index: 100; /* Higher priority */
}

.content-header .menu-icon, 
.content-header .hamburger {
    display: none !important; /* Remove hamburger/menu icons */
}

.menu-toggle-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--pearl);
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.menu-toggle-btn:active {
    transform: scale(0.9);
}

@media (min-width: 1201px) {
    .menu-toggle-btn {
        display: none !important;
    }
}


.chapter-title-display {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--pearl);
    flex: 1; /* Take available space */
    padding-right: 2rem;
}

.btn-nav {
    padding: 0.6rem 1.2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: var(--on-surface);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.btn-nav:hover {
    border-color: var(--pearl);
    background-color: rgba(255, 255, 255, 0.05);
}

.btn-nav.primary {
    background-color: var(--primary);
    color: var(--surface);
    border: none;
}

.btn-nav.primary:hover {
    background-color: var(--primary-container);
    box-shadow: 0 0 15px rgba(110, 229, 145, 0.3);
}

.btn-download {
    display: block;
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.8rem;
    text-align: center;
    background: var(--gradient-gold);
    color: var(--surface);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2);
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.btn-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.4);
    filter: brightness(1.1);
}

.reader-view {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
}

.split-layout {
    display: grid;
    grid-template-columns: 38% 1fr; /* Better ratio for vertical images vs text */
    height: 100%;
    width: 100%;
    background: var(--surface);
}

@media (max-width: 1200px) {
    .split-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
}


.image-viewer-container {
    height: 100%;
    position: relative;
    overflow: hidden;
    background: var(--surface);
}

.image-panel {
    height: 100%;
    position: relative;
    overflow-y: auto; /* Enable scrolling */
    z-index: 1;
    scrollbar-width: none; /* Hide scrollbar */
    padding: 0;
}

.image-panel::-webkit-scrollbar {
    display: none; /* Hide scrollbar Chrome/Safari */
}

.image-panel img {
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    display: block;
    image-rendering: -webkit-optimize-contrast;
}

/* Seamless Transition Layer - Fixed on Container */
.image-viewer-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, transparent 80%, var(--surface) 100%);
    pointer-events: none;
    z-index: 10;
    /* Ensure it covers full height even if content stretches */
    min-height: 100vh;
}

.image-panel.no-fade + .image-viewer-container::after,
.image-viewer-container:has(.no-fade)::after {
    display: none;
}

.image-panel.no-fade img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    background: #000;
}

.text-panel {
    background: var(--surface);
    overflow-y: auto;
    padding: 0 6rem 5rem; /* No top padding for full-bleed images */
    position: relative;
    z-index: 3;
    box-shadow: -50px 0 100px var(--surface); /* Soft glow overlap */
}

@media (max-width: 1024px) {
    .text-panel {
        padding: 0 2rem 5rem;
        box-shadow: none;
    }
}


/* Content refinements for better readability on dark bg */
.content-body {
    max-width: 800px;
    margin: 0 auto;
    padding-top: 4rem; /* Restore padding for text chapters */
}

.content-body h1 {
    color: #d4af37;
    font-size: 2.6rem;
    margin-bottom: 3.5rem; /* Generous space */
    line-height: 1.2;
    text-transform: none;
}

.number-highlight {
    color: #d4af37;
    display: block;
    font-size: 1.4rem;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.text-panel::-webkit-scrollbar {
    width: 6px;
}

.text-panel::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.content-body a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border-bottom: 1px solid rgba(110, 229, 145, 0.3);
}

.content-body a:hover {
    color: var(--pearl);
    border-bottom-color: var(--primary);
}

/* Index Page Specific Styling */
.index-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
}

.index-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.index-card:hover {
    background: rgba(110, 229, 145, 0.05);
    border-color: var(--primary-container);
    transform: translateX(10px);
}

.index-card-title {
    color: var(--pearl);
    font-weight: 600;
    font-size: 1rem;
}

.info-point {
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid var(--primary);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    transition: all 0.3s ease;
}

.info-point:hover {
    background: rgba(110, 229, 145, 0.05);
    transform: translateX(5px);
}

.info-point h3 {
    margin-top: 0;
    border-left: none;
    padding-left: 0;
    font-size: 1.05rem;
    color: var(--secondary); /* Gold */
    font-weight: 400; /* Fine stroke */
    letter-spacing: 0.5px;
}

.info-point p {
    margin-bottom: 0;
    font-size: 0.95rem;
    color: var(--pearl);
    opacity: 0.8;
    line-height: 1.6;
}

.sub-point {
    margin-left: 2rem;
    padding-left: 1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
}

/* Typography in content */
h1 { font-size: 2.5rem; margin-bottom: 2rem; color: var(--pearl); }
h2 { font-size: 1.8rem; margin-top: 3rem; margin-bottom: 1.5rem; color: var(--primary); font-weight: 700; }
h3 { font-size: 1.2rem; margin-top: 2rem; margin-bottom: 1rem; color: var(--on-surface); font-weight: 600; border-left: 2px solid var(--primary); padding-left: 1rem; }
p { 
    margin-bottom: 1.5rem; 
    color: var(--on-surface-variant); 
    font-size: 1.05rem; 
    font-weight: 400 !important; /* Force no bold */
    opacity: 0.9; 
    line-height: 1.7;
}

/* Sidebar Enhancement */
.chapter-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-container) transparent;
}

.nav-label {
    padding: 2rem 1.5rem 1rem;
    font-size: 0.55rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 3px;
    opacity: 0.7;
    text-transform: uppercase;
}

.chapter-nav::-webkit-scrollbar {
    width: 4px;
}

.chapter-nav::-webkit-scrollbar-thumb {
    background: var(--primary-container);
    border-radius: 10px;
}

.chapter-nav ul {
    list-style: none;
    padding: 0 1.5rem;
}

.chapter-item {
    margin-bottom: 1rem;
    padding: 1.25rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    color: var(--on-surface-variant);
    font-size: 0.75rem;
    letter-spacing: 1.5px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.chapter-item::before {
    display: none;
}

.chapter-label {
    display: none;
}

.chapter-title {
    font-size: 0.75rem;
    font-weight: 400; /* Not thick */
    color: var(--on-surface-variant);
    line-height: 1.4;
}

.chapter-prefix {
    color: var(--primary); /* Emerald Green */
    margin-right: 4px;
}

.chapter-desc {
    color: var(--on-surface-variant);
}

.chapter-item.active .chapter-desc {
    color: var(--pearl);
}

/* Central Index Title Styling */
.index-card-title {
    font-size: 1rem;
    font-weight: 400;
}

.index-card-title .chapter-prefix {
    color: var(--primary);
}

.index-card-title .chapter-desc {
    color: var(--pearl);
}

.chapter-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(110, 229, 145, 0.3);
    transform: translateX(5px);
}

.chapter-item.active {
    background: rgba(110, 229, 145, 0.08);
    border: 1px solid var(--primary-container);
    color: var(--pearl);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.chapter-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--gradient-emerald);
}

.highlight {
    background: rgba(233, 195, 73, 0.1);
    border-left: 4px solid var(--secondary);
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: var(--radius-sm);
}

/* Exercise Infoboxes (App vs Workbook) */
.exercise-box {
    margin: 2.5rem 0;
    padding: 2rem;
    border-radius: var(--radius-md);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    display: flex;
    gap: 1.5rem;
    transition: all 0.3s ease;
}

.exercise-box:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.2);
}

.exercise-icon-container {
    flex: 0 0 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.exercise-content {
    flex: 1;
}

.exercise-tag {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
}

/* App Exercise Variant */
.exercise-app {
    background: linear-gradient(135deg, rgba(110, 229, 145, 0.1) 0%, rgba(0, 0, 0, 0.4) 100%);
    border-left: 4px solid var(--primary);
}

.exercise-app .exercise-tag {
    background: var(--primary);
    color: var(--surface);
}

.exercise-app .exercise-icon-container {
    color: var(--primary);
    box-shadow: 0 0 20px rgba(110, 229, 145, 0.2);
}

/* Workbook Exercise Variant */
.exercise-workbook {
    background: linear-gradient(135deg, rgba(233, 195, 73, 0.1) 0%, rgba(0, 0, 0, 0.4) 100%);
    border-left: 4px solid var(--secondary);
}

.exercise-workbook .exercise-tag {
    background: var(--secondary);
    color: var(--surface);
}

.exercise-workbook .exercise-icon-container {
    color: var(--secondary);
    box-shadow: 0 0 20px rgba(233, 195, 73, 0.2);
}

.exercise-text {
    margin-bottom: 0;
    font-weight: 400; /* No negrita */
    color: var(--pearl);
    font-size: 0.95rem;
    line-height: 1.5;
}

.exercise-icon-container svg, .workbook-icon svg {
    width: 24px;
    height: 24px;
    color: #d4af37; /* Gold Icons */
    opacity: 0.9;
}

/* Workbook Section Styling (Chapter Ends) */
.workbook-section {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.workbook-card {
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(212, 175, 55, 0.15);
    border-radius: var(--radius-md);
    padding: 3rem;
    position: relative;
    overflow: hidden;
}

.workbook-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.1) 0%, transparent 70%);
}

.workbook-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.workbook-icon { 
    font-size: 1.5rem; 
    color: #d4af37;
}

.workbook-content {
    margin-bottom: 2rem;
}

.exercise-item {
    margin-bottom: 1.5rem;
}

.exercise-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--on-surface-variant);
    line-height: 1.6;
}

.exercise-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--pearl);
    padding: 1.2rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
    transition: all 0.3s ease;
}

.exercise-input:focus {
    outline: none;
    border-color: #d4af37;
    background: rgba(212, 175, 55, 0.05);
}

.btn-workbook {
    background: var(--gradient-gold);
    color: var(--surface);
    border: none;
    padding: 0.8rem 1.5rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    letter-spacing: 1px;
}
/* Portada Enhancement */
.portada-intro-container {
    text-align: center;
    padding: 0 0 2rem;
    margin-top: -4rem; /* Counter the content-body padding to start from top */
}

.mockup-wrapper {
    margin: 0 0 3rem; /* No top margin */
    perspective: 1000px;
}

.ebook-mockup {
    max-width: 450px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 30px 50px rgba(0,0,0,0.6));
    transition: transform 0.5s ease;
}

.ebook-mockup:hover {
    transform: translateY(-10px) rotateY(-5px);
}

.monumental-title {
    font-size: 4.5rem;
    font-weight: 900;
    letter-spacing: 5px;
    margin: 1rem 0;
    background: var(--gradient-gold);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.portada-tagline {
    font-size: 1.2rem;
    color: var(--on-surface-variant);
    max-width: 600px;
    margin: 0 auto;
    letter-spacing: 1px;
}

.portada-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(110, 229, 145, 0.1);
    color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 2px;
}

.ebook-portada {
    max-width: 500px;
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: 0 30px 60px rgba(0,0,0,0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0 auto;
    display: block;
}

.ebook-hero {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    filter: drop-shadow(0 0 20px rgba(110, 229, 145, 0.2));
}

.hidden { display: none; }

/* Responsive — Tablet & below */
@media (max-width: 1200px) {
    .split-layout {
        display: flex;
        flex-direction: column;
    }
    
    .image-viewer-container {
        height: 40vh;
        width: 100%;
        flex-shrink: 0;
    }

    .image-viewer-container::after {
        background: linear-gradient(to bottom, transparent 80%, var(--surface) 100%);
    }

    /* Sidebar slides in from left */
    .sidebar {
        position: fixed;
        left: -320px;
        top: 0;
        height: 100vh;
        transition: left 0.3s ease;
        z-index: 1000;
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        left: 0;
    }

    /* Dim overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    .sidebar-overlay.active {
        display: block;
    }

    /* Show menu toggle */
    #menu-toggle {
        display: inline-flex !important;
    }

    .text-panel {
        padding: 0 2rem 5rem;
        box-shadow: none;
    }

    .content-header {
        padding: 0.75rem 1.25rem;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .btn-nav {
        padding: 0.4rem 0.75rem;
        font-size: 0.65rem;
    }
}

/* Responsive — Mobile phones */
@media (max-width: 768px) {
    /* Full-width content area (no sidebar taking space) */
    .app-container {
        grid-template-columns: 1fr;
    }

    .content-area {
        width: 100%;
    }

    /* Mobile Header Adjustments */
    .content-header {
        height: 60px;
        padding: 0 1rem;
        backdrop-filter: none; /* Crucial: removes the new stacking context so bottom fixed nav works */
        background-color: var(--surface); /* Solid background on mobile */
        position: relative; /* For absolute centering of title */
    }

    /* Keep side-by-side layout on mobile — image left, text right */
    .split-layout {
        display: flex !important;
        flex-direction: row !important;
        height: calc(100vh - 60px - 56px); /* viewport minus header(60px) minus bottom nav(56px) */
    }

    /* Full screen cover for Portada */
    .split-layout.is-cover {
        display: block !important;
    }
    .split-layout.is-cover .image-viewer-container {
        width: 100% !important;
        height: 100% !important;
    }
    .split-layout.is-cover .image-panel {
        overflow-y: auto !important; /* Allow scroll to see full cover */
    }
    .split-layout.is-cover .image-panel img {
        height: auto !important; /* Let image define height */
        object-fit: unset !important;
    }
    .split-layout.is-cover .text-panel {
        display: none !important;
    }
    .split-layout.is-cover .image-viewer-container::after {
        display: none !important; /* No gradient on full cover */
    }

    /* Image column: 33% wide, FULL height, no scroll */
    .image-viewer-container {
        width: 33%;
        min-width: 33%;
        flex-shrink: 0;
        height: 100%;
        min-height: unset;
        max-height: unset;
        overflow: hidden;
    }

    /* Lateral gradient from image toward text */
    .image-viewer-container::after {
        content: '' !important;
        position: absolute !important;
        top: 0 !important;
        left: auto !important;
        right: -1px !important;
        width: 30% !important;
        height: 100% !important;
        background: linear-gradient(to left, var(--surface) 0%, transparent 100%) !important;
        pointer-events: none;
        z-index: 10;
        min-height: unset !important;
    }

    .image-panel {
        width: 100%;
        height: 100%;
        overflow: hidden !important;
    }

    /* Override global img rules for mobile */
    .image-panel picture { display: block; width: 100%; height: 100%; }
    .image-panel picture img,
    .image-panel img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        object-position: top center !important;
    }

    /* Text column: fills remaining space, scrollable */
    .text-panel {
        flex: 1;
        padding: 1.5rem 1rem 2rem;
        box-shadow: none;
        overflow-y: auto;
    }

    .content-body { max-width: unset; padding-top: 0; }
    .content-body h1 { font-size: 1rem; line-height: 1.2; margin-bottom: 0.5rem; }
    .content-body h2 { font-size: 0.85rem; margin-top: 0.75rem; }
    .content-body p  { font-size: 0.78rem; line-height: 1.4; margin-bottom: 0.4rem; }

    /* --- Compact Infoboxes for mobile --- */
    .exercise-box {
        display: grid !important;
        grid-template-columns: 28px 1fr !important;
        grid-template-rows: auto auto !important;
        padding: 0.6rem 0.75rem !important;
        margin: 0.75rem 0 !important;
        gap: 0.3rem 0.5rem !important;
        align-items: center;
    }

    .exercise-icon-container {
        grid-row: 1;
        grid-column: 1;
        flex: unset !important;
        width: 28px !important;
        height: 28px !important;
        min-width: unset !important;
    }

    .exercise-icon-container svg {
        width: 14px !important;
        height: 14px !important;
    }

    .exercise-content {
        grid-row: 1 / -1;
        grid-column: 2;
    }

    .exercise-tag {
        font-size: 0.5rem !important;
        letter-spacing: 1px !important;
        padding: 1px 5px !important;
        margin-bottom: 0.2rem !important;
    }

    .exercise-text {
        font-size: 0.7rem !important;
        line-height: 1.25 !important;
    }

    /* Workbook */
    .workbook-section { margin: 0; border-radius: 0; }

    /* Compact chapter title in header */
    .chapter-title-display {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        text-align: center;
        width: calc(100% - 100px); /* Leave space for hamburger */
        font-size: 0.7rem;
        letter-spacing: 0.5px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        padding: 0;
        margin: 0;
    }

    /* Index: single column */
    .index-grid { grid-template-columns: 1fr; }

    /* Sidebar: narrower */
    .sidebar { width: 280px; left: -280px; }

    /* Prev/Next fixed at bottom */
    .header-actions {
        position: fixed;
        bottom: 0; left: 0; right: 0;
        background: var(--surface-2);
        border-top: 1px solid var(--border);
        display: flex;
        justify-content: space-between;
        padding: 0.6rem 1.5rem;
        z-index: 100;
        gap: 1rem;
    }

    .header-actions .btn-nav {
        flex: 1;
        text-align: center;
        padding: 0.55rem;
    }
}

/* Utility classes for responsive content */
.responsive-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

/* --- PRINT SYSTEM (PDF GENERATION) --- */
#print-view {
    display: none;
}

@media print {
    html, body {
        height: auto !important;
        overflow: visible !important;
        background: white !important;
    }

    .app-container, .sidebar, .content-header, .header-actions, .progress-container, #menu-toggle {
        display: none !important;
    }

    #print-view {
        display: block !important;
        width: 100% !important;
        background: white !important;
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        font-family: 'Poppins', sans-serif !important;
    }

    #print-view * {
        color: #000000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .print-page {
        page-break-after: always;
        padding: 0.5cm 1cm;
        background: white !important;
        min-height: 28cm; /* Helps stabilize layout */
    }

    .print-split {
        display: flex;
        gap: 0.8cm;
        align-items: flex-start;
        width: 100%;
        min-height: 100%;
    }

    .print-image-side {
        flex: 0 0 35%;
        max-width: 35%;
    }

    .print-text-side {
        flex: 1;
        padding-top: 5pt;
        display: flex;
        flex-direction: column;
    }

    /* Cover Page (First Page) Full Width */
    .print-page:first-of-type .print-split {
        display: block;
        text-align: center;
    }

    .print-page:first-of-type .print-image-side {
        max-width: 100%;
        width: 100%;
    }

    .print-page h1 {
        font-family: 'Montserrat', sans-serif !important;
        font-size: 18pt; /* Slightly smaller to save space */
        margin: 0 0 8pt 0;
        border-bottom: 0.5pt solid #ddd;
        padding-bottom: 4pt;
        line-height: 1.1;
    }

    .print-page h2 { 
        font-family: 'Montserrat', sans-serif !important;
        margin-top: 10pt; 
        font-size: 13pt; 
        line-height: 1.2;
    }

    .print-page p, .print-page li { 
        font-family: 'Poppins', sans-serif !important;
        font-size: 9pt; 
        line-height: 1.2; 
        margin-bottom: 5pt; 
    }
    
    .print-page img {
        width: 100% !important;
        height: 13cm !important; /* Reduced to guarantee single-page fit */
        object-fit: cover;
        border-radius: 5pt;
        display: block;
    }

    /* Cover page override */
    .print-page:first-of-type img {
        height: auto !important;
        max-height: 27cm !important;
        width: auto !important;
        margin: 0 auto;
    }

    /* Index page - compact card list */
    .print-page .index-grid {
        display: block !important;
        columns: 2;
        column-gap: 0.5cm;
    }

    .print-page .index-card {
        display: block !important;
        padding: 2pt 4pt !important;
        margin-bottom: 2pt !important;
        break-inside: avoid;
        border-bottom: 0.3pt solid #eee !important;
        background: transparent !important;
    }

    .print-page .index-card-title {
        display: flex;
        gap: 5pt;
        align-items: baseline;
    }

    .print-page .chapter-prefix {
        font-size: 7pt !important;
        color: #006d36 !important;
        font-weight: bold !important;
        white-space: nowrap;
    }

    .print-page .chapter-desc {
        font-size: 8pt !important;
        line-height: 1.1 !important;
        color: #000 !important;
    }

    .print-page .index-grid h1 {
        column-span: all;
    }

    .print-workbook {
        background: #fdfaf0 !important;
        border: 0.5pt solid #e9c349 !important;
        padding: 8pt 12pt;
        border-radius: 6pt;
        margin-top: 10pt; /* Reduced margin to stay closer to text */
        break-inside: avoid;
    }

    .print-badge {
        background: #e9c349 !important;
        color: black !important;
        padding: 2pt 8pt;
        border-radius: 3pt;
        font-size: 8pt;
        font-weight: bold;
        display: inline-block;
        margin-bottom: 5pt;
    }
}
