/* Zen Reader - Phase 56: Hybrid Architecture (Clean UI + Deep Mechanics) */
:root {
    /* ... diğer değişkenler ... */
    --bionic-color: #f1c40f;
    /* Varsayılan Altın Sarısı */
    /* --- CORE COLORS --- */
    --bg-main: #121212;
    --bg-card: #1e1e1e;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --accent: #9D00FF;

    /* --- GHOST UI VARIABLES --- */
    --glass-bg: rgba(20, 20, 20, 0.95);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(30, 30, 30, 0.4);

    /* --- TYPOGRAPHY --- */
    --font-ui: system-ui, -apple-system, sans-serif;
    --font-reading: 'Georgia', serif; /* Default, overridden by classes */
}

/* --- THEME DEFINITIONS --- */
body.theme-light {
    --bg-main: #ffffff;
    --bg-card: #f5f5f5;
    --text-primary: #1a1a1a;
    --text-secondary: #555555;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(0, 0, 0, 0.1);
    --card-bg: rgba(0, 0, 0, 0.05);
    --accent: #6c5ce7;
    /* Comment UI overrides */
    --comment-bg: rgba(0, 0, 0, 0.035);
    --comment-card-bg: #ffffff;
    --comment-border: rgba(0, 0, 0, 0.1);
    --comment-text: #1a1a1a;
    --comment-heading: #000000;
    --comment-meta: #555555;
    --comment-input-text: #000000;
    --comment-placeholder: rgba(0, 0, 0, 0.4);
    --comment-icon: #555555;
    --comment-tab-active-bg: rgba(108, 92, 231, 0.15);
    --comment-tab-active-text: #6c5ce7;
    --comment-vignette-start: rgba(255, 255, 255, 0.98);
    --comment-vignette-end: rgba(255, 255, 255, 0.88);
    --comment-banner-blend: rgba(255, 255, 255, 0.4);
    --comment-action-hover-bg: rgba(0, 0, 0, 0.06);
    --comment-tool-bg: rgba(0, 0, 0, 0.05);
    --comment-danger: #ef4444;
    --comment-warning: #ca8a04;
    --comment-link: #6c5ce7;
    --comment-link-hover: #5a4bcf;
    --comment-attachment-bg: rgba(0, 0, 0, 0.05);
    --comment-spoiler-bg: rgba(255, 255, 255, 0.8);
    --comment-border-focus: rgba(108, 92, 231, 0.45);
    --comment-border-focus-shadow: rgba(108, 92, 231, 0.08);
}

body.theme-sepia {
    --bg-main: #f4ecd8;
    --bg-card: #e8dfc8;
    --text-primary: #433422;
    --text-secondary: #8b7050;
    --glass-bg: rgba(244, 236, 216, 0.95);
    --glass-border: rgba(100, 80, 50, 0.15);
    --card-bg: rgba(100, 80, 50, 0.05);
    --accent: #d35400;
    /* Comment UI overrides */
    --comment-bg: rgba(100, 80, 50, 0.05);
    --comment-card-bg: #f4ecd8;
    --comment-border: rgba(100, 80, 50, 0.15);
    --comment-text: #433422;
    --comment-heading: #2c2216;
    --comment-meta: #8b7050;
    --comment-input-text: #2c2216;
    --comment-placeholder: rgba(67, 52, 34, 0.5);
    --comment-icon: #8b7050;
    --comment-tab-active-bg: rgba(211, 84, 0, 0.15);
    --comment-tab-active-text: #d35400;
    --comment-vignette-start: rgba(244, 236, 216, 0.98);
    --comment-vignette-end: rgba(244, 236, 216, 0.88);
    --comment-banner-blend: rgba(244, 236, 216, 0.4);
    --comment-action-hover-bg: rgba(100, 80, 50, 0.08);
    --comment-tool-bg: rgba(100, 80, 50, 0.05);
    --comment-danger: #d93838;
    --comment-warning: #b47000;
    --comment-link: #d35400;
    --comment-link-hover: #b04600;
    --comment-attachment-bg: rgba(100, 80, 50, 0.1);
    --comment-spoiler-bg: rgba(244, 236, 216, 0.8);
    --comment-border-focus: rgba(211, 84, 0, 0.45);
    --comment-border-focus-shadow: rgba(211, 84, 0, 0.08);
}

/* Force class-based themes to override system preferences */
body.theme-light,
body.theme-sepia,
body.theme-dark {
    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    body.theme-light,
    body.theme-sepia {
        /* Override dark mode preference when light/sepia theme is explicitly selected */
        background-color: var(--bg-main) !important;
        color: var(--text-primary) !important;
    }
}

/* Base Styles */
body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-ui);
    margin: 0;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    /* Prevent horizontal scroll in vertical mode */
}

/* =========================================
   1. GHOST UI (TOPBAR & SIDEBAR)
   ========================================= */
#ghost-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    transition: transform 0.3s ease;
}

.topbar-left a,
.menu-btn {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Light/Sepia Theme Text Color Fixes */
body.theme-light .topbar-left a,
body.theme-light .menu-btn,
body.theme-light .topbar-left span {
    color: #1a1a1a !important;
}

body.theme-sepia .topbar-left a,
body.theme-sepia .menu-btn,
body.theme-sepia .topbar-left span {
    color: #433422 !important;
}

#ghost-sidebar {
    position: fixed;
    top: 0;
    right: -320px;
    width: 300px;
    height: 100vh;
    background: var(--glass-bg);
    border-left: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    z-index: 2001;
    padding: 20px;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

#ghost-sidebar.active {
    right: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

/* Sidebar text colors for light/sepia themes */
body.theme-light .sidebar-header h3,
body.theme-light .sidebar-close,
body.theme-light .sidebar-label,
body.theme-light .sidebar-section {
    color: #1a1a1a !important;
}

body.theme-sepia .sidebar-header h3,
body.theme-sepia .sidebar-close,
body.theme-sepia .sidebar-label,
body.theme-sepia .sidebar-section {
    color: #433422 !important;
}

.sidebar-close {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover {
    background: rgba(255, 50, 50, 0.2);
    border-color: red;
}

.sidebar-section {
    margin-bottom: 25px;
}

.sidebar-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.theme-grid {
    display: flex;
    gap: 10px;
}

.theme-btn {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    font-size: 1.2rem;
    transition: transform 0.2s;
}

.theme-btn:hover {
    transform: translateY(-2px);
}

.theme-btn[data-theme="dark"] {
    background: #121212;
    color: #fff;
}

.theme-btn[data-theme="sepia"] {
    background: #f4ecd8;
    color: #433422;
}

.theme-btn[data-theme="light"] {
    background: #ffffff;
    color: #000;
}

input[type=range] {
    width: 100%;
    accent-color: var(--accent);
    cursor: pointer;
}

#ghost-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

#ghost-overlay.active {
    display: block;
    opacity: 1;
}

/* =========================================
   2. READER CONTENT (Standard Mode)
   ========================================= */
.reader-container {
    max-width: 800px;
    margin: 80px auto 100px auto;
    padding: 0 20px;
}

.chapter-heading {
    text-align: center;
    margin-bottom: 40px;
    color: var(--text-primary);
    font-family: var(--font-reading);
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1.3;
}

.content-body {
    font-family: var(--font-reading);
    font-size: 1.2rem;
    line-height: 1.8;
    color: var(--text-primary);
}

/* Content text colors for light/sepia themes */
body.theme-light .content-body {
    color: #1a1a1a !important;
}

body.theme-sepia .content-body {
    color: #433422 !important;
}

/* Fix for Mobile Dark Mode (Force White Text) */
body.theme-dark .content-body,
body.theme-dark .content-body p {
    color: #e0e0e0 !important;
}

/* Nav Buttons */
.chapter-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 60px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

.nav-btn {
    padding: 10px 20px;
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
    border: 1px solid var(--glass-border);
}

.nav-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* =========================================
   3. ZEN MODE (RESTORED MECHANICS)
   ========================================= */
/* Hide Standard UI in Zen */
body.zen-active #ghost-topbar {
    transform: translateY(-100%);
}

body.zen-active .chapter-nav,
body.zen-active .chapter-heading,
body.zen-active #interaction-zone,
body.zen-active .reader-header,
body.zen-active footer {
    display: none !important;
}

/* Zen Container - The "Book" View */
body.zen-active .zen-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    background-color: var(--bg-main);
    /* Theme Match! */
    display: flex;
    align-items: center;
    justify-content: center;
}

body.zen-active .zen-book-container {
    width: 90vw !important;
    max-width: var(--reader-width, 1400px); /* Use CSS variable or let JS override style attribute */
    height: 85vh !important;
    margin: 0 auto;
    overflow-x: scroll;
    overflow-y: hidden;
    /* Horizontal Scroll */

    /* COLUMN MAGIC */
    column-fill: auto;
    column-width: 100%;
    /* Default mobile */
    column-gap: 40px;
    /* scroll-snap-type: x mandatory; */
    /* DISABLED - JS kontrolü ele aldı */
    /* scroll-behavior: smooth; */
    /* DISABLED - JS kontrolü ele aldı */

    /* Hide Scrollbars */
    -ms-overflow-style: none;
    scrollbar-width: none;
}

body.zen-active .zen-book-container::-webkit-scrollbar {
    display: none;
}

/* Zen Text Content */
body.zen-active .content-body {
    height: 100%;
    margin: 0;
    box-sizing: border-box;
    font-size: 1.15rem;
    text-align: justify;
    scroll-snap-align: start;
    padding: 0 10px;
}

/* Desktop: Dual Column */
@media (min-width: 1024px) {
    body.zen-active .zen-book-container .content-body {
        column-count: 2 !important;
        column-gap: 60px !important;
        column-rule: 1px solid var(--glass-border);
        width: 100%;
        height: 100%;
    }
}

/* Zen Exit Button (Floating) */
.zen-exit-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1600;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zen-exit-btn:hover {
    background: var(--accent);
    color: white;
}

/* Zen Settings Button (Floating) */
.zen-settings-btn {
    position: fixed;
    top: 20px;
    right: 70px;
    /* Positioned to the left of the exit button */
    z-index: 1600;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zen-settings-btn:hover {
    background: var(--accent);
    color: white;
}

/* =========================================
   4. SOCIAL & COMMENTS (RESTORED STYLES)
   ========================================= */
.interaction-zone {
    margin-top: 80px;
    padding-bottom: 50px;
}

/* Pulse Reactions */
.pulse-reaction-bar {
    text-align: center;
    padding: 30px;
    margin-bottom: 30px;
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.pulse-reaction-bar h3 {
    margin-top: 0;
    margin-bottom: 25px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 1px;
}

.reactions-grid {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.reaction-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    padding: 12px 25px;
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    gap: 10px;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.reaction-btn:hover {
    transform: translateY(-5px) scale(1.05);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.reaction-emoji {
    font-size: 1.6rem;
    line-height: 1;
}

.reaction-btn.active {
    border-color: var(--accent);
    background: rgba(157, 0, 255, 0.15);
    box-shadow: 0 0 15px rgba(157, 0, 255, 0.3);
}

/* Agora Comments */
.agora-container h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.comment-box,
.comment-item {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

/* User Badge */
.user-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    background: rgba(157, 0, 255, 0.1);
    color: var(--accent);
    font-weight: bold;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

/* Textarea */
#commentText {
    width: 100%;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 15px;
    border-radius: 8px;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 10px;
    box-sizing: border-box;
}

#commentText:focus {
    outline: none;
    border-color: var(--accent);
}

/* Comments List */
.comment-item {
    display: flex;
    gap: 15px;
    animation: fadeIn 0.5s ease;
}

.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
}

.comment-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.comment-author {
    color: var(--text-primary);
    font-weight: bold;
    margin-right: 10px;
}

.comment-text {
    line-height: 1.5;
    color: var(--text-primary);
}

/* Delete Comment Button */
.delete-comment-btn {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    color: #ff6b6b;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    margin-left: auto;
    flex-shrink: 0;
}

.delete-comment-btn:hover {
    background: rgba(255, 0, 0, 0.25);
    border-color: #ff6b6b;
    transform: scale(1.05);
}

/* Comment Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(-20px);
    }
}

/* === PHASE 56.5: FLUID ANIMATIONS === */
/* Zen Modu Açılış Animasyonu */
body.zen-active .zen-book-container {
    animation: zenEntrance 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
    transform: scale(0.98) translateY(20px);
}

@keyframes zenEntrance {
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Sayfalar Arası Yumuşak Geçiş (Scroll Snap İyileştirmesi) */
.zen-book-container {
    scroll-behavior: smooth;
    /* Touchpadler için daha akıcı kaydırma */
    -webkit-overflow-scrolling: touch;
}

/* =========================================
   5. GAMIFICATION (XP TOAST)
   ========================================= */
.xp-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(18, 18, 18, 0.95);
    border: 1px solid var(--accent);
    border-left: 5px solid var(--accent);
    color: #fff;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5), 0 0 15px rgba(157, 0, 255, 0.3);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 15px;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55);
    font-family: var(--font-ui);
    backdrop-filter: blur(10px);
}

.xp-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.xp-badge {
    background: var(--accent);
    color: #fff;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 0.9rem;
    box-shadow: 0 0 10px var(--accent);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    min-width: 40px;
    text-align: center;
}

.xp-content {
    display: flex;
    flex-direction: column;
}

.xp-title {
    font-weight: bold;
    font-size: 0.85rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

/* Info Toast (Simple) */
.info-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(30, 30, 30, 0.9);
    border: 1px solid var(--glass-border);
    color: #eee;
    padding: 12px 24px;
    border-radius: 30px;
    z-index: 10000;
    opacity: 0;
    transition: all 0.4s ease;
    font-size: 0.9rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    backdrop-filter: blur(5px);
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* =========================================
   6. READER UPGRADE (FAZ 76)
   ========================================= */

/* --- Bionic Reading Styles (Revised) --- */
.bionic-reading #chapter-content b {
    font-weight: 800;
    /* Kalınlık aynen kalıyor */
    opacity: 1;
    color: var(--bionic-color);
    /* Seçilen renk */
    /* text-shadow: 0 0 5px var(--bionic-color); <-- BU SATIRI SİLİYORUZ */
    transition: color 0.3s ease;
}



/* --- AKILLI KONTRAST (LIGHT MODE FIX) --- */
/* Eğer tema 'Light' veya 'Sepia' ise ve Biyonik aktifse */
body.theme-light .bionic-reading #chapter-content b,
body.theme-sepia .bionic-reading #chapter-content b {
    /* Renkleri biraz koyulaştır ki beyazda okunsun */
    filter: brightness(0.8) contrast(1.2);
}


/* --- Font Families --- */
body.font-serif, body.font-serif .content-body { font-family: 'Merriweather', 'Georgia', serif; }
body.font-sans, body.font-sans .content-body { font-family: 'Roboto', 'Inter', sans-serif; }
body.font-mono, body.font-mono .content-body { font-family: 'Courier Prime', 'Courier New', monospace; }

body.font-roboto, body.font-roboto .content-body { font-family: 'Roboto', sans-serif; }
body.font-source, body.font-source .content-body { font-family: 'Source Sans Pro', sans-serif; }
body.font-nunito, body.font-nunito .content-body { font-family: 'Nunito', sans-serif; }
body.font-merriweather, body.font-merriweather .content-body { font-family: 'Merriweather', serif; }
body.font-lora, body.font-lora .content-body { font-family: 'Lora', serif; }
body.font-comic, body.font-comic .content-body { font-family: 'Comic Neue', cursive; }
body.font-patrick, body.font-patrick .content-body { font-family: 'Patrick Hand', cursive; }
body.font-dyslexic, body.font-dyslexic .content-body { font-family: 'OpenDyslexic', 'Comic Sans MS', sans-serif; line-height: 2 !important; }


/* --- Sidebar Groups & Headers --- */
.sidebar-group {
    margin-bottom: 20px;
}

.sidebar-group-title {
    font-size: 0.75rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin: 0 0 15px 0;
    opacity: 0.8;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 5px;
}

.sidebar-divider {
    border: 0;
    height: 1px;
    background: var(--glass-border);
    margin: 20px 0;
}


/* --- Font Buttons --- */
.font-family-grid {
    display: flex;
    gap: 8px;
}

.font-btn {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.font-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.font-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.font-serif {
    font-family: 'Merriweather', serif;
}

.font-sans {
    font-family: 'Inter', sans-serif;
}

.font-dyslexic {
    font-family: 'Comic Sans MS', sans-serif;
}


/* --- Toggle Switch (iOS Style) --- */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border: 1px solid var(--glass-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--accent);
    border-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(24px);
    background-color: white;
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}


/* --- Auto-Scroll Controls --- */
.auto-scroll-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.small-btn {
    padding: 8px 15px;
    font-size: 0.9rem;
}

.styled-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: var(--glass-border);
    border-radius: 2px;
    outline: none;
}

.styled-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-card);
}

/* Disabled State for Zen Mode (Auto Scroll) */
.auto-scroll-controls.disabled {
    opacity: 0.4;
    pointer-events: none;
    filter: grayscale(1);
}

.bionic-color-grid {
    display: flex;
    gap: 12px;
    margin-top: 15px;
    flex-wrap: wrap; /* Fix overflow */
    justify-content: center; /* Center items on mobile */
}

.color-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--glass-border);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: var(--accent);
}

.color-btn.active {
    border-color: white;
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
    transform: scale(1.15);
}

/* Auto Scroll Section Improvements */
#auto-scroll-section {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

#auto-scroll-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(5px);
    padding: 10px 18px;
    min-width: 110px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-primary);
    transition: all 0.2s;
    font-weight: 600;
}

#auto-scroll-btn:hover, #auto-scroll-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 5px 15px rgba(157, 0, 255, 0.3);
}

#auto-scroll-speed {
    flex: 1; /* Fill remaining space */
    height: 6px;
}

/* ============================
   HUD TEMA KURTARMA PAKETİ (HARDCODED & FINAL)
   ============================ */

/* --- 1. SEPIA MODU (SARI KAĞIT) --- */
/* Kartın Zemini */
body.theme-sepia #chapter-end-hud .nexus-card {
    background-color: #e8dfc8 !important;
    /* Krem Rengi */
    border: 1px solid #8b7050 !important;
}

/* Kartın İçindeki Tüm Yazılar (Başlık, Açıklama) */
body.theme-sepia #chapter-end-hud .nexus-card h2,
body.theme-sepia #chapter-end-hud .nexus-card p,
body.theme-sepia #chapter-end-hud .nexus-card span,
body.theme-sepia #chapter-end-hud .nexus-card div {
    color: #433422 !important;
    /* Koyu Kahve */
    text-shadow: none !important;
}

/* İkincil Butonlar (Yorumlar vb.) */
body.theme-sepia #chapter-end-hud .nav-btn:not(.primary-action) {
    border: 2px solid #433422 !important;
    /* Kahve Çerçeve */
    color: #433422 !important;
    /* Kahve Yazı */
    background: transparent !important;
}

/* Buton içindeki ikon ve yazılar */
body.theme-sepia #chapter-end-hud .nav-btn:not(.primary-action) * {
    color: #433422 !important;
}

/* İkincil Buton HOVER */
body.theme-sepia #chapter-end-hud .nav-btn:not(.primary-action):hover {
    background-color: #433422 !important;
    /* Zemin Kahve olsun */
    color: #e8dfc8 !important;
    /* Yazı Krem olsun */
}

body.theme-sepia #chapter-end-hud .nav-btn:not(.primary-action):hover * {
    color: #e8dfc8 !important;
}


/* --- 2. LIGHT MODU (BEYAZ SAYFA) --- */
/* Kartın Zemini */
body.theme-light #chapter-end-hud .nexus-card {
    background-color: #ffffff !important;
    /* Beyaz */
    border: 1px solid #cccccc !important;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.1);
}

/* Kartın İçindeki Yazılar */
body.theme-light #chapter-end-hud .nexus-card h2,
body.theme-light #chapter-end-hud .nexus-card p,
body.theme-light #chapter-end-hud .nexus-card span,
body.theme-light #chapter-end-hud .nexus-card div {
    color: #000000 !important;
    /* Simsiyah */
    text-shadow: none !important;
}

/* İkincil Butonlar */
body.theme-light #chapter-end-hud .nav-btn:not(.primary-action) {
    border: 2px solid #000000 !important;
    /* Siyah Çerçeve */
    color: #000000 !important;
    /* Siyah Yazı */
    background: transparent !important;
}

body.theme-light #chapter-end-hud .nav-btn:not(.primary-action) * {
    color: #000000 !important;
}

/* İkincil Buton HOVER */
body.theme-light #chapter-end-hud .nav-btn:not(.primary-action):hover {
    background-color: #000000 !important;
    /* Zemin Siyah */
    color: #ffffff !important;
    /* Yazı Beyaz */
}

body.theme-light #chapter-end-hud .nav-btn:not(.primary-action):hover * {
    color: #ffffff !important;
}


/* --- 3. DARK MODU (GECE - VARSAYILAN) --- */
body.theme-dark #chapter-end-hud .nexus-card {
    background-color: #1e1e1e !important;
    color: #e0e0e0 !important;
}

/* İkincil butonlar beyaz kalsın */
body.theme-dark #chapter-end-hud .nav-btn:not(.primary-action) {
    border: 2px solid #e0e0e0 !important;
    color: #e0e0e0 !important;
}


/* --- 4. BİRİNCİL BUTON (SONRAKİ BÖLÜM) - HER TEMADA SABİT --- */
#chapter-end-hud .nav-btn.primary-action {
    background-color: #9D00FF !important;
    /* Mor */
    color: #ffffff !important;
    /* Yazı Hep Beyaz */
    border: none !important;
}

#chapter-end-hud .nav-btn.primary-action * {
    color: #ffffff !important;
}

#chapter-end-hud .nav-btn.primary-action:hover {
    filter: brightness(1.2);
    /* Parlasın */
    transform: scale(1.05);
}

/* REAKSİYON BUTONLARI (NEON & GLASS) */
.reaction-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.reaction-btn:hover {
    background: rgba(138, 43, 226, 0.2);
    /* Senin mor rengin */
    border-color: #8a2be2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(138, 43, 226, 0.2);
    color: white;
}

.reaction-btn span:first-child {
    font-size: 1.2rem;
    /* Emojiyi büyüt */
}

.reaction-btn span:last-child {
    font-weight: bold;
    /* Sayıyı kalın yap */
}

/* =========================================
   8. SETTINGS MODAL & CONTROLS UI
   ========================================= */

/* Styled Select (TTS Voices) */
.styled-select {
    width: 100%;
    padding: 10px 15px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    border-radius: 8px;
    appearance: none; /* Remove default arrow */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.styled-select:hover {
    border-color: var(--accent);
}

.styled-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(157, 0, 255, 0.2);
}

.styled-select option {
    background: var(--bg-main);
    color: var(--text-primary);
    padding: 10px;
}

/* Sidebar Improvements */
.sidebar-section {
    background: rgba(255, 255, 255, 0.02);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    transition: border-color 0.2s;
    margin-bottom: 20px;
}

.sidebar-section:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.sidebar-label {
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--accent);
    opacity: 0.9;
    display: block;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

/* Fix Overflow */
.sidebar-content {
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding-right: 5px; /* Space for scrollbar */
}

/* Custom Scrollbar */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(157, 0, 255, 0.8);
}

/* ============================
   9. DISQUS DARK MODE FORCE (AGGRESSIVE)
   ============================ */
.comments-wrapper {
    background-color: #000000 !important; /* Pitch Black for Contrast Check */
    padding: 25px;
    border: 2px solid #333;
    border-radius: 12px;
}

/* ============================
   10. MOBILE RESPONSIVE FIXES
   ============================ */

@media (max-width: 768px) {
    /* Fix topbar overflow on mobile */
    #ghost-topbar {
        padding: 0 15px;
    }

    .topbar-left a span {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Ensure buttons don't overflow */
    .menu-btn,
    .nav-btn {
        font-size: 0.9rem;
        padding: 8px 15px;
        white-space: nowrap;
    }

    /* Chapter navigation responsive */
    .chapter-nav {
        flex-wrap: wrap;
        gap: 10px;
    }

    .chapter-nav .nav-btn {
        flex: 1;
        min-width: 140px;
        justify-content: center;
    }

    /* Chapter heading mobile size */
    .chapter-heading {
        font-size: 1.8rem;
        margin-bottom: 30px;
    }

    /* Content body mobile adjustments */
    .content-body {
        font-size: 1.1rem;
        line-height: 1.7;
    }

    /* Sidebar width adjustment */
    #ghost-sidebar {
        width: 280px;
        right: -300px;
    }

    /* Zen mode adjustments */
    body.zen-active .zen-book-container {
        width: 95vw !important;
        height: 90vh !important;
    }

    body.zen-active .content-body {
        font-size: 1.05rem;
        padding: 0 15px;
    }

    /* Reactions grid mobile */
    .reactions-grid {
        justify-content: center;
    }

    .reaction-btn {
        font-size: 0.95rem;
        padding: 8px 15px;
    }

    /* Interaction zone mobile spacing */
    .interaction-zone {
        margin-top: 50px;
        padding-bottom: 30px;
    }

    /* Comment form mobile */
    #commentText {
        font-size: 1rem;
        min-height: 100px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .chapter-heading {
        font-size: 1.5rem;
    }

    .content-body {
        font-size: 1rem;
    }

    .nav-btn {
        font-size: 0.85rem;
        padding: 6px 12px;
    }

    .topbar-left a span {
        display: none;
    }

    .menu-btn {
        font-size: 0.85rem;
    }
}

/* 
   Reading Progress Bar (Task Fix) 
   Sticky top, high z-index, no obstruction
*/
#reading-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(0,0,0,0.1);
    z-index: 9999;
    pointer-events: none;
}

#reading-progress-bar {
    height: 100%;
    background: var(--accent); /* Uses centralized accent color */
    width: 0%;
    transition: width 0.1s ease-out;
    box-shadow: 0 0 10px var(--accent-glow, rgba(147, 51, 234, 0.5));
}

/* Hide any potential conflicting progress bars if they exist */
.nprogress-custom-parent #nprogress { display: none !important; }