:root {
    /* Paleta Comic Light Corporativa */
    --primary: #fad701; /* Amarillo Comic */
    --primary-container: #ff8800; /* Naranja Comic */
    --secondary: #151a20; /* Azul Marino Oscuro / Negro suave */
    
    --surface: #ffffff; /* Blanco puro para cajas y lectura */
    --surface-container: #fdfdfd; /* Blanco casi puro para fondos secundarios */
    --surface-container-high: #f0f0f0; /* Gris muy clarito para hovers */
    --background: #faf8eb; /* Crema sólido para el fondo general */
    
    --on-surface: #000000; /* Texto Negro sólido */
    --on-surface-variant: #333333; /* Texto Gris oscuro para subtítulos */
    
    --pure-black: #000000;
    --pearl: #fbf9ec;
    
    /* Gradients (usados con menos frecuencia en Neubrutalism) */
    --gradient-gold: linear-gradient(135deg, #FF6B00 0%, #E9B824 100%);
    --gradient-emerald: linear-gradient(135deg, #2ECC71 0%, #17b359 100%);
    
    /* Neubrutalism Borders & Shadows (Moderados) */
    --radius-sm: 4px;
    --radius-md: 8px;
    --comic-border: 2px solid var(--pure-black); /* Borde sutil de 2px */
    --comic-shadow: 4px 4px 0px var(--pure-black); /* Sombra dura moderada */
    --comic-shadow-hover: 2px 2px 0px var(--pure-black);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif; /* Texto base */
    background-color: var(--surface);
    color: var(--on-surface);
    overflow: hidden; 
    line-height: 1.6;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

.sidebar {
    width: 320px;
    background-color: var(--secondary);
    border-right: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    z-index: 100;
    counter-reset: chapter-counter;
}

.sidebar-header {
    padding: 20px;
    background-color: var(--secondary); /* Fondo oscuro */
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    align-items: center; /* Centrar elementos */
}

.logo-text {
    font-family: 'Montserrat', sans-serif; font-weight: 900;
    font-size: 2rem;
    letter-spacing: 1px;
    color: var(--surface);
    
}

.sidebar-logo {
    width: 140px;
    height: auto;
    max-height: 80px;
    object-fit: contain;
    object-position: center;
    margin: 10px auto; 
    display: block;
    transform: scale(1.4);
    transform-origin: center;
}

.monumental-title-sm {
    font-family: 'Montserrat', sans-serif; font-weight: 900;
    font-size: 1.8rem;
    letter-spacing: 1px;
    margin-bottom: 5px;
    color: var(--primary); /* Cambiado para contraste con fondo oscuro */
    
    line-height: 1.1;
}

.status-badge {
    display: inline-block;
    margin-top: 0.5rem;
    font-family: 'Montserrat', sans-serif; font-weight: 900;
    font-size: 0.8rem;
    padding: 4px 10px;
    background-color: var(--primary); /* Dorado pop */
    color: var(--pure-black); /* Texto negro */
    border-radius: var(--radius-sm);
    letter-spacing: 1px;
}

.chapter-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
    background-color: var(--secondary);
}

.chapter-nav ul {
    list-style: none;
    padding: 0 1.5rem;
}

.chapter-item {
    margin-bottom: 1rem;
    padding: 1.25rem;
    cursor: pointer;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    color: var(--pearl);
    font-size: 0.75rem;
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    box-shadow: none;
}

.chapter-item:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(250, 215, 1, 0.5); /* Primary gold with opacity */
    transform: translate(2px, 2px);
    box-shadow: none;
}

.chapter-item.active {
    background: var(--primary);
    color: var(--pure-black);
}

.chapter-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: inherit;
    line-height: 1.4;
}

.chapter-prefix {
    color: var(--primary); /* Amarillo brillante sobre negro */
    margin-right: 4px;
    font-weight: 700;
}

.chapter-item.active .chapter-prefix {
    color: var(--pure-black); /* Negro sobre amarillo cuando está activo */
}

.chapter-desc {
    color: inherit;
}

.chapter-item.active .chapter-desc {
    color: var(--surface);
}

.sidebar-footer {
    padding: 1.5rem;
    background-color: var(--secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-label {
    font-family: 'Montserrat', sans-serif; font-weight: 900;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
    color: var(--primary);
}

.progress-bar-bg {
    height: 12px;
    background-color: var(--surface);
    border: var(--comic-border);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--secondary);
    border-right: var(--comic-border);
    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;
    background-color: var(--surface-container);
    border-bottom: var(--comic-border);
    position: sticky;
    top: 0;
    z-index: 100; 
}

.content-header .menu-icon, 
.content-header .hamburger {
    display: none !important; 
}

.menu-toggle-btn {
    display: none;
    background: var(--primary);
    border: var(--comic-border);
    border-radius: var(--radius-sm);
    color: var(--surface);
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 1rem;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0px var(--pure-black);
    transition: transform 0.1s ease;
}

.menu-toggle-btn:active {
    transform: translate(2px, 2px);
    box-shadow: none;
}

@media (min-width: 1201px) {
    .menu-toggle-btn {
        display: none !important;
    }
}

.mobile-logo-header {
    display: none;
}

.chapter-title-display {
    font-family: 'Montserrat', sans-serif; font-weight: 900;
    /* text-transform: uppercase; removed */
    font-size: 1.5rem;
    color: var(--primary);
    flex: 1; 
    padding-right: 2rem;
    
}

.btn-nav {
    padding: 0.6rem 1.2rem;
    border: var(--comic-border);
    background: var(--surface);
    color: var(--pure-black); /* Texto negro en botón blanco */
    font-family: 'Montserrat', sans-serif; font-weight: 900;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 1px;
    border-radius: var(--radius-sm);
    box-shadow: var(--comic-shadow);
}

.btn-nav:hover {
    background-color: var(--surface-container-high);
    transform: translate(2px, 2px);
    box-shadow: var(--comic-shadow-hover);
}

.btn-nav.primary {
    background-color: var(--secondary); /* Verde Radiactivo */
    color: var(--surface);
}

.btn-nav.primary:hover {
    background-color: #17b359;
}

.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; removed */
    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-y: auto; /* Fix: allow scrolling */
    position: relative;
    background: rgba(0, 0, 0, 0.2);
}

.split-layout {
    display: grid;
    grid-template-columns: 50% 1fr; /* Better ratio for readability */
    height: auto; /* Allow growth */
    min-height: 100%;
    width: 100%;
    background: var(--surface);
}

@media (max-width: 1200px) {
    .split-layout {
        display: flex;
        flex-direction: column;
    }
}

/* Comic Mode Layout */
.split-layout.comic-mode {
    display: flex;
    overflow-y: visible; /* Let the whole page scroll naturally */
    padding: 0;
    background-color: var(--background); /* Crema sólido para facilitar la lectura */
}

.split-layout.comic-mode .image-viewer-container {
    display: flex; /* Restore side panel */
    flex: 1; /* 1/3 of the space */
    max-width: 35%;
    background: transparent;
    padding: 2rem;
    align-items: flex-start; /* Start from the top instead of centering */
    justify-content: center;
    border-right: 6px solid var(--pure-black);
}

.split-layout.comic-mode .image-panel {
    width: 100%;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.split-layout.comic-mode .image-panel img {
    width: 100%; /* Fill the 1/3 width completely */
    height: auto; /* Let it grow vertically as much as it wants */
    object-fit: contain; /* Nunca recortar la imagen */
    border: 6px solid var(--pure-black);
    border-radius: 4px;
    box-shadow: 12px 12px 0px var(--pure-black);
    /* Filtro para unificar los colores de los cómics de IA con el estilo pop */
    filter: contrast(1.15) saturate(1.2) sepia(0.2) hue-rotate(-5deg);
    transition: transform 0.3s ease;
}
.split-layout.comic-mode .image-panel img:hover {
    transform: scale(1.02);
}

.split-layout.comic-mode .text-panel {
    background: transparent;
    flex: 2; /* 2/3 of the space */
    max-width: 65%;
    padding: 2rem 4rem;
    margin: 0 auto;
    box-shadow: none;
    overflow-y: visible; /* Let it scroll naturally with the page */
}

.comic-narrator-box {
    background-color: var(--surface);
    color: var(--on-surface);
    border: 4px solid var(--pure-black);
    padding: 1.5rem 2rem;
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.6;
    margin: 1.5rem auto;
    border-radius: 2px;
    box-shadow: 6px 6px 0px var(--pure-black);
    position: relative;
    max-width: 800px;
}

.comic-header {
    font-family: 'Luckiest Guy', 'Montserrat', sans-serif !important;
    /* text-transform: uppercase; removed */
    color: var(--primary);
    -webkit-text-stroke: 2px var(--pure-black);
    text-shadow: 4px 4px 0px var(--pure-black);
    margin: 2rem 0 1rem 0;
    letter-spacing: 2px;
    text-align: center;
    font-size: 3rem !important;
    transform: rotate(-2deg);
}

.comic-floating-img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 2rem auto;
    object-fit: contain;
    position: relative;
    z-index: 10;
}

h1.comic-header {
    font-size: 4rem !important;
    color: var(--primary-container);
    transform: rotate(-3deg);
    margin-bottom: 3rem;
}

.split-layout.is-cover .image-panel img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important; /* Changed to contain for cover to avoid cropping */
    background-color: #000;
}


.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;
}

/* Removed Seamless Transition Layer */

.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; 
}

.content-body h1 {
    font-family: 'Montserrat', sans-serif; font-weight: 900;
    /* text-transform: uppercase; removed */
    color: var(--primary); /* Dorado Pop */
    font-size: 3rem;
    margin-bottom: 2rem;
    line-height: 1.1;
    
    letter-spacing: 1px;
}

.number-highlight {
    font-family: 'Montserrat', sans-serif; font-weight: 900;
    color: var(--primary-container); /* Naranja */
    display: inline-block;
    font-size: 2rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    
}

.text-panel::-webkit-scrollbar {
    width: 8px;
}

.text-panel::-webkit-scrollbar-thumb {
    background: var(--primary);
    border: var(--comic-border);
    border-radius: 0; /* Blocky scrollbar */
}

.content-body a {
    color: var(--secondary);
    text-decoration: none;
    font-weight: 700;
    transition: all 0.2s ease;
    border-bottom: 2px solid var(--secondary);
}

.content-body a:hover {
    background-color: var(--secondary);
    color: var(--surface);
}

/* Index Page Specific Styling */
.index-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
}

.index-card {
    background: var(--surface-container); /* Fondo oscuro en lugar de blanco */
    border: 2px solid var(--surface-container-high);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 4px 4px 0px var(--pure-black); /* Sombra sólida de cómic */
}

.index-card:hover {
    background: var(--surface-container-high);
    border-color: var(--primary); /* Se ilumina en dorado al pasar el mouse */
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0px var(--primary); /* Sombra dorada brutalista */
}

.index-card-title {
    color: var(--primary); /* Dorado Pop */
    font-family: 'Montserrat', sans-serif;
    font-weight: 800;
    font-size: 1.1rem;
    /* text-transform: uppercase; removed */
}

.info-point {
    background: var(--surface-container);
    border: var(--comic-border);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    box-shadow: var(--comic-shadow);
}

.info-point:hover {
    transform: translate(2px, 2px);
    box-shadow: var(--comic-shadow-hover);
}

.info-point h3 {
    margin-top: 0;
    border-left: none;
    padding-left: 0;
    font-family: 'Montserrat', sans-serif; font-weight: 900;
    /* text-transform: uppercase; removed */
    font-size: 1.5rem;
    color: var(--primary); 
    letter-spacing: 1px;
    
}

.info-point p {
    margin-bottom: 0;
    font-size: 1rem;
    color: var(--on-surface);
    line-height: 1.6;
}

.sub-point {
    margin-left: 2rem;
    padding-left: 1rem;
    border-left: 3px solid var(--primary);
    margin-bottom: 1rem;
}

/* Typography in content */
h1 { font-family: 'Montserrat', sans-serif; font-weight: 900; /* text-transform: uppercase; removed */ font-size: 3rem; margin-bottom: 2rem; color: var(--primary);  }
h2 { font-family: 'Montserrat', sans-serif; font-weight: 900; /* text-transform: uppercase; removed */ font-size: 2.2rem; margin-top: 1.5rem; margin-bottom: 1.5rem; color: var(--secondary);  }
h3 { font-family: 'Montserrat', sans-serif; font-weight: 900; /* text-transform: uppercase; removed */ font-size: 1.6rem; margin-top: 2rem; margin-bottom: 1rem; color: var(--pearl);  border-left: none; padding-left: 0; }
p { 
    margin-bottom: 1.5rem; 
    color: var(--on-surface); 
    font-size: 1.05rem; 
    font-weight: 400 !important; 
    opacity: 0.95; 
    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; removed */
}

.chapter-nav::-webkit-scrollbar {
    width: 4px;
}

.chapter-nav::-webkit-scrollbar-thumb {
    background: var(--primary-container);
    border-radius: 10px;
}

/* Removed duplicate */

.chapter-item.active .chapter-desc {
    color: inherit; /* Heredar color negro cuando está activo */
}

/* Central Index Title Styling */
.index-card-title {
    font-size: 1rem;
    font-weight: 400;
}

.index-card-title .chapter-prefix {
    color: var(--secondary); /* Verde radiactivo para el número */
    margin-right: 8px;
}

.index-card-title .chapter-desc {
    color: var(--pure-black); /* Fix: Negro para que se lea en fondo claro */
}

/* Duplicate chapter-item pseudo-classes removed */

.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);
    background: var(--pearl); /* Blanco Crema */
    border: var(--comic-border);
    position: relative;
    overflow: visible; /* To allow shadow to bleed */
    display: flex;
    gap: 1.5rem;
    transition: all 0.2s ease;
    box-shadow: var(--comic-shadow);
    color: var(--surface); /* Texto oscuro adentro */
}

.exercise-box:hover {
    transform: translate(2px, 2px);
    box-shadow: var(--comic-shadow-hover);
}

.exercise-icon-container {
    flex: 0 0 60px;
    height: 60px;
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: none;
}

.exercise-content {
    flex: 1;
}

.exercise-tag {
    font-family: 'Montserrat', sans-serif; font-weight: 900;
    font-size: 1.1rem !important;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    display: inline-block;
    padding: 6px 12px;
    border: var(--comic-border);
    border-radius: var(--radius-sm);
    box-shadow: 2px 2px 0px var(--pure-black);
}

/* App Exercise Variant */
.exercise-app {
    border-left-width: 6px;
    border-left-color: var(--primary-container); /* Naranja */
}

.exercise-app .exercise-tag {
    background: var(--primary-container);
    color: var(--surface);
}

.exercise-app .exercise-icon-container {
    color: var(--primary-container);
}

/* Workbook Exercise Variant */
.exercise-workbook {
    border-left-width: 6px;
    border-left-color: var(--primary); /* Dorado */
}

.exercise-workbook .exercise-tag {
    background: var(--primary);
    color: var(--surface);
}

.exercise-workbook .exercise-icon-container {
    color: var(--primary);
}

.exercise-text {
    margin-bottom: 0;
    font-weight: 600 !important; 
    color: var(--on-surface-variant); /* Gris oscuro en lugar de blanco */
    font-size: 1.25rem !important;
    line-height: 1.6;
}

.exercise-icon-container svg, .workbook-icon svg {
    width: 24px;
    height: 24px;
    color: inherit;
}

/* Workbook Section Styling (Chapter Ends) */
.workbook-section {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: var(--comic-border);
}

.workbook-card {
    background: var(--surface-container);
    border: 3px solid var(--primary); /* Borde fuerte estilo cómic */
    border-radius: var(--radius-md);
    padding: 3rem;
    position: relative;
    overflow: hidden;
    box-shadow: 8px 8px 0px var(--pure-black); /* Sombra brutalista profunda */
    color: var(--on-surface);
}

.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.75rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--primary); /* Dorado Pop brillante */
    line-height: 1.6;
    /* text-transform: uppercase; removed */
}

.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;
}
.save-note {
    font-size: 0.7rem;
    color: var(--on-surface-variant);
    margin-top: 0.3rem;
    text-align: center;
}
/* 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;
    }

    

    /* 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 */
    

    .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;
    }
    .image-viewer-container.no-fade::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-panel {
        width: 100%;
        height: 100%;
        overflow: hidden !important;
        page-break-inside: auto !important;
        break-inside: auto !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: 100px 1rem 10rem; /* Increased space to reach the end without cuts */
        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: 1rem !important; letter-spacing: 1px !important; padding: 4px 8px !important; margin-bottom: 0.5rem !important; }

    .exercise-text { font-size: 1.1rem !important; line-height: 1.4 !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% - 120px); /* Adjusted for logo and burger */
        font-size: 0.7rem;
        letter-spacing: 0.5px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        padding: 0;
        margin: 0;
        z-index: 5;
    }

    .menu-toggle-btn {
        position: relative;
        z-index: 10;
    }

    .mobile-logo-header {
        display: block;
        height: 35px;
        width: auto;
        filter: drop-shadow(0 0 5px rgba(210, 174, 109, 0.3));
        position: relative;
        z-index: 10;
    }

    /* 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;
}

@page:first { margin: 0; } @page {
    size: A4;
    margin: 15mm 10mm;
}

@media print {

    

    html, body {
        height: auto !important;
        overflow: visible !important;
        background: white !important;
        margin: 0 !important;
        padding: 0 !important;
        font-family: 'Poppins', sans-serif !important;
    }

    /* Hide everything except print-view */
    body > *:not(#print-view) {
        display: none !important;
    }
    .app-container, .sidebar, .content-header, .header-actions, .progress-container, 

    #print-view {
        display: block !important;
        width: 100% !important;
        background: white !important;
        position: static !important;
    }

    #print-view * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* === PAGE STRUCTURE === */
    .print-page {
        /* removed page-break-after: always to allow flow */
        padding-top: 1px; padding-bottom: 1px;
        padding: 0;
        background: white !important;
    }
    .print-page:last-child {
        page-break-after: auto;
    }
    
    .print-body h1, .print-body h2, .print-body h3, .print-body ul, .print-body ol {
        overflow: hidden;
        list-style-position: inside;
    }

    /* === COVER PAGE === */
    .print-cover {
        width: 100%;
        height: 297mm;
        padding: 0;
        margin: 0;
        overflow: hidden;
    }
    .print-cover img {
        width: 210mm !important;
        height: 297mm !important;
        max-width: none !important;
        max-height: none !important;
        object-fit: cover;
        display: block;
    }

    /* === LATERAL SPLIT LAYOUT === */
    .print-split {
        display: block; /* use block for perfect pagination */
        width: 100%;
        page-break-inside: auto; /* Allow breaks so it doesn't create huge blank pages */
        padding: 0 15mm; /* increased padding */ /* Vertical padding handled by @page margin */
    }
    
    .print-split::after {
        content: "";
        display: table;
        clear: both;
    }

    .print-image-side {
        position: absolute;
        top: 0;
        left: 10mm;
        width: 28%;
    }
    .print-image-side img {
        width: 100% !important;
        max-height: 270mm !important;
        height: auto !important;
        object-fit: contain;
        object-position: top center;
        display: block;
    }
    
    /* Optional left fade to ensure no thin line on the left side either */
    .print-image-side::before {
        content: '';
        position: absolute;
        top: 0;
        left: -1px;
        width: 5px;
        height: 100%;
        background: #fff;
        pointer-events: none;
    }

    /* === FULL WIDTH TEXT (No Image) === */
    .print-full-width {
        padding: 0 20mm; /* Vertical padding handled by @page margin */
        width: 100%;
        page-break-inside: auto; /* Allow breaks */
    }

    .print-text-side {
        flex: 1;
        min-width: 0;
        padding-left: 8pt;
        padding-top: 2pt;
    }

    /* === TYPOGRAPHY === */
    .print-prefix {
        font-size: 8pt;
        font-weight: 700;
        color: #006d36 !important;
        /* text-transform: uppercase; removed */
        letter-spacing: 0.5pt;
        margin-bottom: 2pt;
    }

    .print-page h1,
    .print-full-width h1,
    .print-text-side h1 {
        font-family: 'Poppins', sans-serif !important;
        font-size: 14pt;
        margin: 0 0 6pt 0;
        border-bottom: 0.5pt solid #ddd;
        padding-bottom: 3pt;
        line-height: 1.2;
        color: #000 !important;
        /* removed page-break-after: avoid */
    }

    .print-page h2,
    .print-full-width h2,
    .print-text-side h2 { 
        font-family: 'Poppins', sans-serif !important;
        margin-top: 6pt !important; 
        margin-bottom: 2pt !important;
        font-size: 12pt !important; 
        line-height: 1.2 !important;
        color: #000 !important;
    }

    .print-page h3,
    .print-full-width h3,
    .print-text-side h3 {
        font-family: 'Poppins', sans-serif !important;
        font-size: 12pt;
        color: #000 !important;
        margin-bottom: 4pt;
        /* removed page-break-after: avoid */
    }

    .print-body,
    .print-body p,
    .print-page p,
    .print-page li,
    .print-full-width p,
    .print-full-width li,
    .print-text-side p,
    .print-text-side li { 
        font-family: 'Poppins', sans-serif !important;
        font-size: 12pt; 
        line-height: 1.35; 
        margin-bottom: 3pt;
        color: #000 !important;
        orphans: 1;
        widows: 1;
    }

    .print-body ul,
    .print-body ol {
        padding-left: 14pt;
        margin: 2pt 0;
    }

    
    /* Fix BFC and margins for boxes next to floats */
    .comic-bubble, .workbook-card, .comic-narrator-box {
        overflow: hidden !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        display: block !important;
        margin: 0.5rem 0 !important;
        padding: 0.8rem !important;
        width: auto !important;
        max-width: none !important;
    }

    /* === PREVENT CALLOUT BOXES FROM SPLITTING === */
    .print-page div[style*="border"],
    .print-page div[style*="background"] {
        page-break-inside: avoid !important;
    }

    /* Catch all styled callout/info boxes from ebook content */
    .exercise-box, .tax-partner, .highlight, .case-study, .alert-box, .portada-intro-container { page-break-inside: auto !important; break-inside: auto !important; }

    /* Compact callout boxes for print to prevent overflowing to next page */
    .exercise-box,
    .tax-partner,
    .highlight,
    .case-study,
    .alert-box {
        margin: 3pt 0 !important;
        padding: 4pt 6pt !important;
    }

    /* Fix Portada/Welcome heights to combine onto single page */
    .portada-intro-container {
        min-height: auto !important;
        padding-top: 0 !important;
        margin-bottom: 20pt;
    }
    .workbook-badge {
        margin-top: 15pt !important;
    }

    /* === INDEX STYLES FOR PRINT === */
    .print-body .index-grid {
        display: flex;
        flex-direction: column;
        gap: 3pt;
        margin-top: 5pt;
    }
    .print-body .index-card {
        padding: 3pt 0;
        border: none;
        border-bottom: 0.5pt solid #ddd;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
        page-break-inside: avoid;
    }
    .print-body .index-card-title {
        color: #000 !important;
        font-size: 8.5pt;
        display: flex;
        align-items: baseline;
    }
    .print-body .chapter-prefix {
        color: #006d36 !important;
        font-weight: 700;
        margin-right: 8pt;
        min-width: 50pt;
    }
    .print-body .chapter-desc {
        color: #333 !important;
        font-weight: normal;
    }

    /* === EXERCISES === */
    .print-exercises {
        margin-top: 8pt;
        padding: 6pt 10mm 6pt 10mm;
        border-top: 0.5pt dashed #999;
        page-break-inside: avoid;
    }
    .print-exercises h3 {
        font-size: 9pt;
        margin-bottom: 4pt;
        color: #d4af37 !important;
    }
    .print-exercise-label {
        font-weight: bold;
        font-size: 8pt;
        margin-bottom: 3pt;
        color: #000 !important;
    }
    .print-check-item {
        display: flex;
        align-items: center;
        gap: 6pt;
        margin-bottom: 2pt;
        font-size: 8pt;
        color: #000 !important;
    }
        pointer-events: none;
    }
    /* Optional left fade to ensure no thin line on the left side either */
    .print-image-side::before {
        content: '';
        position: absolute;
        top: 0;
        left: -1px;
        width: 5px;
        height: 100%;
        background: #fff;
        pointer-events: none;
    }

    /* === FULL WIDTH TEXT (No Image) === */
    .print-full-width {
        padding: 0 20mm; /* Vertical padding handled by @page margin */
        width: 100%;
        page-break-inside: auto; /* Allow breaks */
    }

    .print-text-side {
        display: block;
        margin-left: 30%;
        padding-top: 2pt;
    }

    /* === TYPOGRAPHY === */
    .print-prefix {
        font-size: 8pt;
        font-weight: 700;
        color: #006d36 !important;
        /* text-transform: uppercase; removed */
        letter-spacing: 0.5pt;
        margin-bottom: 2pt;
    }

    .print-page h1,
    .print-full-width h1,
    .print-text-side h1 {
        font-family: 'Poppins', sans-serif !important;
        font-size: 12pt;
        margin: 0 0 6pt 0;
        border-bottom: 0.5pt solid #ddd;
        padding-bottom: 3pt;
        line-height: 1.2;
        color: #000 !important;
        /* removed page-break-after: avoid */
    }

    .print-page h2,
    .print-full-width h2,
    .print-text-side h2 { 
        font-family: 'Poppins', sans-serif !important;
        margin-top: 6pt !important; 
        margin-bottom: 2pt !important;
        font-size: 12pt !important; 
        line-height: 1.2 !important;
        color: #000 !important;
    }

    .print-page h3,
    .print-full-width h3,
    .print-text-side h3 {
        font-family: 'Poppins', sans-serif !important;
        font-size: 12pt;
        color: #000 !important;
        margin-bottom: 4pt;
        /* removed page-break-after: avoid */
    }

    .print-body,
    .print-body p,
    .print-page p,
    .print-page li,
    .print-full-width p,
    .print-full-width li,
    .print-text-side p,
    .print-text-side li { 
        font-family: 'Poppins', sans-serif !important;
        font-size: 12pt; 
        line-height: 1.35; 
        margin-bottom: 3pt;
        color: #000 !important;
        orphans: 1;
        widows: 1;
    }

    .print-body ul,
    .print-body ol {
        padding-left: 14pt;
        margin: 2pt 0;
    }

    
    /* Fix BFC and margins for boxes next to floats */
    .comic-bubble, .workbook-card, .comic-narrator-box {
        overflow: hidden !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        display: block !important;
        margin: 0.5rem 0 !important;
        padding: 0.8rem !important;
        width: auto !important;
        max-width: none !important;
    }

    /* === PREVENT CALLOUT BOXES FROM SPLITTING === */
    .print-page div[style*="border"],
    .print-page div[style*="background"] {
        page-break-inside: avoid !important;
    }

    /* Catch all styled callout/info boxes from ebook content */
    .exercise-box, .tax-partner, .highlight, .case-study, .alert-box, .portada-intro-container { page-break-inside: auto !important; break-inside: auto !important; }

    /* Compact callout boxes for print to prevent overflowing to next page */
    .exercise-box,
    .tax-partner,
    .highlight,
    .case-study,
    .alert-box {
        margin: 3pt 0 !important;
        padding: 4pt 6pt !important;
    }

    /* Fix Portada/Welcome heights to combine onto single page */
    .portada-intro-container {
        min-height: auto !important;
        padding-top: 0 !important;
        margin-bottom: 20pt;
    }
    .workbook-badge {
        margin-top: 15pt !important;
    }

    /* === INDEX STYLES FOR PRINT === */
    .print-body .index-grid {
        display: flex;
        flex-direction: column;
        gap: 3pt;
        margin-top: 5pt;
    }
    .print-body .index-card {
        padding: 3pt 0;
        border: none;
        border-bottom: 0.5pt solid #ddd;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
        page-break-inside: avoid;
    }
    .print-body .index-card-title {
        color: #000 !important;
        font-size: 8.5pt;
        display: flex;
        align-items: baseline;
    }
    .print-body .chapter-prefix {
        color: #006d36 !important;
        font-weight: 700;
        margin-right: 8pt;
        min-width: 50pt;
    }
    .print-body .chapter-desc {
        color: #333 !important;
        font-weight: normal;
    }

    /* === EXERCISES === */
    .print-exercises {
        margin-top: 8pt;
        padding: 6pt 10mm 6pt 10mm;
        border-top: 0.5pt dashed #999;
        page-break-inside: avoid;
    }
    .print-exercises h3 {
        font-size: 9pt;
        margin-bottom: 4pt;
        color: #d4af37 !important;
    }
    .print-exercise-label {
        font-weight: bold;
        font-size: 8pt;
        margin-bottom: 3pt;
        color: #000 !important;
    }
    .print-check-item {
        display: flex;
        align-items: center;
        gap: 6pt;
        margin-bottom: 2pt;
        font-size: 8pt;
        color: #000 !important;
    }
    .print-answer {
        padding: 4pt 8pt;
        margin-bottom: 8pt;
        font-style: italic;
        font-size: 8pt;
        color: #333 !important;
        border-bottom: 0.5pt solid #ccc;
    }

    /* Fix CSS Grid pagination issues by converting to block */
    .responsive-grid {
        display: block !important;
        margin: 3pt 0 !important;
    }
    .responsive-grid > div {
        margin-bottom: 10pt !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}

/* Control Buttons Styling */
.control-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: var(--gold);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: var(--gold);
    color: black;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.save-note {
    font-size: 0.75rem;
    color: var(--on-surface-variant);
    margin-top: 0.5rem;
    text-align: center;
    opacity: 0.85;
}

@media print {

    
 .print-page { position: relative; } }
@media print {

    
 .portada-intro-container { padding-top: 0 !important; margin-top: 0 !important; min-height: auto !important; } .print-body div[style*='margin-top: 8rem'] { margin-top: 1rem !important; padding-bottom: 0 !important; } .print-page div[style*='background'], .print-page div[style*='padding'] { page-break-inside: auto !important; } }

/* Comic Bubble & Stylings */
.comic-bubble {
    position: relative;
    background: #ffffff;
    border: 3px solid var(--pure-black);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 6px 6px 0px var(--primary);
    color: var(--pure-black);
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    margin-top: 2rem;
    font-size: 1.1rem;
    transform: rotate(-1deg);
}

.comic-bubble::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 40px;
    border-width: 20px 20px 0 0;
    border-style: solid;
    border-color: #ffffff transparent transparent transparent;
    z-index: 2;
}

.comic-bubble::before {
    content: '';
    position: absolute;
    bottom: -24px;
    left: 38px;
    border-width: 24px 24px 0 0;
    border-style: solid;
    border-color: var(--pure-black) transparent transparent transparent;
    z-index: 1;
}

.comic-bubble-title {
    font-family: 'Luckiest Guy', cursive, 'Montserrat', sans-serif;
    font-size: 2rem;
    color: var(--primary-container);
    /* text-transform: uppercase; removed */
    margin-bottom: 1rem;
    text-shadow: 2px 2px 0px var(--pure-black);
    letter-spacing: 2px;
}

.comic-greeting {
    font-family: 'Luckiest Guy', cursive, 'Montserrat', sans-serif;
    font-size: 5rem;
    color: var(--primary);
    /* text-transform: uppercase; removed */
    text-shadow: 4px 4px 0px var(--pure-black);
    margin-bottom: 1.5rem;
    letter-spacing: 3px;
    transform: rotate(-2deg);
    display: inline-block;
}

.comic-paragraph {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--pure-black);
    line-height: 1.7;
    background: var(--surface-container-high);
    padding: 1.5rem;
    border-left: 6px solid var(--primary-container);
    border-radius: 0 12px 12px 0;
    box-shadow: 3px 3px 0px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

/* === RESPONSIVE DESIGN (MOBILE & TABLET) === */

/* Hamburguer Menu Icon for Mobile */


#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 80;
}
#sidebar-overlay.active {
    display: block;
}

@media (max-width: 900px) {
    
    
    .content-header {
        padding-top: 45px !important; /* Make room for the floating menu button */
    }
    
    /* Keep layout SIDE-BY-SIDE as requested, but optimize ratios */
    .split-layout,
    .split-layout.comic-mode {
        display: flex !important;
        flex-direction: row !important;
        height: auto !important;
        min-height: 100vh !important;
        overflow-x: hidden !important;
    }
    
    /* Image panel takes up 25% of screen width */
    .split-layout.comic-mode .image-viewer-container,
    .image-viewer-container {
        max-width: 25% !important;
        width: 25% !important;
        flex: 1 !important;
        height: auto !important; /* Let it flow down */
        min-height: 100vh !important;
        border-right: 4px solid var(--pure-black) !important;
        border-bottom: none !important;
        padding: 0.5rem !important; /* Minimal padding */
    }
    
    .split-layout.comic-mode .image-panel img {
        width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
    }
    
    /* Text panel takes up 75% of screen width */
    .split-layout.comic-mode .text-panel,
    .text-panel {
        max-width: 75% !important;
        width: 75% !important;
        flex: 3 !important;
        padding: 1.5rem 1rem 5rem 1rem !important; /* Tight horizontal padding */
        overflow-y: auto !important;
    }
    
    /* Sidebar */
    .sidebar {
        position: fixed !important;
        left: -100% !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 85% !important;
        max-width: 350px !important;
        z-index: 90 !important;
        transition: left 0.3s ease !important;
        box-shadow: 10px 0 20px rgba(0,0,0,0.5) !important;
    }
    
    .sidebar.open {
        left: 0 !important;
    }
    
    /* Typography adjustments to fit in the 75% column gracefully */
    h1.comic-title,
    .comic-header,
    .comic-greeting {
        font-size: 1.35rem !important; /* Much smaller for mobile readability */
        line-height: 1.1 !important;
        text-shadow: 2px 2px 0px var(--pure-black) !important; /* Thinner stroke/shadow */
        letter-spacing: 0px !important;
    }
    
    h2.comic-subtitle {
        font-size: 1.2rem !important;
    }
    
    .index-card {
        margin-left: 0 !important; 
        padding: 0.8rem !important;
    }
    
    .comic-paragraph {
        font-size: 0.95rem !important; /* Slightly smaller text */
        padding: 0.8rem !important;
    }
    
    .exercise-text { font-size: 1.1rem !important; }
    
    .workbook-card {
        padding: 1.5rem !important;
    }
}

/* === ULTRA RUTHLESS MOBILE OVERRIDES === */
@media (max-width: 900px) {
    /* 1. Header Layout for Hamburger and Logo */
    .content-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 10px 15px !important;
        background: var(--surface) !important;
        border-bottom: 2px solid var(--pure-black) !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 100 !important;
        width: 100% !important;
    }
    
    .menu-toggle-btn {
        display: block !important;
        background: transparent !important;
        border: none !important;
        color: var(--pure-black) !important;
        font-size: 2rem !important;
        padding: 0 !important;
        box-shadow: none !important;
        margin: 0 !important;
    }
    
    .mobile-logo-header {
        display: block !important;
        height: 55px !important;
        width: auto !important;
        margin: 0 auto !important;
    }
    
    .chapter-title-display {
        display: none !important; /* Hide to save space */
    }

    /* 2. Fix the inline styles of the "DEJA DE SER ESCLAVO" hook and all headers */
    h1, h2, h3, h4, .comic-header, .comic-greeting, .comic-title,
    div[style*="font-size: 3.8rem"] h1, 
    .text-panel h1, .text-panel h2 {
        font-size: 1.5rem !important;
        line-height: 1.1 !important;
        text-shadow: none !important; font-weight: normal !important;
        letter-spacing: 0 !important;
        -webkit-text-stroke: 0px !important; /* Remove any thick borders */
    }
    
    /* Specifically target that huge red "ESCLAVO" span */
    .text-panel h1 span[style*="font-size: 1.3rem"] {
        font-size: 1rem !important; text-shadow: none !important;
    }
    
    .text-panel p, .comic-paragraph { font-size: 1rem !important; line-height: 1.4 !important; padding: 0.5rem !important; }
    .exercise-text { font-size: 1.1rem !important; line-height: 1.4 !important; }
    
    .text-panel {
        padding-top: 1rem !important;
    }
    
    /* Ensure navigation buttons are fixed at the bottom */
    .header-actions {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: var(--surface) !important;
        border-top: 3px solid var(--pure-black) !important;
        padding: 10px 15px !important;
        justify-content: space-between !important;
        z-index: 1000 !important;
    }
    
    .btn-nav {
        flex: 1 !important;
        margin: 0 5px !important;
        font-size: 0.9rem !important;
        padding: 10px !important;
    }
}

@media print {

    
 .index-grid { page-break-inside: auto !important; break-inside: auto !important; display: block !important; } }

@media print {

    h1, h2, h3, h4, .comic-header, .print-prefix {
        page-break-after: avoid !important;
        break-after: avoid !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

}

@media print {
    .print-comic-chapter {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        margin-bottom: 2rem;
    }
}





@media print {
    /* RESTORE ORIGINAL FLEXBOX BEHAVIOR */
    .exercise-box {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
}


@media print {
    /* FORCE EXERCISE BOX TEXT SIZES FOR PRINT */
    .exercise-tag {
        font-size: 1.1rem !important;
        padding: 6px 12px !important;
    }
    .exercise-text {
        font-size: 1.25rem !important;
        font-weight: 600 !important;
    }
}
