.kg-app-v2 .kg-message-row {
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    box-sizing: border-box;
}

.kg-app-v2 .kg-message-row.is-highlighted,
.channel-discussion-row.is-highlighted {
    animation: kg-message-highlight 1.2s ease;
}

.kg-app-v2 .kg-message-row.is-reply-target .msg,
.channel-discussion-row.is-reply-target .msg {
    box-shadow: 0 0 0 2px rgba(178, 145, 255, 0.58), 0 12px 28px rgba(100, 74, 170, 0.18);
    background-image: linear-gradient(135deg, rgba(178, 145, 255, 0.20), rgba(58, 74, 130, 0.12));
}

@keyframes kg-message-highlight {
    0%, 100% { filter: none; }
    35% { filter: drop-shadow(0 0 16px rgba(92, 148, 255, 0.55)); }
}

.kg-app-v2 .msg {
    transition: transform 0.18s ease;
}

.kg-app-v2 .msg.kg-swipe-active,
.channel-discussion-row .msg.kg-swipe-active {
    position: relative;
    z-index: 2;
    will-change: transform;
}

.kg-app-v2 .msg.kg-swipe-active::after,
.channel-discussion-row .msg.kg-swipe-active::after {
    content: "↩";
    position: absolute;
    right: -34px;
    top: 50%;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(143, 129, 255, 0.78);
    color: white;
    font-size: 1.1rem;
    font-weight: 900;
    opacity: var(--kg-swipe-progress, 0);
    transform: translateY(-50%) scale(0.92);
    box-shadow: 0 8px 22px rgba(78, 116, 255, 0.28);
    pointer-events: none;
}

.kg-app-v2 .msg.kg-swipe-ready::after,
.channel-discussion-row .msg.kg-swipe-ready::after {
    background: rgba(143, 129, 255, 0.95);
}

.msg-reply-preview {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin: 0 0 6px;
    padding: 7px 9px;
    border: 0;
    border-left: 3px solid #78a6ff;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.08);
    color: #dfe8ff;
    text-align: left;
    cursor: pointer;
}

.msg-reply-preview strong,
.msg-reply-preview span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-reply-preview span {
    color: #b8c2d8;
    font-size: 0.9rem;
}

#reply-bar-desktop,
.comment-reply-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 6px;
    padding: 6px 10px;
    border-left: 3px solid rgba(178, 145, 255, 0.95);
    border-radius: 12px;
    background: rgba(52, 60, 99, 0.54) !important;
    color: white;
}

#reply-bar-desktop.hidden,
.comment-reply-bar.hidden {
    display: none !important;
}

#reply-preview-desktop,
#reply-comment-preview,
#channel-discussion-reply-preview,
.reply-bar-container {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

#reply-preview-desktop,
#reply-comment-preview,
#channel-discussion-reply-preview {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    white-space: nowrap;
    text-overflow: ellipsis;
}

#reply-preview-desktop strong,
#reply-comment-preview strong,
#channel-discussion-reply-preview strong {
    color: #b291ff;
    flex: 0 0 auto;
}

#reply-preview-desktop span,
#reply-comment-preview span,
#channel-discussion-reply-preview span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

#reply-bar-desktop button,
.comment-reply-bar button {
    width: auto !important;
    min-width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08) !important;
    color: white;
    cursor: pointer;
}

@media (max-width: 1000px) {
    #reply-bar-desktop,
    .comment-reply-bar {
        min-width: 0;
        overflow: hidden;
        gap: 6px;
        padding: 5px 7px;
    }

    #reply-bar-desktop > div,
    .comment-reply-bar .reply-bar-container {
        min-width: 0;
        max-width: calc(100% - 40px);
        overflow: hidden;
    }

    #reply-preview-desktop,
    #reply-comment-preview,
    #channel-discussion-reply-preview {
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
    }

    #reply-preview-desktop strong,
    #reply-preview-desktop span,
    #reply-comment-preview strong,
    #reply-comment-preview span,
    #channel-discussion-reply-preview strong,
    #channel-discussion-reply-preview span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #reply-bar-desktop button,
    .comment-reply-bar button {
        flex: 0 0 34px;
        min-width: 34px;
    }
}

.message-reactions,
.comment-reactions-block {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.message-reaction-chip,
.comment-reaction-pill {
    width: auto !important;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #edf3ff;
    cursor: pointer;
}

.message-reaction-chip.is-active,
.comment-reaction-pill.is-active {
    background: rgba(78, 139, 255, 0.34);
}

.kg-message-context-menu .context-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px;
}

.kg-message-context-menu {
    z-index: 9999999;
    min-width: 180px;
    padding: 6px;
    border-radius: 14px;
}

.kg-message-context-menu button {
    width: 100%;
    min-height: 34px;
    border-radius: 10px;
    padding: 7px 10px;
    font-size: 1rem;
}

.voice-recording-modal,
.circle-recording-modal {
    z-index: 9999998;
}

.kg-message-context-menu .context-reaction {
    width: 34px;
    min-width: 34px;
    height: 34px;
    justify-content: center;
    padding: 0;
    font-size: 1.05rem;
}

.kg-app-v2 .kg-message-row--me {
    justify-content: flex-end;
    padding-right: 15%;
}

.kg-app-v2 .kg-message-row--other {
    justify-content: flex-start;
    padding-left: 18%;
}

.kg-app-v2 .kg-message-avatar-slot {
    width: 38px;
    min-width: 38px;
    display: flex;
    justify-content: center;
}

.kg-app-v2 .msg-sender-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
}

.kg-app-v2 .kg-message-stack {
    max-width: min(620px, 64%);
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.kg-app-v2 .kg-message-row--me .kg-message-stack {
    align-items: flex-end;
}

.kg-app-v2 .kg-message-row--other .kg-message-stack {
    align-items: flex-start;
}

.kg-app-v2 #chat-window .kg-message-row .msg {
    max-width: 100%;
    margin: 0;
    box-sizing: border-box;
}

.kg-app-v2 #chat-window .kg-message-row--me .msg {
    align-self: flex-end;
    color: white;
}

.kg-app-v2 #chat-window .kg-message-row--other .msg {
    align-self: flex-start;
}

.kg-app-v2 .kg-message-row--has-next .msg--other {
    border-bottom-left-radius: 7px;
}

.kg-app-v2 .kg-message-row--has-next .msg--me {
    border-bottom-right-radius: 7px;
}

.kg-app-v2 .kg-message-row--continued .msg--other {
    border-top-left-radius: 7px;
}

.kg-app-v2 .kg-message-row--continued .msg--me {
    border-top-right-radius: 7px;
}

.kg-app-v2 .msg-sender {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
}

.kg-app-v2 .msg-sender-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    padding-left: 0;
    color: #dce8ff;
    font-weight: 800;
    font-size: 0.92rem;
}

.kg-app-v2 .msg-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.kg-app-v2 .msg-time {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    float: right;
    margin-left: 10px;
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.58);
    font-size: 0.72rem;
    line-height: 1;
    white-space: nowrap;
}

.kg-app-v2 .msg-read-status {
    color: rgba(255, 255, 255, 0.72);
    font-weight: 800;
}

.kg-app-v2 .msg-read-status--read {
    color: #a0a0ff;
}

.kg-app-v2 .msg-read-status--pending {
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.68rem;
}

.kg-app-v2 .msg-read-status--failed {
    color: #ff8b8b;
}

.kg-app-v2 .msg--pending {
    opacity: 0.72;
}

.kg-app-v2 .msg--failed {
    outline: 1px solid rgba(255, 139, 139, 0.55);
}

.kg-app-v2 .chat-role-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 1px solid rgba(242, 184, 139, 0.38);
    border-radius: 999px;
    font-size: 0.76rem;
    line-height: 1;
    font-weight: 800;
}
