/* Global App Styles */
body { 
    background-color: #121212; 
    color: #ffffff; 
    font-family: sans-serif; 
    margin: 0; 
    padding-top: 75px; /* Space for fixed header */
    padding-bottom: 30px; 
}
/* ========================================= */
/* Custom Theme Scrollbars                   */
/* ========================================= */

/* Firefox Support */
* {
    scrollbar-width: thin;
    scrollbar-color: #bb86fc #121212;
}

/* Chrome, Edge, and Safari Support */
::-webkit-scrollbar {
    width: 8px;  /* Width for vertical scrollbar */
    height: 8px; /* Height for horizontal scrollbar */
}
::-webkit-scrollbar-track {
    background: #121212; 
}
::-webkit-scrollbar-thumb {
    background-color: #bb86fc; 
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background-color: #9d4edd; 
}
/* Fixed App Header */
.app-header {
    position: fixed; top: 0; left: 0; width: 100%; height: 65px;
    background-color: #1e1e1e; border-bottom: 1px solid #333;
    display: flex; align-items: center; justify-content: center;
    padding: 0 15px; box-sizing: border-box; z-index: 1000;
}
.search-container { position: relative; width: 100%; max-width: 500px; }
.search-input { 
    width: 100%; padding: 12px 20px; border-radius: 25px; border: 2px solid #333; 
    background-color: #2c2c2c; color: white; font-size: 16px; outline: none; box-sizing: border-box;
}
.search-input:focus { border-color: #bb86fc; }
/* ========================================= */
/* Premium Search Dropdown                   */
/* ========================================= */

/* Dropdown Container */
.dropdown { 
    position: fixed; /* Breaks out of the search bar to use the whole screen */
    top: 75px;       /* Drops it cleanly below your fixed header */
    left: 50%;
    transform: translateX(-50%); /* Centers it perfectly */
    width: calc(100% - 30px); /* Uses full width minus 15px padding on edges */
    max-width: 800px; /* Keeps it from getting too wide on Desktop */
    background-color: #1e1e1e; border-radius: 8px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.8); 
    display: none; z-index: 1001; border: 1px solid #333;
    overflow: hidden; 
}
.dropdown.active { display: block; }

/* The Scrollable List */
.manga-list { 
    max-height: 60vh; 
    overflow-y: auto; 
    overflow-x: hidden; 
}

/* Custom Mini Scrollbar for Dropdown */
.manga-list::-webkit-scrollbar { width: 6px; }
.manga-list::-webkit-scrollbar-track { background: transparent; }
.manga-list::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; }
.manga-list::-webkit-scrollbar-thumb:hover { background: #bb86fc; }

.loading-text { padding: 20px; text-align: center; color: #aaa; }

/* ========================================= */
/* Dropdown Results (Manga Items)            */
/* ========================================= */
.novel__item { border-bottom: 1px solid #2a2a2a; transition: background-color 0.2s ease; }
.novel__item:last-child { border-bottom: none; }
.novel__item:hover { background-color: #252525; }

.novel__item-inner { 
    display: flex; 
    padding: 12px 15px; 
    gap: 15px; 
    text-decoration: none; 
    align-items: center;
}

.novel__item-icon { flex-shrink: 0; }
.novel__item-icon img { 
    width: 55px; height: 80px; 
    object-fit: cover; border-radius: 6px; 
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.novel__item-meta { 
    display: flex; flex-direction: column; justify-content: center; 
    flex-grow: 1; min-width: 0; 
}

/* FIX 1: Restored White Text Color for Titles */
.novel__item-meta h3 { margin: 0 0 6px 0; font-size: 15px; font-weight: bold; }
.novel__item-meta h3 a { 
    color: #ffffff !important; /* Forces text back to white */
    text-decoration: none; 
    display: block; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
}

/* Overrides Kaliscan's hardcoded inline cyan color with your purple theme */
.novel__item-meta h3 a span { color: #bb86fc !important; }

/* Grey secondary text (Alternative names, Authors, etc) */
.novel__item-meta > span { 
    display: block; 
    color: #aaa !important; 
    font-size: 12px;
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    margin-bottom: 6px;
}

/* The Chapter Badge */
.novel__item-meta span[title*="Chapter"], .novel__item-meta .latest-chapter { 
    display: inline-block; 
    background: rgba(187, 134, 252, 0.15); 
    color: #bb86fc !important; 
    padding: 3px 8px; 
    border-radius: 4px;
    font-size: 11px; 
    font-weight: bold; 
    width: fit-content;
}

/* The View All Button */
.view-all { 
    display: block; padding: 15px; text-align: center; 
    background-color: #1e1e1e; color: #bb86fc; 
    text-decoration: none; font-weight: bold; 
    border-top: 1px solid #333; 
    transition: background-color 0.2s, color 0.2s;
}
.view-all:hover { background-color: #bb86fc; color: #121212; }
/* Home Page Sections (Recent & Famous) */
.section-title { font-size: 18px; font-weight: bold; margin: 20px 15px 10px; color: #bb86fc; }
.recent-scroll { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; padding: 0 15px 10px; gap: 15px; }
.recent-scroll::-webkit-scrollbar { display: none; }
.manga-card-small { min-width: 100px; scroll-snap-align: start; text-decoration: none; color: white; }
.manga-card-small img { width: 100px; height: 140px; border-radius: 8px; object-fit: cover; }
.manga-card-small .title { font-size: 12px; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.famous-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 15px; padding: 0 15px; }
.manga-card { text-decoration: none; color: white; }
.manga-card img { width: 100%; height: 160px; border-radius: 8px; object-fit: cover; }
.manga-card .title { font-size: 14px; font-weight: bold; margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }





/* ========================================= */
/* Global Loading Spinner                    */
/* ========================================= */
.global-loader-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: #121212; /* Solid dark background for initial load */
    z-index: 9999; /* Stays above absolutely everything */
    display: flex; justify-content: center; align-items: center;
    transition: opacity 0.3s ease-out, visibility 0.3s ease-out;
}

/* When we add the 'hidden' class via JS, it fades out smoothly */
.global-loader-overlay.hidden {
    opacity: 0;
    visibility: hidden;
}

/* The spinning ring */
.spinner {
    width: 50px; height: 50px;
    border: 5px solid #2c2c2c;
    border-top-color: #bb86fc;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}


/* Localized Loader for AJAX/Fetch */
.local-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
    width: 100%;
    box-sizing: border-box;
}

/* Ensure the spinner is a good size for inline areas */
.local-loader .spinner {
    width: 35px;
    height: 35px;
    border-width: 4px;
}


/* ========================================= */
/* Manga Grids & Carousels                   */
/* ========================================= */

/* Fixed Responsive Grid (Guarantees columns instead of 1 row) */
.famous-grid { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); /* Forces 3 items per row on mobile */
    gap: 12px; 
    padding: 0 15px; 
}
@media (min-width: 600px) {
    .famous-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
.manga-card { display: flex; flex-direction: column; text-decoration: none; color: white; }
.manga-card img { width: 100%; aspect-ratio: 2/3; border-radius: 8px; object-fit: cover; }
.manga-card .title { font-size: 13px; font-weight: bold; margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ========================================= */
/* Hot Updates Carousel                      */
/* ========================================= */
.carousel-container { position: relative; display: flex; align-items: center; }

/* The Left/Right Buttons */
.carousel-btn {
    position: absolute; z-index: 10; background: rgba(30, 30, 30, 0.9);
    border: 1px solid #bb86fc; color: #bb86fc; border-radius: 50%;
    width: 35px; height: 35px; cursor: pointer; display: none;
    justify-content: center; align-items: center; font-size: 18px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}
.carousel-btn.left { left: 5px; }
.carousel-btn.right { right: 5px; }
.carousel-btn:active { background: #bb86fc; color: #121212; }

/* Only show buttons on devices with a physical mouse */
@media (hover: hover) and (pointer: fine) {
    .carousel-btn { display: flex; } 
}

/* The Scrollable Track */
.carousel-scroll { 
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory; 
    padding: 0 15px 10px; gap: 12px; scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; 
    cursor: grab; /* Shows the grab hand for mouse users */
}
.carousel-scroll:active { cursor: grabbing; scroll-snap-type: none; } /* Disables snap while dragging */
/* .carousel-scroll::-webkit-scrollbar { display: none; } */
/* The Mini Scrollbar just for the Carousel */
.carousel-scroll::-webkit-scrollbar { 
    display: block; 
    height: 4px; /* Makes it very thin and subtle */
}
.carousel-scroll::-webkit-scrollbar-track { 
    background: transparent; /* Hides the track so it looks cleaner */
    margin: 0 15px; /* Adds padding so it doesn't touch the screen edges */
}
.carousel-scroll::-webkit-scrollbar-thumb { 
    background-color: #2c2c2c; /* Subdued color when resting */
    border-radius: 10px; 
}
/* Turns purple when the user hovers over the carousel */
.carousel-scroll:hover::-webkit-scrollbar-thumb {
    background-color: #bb86fc; 
}

.carousel-item { 
    min-width: 120px; width: 120px; scroll-snap-align: start; 
    text-decoration: none; color: white; display: flex; flex-direction: column; 
}
.carousel-item .image-wrapper { position: relative; width: 100%; aspect-ratio: 2/3; }
.carousel-item img { width: 100%; height: 100%; border-radius: 8px; object-fit: cover; pointer-events: none; }
.carousel-item .title { font-size: 13px; font-weight: bold; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* The Chapter Badge */
.chapter-badge { 
    position: absolute; bottom: 5px; right: 5px; 
    background-color: rgba(187,134,252,0.9); color: #121212; 
    padding: 2px 6px; border-radius: 4px; font-size: 11px; font-weight: bold; 
}




/* ========================================= */
/* Reader Bottom Navigation                  */
/* ========================================= */
.bottom-nav {
    display: flex;
    justify-content: space-between;
    max-width: 800px;
    margin: 30px auto;
    padding: 0 15px;
    gap: 15px;
}

.bottom-nav-btn {
    flex: 1;
    background-color: #bb86fc;
    color: #121212;
    padding: 15px;
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    font-weight: bold;
    font-size: 16px;
    transition: transform 0.2s, background-color 0.2s;
}

.bottom-nav-btn:hover {
    background-color: #9d4edd;
}

.bottom-nav-btn:active {
    transform: scale(0.98);
}

/* If there is no Prev/Next chapter, gray the button out */
.bottom-nav-btn.disabled {
    background-color: #2c2c2c;
    color: #555;
    pointer-events: none;
}

/* ========================================= */
/* Responsive Home Buttons                   */
/* ========================================= */

/* Desktop Header Home Icon */
.home-btn-desktop {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    transition: color 0.2s;
}
.home-btn-desktop:hover {
    color: #bb86fc;
}

/* Sidebar Home Button (Always visible inside toggle) */
.home-btn-sidebar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #1e1e1e !important;
    border: 1px solid #bb86fc;
    color: #bb86fc !important;
    font-weight: bold;
    margin-bottom: 10px;
}
.home-btn-sidebar:hover {
    background: #bb86fc !important;
    color: #121212 !important;
}

/* On Mobile: Hide the header icon to save space */
@media (max-width: 768px) {
    .home-btn-desktop {
        display: none; 
    }
}

/* Custom App Icon Styling for the Buttons */
.home-custom-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px; /* Rounds the corners of your icon slightly */
    object-fit: contain;
}

.home-btn-sidebar .home-custom-icon {
    width: 20px;
    height: 20px;
}

/* ========================================= */
/* Premium Sidebar Brand Link                */
/* ========================================= */
.home-btn-sidebar {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Left-aligned looks more professional */
    gap: 12px;
    background: #151515 !important; /* Very dark, sleek background */
    border: 1px solid #2a2a2a; /* Subtle dark border, no purple */
    color: #ffffff !important; /* Crisp white text */
    padding: 12px 15px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.5px;
    text-decoration: none;
    margin-bottom: 20px; /* Extra breathing room above chapters */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4); /* Premium depth shadow */
    transition: all 0.2s ease;
}

/* The Dark Hover Effect */
.home-btn-sidebar:hover {
    background: #252525 !important; /* Smooth dark grey on hover */
    border-color: #3a3a3a; /* Border slightly catches the light */
    transform: translateY(-2px); /* Tiny lift effect when touched/hovered */
    color: #ffffff !important;
}

/* Ensure the icon fits the new layout */
.home-btn-sidebar .home-custom-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    object-fit: contain;
}



        
        .reader-nav {
            position: fixed; top: 0; left: 0; width: 100%; height: 65px;
            background-color: rgba(30, 30, 30, 0.95); backdrop-filter: blur(10px);
            display: flex; justify-content: space-between; align-items: center; padding: 0 10px; box-sizing: border-box;
            border-bottom: 1px solid #333; z-index: 1000; transition: top 0.3s ease-in-out;
        }
        .reader-nav.hidden { top: -70px; }

        .header-center { display: flex; gap: 10px; align-items: center; }
        .icon-btn { background: none; border: none; color: white; font-size: 24px; cursor: pointer; padding: 10px; }
        .nav-btn { background-color: #bb86fc; color: #121212; padding: 8px 12px; border-radius: 6px; text-decoration: none; font-weight: bold; font-size: 14px; }
        .server-select { background: #2c2c2c; color: white; border: 1px solid #444; padding: 8px; border-radius: 4px; outline: none; font-weight: bold; }

        .sidebar {
            position: fixed; top: 0; height: 100%; width: 280px; background-color: #1e1e1e;
            z-index: 2000; overflow-y: auto; transition: transform 0.3s ease-in-out; box-shadow: 0 0 15px rgba(0,0,0,0.8);
        }
        .sidebar-left { left: 0; transform: translateX(-105%); } 
        .sidebar-right { right: 0; transform: translateX(105%); } 
        .sidebar.active { transform: translateX(0); }
        
        .sidebar-header { padding: 20px; font-size: 18px; font-weight: bold; border-bottom: 1px solid #333; color: #bb86fc; }
        .sidebar-list { padding: 10px; display: flex; flex-direction: column; gap: 10px; }
        .sidebar-list a { color: white; text-decoration: none; padding: 10px; background: #2c2c2c; border-radius: 6px; text-align: center; }
        .sidebar-list a:hover { background: #bb86fc; color: #121212; }

        #sidebar-overlay {
            position: fixed; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.6); z-index: 1500; display: none; opacity: 0; transition: opacity 0.3s;
        }
        #sidebar-overlay.active { display: block; opacity: 1; }

        .fab-top {
            position: fixed; bottom: -60px; right: 20px; background-color: #bb86fc; color: #121212;
            width: 50px; height: 50px; border-radius: 50%; display: flex; justify-content: center; align-items: center;
            font-size: 24px; text-decoration: none; box-shadow: 0 4px 10px rgba(0,0,0,0.5); z-index: 900; transition: bottom 0.3s ease-in-out; cursor: pointer;
        }
        .fab-top.visible { bottom: 20px; }

        #chapter-images { width: 100%; max-width: 800px; margin: 65px auto 0; display: flex; flex-direction: column; align-items: center; }
        .chapter-image { width: 100%; margin-bottom: -4px; min-height: 400px; background-color: #1a1a1a; display: flex; justify-content: center; align-items: center; }
        .chapter-image img { width: 100%; display: block; }
        
        .loading-overlay { display: none; margin: 50px; }
        .loading-overlay.active { display: block; }
        
        /* Reader Recommendations specific wrapper */
        .reader-recommendations { max-width: 800px; margin: 60px auto; padding-bottom: 40px; }

        /* Update this existing rule */
.app-header {
    position: fixed; top: 0; left: 0; width: 100%; height: 65px;
    background-color: #1e1e1e; border-bottom: 1px solid #333;
    display: flex; align-items: center; 
    justify-content: space-between; /* Pushes logo left and search right */
    gap: 15px; /* Adds breathing room between them */
    padding: 0 15px; box-sizing: border-box; z-index: 1000;
}

/* ========================================= */
/* Header Logo Styles                        */
/* ========================================= */
.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #ffffff;
    font-weight: bold;
    font-size: 18px;
    letter-spacing: 0.5px;
    flex-shrink: 0; /* Prevents the logo from getting squished by the search bar */
}

.header-logo img {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: contain;
}

/* On very small phone screens, hide the text to give the search bar more room */
@media (max-width: 400px) {
    .header-logo .logo-text {
        display: none;
    }
}

/* ========================================= */
/* Detailed Search Results Layout            */
/* ========================================= */
.search-results-list {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 15px;
}

.search-result-item {
    display: flex;
    gap: 15px;
    background: #1e1e1e;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #333;
}

.search-result-item img {
    width: 100px;
    height: 150px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.search-result-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.search-result-title {
    font-size: 16px;
    color: #bb86fc;
    font-weight: bold;
    text-decoration: none;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-meta {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 10px;
    display: flex;
    gap: 15px;
}

.search-result-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.search-result-genres span {
    background: #2c2c2c;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    color: #ffffff;
}

.search-result-summary {
    font-size: 12px;
    color: #bbb;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}


/* ========================================= */
/* Pagination Buttons (Single Row Scroll)    */
/* ========================================= */
.paginator {
    display: flex;
    align-items: center;
    gap: 8px;
        justify-content: center;

    margin: 40px auto;
    padding: 0 15px 20px 15px;
    overflow-x: auto; /* Allows swiping left/right on mobile */
    white-space: nowrap; /* Forces them onto one line */
    -webkit-overflow-scrolling: touch;
}

/* Hide the ugly scrollbar for the pagination */
.paginator::-webkit-scrollbar { display: none; }

.paginator a, .paginator span {
    padding: 8px 12px;
    background: #1e1e1e;
    border: 1px solid #333;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
    flex-shrink: 0; /* Prevents buttons from squishing */
    transition: all 0.2s;
}

.paginator a:hover {
    background: #2c2c2c;
    border-color: #bb86fc;
}

.paginator a.active {
    background: #bb86fc;
    color: #121212;
    border-color: #bb86fc;
    pointer-events: none;
}

/* Search Overlay Background */
.search-backdrop {
    position: fixed; top: 65px; left: 0; width: 100%; height: calc(100vh - 65px);
    background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px);
    z-index: 998; opacity: 0; visibility: hidden; transition: 0.2s ease;
}
.search-backdrop.active {
    opacity: 1; visibility: visible;
}

/* Ensure header and dropdown sit ABOVE the backdrop */
.app-header { z-index: 1000; }
.dropdown { z-index: 1001; max-height: 70vh; overflow-y: auto; }


/* ========================================= */
/* Scroll to Top Button (FAB)                */
/* ========================================= */
.fab-top {
    position: fixed; 
    bottom: -60px; /* Hidden off-screen by default */
    right: 20px; 
    background-color: #bb86fc; 
    color: #121212;
    width: 50px; 
    height: 50px; 
    border-radius: 50%; 
    display: flex; 
    justify-content: center; 
    align-items: center;
    font-size: 24px; 
    text-decoration: none; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.5); 
    z-index: 900; 
    transition: bottom 0.3s ease-in-out, transform 0.2s; 
    cursor: pointer;
}

/* Pops the button up onto the screen */
.fab-top.visible { 
    bottom: 20px; 
}

/* Tap effect */
.fab-top:active {
    transform: scale(0.9);
}

/* ========================================= */
/* Bookmark Category Tabs (bookmarks.php)    */
/* ========================================= */
.bookmark-tabs-container {
    background: #1e1e1e;
    border-bottom: 1px solid #333;
    padding: 10px 15px;
    position: sticky;
    top: 65px;
    z-index: 100;
}

.bookmark-tabs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.bookmark-tabs::-webkit-scrollbar { display: none; }

.tab-pill {
    background: #2c2c2c;
    color: white;
    border: 1px solid #444;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-pill.active {
    background: #bb86fc;
    color: #121212;
    border-color: #bb86fc;
}

/* ========================================= */
/* Premium Custom Modal (reader.php)         */
/* ========================================= */
.custom-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 400px;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.9);
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.custom-modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #333;
}

.modal-header h3 { margin: 0; font-size: 18px; color: #bb86fc; }
.close-btn { background: none; border: none; color: #aaa; font-size: 24px; cursor: pointer; }

.modal-body { padding: 20px; }

/* Custom Radio Buttons */
.radio-group { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.bookmark-radio { display: flex; align-items: center; cursor: pointer; }
.bookmark-radio input { display: none; }
.bookmark-radio .radio-label {
    position: relative;
    padding-left: 30px;
    color: white;
    font-size: 15px;
}
.bookmark-radio .radio-label::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; border: 2px solid #555; border-radius: 50%;
    transition: all 0.2s;
}
.bookmark-radio input:checked + .radio-label::before {
    border-color: #bb86fc;
}
.bookmark-radio input:checked + .radio-label::after {
    content: ''; position: absolute; left: 5px; top: 50%; transform: translateY(-50%);
    width: 12px; height: 12px; background: #bb86fc; border-radius: 50%;
}

/* Add New List Input */
.new-list-group { display: flex; gap: 10px; }
.new-list-group input {
    flex: 1; background: #2c2c2c; border: 1px solid #444; color: white;
    padding: 10px; border-radius: 6px; outline: none;
}
.new-list-group input:focus { border-color: #bb86fc; }
.new-list-group button {
    background: #333; color: white; border: none; padding: 0 15px;
    border-radius: 6px; font-weight: bold; cursor: pointer;
}
.new-list-group button:hover { background: #444; }

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #333;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.modal-footer button {
    flex: 1; padding: 12px; border-radius: 6px; font-weight: bold;
    border: none; cursor: pointer; font-size: 14px; transition: 0.2s;
}
.btn-primary { background: #bb86fc; color: #121212; }
.btn-primary:active { transform: scale(0.96); }
.btn-danger { background: #2c2c2c; color: #ff5252; }
.btn-danger:hover { background: #ff5252; color: white; }


/* ========================================= */
/* Global Toast Notifications                */
/* ========================================= */
#toast-container {
    position: fixed;
    bottom: 80px; /* Floats just above your FAB arrow */
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none; /* Allows users to click 'through' the toast */
}

.toast {
    background: #bb86fc;
    color: #121212;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    opacity: 0;
    /* Runs the enter animation, then runs the leave animation 2.7 seconds later */
    animation: toastEnter 0.3s forwards, toastLeave 0.3s forwards 2.7s;
}

/* Red version for removals/errors */
.toast.error {
    background: #ff5252;
    color: #ffffff;
}

@keyframes toastEnter {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastLeave {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(20px); }
}

/* ========================================= */
/* Bookmark SVG Icon States                  */
/* ========================================= */
.bookmark-icon {
    transition: fill 0.2s ease, stroke 0.2s ease, color 0.2s ease;
    color: #ffffff; /* Default outline color */
    display: block;
}

/* When the user hovers over the button */
.icon-btn:hover .bookmark-icon {
    color: #bb86fc;
}

/* The "Saved" state - fills the icon with solid purple */
.bookmark-icon.active {
    fill: #bb86fc;
    stroke: #bb86fc;
    color: #bb86fc;
}

/* ========================================= */
/* Manga Card Overlay Bookmark Button        */
/* ========================================= */
.card-bookmark-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(18, 18, 18, 0.6); /* Semi-transparent dark background */
    backdrop-filter: blur(4px); /* Premium frosted glass effect */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 10;
    transition: transform 0.2s ease, background 0.2s ease;
}

.card-bookmark-btn:hover {
    background: rgba(30, 30, 30, 0.9);
    transform: scale(1.1);
}

.card-bookmark-btn .bookmark-icon {
    /* Ensures the SVG inherits the exact size and alignment */
    width: 14px;
    height: 14px;
}

/* ========================================= */
/* Modal Dark Overlay Backdrop               */
/* ========================================= */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1001; /* Sits right under the modal (1002) */
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Fix for Homepage Cards so the button stays inside the image */
.manga-card {
    position: relative; 
}

/* ========================================= */
/* Header Right Actions & 3-Dot Menu         */
/* ========================================= */
.header-right-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-menu-container {
    position: relative;
}

.nav-dropdown {
    position: absolute;
    top: 50px;
    right: 0;
    width: 180px;
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.8);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1005;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.nav-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-dropdown a {
    padding: 15px;
    color: #ffffff;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    border-bottom: 1px solid #2a2a2a;
    transition: background 0.2s;
}

.nav-dropdown a:hover {
    background: #2c2c2c;
    color: #bb86fc;
}
.nav-dropdown a:last-child { border-bottom: none; }

/* ========================================= */
/* Reader Header Title & Chapter             */
/* ========================================= */
.reader-title-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden; /* Prevents long titles from breaking the header */
    padding: 0 10px;
}

.reader-manga-title {
    font-size: 14px;
    font-weight: bold;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.reader-chapter-title {
    font-size: 11px;
    color: #bb86fc;
    font-weight: bold;
    margin-top: 2px;
}

/* ========================================= */
/* Smart Header Hiding Animation             */
/* ========================================= */
.app-header {
    transition: transform 0.3s ease-in-out; /* Makes it slide smoothly */
}

/* Slides the header exactly 100% of its own height upwards off the screen */
.app-header.hidden {
    transform: translateY(-100%);
}

/* ========================================= */
/* Sidebar Header Styling                    */
/* ========================================= */

/* Restyle the dropdown specifically for the sidebar */
.sidebar-dropdown {
    top: 40px;
    right: 0;
    width: 170px;
}

/* Manga Info Section */
.sidebar-manga-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
}

.sidebar-manga-title {
    font-size: 16px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.3;
    /* Allows the text to wrap to 2 lines, then adds ... if it's still too long */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sidebar-chapter-title {
    font-size: 13px;
    color: #bb86fc;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ========================================= */
/* Reader Header Layout Structure            */
/* ========================================= */
.reader-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 12px;
}

/* Forces the left and right sections to take up equal space */
.header-side {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1; 
}
.header-left { justify-content: flex-start; }
.header-right { justify-content: flex-end; }

/* The Center Zone */
.reader-title-container {
    flex: 2; /* Gives the title priority for space */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-width: 0; /* Prevents overflow from breaking the flex layout */
    padding: 0 10px;
}

/* ========================================= */
/* Beautiful Unified Header Buttons          */
/* ========================================= */
.header-btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05); /* Premium glass/frosted background */
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0; /* Prevents buttons from squishing on tiny phones */
}

.header-btn:hover {
    background: rgba(187, 134, 252, 0.15); /* Soft purple glow */
    border-color: #bb86fc;
    color: #bb86fc;
}

.header-btn svg {
    transition: transform 0.2s ease;
}

.header-btn:active svg {
    transform: scale(0.9); /* Satisfying "click" animation */
}