/* ==========================================================================
   Читалка ранобэ — Стили v3
   Темы: light, sepia, dark, amoled
   ========================================================================== */

:root {
    --bg: #ffffff;
    --text: #1a1a2e;
    --text-primary: #1a1a2e;
    --text-secondary: #64748b;
    --card-bg: #f8fafc;
    --card-border: rgba(99, 102, 241, 0.12);
    --card-hover: rgba(99, 102, 241, 0.05);
    --header-bg: rgba(255, 255, 255, 0.95);
    --accent: #4f46e5;
    --accent-light: rgba(79, 70, 229, 0.12);
    --divider: rgba(0, 0, 0, 0.06);
    --reader-bg: #fff;
    --reader-text: #2c2c2c;
    --shadow: 0 4px 12px rgba(0,0,0,0.05);
    --tab-bg: #f1f5f9;
    --tab-active: #4f46e5;
    --settings-bg: #ffffff;
    --input-bg: #f8fafc;
    --container-max: 800px;
    --glass-bg: rgba(255, 255, 255, 0.94);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --progress-gradient: linear-gradient(90deg, #6366f1 0%, #a855f7 100%);
    --overlay: rgba(0,0,0,0.4);
    --para-spacing: 20px;
    --bg-hover: rgba(99, 102, 241, 0.08);
    --bg-primary: #4f46e5;
    --border: rgba(99, 102, 241, 0.12);
    --divider-light: rgba(0, 0, 0, 0.04);
    --badge-bg: rgba(99, 102, 241, 0.1);
    --bg-secondary: #f1f5f9;
    --text-main: #1a1a2e;
    --accent-rgb: 79, 70, 229;
}

.theme-sepia {
    --bg-main: #f4ead5;
    --bg-secondary: #ede1c9;
    --text-main: #5b4636;
    --text-secondary: #8c786a;
    --glass-bg: rgba(244, 234, 213, 0.85);
    --glass-border: rgba(91, 70, 54, 0.15);
    --divider: rgba(91, 70, 54, 0.1);
}

.theme-dark {
    --bg-main: #1a1a2e;
    --bg-secondary: #16213e;
    --text-main: #e2e2e2;
    --text-secondary: #95a5a6;
    --glass-bg: rgba(26, 26, 46, 0.85);
    --glass-border: rgba(255, 255, 255, 0.1);
    --divider: rgba(255, 255, 255, 0.1);
}

.theme-amoled {
    --bg-main: #000000;
    --bg-secondary: #000000;
    --text-main: #ffffff;
    --text-secondary: #888888;
    --glass-bg: rgba(0, 0, 0, 0.9);
    --glass-border: rgba(255, 255, 255, 0.15);
    --divider: rgba(255, 255, 255, 0.2);
}

/* === ТЕМЫ === */
body.theme-sepia {
    --bg: #f4ead5;
    --text: #5b4636;
    --text-secondary: #8b7355;
    --card-bg: #efe3ca;
    --card-border: rgba(139, 90, 43, 0.15);
    --card-hover: rgba(139, 90, 43, 0.08);
    --header-bg: rgba(244, 234, 213, 0.95);
    --reader-bg: #f4ead5;
    --reader-text: #433422;
    --divider: rgba(139, 90, 43, 0.12);
    --tab-bg: #efe3ca;
    --settings-bg: #f4ead5;
    --input-bg: #efe3ca;
    --accent: #6366f1; /* Royal Indigo */
    --accent-light: rgba(99, 102, 241, 0.1);
    --accent-hover: #4f46e5;
    --badge-bg: rgba(99, 102, 241, 0.12);
    --progress-gradient: linear-gradient(90deg, #6366f1, #a855f7);
}

/* Themes */
body.theme-dark {
    --bg: #0f172a;
    --text: #e2e8f0;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --card-bg: #1e293b;
    --card-border: rgba(99, 102, 241, 0.1);
    --header-bg: #0f172a;
    --accent: #818cf8;
    --badge-bg: rgba(129, 140, 248, 0.15);
    --tab-active: #818cf8;
    --divider: rgba(255,255,255,0.08);
    --reader-bg: #0f172a;
    --reader-text: #e2e8f0;
    --input-bg: #1e293b;
    --settings-bg: #0f172a;
    --tab-bg: #1e293b;
    --card-hover: rgba(129, 140, 248, 0.05);
    --accent-light: rgba(129, 140, 248, 0.15);
    --progress-gradient: linear-gradient(90deg, #818cf8 0%, #c084fc 100%);
    --bg-secondary: #1e293b;
    --text-main: #e2e8f0;
    --accent-rgb: 129, 140, 248;
}

body.theme-amoled {
    --bg: #000000;
    --text: #cbd5e1;
    --header-bg: #000000;
    --accent: #818cf8;
    --card-bg: #111;
    --divider: rgba(255,255,255,0.1);
    --reader-bg: #000000;
    --reader-text: #cbd5e1;
    --input-bg: #111111;
    --settings-bg: #000000;
    --tab-bg: #111111;
    --text-primary: #ffffff;
    --card-hover: rgba(129, 140, 248, 0.1);
    --accent-light: rgba(129, 140, 248, 0.15);
    --progress-gradient: linear-gradient(90deg, #818cf8 0%, #c084fc 100%);
    --bg-secondary: #111111;
    --text-main: #ffffff;
    --accent-rgb: 129, 140, 248;
}

body.theme-gray {
    --bg: #1f2937; /* Gray 800 */
    --text: #d1d5db;
    --text-secondary: #9ca3af;
    --card-bg: #374151;
    --card-border: rgba(255, 255, 255, 0.05);
    --header-bg: #1f2937;
    --accent: #60a5fa;
    --tab-active: #60a5fa;
    --divider: rgba(255,255,255,0.05);
    --reader-bg: #1f2937;
    --reader-text: #d1d5db;
    --input-bg: #374151;
    --settings-bg: #1f2937;
    --tab-bg: #374151;
    --text-primary: #f3f4f6;
    --card-hover: rgba(96, 165, 250, 0.05);
    --accent-light: rgba(96, 165, 250, 0.15);
    --progress-gradient: linear-gradient(90deg, #60a5fa 0%, #a78bfa 100%);
    --bg-secondary: #374151;
    --text-main: #d1d5db;
    --accent-rgb: 96, 165, 250;
    --glass-bg: rgba(31, 41, 55, 0.85);
    --glass-border: rgba(255, 255, 255, 0.05);
}

/* === ГЛОБАЛЬНЫЕ ТЕМНЫЕ СКРОЛЛБАРЫ === */
*::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
*::-webkit-scrollbar-track {
    background: var(--bg);
}
*::-webkit-scrollbar-thumb {
    background: var(--divider);
    border-radius: 4px;
}
*::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

body {
    font-family: Inter, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transition: background 0.3s, color 0.3s;
}

/* === ЭКРАНЫ === */
.screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    opacity: 0;
    /* ★ Smooth Hardware-Accelerated Transitions */
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    will-change: transform, opacity;
    pointer-events: none;
}

.screen.active {
    transform: translate3d(0, 0, 0);
    opacity: 1;
    pointer-events: auto;
}

.screen.slide-left {
    transform: translateX(-30%);
    opacity: 0;
}

/* === ШАПКА === */
.reader-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--glass-border);
    z-index: 20;
    min-height: 56px;
    gap: 12px;
    transition: transform 0.3s ease, background 0.3s;
}

.header-title {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.header-title h1 {
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ★ SVG Icon System (пункт 1) */
.icon {
    width: 22px;
    height: 22px;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: color 0.2s, transform 0.2s;
}
.icon-sm { width: 18px; height: 18px; color: inherit; flex-shrink: 0; }
.icon-xs { width: 14px; height: 14px; color: inherit; flex-shrink: 0; }
.header-icon-svg {
    width: 24px;
    height: 24px;
    color: var(--accent);
}

.back-btn {
    background: var(--accent-light);
    border: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    /* ★ Spring feel */
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    flex-shrink: 0;
}
.back-btn .icon { color: var(--accent); }
.back-btn:active { transform: scale(0.85); }

.settings-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-shrink: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.settings-btn .icon { color: var(--text-secondary); }
.settings-btn:active { transform: scale(0.85); background: var(--accent-light); }
.settings-btn:active .icon { color: var(--accent); }

/* === ОБЛАСТИ КОНТЕНТА === */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

/* === КАРТОЧКИ СЕРИЙ === */
.series-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 18px 20px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
}

.series-card:hover { transform: translateY(-2px); background: var(--card-hover); }
.series-card:active { transform: scale(0.98); }

.series-icon {
    width: 50px; height: 50px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #feb47b);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.series-info { flex: 1; min-width: 0; }
.series-info h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.series-info p { font-size: 12px; color: var(--text-secondary); }
.series-arrow { color: var(--text-secondary); font-size: 20px; }

/* Бейдж «Продолжить» */
.continue-badge {
    display: inline-block;
    font-size: 10px;
    background: var(--accent);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    margin-top: 4px;
    animation: pulse-badge 2s ease-in-out infinite;
}
@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* === ТАБЫ ТОМОВ === */
.volume-tabs {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--divider);
    background: var(--header-bg);
    flex-shrink: 0;
}

.volume-tabs::-webkit-scrollbar { display: none; }

.vol-tab {
    padding: 7px 16px;
    border-radius: 20px;
    border: none;
    background: var(--tab-bg);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.vol-tab.active {
    background: var(--tab-active);
    color: #fff;
}

/* === СПИСОК ГЛАВ === */
.chapter-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--divider);
    cursor: pointer;
    transition: background 0.15s;
    gap: 12px;
}

.chapter-item:hover { background: var(--card-hover); }
.chapter-item:active { background: var(--accent-light); }

.chapter-num {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.chapter-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.chapter-read-mark {
    font-size: 16px;
    opacity: 0;
    transition: opacity 0.2s;
}

.chapter-item.read .chapter-read-mark { opacity: 1; }
.chapter-item.read .chapter-name { color: var(--text-secondary); }

/* === ЧИТАЛКА === */
.reader-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    background: var(--reader-bg);
    transition: background 0.3s;
}

.reader-text {
    max-width: 90%;
    margin: 0 auto;
    padding: 24px 16px 40px;
    font-size: 17px;
    line-height: 1.8;
    color: var(--reader-text);
    font-family: 'Noto Serif', Georgia, serif;
    word-wrap: break-word;
    transition: font-size 0.2s, color 0.3s, max-width 0.3s, line-height 0.2s;
}

.reader-text.font-sans {
    font-family: Inter, -apple-system, sans-serif;
}

.reader-text.font-slab { font-family: 'Roboto Slab', serif; }
.reader-text.font-mono { font-family: 'JetBrains Mono', 'Courier New', monospace; font-size: 0.9em; }

.reader-text p {
    margin-bottom: var(--para-spacing);
    line-height: inherit;
}

.indent-on p {
    text-indent: 1.5em;
}

.reader-text.align-justify {
    text-align: justify;
}

.reader-text a {
    color: var(--accent);
    text-decoration: none;
}

.reader-text iframe {
    width: 100%;
    min-height: 70vh;
    border: none;
    border-radius: 8px;
}

/* === СТИЛИ TELEGRAPH / RICH TEXT === */
.reader-text b, .reader-text strong { font-weight: 700; }
.reader-text i, .reader-text em { font-style: italic; }

.reader-text blockquote {
    margin: 1.5em 0;
    padding: 14px 20px;
    border-left: 4px solid var(--accent);
    background: var(--card-hover);
    border-radius: 0 12px 12px 0;
    font-style: italic;
    color: var(--text-secondary);
}
.reader-text blockquote p { text-indent: 0; margin-bottom: 0; }
.reader-text code {
    background: var(--card-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9em;
}

/* === КРАСИВАЯ ССЫЛКА НА КАНАЛ === */
.channel-banner {
    margin-top: 40px;
    padding: 2px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(var(--accent-rgb), 0.3);
}
.channel-content {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 24px;
    text-align: center;
    overflow: hidden;
}
.channel-content h3 { margin-bottom: 8px; font-size: 18px; font-weight: 700; color: var(--text); }
.channel-content p { font-size: 14px; color: var(--text-secondary); margin-bottom: 20px; line-height: 1.5; text-indent: 0; }
.channel-btn {
    display: inline-block;
    padding: 12px 28px;
    background: var(--accent);
    color: white !important;
    text-decoration: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 15px;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.4);
}
.channel-btn:active { transform: scale(0.95); box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.3); }

/* === НИЖНЯЯ НАВИГАЦИЯ === */
.reader-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-top: 1px solid var(--glass-border);
    z-index: 20;
    transition: transform 0.3s ease, background 0.3s;
}

.nav-btn {
    background: var(--accent-light);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.2s;
}

.nav-btn:active { transform: scale(0.95); }
.nav-btn:disabled { opacity: 0.3; pointer-events: none; }
.chapter-indicator { font-size: 13px; color: var(--text-secondary); font-weight: 500; }

/* --- Progress Bar --- */
.reading-progress-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 1000;
    background: transparent;
    pointer-events: none;
    transition: none;
}

.reading-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.2s ease-out;
}

/* Immersive state - removed progress bar shift */
.immersive .reader-top-bar { transform: translateY(-100%); }
.immersive .reader-bottom-bar { transform: translateY(100%); }

/* === ПАНЕЛЬ НАСТРОЕК === */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10001;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}

.settings-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.settings-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    border-radius: 24px 24px 0 0;
    padding: 24px;
    z-index: 10002;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
    max-height: 85vh;
    overflow-y: auto;
}

.settings-panel.hidden {
    transform: translateY(100%);
}

.reaction-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px;
    margin: 20px 0;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    overflow-x: auto;
    scrollbar-width: none;
}

.reaction-bar::-webkit-scrollbar { display: none; }

.reaction-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--divider);
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.reaction-item:active { transform: scale(0.9); }

.reaction-item.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.2);
}

.reaction-item.active .reaction-icon-wrapper {
    animation: reactionPop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes reactionPop {
    0% { transform: scale(1); }
    40% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

.floating-emoji {
    position: fixed;
    font-size: 28px;
    pointer-events: none;
    z-index: 9999;
    animation: floatUpEmoji 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
    user-select: none;
}

@keyframes floatUpEmoji {
    0% { transform: translate(0, 0) scale(0.5) rotate(0deg); opacity: 0; }
    15% { opacity: 1; transform: translate(0, -20px) scale(1.2) rotate(var(--r0)); }
    100% { transform: translate(var(--tx), var(--ty)) scale(1.5) rotate(var(--r)); opacity: 0; }
}

.reaction-count {
    font-size: 13px;
    font-weight: 600;
    opacity: 0.8;
}

.settings-title {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 700;
    text-align: center;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 600;
}

.setting-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.setting-buttons button {
    flex: 1;
    min-width: 60px;
    padding: 10px 5px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.setting-buttons button.active {
    background: var(--accent) !important;
    color: #ffffff !important;
    border-color: var(--accent) !important;
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

.manga-action-btn.active,
.channel-btn.active {
    background: var(--accent) !important;
    color: #ffffff !important;
    border-color: var(--accent) !important;
}

.theme-light-btn { background: #fff !important; }
.theme-sepia-btn { background: #f4ead5 !important; color: #5b4636 !important; }
.theme-dark-btn { background: #1a1a2e !important; color: #e0e0e0 !important; }
.theme-amoled-btn { background: #000 !important; color: #ccc !important; }

/* Range slider */
input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--divider);
    border-radius: 3px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 3px solid var(--bg);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.close-settings-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: var(--accent);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: transform 0.15s;
}
.close-settings-btn:active { transform: scale(0.97); }

/* === СПИННЕР === */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
}
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--divider);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-spinner p { font-size: 14px; color: var(--text-secondary); }

/* === ПУСТОЕ СОСТОЯНИЕ === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 17px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 14px; line-height: 1.5; }
.retry-btn {
    margin-top: 16px;
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
}
.retry-btn:active { transform: scale(0.95); opacity: 0.85; }

.hidden { display: none !important; }

/* === Admin Mode Switch === */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--divider); transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(20px); }

/* === Admin Edit Button === */
.admin-edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    margin-left: 6px;
    vertical-align: middle;
    padding: 6px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    user-select: none;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    color: var(--text);
}
.admin-edit-btn:active { background: var(--card-hover); }

.admin-reset-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    margin-left: 2px;
    vertical-align: middle;
    padding: 6px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
    user-select: none;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    color: #f59e0b;
}
.admin-reset-btn:active { background: rgba(245,158,11,0.15); }

.custom-name-badge {
    display: inline-block;
    background: rgba(34,197,94,0.18);
    color: #16a34a;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 1px 6px;
    border-radius: 20px;
    margin-right: 5px;
    vertical-align: middle;
    text-transform: uppercase;
}

/* ==========================================================================
   СОЦИАЛЬНЫЕ ФУНКЦИИ: Лайки + Комментарии
   ========================================================================== */

.social-section {
    max-width: 90%;
    margin: 0 auto;
    padding: 0 16px 80px;
}

/* --- Chapter Actions Bar (Channel + Like) --- */
.chapter-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin: 30px 0;
}

.manga-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border-radius: 16px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s, background 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    text-decoration: none;
}

.manga-action-btn:active {
    transform: scale(0.96);
}

.channel-btn {
    flex: 1.5;
    background: var(--progress-gradient);
    color: white !important;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.3);
}

.channel-btn:hover {
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
}

.like-btn {
    flex: 1;
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
}

.like-btn.liked {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

.like-icon {
    font-size: 22px;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
.like-btn.liked .like-icon { transform: scale(1.25); }

.like-count { font-size: 15px; }

@keyframes like-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.4); }
    100% { transform: scale(1.25); }
}
.like-btn.just-liked .like-icon {
    animation: like-pop 0.4s ease-out;
}

/* --- Реакции (Premium Style) --- */
.reaction-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 24px 0;
    padding: 14px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}
.reaction-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--divider);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    position: relative;
    overflow: hidden;
}
.reaction-item:hover {
    border-color: var(--accent);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 4px 12px var(--accent-light);
}
.reaction-item:active { transform: translateY(-1px) scale(0.98); }

.reaction-item.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}
.reaction-emoji { 
    font-size: 20px; 
    transition: transform 0.3s;
}
.reaction-item:hover .reaction-emoji {
    transform: scale(1.2) rotate(5deg);
}
.reaction-count { font-size: 13px; font-weight: 800; }

/* --- Сортировка комментариев (MangaLib Style) --- */
.comment-tabs {
    display: flex;
    gap: 16px;
    margin: 20px 0;
    border-bottom: 1px solid var(--divider);
    padding-bottom: 8px;
}
.comment-tab {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    padding-bottom: 8px;
    transition: color 0.2s;
}
.comment-tab.active {
    color: var(--accent);
}
.comment-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

/* --- Комментарии --- */
.comments-section {
    border-top: 1px solid var(--divider);
    padding-top: 20px;
}

.comments-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.comments-count {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.comment-form {
    margin-bottom: 20px;
}

.comment-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--divider);
    border-radius: 14px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 14px;
    font-family: Inter, -apple-system, sans-serif;
    resize: vertical;
    min-height: 44px;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s;
}
.comment-input:focus { border-color: var(--accent); }
.comment-input::placeholder { color: var(--text-secondary); }

.comment-submit-btn {
    margin-top: 10px;
    padding: 10px 24px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.2s;
    float: right;
}
.comment-submit-btn:active { transform: scale(0.96); }
.comment-submit-btn:disabled { opacity: 0.4; pointer-events: none; }

.comment-reactions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.reaction-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: var(--settings-bg);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, color 0.2s;
    user-select: none;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.reaction-item:active { transform: scale(0.95); }
.reaction-item.active { background: var(--accent-light); color: var(--accent); border-color: rgba(var(--accent-rgb), 0.3); }

.reaction-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
}
.r-svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: all 0.2s;
}

.reaction-item.type-heart.active .r-svg { fill: currentColor; }
.reaction-item.type-fire.active .r-svg { color: #f97316; stroke: #f97316; }
.reaction-item.type-like.active .r-svg { fill: currentColor; }
.reaction-item.type-sad .r-svg { fill: none; }

.c-reaction-btn {
    background: var(--input-bg);
    border: 1px solid var(--divider);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}
.c-reaction-btn span { font-weight: 600; }
.c-reaction-btn:hover { border-color: var(--accent); color: var(--text); }
.c-reaction-btn.active.c-like { background: rgba(0, 200, 83, 0.1); border-color: #00c853; color: #00c853; }
.c-reaction-btn.active.c-dislike { background: rgba(255, 82, 82, 0.1); border-color: #ff5252; color: #ff5252; }

.comment-main-actions {
    display: flex;
    gap: 12px;
}

.c-action-btn {
    background: none;
    border: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 0;
    transition: color 0.2s;
}
.c-action-btn:hover { color: var(--accent); }
.c-action-btn.c-delete:hover { color: #ff5252; }

.comment-children {
    margin-top: 12px;
    padding-left: 12px;
    border-left: 2px solid var(--divider);
}

.comment-reply {
    border-bottom: none;
    padding-bottom: 0px;
    padding-top: 12px;
}

.no-comments {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* === Карточка Продолжить чтение === */
.continue-reading-card {
    background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.1), rgba(254, 180, 123, 0.1));
    border: 1px solid rgba(var(--accent-rgb), 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(var(--accent-rgb), 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}
.continue-reading-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.15); }
.continue-reading-card:active { transform: translateY(1px); }
.continue-reading-icon {
    font-size: 28px;
    margin-right: 16px;
    filter: drop-shadow(0 2px 4px rgba(255,107,129,0.3));
}
.continue-reading-info {
    flex: 1;
}
.continue-reading-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.continue-reading-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 2px 0;
}
.continue-reading-chapter {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}
.continue-reading-arrow {
    font-size: 18px;
    color: var(--accent);
    opacity: 0.7;
}

/* === Анимация Лайка === */
.like-btn {
    background: var(--card-bg);
    border: 1px solid var(--divider);
    border-radius: 20px;
    padding: 8px 16px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.like-btn.liked {
    border-color: var(--accent);
    background: var(--accent-light);
}
.like-icon {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.like-btn.liked .like-icon {
    color: var(--accent);
    transform: scale(1.2);
}
.like-btn:active .like-icon { transform: scale(0.8); }

.social-section {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px dashed var(--divider);
}
.like-section {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

/* ==========================================================================
   IMAGE LIGHTBOX
   ========================================================================== */

.lightbox-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-user-select: none;
    user-select: none;
}
.lightbox-overlay:not(.hidden) {
    opacity: 1;
}
.lightbox-overlay.hidden {
    pointer-events: none;
}

.lightbox-close {
    position: absolute;
    top: 16px; right: 16px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: none;
    color: #fff;
    font-size: 24px;
    width: 44px; height: 44px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2010;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}
.lightbox-close:active { transform: scale(0.9); background: rgba(255,255,255,0.25); }

.lightbox-image-wrapper {
    max-width: 95vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: pinch-zoom;
}

.lightbox-img {
    max-width: 95vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    transition: transform 0.25s ease;
    cursor: zoom-in;
}
.lightbox-img.zoomed { cursor: zoom-out; }

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.12);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: none;
    color: #fff;
    font-size: 36px;
    width: 48px; height: 48px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2010;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}
.lightbox-nav:active { transform: translateY(-50%) scale(0.9); background: rgba(255,255,255,0.25); }
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }
.lightbox-nav:disabled { opacity: 0.2; pointer-events: none; }

.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.7);
    font-size: 13px;
    font-weight: 500;
    background: rgba(0,0,0,0.4);
    padding: 6px 16px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ==========================================================================
   TABLE OF CONTENTS (ToC) SIDEBAR
   ========================================================================== */

.toc-toggle-btn {
    background: var(--accent-light);
    border: none;
    width: 36px; height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.toc-toggle-btn:active { transform: scale(0.9); }

.toc-panel {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: min(300px, 85vw);
    background: var(--bg);
    z-index: 105;
    transform: translateX(-100%);
    box-shadow: 10px 0 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.toc-panel.active {
    transform: translateX(0);
    visibility: visible;
    pointer-events: all;
    backdrop-filter: blur(20px);
}

.toc-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.toc-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--divider);
    flex-shrink: 0;
}
.toc-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.toc-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.toc-close-btn:active { background: var(--card-hover); }

.toc-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
}

.toc-item {
    display: block;
    padding: 10px 20px;
    font-size: 14px;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.2s;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toc-item:active { background: var(--card-hover); }
.toc-item.active {
    border-left-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}
.toc-item.toc-h3 { padding-left: 36px; font-size: 13px; }
.toc-item.toc-h4 { padding-left: 52px; font-size: 12px; color: var(--text-secondary); }

/* === AUTOSCROLL FAB === */
.autoscroll-fab {
    position: fixed;
    bottom: 70px;
    right: 16px;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    font-size: 18px;
    cursor: pointer;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.4);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s;
    -webkit-tap-highlight-color: transparent;
}
.autoscroll-fab:active { transform: scale(0.9); }
.autoscroll-fab.scrolling {
    background: linear-gradient(135deg, var(--accent), #feb47b);
    animation: autoscroll-pulse 1.5s ease-in-out infinite;
}
@keyframes autoscroll-pulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.4); }
    50% { box-shadow: 0 4px 24px rgba(var(--accent-rgb), 0.6); }
}

/* === EDIT URL MODAL & BULK UPLOAD MODAL (Admin) === */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--overlay);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s;
}
.modal-overlay:not(.hidden) { opacity: 1; }

.edit-url-modal, .bulk-upload-modal {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--settings-bg);
    border-radius: 20px 20px 0 0;
    padding: 24px 20px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    z-index: 100;
    transform: translateY(100%);
    /* ★ Spring Physics (пункт 4) */
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 -4px 30px rgba(0,0,0,0.15);
}
.edit-url-modal:not(.hidden), .bulk-upload-modal:not(.hidden) {
    transform: translateY(0);
}

.edit-url-modal h3, .bulk-upload-modal h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.edit-url-chapter-name {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.edit-url-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--divider);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 14px;
    font-family: Inter, -apple-system, monospace;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 16px;
}
.edit-url-input:focus { border-color: var(--accent); }

.bulk-upload-hint {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.bulk-upload-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--divider);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 13px;
    font-family: Inter, -apple-system, monospace;
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
    outline: none;
    transition: border-color 0.2s;
    margin-bottom: 16px;
}
.bulk-upload-input:focus { border-color: var(--accent); }

.edit-url-actions, .bulk-upload-actions {
    display: flex;
    gap: 12px;
}

.edit-url-cancel {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--divider);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s;
}
.edit-url-cancel:active { transform: scale(0.97); }

.edit-url-save {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 12px;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s;
}
.edit-url-save:active { transform: scale(0.97); }
.edit-url-save:disabled { opacity: 0.4; pointer-events: none; }

/* === Admin Link Edit Button === */
.admin-link-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    margin-left: 2px;
    vertical-align: middle;
    padding: 6px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    user-select: none;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    color: #3b82f6;
}
.admin-link-btn:active { background: rgba(59, 130, 246, 0.1); }

/* === Bulk Upload Button === */
.admin-bulk-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    margin: 8px 16px;
    border: 2px dashed var(--accent);
    border-radius: 12px;
    background: var(--accent-light);
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.admin-bulk-btn:active { transform: scale(0.97); }

/* ==========================================================================
   SOCIAL SECTION (Likes & Comments)
   ========================================================================== */

.social-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--divider);
}

.reaction-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.reaction-item {
    padding: 6px 12px;
    border-radius: 16px;
    background: var(--bg-secondary);
    font-size: 14px;
    cursor: pointer;
}

.like-section {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
}

.like-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--input-bg);
    border: 1px solid var(--divider);
    padding: 10px 24px;
    border-radius: 24px;
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.like-btn.liked {
    background: rgba(var(--accent-rgb), 0.1);
    border-color: rgba(var(--accent-rgb), 0.4);
    color: var(--accent);
}
.like-btn:active { transform: scale(0.95); }
.like-btn.just-liked { animation: heart-beat 0.5s ease-in-out; }

@keyframes heart-beat {
    0% { transform: scale(1); }
    40% { transform: scale(1.25); }
    100% { transform: scale(1); }
}

.comments-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.comments-count {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 14px;
}

.comment-form {
    background: var(--input-bg);
    border: 1px solid var(--divider);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 24px;
}

.reply-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg);
    padding: 6px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}
.reply-indicator strong { color: var(--text); }
.cancel-reply-btn {
    background: none; border: none; color: var(--text-secondary);
    cursor: pointer; font-size: 12px; padding: 4px;
}

.comment-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 14px;
    resize: none;
    outline: none;
    font-family: inherit;
}

.comment-submit-btn {
    margin-top: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    float: right;
}
.comment-submit-btn:disabled { opacity: 0.5; }
.comment-form::after { content: ""; display: block; clear: both; }

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.no-comments {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 24px 0;
}

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

.comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.comment-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #9945FF);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.comment-meta {
    flex: 1;
}

.comment-author {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.comment-date {
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.6;
    margin-left: 2px;
}

.comment-text {
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--text);
    white-space: pre-wrap;
    margin-top: 2px;
}

.comment-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.c-action-btn {
    font-size: 11px;
    padding: 2px 6px;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.comment-reply-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px;
}

.comment-delete-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
}

/* --- Compact Comments (MangaLib style) --- */
.comment-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
}

.comment-content {
    flex: 1;
    min-width: 0;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.comment-author {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.comment-date {
    font-size: 10px;
    color: var(--text-secondary);
    opacity: 0.7;
    margin-left: auto;
}

.comment-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--reader-text);
    word-break: break-word;
    margin-bottom: 4px;
}

.comment-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.c-action-btn {
    font-size: 11px;
    padding: 2px 6px;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

.comment-role-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}
.comment-role-badge.admin { background: var(--badge-admin-bg); color: var(--badge-admin-text); }

/* Вложенные комментарии */
.comment-children {
    margin-left: 18px; /* Сдвиг */
    padding-left: 24px;
    border-left: 1px dashed var(--divider);
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.comment-reply .comment-avatar {
    width: 24px;
    height: 24px;
    font-size: 12px;
}
.comment-reply .comment-text {
    padding-left: 34px; /* 24 + 10 */
    font-size: 13px;
}

/* ==========================================================================
   БИБЛИОТЕКА И СТАТИСТИКА
   ========================================================================== */

.reading-stats-card {
    display: flex;
    gap: 16px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.stat-item {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon {
    font-size: 24px;
    background: var(--accent-light);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.library-section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.library-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--divider);
    border-radius: 3px;
    margin-top: 8px;
    overflow: hidden;
}

.library-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #feb47b);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ==========================================================================
   ГЛАВНЫЙ ТАБ БАР (Нижняя навигация)
   ========================================================================== */

.bottom-nav-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-bottom));
    background: var(--bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--divider);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 50;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: none;
    border: none;
    color: var(--text-secondary);
    gap: 4px;
    cursor: pointer;
    transition: color 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.nav-tab:active {
    transform: scale(0.93);
}

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

/* ★ SVG icons in tab bar */
.tab-icon-svg {
    width: 24px;
    height: 24px;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-tab.active .tab-icon-svg {
    transform: translateY(-2px) scale(1.05);
    color: var(--accent);
}

.nav-tab .tab-label {
    font-size: 11px;
    font-weight: 600;
}

.screen:not(#screen-reader) .content-area {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* ==========================================================================
   РЕПОРТ ОПЕЧАТОК (TYPO REPORTER)
   ========================================================================== */

.typo-tooltip {
    position: absolute;
    background: var(--text);
    color: var(--bg);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 1000;
    transform: translate(-50%, -100%);
    margin-top: -10px;
    opacity: 0;
    transition: opacity 0.2s, margin-top 0.2s;
    pointer-events: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.typo-tooltip.visible {
    opacity: 1;
    margin-top: -15px;
    pointer-events: all;
}

.typo-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 6px 0;
    border-style: solid;
    border-color: var(--text) transparent transparent transparent;
}

.typo-modal-context {
    background: var(--card-hover);
    padding: 12px;
    border-radius: 8px;
    border-left: 3px solid var(--accent);
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-style: italic;
    line-height: 1.5;
}

.typo-modal-selected {
    font-weight: bold;
    color: var(--accent);
    background: var(--accent-light);
    padding: 0 4px;
    border-radius: 4px;
}

.typo-modal-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 12px;
    border-radius: 12px;
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 16px;
}
.typo-modal-input:focus {
    border-color: var(--accent);
}

/* ==========================================================================
   DRAG-N-DROP CHAPTER SORT (Admin, Batch 3)
   ========================================================================== */

.drag-handle {
    cursor: grab;
    font-size: 16px;
    color: var(--text-secondary);
    user-select: none;
    padding: 4px 6px;
    margin-right: 2px;
    opacity: 0.6;
    transition: opacity 0.2s, color 0.2s;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}
.drag-handle:active { cursor: grabbing; opacity: 1; color: var(--accent); }
.chapter-item[draggable="true"]:hover .drag-handle { opacity: 1; }

.chapter-item.dragging {
    opacity: 0.4;
    background: var(--accent-light) !important;
    transform: scale(0.97);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 10;
    transition: opacity 0.2s, transform 0.2s;
}

.chapter-item.drag-over {
    border-top: 2px solid var(--accent);
    padding-top: 14px;
    margin-top: -2px;
    transition: all 0.15s ease;
}

/* ==========================================================================
   COVER IMAGES (Batch 3)
   ========================================================================== */

.series-cover-img {
    width: 56px;
    height: 78px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}
.series-card:hover .series-cover-img,
.series-card:active .series-cover-img {
    transform: scale(1.05);
}

.library-cover {
    width: 56px;
    height: 78px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* ==========================================================================
   ★ ADMIN FLOATING MENU (Phase 4)
   ========================================================================== */

.admin-fab-container {
    position: fixed;
    right: 20px;
    bottom: 90px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

.admin-fab-container * {
    pointer-events: auto;
}

.admin-fab-btn {
    width: 50px;
    height: 50px;
    border-radius: 25px;
    background: var(--accent);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-fab-btn:active {
    transform: scale(0.9);
}

.admin-fab-btn svg {
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.admin-fab-btn.open svg {
    transform: rotate(180deg);
}

.admin-menu {
    position: absolute;
    bottom: 65px;
    right: 0;
    width: 200px;
    padding: 8px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.admin-menu.hidden {
    opacity: 0;
    transform: scale(0.8) translateY(20px);
    pointer-events: none;
}

.admin-menu-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 8px 12px 4px;
    opacity: 0.6;
    font-weight: 700;
}

.admin-menu-item {
    background: transparent;
    border: none;
    color: var(--text);
    padding: 10px 12px;
    text-align: left;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.admin-menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.admin-menu-item .icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.continue-badge {
    display: inline-block;
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    background: var(--accent-light);
    padding: 2px 8px;
    border-radius: 6px;
    margin-top: 4px;
}

/* ==========================================================================
   ★ READER 2.0: Auto-Hide UI Bars (Spring Physics)
   ========================================================================== */

.reader-top-bar,
.reader-bottom-bar {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s ease,
                background 0.3s;
    will-change: transform, opacity;
}

.reader-top-bar.bars-hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}

.reader-bottom-bar.bars-hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}

/* ==========================================================================
   ★ READER 2.0: Skeleton Shimmer Loader (Enhanced)
   ========================================================================== */

.skeleton-loader {
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.skeleton-line {
    height: 16px;
    border-radius: 8px;
    background: linear-gradient(
        90deg,
        var(--divider) 25%,
        var(--card-hover) 37%,
        var(--divider) 63%
    );
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
}

@keyframes skeleton-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ★ Skeleton Cards for Library/Series (пункт 3 — продвинутая загрузка) */
.skeleton-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 0;
}

.skeleton-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.skeleton-cover {
    width: 50px;
    height: 68px;
    border-radius: 10px;
    flex-shrink: 0;
    background: linear-gradient(
        90deg,
        var(--divider) 25%,
        var(--card-hover) 37%,
        var(--divider) 63%
    );
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
}

.skeleton-card-lines {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ★ Skeleton for chapters list */
.skeleton-chapters {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.skeleton-chapter {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--divider);
}

.skeleton-chapter-num {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    background: linear-gradient(
        90deg,
        var(--divider) 25%,
        var(--card-hover) 37%,
        var(--divider) 63%
    );
    background-size: 400% 100%;
    animation: skeleton-shimmer 1.4s ease infinite;
}

/* ==========================================================================
   ★ READER 2.0: Slide Chapter Transitions (Spring)
   ========================================================================== */

.reader-text {
    transition: font-size 0.2s, color 0.3s, max-width 0.3s, line-height 0.2s;
}

.reader-text.slide-out-left {
    animation: slideOutLeft 0.22s ease forwards;
}
.reader-text.slide-out-right {
    animation: slideOutRight 0.22s ease forwards;
}
.reader-text.slide-in-right {
    animation: slideInRight 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.reader-text.slide-in-left {
    animation: slideInLeft 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideOutLeft {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-50px); }
}
@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(50px); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(50px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-50px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ==========================================================================
   ★ READER 2.0: Smart Image Fade-In with Blur Placeholder (пункт 6)
   ========================================================================== */

.reader-text img {
    opacity: 1;
    filter: none;
    max-width: 100%;
    border-radius: 8px;
    margin: 12px 0;
}
.reader-text img.img-loading {
    background: var(--card-hover);
    min-height: 120px;
}

/* ==========================================================================
   ★ READER 2.0: Teletype iframe Dark Mode
   ========================================================================== */

.teletype-iframe {
    transition: filter 0.3s ease;
}

/* ==========================================================================
   ★ READER 2.0: Lightbox swipe gesture (Spring)
   ========================================================================== */

.lightbox-image-wrapper {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox-overlay {
    transition: opacity 0.3s ease, background 0.2s ease;
}

/* ==========================================================================
   ★ ФАЗА 1: Toast Notifications (пункт 2)
   ========================================================================== */

.toast-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    padding: 12px 16px;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: var(--text);
    color: var(--bg);
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    font-family: Inter, -apple-system, sans-serif;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    pointer-events: all;
    transform: translateY(-120%) scale(0.9);
    opacity: 0;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.3s ease;
    max-width: 340px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.toast.toast-visible {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.toast.toast-exit {
    transform: translateY(-120%) scale(0.9);
    opacity: 0;
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-success { background: #16a34a; color: #fff; }
.toast-error   { background: #dc2626; color: #fff; }
.toast-info    { background: var(--text); color: var(--bg); }
.toast-warning { background: #f59e0b; color: #1a1a2e; }

/* ==========================================================================
   ★ ФАЗА 4: Morphing FAB Button (пункт 10)
   ========================================================================== */

.autoscroll-fab {
    position: fixed;
    bottom: 80px;
    left: 16px;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(var(--accent-rgb), 0.35);
    z-index: 60;
    transition: transform 0.2s, opacity 0.3s;
    font-size: 18px;
}

.autoscroll-fab.hidden {
    display: none;
}

.autoscroll-fab:active {
    transform: scale(0.9);
}

.fab-container {
    position: fixed;
    bottom: 80px;
    right: 16px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.fab-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(var(--accent-rgb), 0.45);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    z-index: 61;
}

.fab-btn:active {
    transform: scale(0.88);
}

.fab-btn.fab-open {
    background: var(--text);
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}

.fab-icon {
    width: 24px;
    height: 24px;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.2s ease;
    position: absolute;
}

.fab-icon-plus {
    opacity: 1;
    transform: rotate(0);
}

.fab-open .fab-icon-plus {
    opacity: 0;
    transform: rotate(135deg);
}

.fab-icon-close {
    opacity: 0;
    transform: rotate(-135deg);
}

.fab-open .fab-icon-close {
    opacity: 1;
    transform: rotate(0);
}

.fab-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    transform: translateY(20px) scale(0.85);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s ease;
    pointer-events: none;
}

.fab-menu.fab-menu-visible {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: var(--settings-bg);
    border: 1px solid var(--divider);
    border-radius: 28px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    font-family: Inter, -apple-system, sans-serif;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.fab-menu-item .icon-sm { color: var(--accent); }

.fab-menu-item:active {
    transform: scale(0.93);
    background: var(--accent-light);
}

/* Staggered FAB menu animation */
.fab-menu-visible .fab-menu-item:nth-child(1) { transition-delay: 0s; }
.fab-menu-visible .fab-menu-item:nth-child(2) { transition-delay: 0.04s; }
.fab-menu-visible .fab-menu-item:nth-child(3) { transition-delay: 0.08s; }

/* ==========================================================================
   ★ ФАЗА 4: Pull-to-Next Chapter Indicator (пункт 11)
   ========================================================================== */

.pull-next-indicator {
    display: flex;
    justify-content: center;
    padding: 32px 16px 48px;
    color: var(--text-secondary);
    pointer-events: none; /* Устранение перекрытия кликов на ПК */
}

.pull-next-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0.7;
    transition: opacity 0.3s, transform 0.3s;
}

.pull-next-arrow {
    color: var(--accent);
    animation: pullBounce 1.5s ease-in-out infinite;
}

@keyframes pullBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(6px); }
}

.pull-next-content.pull-active {
    opacity: 1;
    transform: scale(1.05);
}

.pull-next-content.pull-loading .pull-next-arrow {
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   ★ ФАЗА 4: Swipe-to-Go-Back (пункт 12)
   ========================================================================== */

.swipe-back-indicator {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%) translateX(-100%);
    width: 28px;
    height: 80px;
    background: linear-gradient(90deg, var(--accent), transparent);
    border-radius: 0 20px 20px 0;
    z-index: 9000;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.swipe-back-indicator.swiping {
    opacity: 0.6;
    transform: translateY(-50%) translateX(0);
}

.swipe-back-indicator.swiping-commit {
    opacity: 1;
    transform: translateY(-50%) translateX(8px);
}

/* ==========================================================================
   ★ ФАЗА 1: Content fade-in for loaded screens
   ========================================================================== */

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

.content-fade-in {
    animation: contentFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ★ Liked heart SVG styling */
.like-btn .like-icon {
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), color 0.2s;
}

.like-btn.liked .like-icon {
    color: var(--accent);
    fill: var(--accent);
    transform: scale(1.2);
}

.like-btn.just-liked .like-icon {
    animation: heartPop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ★ Индикатор времени чтения */
.reading-time-badge {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-family: Inter, -apple-system, sans-serif;
    opacity: 0.8;
}

/* ★ Scrollbar styling for dark themes */
.reader-content::-webkit-scrollbar { width: 4px; }
.reader-content::-webkit-scrollbar-track { background: transparent; }
.reader-content::-webkit-scrollbar-thumb {
    background: var(--divider);
    border-radius: 4px;
}

/* ★ Stat icons with SVG */
.stat-icon .icon-sm { color: var(--accent); }

/* ==========================================================================
   ★ BATCH 4: MANGALIB DELUXE STYLES
   Categorized Settings, Full-screen Dimmer, Inter Font
   ========================================================================== */

:root {
    --inter-font: 'Inter', -apple-system, system-ui, sans-serif;
    --progress-height: 4px;
    --badge-admin-bg: rgba(var(--accent-rgb), 0.15);
    --badge-admin-text: var(--accent);
}

/* --- Full Screen Dimmer --- */
.dimmer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0);
    z-index: 10000;
    pointer-events: none;
    transition: background-color 0.3s ease;
}

/* --- Top Progress Bar --- */
.top-progress-line {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--accent);
    width: 0%;
    z-index: 9999;
    pointer-events: none;
    /* Убрали анимацию появления, оставили только плавное изменение ширины */
    transition: width 0.2s ease-out;
}

/* Deleted duplicate progress bar styles */

/* --- Categorized Settings Panel --- */
.settings-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--divider);
    padding-bottom: 8px;
}

.settings-tab-btn {
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 8px;
}

.settings-tab-btn.active {
    color: var(--accent);
    background: var(--badge-bg);
}

.settings-tab-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.settings-tab-content.hidden {
    display: none;
}

.animate-slide-in {
    animation: slideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(15px); }
    to { opacity: 1; transform: translateX(0); }
}

/* --- Segmented Control (MangaLib style) --- */
.segmented-control {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 4px;
    margin-top: 8px;
    border: 1px solid var(--divider);
}

.segmented-control button {
    padding: 8px 4px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s;
}

.segmented-control button.active {
    background: var(--accent) !important;
    color: #ffffff !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* --- Theme Chips --- */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.theme-chip {
    padding: 10px;
    border: 1.5px solid var(--divider);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.theme-chip::before {
    content: '';
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
}

.theme-chip.theme-light::before { background: #ffffff; }
.theme-chip.theme-sepia::before { background: #f4ecd8; }
.theme-chip.theme-gray::before { background: #333333; }
.theme-chip.theme-dark::before { background: #1a1a1a; }
.theme-chip.theme-amoled::before { background: #000000; }

.theme-chip.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* --- Range Inputs --- */
.setting-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.setting-value-badge {
    background: var(--badge-bg);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}

/* --- Header Improvement: Quick Switcher --- */
.header-title-container {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.header-title-container:hover {
    background: var(--bg-hover);
}

.switcher-arrow {
    opacity: 0.6;
}

.header-right-actions {
    display: flex;
    gap: 8px;
}

.header-action-btn {
    padding: 8px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    transition: background 0.2s;
}

.header-action-btn:hover {
    background: var(--bg-hover);
}

.quick-switcher {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: min(340px, 94vw);
    max-height: 60vh;
    overflow-y: auto;
    z-index: 30000; /* Max priority */
    background: var(--bg);
    border: 1px solid var(--divider);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.quick-switcher.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translate(-50%, -50%) scale(1);
}

.quick-switcher-header {
    padding: 16px 20px;
    font-size: 12px;
    font-weight: 800;
    border-bottom: 1px solid var(--divider-light);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(255,255,255,0.02);
}

.quick-switcher-list {
    padding: 8px 0;
}

.quick-switcher-item {
    padding: 14px 20px;
    font-size: 14.5px;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    margin: 2px 8px;
    border-radius: 12px;
}

.quick-switcher-item:hover {
    background: var(--bg-hover);
    padding-left: 20px;
}

.quick-switcher-item.active {
    color: var(--accent);
    font-weight: 700;
    background: var(--badge-bg);
}

/* --- Immersive Mode Classes --- */
.header-hidden {
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
}
.bar-hidden {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
}
.fab-hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.reader-header, .reader-bottom-bar, .fab-container {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

/* --- Comment Roles & Branches --- */
.comment-role-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 6px;
}

.badge-admin {
    background: var(--badge-admin-bg);
    color: var(--badge-admin-text);
}

.comment-branch {
    position: absolute;
    left: -20px;
    top: 0;
    bottom: 20px;
    width: 2px;
    background: var(--divider);
}

.comment-branch-curve {
    position: absolute;
    left: -20px;
    top: 20px;
    width: 20px;
    height: 2px;
    background: var(--divider);
}

/* --- Setting Blocks (Stacked) --- */
.setting-item-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 0;
}

.setting-item-block label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Setting Rows (Horizontal) --- */
.setting-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--divider-light);
}

.setting-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-info label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-hint {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* --- Improved Sliders --- */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--divider);
    border-radius: 5px;
    outline: none;
    margin: 12px 0;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent);
    cursor: pointer;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255,107,129,0.3);
    transition: transform 0.1s ease;
}

input[type=range]:active::-webkit-slider-thumb {
    transform: scale(1.2);
}

/* --- Comment Form Revamp --- */
.comment-form-modes {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: var(--bg-secondary);
    padding: 3px;
    border-radius: 10px;
    width: fit-content;
}

.comment-mode-btn {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.comment-mode-btn.active {
    background: var(--badge-bg);
    color: var(--accent);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.comment-toolbar {
    display: flex;
    gap: 4px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--divider-light);
    margin-bottom: 8px;
}

.comment-toolbar button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.comment-toolbar button:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.comment-preview-area {
    min-height: 40px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    margin-top: 12px;
    border: 1px dashed var(--divider);
    color: var(--text-main);
}
.comment-preview-area:empty { display: none; }

.comment-quote {
    border-left: 3px solid var(--accent);
    margin: 8px 0;
    padding: 4px 12px;
    background: var(--accent-light);
    font-style: italic;
    font-size: 14px;
    border-radius: 0 8px 8px 0;
}

/* Visibility helper */
.hidden { display: none !important; }
/* Font classes */
.font-sans, .font-montserrat, .font-display {
    font-family: var(--inter-font) !important;
}
.font-montserrat { font-family: 'Montserrat', sans-serif !important; }
.font-display { font-family: 'Playfair Display', serif !important; }

/* Smooth fade transition between chapters */
.reader-content {
    transition: opacity 0.3s ease;
}
.reader-content.loading {
    opacity: 0;
}



