/* === my_book.css === */
/* Проект "Моя книга" — Админ-панель для написания книги */
/* Светлая тема по умолчанию, + сепия, + тёмная */

@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@400..700&family=Inter:wght@300;400;500;600;700;800&family=Kelly+Slab&family=Lobster&family=Montserrat:ital,wght@0,100..900;1,100..900&family=Playfair+Display:wght@400;600;700&family=Special+Elite&display=swap');

#comic-viewer {
    display: none;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--book-bg);
}

.comic-viewer-header {
    padding: 10px 20px;
    border-bottom: 1px solid var(--book-border);
    background: var(--book-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.comic-viewer-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: var(--book-bg);
}

/* ============ LIGHT THEME (default) ============ */
:root {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

:root {
    --book-bg: #f4f5f7;
    --book-surface: #ffffff;
    --book-surface-2: #f0f1f3;
    --book-surface-3: #e4e5e9;
    --book-border: rgba(0, 0, 0, 0.08);
    --book-border-hover: rgba(0, 0, 0, 0.15);
    --book-text: #1a1a2e;
    --book-text-muted: #6b6b80;
    --book-text-dim: #9e9eb0;
    --book-accent: #6c5ce7;
    --book-accent-hover: #5a4bd1;
    --book-accent-glow: rgba(108, 92, 231, 0.15);
    --book-gold: #e6a817;
    --book-green: #22c55e;
    --book-red: #ef4444;
    --book-orange: #f59e0b;
    --book-radius: 12px;
    --book-radius-sm: 8px;
    --book-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --book-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --book-topbar-bg: rgba(255, 255, 255, 0.88);
    --book-toolbar-bg: rgba(244, 245, 247, 0.8);
    --book-glow1: rgba(108, 92, 231, 0.06);
    --book-glow2: rgba(230, 168, 23, 0.04);
    --book-editor-bg: #ffffff;
    --book-scrollbar: #d0d0d8;
    --book-confirm-bg: rgba(0, 0, 0, 0.3);
}

/* ============ SEPIA THEME ============ */
[data-book-theme="sepia"] {
    --book-bg: #f3e8d4;
    --book-surface: #faf3e6;
    --book-surface-2: #efe4d0;
    --book-surface-3: #e4d7c0;
    --book-border: rgba(93, 64, 55, 0.12);
    --book-border-hover: rgba(93, 64, 55, 0.22);
    --book-text: #3e2723;
    --book-text-muted: #6d4c41;
    --book-text-dim: #a1887f;
    --book-accent: #8d6e63;
    --book-accent-hover: #6d4c41;
    --book-accent-glow: rgba(141, 110, 99, 0.18);
    --book-gold: #c68a00;
    --book-green: #558b2f;
    --book-red: #c62828;
    --book-orange: #ef6c00;
    --book-shadow: 0 4px 20px rgba(62, 39, 35, 0.1);
    --book-topbar-bg: rgba(250, 243, 230, 0.9);
    --book-toolbar-bg: rgba(239, 228, 208, 0.7);
    --book-glow1: rgba(141, 110, 99, 0.06);
    --book-glow2: rgba(198, 138, 0, 0.04);
    --book-editor-bg: #faf3e6;
    --book-scrollbar: #c8b89a;
    --book-confirm-bg: rgba(30, 20, 10, 0.35);
}

/* ============ DARK THEME (Windows Modern Style) ============ */
[data-book-theme="dark"] {
    --book-bg: #0a0a0a; /* Deeper black */
    --book-surface: #1e1e1e; /* Dark grey surface */
    --book-surface-2: #252525;
    --book-surface-3: #2d2d2d;
    --book-border: rgba(255, 255, 255, 0.1);
    --book-border-hover: rgba(255, 255, 255, 0.18);
    --book-text: #e0e0e0; /* Off-white for better readability */
    --book-text-muted: #b0b0b0;
    --book-text-dim: #808080;
    --book-accent: #60cdff; 
    --book-accent-hover: #4cc2ff;
    --book-accent-glow: rgba(96, 205, 255, 0.15);
    --book-gold: #ffcf54;
    --book-green: #6ccb5f;
    --book-red: #ff6a6a;
    --book-orange: #ffb900;
    --book-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    --book-topbar-bg: rgba(20, 20, 20, 0.9);
    --book-toolbar-bg: rgba(28, 28, 28, 0.85);
    --book-glow1: rgba(96, 205, 255, 0.04);
    --book-glow2: rgba(255, 207, 84, 0.02);
    --book-editor-bg: #0a0a0a;
    --book-scrollbar: #3a3a3a;
    --book-confirm-bg: rgba(0, 0, 0, 0.8);
}

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

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--book-bg);
    color: var(--book-text);
    height: 100vh;
    overflow: hidden; /* Prevent whole-page scroll in regular mode */
    transition: background 0.35s, color 0.35s;
}

body.zen-mode {
    overflow-y: auto !important;
    height: auto !important;
}

body.zen-mode .book-topbar,
body.zen-mode .book-sidebar,
body.zen-mode .book-sidebar-resizer,
body.zen-mode .book-status-bar {
    display: none !important;
}

body.zen-mode .book-layout {
    height: auto !important;
    display: block !important;
    overflow: visible !important;
}

body.is-resizing-sidebar {
    cursor: col-resize;
    user-select: none;
}

/* === BACKGROUND GLOW === */
body::before {
    content: '';
    position: fixed;
    top: -200px;
    left: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, var(--book-glow1) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -300px;
    right: -200px;
    width: 700px;
    height: 700px;
    background: radial-gradient(circle, var(--book-glow2) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* === THEME SWITCHER === */
.book-theme-switcher {
    display: flex;
    gap: 4px;
    background: var(--book-surface-2);
    padding: 3px;
    border-radius: 8px;
    border: 1px solid var(--book-border);
}

.book-theme-btn {
    padding: 5px 10px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--book-text-muted);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 500;
    transition: var(--book-transition);
}

.book-theme-btn:hover {
    color: var(--book-text);
    background: var(--book-surface-3);
}

.book-theme-btn.active {
    background: var(--book-accent);
    color: #fff;
    box-shadow: 0 2px 6px var(--book-accent-glow);
}

/* === TOP BAR === */
.book-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--book-topbar-bg);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--book-border);
    transition: background 0.35s;
}

.book-topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.book-topbar-logo {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--book-accent), var(--book-gold));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
    transition: max-width 0.3s, font-size 0.3s, display 0.3s;
}

@media (max-width: 1200px) {
    .book-topbar-logo {
        font-size: 1.05rem !important;
        max-width: 160px !important;
    }
}

@media (max-width: 950px) {
    .book-topbar-logo {
        display: none !important;
    }
}

.book-topbar-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--book-accent);
    background: var(--book-accent-glow);
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
}

.book-topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* === COMPACT DROPDOWNS (Mode & Theme) === */
.book-dropdown-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.book-dropdown-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--book-text-dim);
    font-weight: 700;
    margin-left: 12px;
}

.book-dropdown {
    position: relative;
    display: inline-block;
}

.book-dropdown::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 8px;
}

.book-dropdown-btn {
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    color: var(--book-text);
    padding: 6px 14px;
    font-size: 0.85rem;
    border-radius: 18px;
    cursor: pointer;
    transition: var(--book-transition);
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 110px;
    justify-content: space-between;
    font-weight: 500;
}

.book-dropdown-btn:hover {
    background: var(--book-surface-3);
    border-color: var(--book-accent);
}

.book-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--book-surface);
    min-width: 150px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 1000;
    border-radius: 12px;
    overflow: visible; /* Allow bridge visibility */
    border: 1px solid var(--book-border);
    backdrop-filter: blur(10px);
    animation: dropdown-fade-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Мостик, чтобы меню не закрывалось при переходе курсора с кнопки на список */
.book-dropdown-content::before {
    content: '';
    position: absolute;
    top: -15px; /* Taller bridge to cover gap and animation displacement */
    left: 0;
    width: 100%;
    height: 15px;
    background: transparent;
}

.book-dropdown:hover .book-dropdown-content {
    display: block;
}

.book-dropdown:focus-within .book-dropdown-content {
    display: block;
}

.book-dropdown-content button {
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--book-text);
    text-align: left;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: inherit;
}

.book-dropdown-content button:hover {
    background: var(--book-accent-glow);
    color: var(--book-accent);
}

@keyframes dropdown-fade-in {
    from { opacity: 0; transform: translateY(5px) scale(0.98); } /* Reduced displacement */
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.book-btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--book-radius-sm);
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    color: var(--book-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: var(--book-transition);
}

.book-btn-back:hover {
    background: var(--book-surface-3);
    color: var(--book-text);
    border-color: var(--book-border-hover);
}

/* === LAYOUT === */
.book-layout {
    display: flex;
    height: calc(100vh - 56px); /* Fixed height for regular mode */
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* === SIDEBAR === */
.book-sidebar {
    width: var(--sidebar-width, 260px);
    min-width: 150px;
    max-width: 500px;
    flex-shrink: 0;
    background: var(--book-surface);
    border-right: 1px solid var(--book-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow: hidden;
    transition: background 0.35s;
}

.book-sidebar-resizer {
    width: 6px;
    background: transparent;
    cursor: col-resize;
    transition: background 0.2s;
    z-index: 100;
    margin-left: -3px;
    margin-right: -3px;
}

.book-sidebar-resizer:hover,
.book-sidebar-resizer.active {
    background: var(--book-accent-glow);
    box-shadow: 0 0 10px var(--book-accent);
}

.book-sidebar-header {
    padding: 12px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--book-border);
    flex-shrink: 0;
}

.book-sidebar-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--book-text-dim);
    font-weight: 600;
}

.book-btn-add {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--book-accent);
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--book-transition);
    box-shadow: 0 2px 8px var(--book-accent-glow);
}

.book-btn-add:hover {
    background: var(--book-accent-hover);
    transform: scale(1.08);
}

.book-pages-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.book-pages-list::-webkit-scrollbar {
    width: 4px;
}

.book-pages-list::-webkit-scrollbar-track {
    background: transparent;
}

.book-pages-list::-webkit-scrollbar-thumb {
    background: var(--book-scrollbar);
    border-radius: 2px;
}

.book-page-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--book-radius-sm);
    cursor: pointer;
    transition: var(--book-transition);
    border: 1px solid transparent;
    margin-bottom: 2px;
    position: relative;
}

.book-page-item:hover {
    background: var(--book-surface-2);
    border-color: var(--book-border);
}

.book-page-item.active {
    background: var(--book-accent-glow);
    border-color: rgba(108, 92, 231, 0.2);
}

.book-page-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--book-accent);
    border-radius: 0 3px 3px 0;
}

.book-page-item.page-status-unread {
    background: rgba(255, 255, 255, 0.08);
}

.book-page-item.page-status-inProgress {
    background: rgba(255, 239, 163, 0.62);
}

.book-page-item.page-status-done {
    background: rgba(192, 242, 198, 0.62);
}

.book-page-num {
    font-size: 0.7rem;
    color: var(--book-text-dim);
    min-width: 20px;
    text-align: center;
    font-weight: 600;
    opacity: 0.6;
}

.book-page-title {
    font-size: 0.88rem;
    color: var(--book-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.book-page-title-clip {
    min-width: 0;
    text-overflow: clip;
}

.book-page-item.active .book-page-title {
    color: var(--book-text);
    font-weight: 400;
}

.book-sidebar-title-tooltip {
    position: fixed;
    z-index: 12000;
    display: none;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--book-border);
    background: rgba(40, 36, 31, 0.96);
    color: #f4efe3;
    font-size: 0.8rem;
    line-height: 1.35;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    white-space: normal;
    overflow-wrap: anywhere;
}

.book-sidebar-title-tooltip.show {
    display: block;
}

.book-page-context-menu {
    position: fixed;
    z-index: 12500;
    display: none;
    min-width: 220px;
    padding: 6px;
    border: 1px solid var(--book-border);
    border-radius: 10px;
    background: var(--book-surface-2);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.book-page-context-menu.show {
    display: block;
}

.book-page-context-menu button {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--book-text);
    text-align: left;
    font-size: 0.86rem;
    padding: 8px 10px;
    border-radius: 7px;
    cursor: pointer;
}

.book-page-context-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.book-read-status-btn {
    width: 27px;
    height: 27px;
    min-width: 27px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.08);
    color: var(--book-text);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--book-transition);
    padding: 0;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.book-read-status-btn.status-unread {
    border-color: rgba(255, 255, 255, 0.48);
    color: rgba(255, 255, 255, 0.92);
}

.book-read-status-btn.status-inProgress {
    border-color: #d2ab1f;
    background: rgba(255, 236, 153, 0.95);
    color: #5f4300;
}

.book-read-status-btn.status-done {
    border-color: #2e9b52;
    background: rgba(185, 244, 198, 0.95);
    color: #0f5a2a;
}

.book-page-item.active .book-read-status-btn:not(.status-done) {
    border-color: #d2ab1f;
    background: rgba(255, 236, 153, 0.95);
    color: #5f4300;
}

.book-read-status-btn:hover {
    transform: scale(1.06);
}

.book-page-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: var(--book-transition);
}

.book-page-item:hover .book-page-actions {
    opacity: 1;
}

.book-page-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--book-text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--book-transition);
}

.book-page-action-btn:hover {
    background: var(--book-surface-3);
    color: var(--book-text);
}

.book-page-action-btn.delete:hover {
    color: var(--book-red);
    background: rgba(239, 68, 68, 0.1);
}

.book-sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--book-border);
    font-size: 0.75rem;
    color: var(--book-text-dim);
    text-align: center;
}

/* === EDITOR AREA === */
.book-editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.book-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--book-text-dim);
}

.book-empty-icon {
    font-size: 4rem;
    opacity: 0.3;
}

.book-empty-text {
    font-size: 1.1rem;
}

.book-empty-hint {
    font-size: 0.85rem;
    opacity: 0.5;
}

.book-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--book-border);
    background: var(--book-surface);
    transition: background 0.35s;
}

.book-title-input {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    font-weight: 600;
    background: transparent;
    border: none;
    outline: none;
    color: var(--book-text);
    flex: 1;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
    transition: var(--book-transition);
}

.book-title-input:focus {
    border-bottom-color: var(--book-accent);
}

.book-title-input::placeholder {
    color: var(--book-text-dim);
}

.book-editor-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.78rem;
    color: var(--book-text-dim);
}

.book-save-status {
    display: flex;
    align-items: center;
    gap: 5px;
}

.book-save-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--book-green);
}

.book-save-dot.unsaved {
    background: var(--book-orange);
}

.book-toolbar {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 10px 24px;
    border-bottom: 1px solid var(--book-border);
    background: var(--book-toolbar-bg);
    transition: background 0.35s;
}

.book-toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--book-border);
    margin: 0 6px;
}

.book-toolbar-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--book-text-muted);
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--book-transition);
    position: relative;
}

.book-toolbar-btn:hover {
    background: var(--book-surface-3);
    color: var(--book-text);
}

.book-toolbar-btn.active {
    background: var(--book-accent-glow);
    color: var(--book-accent);
}

.book-toolbar-select {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    color: var(--book-text);
    cursor: pointer;
    outline: none;
}

.book-toolbar-select:focus {
    border-color: var(--book-accent);
}

.book-content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    background: var(--book-editor-bg);
    transition: background 0.35s;
}

.book-content-wrapper::-webkit-scrollbar {
    width: 6px;
}

.book-content-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

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

.book-editor-content {
    width: 100%;
    max-width: 800px; /* Slightly wider */
    min-height: 800px;
    height: auto !important; /* Ensure it grows with content */
    display: flow-root; /* Better containment of children */
    outline: none;
    line-height: 1.8;
    font-size: 1.05rem;
    color: var(--book-text);
    caret-color: var(--book-accent);
    padding: 60px 80px 200px;
    background: var(--book-surface);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--book-border);
    border-radius: 8px;
    margin: 40px auto;
    transition: background 0.3s, color 0.3s, font-size 0.2s;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* === MODAL COMPONENTS === */
.book-chat-msg {
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    max-width: 85%;
    align-self: flex-start;
}

.book-chat-msg.mine {
    align-self: flex-end;
    background: var(--book-accent-glow);
    border-color: var(--book-accent-glow);
}

.book-chat-msg-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--book-text-dim);
    margin-bottom: 4px;
    gap: 10px;
}

.book-chat-msg-text {
    font-size: 0.85rem;
    line-height: 1.4;
}

.book-chat-context {
    margin-bottom: 6px;
    padding: 6px 8px;
    border-radius: 6px;
    background: var(--book-accent-glow);
    border: 1px solid var(--book-border);
    font-size: 0.72rem;
    color: var(--book-text-dim);
}

.book-chat-context-link {
    margin-top: 6px;
    width: 100%;
    border: 1px solid var(--book-border);
    background: var(--book-surface);
    color: var(--book-text);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 0.72rem;
    text-align: left;
}

.book-note-card {
    padding: 12px;
    border-radius: 8px;
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.book-note-textarea {
    width: 100%;
    min-height: 80px;
    border: none;
    background: transparent;
    color: var(--book-text);
    font-family: inherit;
    font-size: 0.88rem;
    resize: vertical;
    outline: none;
}

.book-editor-content:empty::before {
    content: 'Начните писать здесь...';
    color: var(--book-text-dim);
    font-style: italic;
}

.book-editor-content h1 {
    font-family: 'Playfair Display', serif;
    font-size: 2rem;
    margin: 24px 0 12px;
}

.book-editor-content h2 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    margin: 20px 0 10px;
}

.book-editor-content h3 {
    font-size: 1.2rem;
    margin: 16px 0 8px;
    font-weight: 600;
}

.book-editor-content p {
    margin-bottom: 12px;
}

.book-editor-content blockquote {
    border-left: 3px solid var(--book-accent);
    padding: 8px 16px;
    margin: 12px 0;
    background: var(--book-accent-glow);
    border-radius: 0 var(--book-radius-sm) var(--book-radius-sm) 0;
    font-style: italic;
    color: var(--book-text-muted);
}

.book-editor-content ul,
.book-editor-content ol {
    padding-left: 24px;
    margin-bottom: 12px;
}

.book-editor-content li {
    margin-bottom: 4px;
}

.book-editor-content a {
    color: var(--book-accent);
    text-decoration: underline;
}

.book-editor-content hr {
    border: none;
    height: 1px;
    background: var(--book-border);
    margin: 24px 0;
}

/* === AI PANEL (stub) === */
.book-ai-panel {
    position: fixed;
    right: -360px;
    top: 56px;
    width: 350px;
    height: calc(100vh - 56px);
    background: var(--book-surface);
    border-left: 1px solid var(--book-border);
    z-index: 50;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1), background 0.35s;
    display: flex;
    flex-direction: column;
}

.book-ai-panel.open {
    right: 0;
}

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

.book-ai-panel-title {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.book-ai-panel-body {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 16px;
    color: var(--book-text-dim);
}

.book-ai-stub-icon {
    font-size: 3rem;
    opacity: 0.4;
}

.book-ai-stub-text {
    font-size: 0.9rem;
    line-height: 1.6;
}

.book-ai-close-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid var(--book-border);
    color: var(--book-text-muted);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--book-transition);
}

.book-ai-close-btn:hover {
    background: var(--book-surface-3);
    color: var(--book-text);
}

/* === SAVE BUTTON === */
.book-btn-save {
    padding: 8px 20px;
    border-radius: var(--book-radius-sm);
    background: var(--book-accent);
    border: none;
    color: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--book-transition);
    box-shadow: 0 2px 12px var(--book-accent-glow);
}

.book-btn-save:hover {
    background: var(--book-accent-hover);
    transform: translateY(-1px);
}

.book-btn-save:active {
    transform: translateY(0);
}

.book-btn-save:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* === STATUS BAR === */
.d-page-nav {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    background: var(--book-surface);
    border-top: 1px solid var(--book-border);
    box-shadow: 0 -6px 16px rgba(0, 0, 0, 0.08);
    opacity: 0;
    transform: translateY(10px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.d-page-nav.show-at-end {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.d-page-nav-btn {
    flex: 1;
    border: 1px solid var(--book-border);
    background: var(--book-bg);
    color: var(--book-text);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    cursor: pointer;
}

.d-page-nav-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.d-page-nav-title {
    width: 100%;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--book-text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.d-page-nav-label {
    font-size: 0.84rem;
}

.book-statusbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-top: 1px solid var(--book-border);
    background: var(--book-surface);
    font-size: 0.72rem;
    color: var(--book-text-dim);
    transition: background 0.35s;
}

.book-statusbar-left,
.book-statusbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* === TOAST === */
.book-toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 24px;
    border-radius: var(--book-radius);
    background: var(--book-surface-2);
    color: var(--book-text);
    border: 1px solid var(--book-border);
    box-shadow: var(--book-shadow);
    font-size: 0.88rem;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

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

.book-toast.success {
    border-color: var(--book-green);
}

.book-toast.error {
    border-color: var(--book-red);
}

/* === CONFIRM DIALOG === */
.book-confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--book-confirm-bg);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.2s;
}

.book-confirm-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.book-confirm-box {
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    border-radius: var(--book-radius);
    padding: 24px;
    max-width: 380px;
    width: 90%;
    box-shadow: var(--book-shadow);
}

.book-confirm-box h4 {
    margin-bottom: 12px;
    font-size: 1.05rem;
}

.book-confirm-box p {
    color: var(--book-text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.book-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.book-confirm-actions button {
    padding: 8px 18px;
    border-radius: var(--book-radius-sm);
    border: 1px solid var(--book-border);
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--book-transition);
}

.book-btn-cancel {
    background: var(--book-surface-3);
    color: var(--book-text-muted);
}

.book-btn-cancel:hover {
    background: var(--book-surface);
    color: var(--book-text);
}

.book-btn-danger {
    background: var(--book-red);
    color: white;
    border-color: transparent;
}

.book-btn-danger:hover {
    opacity: 0.85;
}

/* === LOADING SPINNER === */
.book-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.book-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--book-border);
    border-top-color: var(--book-accent);
    border-radius: 50%;
    animation: bookSpin 0.7s linear infinite;
}

.m-info-handle {
    height: 24px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}
.m-info-handle::after {
    content: '';
    width: 30px;
    height: 4px;
    background: var(--book-accent);
    opacity: 0.3;
    border-radius: 2px;
}

@keyframes bookSpin {
    to {
        transform: rotate(360deg);
    }
}

/* === ANIMATIONS === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

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

.book-page-item {
    animation: fadeInUp 0.3s ease backwards;
}

.book-page-item:nth-child(1) {
    animation-delay: 0.02s;
}

.book-page-item:nth-child(2) {
    animation-delay: 0.04s;
}

.book-page-item:nth-child(3) {
    animation-delay: 0.06s;
}

.book-page-item:nth-child(4) {
    animation-delay: 0.08s;
}

.book-page-item:nth-child(5) {
    animation-delay: 0.1s;
}

/* === ROLE BASED UI === */
.admin-only,
.reader-only {
    display: none !important;
}

body.is-admin .admin-only {
    display: flex !important;
}

body.is-admin button.admin-only,
body.is-admin div.admin-only {
    display: flex !important;
}

body.is-admin .admin-only.book-btn-save {
    display: block !important;
}

body.is-reader .reader-only {
    display: flex !important;
}

/* === TRANSLATION UI === */
#book-lang-badge-wrap,
#admin-lang-badge-wrap {
    transition: var(--book-transition);
    animation: fadeInUp 0.3s ease;
}

#ai-translation-modes {
    margin-top: 10px;
    animation: fadeInUp 0.2s ease;
}

.is-reader .book-editor-content {
    cursor: default;
    outline: none !important;
}

.is-reader .book-title-input {
    cursor: default;
    pointer-events: none;
}

@media (max-width: 768px) {
    .book-sidebar {
        width: 60px;
        min-width: 60px;
    }

    .book-sidebar-header {
        padding: 12px 8px;
    }

    .book-sidebar-title {
        display: none;
    }

    .book-page-title {
        display: block;
    }

    .book-page-num {
        min-width: unset;
    }

    .book-page-actions {
        display: none;
    }

    .book-sidebar-footer {
        display: none;
    }

    .book-toolbar {
        padding: 8px 12px;
    }

    .book-content-wrapper {
        padding: 16px;
    }

    .book-editor-header {
        padding: 12px 16px;
    }

    .book-title-input {
        font-size: 1.1rem;
    }

    .book-statusbar {
        padding: 6px 12px;
    }

    .book-topbar {
        padding: 10px 12px;
    }

    .book-topbar-badge {
        display: none;
    }

    .book-theme-switcher {
        display: none;
    }
}

@media (max-width: 480px) {
    .book-editor-meta {
        display: none;
    }
}

/* === DRAG & DROP === */
.book-page-item[draggable="true"] {
    cursor: grab;
}

.book-page-item[draggable="true"]:active {
    cursor: grabbing;
}

.book-page-item.drag-over {
    border-top: 2px solid var(--book-accent);
}

/* === SIDEBAR RESIZER === */
.book-sidebar-resizer {
    width: 6px;
    background: transparent;
    cursor: col-resize;
    transition: background 0.2s;
    z-index: 100;
    margin-left: -3px;
    margin-right: -3px;
}

.book-sidebar-resizer:hover,
.book-sidebar-resizer.active {
    background: var(--book-accent-glow);
    box-shadow: 0 0 10px var(--book-accent);
}

/* === PUBLISHING STATUS === */
.publish-status-btn {
    background: transparent;
    border: 1px solid var(--book-border);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--book-text-dim);
    transition: all 0.2s;
}

.publish-status-btn.published {
    border-color: var(--book-green);
    color: var(--book-green);
    background: var(--book-green-glow);
}

.publish-status-btn.draft {
    border-color: var(--book-red);
    color: var(--book-red);
    background: var(--book-red-glow);
}

/* === PREVIEW MODE (REFINED) === */
body.preview-active .book-toolbar,
body.preview-active .book-statusbar,
body.preview-active .book-editor-meta,
body.preview-active .book-btn-save,
body.preview-active .admin-only {
    display: none !important;
}

body.preview-active .book-editor-content {
    cursor: default;
    border: none !important;
    box-shadow: none !important;
}

/* === FOOTNOTE TOOLTIP === */
.footnote-tooltip {
    position: absolute;
    background: var(--book-surface);
    border: 1px solid var(--book-border);
    border-radius: 8px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    font-family: var(--book-font-ui);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.footnote-tooltip.show {
    opacity: 1;
    pointer-events: auto;
}

.footnote-tooltip button {
    background: transparent;
    border: none;
    color: var(--book-text);
    padding: 6px 12px;
    text-align: left;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.footnote-tooltip button:hover {
    background: var(--book-surface-2);
}

/* === IMAGES IN CONTENT === */
.book-editor-content img {
    max-width: 100% !important;
    height: auto !important;
    display: block;
    margin: 24px auto;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    box-sizing: border-box !important;
}

.editor-image-wrap {
    display: block;
    position: relative;
    max-width: 100% !important;
    margin: 15px 0;
    line-height: 0;
    transition: all 0.3s ease;
    box-sizing: border-box !important;
}

.editor-image-wrap.float-left {
    float: left;
    margin-right: 20px;
    max-width: 40% !important;
}

.editor-image-wrap.float-right {
    float: right;
    margin-left: 20px;
    max-width: 40% !important;
}

.editor-image-wrap.float-none {
    float: none;
    margin: 20px auto;
}

.editor-image-wrap img {
    display: block;
    width: 100% !important;
    height: auto !important;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.editor-image-wrap img.lazy-blur {
    filter: blur(10px);
    transform: scale(0.98);
}

/* Компактный маркер картинки (Смайлик) */
.inline-image-marker {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--book-surface-3);
    border: 1px solid var(--book-border);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
    color: var(--book-accent);
    margin: 0 4px;
    transition: background 0.2s;
}

.inline-image-marker:hover {
    background: var(--book-accent-glow);
}

.image-resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 15px;
    height: 15px;
    background: var(--book-accent);
    cursor: se-resize;
    display: none;
    z-index: 10;
    border-radius: 2px;
}

.editor-image-wrap:hover .image-resize-handle {
    display: block;
}

/* === ARCHIVE ENHANCEMENTS === */
.archive-item-actions {
    display: flex;
    gap: 8px;
}

.archive-btn {
    background: var(--book-surface-3);
    border: none;
    color: var(--book-text);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
    transition: background 0.2s;
}

.archive-btn:hover {
    background: var(--book-surface-2);
}

.archive-btn.delete-forever {
    color: var(--book-red);
}

.archive-btn.delete-forever:hover {
    background: var(--book-red-glow);
}


/* === INDEPENDENT COVER EDITOR === */
.cover-workspace {
    width: 100%;
    height: 600px;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 20px;
    border-radius: 8px;
}

.cover-canvas {
    width: 400px;
    height: 600px;
    background: #fff;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.cover-text-box {
    position: absolute;
    min-width: 50px;
    padding: 5px;
    cursor: move;
    user-select: none;
    box-sizing: border-box;
    border: 1px dashed transparent;
}

.cover-text-box:hover {
    border: 1px dashed rgba(255, 255, 255, 0.5);
}

.cover-text-box.selected {
    border: 1px dashed #fff;
    background: rgba(255, 255, 255, 0.1);
}

.cover-text-content {
    outline: none;
    word-break: break-word;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.cover-text-box.dragging .cover-text-content {
    pointer-events: none;
}

.cover-resize-handle {
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 1px solid #000;
    cursor: se-resize;
    display: none;
}

.cover-text-box.selected .cover-resize-handle {
    display: block;
}


body.preview-active .book-layout {
    min-height: 100vh;
}

body.preview-active .book-editor-content {
    cursor: default;
}

/* === COVER MODE === */
.is-cover-mode .book-editor-content {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    border: none;
    /* Убираем отступы, чтобы обложка заполняла всю ширину странцы-книги (720px) */
    padding: 0;
}

.is-cover-mode .book-editor-content::before {
    display: none;
}


/* === FOOTNOTES === */
.footnote-ref {
    color: var(--book-accent);
    cursor: pointer;
    font-weight: 700;
    padding: 0 2px;
    text-decoration: none;
    transition: var(--book-transition);
    font-size: 0.85em;
    vertical-align: super;
}

.footnote-ref:hover {
    background: var(--book-accent-glow);
    border-radius: 3px;
}

/* === SUBCHAPTERS (CHAPTER NOTES) === */
.book-subchapters-list {
    margin-left: 25px;
    border-left: 1px solid var(--book-border);
    padding-left: 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.book-subchapters-list.collapsed {
    max-height: 0;
    display: none;
}

.book-subchapters-list.expanded {
    max-height: 1000px;
    margin-bottom: 5px;
}

.book-subchapters-toggle {
    font-size: 0.65rem;
    color: var(--book-text-dim);
    padding: 2px 8px;
    margin-left: 25px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    opacity: 0.7;
    transition: all 0.2s;
    user-select: none;
}

.book-subchapters-toggle:hover {
    opacity: 1;
    text-decoration: underline;
}

.book-subchapters-toggle .toggle-icon {
    font-size: 0.6rem;
    margin-left: 5px;
}

.book-subchapter-item {
    font-size: 0.75rem;
    color: var(--book-text-muted);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--book-transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.book-subchapter-item:hover {
    background: var(--book-surface-2);
    color: var(--book-text);
}

.book-subchapter-item.active {
    background: var(--book-accent-glow);
    color: var(--book-accent);
    font-weight: 500;
}

/* === GLOBAL NOTES (SPLIT VIEW) === */
.notes-layout-container {
    display: flex;
    height: 600px;
    width: 100%;
    overflow: hidden;
    background: var(--book-surface);
    border-radius: var(--book-radius);
}

.notes-tree-panel {
    width: 250px;
    min-width: 150px;
    max-width: 500px;
    resize: horizontal;
    border-right: 1px solid var(--book-border);
    overflow-y: auto;
    padding: 16px;
    background: var(--book-surface-2);
}

.notes-editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--book-surface);
    min-width: 200px;
}

.notes-editor-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--book-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notes-editor-content {
    flex: 1;
    padding: 20px;
    border: none;
    resize: none;
    outline: none;
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.6;
    color: var(--book-text);
    background: transparent;
}

.note-tree-item {
    margin: 4px 0;
}

.note-tree-node {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--book-text);
    transition: var(--book-transition);
}

.note-tree-node:hover {
    background: var(--book-surface-3);
}

.note-tree-node.active {
    background: var(--book-accent-glow);
    color: var(--book-accent);
    font-weight: 500;
}

.note-tree-children {
    padding-left: 15px;
    border-left: 1px dashed var(--book-border);
    margin-left: 10px;
}

.note-status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--book-green);
    margin-right: 6px;
    transition: background-color 0.3s;
}

/* === MODULAR COVER VIEW === */
.is-cover-view .book-editor-content {
    width: 400px !important;
    height: 600px !important;
    min-height: 600px !important;
    margin: 40px auto !important;
    padding: 0 !important;
    overflow: hidden !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3) !important;
    border: none !important;
    position: relative !important;
    background-size: cover !important;
    background-position: center !important;
}

.is-cover-view .book-toolbar,
.is-cover-view .book-editor-header input,
.is-cover-view .book-editor-meta,
.is-cover-view .book-save-status {
    display: none !important;
}

.is-cover-view .book-editor-header {
    justify-content: center;
}

.is-cover-view .book-title-input {
    text-align: center;
    border: none;
}

/* ============================================================
   COMICS MODE STYLES
   ============================================================ */

/* === MODE SWITCHER (Книги / Комиксы) === */
.book-mode-switcher {
    display: flex;
    gap: 3px;
    background: var(--book-surface-2);
    padding: 3px;
    border-radius: 9px;
    border: 1px solid var(--book-border);
}

.book-mode-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--book-text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    transition: var(--book-transition);
    white-space: nowrap;
}

.book-mode-btn:hover {
    color: var(--book-text);
    background: var(--book-surface-3);
}

.book-mode-btn.active {
    background: var(--book-accent);
    color: #fff;
    box-shadow: 0 2px 8px var(--book-accent-glow);
}

/* === COMIC VIEWER WRAPPER === */
#comic-viewer {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    background: var(--book-editor-bg);
}

body.is-comic-mode #comic-viewer {
    display: flex;
}

body.is-comic-mode #book-editor-wrap,
body.is-comic-mode #book-empty-state {
    display: none !important;
}

/* === COMIC VIEWER HEADER === */
.comic-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--book-border);
    background: var(--book-surface);
    flex-shrink: 0;
}

.comic-chapter-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--book-text);
}

.comic-chapter-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--book-text-dim);
}

/* === COMIC VIEWER MAIN AREA === */
.comic-viewer-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

/* --- Thumbnails Rail (left) --- */
.comic-thumbs-rail {
    width: 88px;
    flex-shrink: 0;
    background: var(--book-surface-2);
    border-right: 1px solid var(--book-border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 8px;
}

.comic-thumbs-rail::-webkit-scrollbar {
    width: 3px;
}

.comic-thumbs-rail::-webkit-scrollbar-thumb {
    background: var(--book-scrollbar);
    border-radius: 2px;
}

.comic-thumb {
    position: relative;
    width: 72px;
    height: 90px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--book-transition);
    background: var(--book-surface-3);
    flex-shrink: 0;
}

.comic-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.comic-thumb-num {
    position: absolute;
    bottom: 3px;
    right: 5px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    background: rgba(0, 0, 0, 0.4);
    padding: 1px 4px;
    border-radius: 3px;
}

.comic-thumb:hover {
    border-color: var(--book-border-hover);
    transform: scale(1.04);
}

.comic-thumb.active {
    border-color: var(--book-accent);
    box-shadow: 0 0 0 1px var(--book-accent-glow);
}

.comic-thumb.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--book-text-dim);
}

/* --- Main Image Area (center) --- */
.comic-main-image-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--book-bg);
    position: relative;
    padding: 20px;
    height: 100%;
    cursor: zoom-in;
}

.comic-main-image-wrap.magnifier-active {
    cursor: none;
    /* Скрываем курсор, когда лупа активна */
}

.comic-main-image-wrap img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    transition: opacity 0.3s;
    user-select: none;
    pointer-events: auto;
}

/* Лупа (Magnifier) */
.comic-magnifier-lens {
    position: absolute;
    border: 3px solid var(--book-accent);
    border-radius: 50%;
    cursor: none;
    width: 220px;
    height: 220px;
    display: none;
    pointer-events: none;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.4), inset 0 0 10px rgba(255, 255, 255, 0.2);
    background-repeat: no-repeat;
    z-index: 1000;
    background-color: var(--book-bg);
}

.comic-main-image-wrap.magnifier-active {
    cursor: crosshair;
}

.comic-main-image-wrap img.loading {
    opacity: 0;
    transform: scale(0.98);
}

.comic-no-image-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--book-text-dim);
    font-size: 0.9rem;
}

.comic-no-image-placeholder .big-icon {
    font-size: 3rem;
    opacity: 0.3;
}

/* --- Text Panel (right) --- */
.comic-text-panel {
    width: 300px;
    flex-shrink: 0;
    border-left: 1px solid var(--book-border);
    background: var(--book-surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.comic-text-panel-header {
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--book-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.comic-lang-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--book-accent);
    background: var(--book-accent-glow);
    padding: 3px 8px;
    border-radius: 5px;
}

.comic-lang-switcher select {
    background: transparent;
    border: none;
    color: inherit;
    font-size: inherit;
    outline: none;
    cursor: pointer;
}

.comic-page-indicator {
    font-size: 0.7rem;
    color: var(--book-text-dim);
    font-weight: 500;
}

.comic-text-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.comic-text-body::-webkit-scrollbar {
    width: 4px;
}

.comic-text-body::-webkit-scrollbar-thumb {
    background: var(--book-scrollbar);
    border-radius: 2px;
}

.comic-text-content {
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--book-text);
    min-height: 120px;
    outline: none;
    white-space: pre-wrap;
    word-break: break-word;
}

.comic-text-content:empty::before {
    content: 'Описание страницы...';
    color: var(--book-text-dim);
    font-style: italic;
}

/* Notes section in text panel */
.comic-notes-section {
    border-top: 1px solid var(--book-border);
    flex-shrink: 0;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px 16px;
}

.comic-notes-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--book-text-dim);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.comic-note-item {
    padding: 6px 8px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--book-text-muted);
    transition: var(--book-transition);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}

.comic-note-item:hover {
    background: var(--book-surface-2);
    color: var(--book-text);
}

/* === COMIC NAVIGATION BAR === */
.comic-nav-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px 20px;
    border-top: 1px solid var(--book-border);
    background: var(--book-surface);
    flex-shrink: 0;
}

.comic-nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    border-radius: var(--book-radius-sm);
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    color: var(--book-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--book-transition);
    font-family: 'Inter', sans-serif;
}

.comic-nav-btn:hover:not(:disabled) {
    background: var(--book-surface-3);
    color: var(--book-text);
    border-color: var(--book-border-hover);
}

.comic-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.comic-nav-counter {
    font-size: 0.85rem;
    color: var(--book-text-dim);
    min-width: 80px;
    text-align: center;
    font-weight: 500;
}

/* Кнопки действий */
.comic-action-btns {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comic-action-btn {
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    color: var(--book-text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.comic-action-btn:hover {
    background: var(--book-surface-3);
    color: var(--book-text);
    border-color: var(--book-border-hover);
}

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

.comic-action-btn i {
    font-style: normal;
}

/* === COMIC ADMIN: Image Upload Zone === */
.comic-dropzone {
    border: 2px dashed var(--book-border);
    border-radius: var(--book-radius);
    padding: 32px 24px;
    text-align: center;
    color: var(--book-text-dim);
    cursor: pointer;
    transition: var(--book-transition);
    background: var(--book-surface-2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.comic-dropzone:hover,
.comic-dropzone.drag-over {
    border-color: var(--book-accent);
    background: var(--book-accent-glow);
    color: var(--book-accent);
}

.comic-dropzone .dz-icon {
    font-size: 2.5rem;
    opacity: 0.5;
}

.comic-dropzone .dz-hint {
    font-size: 0.78rem;
    line-height: 1.5;
}

/* Image list in admin modal */
.comic-images-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    padding: 2px;
}

.comic-images-list::-webkit-scrollbar {
    width: 4px;
}

.comic-images-list::-webkit-scrollbar-thumb {
    background: var(--book-scrollbar);
    border-radius: 2px;
}

.comic-image-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--book-border);
    background: var(--book-surface-2);
    transition: var(--book-transition);
}

.comic-image-row:hover {
    border-color: var(--book-border-hover);
}

.comic-image-row-thumb {
    width: 48px;
    height: 60px;
    border-radius: 4px;
    object-fit: cover;
    background: var(--book-surface-3);
    flex-shrink: 0;
    border: 1px solid var(--book-border);
}

.comic-image-row-info {
    flex: 1;
    overflow: hidden;
}

.comic-image-row-name {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--book-text);
    word-break: break-all;
    white-space: normal !important;
}

.comic-image-row-url {
    font-size: 0.65rem;
    color: var(--book-text-dim);
    word-break: break-all;
    white-space: normal !important;
    margin-top: 2px;
}

.comic-image-row-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Pending save indicator in admin panel */
.comic-text-unsaved-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--book-orange);
    display: inline-block;
    margin-left: 4px;
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* === COMIC EMPTY STATE === */
.comic-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--book-text-dim);
}

.comic-empty-icon {
    font-size: 4rem;
    opacity: 0.3;
}

.comic-empty-text {
    font-size: 1.1rem;
}

.comic-empty-hint {
    font-size: 0.85rem;
    opacity: 0.6;
}

/* === RESPONSIVE: Mobile Comic Viewer === */
@media (max-width: 768px) {

    /* Mode switcher: hide text, show icons only */
    .book-mode-btn {
        padding: 5px 8px;
        font-size: 0.75rem;
    }

    /* Comic viewer: stack vertically */
    .comic-viewer-body {
        flex-direction: column;
    }

    .comic-thumbs-rail {
        width: 100%;
        height: 70px;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--book-border);
        overflow-x: auto;
        overflow-y: hidden;
        padding: 6px 10px;
        gap: 6px;
    }

    .comic-thumb {
        width: 48px;
        height: 58px;
        flex-shrink: 0;
    }

    .comic-text-panel {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--book-border);
        max-height: 240px;
    }

    .comic-main-image-wrap {
        flex: unset;
        height: 300px;
        padding: 10px;
    }

    .comic-nav-bar {
        gap: 8px;
        padding: 8px 12px;
    }

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

@media (max-width: 480px) {
    .comic-text-panel {
        max-height: 180px;
    }

    .comic-viewer-header {
        padding: 8px 12px;
    }

    .comic-chapter-title {
        font-size: 0.92rem;
    }
}

/* ============================================================
   STRICT COMICS LAYOUT (FORCE FIT TO SCREEN)
   ============================================================ */

#comic-viewer {
    display: none;
    flex-direction: column;
    height: calc(100vh - 65px);
    /* Учитываем топбар */
    max-height: calc(100vh - 65px);
    overflow: hidden;
    background: var(--book-bg);
}

body.is-comic-mode #comic-viewer {
    display: flex !important;
}

body.is-comic-mode #book-editor-wrap,
body.is-comic-mode #book-empty-state,
body.is-comic-mode #book-sidebar-header .book-sidebar-title:not(.comic-title) {
    display: none !important;
}

.comic-viewer-body {
    flex: 1 !important;
    display: flex !important;
    overflow: hidden !important;
    height: 100% !important;
}

.comic-main-image-wrap {
    flex: 1 !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    position: relative !important;
    padding: 10px !important;
}

.comic-main-image-wrap img {
    max-width: 100% !important;
    max-height: 100% !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
    display: block !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15) !important;
}

.comic-magnifier-lens {
    position: fixed !important;
    z-index: 1000000 !important;
    /* Абсолютно поверх всего */
    border: 4px solid var(--book-accent) !important;
    pointer-events: none !important;
    display: none;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6), inset 0 0 15px rgba(255, 255, 255, 0.2);
    background-repeat: no-repeat;
    background-color: transparent;
}

/* Формы лиnsы */
.comic-magnifier-lens.shape-circle {
    border-radius: 50% !important;
}

.comic-magnifier-lens.shape-square {
    border-radius: 8px !important;
}

.comic-magnifier-lens.shape-rect {
    border-radius: 8px !important;
}

/* ======== ZEN MODE ======== */
body.zen-mode .book-sidebar,
body.zen-mode .book-topbar,
body.zen-mode .book-sidebar-resizer,
body.zen-mode .book-editor-toolbar {
    display: none !important;
}

body.zen-mode .book-layout,
body.zen-mode .book-editor-area,
body.zen-mode .book-editor-wrap,
body.zen-mode .book-content-wrapper {
    display: block !important;
    height: auto !important;
    min-height: none !important;
    max-height: none !important;
    overflow: visible !important;
    width: 100% !important;
    flex: none !important;
}

body.zen-mode {
    overflow-y: auto !important;
    height: auto !important;
}

body.zen-mode .book-editor-area {
    padding: 40px 20px;
    background: var(--book-bg);
}

body.zen-mode .book-editor-wrap {
    max-width: 900px;
    margin: 0 auto;
    box-shadow: none;
    background: transparent;
    display: flex !important; /* Ensure it's visible if it was flex */
    height: auto !important;
}

body.zen-mode .book-editor-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 5px 20px;
    background: var(--book-surface);
    border-bottom: 1px solid var(--book-border);
    height: 40px;
    display: flex;
    align-items: center;
}

body.zen-mode .book-title-input {
    font-size: 1rem;
    height: 30px;
}

body.zen-mode .book-editor-content {
    margin: 80px auto !important; /* Increased top margin for header clearance */
    font-size: var(--zen-font-size, 20px) !important;
    line-height: 1.7;
    background: var(--book-surface) !important;
    box-shadow: 0 0 0 1px var(--book-border), 0 20px 60px rgba(0,0,0,0.2) !important;
    color: var(--book-text) !important;
    padding: 80px 60px 100px !important; 
    max-width: 900px !important;
    width: 90% !important;
    height: auto !important;
    min-height: 60vh !important;
    border-radius: 8px;
    box-sizing: border-box !important;
    overflow-wrap: break-word !important;
    display: flow-root !important; 
    position: relative;
    z-index: 1;
}

/* Force readable text colors in Dark Mode, except for custom inline styled text and font tags */
[data-book-theme="dark"] .book-editor-content,
[data-book-theme="dark"] .book-editor-content *:not([style*="color"]):not(font) {
    color: #e0e0e0 !important;
}

/* Override inline styles for copy-pasted black and dark text in Dark Mode so it becomes white/light grey */
[data-book-theme="dark"] .book-editor-content [style*="color: rgb(0, 0, 0)" i],
[data-book-theme="dark"] .book-editor-content [style*="color:rgb(0,0,0)" i],
[data-book-theme="dark"] .book-editor-content [style*="color: rgb(26, 26, 46)" i],
[data-book-theme="dark"] .book-editor-content [style*="color:rgb(26,26,46)" i],
[data-book-theme="dark"] .book-editor-content [style*="color: rgb(34, 34, 34)" i],
[data-book-theme="dark"] .book-editor-content [style*="color:rgb(34,34,34)" i],
[data-book-theme="dark"] .book-editor-content [style*="color: rgb(51, 51, 51)" i],
[data-book-theme="dark"] .book-editor-content [style*="color:rgb(51,51,51)" i],
[data-book-theme="dark"] .book-editor-content [style*="color: rgb(32, 33, 36)" i],
[data-book-theme="dark"] .book-editor-content [style*="color:rgb(32,33,36)" i],
[data-book-theme="dark"] .book-editor-content [style*="color: black" i],
[data-book-theme="dark"] .book-editor-content [style*="color:black" i],
[data-book-theme="dark"] .book-editor-content [style*="color: #000" i],
[data-book-theme="dark"] .book-editor-content [style*="color:#000" i],
[data-book-theme="dark"] .book-editor-content [style*="color: #000000" i],
[data-book-theme="dark"] .book-editor-content [style*="color:#000000" i],
[data-book-theme="dark"] .book-editor-content [style*="color: #1a1a2e" i],
[data-book-theme="dark"] .book-editor-content [style*="color:#1a1a2e" i],
[data-book-theme="dark"] .book-editor-content [style*="color: #222" i],
[data-book-theme="dark"] .book-editor-content [style*="color:#222" i],
[data-book-theme="dark"] .book-editor-content [style*="color: #222222" i],
[data-book-theme="dark"] .book-editor-content [style*="color:#222222" i],
[data-book-theme="dark"] .book-editor-content [style*="color: #333" i],
[data-book-theme="dark"] .book-editor-content [style*="color:#333" i],
[data-book-theme="dark"] .book-editor-content [style*="color: #333333" i],
[data-book-theme="dark"] .book-editor-content [style*="color:#333333" i],
[data-book-theme="dark"] .book-editor-content [style*="color: #202124" i],
[data-book-theme="dark"] .book-editor-content [style*="color:#202124" i] {
    color: #e0e0e0 !important;
}

/* Hard fallback: any inline text color or legacy <font color> in dark mode becomes light */
[data-book-theme="dark"] .book-editor-content [style*="color:" i],
[data-book-theme="dark"] .book-editor-content font[color],
[data-book-theme="dark"] .book-editor-content font[color] * {
    color: #f1f5f9 !important;
}

/* Override inline styles for copy-pasted white background/highlight blocks in Dark Mode so they become transparent */
[data-book-theme="dark"] .book-editor-content [style*="background-color: rgb(255, 255, 255)" i],
[data-book-theme="dark"] .book-editor-content [style*="background-color:rgb(255,255,255)" i],
[data-book-theme="dark"] .book-editor-content [style*="background-color: #fff" i],
[data-book-theme="dark"] .book-editor-content [style*="background-color:#fff" i],
[data-book-theme="dark"] .book-editor-content [style*="background-color: #ffffff" i],
[data-book-theme="dark"] .book-editor-content [style*="background-color:#ffffff" i],
[data-book-theme="dark"] .book-editor-content [style*="background-color: white" i],
[data-book-theme="dark"] .book-editor-content [style*="background-color:white" i],
[data-book-theme="dark"] .book-editor-content [style*="background: rgb(255, 255, 255)" i],
[data-book-theme="dark"] .book-editor-content [style*="background:rgb(255,255,255)" i],
[data-book-theme="dark"] .book-editor-content [style*="background: #fff" i],
[data-book-theme="dark"] .book-editor-content [style*="background:#fff" i],
[data-book-theme="dark"] .book-editor-content [style*="background: #ffffff" i],
[data-book-theme="dark"] .book-editor-content [style*="background:#ffffff" i],
[data-book-theme="dark"] .book-editor-content [style*="background: white" i],
[data-book-theme="dark"] .book-editor-content [style*="background:white" i] {
    background-color: transparent !important;
    background: transparent !important;
}

[data-book-theme="dark"] .book-editor-content a {
    color: #60cdff !important;
    text-decoration: underline;
}

/* Highlight (marker) fix: only force black text on SPECIFIC light markers */
[data-book-theme="dark"] .book-editor-content mark,
[data-book-theme="dark"] .book-editor-content [style*="background-color: yellow"],
[data-book-theme="dark"] .book-editor-content [style*="background-color:yellow"],
[data-book-theme="dark"] .book-editor-content [style*="background-color: rgb(255, 255, 0)"],
[data-book-theme="dark"] .book-editor-content [style*="background-color:rgb(255, 255, 0)"],
[data-book-theme="dark"] .book-editor-content [style*="background-color: #ffff"],
[data-book-theme="dark"] .book-editor-content [style*="background-color: cyan"],
[data-book-theme="dark"] .book-editor-content [style*="background-color: aqua"],
[data-book-theme="dark"] .book-editor-content [style*="background-color: rgb(0, 255, 255)"],
[data-book-theme="dark"] .book-editor-content [style*="background-color:rgb(0, 255, 255)"],
[data-book-theme="dark"] .book-editor-content [style*="background-color: rgb(128, 255, 255)"],
[data-book-theme="dark"] .book-editor-content [style*="background-color:rgb(128, 255, 255)"],
[data-book-theme="dark"] .book-editor-content [style*="background-color: lime"],
[data-book-theme="dark"] .book-editor-content [style*="background-color: #00ff"],
[data-book-theme="dark"] .book-editor-content [style*="background-color: pink"] {
    color: #000000 !important;
}

/* Force black text on children of highlighted elements too */
[data-book-theme="dark"] .book-editor-content mark *,
[data-book-theme="dark"] .book-editor-content [style*="background-color: yellow"] *,
[data-book-theme="dark"] .book-editor-content [style*="background-color: rgb(255, 255, 0)"] *,
[data-book-theme="dark"] .book-editor-content [style*="background-color: cyan"] *,
[data-book-theme="dark"] .book-editor-content [style*="background-color: aqua"] *,
[data-book-theme="dark"] .book-editor-content [style*="background-color: rgb(128, 255, 255)"] *,
[data-book-theme="dark"] .book-editor-content [style*="background-color:rgb(128, 255, 255)"] *,
[data-book-theme="dark"] .book-editor-content [style*="background-color: rgb(0, 255, 255)"] * {
    color: #000000 !important;
}

/* Force font size inheritance for Zen Mode scaling but allow some relative sizing */
body.zen-mode .book-editor-content * {
    font-size: 1em !important;
    line-height: inherit !important;
}

/* Specific adjustments for Dark Theme in Zen Mode background */
[data-book-theme="dark"].zen-mode .book-editor-area {
    background: #050505; 
}

body.zen-mode #zen-author-info {
    display: none;
}

/* Zen Sidebar - Right Side Hover Menu */
#zen-sidebar-trigger {
    display: none;
    position: fixed;
    right: 0;
    top: 0;
    width: 20px;
    height: 100vh;
    z-index: 9998;
    background: transparent;
}

body.zen-mode #zen-sidebar-trigger {
    display: block;
}

#zen-sidebar {
    position: fixed;
    right: -280px;
    top: 0;
    width: 280px;
    height: 100vh;
    background: var(--book-surface);
    border-left: 1px solid var(--book-border);
    z-index: 9999;
    box-shadow: -5px 0 30px rgba(0,0,0,0.5);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

#zen-sidebar-trigger:hover + #zen-sidebar,
#zen-sidebar:hover {
    right: 0;
}

.zen-sidebar-header {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--book-border);
    color: var(--book-accent);
}

.zen-sidebar-content button {
    width: 100%;
    padding: 10px;
    margin-bottom: 5px;
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    color: var(--book-text);
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    font-size: 0.85rem;
    transition: 0.2s;
}

.zen-sidebar-content button:hover {
    background: var(--book-surface-3);
    border-color: var(--book-accent);
}

#zen-sidebar-chapters {
    overflow-y: auto;
    flex: 1;
}

.zen-chapter-link {
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    color: var(--book-text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    margin-bottom: 2px;
    transition: 0.2s;
}

.zen-chapter-link:hover {
    background: var(--book-surface-2);
    color: var(--book-text);
}

.zen-chapter-link.active {
    background: var(--book-accent-glow);
    color: var(--book-accent);
    font-weight: 600;
}

/* Zen Controls */
.zen-controls {
    display: none;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

body.zen-mode .zen-controls {
    display: flex;
}

.zen-control-btn {
    background: var(--book-surface-2);
    border: 1px solid var(--book-border);
    color: var(--book-text);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: 0.2s;
}

.zen-control-btn:hover {
    background: var(--book-surface-3);
}

.zen-theme-mini {
    display: flex;
    gap: 5px;
    padding: 0 10px;
    border-left: 1px solid var(--book-border);
}

.mini-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.mini-dot:hover { transform: scale(1.2); }
.mini-dot.light { background: #ffffff; }
.mini-dot.sepia { background: #f3e8d4; }
.mini-dot.dark { background: #1f1f1f; }

/* Zen Exit Button - Moved to Bottom */
.zen-exit-btn {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9999;
    padding: 8px 16px;
    background: var(--book-accent);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--book-accent-glow);
}

body.zen-mode .zen-exit-btn {
    opacity: 0.7;
    pointer-events: auto;
    transform: translateY(0);
}

body.zen-mode .zen-exit-btn:hover {
    opacity: 1;
    background: var(--book-accent-hover);
    transform: scale(1.05);
}

/* ============ NEWS PORTAL (О проектах) ============ */
.news-portal-container {
    display: flex;
    gap: 30px;
    height: 100%;
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    animation: fadeIn 0.5s ease;
}

.news-portal-sidebar {
    flex: 0 0 350px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-right: 1px solid var(--book-border);
    padding-right: 20px;
}

.news-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.news-portal-title {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    color: var(--book-accent);
    margin: 0;
}

.news-add-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--book-accent);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 10px var(--book-accent-glow);
}

.news-add-btn:hover {
    transform: scale(1.1) rotate(90deg);
}

.news-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-right: 5px;
}

.news-card {
    background: var(--book-surface);
    border: 1px solid var(--book-border);
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.news-card:hover {
    border-color: var(--book-accent);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.news-card.active {
    background: var(--book-surface-2);
    border-color: var(--book-accent);
    box-shadow: inset 4px 0 0 var(--book-accent);
}

.news-card-title {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 5px;
    color: var(--book-text);
}

.news-card-meta {
    font-size: 0.75rem;
    color: var(--book-text-dim);
    display: flex;
    justify-content: space-between;
}

.news-portal-main {
    flex: 1;
    background: var(--book-surface);
    border-radius: 20px;
    padding: 40px;
    border: 1px solid var(--book-border);
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
}

.news-empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--book-text-dim);
    opacity: 0.6;
}

.news-empty-icon {
    font-size: 5rem;
    margin-bottom: 20px;
}

.news-article-view h1 {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    margin-bottom: 30px;
    line-height: 1.1;
}

.news-article-content {
    font-size: 1.15rem;
    line-height: 1.8;
    color: var(--book-text);
}

.news-card-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

.news-card:hover .news-card-actions {
    opacity: 1;
}

/* ============ RESPONSIVE MEDIA QUERIES (ADAPTIVE VIEWPORT <= 768px) ============ */
@media (max-width: 768px) {
    /* News portal container stacked vertically */
    .news-portal-container {
        flex-direction: column !important;
        gap: 15px !important;
        height: auto !important;
    }
    
    .news-portal-sidebar {
        flex: unset !important;
        width: 100% !important;
        border-right: none !important;
        padding-right: 0 !important;
        gap: 15px !important;
    }
    
    .news-portal-main {
        width: 100% !important;
        padding: 15px !important;
        background: var(--book-surface) !important;
        border-radius: 12px !important;
        border: 1px solid var(--book-border) !important;
    }
    
    /* Toggle visibility when show-content is toggled */
    .news-portal-container.show-content .news-portal-sidebar {
        display: none !important;
    }
    
    .news-portal-container:not(.show-content) .news-portal-main {
        display: none !important;
    }

    /* Projects cards selection page compacting to fit exactly on screen */
    .projects-navigation-view {
        padding: 5px !important;
    }
    
    .projects-main-title {
        font-size: 1.6rem !important;
        margin-bottom: 5px !important;
        text-align: center !important;
    }
    
    .projects-intro-text {
        font-size: 0.85rem !important;
        margin-bottom: 12px !important;
        text-align: center !important;
        line-height: 1.4 !important;
    }
    
    .projects-nav-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        padding-bottom: 5px !important;
    }
    
    .project-nav-card {
        padding: 10px 15px !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;
        border-radius: 12px !important;
        min-height: 52px !important;
        margin: 0 !important;
    }
    
    .project-nav-icon {
        font-size: 1.6rem !important;
        margin-bottom: 0 !important;
    }
    
    .project-nav-title {
        font-size: 1.1rem !important;
        margin-bottom: 0 !important;
    }
    
    .project-nav-desc {
        display: none !important;
    }
    
    .project-nav-btn {
        display: none !important;
    }
}

/* === ICON ONLY & COMPACT MOBILE BAR DESIGN === */
.icon-only-btn {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.1rem !important;
    border-radius: 50% !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    transition: var(--book-transition) !important;
}

.icon-only-btn:hover {
    transform: translateY(-1px) scale(1.05) !important;
}

@media (max-width: 1024px) {
    .book-topbar .btn-text {
        display: none !important;
    }
    .book-topbar .book-dropdown-btn {
        min-width: 50px !important;
        padding: 6px 10px !important;
        justify-content: center !important;
        gap: 0 !important;
    }
}
