/* ========================================
   聊天室样式 - 商业级现代设计
   适配 Zibll 深色主题
======================================== */

/* CSS变量定义 */
:root {
    --chat-primary: #1890ff;
    --chat-primary-hover: #40a9ff;
    --chat-primary-active: #096dd9;
    --chat-success: #52c41a;
    --chat-warning: #faad14;
    --chat-error: #ff4d4f;
    --chat-bg-1: #ffffff;
    --chat-bg-2: #fafafa;
    --chat-bg-3: #f5f5f5;
    --chat-border: #e8e8e8;
    --chat-border-light: #f0f0f0;
    --chat-text-1: #262626;
    --chat-text-2: #595959;
    --chat-text-3: #8c8c8c;
    --chat-text-4: #bfbfbf;
    --chat-shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
    --chat-shadow-md: 0 4px 16px rgba(0,0,0,0.12);
    --chat-shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
    --chat-radius-sm: 4px;
    --chat-radius-md: 8px;
    --chat-radius-lg: 12px;
    --chat-msg-self-bg: #1890ff;
    --chat-msg-other-bg: #ffffff;
}

/* 深色主题 - 适配Zibll */
.dark-theme,
body.dark-theme {
    --chat-primary: #1890ff;
    --chat-primary-hover: #40a9ff;
    --chat-primary-active: #096dd9;
    --chat-bg-1: #1f1f1f;
    --chat-bg-2: #2a2a2a;
    --chat-bg-3: #323232;
    --chat-border: #3a3a3a;
    --chat-border-light: #2f2f2f;
    --chat-text-1: #e8e8e8;
    --chat-text-2: #b8b8b8;
    --chat-text-3: #8c8c8c;
    --chat-text-4: #5c5c5c;
    --chat-shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --chat-shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --chat-shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
    --chat-msg-other-bg: #2a2a2a;
}

/* ========================================
   基础容器
======================================== */
.knn-chat {
    position: fixed;
    bottom: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
.knn-chat.pos-right { right: 20px; }
.knn-chat.pos-left { left: 20px; }

/* ========================================
   悬浮按钮
======================================== */
.chat-btn {
    width: 54px;
    height: 54px;
    background: var(--chat-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--chat-shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}
.chat-btn:hover {
    background: var(--chat-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--chat-shadow-lg);
}
.chat-btn:active {
    transform: translateY(0);
}
.chat-btn i {
    color: #fff;
    font-size: 22px;
}
.chat-btn .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--chat-error);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--chat-bg-1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* ========================================
   聊天窗口主体 - 居中弹窗式
======================================== */
.chat-box {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 550px;
    height: 550px;
    background: var(--chat-bg-1);
    border-radius: var(--chat-radius-lg);
    box-shadow: var(--chat-shadow-lg);
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--chat-border);
    z-index: 99998;
}
.chat-box.open {
    display: flex;
    animation: chatBoxIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chatBoxIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* 遮罩层 */
.chat-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99997;
    backdrop-filter: blur(2px);
}
.chat-backdrop.open {
    display: block;
    animation: backdropFadeIn 0.3s ease;
}
@keyframes backdropFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   头部区域
======================================== */
.chat-head {
    padding: 14px 16px;
    background: var(--chat-bg-1);
    border-bottom: 1px solid var(--chat-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.chat-head span {
    font-size: 15px;
    font-weight: 600;
    color: var(--chat-text-1);
    display: flex;
    align-items: center;
    gap: 8px;
}
.chat-head span i {
    color: var(--chat-primary);
    font-size: 18px;
}
.chat-close {
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: var(--chat-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--chat-text-3);
}
.chat-close:hover {
    background: var(--chat-bg-3);
    color: var(--chat-text-1);
}
.chat-close i {
    font-size: 16px;
}

/* 在线人数 */
.online-count {
    font-size: 12px;
    font-weight: 400;
    color: var(--chat-text-3);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.online-dot {
    width: 6px;
    height: 6px;
    background: var(--chat-success);
    border-radius: 50%;
    display: inline-block;
    animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.9); }
}

/* ========================================
   消息区域
======================================== */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--chat-bg-2);
    scroll-behavior: smooth;
}
.chat-body::-webkit-scrollbar {
    width: 6px;
}
.chat-body::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}
.chat-body::-webkit-scrollbar-thumb:hover {
    background: var(--chat-text-4);
}
.chat-body::-webkit-scrollbar-track {
    background: transparent;
}

/* 消息项 */
.chat-msg {
    display: flex;
    margin-bottom: 16px;
    align-items: flex-start;
    animation: msgSlideIn 0.3s ease;
}
@keyframes msgSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-msg .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background: var(--chat-bg-3);
    border: 1px solid var(--chat-border-light);
}

.chat-msg .content {
    max-width: calc(100% - 50px);
    display: flex;
    flex-direction: column;
}

.chat-msg .head {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    gap: 6px;
}

.chat-msg .name {
    font-size: 12px;
    font-weight: 500;
    color: var(--chat-text-2);
}

.chat-msg .time {
    font-size: 11px;
    color: var(--chat-text-3);
}

.chat-msg .text {
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    position: relative;
    border-radius: var(--chat-radius-md);
}

.chat-msg .del {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s;
    padding: 4px 6px;
    border-radius: var(--chat-radius-sm);
}
.chat-msg:hover .del { opacity: 1; }
.chat-msg .del:hover { background: var(--chat-error); }

/* 别人的消息 */
.chat-msg.other {
    flex-direction: row;
}
.chat-msg.other .avatar {
    margin-right: 10px;
}
.chat-msg.other .text {
    background: var(--chat-msg-other-bg);
    color: var(--chat-text-1);
    border: 1px solid var(--chat-border-light);
    border-radius: 0 var(--chat-radius-md) var(--chat-radius-md) var(--chat-radius-md);
}
.chat-msg.other .del {
    right: -30px;
}

/* 自己的消息 */
.chat-msg.self {
    flex-direction: row-reverse;
}
.chat-msg.self .avatar {
    margin-left: 10px;
}
.chat-msg.self .content {
    align-items: flex-end;
}
.chat-msg.self .text {
    background: var(--chat-msg-self-bg);
    color: #fff;
    border-radius: var(--chat-radius-md) 0 var(--chat-radius-md) var(--chat-radius-md);
}
.chat-msg.self .del {
    left: -30px;
}

/* ========================================
   底部输入区
======================================== */
.chat-foot {
    padding: 12px 16px;
    background: var(--chat-bg-1);
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
    position: relative;
}

/* 工具栏 */
.chat-toolbar {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}
.tool-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: var(--chat-radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--chat-text-3);
    transition: all 0.2s;
    font-size: 16px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.tool-btn:hover {
    background: var(--chat-bg-3);
    color: var(--chat-primary);
}
.tool-btn:active {
    transform: scale(0.95);
}

/* 输入框区域 */
.chat-foot-inner {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.chat-foot textarea {
    flex: 1;
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius-md);
    padding: 10px 12px;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    max-height: 80px;
    min-height: 40px;
    outline: none;
    transition: all 0.2s;
    font-family: inherit;
    color: var(--chat-text-1);
    background: var(--chat-bg-1);
}
.chat-foot textarea:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 2px rgba(24,144,255,0.1);
}
.chat-foot textarea::placeholder {
    color: var(--chat-text-4);
}
.chat-foot button#chat-send {
    height: 40px;
    padding: 0 18px;
    background: var(--chat-primary);
    color: #fff;
    border: none;
    border-radius: var(--chat-radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-foot button#chat-send:hover {
    background: var(--chat-primary-hover);
}
.chat-foot button#chat-send:active {
    background: var(--chat-primary-active);
}
.chat-foot button#chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 登录提示 */
.chat-tip {
    text-align: center;
    padding: 12px;
    color: var(--chat-text-3);
    font-size: 13px;
}
.chat-tip a {
    color: var(--chat-primary);
    text-decoration: none;
    font-weight: 500;
}
.chat-tip a:hover {
    text-decoration: underline;
}

/* ========================================
   卡片消息
======================================== */
.msg-card {
    display: flex;
    background: var(--chat-bg-1);
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius-md);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    max-width: 240px;
}
.msg-card:hover {
    box-shadow: var(--chat-shadow-sm);
    transform: translateY(-1px);
    border-color: var(--chat-primary);
}
.card-thumb {
    width: 70px;
    height: 70px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--chat-bg-3);
}
.card-info {
    flex: 1;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}
.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-text-1);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-desc {
    font-size: 11px;
    color: var(--chat-text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 4px 0;
}
.card-foot {
    display: flex;
    align-items: center;
    gap: 6px;
}
.card-tag {
    font-size: 10px;
    padding: 2px 6px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: #fff;
    border-radius: var(--chat-radius-sm);
    font-weight: 500;
}
.card-price {
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-error);
}

/* ========================================
   图片消息
======================================== */
.msg-image {
    max-width: 200px;
    border-radius: var(--chat-radius-md);
    overflow: hidden;
    cursor: zoom-in;
    transition: all 0.2s;
}
.msg-image:hover {
    transform: translateY(-2px);
    box-shadow: var(--chat-shadow-sm);
}
.msg-image img {
    display: block;
    max-width: 100%;
    border-radius: var(--chat-radius-md);
    background: var(--chat-bg-3);
}

/* 图片灯箱 */
.chat-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 100002;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    backdrop-filter: blur(4px);
}
.chat-lightbox.open { display: flex; }
.chat-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: var(--chat-radius-md);
    object-fit: contain;
}
.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}
.lightbox-close:hover {
    background: rgba(255,255,255,0.25);
}

/* ========================================
   红包卡片样式
======================================== */
.msg-red-packet {
    width: 260px;
    border-radius: var(--chat-radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
}
.msg-red-packet:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.4);
}

.rp-card-top {
    display: flex;
    align-items: center;
    padding: 16px;
    gap: 12px;
}
.rp-icon {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
}
.rp-icon i {
    color: #ffd700;
    font-size: 22px;
}
.rp-info {
    flex: 1;
    min-width: 0;
}
.rp-greeting {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rp-status-text {
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    margin-top: 4px;
}
.rp-card-bottom {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(0, 0, 0, 0.15);
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    backdrop-filter: blur(10px);
}

/* 红包状态样式 */
.msg-red-packet.rp-active {
    animation: rp-pulse 2s ease-in-out infinite;
}
@keyframes rp-pulse {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(255, 107, 107, 0.6);
    }
}
.msg-red-packet.rp-claimed,
.msg-red-packet.rp-self {
    opacity: 0.8;
}
.msg-red-packet.rp-finished,
.msg-red-packet.rp-expired {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    opacity: 0.75;
}
.msg-red-packet.rp-finished .rp-icon i,
.msg-red-packet.rp-expired .rp-icon i {
    color: #d1d5db;
}

/* 领取动画 */
.rp-claim-anim {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: #ffd700;
    font-size: 28px;
    font-weight: 700;
    padding: 20px 40px;
    border-radius: var(--chat-radius-lg);
    z-index: 100001;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    box-shadow: 0 8px 32px rgba(255, 107, 107, 0.5);
}
.rp-claim-anim.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ========================================
   红包弹窗样式
======================================== */
/* 发送红包弹窗 */
.rp-modal,
.rp-detail-modal,
.rp-open-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}
.rp-modal.open,
.rp-detail-modal.open,
.rp-open-modal.open {
    display: flex;
    animation: modalFadeIn 0.2s ease;
}
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.rp-modal-content {
    width: 360px;
    max-width: 90vw;
    background: var(--chat-bg-1);
    border-radius: var(--chat-radius-lg);
    overflow: hidden;
    box-shadow: var(--chat-shadow-lg);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.rp-modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: #fff;
}
.rp-modal-head span {
    font-size: 16px;
    font-weight: 600;
}
.rp-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--chat-radius-sm);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: all 0.2s;
}
.rp-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.rp-modal-body {
    padding: 20px;
}
.rp-form-group {
    margin-bottom: 16px;
}
.rp-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--chat-text-1);
    margin-bottom: 8px;
}
.rp-form-group select,
.rp-form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius-md);
    font-size: 14px;
    background: var(--chat-bg-1);
    color: var(--chat-text-1);
    box-sizing: border-box;
    transition: all 0.2s;
}
.rp-form-group select:focus,
.rp-form-group input:focus {
    outline: none;
    border-color: #ff6b6b;
    box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.1);
}
.rp-summary {
    padding: 12px;
    margin-bottom: 16px;
    background: rgba(255, 107, 107, 0.08);
    border-radius: var(--chat-radius-md);
    font-size: 13px;
    color: var(--chat-text-2);
    text-align: center;
    line-height: 1.6;
    border: 1px solid rgba(255, 107, 107, 0.15);
}
.rp-send-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: #fff;
    border: none;
    border-radius: var(--chat-radius-md);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.rp-send-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}
.rp-send-btn:active {
    transform: translateY(0);
}
.rp-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   红包详情弹窗
======================================== */
.rp-detail-content {
    width: 360px;
    max-width: 90vw;
    max-height: 80vh;
    background: var(--chat-bg-1);
    border-radius: var(--chat-radius-lg);
    overflow: hidden;
    box-shadow: var(--chat-shadow-lg);
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rp-detail-head {
    padding: 20px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
    color: #fff;
    flex-shrink: 0;
}
.rp-detail-sender {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.rp-detail-sender img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}
.rp-detail-name {
    font-size: 16px;
    font-weight: 600;
}
.rp-detail-greeting {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 4px;
}
.rp-detail-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    opacity: 0.95;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    gap: 8px;
}
.rp-detail-info span {
    flex: 1;
}
.rp-detail-status {
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 11px;
    white-space: nowrap;
}
.rp-detail-remaining {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    padding-top: 8px;
    text-align: center;
}

.rp-detail-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    max-height: 320px;
}
.rp-detail-list::-webkit-scrollbar {
    width: 6px;
}
.rp-detail-list::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}
.rp-detail-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    gap: 12px;
    border-bottom: 1px solid var(--chat-border-light);
}
.rp-detail-item:last-child {
    border-bottom: none;
}
.rp-detail-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--chat-bg-3);
    border: 1px solid var(--chat-border-light);
}
.rp-detail-item-info {
    flex: 1;
    min-width: 0;
}
.rp-detail-item-info span:first-child {
    font-size: 14px;
    font-weight: 500;
    color: var(--chat-text-1);
}
.rp-detail-time {
    font-size: 11px;
    color: var(--chat-text-3);
    margin-left: 8px;
}
.rp-detail-amount {
    font-size: 15px;
    font-weight: 600;
    color: #ff6b6b;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}
.rp-best-luck {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    background: #ffd700;
    color: #8b4513;
    border-radius: var(--chat-radius-sm);
    font-weight: 600;
}
.rp-detail-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--chat-text-3);
    font-size: 13px;
}
.rp-detail-close {
    margin: 12px 20px 16px;
    padding: 10px;
    background: var(--chat-bg-3);
    border: none;
    border-radius: var(--chat-radius-md);
    color: var(--chat-text-1);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.rp-detail-close:hover {
    background: var(--chat-border);
}

/* ========================================
   拆红包弹窗（微信风格）
======================================== */
.rp-open-content {
    width: 300px;
    background: linear-gradient(180deg, #d84a3e 0%, #e85b4f 40%, #d84a3e 100%);
    border-radius: var(--chat-radius-lg);
    text-align: center;
    padding: 32px 24px 24px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: rp-open-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes rp-open-in {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.rp-open-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    transition: all 0.2s;
    backdrop-filter: blur(10px);
}
.rp-open-close:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.rp-open-sender {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 16px;
}
.rp-open-sender img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}
.rp-open-sender span {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
}

.rp-open-greeting {
    color: rgba(255, 255, 255, 0.95);
    font-size: 15px;
    margin-bottom: 32px;
    line-height: 1.5;
    min-height: 24px;
}

.rp-open-btn-wrap {
    position: relative;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.rp-open-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #f7c948, #e8a820);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 32px;
    color: #d84a3e;
    box-shadow: 0 4px 20px rgba(232, 168, 32, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}
.rp-open-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(232, 168, 32, 0.7);
}
.rp-open-btn:active {
    transform: scale(1.02);
}
.rp-open-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}
.rp-open-btn.rp-opening {
    animation: rp-spin 0.8s linear infinite;
}
@keyframes rp-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.rp-open-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #d84a3e;
    font-size: 22px;
    font-weight: 700;
    pointer-events: none;
    z-index: 2;
}

.rp-open-footer {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

/* ========================================
   表情选择器
======================================== */
.emoji-picker {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 8px;
    width: 320px;
    background: var(--chat-bg-1);
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius-lg);
    box-shadow: var(--chat-shadow-lg);
    z-index: 100001;
}
.emoji-picker.open {
    display: block;
    animation: emojiPickerIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes emojiPickerIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.emoji-picker-content {
    display: flex;
    flex-direction: column;
    max-height: 300px;
}
.emoji-picker-tabs {
    display: flex;
    border-bottom: 1px solid var(--chat-border);
    padding: 8px;
    gap: 4px;
    background: var(--chat-bg-2);
    border-radius: var(--chat-radius-lg) var(--chat-radius-lg) 0 0;
}
.emoji-tab {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: var(--chat-radius-sm);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.emoji-tab:hover {
    background: var(--chat-bg-3);
}
.emoji-tab.active {
    background: var(--chat-primary);
}
.emoji-tab:active {
    transform: scale(0.95);
}
.emoji-picker-body {
    padding: 12px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
    max-height: 240px;
}
.emoji-picker-body::-webkit-scrollbar {
    width: 6px;
}
.emoji-picker-body::-webkit-scrollbar-thumb {
    background: var(--chat-border);
    border-radius: 3px;
}
.emoji-item {
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: var(--chat-radius-sm);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.emoji-item:hover {
    background: var(--chat-bg-3);
    transform: scale(1.2);
}
.emoji-item:active {
    transform: scale(1.1);
}

/* ========================================
   响应式设计
======================================== */
@media (max-width: 480px) {
    .knn-chat {
        bottom: 16px;
    }
    .knn-chat.pos-right { right: 16px; }
    .knn-chat.pos-left { left: 16px; }
    .chat-box {
        width: calc(100vw - 32px);
        height: calc(100vh - 100px);
        max-height: none;
    }
    .msg-red-packet { width: 220px; }
    .msg-image { max-width: 160px; }
    .msg-card { max-width: 200px; }
    .rp-modal-content,
    .rp-detail-content,
    .rp-open-content {
        width: calc(100vw - 32px);
    }
}
