.comments-section .cmt-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.comments-section .cmt-sort {
    display: flex;
    gap: 4px;
}

.comments-section .cmt-sort-link {
    font-size: 14px;
    color: #595959;
    padding: 6px 12px;
    border-radius: 999px;
    text-decoration: none;
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.comments-section .cmt-sort-link:hover {
    background-color: #F2F3F5;
}

.comments-section .cmt-sort-link.is-active {
    background-color: #F2F3F5;
    color: #000;
    font-weight: 500;
}

.comments-section .cmt-time {
    color: #808080;
    font-size: 13px;
    text-decoration: none;
}

.comments-section .cmt-time:hover {
    text-decoration: underline;
}

.comments-section .cmt-photo {
    display: block;
    margin-top: 8px;
    max-width: 320px;
}

.comments-section .cmt-photo img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
}

.comments-section .cmt-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-top: 8px;
}

.comments-section .cmt-reactions {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    position: relative;
}

.comments-section .cmt-reaction {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    background: #F2F3F5;
    font: 13px/1 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    color: #33393F;
    cursor: pointer;
    transition: background-color 0.2s;
}

.comments-section .cmt-reaction:hover {
    background-color: #E8EAEE;
}

.comments-section .cmt-reaction.is-mine {
    background-color: #EDF3FC;
    color: #0B5DD7;
    border: 1px solid #0B5DD7;
}

.comments-section .cmt-reaction-emoji {
    font-size: 15px;
}

.comments-section .cmt-reaction-add {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 0;
    background: #F2F3F5;
    color: #595959;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s;
}

.comments-section .cmt-reaction-add:hover {
    background-color: #E8EAEE;
}

.comments-section .cmt-reaction-picker-wrap {
    position: relative;
    display: inline-flex;
}

.comments-section .cmt-reaction-picker {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    z-index: 20;
    display: flex;
    gap: 2px;
    padding: 6px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1), 0 16px 40px rgba(0, 0, 0, 0.18);
}

.comments-section .cmt-reaction-picker[hidden] {
    display: none;
}

.comments-section .cmt-reaction-option {
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.12s, transform 0.12s;
}

.comments-section .cmt-reaction-option:hover {
    background-color: #F2F3F5;
    transform: scale(1.15);
}

.comments-section .cmt-reactions.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.comments-section .comment-list .children {
    margin-left: 20px;
    padding-left: 12px;
    border-left: 2px solid #EDEDED;
    list-style: none;
}

.comments-section .cmt-expand {
    margin: 6px 0 0 20px;
    height: 32px;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: #F2F3F5;
    color: #0B5DD7;
    font: 14px -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
    cursor: pointer;
    transition: background-color 0.2s;
}

.comments-section .cmt-expand:hover {
    background-color: #E8EAEE;
}

.comments-section .cmt-item {
    transition: background-color 1s ease;
    border-radius: 12px;
}

.comments-section .cmt-item.is-new {
    background: rgba(11, 93, 215, 0.08);
}

.comments-section .cmt-item.is-new .cmt-time::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 6px;
    border-radius: 50%;
    background: #0B5DD7;
    vertical-align: middle;
}

.comments-section li:target > .cmt-item {
    outline: 2px solid rgba(11, 93, 215, 0.35);
    outline-offset: 4px;
}

.comments-section .cmt-attach {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.comments-section .cmt-attach-btn {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: #F2F3F5;
    color: #0B5DD7;
    font-size: 14px;
    cursor: pointer;
    border: 0;
    transition: background-color 0.2s;
}

.comments-section .cmt-attach-btn:hover {
    background-color: #E8EAEE;
}

.comments-section .cmt-attach-btn:focus-within {
    outline: 3px solid #0B5DD7;
    outline-offset: 2px;
}

.comments-section .cmt-photo-preview {
    position: relative;
    display: inline-block;
}

.comments-section .cmt-photo-preview[hidden] {
    display: none;
}

.comments-section .cmt-photo-preview img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

.comments-section .cmt-photo-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 0;
    background: #000;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    transition: background-color 0.2s;
}

.comments-section .cmt-photo-remove:hover {
    background-color: #333;
}

.comments-section #comment {
    resize: vertical;
    min-height: 44px;
    max-height: 240px;
    overflow: auto;
}

.comments-section .cmt-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    background: #1f2328;
    color: #fff;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}

.comments-section .cmt-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.comments-section .cmt-sort-link:focus-visible,
.comments-section .cmt-reaction:focus-visible,
.comments-section .cmt-reaction-add:focus-visible,
.comments-section .cmt-reaction-option:focus-visible,
.comments-section .cmt-expand:focus-visible,
.comments-section .cmt-attach-btn:focus-visible,
.comments-section .cmt-photo-remove:focus-visible,
.comments-section .cmt-time:focus-visible {
    outline: 3px solid #0B5DD7;
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .comments-section .comment-list .children {
        margin-left: 8px;
        padding-left: 8px;
    }

    .comments-section .cmt-reaction {
        height: 28px;
        padding: 0 8px;
        font-size: 12px;
    }

    .comments-section .cmt-photo {
        max-width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .comments-section .cmt-item,
    .comments-section .cmt-reaction-option,
    .comments-section .cmt-toast {
        transition: none;
    }
}

/* Мобильная карточка: шапка (аватар + имя/дата/статус) по центру аватара, тело — во всю ширину от края аватара. */
@media (max-width: 600px) {
    html body.nd .nd-post-comments .comment-item { display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 10px; align-items: center; }
    html body.nd .nd-post-comments .comment-item > div { display: contents; }
    html body.nd .nd-post-comments .comment-item > .avatar { grid-column: 1; grid-row: 1; }
    html body.nd .nd-post-comments .comment-meta { grid-column: 2; grid-row: 1; align-items: baseline; column-gap: 8px; row-gap: 0; }
    html body.nd .nd-post-comments .comment-meta strong { order: 1; }
    html body.nd .nd-post-comments .comment-meta .cmt-time { order: 2; }
    html body.nd .nd-post-comments .comment-meta .comment-edited { order: 3; }
    html body.nd .nd-post-comments .comment-meta .tag { order: 4; flex-basis: 100%; height: auto; padding: 0; background: none; border-radius: 0; font-size: 13px; line-height: 18px; color: #808080; }
    html body.nd .nd-post-comments .comment-text,
    html body.nd .nd-post-comments .cmt-photo,
    html body.nd .nd-post-comments .comment-controls { grid-column: 1 / -1; }
    html body.nd .nd-post-comments .comment-text { margin-top: 10px; }
}
