/* ═══════════ MangaVault — Ultra Dark Theme ═══════════ */
:root {
    --bg-void: #000000;
    --bg-deep: #08080c;
    --bg-base: #0c0c14;
    --bg-surface: #111119;
    --bg-elevated: #16161f;
    --bg-hover: #1c1c28;
    --bg-active: #222233;
    --border-subtle: rgba(255,255,255,0.04);
    --border-dim: rgba(255,255,255,0.07);
    --border-default: rgba(255,255,255,0.1);
    --text-primary: #e8e8f0;
    --text-secondary: #9090a8;
    --text-muted: #5a5a72;
    --accent: #a855f7;
    --accent-dim: rgba(168,85,247,0.15);
    --accent-glow: rgba(168,85,247,0.3);
    --accent2: #6366f1;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --sidebar-w: 280px;
    --topbar-h: 56px;
    --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

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

html {
    font-size: 15px;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary);
    display: flex;
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent-dim); }

/* ═══════════ BUTTONS ═══════════ */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border: none; border-radius: var(--radius-md);
    font-family: inherit; font-size: 0.87rem; font-weight: 600;
    cursor: pointer; transition: all var(--transition);
    white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
}
.btn-primary:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn-glow { box-shadow: 0 0 20px var(--accent-glow), 0 4px 12px rgba(0,0,0,0.4); }
.btn-glow:hover { box-shadow: 0 0 30px var(--accent-glow), 0 6px 20px rgba(0,0,0,0.5); }
.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-dim);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-default); }
.btn-icon {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-secondary);
    cursor: pointer; transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon svg { width: 18px; height: 18px; }
.btn-back {
    display: inline-flex; align-items: center; gap: 6px;
    background: none; border: none; color: var(--text-secondary);
    font: inherit; font-size: 0.85rem; cursor: pointer;
    transition: color var(--transition); margin-bottom: 8px;
}
.btn-back:hover { color: var(--accent); }
.btn-back svg { width: 16px; height: 16px; }

/* ═══════════ SIDEBAR ═══════════ */
.sidebar {
    width: var(--sidebar-w); height: 100%;
    background: var(--bg-deep);
    border-right: 1px solid var(--border-subtle);
    display: flex; flex-direction: column;
    transition: width 0.3s ease, transform 0.3s ease;
    z-index: 100; flex-shrink: 0;
    overflow: hidden;
}
.sidebar.collapsed { width: 0; border-right: none; }

.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 16px 12px; border-bottom: 1px solid var(--border-subtle);
    min-height: 60px;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--accent-dim), rgba(99,102,241,0.15));
    border-radius: var(--radius-sm); color: var(--accent);
}
.logo-icon svg { width: 20px; height: 20px; }
.logo-title { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.5px; }
.logo-subtitle { display: block; font-size: 0.65rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.5px; }
.sidebar-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border: none; border-radius: var(--radius-sm);
    background: transparent; color: var(--text-muted); cursor: pointer;
    transition: all var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-toggle svg { width: 14px; height: 14px; }

.sidebar-actions { padding: 12px 16px; }
.sidebar-actions .btn { width: 100%; justify-content: center; }

.sidebar-section { padding: 8px 0; flex: 1; overflow-y: auto; }
.section-title {
    padding: 8px 16px; font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted);
}

/* Manga list items */
.manga-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; cursor: pointer;
    transition: background var(--transition);
    border-left: 3px solid transparent;
}
.manga-item:hover { background: var(--bg-hover); }
.manga-item.active { background: var(--bg-active); border-left-color: var(--accent); }
.manga-item-cover {
    width: 40px; height: 54px; border-radius: var(--radius-sm);
    background: var(--bg-elevated); object-fit: cover;
    flex-shrink: 0; border: 1px solid var(--border-subtle);
}
.manga-item-info { flex: 1; overflow: hidden; }
.manga-item-title {
    font-size: 0.85rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.manga-item-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

/* Downloads list */
.downloads-list { padding: 0 16px; }
.empty-text { font-size: 0.78rem; color: var(--text-muted); padding: 8px 16px; }
.download-item {
    padding: 10px 0; border-bottom: 1px solid var(--border-subtle);
}
.download-item-title { font-size: 0.8rem; font-weight: 600; margin-bottom: 6px; }
.download-item-status { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 6px; }
.progress-bar {
    height: 4px; background: var(--bg-active); border-radius: 2px; overflow: hidden;
}
.progress-fill {
    height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2));
    border-radius: 2px; transition: width 0.4s ease;
    box-shadow: 0 0 8px var(--accent-glow);
}

/* Loading pulse */
.loading-pulse { padding: 16px; }
.pulse-bar {
    height: 12px; background: var(--bg-elevated); border-radius: var(--radius-sm);
    margin-bottom: 10px; animation: pulse 1.5s ease-in-out infinite;
}
.pulse-bar.short { width: 60%; }
@keyframes pulse {
    0%,100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.main-content {
    flex: 1; height: 100%; overflow-y: auto;
    background: var(--bg-base);
    position: relative;
}
.main-content:has(#readerView.active) {
    overflow: hidden !important;
    padding-bottom: 0 !important;
}

.view { display: none; }
.view.active { display: block; }

/* ═══════════ WELCOME ═══════════ */
.welcome-container {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 100vh; padding: 40px 20px; text-align: center;
    position: relative;
}
.welcome-glow {
    position: absolute; top: 20%; left: 50%; transform: translateX(-50%);
    width: 400px; height: 400px; border-radius: 50%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    filter: blur(80px); opacity: 0.3; pointer-events: none;
}
.welcome-icon { margin-bottom: 24px; opacity: 0.9; }
.welcome-icon svg { width: 80px; height: 80px; }
.welcome-title { font-size: 2.4rem; font-weight: 900; letter-spacing: -1px; margin-bottom: 12px; }
.gradient-text {
    background: linear-gradient(135deg, var(--accent), var(--accent2), #ec4899);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.welcome-desc { max-width: 480px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 48px; }

.welcome-features {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
    max-width: 720px; width: 100%;
}
.feature-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); padding: 28px 20px;
    transition: all 0.3s ease;
}
.feature-card:hover {
    border-color: var(--accent-dim);
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.feature-icon { font-size: 1.8rem; margin-bottom: 12px; }
.feature-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 6px; }
.feature-card p { font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }

/* ═══════════ MANGA DETAIL ═══════════ */
.manga-header {
    display: flex; gap: 32px; padding: 40px; align-items: flex-start;
    background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-base) 100%);
    border-bottom: 1px solid var(--border-subtle);
}
.manga-cover-large {
    width: 200px; height: 280px; border-radius: var(--radius-lg);
    background: var(--bg-elevated); flex-shrink: 0; overflow: hidden;
    border: 1px solid var(--border-dim);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.manga-cover-large img { width: 100%; height: 100%; object-fit: cover; }
.manga-title-large { font-size: 2rem; font-weight: 900; letter-spacing: -0.5px; margin-bottom: 8px; }
.manga-stats {
    display: flex; gap: 20px; margin-bottom: 20px;
    font-size: 0.85rem; color: var(--text-secondary);
}
.manga-stats .stat { display: flex; align-items: center; gap: 6px; }
.manga-stats .stat-val { color: var(--accent); font-weight: 700; }
.manga-actions { display: flex; gap: 12px; }

/* Chapter grid */
.chapter-grid-container { padding: 24px 40px 40px; }
.chapter-grid-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.chapter-grid-header h2 { font-size: 1.2rem; font-weight: 800; }
.chapter-search {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-surface); border: 1px solid var(--border-dim);
    border-radius: var(--radius-md); padding: 8px 14px;
}
.chapter-search svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.chapter-search input {
    background: none; border: none; color: var(--text-primary);
    font: inherit; font-size: 0.85rem; outline: none; width: 160px;
}
.chapter-search input::placeholder { color: var(--text-muted); }

.chapter-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}
.chapter-card {
    display: flex; align-items: center; justify-content: center;
    padding: 14px 8px; background: var(--bg-surface);
    border: 1px solid var(--border-subtle); border-radius: var(--radius-md);
    cursor: pointer; transition: all var(--transition);
    font-size: 0.85rem; font-weight: 600; text-align: center;
}
.chapter-card:hover {
    background: var(--bg-hover); border-color: var(--accent-dim);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.chapter-card.read { color: var(--text-muted); }
.chapter-card .ch-pages { display: block; font-size: 0.65rem; color: var(--text-muted); font-weight: 400; margin-top: 2px; }

/* ═══════════ READER ═══════════ */
#readerView.active { display: flex; flex-direction: column; height: 100%; position: relative; }

/* Scroll progress bar — pinned at absolute top */
.reader-progress {
    position: fixed; top: 0; left: 0; right: 0; height: 3px;
    background: var(--bg-active); z-index: 60;
}
.reader-progress-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent2), #ec4899);
    transition: width 0.15s linear;
    box-shadow: 0 0 8px var(--accent-glow);
}

/* Topbar — sticks on top, auto-hides */
.reader-topbar {
    position: absolute; top: 0; left: 0; right: 0;
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px; background: rgba(8,8,12,0.92);
    backdrop-filter: blur(12px); border-bottom: 1px solid var(--border-subtle);
    min-height: var(--topbar-h); z-index: 55;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.reader-topbar.hidden { transform: translateY(-100%); opacity: 0; pointer-events: none; }
.reader-topbar-left, .reader-topbar-right { display: flex; align-items: center; gap: 12px; }
.reader-info { display: flex; flex-direction: column; }
.reader-manga-title { font-size: 0.85rem; font-weight: 700; }
.reader-chapter-title { font-size: 0.72rem; color: var(--text-muted); }
.reader-page-counter {
    font-family: 'JetBrains Mono', monospace; font-size: 0.8rem;
    color: var(--text-secondary); background: var(--bg-surface);
    padding: 4px 12px; border-radius: var(--radius-sm);
}

/* Width selector dropdown */
.reader-width-select {
    background: var(--bg-surface); color: var(--text-primary);
    border: 1px solid var(--border-dim); border-radius: var(--radius-sm);
    padding: 4px 8px; font: inherit; font-size: 0.78rem;
    cursor: pointer; outline: none;
}
.reader-width-select:focus { border-color: var(--accent); }
.reader-width-select option { background: var(--bg-elevated); color: var(--text-primary); }

/* Scroll container — the main scrollable area */
.reader-container {
    flex: 1; overflow-y: auto; overflow-x: hidden;
    background: var(--bg-void);
    scroll-behavior: smooth;
    padding-top: var(--topbar-h);
}

/* Vertical image strip */
.reader-scroll {
    display: flex; flex-direction: column; align-items: center;
    width: 100%; min-height: 100%;
    --reader-max-width: 800px;
}
.reader-scroll img {
    width: 100%; max-width: var(--reader-max-width);
    display: block; user-select: none;
    /* No gap between images for seamless reading */
}
.reader-scroll img + img {
    /* Tiny visual separator so you can see page boundaries if needed */
    border-top: 1px solid rgba(255,255,255,0.02);
}

/* Chapter end zone */
.reader-chapter-end {
    display: flex; flex-direction: column; align-items: center;
    padding: 60px 20px 80px; gap: 20px;
}
.chapter-end-line {
    width: 200px; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-dim), transparent);
}
.chapter-end-label {
    font-size: 0.9rem; font-weight: 600; color: var(--text-muted);
}
.chapter-end-actions {
    display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
}
.chapter-end-actions .btn:disabled {
    opacity: 0.3; cursor: not-allowed;
    filter: none; transform: none;
}

/* Floating action button — scroll to top */
.reader-fab {
    position: fixed; bottom: 24px; right: 24px;
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-elevated); border: 1px solid var(--border-dim);
    border-radius: 50%; color: var(--text-secondary);
    cursor: pointer; z-index: 55;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.reader-fab:hover {
    background: var(--accent); color: #fff;
    border-color: var(--accent);
    box-shadow: 0 4px 24px var(--accent-glow);
}
.reader-fab svg { width: 20px; height: 20px; }

/* ═══════════ MODAL ═══════════ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px); display: none;
    align-items: center; justify-content: center; z-index: 200;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-surface); border: 1px solid var(--border-dim);
    border-radius: var(--radius-xl); width: 90%; max-width: 520px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
    animation: modalIn 0.3s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border-subtle);
}
.modal-header h2 { font-size: 1.1rem; font-weight: 800; }
.modal-body { padding: 24px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 12px;
    padding: 16px 24px; border-top: 1px solid var(--border-subtle);
}

.input-group { margin-bottom: 16px; }
.input-group label {
    display: block; font-size: 0.78rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 6px;
}
.input-group input {
    width: 100%; padding: 10px 14px;
    background: var(--bg-elevated); border: 1px solid var(--border-dim);
    border-radius: var(--radius-md); color: var(--text-primary);
    font: inherit; font-size: 0.9rem; outline: none;
    transition: border-color var(--transition);
}
.input-group input:focus { border-color: var(--accent); }
.input-group input::placeholder { color: var(--text-muted); }
.input-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 6px; line-height: 1.4; }
.input-hint code {
    background: var(--bg-active); padding: 1px 5px;
    border-radius: 3px; font-family: 'JetBrains Mono', monospace; font-size: 0.68rem;
}
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.detected-slug {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px; background: rgba(34,197,94,0.08);
    border: 1px solid rgba(34,197,94,0.2); border-radius: var(--radius-md);
    color: var(--success); font-size: 0.82rem;
}
.detected-slug svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ═══════════ TOAST ═══════════ */
.toast-container {
    position: fixed; bottom: 20px; right: 20px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 300; pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 18px; background: var(--bg-elevated);
    border: 1px solid var(--border-dim); border-radius: var(--radius-md);
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    font-size: 0.82rem; pointer-events: auto;
    animation: toastIn 0.3s ease;
    max-width: 380px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ═══════════ RESPONSIVE ═══════════ */

/* ── Floating Hamburger (mobile only) ── */
.floating-sidebar-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 200;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    color: var(--text-primary);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    display: none !important; /* hidden by default, shown via JS on mobile */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
}
.floating-sidebar-toggle:active {
    background: var(--accent-dim);
    border-color: var(--accent);
}

/* ── Sidebar overlay backdrop (mobile only) ── */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    z-index: 140;
    transition: opacity 0.3s ease;
}
.sidebar-backdrop.active { display: block; }

@media (max-width: 768px) {
    /* Sidebar becomes a fixed full-height overlay drawer */
    .sidebar {
        position: fixed;
        left: 0; top: 0;
        height: 100dvh;
        height: 100vh; /* fallback */
        z-index: 150;
        transform: translateX(-100%);
        width: var(--sidebar-w) !important;
        transition: transform 0.3s cubic-bezier(.4,0,.2,1);
        box-shadow: 8px 0 40px rgba(0,0,0,0.7);
    }
    /* When sidebar is NOT collapsed it slides in */
    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }

    /* Show floating hamburger on mobile */
    .floating-sidebar-toggle {
        display: flex !important;
    }

    /* Main content takes full width on mobile */
    .main-content {
        width: 100%;
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }

    /* Reader strips bottom padding for immersive mode */
    .main-content:has(#readerView.active) {
        padding-bottom: 0 !important;
    }

    /* Welcome layout tweaks */
    .welcome-features { grid-template-columns: 1fr; max-width: 320px; }
    .manga-header { flex-direction: column; padding: 20px; align-items: center; text-align: center; }
    .manga-cover-large { width: 160px; height: 224px; }
    .manga-actions { justify-content: center; }
    .chapter-grid-container { padding: 16px; }
    .chapter-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }

    /* Discover sections padding */
    .discover-sections-container { padding: 0 16px 40px; }

    /* Reader topbar compact on mobile */
    .reader-topbar { padding: 6px 12px; }
    .reader-topbar-right { gap: 6px; }
    .reader-width-select { font-size: 0.7rem; padding: 3px 4px; }
    .reader-page-counter { font-size: 0.72rem; padding: 3px 8px; }
}

/* ═══════════ DISCOVER HUB ═══════════ */
.discover-search-container {
    width: 100%; max-width: 680px; margin: 0 auto;
}
.search-box-large {
    display: flex; align-items: center; gap: 12px;
    background: var(--bg-surface); border: 1px solid var(--border-default);
    border-radius: var(--radius-lg); padding: 10px 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transition: border-color var(--transition);
}
.search-box-large:focus-within { border-color: var(--accent); }
.search-box-large svg { width: 20px; height: 20px; color: var(--text-secondary); flex-shrink: 0; }
.search-box-large input {
    flex: 1; background: none; border: none; color: var(--text-primary);
    font: inherit; font-size: 0.95rem; outline: none;
}
.search-box-large input::placeholder { color: var(--text-muted); }

.discover-sections-container {
    padding: 0 40px 40px;
    display: flex; flex-direction: column; gap: 40px;
}
.discover-section { width: 100%; }
.section-heading {
    font-size: 1.3rem; font-weight: 800; margin-bottom: 20px;
    border-left: 4px solid var(--accent); padding-left: 12px;
}
.discover-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
}
.discover-card {
    background: var(--bg-surface); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); overflow: hidden; cursor: pointer;
    transition: all 0.3s ease; display: flex; flex-direction: column;
}
.discover-card:hover {
    transform: translateY(-4px); border-color: var(--accent-dim);
    box-shadow: 0 12px 30px rgba(0,0,0,0.5);
}
.discover-card-cover-container {
    width: 100%; aspect-ratio: 3/4; position: relative;
    background: var(--bg-elevated); overflow: hidden;
}
.discover-card-cover {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform 0.3s ease;
}
.discover-card:hover .discover-card-cover { transform: scale(1.05); }
.discover-card-info { padding: 12px; flex: 1; display: flex; flex-direction: column; justify-content: space-between; }
.discover-card-title {
    font-size: 0.88rem; font-weight: 700; line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; text-overflow: ellipsis;
}
.discover-card-update { font-size: 0.72rem; color: var(--accent); margin-top: 6px; font-weight: 600; }
.empty-cover {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; color: var(--text-muted); font-size: 0.8rem;
}

/* Discover skeletons */
.discover-skeleton {
    grid-column: 1/-1; display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 20px;
}

/* ═══════════ SOURCE BADGES ═══════════ */
.source-badge {
    position: absolute; top: 10px; left: 10px;
    font-size: 0.65rem; font-weight: 800; letter-spacing: 0.5px;
    padding: 3px 8px; border-radius: var(--radius-sm);
    color: #fff; text-transform: uppercase; z-index: 10;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}
.manga-header .source-badge {
    position: static; font-size: 0.75rem; letter-spacing: 1px;
    padding: 4px 10px;
}
.badge-asura { background: linear-gradient(135deg, #7c35c2, #913fe2); }
.badge-crow { background: linear-gradient(135deg, #1e1b4b, #312e81); }
.badge-local { background: linear-gradient(135deg, #059669, #10b981); }

/* ═══════════ SYNOPSIS SECTION ═══════════ */
.manga-synopsis-container {
    padding: 24px 40px; border-bottom: 1px solid var(--border-subtle);
    max-width: 900px;
}
.manga-synopsis-container h3 {
    font-size: 1rem; font-weight: 700; color: var(--text-secondary);
    margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px;
}
.manga-synopsis-container p {
    font-size: 0.88rem; color: var(--text-primary); line-height: 1.6;
    white-space: pre-line;
}

/* ═══════════ BULK ACTION TOOLBAR ═══════════ */
.header-actions { display: flex; align-items: center; gap: 12px; }
.bulk-actions-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(168,85,247,0.1); border: 1px solid var(--accent-dim);
    border-radius: var(--radius-md); padding: 12px 20px;
    margin-bottom: 16px; animation: slideDown 0.2s ease;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}
.bulk-info { font-size: 0.85rem; font-weight: 600; color: var(--accent); }
.bulk-buttons { display: flex; gap: 8px; }
.bulk-check-box {
    width: 16px; height: 16px; border-radius: 3px; accent-color: var(--accent);
    cursor: pointer;
}
.chapter-card { position: relative; gap: 10px; }
.chapter-card.selected { border-color: var(--accent); background: var(--bg-hover); }

/* ═══════════ SINGLE PAGE LAYOUT ═══════════ */
.single-page-layout {
    display: flex; justify-content: center; align-items: center;
    flex: 1;
}
.single-page-layout img {
    max-height: 85vh; width: auto !important; object-fit: contain;
    box-shadow: 0 12px 48px rgba(0,0,0,0.6);
    border-radius: var(--radius-sm);
}

/* ─── Reader Background Themes ─── */
.reader-container.bg-void { background: #000; color: #e8e8f0; }
.reader-container.bg-deep { background: #111118; color: #d0d0d8; }
.reader-container.bg-sepia { background: #f4ecd8; color: #5c4033; }
.reader-container.bg-sepia img { filter: sepia(0.2) contrast(0.95); }
.reader-container.bg-light { background: #fafafa; color: #111; }
.reader-container.bg-light img { filter: contrast(1.05); }

/* ─── Infinite Loader Spinner ─── */
.spinner {
    width: 28px; height: 28px; border: 3px solid rgba(168,85,247,0.1);
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chapter-transition-label {
    width: 100%; display: flex; flex-direction: column; align-items: center;
    padding: 40px 0; background: var(--bg-void);
}


/* ═══════════ GLOBAL LOADING SCREEN ═══════════ */
.loading-overlay-screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(4, 4, 6, 0.88); backdrop-filter: blur(12px);
    z-index: 10000; display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.3s ease;
}
.loading-content { display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; }
.logo-spinner {
    width: 80px; height: 80px; color: var(--accent);
    animation: pulseSpin 2s infinite ease-in-out;
    filter: drop-shadow(0 0 15px var(--accent-glow));
}
.logo-spinner svg { width: 100%; height: 100%; }
.loading-text {
    font-size: 0.95rem; font-weight: 700; color: var(--text-primary);
    letter-spacing: 0.15em; text-transform: uppercase;
    animation: pulseText 1.5s infinite alternate;
}
@keyframes pulseSpin {
    0% { transform: scale(1) rotate(0deg); opacity: 0.8; }
    50% { transform: scale(1.15) rotate(180deg); opacity: 1; }
    100% { transform: scale(1) rotate(360deg); opacity: 0.8; }
}
@keyframes pulseText {
    from { opacity: 0.4; text-shadow: 0 0 4px rgba(168,85,247,0.2); }
    to { opacity: 1; text-shadow: 0 0 12px rgba(168,85,247,0.6); }
}


/* ═══════════ DEVELOPER SYSTEM LOGS DRAWER ═══════════ */
.logs-drawer {
    position: fixed; bottom: 0; left: var(--sidebar-width); right: 0;
    background: #020204; border-top: 1px solid var(--border-dim);
    box-shadow: 0 -12px 48px rgba(0,0,0,0.6);
    z-index: 500; height: 320px; display: flex; flex-direction: column;
    transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.logs-drawer.active { transform: translateY(0); }
.logs-drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    background: #0a0a0f; border-bottom: 1px solid var(--border-subtle);
    padding: 8px 20px; height: 44px;
}
.live-indicator {
    width: 8px; height: 8px; border-radius: 50%; background: #ef4444;
    animation: blink 1.2s infinite alternate;
}
@keyframes blink { from { opacity: 0.3; } to { opacity: 1; } }
.logs-console {
    flex: 1; overflow-y: auto; padding: 15px 20px;
    font-family: 'JetBrains Mono', 'Courier New', monospace; font-size: 0.82rem;
    line-height: 1.5; color: #a1a1aa; background: #020204;
    user-select: text; text-align: left;
}
.log-line { border-bottom: 1px solid rgba(255,255,255,0.02); padding: 2px 0; white-space: pre-wrap; }
.log-line.system { color: #818cf8; }
.log-line.info { color: #a1a1aa; }
.log-line.warning { color: #fbbf24; }
.log-line.error { color: #f87171; font-weight: 600; }
.log-line.success { color: #34d399; }


/* ═══════════ STORAGE MANAGER ═══════════ */
.storage-summary-card {
    background: var(--bg-elevated); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px;
    text-align: left;
}
.storage-list-container {
    display: flex; flex-direction: column; gap: 8px;
}
.storage-item {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-surface); border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md); padding: 12px 18px;
    transition: border-color var(--transition); text-align: left;
}
.storage-item:hover { border-color: var(--border-dim); }
.storage-item-info { display: flex; flex-direction: column; gap: 4px; }
.storage-item-title { font-weight: 700; font-size: 0.92rem; color: var(--text-primary); }
.storage-item-size { font-size: 0.78rem; color: var(--accent); font-weight: 600; }
.storage-trim-btn {
    background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.2);
    color: #f87171; border-radius: var(--radius-sm); padding: 6px 12px;
    font-size: 0.78rem; font-weight: 600; cursor: pointer; transition: all 0.2s ease;
}
.storage-trim-btn:hover { background: #ef4444; color: #fff; }


/* ═══════════ Cinematic Cover Card Header ═══════════ */
.reader-cinematic-header {
    position: relative; width: 100%; min-height: 400px; display: flex;
    align-items: center; justify-content: center; overflow: hidden;
    padding: 80px 20px 40px; border-bottom: 1px solid rgba(255,255,255,0.08);
    background: #040406; text-align: left;
}
.cinematic-blur-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover; background-position: center;
    filter: blur(60px) brightness(0.25); transform: scale(1.1);
    opacity: 0.85; z-index: 1;
}
.cinematic-content {
    position: relative; z-index: 2; max-width: 800px; display: flex;
    gap: 30px; align-items: center; width: 100%;
}
.cinematic-cover {
    width: 160px; aspect-ratio: 3/4; border-radius: var(--radius-md);
    box-shadow: 0 12px 36px rgba(0,0,0,0.8), 0 0 20px rgba(168,85,247,0.15);
    border: 1px solid rgba(255,255,255,0.15); object-fit: cover;
    flex-shrink: 0;
}
.cinematic-info { display: flex; flex-direction: column; gap: 12px; color: #e4e4e7; }
.cinematic-title { font-size: 1.8rem; font-weight: 900; line-height: 1.2; text-shadow: 0 4px 12px rgba(0,0,0,0.6); }
.cinematic-rating { display: flex; align-items: center; gap: 6px; font-weight: 700; color: #facc15; }
.cinematic-desc { font-size: 0.85rem; line-height: 1.5; color: #a1a1aa; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; text-shadow: 0 2px 4px rgba(0,0,0,0.5); }
.cinematic-meta-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.meta-pill { font-size: 0.7rem; font-weight: 600; padding: 3px 8px; border-radius: var(--radius-sm); background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); color: #d4d4d8; text-transform: uppercase; }
.meta-pill.genre { border-color: rgba(168,85,247,0.25); background: rgba(168,85,247,0.04); color: #c084fc; }
.meta-pill.status-tag { border-color: rgba(34,197,94,0.25); background: rgba(34,197,94,0.04); color: #4ade80; }


/* ═══════════ DISCUSSION & COMMENTS ═══════════ */
.comments-section-container {
    max-width: var(--reader-max-width, 800px); margin: 60px auto 40px;
    padding: 30px; border-top: 1px solid var(--border-subtle);
    display: flex; flex-direction: column; gap: 24px; text-align: left;
}
.comments-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-subtle); padding-bottom: 12px; }
.comments-header h3 { font-size: 1.1rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }
.comments-count { font-size: 0.82rem; font-weight: 600; color: var(--accent); }
.comment-input-area { display: flex; flex-direction: column; gap: 10px; background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 15px; }
.comment-input-area input { background: var(--bg-elevated); border: 1px solid var(--border-dim); color: var(--text-primary); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.85rem; outline: none; transition: border-color 0.2s ease; }
.comment-input-area input:focus { border-color: var(--accent); }
.comments-list { display: flex; flex-direction: column; gap: 12px; }
.comment-card { background: rgba(255,255,255,0.01); border: 1px solid rgba(255,255,255,0.03); border-radius: var(--radius-md); padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; }
.comment-card-header { display: flex; justify-content: space-between; font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); }
.comment-user { color: var(--accent); font-weight: 700; }
.comment-time { color: var(--text-muted); font-size: 0.7rem; }
.comment-body { font-size: 0.88rem; line-height: 1.45; color: var(--text-primary); }


/* ═══════════ READING STATISTICS DASHBOARD ═══════════ */
.stats-tracker-dashboard {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px; max-width: 900px; width: 100%; margin: 24px auto 0;
    padding: 0 20px; box-sizing: border-box;
}
.stats-card {
    background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.04);
    border-radius: var(--radius-lg); padding: 16px 20px; display: flex;
    align-items: center; gap: 16px; transition: all 0.3s ease;
    backdrop-filter: blur(10px); text-align: left;
}
.stats-card:hover {
    transform: translateY(-2px); border-color: rgba(168,85,247,0.15);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    background: rgba(255,255,255,0.04);
}
.stats-icon {
    width: 44px; height: 44px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0;
}
.stats-icon svg { width: 22px; height: 22px; }
.stats-info { display: flex; flex-direction: column; gap: 4px; }
.stats-label { font-size: 0.72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stats-value { font-family: 'JetBrains Mono', monospace; font-size: 1.4rem; font-weight: 900; color: var(--text-primary); text-shadow: 0 0 10px rgba(255,255,255,0.1); }


/* ═══════════ DOWNLOADS & SYNC MANAGERS ═══════════ */
.downloads-manager-grid, .sync-manager-grid {
    display: flex; flex-direction: column; gap: 12px;
}
.download-item-row, .sync-item-row {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    transition: border-color var(--transition), transform var(--transition);
}
.download-item-row:hover, .sync-item-row:hover {
    border-color: var(--border-default);
    transform: translateY(-1px);
}
.download-item-row-left, .sync-item-row-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-grow: 1;
}
.download-item-info, .sync-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}
.download-item-row-title, .sync-item-row-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}
.download-item-row-details, .sync-item-row-details {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}
.download-item-status-tag {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
}
.status-tag-active {
    background: rgba(168, 85, 247, 0.1);
    color: var(--accent);
    border-color: rgba(168, 85, 247, 0.2);
}
.status-tag-complete {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.2);
}
.status-tag-failed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}
.status-tag-cancelled {
    background: rgba(90, 90, 114, 0.15);
    color: var(--text-muted);
    border-color: rgba(90, 90, 114, 0.25);
}
.status-tag-interrupted {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.2);
}
.download-item-progress-container {
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.download-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-active);
    border-radius: 3px;
    overflow: hidden;
}
.download-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    transition: width 0.3s ease;
}
.download-progress-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
}
.sync-checkbox-container {
    display: flex;
    align-items: center;
    justify-content: center;
}
.sync-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}
