:root {
    --reader-bg-dark: #1a1a1a;
    --reader-text-dark: #EAEAEA;
    --reader-bg-light: #f5f5ff;
    --reader-text-light: #222;
    --menu-bg: #2f2f2f;
    --accent-color: #6da8ff;
    --border-color: #444;
}
body { margin: 0; font-family: 'Georgia', serif; transition: background-color 0.3s, color 0.3s; }
body.theme-light { background-color: var(--reader-bg-light); color: var(--reader-text-light); }
body.theme-dark { background-color: var(--reader-bg-dark); color: var(--reader-text-dark); }

#reader-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 20px 40px;
    line-height: 1.8;
    transition: font-size 0.2s;
    cursor: pointer;
}
#chapter-content img { max-width: 100%; height: auto; display: block; margin: 25px auto; border-radius: 8px; }
#chapter-content p { margin-bottom: 1.2em; }
#reader-container.font-size-small { font-size: 14px; }
#reader-container.font-size-medium { font-size: 16px; }
#reader-container.font-size-large { font-size: 18px; }
.chapter-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border-color); }
.like-container { display: flex; align-items: center; justify-content: center; flex: 0 0 140px; }
#like-btn { 
    background: transparent; 
    border: 1px solid var(--border-color); 
    cursor: pointer; 
    padding: 10px 20px; 
    line-height: 1;
    min-width: 110px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    transition: transform 0.2s ease, color 0.2s ease;
}
#like-btn:hover { transform: translateY(-1px); }
#like-btn.liked { 
    color: #FF424D;
    border-color: #FF424D;
    background: rgba(255, 66, 77, 0.12);
}
#like-count { font-size: 1rem; font-weight: 600; color: inherit; }

/* match chapter-like style from main.css */
.chapter-likes { color: #fff; }
.chapter-likes.liked { color: #FF424D; }
.heart-icon-svg {
    vertical-align: middle;
    transition: fill 0.2s, stroke 0.2s, transform 0.2s;
    fill: currentColor;
    stroke: currentColor;
}
.nav-btn { color: #ccc; text-decoration: none; padding: 10px 20px; border: 1px solid var(--border-color); border-radius: 8px; width: 110px; text-align: center; box-sizing: border-box; }
.nav-placeholder { width: 110px; }
@keyframes like-burst { 0% { transform: scale(1); } 50% { transform: scale(1.4); } 100% { transform: scale(1); } }
.heart-icon-svg.burst { animation: like-burst 0.4s ease-in-out; }

/* Mobile tweaks */
@media (max-width: 768px) {
	#reader-container { margin: 0 auto; padding: 16px 16px; max-width: 100%; }
	.chapter-footer { gap: 12px; }
	.nav-btn { width: 110px; min-width: 110px; flex: 0 0 110px; }
	.nav-placeholder { width: 110px; min-width: 110px; flex: 0 0 110px; }
}
@media (max-width: 420px) {
	#reader-container { padding: 14px 12px; }
	h1 { font-size: 1.2rem; line-height: 1.3; }
	.nav-btn { width: 110px; min-width: 110px; flex: 0 0 110px; padding: 10px 12px; }
	.nav-placeholder { width: 110px; min-width: 110px; flex: 0 0 110px; }
}

/* Боковое меню */
#reader-menu { position: fixed; top: 0; right: 0; width: 320px; height: 100%; background-color: var(--menu-bg); color: var(--reader-text-dark); box-shadow: -5px 0 15px rgba(0,0,0,0.3); transform: translateX(100%); transition: transform 0.3s ease-in-out; display: flex; flex-direction: column; z-index: 1001; }
#reader-menu.open { transform: translateX(0); }
#menu-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s; z-index: 1000; }
#reader-menu.open + #menu-overlay { opacity: 1; visibility: visible; }
.menu-header { padding: 15px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.menu-header h3 { margin: 0; }
.menu-header h3 a { color: var(--reader-text-dark); text-decoration: none; transition: color 0.2s; }
.menu-header h3 a:hover { color: var(--accent-color); }
#close-menu-btn { background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer; }
.menu-tab-content { padding: 15px; overflow-y: auto; flex-grow: 1; }
.menu-tab-content h4 { margin-top: 0; }
.chapter-nav-list { list-style: none; padding: 0; max-height: 40vh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #555 #2f2f2f; }
.chapter-nav-list::-webkit-scrollbar { width: 4px; }
.chapter-nav-list::-webkit-scrollbar-track { background: #2f2f2f; }
.chapter-nav-list::-webkit-scrollbar-thumb { background: #555; border-radius: 2px; }
.chapter-nav-list::-webkit-scrollbar-thumb:hover { background: #666; }
.chapter-nav-list li a { color: #ccc; text-decoration: none; display: block; padding: 8px 0; }
.chapter-nav-list li.active a { color: var(--accent-color); font-weight: bold; }
.chapter-nav-list li a:hover { color: white; }
.setting-group { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.setting-btn { background-color: #444; border: 1px solid #666; color: white; padding: 5px 10px; border-radius: 5px; cursor: pointer; }
.setting-btn.active { background-color: var(--accent-color); border-color: var(--accent-color); }

/* Комментарии */
#comments-section { max-width: 800px; margin: 50px auto; padding: 20px 40px; border-top: 1px solid #555; }
.comment-form textarea { width: 100%; background: #2f2f2f; color: white; border: 1px solid var(--border-color); border-radius: 5px; padding: 10px; min-height: 80px; box-sizing: border-box; }
.comment-form button { display: block; margin-top: 10px; margin-left: auto; background: var(--accent-color); color: white; border: none; padding: 8px 15px; border-radius: 5px; cursor: pointer; }
.comment { display: flex; gap: 15px; margin-bottom: 20px; padding-top: 20px; }
.comment-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; aspect-ratio: 1 / 1; flex-shrink: 0; }
.comment-body { position: relative; width: 100%; }
.comment-header { display: flex; justify-content: space-between; align-items: flex-start; }
.comment-body strong { display: block; margin-bottom: 5px; }
.comment-body p { margin: 0; word-break: break-word; }
.comment-actions { display: flex; gap: 15px; align-items: center; margin-top: 8px; }
.like-comment-btn { 
    background: none; 
    border: none; 
    cursor: pointer; 
    padding: 4px 10px; 
    display: inline-flex; 
    align-items: center; 
    gap: 6px; 
    color: #fff; 
    transition: transform 0.2s ease, color 0.2s ease;
}
.like-comment-btn:hover { transform: translateY(-1px); }
.like-comment-btn.liked { color: #FF424D; }
.comment-heart-icon { display: inline-flex; }
.comment-like-count { font-size: 0.9rem; color: inherit; }
.reply-btn { background: none; border: 1px solid #555; color: #aaa; border-radius: 5px; cursor: pointer; font-size: 0.8rem; padding: 4px 8px; }
.reply-btn:hover { background: #444; }
.edit-btn { background: none; border: 1px solid #555; color: #aaa; border-radius: 5px; cursor: pointer; font-size: 0.8rem; padding: 4px 8px; }
.edit-btn:hover { background: #444; }
.reply-form-container { margin-top: 10px; padding: 10px; background: #2a2a2a; border-radius: 5px; }
.reply-form textarea { width: 100%; min-height: 60px; margin-bottom: 8px; box-sizing: border-box; background: #3a3a3a; color: white; border-radius: 5px; padding: 8px; border: 1px solid var(--border-color); }
.reply-actions { display: flex; gap: 8px; }
.reply-actions button { background-color: #555; border: none; color: white; padding: 5px 10px; border-radius: 4px; cursor: pointer; font-size: 0.85rem; }
.reply-actions button[type="submit"] { background-color: var(--accent-color); }
.reply-actions button:hover { opacity: 0.8; }
.replies-container { margin-top: 15px; margin-left: 20px; padding-left: 20px; border-left: 2px solid #444; }
.reply-comment { display: flex; gap: 10px; margin-bottom: 15px; }
.reply-comment .comment-avatar { width: 32px; height: 32px; }
.reply-comment .comment-body { font-size: 0.9rem; }
.reply-comment .comment-body strong { font-size: 0.85rem; }
.reply-comment .comment-actions { margin-top: 5px; }
.reply-comment .comment-heart-icon { font-size: 1rem; }
.reply-comment .comment-like-count { font-size: 0.8rem; }
.reply-comment .reply-btn { font-size: 0.75rem; padding: 3px 8px; }
.comment-heart-icon.burst { animation: like-burst 0.4s ease-in-out; }
.comment-hidden { display: none; }
.show-more-comments-btn { display: block; width: 100%; margin-top: 15px; padding: 10px; background: #2f2f2f; border: 1px solid var(--border-color); color: #ccc; border-radius: 5px; cursor: pointer; text-align: center; transition: background 0.2s; }
.show-more-comments-btn:hover { background: #3a3a3a; }
.show-more-replies-btn { display: block; width: 100%; margin-top: 10px; padding: 8px; background: #2a2a2a; border: 1px solid var(--border-color); color: #ccc; border-radius: 5px; cursor: pointer; text-align: center; transition: background 0.2s; font-size: 0.85rem; }
.show-more-replies-btn:hover { background: #333; }
.edit-comment-form textarea { width: 100%; min-height: 60px; margin-bottom: 5px; box-sizing: border-box; background: #3a3a3a; color: white; border-radius: 5px; padding: 5px; }
.edit-actions button { margin-right: 5px; background-color: #555; border: none; color: white; padding: 5px 8px; border-radius: 4px; cursor: pointer; }
#open-menu-btn { display: none; }

/* Post Actions (Ellipsis Menu) */
.post-actions { position: relative; margin-left: 10px; }
.ellipsis-btn { background: none; border: none; color: #aaa; font-size: 1.2rem; cursor: pointer; padding: 0 5px; border-radius: 5px; line-height: 1; }
.ellipsis-btn:hover { background-color: #444; color: white; }
.actions-menu { display: none; position: absolute; right: 0; top: 100%; background-color: #2f2f2f; border: 1px solid #444; border-radius: 5px; list-style: none; padding: 5px 0; margin: 0; z-index: 10; min-width: 120px; box-shadow: 0 2px 10px rgba(0,0,0,0.3); }
.actions-menu button, .actions-menu a { background: none; border: none; color: #EAEAEA; padding: 8px 12px; display: block; width: 100%; text-align: left; cursor: pointer; font-size: 0.85rem; text-decoration: none; box-sizing: border-box; }
.actions-menu button:hover, .actions-menu a:hover { background-color: var(--accent-color); color: #050505; }
.actions-menu .delete-action { color: #ff4d4d; }
.actions-menu hr { border: 0; border-top: 1px solid #444; margin: 5px 0; }

/* --- Общее модальное окно (для страницы чтения) --- */
.app-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.app-modal {
    background-color: #161616;
    border-radius: 12px;
    padding: 20px 24px;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.75);
    border: 1px solid #2a2a2a;
}

.app-modal-title {
    margin: 0 0 8px;
    font-size: 1.1rem;
}

.app-modal-text {
    margin: 4px 0;
    font-size: 0.95rem;
    color: #cccccc;
    white-space: pre-wrap;
}

.app-modal-actions {
    margin-top: 18px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.app-modal-button {
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
}

.app-modal-button.primary {
    background-color: var(--accent-color);
    color: #050505;
}

.app-modal-button.secondary {
    background-color: #2f2f2f;
    color: #eaeaea;
}

.app-modal-field {
    margin-top: 10px;
}

.app-modal-field-inline {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-end;
}

.app-modal-field label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: #cccccc;
}

.app-modal-input {
    width: 100%;
    box-sizing: border-box;
    background-color: #1f1f1f;
    border: 1px solid #333;
    color: #eaeaea;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 0.9rem;
}

/* --- АДАПТИВНОСТЬ ДЛЯ ЧИТАЛКИ --- */
@media (max-width: 880px) {
    #reader-container, #comments-section {
        padding: 20px 15px;
        margin: 20px auto;
    }
    .nav-btn {
        padding: 8px 10px;
        width: 110px;
        min-width: 110px;
        flex: 0 0 110px;
    }
    .chapter-footer {
        gap: 15px;
    }
    .nav-placeholder {
        width: 110px;
        min-width: 110px;
        flex: 0 0 110px;
    }
}
@media (max-width: 600px) {
    #reader-menu {
        width: 85%;
    }
}

