* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #FF6B6B;
    --secondary: #4ECDC4;
    --accent: #FFE66D;
    --safe: #95E1D3;
    --dark: #2C3E50;
    --light: #ECF0F1;
    --shadow: rgba(0, 0, 0, 0.15);
}

/* PART 7: GPU Acceleration and Performance Optimization */
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
    transform: translate3d(0, 0, 0); /* GPU acceleration */
}

body {
    font-family: 'Comic Sans MS', 'Arial Rounded MT Bold', cursive, sans-serif;
    background: linear-gradient(135deg, #FF6B9D 0%, #4ECDC4 50%, #FFE66D 100%);
    min-height: 100vh;
    font-size: 16px;
    color: var(--dark);
    /* PART 5: Ensure no extra space from body */
    margin: 0;
    padding: 0;
    position: relative;
}

body.night-mode {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
}

/* Hamburger Menu - BIG for kids */
/* Premium Hamburger Menu */
#hamburgerMenu.menu-btn {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 56px;
    height: 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    background: white;
    border: 2px solid var(--primary);
    border-radius: 12px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.2);
    padding: 0;
}

#hamburgerMenu.menu-btn:hover {
    background: var(--primary);
    box-shadow: 0 8px 28px rgba(255, 107, 107, 0.35);
    transform: translateY(-3px);
}

#hamburgerMenu.menu-btn:active {
    transform: scale(0.97);
}

#hamburgerMenu.menu-btn span {
    width: 26px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: center;
}

#hamburgerMenu.menu-btn:hover span {
    background: white;
}

#hamburgerMenu.menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(10px, 10px);
}

#hamburgerMenu.menu-btn.active span:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

#hamburgerMenu.menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Premium Icon Buttons */
.icon-btn {
    background: white;
    border: 2px solid var(--primary);
    width: 52px;
    height: 52px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    color: var(--primary);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.icon-btn:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 8px 20px rgba(255, 107, 107, 0.25);
    transform: translateY(-2px);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* Zoom Display */
.zoom-display {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 15px;
    border: 2px solid white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 70px;
    text-align: center;
}

/* PART 2: PINCH ZOOM - Visual feedback indicator */
#pinchIndicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 107, 107, 0.9);
    color: white;
    padding: 18px 28px;
    border-radius: 14px;
    font-size: 20px;
    font-weight: bold;
    z-index: 2000;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.4);
    border: 3px solid white;
    animation: pinchPulse 0.4s ease-out;
}

@keyframes pinchPulse {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* PART 3: MOBILE SLIDE/FLIP - Swipe animation feedback */
@keyframes swipeArrow {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(80px) scale(0.5);
    }
}

/* PART 3: MOBILE SLIDE/FLIP - Button tap feedback */
@keyframes buttonTap {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.92);
    }
    100% {
        transform: scale(1);
    }
}

/* TOP BAR */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border-bottom: 3px solid var(--accent);
    margin: 0;
}

.top-bar-left, .top-bar-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

body.night-mode .top-bar {
    background: linear-gradient(135deg, #2C3E50 0%, #1a1a2e 100%);
    border-bottom-color: #FFE66D;
}

/* Sidebar Header */
.sidebar-header {
    padding: 18px;
    text-align: center;
    border-bottom: 3px solid white;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-header h3 {
    color: white;
    font-size: 24px;
    margin: 0;
    font-weight: 900;
    letter-spacing: 1px;
}

/* PART 6: Sections list scrollable container */
#sectionsList {
    padding: 12px 0;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    overflow-x: hidden;
}

#sectionsList::-webkit-scrollbar {
    width: 8px;
}

#sectionsList::-webkit-scrollbar-track {
    background: rgba(255, 107, 107, 0.1);
    border-radius: 4px;
}

#sectionsList::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 4px;
    transition: all 0.3s ease;
}

#sectionsList::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
    width: 12px;
}

body.night-mode #sectionsList::-webkit-scrollbar-track {
    background: rgba(78, 205, 196, 0.1);
}

body.night-mode #sectionsList::-webkit-scrollbar-thumb {
    background: var(--secondary);
}

body.night-mode #sectionsList::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* Settings Header */
.settings-header {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 14px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

.settings-header h3 {
    color: white;
    font-size: 22px;
    margin: 0;
    font-weight: 900;
    letter-spacing: 0.5px;
}

/* Close Button */
.close-btn {
    background: var(--accent);
    border: 3px solid white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 910;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.close-btn:hover {
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Bottom Bar */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    border-top: 2px solid white;
    margin: 0;
}

body.night-mode .bottom-bar {
    background: linear-gradient(135deg, #2C3E50 0%, #1a1a2e 100%);
    border-top-color: var(--accent);
}

/* Button Groups */
.btn-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-group button {
    background: white;
    border: 2px solid var(--primary);
    width: 54px;
    height: 54px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-group button:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.3);
    transform: translateY(-3px);
}

.btn-group button:active {
    transform: scale(0.94);
}

/* Slider Container */
.slider-container {
    flex: 1;
    margin: 0 12px;
    position: relative;
}

#pageSlider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.6));
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

#pageSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#pageSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--primary);
    cursor: pointer;
}

#progressBar {
    position: absolute;
    bottom: -6px;
    left: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 1px;
    width: 0%;
}

/* Sidebar */

#sidebar {
    position: fixed;
    left: -320px;
    top: 0;
    width: 320px;
    height: 100vh;
    background: white;
    box-shadow: 4px 0 25px var(--shadow);
    z-index: 999;
    transition: left 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow-y: auto;
    border-right: 4px solid var(--primary);
    /* PART 7: GPU acceleration for smooth sidebar sliding */
    will-change: left;
    transform: translate3d(0, 0, 0);
}

body.night-mode #sidebar {
    background: #1a1a2e;
    color: white;
    border-right-color: var(--secondary);
}

#sidebar.active {
    left: 0;
}

.sidebar-header {
    padding: 22px;
    border-bottom: 4px solid var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

body.night-mode .sidebar-header {
    background: #16213e;
    border-bottom-color: var(--secondary);
}

.sidebar-header h2 {
    font-size: 24px;
    color: var(--primary);
    font-weight: bold;
}

body.night-mode .sidebar-header h2 {
    color: var(--secondary);
}

.close-btn {
    background: var(--primary);
    color: white;
    border: none;
    font-size: 32px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-weight: bold;
}

.close-btn:hover {
    background: var(--secondary);
    transform: scale(1.15);
}

.sections-list {
    padding: 15px 0;
}

.section-item {
    padding: 16px 18px;
    margin: 10px;
    cursor: pointer;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 2px solid transparent;
    border-radius: 12px;
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.section-title {
    font-size: 17px;
    font-weight: 900;
    color: var(--primary);
    margin-bottom: 6px;
    letter-spacing: 0.5px;
}

.section-pages {
    font-size: 12px;
    color: var(--secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

body.night-mode .section-item {
    background: #2a2a3e;
    border-color: transparent;
}

body.night-mode .section-title {
    color: var(--accent);
}

body.night-mode .section-pages {
    color: var(--secondary);
}

.section-item:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-color: white;
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.28);
    transform: translateX(8px) translateY(-2px);
    border-width: 2px;
}

.section-item:hover .section-title {
    color: white;
}

.section-item:hover .section-pages {
    color: rgba(255, 255, 255, 0.9);
}

.section-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-color: white;
    border-width: 2px;
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.3);
    color: white;
    border-color: var(--primary);
    font-weight: bold;
}

/* PART 6: CHAPTER MENU - Section group styles */
.section-group-heading {
    padding: 16px 18px;
    margin: 12px 10px 0 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 12px 12px 0 0;
    border-bottom: 2px solid var(--accent);
    transition: all 0.3s ease;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

body.night-mode .section-group-heading {
    background: linear-gradient(135deg, #2a2a3e 0%, #3a3a4e 100%);
    border-bottom-color: var(--secondary);
}

.section-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.section-toggle {
    font-size: 14px;
    color: white;
    transition: transform 0.3s ease;
    font-weight: bold;
    min-width: 16px;
}

.section-group-icon {
    font-size: 20px;
}

.section-group-name {
    font-size: 16px;
    font-weight: bold;
    color: white;
    letter-spacing: 0.5px;
}

/* PART 6: Chapters list container */
.chapters-list {
    background: white;
    border: 1px solid rgba(255, 107, 107, 0.2);
    border-radius: 0 0 12px 12px;
    margin: 0 10px 8px 10px;
    max-height: 1000px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

body.night-mode .chapters-list {
    background: #1a1a2e;
    border-color: rgba(78, 205, 196, 0.2);
}

.chapters-list.expanded {
    max-height: 1000px;
    opacity: 1;
}

.chapters-list:not(.expanded) {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0 10px 0 10px;
}

/* PART 6: Individual chapter items */
.chapter-item {
    padding: 12px 18px;
    border-left: 4px solid transparent;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

body.night-mode .chapter-item {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

.chapter-item:hover {
    background: rgba(255, 107, 107, 0.08);
    border-left-color: var(--primary);
    padding-left: 22px;
}

body.night-mode .chapter-item:hover {
    background: rgba(78, 205, 196, 0.08);
    border-left-color: var(--secondary);
}

.chapter-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    flex: 1;
}

body.night-mode .chapter-name {
    color: var(--secondary);
}

.chapter-pages {
    font-size: 11px;
    color: #999;
    font-weight: 500;
    letter-spacing: 0.5px;
    margin-left: 12px;
    white-space: nowrap;
}

body.night-mode .chapter-pages {
    color: #aaa;
}

/* Settings Panel */
#settingsPanel {
    position: fixed;
    right: -360px;
    top: 0;
    width: 360px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 25px var(--shadow);
    z-index: 999;
    transition: right 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    overflow-y: auto;
    border-left: 4px solid var(--secondary);
}

body.night-mode #settingsPanel {
    background: #1a1a2e;
    color: white;
    border-left-color: var(--primary);
}

#settingsPanel.active {
    right: 0;
}

.settings-header {
    padding: 22px;
    border-bottom: 4px solid var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

body.night-mode .settings-header {
    background: #16213e;
    border-bottom-color: var(--secondary);
}

.settings-header h3 {
    font-size: 20px;
    color: var(--primary);
    font-weight: bold;
}

body.night-mode .settings-header h3 {
    color: var(--secondary);
}

.settings-content {
    padding: 20px;
}

.setting-group {
    margin-bottom: 22px;
    background: #f9f9f9;
    padding: 14px;
    border-radius: 10px;
    border: 2px solid var(--accent);
}

body.night-mode .setting-group {
    background: #333;
    border-color: var(--secondary);
}

.setting-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: var(--dark);
    font-size: 16px;
}

body.night-mode .setting-group label {
    color: white;
}

.setting-group input[type="range"] {
    width: 100%;
    height: 8px;
    cursor: pointer;
    accent-color: var(--primary);
    border-radius: 5px;
}

.setting-group input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--primary);
    margin-right: 10px;
}

.setting-group span {
    font-size: 14px;
    color: var(--primary);
    margin-left: 10px;
    font-weight: bold;
}

.button-group {
    display: flex;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    padding: 12px;
    border: 3px solid var(--primary);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    font-weight: bold;
}

body.night-mode .mode-btn {
    background: #333;
    border-color: var(--secondary);
    color: white;
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: scale(1.05);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    border: 4px solid var(--primary);
}

body.night-mode .modal-content {
    background: #1a1a2e;
    color: white;
    border-color: var(--secondary);
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 22px;
    border-bottom: 3px solid var(--accent);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 22px;
    color: var(--primary);
    font-weight: bold;
}

body.night-mode .modal-header h3 {
    color: var(--secondary);
}

.search-input {
    width: 100%;
    padding: 14px;
    margin: 12px;
    border: 3px solid var(--primary);
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
}

body.night-mode .search-input {
    background: #333;
    border-color: var(--secondary);
    color: white;
}

.search-input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.search-results {
    padding: 12px;
}

.bookmarks-list {
    padding: 12px;
}

.bookmark-item, .search-result {
    padding: 14px;
    margin-bottom: 10px;
    background: #f0f0f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
    font-weight: 600;
}

body.night-mode .bookmark-item,
body.night-mode .search-result {
    background: #333;
    color: white;
}

.bookmark-item:hover, .search-result:hover {
    background: var(--accent);
    transform: translateX(6px);
    border-color: var(--primary);
}

/* Overlay */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

#overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Main Container */
.container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    padding-top: 70px;
    padding-bottom: 100px;
}

/* Controls - BIG for kids! */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: white;
    border-radius: 12px;
    margin: 10px 12px;
    box-shadow: 0 4px 15px var(--shadow);
    gap: 10px;
    border: 3px solid var(--primary);
}

body.night-mode .controls {
    background: #1a1a2e;
    border-color: var(--secondary);
}

.controls-left, .controls-center, .controls-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.controls-center {
    flex: 1;
    justify-content: center;
}

.control-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: 3px solid white;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px var(--shadow);
    flex-shrink: 0;
    font-weight: bold;
}

.control-btn:hover {
    transform: translateY(-4px) scale(1.08);
    box-shadow: 0 6px 15px var(--shadow);
}

.control-btn:active {
    transform: translateY(-1px) scale(0.98);
}

.zoom-level {
    font-size: 14px;
    font-weight: bold;
    color: var(--primary);
    min-width: 50px;
    text-align: center;
}

body.night-mode .zoom-level {
    color: var(--secondary);
}

/* Loading Bar */
#loadingBar {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    height: 4px;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--secondary));
    transition: width 0.3s ease;
    z-index: 999;
    border-radius: 0;
    /* PART 5: Ensure loading bar doesn't affect layout */
    margin: 0;
    padding: 0;
}

#loadingBar.active {
    animation: loadingPulse 2s infinite;
}

@keyframes loadingPulse {
    0% { width: 0%; opacity: 1; }
    25% { opacity: 0.8; }
    50% { opacity: 1; }
    75% { opacity: 0.8; }
    100% { width: 100%; opacity: 1; }
}

.loading-bar {
    position: absolute;
    top: 65px;
    left: 0;
    height: 5px;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent), var(--secondary));
    transition: width 0.3s ease;
    z-index: 100;
    border-radius: 3px;
}

.loading-bar.active {
    animation: loading 2s infinite;
}

@keyframes loading {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Flipbook Wrapper */
.flipbook-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 15px;
    perspective: 1500px;
}

.flipbook {
    position: relative;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
    border: 4px solid var(--primary);
}

body.night-mode .flipbook {
    background: #333;
}

.book-spine {
    position: absolute;
    left: 50%;
    width: 3px;
    height: 100%;
    background: linear-gradient(to bottom, #888, #333, #888);
    z-index: 10;
    transform: translateX(-1.5px);
    box-shadow: inset -3px 0 10px rgba(0, 0, 0, 0.4);
}

#pagesContainer {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 64px;
    width: 100%;
    height: calc(100vh - 124px);
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
    touch-action: none; /* PART 2: Prevent default browser pinch zoom */
    perspective: 1200px; /* PART 4: Add 3D perspective for realistic book flip */
    /* PART 5: Proper centering and spacing */
    padding: 0;
    margin: 0;
    background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
    overflow: hidden;
    /* PART 7: GPU acceleration for smooth rendering */
    will-change: transform;
    backface-visibility: hidden;
}

.page {
    position: absolute;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    opacity: 0;
    z-index: 1;
    transform-style: preserve-3d;
    user-select: none;
    -webkit-user-select: none;
    /* PART 4: Better perspective origin for realistic book flip */
    transform-origin: right center;
    /* PART 4: Add subtle shadow during flip for depth */
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
    backface-visibility: hidden;
    /* PART 5: Ensure proper sizing and centering */
    padding: 0;
    margin: 0;
    border: none;
    overflow: hidden;
    /* PART 7: GPU acceleration for flip animations */
    will-change: transform, opacity;
}

body.night-mode .page {
    background: #333;
    filter: brightness(0.9);
}

.page.active {
    opacity: 1;
    z-index: 100;
    animation: pageFlipIn var(--flip-speed, 500ms) cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    transform: rotateY(0deg);
}

.page.prev-visible {
    opacity: 0;
    z-index: 50;
}

.page.next-visible {
    opacity: 0;
    z-index: 49;
}

@keyframes pageFlipIn {
    0% {
        transform: rotateY(85deg) rotateZ(-5deg) scaleX(0.9) scaleY(0.95);
        opacity: 0;
        filter: brightness(0.85);
    }
    30% {
        opacity: 0.5;
        filter: brightness(0.90);
    }
    50% {
        transform: rotateY(35deg) scaleX(0.98);
        opacity: 0.8;
        filter: brightness(0.95);
    }
    80% {
        transform: rotateY(5deg) scaleX(0.99);
        opacity: 1;
        filter: brightness(0.98);
    }
    100% {
        transform: rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1);
        opacity: 1;
        filter: brightness(1);
    }
}

@keyframes pageFlipOut {
    0% {
        transform: rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1);
        opacity: 1;
        filter: brightness(1);
    }
    20% {
        transform: rotateY(-25deg) scaleX(0.99);
        opacity: 0.9;
        filter: brightness(0.98);
    }
    50% {
        transform: rotateY(-50deg) scaleX(0.95);
        opacity: 0.6;
        filter: brightness(0.90);
    }
    100% {
        transform: rotateY(-95deg) rotateZ(5deg) scaleX(0.8) scaleY(0.95);
        opacity: 0;
        filter: brightness(0.75);
    }
}

@keyframes pageFlipInBack {
    0% {
        transform: rotateY(-85deg) rotateZ(5deg) scaleX(0.9) scaleY(0.95);
        opacity: 0;
        filter: brightness(0.85);
    }
    30% {
        opacity: 0.5;
        filter: brightness(0.90);
    }
    50% {
        transform: rotateY(-35deg) scaleX(0.98);
        opacity: 0.8;
        filter: brightness(0.95);
    }
    80% {
        transform: rotateY(-5deg) scaleX(0.99);
        opacity: 1;
        filter: brightness(0.98);
    }
    100% {
        transform: rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1);
        opacity: 1;
        filter: brightness(1);
    }
}

@keyframes pageFlipOutBack {
    0% {
        transform: rotateY(0deg) rotateZ(0deg) scaleX(1) scaleY(1);
        opacity: 1;
        filter: brightness(1);
    }
    20% {
        transform: rotateY(25deg) scaleX(0.99);
        opacity: 0.9;
        filter: brightness(0.98);
    }
    50% {
        transform: rotateY(50deg) scaleX(0.95);
        opacity: 0.6;
        filter: brightness(0.90);
    }
    100% {
        transform: rotateY(95deg) rotateZ(-5deg) scaleX(0.8) scaleY(0.95);
        opacity: 0;
        filter: brightness(0.75);
    }
}

.page canvas {
    max-width: 95%;
    max-height: 98%;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-select: none;
    /* PART 4: Combine page filter with subtle drop shadow for depth */
    filter: var(--page-filter, brightness(1) contrast(1)) drop-shadow(0 4px 12px rgba(0, 0, 0, 0.08));
    border-radius: 0;
    /* PART 5: Ensure canvas is properly centered and sized */
    display: block;
    margin: auto;
}

/* PART 4: REALISTIC FLIP SHADOW - Simulate page depth and curl */
.page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(0, 0, 0, 0.03) 50%,
        transparent 100%
    );
    pointer-events: none;
    opacity: 0;
    z-index: 2;
}

.page::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 8px;
    background: linear-gradient(
        to right,
        transparent,
        rgba(0, 0, 0, 0.15)
    );
    pointer-events: none;
    z-index: 1;
}

/* Flip Shadow */
.flip-shadow {
    position: absolute;
    left: 50%;
    top: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.4));
    z-index: 500;
    pointer-events: none;
    transform-origin: left;
    transition: width 0.3s ease;
}

/* Reading Progress */
.reading-progress {
    position: fixed;
    bottom: 102px;
    left: 15px;
    right: 15px;
    height: 4px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 3px;
    z-index: 100;
    overflow: hidden;
    border: 2px solid var(--primary);
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    width: 0%;
    transition: width 0.3s ease;
}

/* Bottom Controls - BIGGER for kids! */
.bottom-controls {
    position: fixed;
    bottom: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    background: white;
    padding: 14px 16px;
    border-radius: 12px;
    box-shadow: 0 6px 20px var(--shadow);
    z-index: 100;
    border: 3px solid var(--primary);
}

body.night-mode .bottom-controls {
    background: #1a1a2e;
    border-color: var(--secondary);
}

.nav-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: 3px solid white;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px var(--shadow);
    flex-shrink: 0;
    font-weight: bold;
}

.nav-btn:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 6px 15px var(--shadow);
}

.nav-btn:active {
    transform: translateY(-2px) scale(0.95);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-slider {
    flex: 1;
    display: flex;
    align-items: center;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

body.night-mode .slider {
    background: #555;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 3px solid white;
}

.slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.page-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-weight: bold;
    min-width: 90px;
    justify-content: center;
    font-size: 15px;
}

body.night-mode .page-info {
    color: var(--secondary);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 115px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark);
    color: white;
    padding: 14px 24px;
    border-radius: 10px;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    font-size: 14px;
    font-weight: bold;
    border: 2px solid var(--primary);
}

.toast.show {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive for tablets */
@media (max-width: 1024px) {
    .container {
        padding-top: 65px;
        padding-bottom: 90px;
    }

    .controls {
        margin: 8px 10px;
        padding: 10px 12px;
    }

    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .nav-btn {
        width: 44px;
        height: 44px;
    }
}

/* Mobile responsive */
@media (max-width: 768px) {
    .container {
        padding-top: 60px;
        padding-bottom: 85px;
    }

    .controls {
        margin: 8px 8px;
        padding: 8px 10px;
        gap: 6px;
    }

    .controls-left, .controls-right {
        display: none;
    }

    .controls-center {
        width: 100%;
    }

    .control-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .bottom-controls {
        gap: 10px;
        padding: 12px 14px;
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .nav-btn {
        width: 42px;
        height: 42px;
    }

    .page-info {
        min-width: 80px;
        font-size: 13px;
    }

    .settings-panel {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .hamburger-menu {
        width: 46px;
        height: 46px;
        border-width: 2px;
    }

    .container {
        padding-top: 55px;
        padding-bottom: 80px;
    }

    .controls {
        margin: 6px 6px;
        padding: 6px 8px;
        gap: 4px;
    }

    .flipbook-wrapper {
        padding: 6px;
    }

    .bottom-controls {
        gap: 8px;
        padding: 10px 12px;
        left: 8px;
        right: 8px;
        bottom: 8px;
    }

    .nav-btn {
        width: 40px;
        height: 40px;
    }

    .control-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

body.night-mode {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

/* Hamburger Menu */
.hamburger-menu {
    position: fixed;
    top: 15px;
    left: 15px;
    width: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--shadow);
    border: none;
}

.hamburger-menu:hover {
    background: white;
    box-shadow: 0 4px 12px var(--shadow);
    transform: scale(1.05);
}

.hamburger-menu span {
    width: 24px;
    height: 3px;
    background: var(--dark);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-menu.active span:nth-child(1) {
    transform: rotate(45deg) translate(10px, 10px);
}

.hamburger-menu.active span:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* Sidebar Navigation */
.sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    width: 300px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 20px var(--shadow);
    z-index: 999;
    transition: left 0.3s ease;
    overflow-y: auto;
}

body.night-mode .sidebar {
    background: #1a1a1a;
    color: white;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

body.night-mode .sidebar-header {
    background: #252525;
    border-bottom-color: #444;
}

.sidebar-header h2 {
    font-size: 18px;
    color: var(--dark);
}

body.night-mode .sidebar-header h2 {
    color: white;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: var(--primary);
    transform: scale(1.2);
}

.sections-list {
    padding: 10px 0;
}

.section-item {
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
    color: #555;
    font-size: 14px;
}

body.night-mode .section-item {
    color: #bbb;
}

.section-item:hover {
    background: #f5f5f5;
    border-left-color: var(--primary);
    color: var(--primary);
}

body.night-mode .section-item:hover {
    background: #333;
}

.section-item.active {
    background: #f0f4ff;
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

body.night-mode .section-item.active {
    background: #2a3a5a;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    right: -350px;
    top: 0;
    width: 350px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 20px var(--shadow);
    z-index: 999;
    transition: right 0.3s ease;
    overflow-y: auto;
}

body.night-mode .settings-panel {
    background: #1a1a1a;
    color: white;
}

.settings-panel.active {
    right: 0;
}

.settings-header {
    padding: 20px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

body.night-mode .settings-header {
    background: #252525;
    border-bottom-color: #444;
}

.settings-content {
    padding: 20px;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
    font-size: 13px;
}

body.night-mode .setting-group label {
    color: white;
}

.setting-group input[type="range"] {
    width: 100%;
    cursor: pointer;
    accent-color: var(--primary);
}

.setting-group input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    accent-color: var(--primary);
}

.setting-group span {
    font-size: 12px;
    color: #888;
    margin-left: 10px;
}

.button-group {
    display: flex;
    gap: 10px;
}

.mode-btn {
    flex: 1;
    padding: 8px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 12px;
    font-weight: 600;
}

body.night-mode .mode-btn {
    background: #333;
    border-color: #555;
    color: white;
}

.mode-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
}

body.night-mode .modal-content {
    background: #1a1a1a;
    color: white;
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

body.night-mode .modal-header {
    border-bottom-color: #333;
}

.modal-header h3 {
    font-size: 18px;
    color: var(--dark);
}

body.night-mode .modal-header h3 {
    color: white;
}

.search-input {
    width: 100%;
    padding: 12px;
    margin: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

body.night-mode .search-input {
    background: #333;
    border-color: #555;
    color: white;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-results {
    padding: 12px;
}

.bookmarks-list {
    padding: 12px;
}

.bookmark-item, .search-result {
    padding: 12px;
    margin-bottom: 8px;
    background: #f5f5f5;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

body.night-mode .bookmark-item,
body.night-mode .search-result {
    background: #333;
}

.bookmark-item:hover, .search-result:hover {
    background: #f0f0f0;
    transform: translateX(4px);
}

body.night-mode .bookmark-item:hover,
body.night-mode .search-result:hover {
    background: #444;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Main Container */
.container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    padding-top: 60px;
    padding-bottom: 90px;
}

/* Controls */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    margin: 10px 15px;
    box-shadow: 0 2px 8px var(--shadow);
    gap: 10px;
}

body.night-mode .controls {
    background: rgba(30, 30, 30, 0.95);
}

.controls-left, .controls-center, .controls-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

.controls-center {
    flex: 1;
    justify-content: center;
}

.control-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.control-btn:active {
    transform: translateY(0);
}

.zoom-level {
    font-size: 12px;
    font-weight: 600;
    color: var(--dark);
    min-width: 45px;
    text-align: center;
}

body.night-mode .zoom-level {
    color: white;
}

/* Loading Bar */
.loading-bar {
    position: absolute;
    top: 55px;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.3s ease;
    z-index: 100;
}

.loading-bar.active {
    animation: loading 2s infinite;
}

@keyframes loading {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Flipbook Wrapper */
.flipbook-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 15px;
    perspective: 1200px;
}

.flipbook {
    position: relative;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 8px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
}

body.night-mode .flipbook {
    background: #2a2a2a;
}

.book-spine {
    position: absolute;
    left: 50%;
    width: 3px;
    height: 100%;
    background: linear-gradient(to bottom, #ddd, #666, #ddd);
    z-index: 10;
    transform: translateX(-1.5px);
    box-shadow: inset -2px 0 8px rgba(0, 0, 0, 0.2);
}

body.night-mode .book-spine {
    background: linear-gradient(to bottom, #444, #111, #444);
}

.pages-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
}

.page {
    position: absolute;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    opacity: 0;
    z-index: 1;
    transform-style: preserve-3d;
    user-select: none;
    -webkit-user-select: none;
}

body.night-mode .page {
    background: #333;
    filter: brightness(0.9);
}

.page.active {
    opacity: 1;
    z-index: 100;
    animation: pageFlipIn var(--flip-speed, 400ms) cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.page.prev-visible {
    opacity: 0.7;
    z-index: 50;
    transform: rotateY(95deg);
    transform-origin: left center;
    animation: pageFlipOut var(--flip-speed, 400ms) ease-out forwards;
}

.page.next-visible {
    opacity: 0.7;
    z-index: 49;
    transform: rotateY(-95deg);
    transform-origin: right center;
}

.page canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-select: none;
    filter: var(--page-filter, none);
}

/* Flip Shadow */
.flip-shadow {
    position: absolute;
    left: 50%;
    top: 0;
    width: 0;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(0, 0, 0, 0.3));
    z-index: 500;
    pointer-events: none;
    transform-origin: left;
    transition: width 0.3s ease;
}

/* Reading Progress */
.reading-progress {
    position: fixed;
    bottom: 90px;
    left: 15px;
    right: 15px;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    z-index: 100;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    width: 0%;
    transition: width 0.3s ease;
}

/* Bottom Controls */
.bottom-controls {
    position: fixed;
    bottom: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    gap: 12px;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 12px 15px;
    border-radius: 12px;
    box-shadow: 0 4px 16px var(--shadow);
    z-index: 100;
}

body.night-mode .bottom-controls {
    background: rgba(30, 30, 30, 0.95);
}

.nav-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    flex-shrink: 0;
}

.nav-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.nav-btn:active {
    transform: translateY(-1px);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-slider {
    flex: 1;
    display: flex;
    align-items: center;
}

.slider {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

body.night-mode .slider {
    background: #555;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.page-info {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--dark);
    font-weight: 600;
    min-width: 80px;
    justify-content: center;
    font-size: 13px;
}

body.night-mode .page-info {
    color: white;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--dark);
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    font-size: 13px;
}

.toast.show {
    opacity: 1;
    pointer-events: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding-top: 50px;
        padding-bottom: 80px;
    }

    .controls {
        margin: 8px 10px;
        padding: 8px 10px;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }

    .controls-left, .controls-right {
        display: none;
    }

    .controls-center {
        width: 100%;
    }

    .flipbook-wrapper {
        padding: 10px;
    }

    .bottom-controls {
        gap: 8px;
        padding: 10px 12px;
        left: 10px;
        right: 10px;
        bottom: 10px;
    }

    .nav-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .control-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .zoom-level {
        font-size: 11px;
        min-width: 40px;
    }

    .page-info {
        min-width: 70px;
        font-size: 12px;
    }

    .page-slider {
        max-width: 80px;
    }
}

@media (max-width: 480px) {
    .container {
        padding-top: 45px;
        padding-bottom: 75px;
    }

    .controls {
        margin: 6px 8px;
        padding: 6px 8px;
        gap: 4px;
    }

    .flipbook-wrapper {
        padding: 8px;
    }

    .bottom-controls {
        gap: 6px;
        padding: 8px 10px;
        left: 8px;
        right: 8px;
        bottom: 8px;
    }

    .nav-btn {
        width: 32px;
        height: 32px;
    }

    .control-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .page-slider {
        max-width: 60px;
    }

    .settings-panel {
        width: 100%;
    }
}
