/* Main Container */
.chapter-detail-space {
    width: calc(100% - 4.4rem);
    margin-left: 4.4rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-direction: column;
    background-color: var(--second-page-bg-color);
}

.chapter-detail-container {
    color: var(--text-secondary-color);
    width: 800px;
    padding: 0 2.5em 1.5em;
    border-inline: 2px solid var(--primary-color);
    border-radius: 8px 8px 0 0;
    display: flex;
    flex-direction: column;
    line-height: 1.8;
    font-size: 1.1rem;
    background-color: var(--chapter-detail-background-color);
}

/* Navigation Bar */
.chapter_map_guide {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted-color);
    padding: 0.75rem 0;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 0.875rem;
    white-space: nowrap;
}

.chapter-map {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.create-edit-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 1rem;
}

.chapter_map_guide a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
}

.chapter_map_guide a:hover {
    text-decoration: underline;
    color: var(--primary-hover-color);
}

.chapter_map_guide span {
    padding: 0 0.25rem;
    font-size: 1rem;
    font-weight: 500;
    flex-shrink: 0;
}

.chapter_map_guide i {
    font-size: 1.5rem;
}

.chapter_map_guide .fa-home {
    font-size: 1rem;
}

.chapter_map_guide .ellipsis-none {
    overflow: visible !important;
}

.back-to-novel-link {
    font-weight: 500;
}

.map-chapter-list {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.map-chapter-list i {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--primary-color);
    cursor: pointer;
    transition: color 0.2s ease;
}

.map-chapter-list i:hover {
    color: var(--primary-hover-color);
}

.create-edit-container a {
    color: var(--primary-color);
    margin-left: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.create-edit-container a:hover {
    color: var(--primary-hover-color);
}

/* Chapter Header */
.chapter-header {
    padding: 1.2rem 0;
    position: relative;
}

.chapter-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}

.chapter-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--primary-color), transparent);
}

.chapter-header h1 {
    font-size: 1.6rem;
    font-weight: bold;
    color: var(--chapter-title-text);
    text-align: center;
    border-bottom: none;
    padding: 0;
    margin-bottom: 0;
}

.chapter-header h1:has(+ .draft-badge) {
    color: var(--chapter-draft-title-color);
}

.chapter-header h1 .draft-badge {
    border: 2px solid var(--primary-color);
}

.draft-badge, .modal-draft-badge {
    background-color: var(--sidebar-secondary-bg-color);
    color: var(--text-color);
    font-size: 0.5em;
    padding: 3px 8px;
    border-radius: 40px;
    text-transform: uppercase;
    font-weight: bold;
    vertical-align: middle;
    display: inline-block;
    position: relative;
}

.draft-badge {
    margin-left: 10px;
    top: -3px;
}

/* Chapter Navigation */
.chapter-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 0;
}

.chapter-navigation.top {
    border-bottom: 1px solid var(--input-border-color);
}

.chapter-navigation.bottom {
    border-top: 1px solid var(--input-border-color);
}

.chapter-navigation a {
    background-color: var(--chapter-nav-button-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border-color);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    text-decoration: none;
    display: inline-block;
}

.chapter-navigation a:hover:not(.disabled) {
    background-color: var(--chapter-nav-button-hover);
    color: var(--text-color);
}

.chapter-navigation .disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--chapter-nav-disabled-bg);
    color: var(--text-muted-color);
    border: 1px solid var(--input-border-color);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 1rem;
    text-decoration: none;
    display: inline-block;
    box-shadow: none;
}

.chapter-navigation i {
    color: var(--text-secondary-color);
}

/* Chapter Content */
.chapter-content {
    position: relative;
    color: var(--chapter-text);
    line-height: 1.8;
    white-space: pre-line;
    overflow-wrap: break-word;
    word-break: break-word;
}

.chapter-content.with-border {
    border-bottom: solid 1px var(--input-border-color);
    margin-bottom: 2rem;
}

.formatted-content strong {
    font-weight: bold;
}

.formatted-content em {
    font-style: italic;
}

.chapter-ad-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    min-height: 40px; 
    max-height: 100px;
    clear: both;
    border-top: 1px solid #333; 
    border-bottom: 1px solid #333;
    background-color: rgba(255, 255, 255, 0.02);
    padding: 0.5rem 0;
    text-align: center;
    margin: 1rem 0;
}

/* Author Notes */
.author_note {
    position: relative;
    border-radius: 5px;
    font-family: Arial, sans-serif;
    padding: 15px 35px 35px 35px;
    background-color: var(--sidebar-secondary-bg-color);
    display: block;
    margin-bottom: 2rem;
    border: 1px solid var(--input-border-color);
}

.author_note.active {
    display: none;
}

.author_note::before {
    content: "“";
    position: absolute;
    top: -20px;
    left: 10px;
    font-size: 4em;
    color: var(--author-note-quote-color);
    z-index: 1;
}

.author_note::after {
    content: "”";
    position: absolute;
    bottom: -60px;
    right: 10px;
    font-size: 4em;
    color: var(--author-note-quote-color);
    z-index: 1;
}

.author_note_avatar {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
}

.note_avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 5px;
}

.note_title {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-color);
    z-index: 2;
}

.note_content {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    font-weight: bold;
    white-space: pre-line;
    overflow-wrap: break-word;
    word-break: break-word;
    z-index: 2;
    position: relative;
}

/* Comment Section */
.comment-section {
    border-top: 1px solid var(--input-border-color);
    padding-top: 1rem;
    font-family: Arial, sans-serif;
}

.comment-section h2 {
    color: var(--text-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    font-size: 1.5rem;
}

/* Comment Form */
#comment-form {
    margin-bottom: 1.5rem;
}

.comment-form {
    margin: 1rem 0;
}

.comment-form .form-group {
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
}

.comment-form [name="content"] {
    color: var(--text-color);
    border-radius: 0 12px 12px 0;
    font-size: 1rem;
    resize: vertical;
    min-height: 100px;
    transition: border-color 0.3s ease;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--chapter-border-color);
    background-color: var(--chapter-text-area);
}

.comment-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.comment-form .form-group-btn {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
}

.btn-submit {
    background-color: var(--primary-color);
    color: var(--text-dark-light-color);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-submit:hover {
    background-color: var(--primary-hover-color);
}

.btn-submit:hover {
    background-color: var(--primary-hover-color);
}

.chapter-auth-prompt {
    margin: 1rem 0;
    font-size: 1rem;
}

.chapter-auth-link {
    color: #ffa617;
}

/* Comments Display */
.comment {
    background-color: var(--comment-bg-color);
    border: 1px solid var(--input-border-color);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.comment-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 0.3rem;
}

.comment-avatar-container {
    height: 40px;
    width: 40px;
}

.comment-avatar {
    margin-right: 0.7rem;
    max-height: 40px;
    max-width: 40px;
    min-width: 40px;
    min-height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.comment-meta {
    flex-grow: 1;
}

.comment-username {
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
    margin-left: 0.2rem;
}

.comment-timestamp {
    font-size: 0.8rem;
    color: var(--text-muted-color);
}

.comment-content {
    color: var(--secondary-color);
    padding: 0.5rem 0.8rem 0 0.8rem;
    line-height: 1.4;
    font-size: 1rem;
    white-space: pre-line;
    overflow-wrap: break-word;
    word-break: break-word;
}

.highlight-comment {
    animation: chapter-highlight-fade 2s ease-in-out;
}

/* Comment Actions */
.comment-actions {
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.btn-like, .btn-dislike, .btn-reply, .btn-edit, .btn-delete, .btn-cancel, .btn-reply-reply {
    background-color: transparent;
    color: var(--intraction-button-color);
    border: none;
    padding: 0.5rem 0.8rem;
    cursor: pointer;
    transition: color 0.3s ease;
    display: flex;
    gap: 0.3rem;
    align-items: center;
    font-size: 0.9rem;
}

.btn-like:hover, .btn-dislike:hover, .btn-reply:hover, .btn-edit:hover, .btn-reply-reply:hover {
    color: var(--primary-color);
}

.btn-delete:hover {
    color: var(--error-color);
}

.btn-like.liked, .btn-dislike.disliked {
    color: var(--primary-color);
}

.btn-cancel {
    background-color: var(--cancel-btn-bg);
    color: var(--text-secondary-color);
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 1.05rem;
    margin: 0;
    transition: background-color 0.3s ease;
}

.btn-cancel:hover {
    background-color: var(--cancel-btn-hover-bg);
}

/* Replies */
.replies {
    margin-left: 3rem;
    margin-top: 1rem;
}

.reply {
    background-color: var(--reply-bg-color);
    border: 1px solid var(--sidebar-secondary-bg-color);
    border-radius: 8px;
    padding: 0.8rem;
    margin-top: 0.8rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.reply-form-container {
    margin-left: 1rem;
}

.replies-wrapper {
    margin-top: 0.5rem;
}

.toggle-replies-btn, .load-more-replies-btn {
    border: none;
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    border-radius: 1rem;
    background: transparent;
    font-size: 1rem;
    font-weight: inherit;
    color: var(--primary-color);
    margin-left: 0.3rem;
    transition: all 0.1s ease-in-out;
}

.load-more-replies-btn {
    margin-top: 0.5rem;
}

.toggle-replies-btn:hover, .load-more-replies-btn:hover {
    background: var(--primary-color);
    color: var(--about-button-text-color);
}

.arrow-icon {
    display: inline-block;
    transition: transform 0.3s ease;
}

.toggle-replies-btn.open .arrow-icon {
    transform: rotate(180deg);
}

.edit-form-container {
    margin-top: 1rem;
}

/* Chapter List Modal */
.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    width: 450px;
    background-color: var(--modal-overlay-bg);
    border-radius: 8px;
    padding: 0.5rem;
    box-shadow: var(--box-shadow);
    opacity: 0;
    z-index: 1000;
    overscroll-behavior: contain;
}

.modal.show {
    display: block;
    animation: chapter-modalFadeIn 0.3s ease forwards;
    overscroll-behavior: contain;
}

.modal.hide {
    animation: chapter-modalFadeOut 0.3s ease forwards;
}

.modal-content {
    background-color: var(--modal-content-bg);
    border: 1px solid var(--input-border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.close {
    color: var(--text-secondary-color);
    float: right;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

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

.modal-content h2 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

.modal-content ul {
    list-style-type: none;
    padding: 0;
    max-height: 300px;
    overscroll-behavior: contain;
    overflow-y: auto;
}

.modal-content ul::-webkit-scrollbar {
    width: 6px;
}

.modal-content ul::-webkit-scrollbar-track {
    background: var(--sidebar-secondary-bg-color);
}

.modal-content ul::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.modal-content ul::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover-color);
}

.modal-content li {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--text-third-color);
    padding: 10px 0;
    max-width: 95%;
}

.modal-content li a {
    color: var(--text-third-color);
    text-decoration: none;
}

.modal-content li a:hover {
    text-decoration: underline;
}

.modal-content li.current-chapter a {
    color: var(--text-color);
    font-weight: bold;
    border-left: 4px solid #ffa500;
    padding-left: 5px;
}

/* Adult Content Warning Modal */
.adult-modal {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-bg);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.adult-modal-content {
    background-color: var(--background-color);
    padding: 30px;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: var(--box-shadow);
    border-left: 5px solid var(--error-color);
}

.adult-warning-icon {
    color: var(--error-color);
    font-size: 3rem;
    margin-bottom: 15px;
}

.adult-modal-content h2 {
    color: var(--error-color);
    margin-bottom: 15px;
}

.adult-modal-content p {
    margin-bottom: 15px;
    color: var(--text-secondary-color);
}

.adult-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.adult-btn-back {
    padding: 10px 20px;
    background-color: var(--sidebar-secondary-bg-color);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.adult-btn-proceed {
    padding: 10px 20px;
    background-color: var(--error-color);
    color: var(--text-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.adult-btn-back:hover {
    background-color: var(--filter-tab-hover-bg);
}

.adult-btn-proceed:hover {
    background-color: var(--primary-color);
}

.blurred {
    filter: blur(5px);
}

/* Author Feedback */
.author-feedback {
    position: relative;
    cursor: help;
    border-bottom: 1px dashed var(--primary-color);
    color: var(--primary-color);
}

.author-feedback:hover::after,
.author-feedback.active::after {
    content: attr(data-note);
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%); 
    background: var(--comment-bg-color);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9em;
    max-width: 300px;
    width: max-content;
    white-space: pre-line;
    overflow-wrap: break-word;
    word-break: break-word;
    word-wrap: break-word;
    z-index: 999;
    box-shadow: var(--box-shadow);
    pointer-events: none;
}

.author-feedback.active::after {
    display: block;
}

/* Keyframe Animations */
@keyframes chapter-modalFadeIn {
    from { opacity: 0; transform: translate(-50%, -60%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes chapter-modalFadeOut {
    from { opacity: 1; transform: translate(-50%, -50%); }
    to { opacity: 0; transform: translate(-50%, -60%); }
}

@keyframes chapter-highlight-fade {
    0% { background-color: var(--highlight-fade-start); }
    100% { background-color: var(--comment-bg-color); }
}

/* Tablet Styles */
@media (max-width: 1024px) {
    .chapter-detail-space {
        width: 100%;
        margin-left: 0;
    }
    
    .chapter-detail-container {
        width: inherit;
        max-width: 800px;
    }

    .chapter-detail-container .chapter-content {
        line-height: 1.2;
    }
    
    .chapter-header h1 {
        font-size: 1.3rem;
    }
    
    .adult-title-end-container h1::before {
        left: -1.5rem;
    }

    .adult-title-end-container h1::after {
        right: -1.5rem;
    }
    
    .chapter-navigation {
        flex-direction: row;
        justify-content: space-between;
        gap: 0.3rem;
    }
    
    .chapter-navigation button {
        padding: 0.6rem 1.2rem;
        font-size: 1rem;
    }
    
    .modal {
        width: 60%;
        transform: none;
    }
    
    .comment-section {
        padding: 0.8rem 0;
    }
    
    .comment-section h2 {
        font-size: 1.3rem;
    }
    
    #comment-form button,
    .reply-form button,
    .comment-actions button,
    .form-group-btn button,
    .btn-reply-reply {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .comment-header {
        align-items: flex-start;
    }
    
    .comment-form textarea {
        font-size: 16px;
    }
    
    .replies {
        margin-left: 1.5rem;
    }
    
    .reply-form-container {
        margin-left: 1.5rem;
    }
}

/* Mobile Styles */
@media (max-width: 769px) {
    .chapter-detail-container {
        padding: 0 1rem 0.8rem;
        border-top: 1px solid var(--input-border-color);
        max-width: 100%;
        min-width: 100%;
        border-inline: none;
    }
    
    .chapter-header h1 {
        font-size: 1.5rem;
    }
    
    .adult-title-end-container::before {
        left: -1.3rem;
    }
    
    .adult-title-end-container::after {
        right: -1.3rem;
    }
    
    .edit-chapter-icon {
        top: 0.3rem;
        right: 0.3rem;
    }
    
    .chapter-content {
        font-size: 1.1rem;
        line-height: 1.6;
    }

    .chapter-ad-banner{
        margin: 0.7rem 0;
    }
    
    .chapter-navigation {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .nav_butt_hide {
        display: none;
    }
    
    .chapter-navigation a, .chapter-navigation .disabled {
        flex: 0 0 auto;
        width: 45px;
        height: 45px;
        border-radius: 50%;
        padding: 0;
        margin: 0 0.3rem;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 0.9rem;
    }
    
    .modal {
        width: 90%;
        max-width: none;
    }
    
    .modal-content {
        padding: 0.8em;
    }
    
    .modal-content h2 {
        font-size: 1.3em;
    }
    
    .modal-content ul {
        max-height: 60vh;
    }
    
    .comment-section {
        padding: 1em 0 0 0;
    }
    
    .comment-section h2 {
        font-size: 1.4rem;
        margin-bottom: 0.8rem;
    }
    
    .comment {
        padding: 0.5rem;
    }
    
    .comment-form textarea {
        border-radius: 8px;
        font-size: 16px;
    }
    
    .btn-submit, .btn-cancel {
        padding: 0.4rem 1rem;
        font-size: 0.9rem;
    }
    
    .comment-username {
        font-size: 1rem;
    }
    
    .comment-timestamp {
        font-size: 0.8rem;
    }
    
    .comment-content {
        font-size: 0.95rem;
        padding: 0.4em 0.8rem 0 0.8rem;
    }
    
    .comment-actions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .btn-like, .btn-dislike, .btn-reply, .btn-edit, .btn-delete {
        padding: 0.4em 0.8rem;
        font-size: 0.85rem;
    }
    
    .btn-delete:hover {
        color: inherit;
    }
    
    .toggle-replies-btn:hover, .load-more-replies-btn:hover {
        background: inherit;
        color: var(--primary-color);
    }
    
    .replies {
        margin-left: 1.5rem;
        padding-left: 0;
    }
}

/* Small Mobile Styles */
@media (max-width: 480px) {
    .chapter-header h1 {
        font-size: 1.3rem;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    
    .chapter_map_guide {
        font-size: 0.8rem;
    }
    
    .adult-title-end-container::before {
        left: -1rem;
    }
    
    .adult-title-end-container::after {
        right: -1rem;
    }
    
    .comment-section h2 {
        font-size: 1.2rem;
    }
    
    .comment-content {
        padding: 0.3rem 0.5rem 0 0.5rem;
    }
    
    .btn-like, .btn-dislike, .btn-reply, .btn-edit, .btn-delete, .btn-reply-reply {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .btn-delete:hover {
        color: inherit;
    }
}

/* Extra Small Mobile Styles */
@media (max-width: 390px) {    
    .chapter_map_guide {
        font-size: 0.7rem;
    }
    
    .chapter-content {
        font-size: 1rem;
        line-height: 1.3;
    }
    
    .note_content {
        font-size: 1rem;
        line-height: 1.3;
    }
}