/* --- INTER (Интерфейс) --- */
@font-face { font-family: 'Inter'; src: url('../fonts/Inter_18pt-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/Inter_18pt-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/Inter_18pt-SemiBold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('../fonts/Inter_18pt-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

/* --- SPACE GROTESK (Логотипы и акценты) --- */
@font-face { font-family: 'Space Grotesk'; src: url('../fonts/SpaceGrotesk-Light.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url('../fonts/SpaceGrotesk-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url('../fonts/SpaceGrotesk-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url('../fonts/SpaceGrotesk-SemiBold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Space Grotesk'; src: url('../fonts/SpaceGrotesk-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

/* --- CORMORANT GARAMOND (Классика) --- */
@font-face { font-family: 'EB Garamond'; src: url('../fonts/CormorantGaramond-Light.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'EB Garamond'; src: url('../fonts/CormorantGaramond-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'EB Garamond'; src: url('../fonts/CormorantGaramond-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'EB Garamond'; src: url('../fonts/CormorantGaramond-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

/* --- CORMORANT INFANT (Сказки) --- */
@font-face { font-family: 'Cormorant Infant'; src: url('../fonts/CormorantInfant-Light.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Cormorant Infant'; src: url('../fonts/CormorantInfant-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Cormorant Infant'; src: url('../fonts/CormorantInfant-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Cormorant Infant'; src: url('../fonts/CormorantInfant-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

/* --- COMFORTAA (Округлый текст) --- */
@font-face { font-family: 'Comfortaa'; src: url('../fonts/Comfortaa-Light.woff2') format('woff2'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Comfortaa'; src: url('../fonts/Comfortaa-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Comfortaa'; src: url('../fonts/Comfortaa-Medium.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Comfortaa'; src: url('../fonts/Comfortaa-SemiBold.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Comfortaa'; src: url('../fonts/Comfortaa-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

/* --- ANONYMOUS PRO (Моноширинный) --- */
@font-face { font-family: 'Anonymous Pro'; src: url('../fonts/AnonymousPro-Regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Anonymous Pro'; src: url('../fonts/AnonymousPro-Bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Anonymous Pro'; src: url('../fonts/AnonymousPro-Italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }

/* --- ДЕКОРАТИВНЫЕ ШРИФТЫ --- */
@font-face { font-family: 'Steamy'; src: url('../fonts/steamy.woff2') format('woff2'); font-weight: normal; font-style: normal; font-display: swap; }
@font-face { font-family: 'Bebas Neue Local'; src: url('../fonts/bebas_neue_regular.woff2') format('woff2'); font-weight: normal; font-style: normal; font-display: swap; }
@font-face { font-family: 'Bebas Neue Local'; src: url('../fonts/bebas_neue_bold.woff2') format('woff2'); font-weight: bold; font-style: normal; font-display: swap; }
@font-face { font-family: 'Erkan'; src: url('../fonts/ekran.woff2') format('woff2'); font-weight: normal; font-style: normal; font-display: swap; }
@font-face { font-family: 'Excalifont'; src: url('../fonts/Excalifont-Regular.woff2') format('woff2'); font-weight: normal; font-style: normal; font-display: swap; }
@font-face { font-family: 'MakiSans'; src: url('../fonts/MakiSans-Regular.woff2') format('woff2'); font-weight: normal; font-style: normal; font-display: swap; }
@font-face { font-family: 'Gabriela'; src: url('../fonts/Gabriela-Regular.woff2') format('woff2'); font-weight: normal; font-style: normal; font-display: swap; }
@font-face { font-family: 'Bella Script'; src: url('../fonts/Bella_Script_CYR.woff2') format('woff2'); font-weight: normal; font-style: normal; font-display: swap; }
:root {
    /* --- ПАЛИТРА (DARK MODE) --- */
    
    /* Основные фоны */
    --bg-body: #0f0f10;
    --bg-card: #1c1c1e;
    --bg-sidebar: #141414;
    
    /* Градиенты */
    --hero-gradient-start: #1a1a1a;
    --hero-gradient-end: #0f0f10;
    
    /* Поверхности */
    --surface-1: rgba(255, 255, 255, 0.03);
    --surface-2: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --surface-active: rgba(255, 255, 255, 0.1);
    
    /* Стекло */
    --glass-bg: rgba(30, 30, 30, 0.70);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    
    /* Текст */
    --text-primary: #E4EBFB;
    --text-secondary: #A0A0A0;
    --text-muted: #666666;
    --text-inverse: #000000;
    
    /* Акценты */
    --accent-color: #D32F2F;
    --accent-hover: #b71c1c;
    --accent-glow: rgba(211, 47, 47, 0.4);
    --accent-bg-subtle: rgba(211, 47, 47, 0.15);
    
    --accent-gold: #FFB74D;
    --accent-gold-bg: rgba(255, 183, 77, 0.1);
    
    --danger-color: #ef5350;
    --danger-bg: rgba(211, 47, 47, 0.1);
    
    --success-color: #81c784;
    --success-bg: rgba(76, 175, 80, 0.2);

    /* UI Элементы */
    --border-color: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);
    --bg-dropdown: rgba(0, 0, 0, 0.2);
    --toggle-bg: #333333;
    --toggle-knob: #ffffff;
    
    /* Скроллбар */
    --scrollbar-track: rgba(255, 255, 255, 0.05);
    --scrollbar-thumb: var(--accent-color);
    --scrollbar-width: 8px;

    /* Размеры и шрифты */
    --nav-height: 60px;
    --border-radius-lg: 24px;
    --border-radius-md: 16px;
    --border-radius-sm: 12px;
    
    --font-ui: 'Inter', sans-serif;
    --font-book: 'EB Garamond', serif;
    --font-reader: 'EB Garamond', serif;
    
    --safe-top: env(safe-area-inset-top, 20px);
    --safe-bottom: env(safe-area-inset-bottom, 20px);
    --glider-bg: #48484A;

    --font-scale: 1;
    --reader-base-size: 20px;
    --reader-font-weight: 400;
    --reader-line-height: 1.6;
}

/* --- LIGHT THEME OVERRIDES --- */
body.theme-light {
    /* Основные фоны */
    --bg-body: #F2F2F7;
    --bg-card: #FFFFFF;
    --bg-sidebar: #E5E5EA;

    /* Градиенты */
    --hero-gradient-start: #FFFFFF;
    --hero-gradient-end: #F2F2F7;

    /* Поверхности */
    --surface-1: rgba(0, 0, 0, 0.03);
    --surface-2: rgba(0, 0, 0, 0.05);
    --surface-hover: rgba(0, 0, 0, 0.04);
    --surface-active: rgba(0, 0, 0, 0.1);

    /* Стекло */
    --glass-bg: rgba(255, 255, 255, 0.85); 
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);

    /* Текст */
    --text-primary: #000000;
    --text-secondary: #3C3C43;
    --text-muted: #8E8E93;
    --text-inverse: #FFFFFF;

    /* Акценты */
    --accent-glow: rgba(211, 47, 47, 0.2);
    
    /* UI Элементы */
    --border-color: rgba(60, 60, 67, 0.15);
    --border-hover: rgba(60, 60, 67, 0.25);
    --bg-dropdown: rgba(0, 0, 0, 0.05);
    --toggle-bg: #8E8E93;
    --toggle-knob: #FFFFFF;

    --scrollbar-track: rgba(0, 0, 0, 0.05);
    --glider-bg: #FFFFFF;
}

/* --- БАЗОВЫЕ СТИЛИ --- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

html:has(body.theme-light) {
    background-color: #F2F2F7;
}

i[class^="ri-"] {
    font-size: 20px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, transform 0.2s;
}

.nav-btn i {
    font-size: 24px;
}

.btn-action i {
    font-size: 20px;
}

.icon-action-btn i, 
.side-btn-sm i {
    font-size: 18px;
}

.fab-icon {
    font-size: 28px; 
}

.nav-item i {
    font-size: 24px;
}
.nav-item.active i {
    color: var(--accent-color);
}

.footer-action-btn i {
    font-size: 16px;
}

.item-icon i {
    font-size: 20px;
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: var(--font-ui);
    margin: 0; padding: 0;
    padding-bottom: calc(80px + var(--safe-bottom));
    padding-bottom: 0 !important;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a { text-decoration: none; color: inherit; }

/* --- GLOBAL SCROLLBAR --- */
::-webkit-scrollbar { width: var(--scrollbar-width); height: var(--scrollbar-width); }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-track:hover { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: calc(var(--scrollbar-width) / 2); 
    border: 1px solid var(--bg-body); 
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-gold); cursor: grab; }
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }

/* КОНТЕЙНЕРЫ */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0; }
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

/* --- HEADER --- */
.header {
    position: fixed; top: max(15px, var(--safe-top)); left: 15px; right: 15px;
    height: 60px; border-radius: 30px;
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 20px; z-index: 200; transition: transform 0.3s;
}
.logo-img { height: 28px; width: auto; display: block; }
body.theme-light .logo-img {
    filter: invert(1);
}
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--surface-2);
    display: flex; align-items: center; justify-content: center;
    font-weight: 100; font-size: 14px;
    border: 1.5px solid var(--glass-border); color: var(--text-primary);
    transition: transform 0.2s; overflow: hidden; padding: 0;
}
.user-avatar:active { transform: scale(0.95); }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* --- GREETING --- */
.greeting-block {
    margin-top: calc(90px + var(--safe-top)); padding: 0 20px; 
    margin-bottom: 10px; animation: fadeUp 0.6s ease-out;
}
.greeting-text { font-size: 24px; font-weight: 700; line-height: 1.2; }
.greeting-sub { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* --- HERO CAROUSEL --- */
.hero-wrapper { margin-top: 20px; position: relative; }
.hero-carousel {
    display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
    padding: 30px 20px 50px; 
    gap: 15px; scrollbar-width: none;
    scroll-behavior: smooth;
    margin-top: -30px; 
}
.hero-carousel::-webkit-scrollbar { display: none; }
.hero-slide { flex: 0 0 100%; scroll-snap-align: center; position: relative; }

.hero-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg); padding: 24px;
    position: relative; overflow: hidden;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border);
    display: flex; flex-direction: column; align-items: center; text-align: center;
    height: 100%;
}

.hero-bg-glow {
    position: absolute; top: -50%; left: -50%; width: 200%; height: 200%;
    z-index: 0; pointer-events: none; opacity: 0.15;
}
.glow-gold { background: radial-gradient(circle, var(--accent-gold) 0%, rgba(0,0,0,0) 60%); }
.glow-red { background: radial-gradient(circle, var(--accent-color) 0%, rgba(0,0,0,0) 60%); }

.hero-content { position: relative; z-index: 1; width: 100%; display: flex; flex-direction: column; align-items: center; }
.hero-text-group { display: contents; }

.hero-badges-slot {
    display: flex;
    align-items: center; 
    gap: 10px;
    min-height: 56px; 
    
    margin-bottom: 10px;
}
.hero-cover-wrapper {
    order: 2; position: relative; width: 160px; margin-bottom: 20px;
    border-radius: 12px; overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3); flex-shrink: 0;
}
.hero-text-info { order: 3; display: flex; flex-direction: column; align-items: center; width: 100%; }

.hero-cover { width: 100%; display: block; aspect-ratio: 2/3; object-fit: cover; }
.hero-badge {
    font-size: 11px; text-transform: uppercase; letter-spacing: 1px; font-weight: 800;
    margin-bottom: 15px; display: inline-block; padding: 6px 12px; border-radius: 20px;
}
.badge-gold { color: var(--accent-gold); background: var(--accent-gold-bg); }
.badge-red { color: #ff8a80; background: var(--accent-bg-subtle); } 
.badges-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 15px; }

.hero-title {
    font-weight: 700; font-size: 32px; line-height: 1.1; margin: 0 0 5px 0;
    color: var(--text-primary); letter-spacing: -0.5px;
}
.hero-meta { font-size: 14px; color: var(--text-secondary); margin-bottom: 25px; font-weight: 500; }

.btn-main {
    border: 1px solid transparent; 
    width: 100%; padding: 16px; border-radius: 18px;
    font-size: 16px; font-weight: 700; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    text-decoration: none; font-family: var(--font-ui); 
    transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}
.btn-main:active { transform: scale(0.96); }
.btn-gold { background: var(--accent-gold); color: #000; }
.btn-red { background: var(--accent-color); color: #ffffff; }
.btn-red:hover {
    background-color: var(--accent-hover);
    border-color: rgba(255, 255, 255, 0.3);
}
.btn-disabled {
    background: var(--surface-active) !important;
    color: var(--text-secondary) !important;
    cursor: default; pointer-events: none; border: 1px solid var(--border-color);
}

.progress-overlay { position: absolute; bottom: 0; left: 0; right: 0; height: 4px; background: rgba(0,0,0,0.5); }
.progress-val { height: 100%; background: var(--accent-color); }

.dots-container { display: flex; justify-content: center; gap: 8px; margin-top: -15px; margin-bottom: 30px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--glass-border); transition: 0.3s; }
.dot.active { background: var(--text-primary); width: 24px; border-radius: 4px; }
.carousel-arrow { display: none; }

/* --- LISTS --- */
.section-header { margin: 10px 0 15px; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; }
.section-title { font-size: 20px; font-weight: 800; margin: 0; letter-spacing: -0.5px; color: var(--text-primary); }

.scroll-container { display: flex; gap: 16px; overflow-x: auto; padding: 0 20px 10px; scrollbar-width: none; }
.scroll-container::-webkit-scrollbar { display: none; }

.book-card-sm { flex: 0 0 130px; display: flex; flex-direction: column; text-decoration: none; color: inherit; }
.cover-wrapper { 
    position: relative; border-radius: 16px; overflow: hidden; margin-bottom: 10px; 
    aspect-ratio: 2/3; background: var(--bg-card); 
}
.cover-wrapper img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s; }
.book-card-sm:active img { transform: scale(1.05); }
.book-title-sm { font-size: 14px; font-weight: 700; margin-bottom: 4px; line-height: 1.3; color: var(--text-primary); }
.book-author-sm { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

.mystery-box {
    background: linear-gradient(135deg, var(--surface-2), var(--bg-card)); 
    display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; position: relative;
}
.mystery-blur { position: absolute; inset: 0; filter: blur(8px) grayscale(0.8); opacity: 0.3; }
.mystery-content { position: relative; z-index: 2; text-align: center; }
.mystery-icon { 
    width: 32px; height: 32px; background: var(--surface-active); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; color: var(--text-primary);
}

/* --- BOTTOM NAV --- */
.bottom-nav {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    
    width: calc(100% - 40px); 
    max-width: 400px;
    
    height: 60px;
    border-radius: 24px;
    display: flex; justify-content: space-around; align-items: center;
    z-index: 200; 
    
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.nav-item {
    display: flex; align-items: center; justify-content: center; color: var(--text-secondary); 
    opacity: 0.5; transition: 0.3s; cursor: pointer; width: 60px; height: 100%;
}
.nav-item.active { opacity: 1; color: var(--text-primary); transform: scale(1.1); }
.nav-item.active svg { color: var(--accent-color); filter: drop-shadow(0 0 10px var(--accent-glow)); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ========================================= */
/* DESKTOP ADAPTATION (1024px+)              */
/* ========================================= */
@media (min-width: 1024px) {
    .container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 40px; }
    .header { width: 100%; max-width: 1200px; left: 50%; transform: translateX(-50%); top: 20px; padding: 0 40px; }
    .hero-wrapper { margin-top: 40px; }
    .hero-carousel { gap: 5px; }
    .hero-slide { padding: 0 10px; }
    .hero-card { padding: 40px 60px; min-height: 400px; display: flex; align-items: center; }
    .hero-content { flex-direction: row; justify-content: space-between; text-align: left; align-items: center; }
    .hero-text-group { display: flex; flex-direction: column; align-items: flex-start; flex: 1; order: initial; }
    .hero-badges-slot, .hero-text-info, .hero-cover-wrapper { order: initial; }
    .hero-badges-slot { justify-content: flex-start; width: 100%; }
    .hero-cover-wrapper { margin-left: 40px; margin-bottom: 0; width: 260px; transform: none; box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
    .hero-text-info { align-items: flex-start; text-align: left; width: 100%; }
    .hero-title { font-size: 48px; margin-bottom: 10px; }
    .hero-meta { font-size: 16px; margin-bottom: 30px; }
    .btn-main { width: auto; padding: 16px 40px; }
    .badges-row { justify-content: flex-start; }

    .carousel-arrow {
        display: flex; position: absolute; top: 50%; transform: translateY(-50%);
        width: 48px; height: 48px; border-radius: 50%;
        background: var(--bg-card); border: 1px solid var(--glass-border);
        box-shadow: 0 5px 20px rgba(0,0,0,0.3); color: var(--text-primary);
        align-items: center; justify-content: center; cursor: pointer; z-index: 10; transition: all 0.2s ease;
    }
    .carousel-arrow:hover {
        background: var(--surface-hover);
        color: var(--text-primary);
        border-color: var(--border-hover);
        backdrop-filter: blur(10px);
    }
    .arrow-prev { left: -14px; }
    .arrow-next { right: -14px; }
    .carousel-arrow.hidden { opacity: 0; pointer-events: none; }
    
    .section-header { margin: 40px 0 20px; padding: 0; }
    .scroll-container { padding: 0 0 20px 0; gap: 30px; }
    .book-card-sm { flex: 0 0 180px; }
    .book-title-sm { font-size: 16px; }
    .greeting-block { margin-top: calc(100px + var(--safe-top)); padding: 0; }
    .bottom-nav { max-width: 400px; }
}

/* ========================================= */
/* PAGE: DETAILS (КНИГА)                     */
/* ========================================= */
.nav-btn {
    position: fixed; top: max(20px, var(--safe-top)); width: 44px; height: 44px;
    border-radius: 50%; 
    background: var(--glass-bg); 
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border); color: var(--text-primary);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; cursor: pointer; transition: 0.2s;
}
.nav-btn:active { transform: scale(0.9); background: var(--surface-active); }
.nav-btn.left { left: 20px; }
.nav-btn.right { right: 20px; }
.nav-btn.liked svg { fill: var(--accent-color); color: var(--accent-color); }

.details-hero-wrapper { position: relative; width: 100%; display: flex; flex-direction: column; }
.cover-bg-mobile { position: relative; width: 100%; height: 55vh; overflow: hidden; display: flex; justify-content: center; }
.cover-img {
    width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 1;
    mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
}
body.theme-light .cover-img {
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 95%);
    mask-image: linear-gradient(to bottom, black 50%, transparent 95%);
}

.info-container { position: relative; margin-top: -120px; padding: 0 24px 30px; z-index: 20; display: block; flex-direction: column; justify-content: flex-end; }
.book-title {
    font-family: var(--font-book); font-size: 38px; line-height: 1; margin: 0 0 15px 0;
    text-shadow: 0 10px 30px rgba(0,0,0,0.8); color: var(--text-primary);
}

.meta-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 25px; }
.glass-tag {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
    padding: 6px 10px; border-radius: 8px;
    background: var(--surface-1); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border); color: var(--text-primary);
    display: flex; align-items: center; gap: 6px; height: 32px; transition: background 0.3s;
}

.glass-tag.accent {
    background: rgba(211, 47, 47, 0.1); 
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    box-shadow: 0 4px 10px rgba(211, 47, 47, 0.15); 
}

.progress-ring { width: 16px; height: 16px; transform: rotate(-90deg); }
.progress-ring circle { fill: transparent; stroke-width: 3; }
.ring-bg { stroke: var(--border-color); }
.progress-text { color: var(--accent-color); }

.progress-ring {
    width: 20px;
    height: 20px;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 3;
}

.ring-val {
    fill: none;
    stroke: var(--accent-color);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.4s ease;
}

.action-row { display: flex; gap: 10px; margin-bottom: 30px; }
.icon-action-btn {
    background: var(--surface-2); border: 1px solid var(--border-color);
    color: var(--text-primary); padding: 0 16px; height: 44px; border-radius: 14px;
    display: flex; align-items: center; gap: 10px; font-family: var(--font-ui); font-size: 13px; font-weight: 600;
    cursor: pointer; position: relative; transition: 0.2s;
}
.icon-action-btn:active { background: var(--surface-active); }
.icon-action-btn:hover { background: var(--surface-hover); border-color: var(--border-hover); }

.tooltip {
    position: absolute; bottom: 115%; left: 0;
    background: #222; color: #fff; padding: 10px 14px; border-radius: 10px;
    font-size: 12px; white-space: nowrap; pointer-events: none; opacity: 0;
    transition: 0.2s; box-shadow: 0 5px 20px rgba(0,0,0,0.6); z-index: 20; border: 1px solid rgba(255,255,255,0.15);
}
.tooltip::after {
    content: ''; position: absolute; top: 100%; left: 20px;
    border-width: 6px; border-style: solid; border-color: #222 transparent transparent transparent;
}
.tooltip.show { opacity: 1; bottom: 130%; }

.tabs-header { display: flex; gap: 25px; border-bottom: 1px solid var(--border-color); margin-bottom: 20px; }
.tab-btn {
    background: none; border: none; color: var(--text-secondary);
    font-family: var(--font-ui); font-size: 16px; font-weight: 600;
    padding-bottom: 12px; cursor: pointer; position: relative; transition: 0.3s;
}
.tab-btn.active { color: var(--text-primary); }
.tab-btn.active::after {
    content: ''; position: absolute; bottom: -1px; left: 0; right: 0;
    height: 3px; background: var(--accent-color); border-radius: 3px 3px 0 0;
}
.tab-content { display: none; animation: fadeUp 0.4s ease; }
.tab-content.active { display: block; }

.desc-text { font-size: 15px; line-height: 1.6; color: var(--text-secondary); }
.desc-text p { margin-bottom: 15px; }

.chapter-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 0; border-bottom: 1px solid var(--border-color);
    text-decoration: none; color: inherit; transition: 0.2s;
}
.chapter-item:hover { background: var(--surface-1); padding-left: 10px; padding-right: 10px; border-radius: 8px; border-bottom-color: transparent; }
.chapter-item:has(+ .chapter-item:hover) { border-bottom-color: transparent; }
.chapter-item.locked { opacity: 0.5; pointer-events: none; }
.ch-info { display: flex; flex-direction: column; gap: 4px; }
.ch-act { font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--text-muted); letter-spacing: 1px; }
.ch-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.chapter-item.active .ch-title { color: var(--accent-color); }
.chapter-item.active .ch-act { color: var(--accent-color); opacity: 0.6; }
.bookmark-icon { color: var(--accent-color); animation: pulse 2s infinite ease-in-out; }

.bottom-bar { position: fixed; bottom: max(14px, var(--safe-bottom)); left: 20px; right: 20px; z-index: 50; pointer-events: none; }
.btn-action {
    pointer-events: auto; 
    width: 100%; 
    
    background: rgba(211, 47, 47, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    
    height: 60px;
    padding: 16px;
    border-radius: 24px;
    
    font-family: var(--font-ui); 
    font-size: 16px; 
    font-weight: 600;
    color: var(--text-primary);
    
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    gap: 10px;
    padding-left: 24px; padding-right: 24px;
    
    text-decoration: none; 
    transition: transform 0.2s, background 0.2s;
}
.btn-action:active { transform: scale(0.97); }

@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.6; transform: scale(0.9); } }

.book-logo-title { display: block; width: 100%; max-width: 280px; height: auto; margin: 0 0 10px 0; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.9)); }
.book-author { font-family: var(--font-ui); font-size: 16px; font-weight: 500; color: var(--text-secondary); margin-bottom: 25px; }

.book-logo-mobile {
    display: block;
    width: 100%;
    max-width: 280px;
    height: auto;
    margin: 0 0 15px 0;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.book-art-desktop {
    display: none; 
}

@media (min-width: 1024px) {
    .book-logo-mobile {
        display: none; 
    }

    .book-art-desktop {
        display: block; 
        width: 100%;
        max-height: 200px; 
        object-fit: cover; 
        border-radius: 12px;
        margin-bottom: 25px;
        mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
        -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
        opacity: 0.8;
    }
}

/* Desktop Details (1024px+) */
.desktop-bg, .desktop-header, .desktop-side-group { display: none; }
@media (min-width: 1024px) {
    .desktop-bg {
        display: block; position: fixed; inset: 0; z-index: 0;
        background-color: var(--bg-body);
        background-image: radial-gradient(circle at 20% 30%, var(--surface-hover) 0%, transparent 60%);
        transform: translateZ(0); 
    }
    body:has(.details-hero-wrapper) { padding-bottom: 0; background-color: transparent; }
    .desktop-header { display: flex; top: 20px; max-width: 1200px; width: 100%; left: 50%; transform: translateX(-50%); padding: 0 40px; }
    .mobile-nav-btn { display: none !important; }

    .details-hero-wrapper {
        display: grid; grid-template-columns: 300px 1fr; gap: 60px; 
        max-width: 1200px; width: 100%; margin: 120px auto 100px; padding: 0 40px;
        align-items: start; position: relative; z-index: 2;
    }
    .cover-bg-mobile {
        width: 100%; height: auto; position: sticky; top: 120px; 
        display: flex; flex-direction: column; overflow: visible; order: 1; will-change: transform;
    }
    .cover-img { border-radius: 16px; aspect-ratio: 2/3; mask-image: none; box-shadow: 0 20px 50px rgba(0,0,0,0.5); margin-bottom: 25px; }
    .details-hero-wrapper .hero-bg-glow { display: none; }

    .desktop-side-group { display: flex; flex-direction: column; gap: 12px; width: 100%; }
    .main-read-btn {
        background: var(--accent-color); color: var(--text-inverse);
        padding: 18px; border-radius: 16px; font-family: var(--font-ui); font-size: 16px; font-weight: 700;
        text-align: center; text-decoration: none; box-shadow: 0 10px 30px var(--accent-glow);
        transition: background-color 0.2s, border-color 0.2s; border: 1px solid transparent;
        display: flex; justify-content: center; width: 100%;
        color: #fff;
    }
    .main-read-btn:hover { background-color: var(--accent-hover); border-color: rgba(255,255,255,0.3); }

    .sidebar-small-row { display: flex; gap: 10px; width: 100%; }
    .side-btn-sm {
        flex: 1; height: 44px; border-radius: 12px;
        background: var(--surface-1); border: 1px solid var(--border-color);
        color: var(--text-muted); font-weight: 600; font-family: var(--font-ui); font-size: 13px;
        display: flex; align-items: center; justify-content: center; gap: 8px;
        cursor: pointer; transition: 0.2s; position: relative;
    }
    .side-btn-sm:hover { background: var(--surface-hover); color: var(--text-primary); border-color: var(--border-hover); }

    .info-container {
        margin-top: 0; z-index: 1; order: 2;
        background: var(--glass-bg); 
        backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
        border: 1px solid var(--glass-border); border-radius: 24px; padding: 50px;
        box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    }
    .book-logo-title { max-width: 400px; margin-bottom: 15px; filter: drop-shadow(0 5px 15px rgba(0,0,0,0.5)); }
    .book-title { display: none; } 
    .book-author { font-size: 18px; color: var(--text-secondary); margin-bottom: 35px; }
    .meta-row { margin-bottom: 50px; gap: 10px; }
    .mobile-only-actions, .bottom-bar { display: none !important; }
    .tabs-header { justify-content: flex-start; gap: 40px; margin-bottom: 30px; border-bottom: 1px solid var(--border-color); padding-bottom: 0; }
    .tab-btn { font-size: 16px; padding-bottom: 15px; color: var(--text-muted); }
    .tab-btn.active { color: var(--text-primary); }
    .desc-text { font-family: var(--font-ui); font-size: 16px; line-height: 1.7; color: var(--text-primary); max-width: 100%; font-weight: 400; }
    .ch-item { padding: 18px 0; border-bottom: 1px solid var(--border-color); }
    .ch-item:hover { background: var(--surface-1); padding-left: 15px; border-radius: 8px; border-color: transparent; }
    body.theme-light .book-logo-title { filter: invert(1); opacity: 0.9; }
}

@media (max-width: 1023px) {
    body.theme-light .book-logo-title {
        filter: none;
        filter: drop-shadow(0 1px 2px rgba(0,0,0,0.8)) drop-shadow(0 4px 15px rgba(0,0,0,0.5));
        opacity: 1;
    }
}

/* --- AGE VERIFICATION MODAL --- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: 0.3s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-glass {
    background: var(--bg-card); border: 1px solid var(--glass-border); border-radius: 28px; padding: 40px;
    width: 90%; max-width: 420px; text-align: center;
    box-shadow: 0 30px 80px rgba(0,0,0,0.6); transform: scale(0.9); transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.modal-overlay.active .modal-glass { transform: scale(1); }
.modal-icon {
    width: 60px; height: 60px; margin: 0 auto 25px;
    border-radius: 50%; border: 2px solid var(--accent-color); color: var(--accent-color);
    font-family: var(--font-ui); font-weight: 800; font-size: 22px;
    display: flex; align-items: center; justify-content: center;
}
.modal-title { font-size: 24px; font-weight: 700; color: var(--text-primary); margin: 0 0 15px 0; }
.modal-desc { font-size: 16px; color: var(--text-secondary); line-height: 1.6; margin: 0 0 30px 0; }
.modal-actions { display: flex; gap: 10px; }
.btn-modal {
    flex: 1; padding: 14px; border-radius: 14px; border: none; font-family: var(--font-ui); font-size: 14px; font-weight: 600;
    cursor: pointer; transition: 0.2s;
}
.btn-modal.cancel { background: var(--surface-2); color: var(--text-secondary); }
.btn-modal.cancel:hover { background: var(--surface-hover); color: var(--text-primary); }
.btn-modal.confirm { background: var(--accent-color); color: #fff; }
.btn-modal.confirm:hover { background: var(--accent-hover); }


/* ========================================= */
/* PAGE: READER                     */
/* ========================================= */
.reader-page {
    --reader-size: 20px;
    --reader-line-height: 1.6;
    --reader-align: left;
    --fab-size: 64px;
    --font-steamy: 'Steamy', cursive;
}

.reader-page .header.merged { border-bottom-right-radius: 0; box-shadow: none; border-bottom: none; background: var(--glass-bg); }
.reader-page .header.hidden { transform: translateY(-100px); }

.reader-head-btn {
    width: 44px; height: 44px; background: none; border: none; color: inherit;
    border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.reader-head-btn:active { background: var(--surface-active); transform: scale(0.9); }

.sidebar-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 90;
    opacity: 0; pointer-events: none; transition: 0.3s;
}
.sidebar-overlay.active { opacity: 1; pointer-events: auto; }

.sidebar {
    position: fixed; top: 75px; right: 15px; width: 280px; max-height: 70vh;
    background: var(--glass-bg); 
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border); border-top: none;
    border-radius: 0 0 24px 24px; z-index: 100;
    transform-origin: top right; transform: scaleY(0.8) translateY(-20px);
    opacity: 0; visibility: hidden; transition: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow-y: auto; box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}
.sidebar.active { transform: scaleY(1) translateY(0); opacity: 1; visibility: visible; }

.toc-list { display: flex; flex-direction: column; padding: 0; }
.toc-item { 
    padding: 14px 24px; border-bottom: 1px solid var(--border-color);
    cursor: pointer; display: flex; flex-direction: column; gap: 2px; transition: background 0.2s;
}
.toc-item:hover { background: var(--surface-hover); }
.toc-item:active { background: var(--surface-active); }
.toc-item.active .toc-title { color: var(--accent-color); }
.toc-act { font-size: 10px; font-weight: 700; text-transform: uppercase; opacity: 0.5; letter-spacing: 1px; }
.toc-title { font-size: 15px; font-weight: 500; }

.reader-container { padding: 100px 24px 50px; max-width: 700px; margin: 0 auto; }
.chapter-header { margin-bottom: 40px; text-align: center; }
.act-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; opacity: 0.5; margin-bottom: 10px; }
.chapter-num { font-family: 'Bella Script'; color: var(--accent-color); font-size: 80px; font-weight: 400; display: block; }
.chapter-name { font-family: 'Bella Script'; font-size: 90px; line-height: 0.6; margin-top: -35px; font-weight: 400; color: var(--accent-color); }

.book-text {
    font-family: var(--font-reader); font-weight: var(--reader-font-weight); font-size: calc(var(--reader-base-size) * var(--font-scale));
    line-height: var(--reader-line-height, 1.6); text-align: var(--reader-align); color: inherit;
}
.book-text p { margin-bottom: 1.2em; }
.book-text > p:first-of-type::first-letter {
    font-family: 'Gabriela', serif; font-size: 3.5em; float: left; line-height: 0.8;
    margin-right: 0.1em; margin-top: -0.1em; color: var(--accent-color); font-weight: 700;
}

.book-image, .zoomable-image-wrapper img {
    display: block; max-width: 100%; height: auto; margin: 40px auto; border: none; box-shadow: none; border-radius: 0;
}
.zoomable-image-wrapper { position: relative; display: block; margin: 40px auto; max-width: 100%; cursor: pointer; }
.zoom-icon {
    position: absolute; bottom: 15px; right: 15px; width: 36px; height: 36px; 
    background: rgba(0,0,0,0.6); backdrop-filter: blur(5px); border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; color: #fff; border: 1px solid rgba(255,255,255,0.2);
}

.lightbox {
    position: fixed; inset: 0; z-index: 1000; background: #000;
    display: flex; flex-direction: column; opacity: 0; pointer-events: none; transition: 0.3s;
}
.lightbox.active { opacity: 1; pointer-events: auto; }
.lightbox-close {
    position: absolute; top: 20px; right: 20px; z-index: 1002; width: 44px; height: 44px; 
    background: rgba(255,255,255,0.1); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; cursor: pointer;
}
.lightbox-content { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.lightbox-img { max-width: 100dvw; max-height: 100vh; object-fit: contain; transition: 0.3s; }
.lightbox.has-caption .lightbox-img { padding-bottom: 35vh; }
.lightbox-caption-container {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, #000 30%, rgba(0,0,0,0.9) 70%, transparent 100%);
    padding: 60px 24px 40px; color: #fff; z-index: 1001; max-height: 60vh; 
    display: flex; flex-direction: column; transform: translateY(100%); transition: 0.4s;
}
.lightbox.has-caption .lightbox-caption-container { transform: translateY(0); }
.lightbox-caption-scroll { overflow-y: auto; padding-right: 10px; font-family: var(--font-book); font-size: 18px; line-height: 1.6; }

.end-logo-container { display: flex; justify-content: center; width: 100%; margin: 80px 0 50px; }
.end-logo {
    width: 100%; max-width: 520px; aspect-ratio: 3/1; background-color: var(--text-primary); opacity: 0.8;
    -webkit-mask: url('../img/content/scar-of-eternity/book-logo.svg') no-repeat center center; 
    mask: url('../img/content/scar-of-eternity/book-logo.svg') no-repeat center center;
    -webkit-mask-size: contain; mask-size: contain;
}

.chapter-nav-row { display: flex; gap: 15px; margin-top: 20px; }
.nav-chapter-btn {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 16px;
    background: var(--surface-1); border: 1px solid var(--glass-border);
    border-radius: 16px; color: inherit; text-decoration: none;
    font-family: var(--font-ui); font-weight: 600; font-size: 14px; transition: 0.2s;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.nav-chapter-btn.disabled { opacity: 0.3; pointer-events: none; }

.nav-chapter-btn:not(.disabled):hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.nav-chapter-btn:not(.disabled):active {
    transform: translateY(0) scale(0.98);
}

.nav-chapter-btn.disabled { opacity: 0.3; pointer-events: none; }

.comments-section { margin-top: 60px; border-top: 1px solid var(--glass-border); padding-top: 30px; }
.comments-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.comments-title { font-size: 18px; font-weight: 700; margin: 0; }
.like-btn {
    display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 14px; cursor: pointer;
    background: var(--surface-2); border: 1px solid var(--glass-border);
    font-family: var(--font-ui); font-size: 13px; font-weight: 600; color: var(--text-primary);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.like-btn svg { transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.like-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
}

.like-btn.active {
    background: var(--accent-bg-subtle); 
    border-color: var(--accent-color); 
    color: var(--accent-color);
}

.like-btn.active svg {
    fill: var(--accent-color); 
    stroke: none;
    animation: heartPop 0.4s forwards; 
}

@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.fab-wrapper { 
    position: fixed; bottom: 30px; right: 20px; width: var(--fab-size); height: var(--fab-size); z-index: 90; 
    display: flex; align-items: center; justify-content: center; 
}
.fab-wrapper .progress-ring { position: absolute; top: -3px; left: -3px; width: 70px; height: 70px; transform: rotate(-90deg); pointer-events: none; }
.fab-wrapper .progress-ring__circle { transition: stroke-dashoffset 0.1s; stroke-dasharray: 200; stroke-dashoffset: 200; stroke-linecap: round; stroke: var(--accent-color); }
.fab-btn { 
    width: var(--fab-size); height: var(--fab-size); min-width: 64px; min-height: 64px; border-radius: 50%; 
    background: var(--glass-bg); 
    backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border); color: inherit; 
    display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 2; box-shadow: 0 5px 20px rgba(0,0,0,0.4); flex-shrink: 0;
    position: relative; display: flex; align-items: center; justify-content: center;
}

.fab-icon {
    position: absolute;
    top: 50%; left: 50%;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); 
}

.icon-settings {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

.icon-close {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-90deg) scale(0.5);
}
.fab-wrapper.active .icon-settings {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(90deg) scale(0.5);
}

.fab-wrapper.active .icon-close {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
}

.settings-panel {
    position: fixed; bottom: 110px; left: 15px; right: 15px; border-radius: 20px; padding: 24px 20px; z-index: 200;
    opacity: 0; visibility: hidden; transform: translateY(30px) scale(0.98);
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    background: var(--glass-bg); 
    backdrop-filter: blur(30px) saturate(180%); -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid var(--glass-border); box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.settings-panel.active { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.setting-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; } .setting-group:last-child { margin-bottom: 0; }
.setting-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 10px; display: block; letter-spacing: 0.02em; }

.segmented-control { position: relative; display: flex; background: var(--surface-1); border-radius: 12px; padding: 4px; height: 48px; }
.glider { 
    position: absolute; 
    top: 0; 
    left: 0;
    height: 100%;
    background: var(--glider-bg);
    border-radius: 8px; 
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); 
    z-index: 1; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    pointer-events: none;
}
#size-control .segment-btn {
    font-size: 13px;
    font-weight: 600;
    padding: 6px 0; 
    flex: 1;
}
.segment-btn { 
    flex: 1; position: relative; z-index: 2; padding: 10px 0; text-align: center; 
    font-size: 14px; font-weight: 500; color: var(--text-secondary); border: none; background: none; 
    cursor: pointer; transition: color 0.2s; font-family: var(--font-ui); 
    height: 100%; display: flex; align-items: center; justify-content: center;
}
.segment-btn.active { color: var(--text-primary); font-weight: 600; }
.font-opt-garamond { font-family: 'EB Garamond', serif; font-size: 18px; font-weight: 400; }
.font-opt-infant { font-family: 'Cormorant Infant', serif; font-size: 18px; font-weight: 400; }
.font-opt-inter { font-family: 'Inter', sans-serif; font-size: 14px; font-weight: 300; }

.slider-wrapper { background: var(--surface-1); border-radius: 12px; padding: 12px 15px; display: flex; align-items: center; gap: 15px; }
input[type=range] { flex: 1; -webkit-appearance: none; background: transparent; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; height: 20px; width: 20px; border-radius: 50%; background: var(--text-primary); cursor: pointer; margin-top: -8px; box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; background: var(--text-muted); opacity: 0.3; border-radius: 2px; }

/* Desktop Reader (1024px+) */
@media (min-width: 1024px) {
    .reader-page { --reader-size: 22px; }
    .reader-page .header { max-width: 1000px; left: 50%; transform: translateX(-50%); top: 20px; padding: 0 40px; }
    .reader-container { max-width: 1000px; padding-top: 140px; }
    .book-image { max-width: 70%; }
    .settings-panel { left: auto; right: 40px; bottom: 110px; width: 380px; transform-origin: bottom right; }
    .fab-wrapper { right: 40px; }
    .sidebar {
        top: 80px; right: max(15px, calc(50% - 500px)); width: 400px; max-height: calc(100vh - 100px);
        border-radius: 0 0 20px 20px; background: var(--glass-bg) !important; 
        border: 1px solid var(--glass-border); border-top: none; box-shadow: 0 20px 50px rgba(0,0,0,0.5); 
    }
    .chapter-header { margin-bottom: 80px; }
    .act-title { font-size: 14px; letter-spacing: 4px; margin-bottom: 20px; }
    .chapter-num { font-size: 120px; margin-bottom: -65px; }
    .chapter-name { font-size: 162px; line-height: 1.1; max-width: 900px; margin-left: auto; margin-right: auto; }
    .caption-text { font-family: 'Cormorant Infant', serif; font-size: 22px; line-height: 1.6; }
}

/* ========================================= */
/* PAGE: PROFILE                             */
/* ========================================= */
.profile-hero {
    position: relative; padding: 80px 20px 40px;
    display: flex; flex-direction: column; align-items: center; text-align: center;
}
.profile-hero .hero-bg-glow {
    position: absolute; top: -50%; left: 50%; transform: translateX(-50%); width: 100%; height: 100%;
    background: radial-gradient(circle, var(--accent-glow) 0%, rgba(0,0,0,0) 70%); z-index: 0; pointer-events: none; opacity: 0.6;
}
.avatar-wrapper { position: relative; margin-bottom: 20px; z-index: 1; }
.avatar {
    width: 110px; height: 110px; border-radius: 50%;
    background: linear-gradient(135deg, var(--surface-1), var(--surface-hover));
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-ui); font-size: 36px; font-weight: 700; color: var(--text-primary);
    border: 4px solid var(--bg-body); box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.edit-badge {
    position: absolute; bottom: 0; right: 0; width: 36px; height: 36px;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; color: var(--text-primary); cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.user-name {
    font-family: var(--font-ui); font-size: 32px; font-weight: 700;
    margin: 0 0 10px 0; line-height: 1; z-index: 1; color: var(--text-primary);
}
.user-tag {
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    padding: 6px 12px; border-radius: 20px;
    
    background: rgba(211, 47, 47, 0.1); 
    border: 1px solid var(--accent-color);
    color: var(--accent-color);

    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    
    z-index: 1; display: inline-block;
}

.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; padding: 0 20px; margin-bottom: 40px; }
.stat-card {
    background: var(--surface-1); border: 1px solid var(--border-color);
    border-radius: 16px; padding: 16px 10px; text-align: center;
}
.stat-val { font-family: var(--font-ui); font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.stat-lbl { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; font-weight: 600; }

.section-container { padding: 0 20px; margin-bottom: 30px; }
.section-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; padding-left: 10px; }
.menu-list {
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
}
.menu-item {
    display: flex; align-items: center; justify-content: space-between; padding: 18px 20px;
    border-bottom: 1px solid var(--border-color); transition: 0.2s; cursor: pointer;
}
.menu-item:last-of-type { border-bottom: none; }
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--surface-hover); }
.item-left { display: flex; align-items: center; gap: 14px; }
.item-icon { color: var(--text-secondary); }
.item-label { font-size: 16px; font-weight: 500; color: var(--text-primary); }
.item-info { font-size: 14px; color: var(--text-muted); font-weight: 500; display: flex; align-items: center; gap: 6px; }

.toggle-switch { width: 44px; height: 24px; background: var(--toggle-bg); border-radius: 12px; position: relative; transition: 0.3s; }
.toggle-switch::after {
    content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
    background: var(--toggle-knob); border-radius: 50%; transition: 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-switch.active { background: var(--accent-color); }
.toggle-switch.active::after { transform: translateX(20px); }

.menu-item.danger .item-label, .menu-item.danger .item-icon { color: var(--danger-color); }

.dropdown-content {
    background: var(--bg-dropdown); 
    backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    max-height: 0; overflow: hidden; transition: max-height 0.3s ease-out;
    
    border-top: none; 
    margin-top: -1px; 
}
.dropdown-content.open { max-height: 150px; border-top: 1px solid var(--border-color);}
.dropdown-opt {
    padding: 14px 20px 14px 54px; font-size: 14px; color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between;
    transition: 0.2s; cursor: pointer;
}
.dropdown-opt:last-child { border-bottom: none; }
.dropdown-opt:hover { background: var(--surface-hover); color: var(--text-primary);}
.dropdown-opt.selected { color: var(--text-primary); background: var(--surface-2); }
.dropdown-opt.selected::after { content: '✓'; color: var(--accent-color); font-weight: bold; }

.modal-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    width: 80%; max-width: 460px; border-radius: 20px; padding: 25px; text-align: center;
    transform: scale(0.9); transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.modal-overlay.active .modal-card { transform: scale(1); }
.modal-text { font-size: 14px; color: var(--text-secondary); margin-bottom: 25px; line-height: 1.5; }

/* Desktop Profile */
.settings-btn-desktop { display: none; }
@media (min-width: 1024px) {
    .settings-btn-desktop {
        position: absolute; top: 30px; right: 30px; width: 44px; height: 44px;
        border-radius: 50%; background: var(--surface-1); border: 1px solid var(--border-color);
        color: var(--text-secondary); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; z-index: 10;
    }
    .settings-btn-desktop:hover { background: var(--surface-hover); color: var(--text-primary); transform: rotate(30deg); }
    
    body:has(.profile-hero) {
        display: flex; flex-direction: column; align-items: center;
        background: radial-gradient(circle at 50% 0%, var(--hero-gradient-start) 0%, var(--hero-gradient-end) 100%); min-height: 100vh;
    }
    .profile-hero {
        margin-top: 100px; width: 100%; max-width: 1200px;
        flex-direction: row; align-items: center; text-align: left; gap: 40px; padding: 40px;
        background: var(--surface-1); border: 1px solid var(--border-color); border-radius: 24px 24px 0 0;
    }
    .profile-hero .hero-bg-glow { width: 60%; height: 60%; left: 0; transform: none; top: 0; opacity: 0.3; }
    .avatar-wrapper { margin-bottom: 0; }
    .avatar { width: 140px; height: 140px; font-size: 48px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
    .edit-badge { width: 44px; height: 44px; bottom: 5px; right: 5px; }
    .user-info-desktop { display: flex; flex-direction: column; align-items: flex-start; }
    .user-name { font-size: 48px; margin-bottom: 15px; }
    .user-tag { font-size: 13px; padding: 8px 16px; }

    .stats-row {
        width: 100%; max-width: 1200px;
        background: var(--surface-1); border-left: 1px solid var(--border-color); border-right: 1px solid var(--border-color);
        margin-bottom: 0; padding: 20px 40px; gap: 20px;
    }
    .stat-card {
        background: var(--surface-1); border: 1px solid var(--border-color);
        padding: 20px; transition: 0.2s;
    }
    .stat-card:hover { transform: translateY(-5px); background: var(--surface-hover); }

    .desktop-grid-wrapper {
        width: 100%; max-width: 1200px;
        background: var(--surface-1); border: 1px solid var(--border-color); border-top: none; border-radius: 0 0 24px 24px;
        padding: 20px 40px 60px; display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; margin-bottom: 40px;
    }
    .section-container { padding: 0; margin-bottom: 0; }
}

.info-icon-btn {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: var(--surface-hover);
    color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; cursor: pointer;
    transition: 0.2s;
}
.info-icon-btn:hover { background: var(--accent-color); color: white; }

/* --- LIGHT THEME FIXES --- */
body.theme-light .profile-hero .hero-bg-glow {
    opacity: 1;
}

body.theme-light .avatar {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-color: rgba(255,255,255,0.5);
}

body.theme-light .book-logo-title {
    opacity: 0.9; 
}

.book-logo-adaptive {
    display: block;
    width: 100%;
    max-width: 280px; 
    height: auto;
    margin: 0 0 15px 0;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
}

.cover-img-mobile {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
}

.cover-img-desktop {
    display: none;
}

@media (min-width: 1024px) {
    
    .book-logo-adaptive {
        max-width: 400px;
        margin-bottom: 30px;
        filter: drop-shadow(0 5px 15px rgba(0,0,0,0.6));
    }

    .cover-img-mobile {
        display: none;
    }

    .cover-img-desktop {
        display: block;
        width: 100%;
        height: auto;
        border-radius: 16px;
        box-shadow: 0 20px 50px rgba(0,0,0,0.5);
        aspect-ratio: 2/3;
        object-fit: cover;
        margin-bottom: 25px;
    }

    body.theme-light .book-logo-adaptive {
        filter: invert(1);
        opacity: 0.9;
    }
}

/* --- THEME SWITCHER ---  */
body.theme-animating,
body.theme-animating * {
    transition: background-color 0.3s ease,
                border-color 0.3s ease,
                color 0.3s ease,
                box-shadow 0.3s ease,
                fill 0.3s ease,
                stroke 0.3s ease,
                opacity 0.3s ease !important;
}

/* --- SCROLL LOCK --- */
body.no-scroll {
    overflow: hidden !important;
    touch-action: none;
    overscroll-behavior: none;
}

/* --- COMMENTS --- */
.comments-container {
    max-width: 100%; 
    margin: 60px auto 70px;
    padding-top: 30px;
    border-top: 1px solid var(--glass-border);
}

.comments-header-row-main {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 25px;
}

.comments-header-title {
    font-size: 20px; font-weight: 700; margin: 0;
    color: var(--text-primary); font-family: var(--font-ui);
}

.comment-form {
    margin-top: 30px;
    margin-bottom: 40px;
    background: transparent;
    padding: 0;
    display: flex; flex-direction: column; gap: 15px;
}

.comment-input {
    width: 100%;
    background: var(--surface-1);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    
    resize: none; 
    overflow: hidden;
    min-height: 50px; 
    max-height: 30vh;
    box-sizing: border-box;
    
    transition: border-color 0.2s, background 0.2s; 
    outline: none;
}
.comment-input:focus {
    border-color: var(--accent-color);
    background: var(--surface-2);
}

.auth-btn {
    align-self: flex-end;
    background: var(--accent-color);
    color: #fff;
    border: none; padding: 8px 20px;
    border-radius: 10px;
    font-weight: 600; cursor: pointer;
    font-family: var(--font-ui); font-size: 13px;
    transition: 0.2s;
}
.auth-btn:active { transform: scale(0.96); }

.comment-list { display: flex; flex-direction: column; gap: 20px; }

.comment-item {
    display: flex; flex-direction: column; gap: 10px;
}

.comment-card {
    background: var(--surface-1);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 15px;
    position: relative;
    transition: background 0.2s;
}

.comment-header-row {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
}

.comment-author-info { display: flex; gap: 10px; align-items: center; }

.comment-author {
    font-weight: 700; font-size: 14px;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 8px;
}

.author-badge {
    font-size: 9px; font-weight: 800;
    background: var(--accent-bg-subtle);
    color: var(--accent-color);
    padding: 2px 6px; border-radius: 4px;
    border: 1px solid var(--accent-glow);
    text-transform: uppercase; letter-spacing: 0.5px;
}

.comment-date { font-size: 11px; color: var(--text-secondary); font-weight: 500; }

.btn-reply {
    background: none; border: none;
    color: var(--text-secondary);
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    display: flex; align-items: center; gap: 5px;
    padding: 4px 8px; border-radius: 6px;
    transition: 0.2s; font-family: var(--font-ui);
}
.btn-reply:hover { color: var(--text-primary); background: var(--surface-hover); }

.comment-text {
    font-size: 15px; line-height: 1.6;
    color: var(--text-primary); opacity: 0.9;
    white-space: pre-line;
}

.comment-children {
    margin-left: 8px;
    padding-left: 16px;
    border-left: 2px solid var(--border-color); 
    display: flex; flex-direction: column; gap: 15px;
    margin-top: 5px;
    transition: border-left-color 0.2s ease;
}

.comment-children:hover {
    border-left-color: var(--text-primary); 
}

.reply-box {
    margin-top: 15px;
    animation: fadeUp 0.3s ease;
    background: transparent;
    padding: 0;
    border: none;
    
    padding-left: 15px;
    border-left: 2px solid var(--accent-color); 
}

.reply-actions { display: flex; gap: 10px; margin-top: 10px; }

.small-btn { padding: 6px 14px; font-size: 12px; }

.cancel-btn {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 6px 14px; border-radius: 10px;
    cursor: pointer;
    font-family: var(--font-ui); font-size: 12px;
    transition: 0.2s;
}
.cancel-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }

/* --- PAGE: MATERIALS / BLOG --- */

.blog-header {
    display: flex; flex-direction: column; gap: 20px;
    margin-bottom: 40px;
}

.blog-container {
    padding: 100px 40px 80px;
    max-width: 1400px;
    margin: 0 auto;
}

.page-title {
    font-size: 32px; font-weight: 800;
    font-family: var(--font-display, var(--font-ui)); 
}

/* Фильтры */
.category-filter {
    display: flex; gap: 10px; overflow-x: auto;
    padding-bottom: 5px; 
    scrollbar-width: none;
}

.filter-btn {
    padding: 8px 16px; border-radius: 20px;
    background: var(--surface-1); border: 1px solid var(--glass-border);
    color: var(--text-secondary); font-family: var(--font-ui);
    font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: 0.2s;
}
.filter-btn.active, .filter-btn:hover {
    background: var(--text-primary); color: var(--text-inverse);
    border-color: var(--text-primary);
}

.materials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    grid-auto-rows: 250px; 
    gap: 20px; 
}

.mat-card {
    position: relative; border-radius: 24px; overflow: hidden;
    display: block; text-decoration: none;
    background: var(--bg-card);
    
    border: 1px solid rgba(255, 255, 255, 0.15); 
    
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.mat-card:hover { transform: translateY(-5px); }

.mat-bg {
    position: absolute; inset: 0;
    background-size: cover; background-position: center;
    transition: transform 0.5s;
}
.mat-card:hover .mat-bg { transform: scale(1.05); }

.mat-overlay {
    position: absolute; inset: 0;
    background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.8) 100%);
}

/* Контент */
.mat-content {
    position: absolute; bottom: 0; left: 0; width: 100%;
    padding: 20px;
    z-index: 2;
    color: #fff;
}

.mat-tag {
    font-size: 10px; text-transform: uppercase; letter-spacing: 1px; font-weight: 800;
    background: rgba(255,255,255,0.2); backdrop-filter: blur(4px);
    padding: 4px 8px; border-radius: 6px; display: inline-block;
    margin-bottom: 8px;
}

.mat-title {
    font-size: 18px; font-weight: 700; margin: 0 0 5px 0;
    line-height: 1.3;
}

.mat-desc {
    font-size: 13px; color: rgba(255,255,255,0.8);
    margin: 0; line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mat-date {
    font-size: 12px; color: rgba(255,255,255,0.6);
}

@media (min-width: 768px) {
    .mat-card.large {
        grid-column: span 2;
        grid-row: span 2;
    }
    
    .mat-card.wide {
        grid-column: span 2;
    }

    .materials-grid {
        gap: 20px; 
    }

    log-container { padding: 80px 20px 60px; }
}

/* --- FOOTER --- */
body {
    padding-bottom: 100px !important;
}

@media (min-width: 768px) {
    body { padding-bottom: 0 !important; }
}

.footer {
    width: calc(100% - 40px);
    max-width: 1200px;
    margin: 60px auto 40px;
    
    border-radius: 24px;
    border: 1px solid var(--glass-border);
    background: var(--surface-1);
    position: relative;
    z-index: 10;
    
    padding: 60px 40px 30px;
    box-sizing: border-box;
}

.footer-container {
    width: 100%;
    padding: 0;
}

.footer-grid {
    display: flex; justify-content: flex-start; gap: 10%; flex-wrap: wrap; margin-bottom: 40px;
}

.footer-brand-col { max-width: 300px; flex-shrink: 0; }
.footer-logo { font-family: 'Space Grotesk', sans-serif; font-size: 24px; font-weight: 600; color: var(--text-primary); text-decoration: none; display: inline-block; margin-bottom: 15px; }
.footer-desc { color: var(--text-secondary); font-size: 14px; line-height: 1.5; margin: 0; }

.footer-links-group { display: flex; gap: 80px; }
.footer-col { display: flex; flex-direction: column; gap: 10px; }
.footer-col h4 { font-size: 14px; color: var(--text-primary); margin: 0 0 10px 0; font-weight: 700; }
.footer-col a { color: var(--text-secondary); text-decoration: none; font-size: 14px; font-weight: 500; transition: 0.2s; }
.footer-col a:hover { color: var(--text-primary); }

.footer-bottom {
    border-top: 1px solid var(--glass-border);
    padding-top: 20px;
    display: flex; justify-content: space-between; align-items: center;
    color: var(--text-secondary); font-size: 13px; opacity: 0.7;
}

.footer-action-btn {
    background: none; border: none; padding: 0; color: var(--text-secondary); cursor: pointer;
    font-family: inherit; font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; transition: 0.2s;
}
.footer-action-btn:hover { color: var(--accent-color); }
.bug-btn:hover { color: #ff5555; }

@media (max-width: 768px) {
    .footer {
        max-width: 100%;
        margin: 20px;
        margin-bottom: 20px;
        border: 1px solid var(--glass-border);
        border-radius: 24px;
        padding-bottom: 80px;
        padding-left: 20px;
        padding-right: 20px;
        padding-top: 40px;
        background: var(--surface-1);
    }

    body {
        padding-bottom: 0 !important;
    }

    .bottom-nav {
        bottom: 20px;
        width: calc(100% - 40px);
        max-width: 400px;
    }
    
    .footer-grid { flex-direction: column; gap: 30px; }
    .footer-links-group { width: 100%; gap: 40px; }
    .footer-bottom { flex-direction: column; gap: 10px; align-items: flex-start; opacity: 0.5; }
}

@media (min-width: 769px) {
    .footer {
        margin-bottom: 10px;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .footer { padding-bottom: 80px; }
}

/* ========================================= */
/* UI: СИСТЕМА УВЕДОМЛЕНИЙ                   */
/* ========================================= */

.achievement-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-150%);
    width: 90%;
    max-width: 400px;
    
    background: var(--bg-card); 
    border: 1px solid var(--accent-gold);
    border-color: var(--glass-border);
    
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 9999;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    cursor: pointer;
}

body.theme-light .achievement-toast {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.achievement-toast.active {
    transform: translateX(-50%) translateY(0);
}

.achievement-toast.gold {
    border-color: var(--accent-gold);
    box-shadow: 0 10px 50px rgba(255, 183, 77, 0.2);
}
.achievement-toast.gold::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, transparent 0%, var(--accent-gold-bg) 100%);
    pointer-events: none; border-radius: 16px;
}

.ach-icon-box {
    width: 48px; height: 48px;
    background: var(--surface-2);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    color: var(--text-primary);
    flex-shrink: 0;
}
.achievement-toast.gold .ach-icon-box {
    color: var(--accent-gold);
    background: rgba(255, 183, 77, 0.1);
}

.ach-content {
    flex: 1;
    display: flex; flex-direction: column; justify-content: center;
}
.ach-head {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 700;
}
.ach-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.ach-close {
    background: none; border: none;
    color: var(--text-secondary);
    cursor: pointer; padding: 8px;
    transition: 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.ach-close:hover {
    color: var(--text-primary);
    background: var(--surface-hover);
    border-radius: 50%;
}

#quote-tooltip {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-family: var(--font-ui);
    font-size: 13px; font-weight: 600;
    opacity: 0; transform: translateY(10px);
    transition: 0.2s; z-index: 1000;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    display: flex; gap: 10px; align-items: center;
    pointer-events: none;
}
#quote-tooltip.active {
    opacity: 1; transform: translateY(0);
    pointer-events: auto;
}
.quote-btn {
    background: none; border: none; 
    color: var(--text-primary); 
    cursor: pointer; padding: 0;
    display: flex; align-items: center; gap: 6px;
    font-family: inherit; font-weight: 600;
}
.quote-btn:hover { color: var(--accent-color); }

/* ========================================= */
/* UI: УВЕДОМЛЕНИЯ, АЧИВКИ, ЛАЙТБОКС         */
/* ========================================= */

.sys-alert {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    background: var(--bg-card); color: var(--text-primary); 
    padding: 10px 20px; border-radius: 30px; border: 1px solid var(--border-color);
    font-size: 13px; font-weight: 600; font-family: var(--font-ui);
    opacity: 0; pointer-events: none; transition: 0.3s;
    z-index: 9999 !important; box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}
.sys-alert.active { opacity: 1; bottom: 120px; }

#quote-tooltip {
    position: absolute; background: var(--bg-card); border: 1px solid var(--border-color);
    color: var(--text-primary); padding: 8px 16px; border-radius: 8px;
    font-family: var(--font-ui); font-size: 13px; font-weight: 600;
    opacity: 0; transform: translateY(10px); transition: 0.2s; 
    z-index: 9000 !important; box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    display: flex; gap: 10px; align-items: center; pointer-events: none;
}
#quote-tooltip.active { opacity: 1; transform: translateY(0); pointer-events: auto; }
.quote-btn { background: none; border: none; color: var(--text-primary); cursor: pointer; padding: 0; display: flex; align-items: center; gap: 6px; font-family: inherit; font-weight: 600; }
.quote-btn:hover { color: var(--accent-color); }

.achievement-toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-150%);
    width: 90%; max-width: 400px; background: var(--bg-card); 
    border: 1px solid var(--border-color); border-radius: 16px; padding: 16px;
    display: flex; align-items: center; gap: 16px; z-index: 9999 !important;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5); cursor: pointer;
}
.achievement-toast.active { transform: translateX(-50%) translateY(0); }
.achievement-toast.gold { border-color: var(--accent-gold); box-shadow: 0 10px 50px rgba(255, 183, 77, 0.2); }
.ach-icon-box { width: 48px; height: 48px; background: var(--surface-2); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: var(--text-primary); flex-shrink: 0; }
.achievement-toast.gold .ach-icon-box { color: var(--accent-gold); background: rgba(255, 183, 77, 0.1); }
.ach-content { flex: 1; display: flex; flex-direction: column; justify-content: center; }
.ach-head { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 700; }
.ach-title { font-size: 15px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.ach-close { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 8px; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.ach-close:hover { color: var(--text-primary); background: var(--surface-hover); border-radius: 50%; }

.book-image, .zoomable-image-wrapper, body {
    -webkit-user-select: none;
    user-select: none;
}

.book-text {
    -webkit-user-select: text;
    user-select: text;
}

.book-text p {
    text-indent: 2em;
    margin: 1.2em 0;
}

.book-text > p:first-of-type {
    text-indent: 0;
}

.book-image.static {
    display: block;
    margin: 2em auto;
}

.book-image,
.zoomable-image-wrapper img,
.cover-img-mobile,
.cover-img-desktop,
.cover-wrapper,
.hero-cover,
.book-logo-adaptive {
    -webkit-user-drag: none;
    user-drag: none;
}

img {
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: auto;
}

* {
    -webkit-touch-callout: none;
}

@media (max-width: 502px) {
    .sys-alert.active {
        width: 80vw;
    }
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: #000;
    display: flex;
    flex-direction: column;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition: opacity 0.3s ease;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.logo-text {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1.5rem;
    letter-spacing: -0.02em;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.logo-ex,
.logo-underscore {
    color: var(--text-primary);
}

.logo-lib {
    color: #D32F2F;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: 0.2s;
}

.user-avatar:hover {
    background: var(--surface-hover);
}

.avatar-initials {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.profile-icon {
    font-size: 20px;
    color: var(--text-primary);
}

.bottom-nav {
    padding: 8px 12px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 11px;
    transition: 0.2s ease;
}

.nav-item i {
    font-size: 22px;
    transition: 0.2s ease;
}

.nav-label {
    font-size: 10px;
    opacity: 0.8;
    letter-spacing: 0.3px;
}

.nav-item:hover {
    color: var(--text-primary);
}

.nav-item:hover i {
    transform: translateY(-2px);
}

.nav-item.active {
    color: var(--accent-color);
}

.nav-item.active i {
    transform: translateY(-2px);
}

.nav-item:active {
    transform: scale(0.95);
}

@media (max-width: 768px) {
    .details-page .header {
        display: none;
    }
}

/* ---------------------------- */

.section-container { 
    padding: 0 20px; 
    margin-bottom: 30px;
}

@media (min-width: 1024px) {
    .section-container {
        padding: 0;
    }
}

.menu-item.reading-card {
    min-height: 80px; 
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
    min-height: 80px;
    background: var(--surface-1);
    border: 1px dashed var(--border-color);
    border-radius: 16px;
    color: var(--text-secondary);
    text-align: center;
    font-size: 13px;
    gap: 8px;
    transition: background 0.2s;
}

.empty-state.large {
    min-height: 120px;
}

.empty-state:hover {
    background: var(--surface-hover);
}

.empty-state i {
    font-size: 24px;
    color: var(--text-muted);
    opacity: 0.7;
}

.achievements-scroll-wrapper {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-top: 5px;
    padding-bottom: 15px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.achievements-scroll-wrapper::-webkit-scrollbar {
    height: 4px;
    display: block;
}

.achievements-scroll-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.achievements-scroll-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

@media (min-width: 1024px) {
    .achievements-scroll-wrapper {
        flex-wrap: wrap;
        overflow-x: visible;
        padding-bottom: 5px;
    }
    
    .achievements-scroll-wrapper::-webkit-scrollbar {
        display: none;
    }
}

.ach-badge {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border-radius: 50% !important;
    background: var(--surface-1); 
    border: 1px solid var(--border-color);
    display: flex; 
    align-items: center; 
    justify-content: center; 
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.ach-badge:hover {
    transform: translateY(-3px);
    background: var(--surface-hover);
}

.ach-badge.gold-badge {
    border-color: var(--accent-gold) !important;
    background: rgba(255, 183, 77, 0.05);
}

.ach-badge i {
    font-size: 28px;
}

.ach-badge.locked {
    opacity: 0.3;
    cursor: default;
    border-style: dashed;
}

.ach-badge.locked:hover {
    transform: none;
    background: var(--surface-1);
}

.stat-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    padding: 16px 5px;
}

@media (min-width: 1024px) {
    .settings-wrapper {
        padding-top: 40px;
    }
}

.settings-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.setting-row.clickable {
    cursor: pointer;
}

.setting-row.clickable:hover {
    background: var(--surface-hover);
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 15px;
}

.setting-name {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.setting-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

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

.danger-text .setting-name, 
.danger-text .setting-icon {
    color: var(--danger-color);
}

.setting-icon {
    font-size: 20px;
    color: var(--text-secondary);
}

.btn-action-sm {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: 0.2s;
}

.btn-action-sm.primary {
    background: var(--accent-color);
    color: white;
}

.btn-action-sm.danger {
    background: var(--surface-2);
    color: var(--danger-color);
    border: 1px solid var(--border-color);
}

#theme-control {
    width: 200px;
    height: 36px;
}

#theme-control .segment-btn {
    font-size: 12px;
    padding: 0;
}

.app-version {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.4;
    margin-top: 10px;
}

#settings-profile-view {
    display: flex;
    flex-direction: column;
}

@media (min-width: 1024px) {
    #settings-profile-view {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas: 
            "account appearance"
            "app notify";
        gap: 15px 40px;
        align-items: start;
    }

    .setting-sect-appearance { grid-area: appearance; }
    .setting-sect-notify     { grid-area: notify; }
    .setting-sect-account    { grid-area: account; }
    .setting-sect-app        { grid-area: app; }
}

@media (max-width: 1024px) {
    #main-profile-view, 
    #settings-profile-view {
        animation: fadeUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
        will-change: opacity, transform;
    }
}

.ach-tooltip {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    width: max-content;
    max-width: 250px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    pointer-events: none;
}

.ach-tooltip.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ach-tooltip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.ach-tooltip-header i {
    font-size: 18px;
    color: var(--accent-color);
}

.ach-tooltip-header i.gold-icon {
    color: var(--accent-gold);
}

.ach-tooltip-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: normal;
}

.ach-tooltip-arrow {
    position: absolute;
    bottom: -6px;
    left: 50%;
    margin-left: -6px;
    width: 12px;
    height: 12px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    transform: rotate(45deg);
}

.ach-tooltip.gold-theme {
    border-color: var(--accent-gold);
    box-shadow: 0 0 15px rgba(255, 183, 77, 0.4), inset 0 0 10px rgba(255, 183, 77, 0.1) !important;
    animation: goldPulseTooltip 3s infinite ease-in-out;
}

@keyframes goldPulseTooltip {
    0%, 100% { box-shadow: 0 0 15px rgba(255, 183, 77, 0.4), inset 0 0 10px rgba(255, 183, 77, 0.1); }
    50% { box-shadow: 0 0 25px rgba(255, 183, 77, 0.7), inset 0 0 15px rgba(255, 183, 77, 0.3); }
}

.ach-tooltip.gold-theme .ach-tooltip-arrow {
    border-right-color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
    box-shadow: 2px 2px 4px rgba(255, 183, 77, 0.2);
}

.tooltip-close {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 18px;
    transition: color 0.2s;
}

.tooltip-close:hover {
    color: var(--text-primary);
}

.quotes-wrapper { 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
}

.quote-card {
    background: var(--surface-1); 
    border: 1px solid var(--border-color);
    border-radius: 16px; 
    padding: 16px 20px; 
    display: flex; 
    flex-direction: column; 
    gap: 10px; 
    transition: all 0.3s ease;
    cursor: pointer;
    margin-bottom: 10px;
}

.quote-card:hover { 
    background: var(--surface-hover); 
}

.quote-card:active { 
    transform: scale(0.98); 
}

.quote-text {
    font-style: italic;
    margin-bottom: 8px;
    line-height: 1.5;
    color: var(--text-primary);
}

.quote-text-content {
    font-family: 'Cormorant Infant', serif;
    font-size: 16px;
    line-height: 1.4;
    color: var(--text-primary); 
    font-style: italic;
}

@media (min-width: 1024px) {
    .quote-text-content {
        font-size: 20px;
    }
}

.quote-meta {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
}

.quote-meta-row {
    display: flex; 
    justify-content: space-between; 
    align-items: flex-end;
    margin-top: 5px; 
}

.quote-source { 
    display: flex; 
    flex-direction: column; 
    gap: 2px; 
    padding-left: 20px; 
}

.quote-book { 
    font-size: 13px; 
    font-weight: 700; 
    color: var(--accent-color); 
}

.quote-chapter { 
    font-size: 12px; 
    color: var(--text-secondary); 
}

.quote-actions { 
    display: flex; 
    gap: 4px; 
}

.quote-action-btn {
    background: transparent; 
    border: 1px solid transparent;
    color: var(--text-secondary); 
    width: 32px; 
    height: 32px; 
    border-radius: 8px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    cursor: pointer; 
    transition: 0.2s; 
    text-decoration: none;
}

.quote-action-btn:hover { 
    color: var(--text-primary); 
    background: var(--surface-2); 
    border-color: var(--border-color);
}

.quote-action-btn.danger:hover {
    color: var(--danger-color); 
    border-color: rgba(239, 83, 80, 0.3);
    background: rgba(239, 83, 80, 0.1);
}

::selection {
    background: var(--accent-glow); 
    color: inherit;
}

::-moz-selection {
    background: var(--accent-glow);
    color: inherit;
}

::target-text {
    background: rgba(255, 183, 77, 0.4); 
    color: inherit;
    transition: background 0.3s ease;
}

body.hide-fragments ::target-text {
    background: transparent !important;
    color: inherit !important;
}

.profile-comments-wrapper { 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
}

.ex-comment-card {
    background: var(--bg-card); 
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden; 
    transition: border-color 0.2s;
}

.ex-comment-card:hover { 
    border-color: var(--border-hover); 
}

.ex-comment-main {
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.ex-comment-main:hover { 
    background: var(--surface-1); 
}

.ex-comment-header {
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start;
    margin-bottom: 12px;
}

.ex-c-meta { 
    display: flex; 
    align-items: center; 
    gap: 10px; 
}

.ex-c-date { 
    font-size: 12px; 
    color: var(--text-secondary); 
}

.ex-c-badge {
    display: flex; 
    align-items: center; 
    gap: 6px;
    background: var(--surface-1); 
    border: 1px solid var(--border-color);
    padding: 4px 10px; 
    border-radius: 8px;
    font-size: 10px; 
    text-transform: uppercase; 
    font-weight: 600;
    color: #B388FF;
}

.c-badge-book {
    font-size: 11px; 
    font-weight: 700; 
    color: var(--accent-color);
}

.c-badge-ch {
    font-size: 11px; 
    font-weight: 500; 
    color: var(--text-secondary); 
}

.ex-c-delete {
    background: none; 
    border: none; 
    color: var(--text-secondary);
    cursor: pointer; 
    padding: 4px; 
    font-size: 16px; 
    transition: color 0.2s;
}

.ex-c-delete:hover { 
    color: var(--danger-color); 
}

.ex-c-text {
    font-size: 14px; 
    color: var(--text-primary); 
    line-height: 1.5;
    margin-bottom: 15px; 
    white-space: pre-wrap; 
    opacity: 0.9;
}

.ex-c-link-text {
    font-size: 12px; 
    color: var(--text-secondary);
    display: flex; 
    align-items: center; 
    gap: 4px;
    padding-bottom: 5px; 
    border-bottom: 1px dashed var(--border-color);
    width: max-content;
}

.ex-replies-accordion {
    background: var(--surface-1);
    border-top: 1px solid var(--border-color);
}

.ex-replies-toggle {
    padding: 12px 20px; 
    font-size: 12px; 
    font-weight: 600; 
    color: var(--text-secondary);
    cursor: pointer; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    transition: background 0.2s, color 0.2s;
}

.ex-replies-toggle:hover { 
    background: var(--surface-2); 
    color: var(--text-primary); 
}

.ex-replies-toggle i { 
    transition: transform 0.3s; 
}

.ex-replies-content {
    display: none; 
    padding: 0 20px 15px 20px;
    flex-direction: column; 
    gap: 12px;
}

.ex-replies-content.open { 
    display: flex; 
    animation: fadeUp 0.3s ease; 
}

.ex-reply-item {
    margin-top: 10px; 
    padding-left: 12px; 
    border-left: 2px solid var(--border-color);
}

.ex-r-header { 
    display: flex; 
    gap: 10px; 
    margin-bottom: 4px; 
    align-items: baseline; 
}

.ex-r-author { 
    font-size: 13px; 
    font-weight: 600; 
    color: var(--text-primary); 
}

.ex-r-date { 
    font-size: 10px; 
    color: var(--text-muted); 
}

.ex-r-text { 
    font-size: 13px; 
    color: var(--text-secondary); 
    line-height: 1.4; 
}

.avatar-wrapper { 
    position: relative; 
    margin-bottom: 20px; 
    z-index: 100; 
}

.edit-badge {
    position: absolute; 
    bottom: 0; 
    right: 0; 
    width: 36px; 
    height: 36px;
    background: var(--bg-card); 
    border: 1px solid var(--border-color); 
    border-radius: 50%;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: var(--text-primary); 
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3); 
    z-index: 101;
    transition: transform 0.2s, background 0.2s;
}

.edit-badge:hover { 
    background: var(--bg-body); 
    transform: scale(1.05); 
    box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

@media (min-width: 1024px) {
    .edit-badge { 
        width: 44px; 
        height: 44px; 
        bottom: 5px; 
        right: 5px; 
    }
}

.avatar-dropdown {
    position: absolute; 
    top: calc(100% + 15px);
    left: 50%; 
    transform: translateX(-50%) translateY(-10px);
    background: var(--bg-dropdown); 
    backdrop-filter: blur(20px); 
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color); 
    border-radius: 16px;
    width: max-content; 
    min-width: 220px; 
    overflow: hidden;
    opacity: 0; 
    visibility: hidden; 
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5); 
    z-index: 102;
}

.avatar-dropdown.active {
    opacity: 1; 
    visibility: visible; 
    transform: translateX(-50%) translateY(0);
}

.avatar-panel-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    padding: 14px 16px 10px; 
    font-size: 11px; 
    font-weight: 600;
    color: var(--text-secondary); 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
}

.avatar-panel-header i {
    font-size: 20px; 
    color: var(--danger-color); 
    cursor: pointer; 
    transition: transform 0.2s;
}

.avatar-panel-header i:hover { 
    transform: scale(1.1); 
}

.dropdown-opt {
    padding: 14px 16px; 
    font-size: 14px; 
    color: var(--text-primary); 
    font-weight: 500;
    cursor: pointer; 
    border-top: 1px solid var(--border-color); 
    transition: background 0.2s;
}

.dropdown-opt:hover { 
    background: var(--surface-hover); 
}

.dropdown-opt.danger { 
    color: var(--danger-color); 
}

.avatar-dropdown .dropdown-opt:first-child { 
    border-top: none; 
}

.avatar-wrapper[data-has-avatar="false"] .opt-view,
.avatar-wrapper[data-has-avatar="false"] .opt-delete {
    display: none !important;
}

.lightbox-caption {
    margin-top: 20px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: #E4EBFB;
    font-family: var(--font-reader);
    font-size: 18px;
    line-height: 1.6;
    text-align: left;
    max-width: 600px;
    width: 100%;
    max-height: 40dvh; 
    overflow-y: auto;
}
.lightbox-caption b { color: #fff; font-weight: 700; }
.lightbox-caption i { opacity: 0.8; }

/* ============ */

.comment-text { word-break: break-word; }
.comment-header-row { flex-wrap: wrap; gap: 8px; }

@media (max-width: 768px) {
    .comment-card { padding: 12px 14px; border-radius: 14px; }
    .comment-children { margin-left: 4px; padding-left: 10px; gap: 10px; }
    .comment-children .comment-children .comment-children { margin-left: 0; padding-left: 4px; border-left-color: rgba(255, 255, 255, 0.05); }
    .comment-children .comment-children .comment-children .comment-children { padding-left: 0; border-left: none; }
}

@media (max-width: 768px) {
    .material-page .header { background: transparent !important; border: none !important; box-shadow: none !important; backdrop-filter: none !important; -webkit-backdrop-filter: none !important; padding: 0 16px !important; pointer-events: none; }
    .material-page .header > * { pointer-events: auto; }
    .material-page .reader-head-btn,
    .material-page .user-avatar { width: 44px !important; height: 44px !important; background: var(--glass-bg) !important; backdrop-filter: blur(10px) !important; -webkit-backdrop-filter: blur(10px) !important; border: 1px solid var(--glass-border) !important; border-radius: 50% !important; display: flex !important; align-items: center !important; justify-content: center !important; }
    .material-page .reader-head-btn svg { width: 20px; height: 20px; margin: 0; }
}

.material-header-clean { position: relative; z-index: 2; max-width: 700px; margin: 0 auto; width: 100%; padding: 80px 24px 20px; }
.material-header-text { margin-bottom: 10px; text-align: left; }

.material-tag { display: inline-block; padding: 6px 14px; border-radius: 20px; margin-bottom: 24px; background: var(--surface-2); border: 1px solid var(--border-color); color: var(--text-primary); font-family: var(--font-ui); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; backdrop-filter: blur(10px); }

.material-title { font-family: var(--font-ui); font-size: 44px; line-height: 1.1; margin: 0 0 24px 0; color: var(--text-primary); font-weight: 800; letter-spacing: -1px; text-align: left; }

.material-meta { display: flex; align-items: center; justify-content: left; gap: 15px; flex-wrap: wrap; font-family: var(--font-ui); font-size: 14px; color: var(--text-secondary); font-weight: 500; }

.meta-author { display: flex; align-items: center; gap: 10px; color: var(--text-primary); font-weight: 600; }
.author-avatar-badge { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; font-family: 'Space Grotesk', sans-serif; font-size: 12px; font-weight: 700; color: var(--text-primary); }
.meta-dot { opacity: 0.5; }

.material-cover-image { max-width: 700px; width: calc(100% - 40px); margin: 0 auto 40px; border-radius: 16px; border: 1px solid var(--border-color); box-shadow: 0 20px 40px rgba(0,0,0,0.3); overflow: hidden; display: flex; justify-content: center; background: var(--surface-1); }

.material-cover-image img { width: 100%; height: auto !important; display: block; border: none !important; border-radius: 0 !important; box-shadow: none !important; }

.material-hero { position: relative; width: 100%; min-height: 50vh; display: flex; flex-direction: column; justify-content: flex-end; padding: 120px 24px 60px; margin-bottom: 40px; }

.material-bg { position: absolute; inset: 0; background-size: cover; background-position: center; z-index: 0; opacity: 0.7; mask-image: linear-gradient(to bottom, black 40%, transparent 100%); -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%); }

body.theme-light .material-bg { opacity: 0.3; }

.material-hero-content { text-align: center; }

.material-content { padding: 0 24px 40px; font-family: var(--font-ui); font-size: 16px; line-height: 1.6; color: var(--text-primary); }
.material-content p { margin-bottom: 1.6em; }
.material-content img { border-radius: 12px; margin: 20px 0; max-width: 100%; height: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }

.article-footer-actions { padding: 24px; margin-bottom: 60px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); }

.action-group { display: flex; gap: 12px; }

.mat-action-btn { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 24px; background: transparent; border: 1px solid var(--border-color); color: var(--text-primary); font-family: var(--font-ui); font-size: 14px; font-weight: 500; cursor: pointer; transition: 0.2s; }
.mat-action-btn:hover { background: var(--surface-hover); }
.mat-action-btn.liked { color: var(--danger-color); border-color: rgba(239, 83, 80, 0.4); background: rgba(239, 83, 80, 0.1); }
.mat-action-btn i { font-size: 18px; }

.inline-comments { padding: 0 24px 80px; }

.material-content, .article-footer-actions, .inline-comments, .material-hero-content { position: relative; z-index: 2; max-width: 700px; margin: 0 auto; width: 100%; }

@media (min-width: 1024px) {
    .material-hero { min-height: 60vh; }
    .material-title { font-size: 56px; }
    .material-content { font-size: 18px; }
    .material-header-clean { max-width: 1000px; padding-top: 100px; }
    .material-cover-image { max-width: 1000px; width: fit-content; }
    .material-cover-image img { max-height: 550px; width: auto !important; max-width: 100%; margin: 0 auto; }
    .material-hero-content, .material-content, .article-footer-actions, .inline-comments { max-width: 1000px; }
}

@media (max-width: 768px) {
    .material-title { font-size: 36px; }
    .material-cover-image { width: calc(100% - 40px); padding: 0; }
}

.comment-input-wrapper {
    margin-bottom: 40px !important;
}

#comments-list,
#matCommentsContainer {
    margin-top: 10px;
}

.lightbox-caption:empty {
    display: none !important;
}

.glass-lock-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 12, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
    transition: 0.3s;
}

.lock-circle {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.lock-circle i {
    font-size: 26px;
    color: rgba(255, 255, 255, 0.9);
}

.book-card-sm.locked, 
.book-card-sm.is-announced {
    cursor: default;
}

.book-card-sm.locked:hover, 
.book-card-sm.is-announced:hover {
    transform: none;
}

.book-card-sm.locked:hover img, 
.book-card-sm.is-announced:hover img {
    transform: none !important;
}

.reader-chapter-header { text-align: center; margin-bottom: 40px; }
.ch-act-label { font-size: 16px; color: var(--text-secondary); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 2px; }
.ch-main-title { font-family: 'Bella Script', cursive; font-size: 56px; color: var(--text-primary); margin: 0; }

/* .theme-action .book-text p {
    font-family: 'Comfortaa', sans-serif !important;
    font-size: 17px !important;
    line-height: 1.8 !important;
} */

.theme-action .chapter-num,
.theme-action .act-title {
    font-family: 'Bebas Neue Local', sans-serif !important;
    font-weight: normal;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.theme-action .chapter-name {
    font-family: 'Erkan', sans-serif !important;
    font-size: 50px !important;
    margin-top: 60px !important;
    color: var(--text-primary) !important;
    letter-spacing: normal !important;
}

.theme-action .chapter-num {
    font-family: 'Erkan', sans-serif !important;
    font-size: 50px !important;
    margin-top: 0 !important;
    color: var(--text-primary) !important;
    letter-spacing: normal !important;
}

@media (max-width: 1024px) {
    .theme-action .chapter-name {
        margin-top: 10px !important;
    }
}

.theme-action .book-text > p:first-of-type::first-letter {
    font-family: inherit !important;
    font-size: inherit !important;
    color: inherit !important;
    float: none !important;
    margin: 0 !important;
    line-height: inherit !important;
}

.theme-action .book-text h2 {
    font-family: 'Bebas Neue Local', sans-serif !important;
    font-weight: bold !important;
    font-size: 24px;
    color: var(--text-primary) !important;
    letter-spacing: 1.5px;
    margin-top: 40px;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.theme-action .lightbox-caption-container .caption-text,
.theme-action .lightbox-caption-container .caption-text * {
    font-family: 'Anonymous Pro', monospace !important;
}

.end-logo-img {
    display: block;
    margin: 0 auto;
    opacity: 0.8;
    filter: brightness(0) invert(1); 
    max-width: 500px; 
    width: 100%;
}

@media (max-width: 647px) {
    .end-logo-img {
        max-width: 80vw;
    }
}

body.theme-light .end-logo-img {
    filter: brightness(0);
}

.badge-admin {
    background: rgba(212, 175, 55, 0.1) !important;
    color: #D4AF37 !important;
    border: 1px solid rgba(212, 175, 55, 0.3) !important;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.1);
}

.btn-admin-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #1a1712 0%, #262115 100%);
    color: #D4AF37;
    border: 1px solid rgba(212, 175, 55, 0.3);
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: 0.3s;
    width: 100%;
    margin-top: 15px;
}

.btn-admin-panel:hover {
    background: linear-gradient(135deg, #262115 0%, #332b1a 100%);
    border-color: rgba(212, 175, 55, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.15);
}

.sys-alert {
    text-align: center;
}

.theme-indie .book-title {
    font-family: 'MakiSans', sans-serif !important;
    font-weight: normal !important;
    font-size: 32px;
    color: var(--text-primary) !important;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.theme-indie .book-chapter-title {
    font-family: 'MakiSans', sans-serif !important;
    font-weight: normal !important;
    font-size: 24px;
    color: var(--text-primary) !important;
    letter-spacing: 1.5px;
    margin-top: 40px;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.theme-indie .lightbox-caption-container .caption-text,
.theme-indie .lightbox-caption-container .caption-text * {
    font-family: 'Excalifont', sans-serif !important;
}

.theme-indie .book-text > p:first-of-type::first-letter {
    font-family: inherit !important;
    font-size: inherit !important;
    color: inherit !important;
    float: none !important;
    margin: 0 !important;
    line-height: inherit !important;
}

.theme-indie .book-text > p:first-of-type {
    text-indent: 2em !important;
}

.mobile-action-row { display: none; }
        
@media (max-width: 768px) {
    .mobile-action-row { 
        display: flex; 
        gap: 10px; 
        margin-top: 15px;
        margin-bottom: 20px; 
    }
    .mobile-action-row button {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 12px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
        border-radius: 12px;
        color: var(--text-main, #ffffff);
        font-family: var(--font-ui, inherit);
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        outline: none;
        transition: 0.2s;
    }
    .mobile-action-row button:active {
        background: rgba(255, 255, 255, 0.1);
    }
}

.ex-gallery-wrapper {
    position: relative;
    margin: 30px 0;
    border-radius: 16px;
    overflow: hidden;
    background: transparent; 
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.ex-gallery {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    gap: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.ex-gallery::-webkit-scrollbar { 
    display: none; 
}

.ex-gallery img {
    flex: 0 0 100%;
    width: 100%;
    aspect-ratio: 16 / 9; 
    object-fit: cover; 
    scroll-snap-align: start;
    
    cursor: default; 
    background: transparent;
}

.gallery-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    font-size: 24px;
}

.gallery-nav-btn:hover { 
    background: var(--surface-hover);
    color: var(--text-primary);
    border-color: var(--border-hover);
    backdrop-filter: blur(10px);
}

.gallery-nav-btn.prev { left: 15px; }
.gallery-nav-btn.next { right: 15px; }

.gallery-nav-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 768px) {
    .gallery-nav-btn { display: none; }
}

.gallery-dots {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.05);
}
.gallery-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transition: 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.gallery-dot.active { 
    background: #fff; 
    transform: scale(1.3); 
}

@media (max-width: 768px) {
    .gallery-nav-btn { display: none; }
}

.material-content a, 
.book-text a, 
.desc-text a, 
.comment-text a,
.ex-c-text a {
    color: var(--accent-color);
    text-decoration: none;
    position: relative;
    font-weight: 500;
    transition: color 0.2s ease;
}

.material-content a:hover, 
.book-text a:hover, 
.desc-text a:hover, 
.comment-text a:hover,
.ex-c-text a:hover {
    color: var(--accent-hover);
}

.material-content a::after, 
.book-text a::after, 
.desc-text a::after, 
.comment-text a::after,
.ex-c-text a::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    bottom: -2px;
    left: 0;
    background-color: var(--accent-color);
    
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.material-content a:hover::after, 
.book-text a:hover::after, 
.desc-text a:hover::after, 
.comment-text a:hover::after,
.ex-c-text a:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

.mobile-action-row button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    
    background: var(--surface-2); 
    color: var(--text-primary); 
    border: 1px solid var(--border-color);
    
    border-radius: var(--border-radius-sm, 12px);
    padding: 12px 10px;
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.mobile-action-row button:hover,
.mobile-action-row button:active {
    background: var(--surface-hover);
}

.mobile-action-row button i {
    font-size: 18px;
    color: var(--text-secondary);
}