/* 群聊与单聊统一消息布局修复 */

/* 外层容器：横向 Flex，头像在左，内容区在右 */
#echo .msg-row.other,
#echo .msg-row.ai {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start !important;
    gap: 10px !important;
    margin-bottom: 8px !important;
}

/* 头像固定尺寸，不收缩，顶部对齐 */
#echo .msg-row.other .msg-avatar,
#echo .msg-row.ai .msg-avatar,
#echo .msg-row.other .chat-avatar,
#echo .msg-row.ai .chat-avatar {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    margin-top: 0 !important;
    align-self: flex-start !important;
}

/* 右侧主内容区：纵向 Flex，名字在上，气泡在下 */
#echo .msg-row.other .msg-main-content,
#echo .msg-row.ai .msg-main-content,
#echo .msg-row.other .msg-bubble-wrap,
#echo .msg-row.ai .msg-bubble-wrap {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
    flex: 1 !important;
    min-width: 0 !important;
}

/* 名字标签：紧贴气泡上方 */
#echo .msg-row.other .name-tag,
#echo .msg-row.ai .name-tag {
    font-size: 12px !important;
    color: #999 !important;
    margin: 0 !important;
    padding: 0 4px !important;
    line-height: 1 !important;
    position: static !important;
}

/* 气泡本体：确保顶部对齐 */
#echo .msg-row.other .msg-content,
#echo .msg-row.other .speech-bubble,
#echo .msg-row.other .msg-bubble,
#echo .msg-row.ai .msg-content,
#echo .msg-row.ai .speech-bubble,
#echo .msg-row.ai .msg-bubble {
    margin: 0 !important;
    padding: 12px 16px !important;
    align-self: flex-start !important;
}

/* 单聊无名字时，气泡直接与头像顶部对齐 */
#echo .msg-row.other:not(:has(.name-tag)) .msg-main-content,
#echo .msg-row.other:not(:has(.name-tag)) .msg-bubble-wrap,
#echo .msg-row.ai:not(:has(.name-tag)) .msg-main-content,
#echo .msg-row.ai:not(:has(.name-tag)) .msg-bubble-wrap {
    margin-top: 0 !important;
}
