.comment-editor-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.comment-format-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.4rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: var(--card-bg-alt, #f9fafb);
}

.comment-editor-wrap .comment-textarea-vc,
.comment-editor-wrap .comment-rich-editor {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: 0;
}

.comment-rich-editor {
    min-height: 7rem;
    max-height: 28rem;
    overflow-y: auto;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 0 0 8px 8px;
    background: #fff;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text, #374151);
}

.comment-rich-editor:focus {
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: 0;
}

.comment-rich-editor.comment-rich-empty[data-placeholder]:before {
    content: attr(data-placeholder);
    color: #9ca3af;
    pointer-events: none;
}

.comment-rich-editor ul.comment-md-list,
.comment-rich-editor blockquote.comment-md-quote {
    margin: 0.35em 0;
    padding-left: 1.25rem;
}

.comment-rich-editor blockquote.comment-md-quote {
    border-left: 3px solid #e5e7eb;
    padding-left: 0.75rem;
    color: #4b5563;
}

.comment-fmt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.45rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: #fff;
    color: var(--text, #374151);
    cursor: pointer;
    font: inherit;
    line-height: 1;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.comment-fmt-btn:hover {
    background: var(--hover-bg, #f3f4f6);
    border-color: var(--border-color, #e5e7eb);
}

.comment-fmt-btn:focus-visible {
    outline: 2px solid var(--accent, #2563eb);
    outline-offset: 1px;
}

.comment-fmt-icon {
    font-weight: 700;
    font-size: 0.9rem;
}

.comment-fmt-italic .comment-fmt-icon {
    font-style: italic;
    font-weight: 600;
}

.comment-fmt-icon-list {
    display: block;
    width: 1rem;
    height: 0.65rem;
    background: linear-gradient(
        to bottom,
        currentColor 0,
        currentColor 15%,
        transparent 15%,
        transparent 42%,
        currentColor 42%,
        currentColor 57%,
        transparent 57%,
        transparent 85%,
        currentColor 85%,
        currentColor 100%
    );
    opacity: 0.85;
}

.comments-section-enhanced .comments-section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.comments-sort-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.comments-sort-link {
    font-size: 0.875rem;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    border: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-muted, #6b7280);
    text-decoration: none;
}

.comments-sort-link:hover {
    border-color: var(--accent, #2563eb);
    color: var(--accent, #2563eb);
}

.comments-sort-link.is-active {
    background: var(--accent-soft, #eff6ff);
    border-color: var(--accent, #2563eb);
    color: var(--accent, #1d4ed8);
    font-weight: 600;
}

.comment-header-vc {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem 1rem;
}

.comment-header-actions {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.btn-comment-helpful,
.btn-comment-reply,
.btn-comment-edit,
.btn-comment-delete,
.btn-comment-report {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color, #e5e7eb);
    background: #fff;
    cursor: pointer;
    color: var(--text, #374151);
}

.btn-comment-helpful.is-active {
    background: #ecfdf5;
    border-color: #10b981;
    color: #047857;
}

.comment-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    margin-left: 0.35rem;
    vertical-align: middle;
}

.comment-badge--author {
    background: #fef3c7;
    color: #92400e;
}

.comment-branch {
    margin-top: 0.5rem;
}

/* Древовидные ответы: направляющая и отступ (вместо едва заметного margin-left) */
.comment-thread-node .comment-branch-children {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.75rem;
    padding-left: 1rem;
    margin-left: 0.35rem;
    border-left: 3px solid rgba(37, 99, 235, 0.35);
}

.comment-thread-node .comment-branch-children > .comment-thread-node {
    margin-left: 0 !important;
}

.comment-vc--reply {
    background: rgba(248, 250, 252, 0.98);
    border-color: #e2e8f0;
}

.comment-reply-context {
    margin: 0 0 0.35rem;
    padding-left: 52px;
    font-size: 0.8rem;
    color: var(--text-muted, #6b7280);
}

.comment-reply-context-link {
    color: var(--accent, #2563eb);
    font-weight: 600;
    text-decoration: none;
}

.comment-reply-context-link:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .comment-thread-node .comment-branch-children {
        padding-left: 0.65rem;
        margin-left: 0.15rem;
    }

    .comment-reply-context {
        padding-left: 0;
    }
}

.btn-branch-toggle {
    font-size: 0.8rem;
    border: none;
    background: transparent;
    color: var(--accent, #2563eb);
    cursor: pointer;
    padding: 0.25rem 0;
    text-decoration: underline;
}

.comment-form-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.comment-preview-panel {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border: 1px dashed var(--border-color, #d1d5db);
    border-radius: 8px;
    background: var(--card-bg-alt, #f9fafb);
}

.comment-preview-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    margin-bottom: 0.35rem;
}

.comment-md-body ul.comment-md-list {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.comment-md-quote {
    margin: 0.5rem 0;
    padding: 0.35rem 0.65rem;
    border-left: 3px solid var(--border-color, #d1d5db);
    color: var(--text-muted, #4b5563);
    font-size: 0.95em;
}

.comments-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 1rem;
}

.comments-page-link {
    min-width: 2rem;
    text-align: center;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color, #e5e7eb);
    text-decoration: none;
    color: var(--text, #374151);
    font-size: 0.875rem;
}

.comments-page-link.is-active {
    background: var(--accent, #2563eb);
    border-color: var(--accent, #2563eb);
    color: #fff;
    font-weight: 600;
}

.comment-replying-to {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted, #6b7280);
}

.btn-link {
    border: none;
    background: none;
    color: var(--accent, #2563eb);
    cursor: pointer;
    text-decoration: underline;
    font-size: inherit;
    margin-left: 0.5rem;
}

.comment-edit-panel {
    margin-top: 0.5rem;
}

.comment-edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.comment-report-modal {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.comment-report-modal.active {
    display: flex;
}

.comment-report-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.comment-report-dialog {
    position: relative;
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.comment-report-dialog h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

.comment-report-dialog .form-group {
    margin-bottom: 0.75rem;
}

.comment-report-dialog label {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.comment-report-dialog .form-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.comment-report-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.comment-form-errors {
    margin: 0.5rem 0 0;
    padding: 0.6rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
}

.comment-form-errors[hidden] {
    display: none !important;
}

.btn-comment-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-comment-anchor {
    margin: 0;
    padding: 0.15rem 0.4rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--muted, #6b7280);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.btn-comment-anchor:hover {
    color: var(--accent, #2563eb);
}

@keyframes comment-highlight-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.45);
    }
    100% {
        box-shadow: 0 0 0 10px rgba(37, 99, 235, 0);
    }
}

.comment-thread-node.comment-highlight-flash {
    animation: comment-highlight-pulse 1.2s ease-out 2;
    border-radius: 10px;
}

@media (max-width: 640px) {
    .comment-header-actions {
        width: 100%;
        margin-left: 0;
    }
}
