/* Set base font and background */
        body {
            font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
            background-color: #111;
            /* CRITICAL: Prevent all body scrolling */
            overflow: hidden;
            color: #fff;
        }
        
        /* Blur background when modal is open */
        body.modal-open > *:not(#signup-modal) {
            filter: blur(5px);
            pointer-events: none;
        }

        /* Hide scrollbars */
        ::-webkit-scrollbar { display: none; }
        body { -ms-overflow-style: none; scrollbar-width: none; }

        /* UI bars transition */
        #top-bar, #bottom-bar {
            transition: transform 0.3s ease-in-out;
            background-color: rgba(23, 23, 23, 0.85);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px); /* Safari support */
        }

        .ui-hidden#top-bar { transform: translateY(-100%); }
        .ui-hidden#bottom-bar { transform: translateY(100%); }

        /* Custom range slider */
        input[type="range"] {
            -webkit-appearance: none;
            appearance: none;
            width: 100%;
            height: 6px;
            background: rgba(255, 255, 255, 0.2);
            border-radius: 3px;
            outline: none;
            /* MODIFIED: transform: scaleX(-1) has been removed */
        }

        input[type="range"]::-webkit-slider-thumb {
            -webkit-appearance: none;
            appearance: none;
            width: 18px;
            height: 18px;
            background: #ffffff;
            border-radius: 50%;
            cursor: pointer;
            border: 2px solid #333;
        }

        input[type="range"]::-moz-range-thumb {
            width: 14px;
            height: 14px;
            background: #ffffff;
            border-radius: 50%;
            cursor: pointer;
            border: 2px solid #333;
        }

        /* Horizontal reader viewport */
        #reader-viewport {
            position: fixed;
            inset: 0;
            overflow: hidden;
            z-index: 10;
        }

        #image-track {
            display: flex;
            height: 100%;
            box-sizing: border-box;
            transition: transform 0.3s ease-in-out;
            /* MODIFIED: Changed from row-reverse */
            flex-direction: row;
        }

        .page {
            flex-shrink: 0;
            height: 100%;
            object-fit: contain;
        }

        /* Lazy loading blur */
        .loading-blur {
            filter: blur(8px);
            opacity: 0.1;
            transition: filter 0.5s ease-out, opacity 0.8s ease-out;
        }

        .loaded-image {
            filter: blur(0);
            opacity: 1;
        }
        
        /* Desktop spread alignment - MODIFIED */
        @media (min-width: 768px) {
            /* Left Page (even) aligns right */
            .page:nth-child(even) {
                object-position: right;  
            }
            /* Right Page (odd, not first) aligns left */
            .page:nth-child(odd):not(:first-child) {
                object-position: left;
            }
        }
        
/* =====================================================================
== CSS FOR BUBBLE, END OF CHAPTER, & MODAL (No changes) ==
=====================================================================
*/

/* ----- Scroll Bubble ----- */
#scroll-bubble {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(230, 0, 0, 0.85);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: 600;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.5s ease-out;
    animation: fadeIn 0.5s ease-out 0.5s forwards, fadeOut 0.5s ease-out 5.5s forwards;
}

#scroll-bubble i {
    margin-right: 8px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ----- End of Chapter Page ----- */
.end-of-chapter-page {
    width: 100vw;
    background-color: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-top: 80px;
    padding-bottom: 80px;
    overflow-y: auto;
}

.end-content {
    max-width: 600px;
    width: 100%;
    text-align: left;
    color: #fff;
}

.end-content h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 20px;
    border-bottom: 2px solid #e60000;
    padding-bottom: 10px;
    display: inline-block;
}

.next-chapter-card {
    display: block;
    background-color: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    margin-bottom: 30px;
    transition: transform 0.3s ease;
}
.next-chapter-card:hover {
    transform: translateY(-5px);
}
.next-chapter-card img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    max-height: 250px;
    margin: 0 auto;
}
.next-chapter-info {
    padding: 15px;
}
.next-chapter-info h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #fff;
}
.next-chapter-info p {
    color: #aaaaaa;
    font-size: 0.9rem;
}

.reader-favorite-btn {
    width: 100%;
    padding: 12px;
    background-color: #e60000;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    transition: background-color 0.3s ease;
    margin-bottom: 15px;
}
.reader-favorite-btn:hover {
    background-color: #c00;
}
.reader-favorite-btn.is-favorite {
    background-color: #2a2a2a;
    color: #aaaaaa;
}

.reader-comment-btn {
    width: 100%;
    padding: 12px;
    background-color: #2a2a2a;
    color: #fff;
    border: 1px solid #444;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    transition: background-color 0.3s ease;
    margin-bottom: 15px;
    display: block;
    text-align: center;
}
.reader-comment-btn:hover {
    background-color: #3a3a3a;
    color: #fff;
}
.reader-comment-btn i {
    margin-right: 8px;
}

.comments-section {
    display: none;
}
.comments-section.open {
    display: block;
}

.comment-login-prompt {
    text-align: center;
    padding: 20px;
    background-color: #1a1a1a;
    border-radius: 8px;
    font-size: 1.1rem;
}
.comment-login-prompt span {
    color: #e60000;
    font-weight: 600;
    cursor: pointer;
}
.comment-form {
    display: none;
}
.comment-form textarea {
    width: 100%;
    height: 100px;
    background-color: #1a1a1a;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 10px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    margin-bottom: 10px;
    resize: vertical;
}
.comment-form button {
    padding: 8px 16px;
    background-color: #e60000;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
}
.comment-list {
    margin-top: 20px;
}

.comment-item {
    display: flex;
    gap: 12px;
    padding: 15px;
    background-color: #1a1a1a;
    border-radius: 8px;
    margin-bottom: 10px;
    animation: fadeIn 0.3s ease-out;
}
.comment-avatar {
    flex-shrink: 0;
    font-size: 2.5rem;
    color: #aaaaaa;
}
.comment-content {
    flex-grow: 1;
}
.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.comment-user {
    font-weight: 700;
    color: #fff;
}
.comment-timestamp {
    font-size: 0.8rem;
    color: #888;
}
.comment-text {
    color: #dddddd;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.comment-like-button {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px;
    border-radius: 5px;
}
.comment-like-button.liked {
    color: #e60000;
}
.comment-like-count {
    font-size: 0.8rem;
    color: #888;
    margin-top: 2px;
}
.comment-like-button:hover {
    background-color: #2a2a2a;
}

@media (min-width: 768px) {
    .end-of-chapter-page {
        width: 100vw;
        object-position: center;
    }
}

/* ----- Signup / Login Modal ----- */
#signup-modal {
    display: none;
    position: fixed;
    z-index: 6000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
    background-color: #2a2a2a;
    margin: 10vh auto;
    padding: 25px;
    border: 1px solid #444;
    width: 90%;
    max-width: 450px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    color: #f0f0f0;
}

.close {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: 300;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #fff;
}

#form-title {
    text-align: center;
    font-weight: 300;
    font-size: 1.8rem;
    margin-bottom: 20px;
}

#error-message {
    color: #e60000;
    background-color: rgba(230, 0, 0, 0.1);
    border: 1px solid #e60000;
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 5px;
    text-align: center;
    font-weight: 300;
    min-height: 1.5em;
}

#error-message:empty {
    display: none;
}

#signup-form input[type="text"],
#signup-form input[type="email"],
#signup-form input[type="password"] {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: #1a1a1a;
    border: 1px solid #444;
    color: #fff;
    border-radius: 5px;
    font-weight: 300;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
}

#signup-form input[type="email"] {
    text-transform: lowercase;
}

#signup-form input[type="text"]:focus,
#signup-form input[type="email"]:focus,
#signup-form input[type="password"]:focus {
    outline: none;
    border-color: #e60000;
}

.password-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    margin-top: -7.5px;
    color: #888;
    cursor: pointer;
}

#signup-form #submit-btn {
    width: 100%;
    padding: 12px;
    background-color: #e60000;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 300;
    transition: background-color 0.3s ease;
}

#signup-form #submit-btn:hover {
    background-color: #c00;
}

.form-disclaimer {
    font-weight: 300;
    font-size: 0.8rem;
    color: #aaaaaa;
    margin-top: 15px;
    text-align: center;
}

.form-disclaimer a {
    color: #e60000;
    font-weight: 300;
}

#switch-form {
    text-align: center;
    margin-top: 20px;
    color: #aaaaaa;
    cursor: pointer;
}

#switch-form span {
    color: #e60000;
    font-weight: 300;
}
