/* ══════════════════════════════════════
   聊天功能样式 - 与主站主题统一
   ══════════════════════════════════════ */

/* ── 聊天浮窗（通用组件） ── */
.chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 28, 28, 0.4);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.chat-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.chat-window {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 48px);
    background: var(--cream, #FDFBF7);
    border: 1px solid var(--border, #D6D3CE);
    border-radius: var(--radius, 4px);
    box-shadow: 0 12px 40px rgba(28, 28, 28, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000;
    transform: translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.chat-window.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* 头部 */
.chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--pine, #2D6A4F);
    color: #fff;
    flex-shrink: 0;
}
.chat-header-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius, 4px);
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}
.chat-header-info {
    flex: 1;
    min-width: 0;
}
.chat-header-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-header-product {
    font-size: 12px;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.chat-header-close {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius, 4px);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}
.chat-header-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 商品信息条 */
.chat-product-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--wheat, #F5ECD7);
    border-bottom: 1px solid var(--border, #D6D3CE);
    flex-shrink: 0;
}
.chat-product-bar img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius, 4px);
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border, #D6D3CE);
}
.chat-product-bar-info {
    flex: 1;
    min-width: 0;
}
.chat-product-bar-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink, #1C1C1C);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-product-bar-price {
    font-size: 12px;
    color: var(--clay, #D97059);
    font-weight: 500;
}
.chat-product-bar-link {
    font-size: 12px;
    color: var(--pine, #2D6A4F);
    text-decoration: none;
    flex-shrink: 0;
}
.chat-product-bar-link:hover {
    text-decoration: underline;
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border, #D6D3CE);
    border-radius: 2px;
}

/* 加载更多 */
.chat-load-more {
    text-align: center;
    padding: 4px 0 8px;
}
.chat-load-more button {
    background: none;
    border: 1px solid var(--border, #D6D3CE);
    color: var(--stone, #78716C);
    font-size: 12px;
    padding: 4px 14px;
    border-radius: var(--radius, 4px);
    cursor: pointer;
    transition: all 0.15s;
}
.chat-load-more button:hover {
    background: var(--sage, #E8F0EB);
    color: var(--ink, #1C1C1C);
}

/* 消息气泡 */
.chat-msg {
    display: flex;
    gap: 8px;
    max-width: 80%;
}
.chat-msg.self {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.chat-msg-bubble {
    padding: 8px 12px;
    border-radius: var(--radius, 4px);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.chat-msg:not(.self) .chat-msg-bubble {
    background: #fff;
    color: var(--ink, #1C1C1C);
    border: 1px solid var(--border, #D6D3CE);
}
.chat-msg.self .chat-msg-bubble {
    background: var(--pine, #2D6A4F);
    color: #fff;
}
.chat-msg-time {
    font-size: 11px;
    color: var(--stone, #78716C);
    margin-top: 4px;
}
.chat-msg:not(.self) .chat-msg-time {
    text-align: left;
}
.chat-msg.self .chat-msg-time {
    text-align: right;
}

/* 聊天浮窗消息发送状态 */
.chat-msg-time .chat-bubble-status {
    margin-right: 6px;
    vertical-align: middle;
}
.chat-msg.sending .chat-msg-bubble {
    opacity: 0.85;
}
.chat-msg.failed .chat-msg-bubble {
    opacity: 0.7;
}
.chat-msg.failed .chat-msg-time {
    color: #B91C1C;
}

/* 时间分隔线 */
.chat-time-divider {
    text-align: center;
    font-size: 11px;
    color: var(--stone, #78716C);
    padding: 8px 0;
    position: relative;
}
.chat-time-divider::before,
.chat-time-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: calc(50% - 36px);
    height: 1px;
    background: var(--border, #D6D3CE);
}
.chat-time-divider::before { left: 0; }
.chat-time-divider::after  { right: 0; }

/* 输入区域 */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid var(--border, #D6D3CE);
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    border: 1px solid var(--border, #D6D3CE);
    border-radius: var(--radius, 4px);
    padding: 8px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.15s;
    background: var(--cream, #FDFBF7);
}
.chat-input:focus {
    border-color: var(--pine, #2D6A4F);
}
.chat-input::placeholder {
    color: var(--stone, #78716C);
}
.chat-send-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: linear-gradient(135deg, #315743 0%, #2a4a3a 100%);
    color: #fff;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: 0 4px 12px rgba(49, 87, 67, 0.25);
}
.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(49, 87, 67, 0.35);
}
.chat-send-btn:active {
    transform: translateY(0);
}
.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.chat-send-btn svg {
    width: 18px;
    height: 18px;
}

/* 连接状态 */
.chat-status {
    text-align: center;
    font-size: 12px;
    padding: 6px;
    color: var(--stone, #78716C);
}
.chat-status.connected {
    color: var(--pine, #2D6A4F);
}
.chat-status.error {
    color: #B91C1C;
}

/* 空状态 */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--stone, #78716C);
    gap: 8px;
    padding: 40px 20px;
}
.chat-empty-icon {
    font-size: 32px;
    opacity: 0.3;
}
.chat-empty-text {
    font-size: 14px;
}

/* ── 消息中心页面（market 主题） ── */
.chat-hero {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 22px;
}
.chat-hero .hero-copy {
    max-width: 680px;
}
.chat-hero h1 {
    max-width: 14ch;
    font-size: clamp(32px, 4vw, 52px);
    line-height: 1.08;
}
.chat-hero p {
    max-width: 48ch;
}

/* 会话列表 */
.conv-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.conv-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: linear-gradient(180deg, rgba(255, 250, 244, 0.98), rgba(248, 241, 230, 0.98));
    border: 1px solid rgba(41, 28, 18, 0.1);
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    text-decoration: none;
    color: inherit;
}
.conv-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(56, 37, 23, 0.1);
    border-color: rgba(49, 87, 67, 0.22);
}
.conv-item.active {
    border-color: var(--pine, #315743);
    box-shadow: 0 0 0 3px rgba(49, 87, 67, 0.12);
    background: linear-gradient(180deg, rgba(255, 252, 247, 1), rgba(245, 238, 226, 1));
}
.conv-item-thumb {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid rgba(41, 28, 18, 0.1);
    box-shadow: 0 4px 12px rgba(56, 37, 23, 0.08);
}
.conv-item-thumb-placeholder {
    background: linear-gradient(135deg, rgba(49, 87, 67, 0.12), rgba(169, 123, 61, 0.12));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: var(--pine, #315743);
}
.conv-item-info {
    flex: 1;
    min-width: 0;
}
.conv-item-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.conv-item-product {
    font-size: 19px;
    font-weight: 800;
    color: var(--ink, #211912);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.conv-item-subhead {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}
.conv-item-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--soft-2, #8a7d71);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* 卖家/买家角色标签 */
.conv-item-role {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    flex-shrink: 0;
    margin-left: 6px;
}
.conv-item-role-seller {
    background: linear-gradient(135deg, rgba(49, 87, 67, 0.12), rgba(49, 87, 67, 0.08));
    color: var(--pine, #315743);
    border: 1px solid rgba(49, 87, 67, 0.2);
}
.conv-item-role-buyer {
    background: linear-gradient(135deg, rgba(217, 112, 89, 0.12), rgba(217, 112, 89, 0.08));
    color: var(--clay, #D97059);
    border: 1px solid rgba(217, 112, 89, 0.2);
}
.conv-item-time {
    font-size: 11px;
    color: var(--soft-2, #8a7d71);
    flex-shrink: 0;
}
.conv-item-msg {
    font-size: 13px;
    color: var(--soft, #695d52);
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 空会话 */
.conv-empty {
    text-align: center;
    padding: 56px 24px;
    color: var(--soft, #695d52);
    border: 1.5px dashed rgba(41, 28, 18, 0.16);
    border-radius: 18px;
    background: rgba(255, 250, 243, 0.76);
}
.conv-empty-icon {
    font-size: 44px;
    opacity: 0.6;
    margin-bottom: 14px;
    animation: emptyFloat 3s ease-in-out infinite;
}
@keyframes emptyFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
.conv-empty-text {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--ink, #211912);
}
.conv-empty-sub {
    font-size: 14px;
    color: var(--soft, #695d52);
}

/* ── 消息中心内嵌聊天面板（market 主题） ── */
.chat-panel {
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(41, 28, 18, 0.12);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 250, 244, 0.98), rgba(248, 241, 230, 0.98));
    margin-top: 18px;
    height: 500px;
    box-shadow: 0 20px 50px rgba(56, 37, 23, 0.08);
    overflow: hidden;
}
.chat-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #315743 0%, #2a4a3a 100%);
    color: #fff;
    flex-shrink: 0;
}
.chat-panel-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}
.chat-panel-info {
    flex: 1;
    min-width: 0;
}
.chat-panel-product {
    font-size: 18px;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-panel-name {
    font-size: 11px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.chat-panel-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.2s;
}
.chat-panel-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.05);
}
.chat-panel-close:active {
    transform: scale(0.95);
}
.chat-panel-close svg {
    width: 16px;
    height: 16px;
}
/* 删除会话按钮（右上角，垃圾箱图标，悬停红色警示） */
.chat-panel-delete {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.2s;
}
.chat-panel-delete:hover {
    background: rgba(231, 76, 60, 0.9);
    transform: scale(1.05);
}
.chat-panel-delete:active {
    transform: scale(0.95);
}
.chat-panel-delete svg {
    width: 16px;
    height: 16px;
}
.chat-panel-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background:
        radial-gradient(circle at 0% 0%, rgba(187, 100, 76, 0.04), transparent 28%),
        radial-gradient(circle at 100% 100%, rgba(49, 87, 67, 0.04), transparent 28%),
        linear-gradient(180deg, #faf4ea 0%, #f6efe3 100%);
}
.chat-panel-messages::-webkit-scrollbar {
    width: 5px;
}
.chat-panel-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-panel-messages::-webkit-scrollbar-thumb {
    background: rgba(41, 28, 18, 0.15);
    border-radius: 3px;
}
.chat-panel-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(41, 28, 18, 0.25);
}
.chat-panel-input {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px;
    border-top: 1px solid rgba(41, 28, 18, 0.1);
    background: rgba(255, 250, 244, 0.98);
    flex-shrink: 0;
}
.chat-textarea {
    flex: 1;
    border: 1.5px solid rgba(41, 28, 18, 0.14);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 88px;
    line-height: 1.5;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: rgba(255, 255, 255, 0.95);
}
.chat-textarea:focus {
    border-color: var(--pine, #315743);
    box-shadow: 0 0 0 3px rgba(49, 87, 67, 0.1);
}
.chat-textarea::placeholder {
    color: #a59a8f;
}
.chat-loading {
    text-align: center;
    color: var(--soft, #695d52);
    font-size: 14px;
    padding: 24px;
}

/* 消息气泡（面板内 - market 主题） */
.chat-bubble {
    max-width: 78%;
    animation: bubbleIn 0.25s ease;
}
@keyframes bubbleIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-bubble.mine {
    align-self: flex-end;
    text-align: right;
}
.chat-bubble-sender {
    font-size: 11px;
    color: var(--soft-2, #8a7d71);
    margin-bottom: 4px;
    font-weight: 600;
}
.chat-bubble-text {
    display: inline-block;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
    text-align: left;
    box-shadow: 0 2px 8px rgba(56, 37, 23, 0.06);
}
.chat-bubble:not(.mine) .chat-bubble-text {
    background: rgba(255, 255, 255, 0.95);
    color: var(--ink, #211912);
    border: 1px solid rgba(41, 28, 18, 0.08);
    border-bottom-left-radius: 4px;
}
.chat-bubble.mine .chat-bubble-text {
    background: linear-gradient(135deg, #315743 0%, #2a4a3a 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble-time {
    font-size: 11px;
    color: var(--soft-2, #8a7d71);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.chat-bubble.mine .chat-bubble-time {
    justify-content: flex-end;
}

/* 消息发送状态 */
.chat-bubble-status {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
}
.chat-bubble-status.sending {
    color: var(--soft-2, #8a7d71);
    font-style: italic;
}
.chat-bubble-status.failed {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: #e74c3c;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    animation: failedShake 0.3s ease;
}
@keyframes failedShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}
.chat-bubble.failed {
    cursor: pointer;
}
.chat-bubble.failed .chat-bubble-text {
    opacity: 0.7;
}

/* ── 敏感词警告（系统提示） ── */
.chat-warning {
    align-self: center;
    max-width: 92%;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 14px;
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.10), rgba(230, 126, 34, 0.10));
    border: 1px solid rgba(231, 76, 60, 0.35);
    border-left: 3px solid #e74c3c;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.6;
    color: #a03d2e;
    animation: warningIn 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97);
    box-shadow: 0 2px 10px rgba(231, 76, 60, 0.12);
}
.chat-warning-icon {
    flex-shrink: 0;
    font-size: 14px;
    line-height: 1.5;
    animation: warningPulse 1.6s ease-in-out 2;
}
.chat-warning-text {
    flex: 1;
    word-break: break-word;
}
@keyframes warningIn {
    0% { opacity: 0; transform: translateY(-6px) scale(0.97); }
    60% { opacity: 1; transform: translateY(1px) scale(1.005); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes warningPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.25); }
}
/* 被屏蔽的消息气泡：弱化显示 + 删除线质感 */
.chat-bubble-text.masked,
.chat-msg-bubble.masked {
    color: #b0453a;
    background: rgba(231, 76, 60, 0.07) !important;
    border: 1px dashed rgba(231, 76, 60, 0.45) !important;
    letter-spacing: 1px;
    font-weight: 600;
}
.chat-bubble.mine .chat-bubble-text.masked {
    background: rgba(231, 76, 60, 0.14) !important;
    color: #ffd9d4;
}

/* ── 联系卖家按钮 ── */
.btn-contact-seller {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: var(--pine, #2D6A4F);
    color: #fff;
    border: none;
    border-radius: var(--radius, 4px);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-contact-seller:hover {
    background: #245540;
}
.btn-contact-seller svg {
    width: 16px;
    height: 16px;
}

/* ── 导航栏消息图标 ── */
.nav-messages-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius, 4px);
    color: var(--ink, #1C1C1C);
    transition: background 0.15s;
}
.nav-messages-link:hover {
    background: var(--sage, #E8F0EB);
}
.nav-messages-link svg {
    width: 18px;
    height: 18px;
}

/* ── 未读消息徽章 ── */
.conv-item-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.35);
    animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ── 铃铛通知图标 ── */
.notification-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    color: var(--ink, #1C1C1C);
    transition: background 0.15s, transform 0.15s;
    text-decoration: none;
}
.notification-bell:hover {
    background: var(--sage, #E8F0EB);
    transform: scale(1.05);
}
.notification-bell svg {
    width: 20px;
    height: 20px;
}
.notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: #e74c3c;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 0 0 2px var(--cream, #FDFBF7);
}
.notification-dot.show {
    opacity: 1;
    transform: scale(1);
    animation: dotPulse 1.5s ease-in-out infinite;
}
@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 0 2px var(--cream, #FDFBF7); }
    50% { box-shadow: 0 0 0 2px var(--cream, #FDFBF7), 0 0 0 5px rgba(231, 76, 60, 0.2); }
}

/* ── 交易信息按钮（输入框左侧） ── */
.chat-trade-btn {
    width: 42px;
    height: 42px;
    border: 1.5px solid rgba(49, 87, 67, 0.25);
    background: linear-gradient(135deg, rgba(49, 87, 67, 0.08), rgba(200, 154, 75, 0.08));
    color: var(--pine, #315743);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}
.chat-trade-btn:hover {
    background: linear-gradient(135deg, rgba(49, 87, 67, 0.15), rgba(200, 154, 75, 0.15));
    border-color: var(--pine, #315743);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(49, 87, 67, 0.18);
}
.chat-trade-btn:active {
    transform: translateY(0);
    box-shadow: none;
}
.chat-trade-btn svg {
    width: 19px;
    height: 19px;
}

/* ══════════════════════════════════════
   交易信息模态框
   ══════════════════════════════════════ */
.trade-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 28, 28, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.trade-modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.trade-modal {
    width: 420px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    background: linear-gradient(180deg, #fffdf9 0%, #faf5ec 100%);
    border: 1px solid rgba(41, 28, 18, 0.12);
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(33, 25, 18, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(16px) scale(0.97);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0.24, 1);
}
.trade-modal-overlay.open .trade-modal {
    transform: translateY(0) scale(1);
}

/* 模态框头部 */
.trade-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #315743 0%, #2a4a3a 100%);
    color: #fff;
    flex-shrink: 0;
}
.trade-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 700;
}
.trade-modal-title svg {
    width: 18px;
    height: 18px;
    opacity: 0.9;
}
.trade-modal-close {
    width: 30px;
    height: 30px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 9px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}
.trade-modal-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.05);
}
.trade-modal-close:active {
    transform: scale(0.95);
}
.trade-modal-close svg {
    width: 15px;
    height: 15px;
}

/* 模态框主体 */
.trade-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.trade-modal-body::-webkit-scrollbar {
    width: 5px;
}
.trade-modal-body::-webkit-scrollbar-thumb {
    background: rgba(41, 28, 18, 0.15);
    border-radius: 3px;
}

/* 表单组 */
.trade-form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.trade-form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink, #211912);
}
.trade-form-required {
    color: #e74c3c;
}
.trade-form-optional {
    color: var(--soft-2, #8a7d71);
    font-weight: 400;
    font-size: 12px;
}
.trade-form-input,
.trade-form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid rgba(41, 28, 18, 0.14);
    border-radius: 11px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ink, #211912);
    background: rgba(255, 255, 255, 0.95);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.trade-form-input:focus,
.trade-form-select:focus {
    border-color: var(--pine, #315743);
    box-shadow: 0 0 0 3px rgba(49, 87, 67, 0.12);
}
.trade-form-input::placeholder {
    color: #a59a8f;
}
.trade-form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a7d71' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}
.trade-form-select:invalid,
.trade-form-select option[value=""] {
    color: #a59a8f;
}

/* 消息预览 */
.trade-form-preview {
    background: rgba(49, 87, 67, 0.05);
    border: 1px dashed rgba(49, 87, 67, 0.25);
    border-radius: 12px;
    padding: 14px;
}
.trade-preview-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--pine, #315743);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.trade-preview-title::before {
    content: '📋';
    font-size: 13px;
}
.trade-preview-content {
    font-size: 13px;
    line-height: 1.7;
    color: var(--soft, #695d52);
    white-space: pre-wrap;
    word-break: break-word;
}
.trade-preview-content.has-content {
    color: var(--ink, #211912);
    font-weight: 500;
}

/* 模态框底部 */
.trade-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid rgba(41, 28, 18, 0.08);
    background: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}
.trade-btn-cancel {
    padding: 10px 22px;
    border: 1.5px solid rgba(41, 28, 18, 0.16);
    background: transparent;
    color: var(--soft, #695d52);
    border-radius: 11px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}
.trade-btn-cancel:hover {
    background: rgba(41, 28, 18, 0.05);
    color: var(--ink, #211912);
}
.trade-btn-send {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: none;
    background: linear-gradient(135deg, #315743 0%, #2a4a3a 100%);
    color: #fff;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(49, 87, 67, 0.28);
}
.trade-btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(49, 87, 67, 0.38);
}
.trade-btn-send:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(49, 87, 67, 0.25);
}
.trade-btn-send svg {
    width: 16px;
    height: 16px;
}

/* ══════════════════════════════════════
   交易信息卡片（消息内嵌卡片）
   ══════════════════════════════════════ */
.trade-card {
    display: block;
    min-width: 240px;
    max-width: 300px;
    background: linear-gradient(180deg, #fffdf9 0%, #f8f2e7 100%);
    border: 1px solid rgba(49, 87, 67, 0.22);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 6px 18px rgba(49, 87, 67, 0.12);
    text-align: left;
}

/* 卡片头部 */
.trade-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #315743 0%, #2a4a3a 100%);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
}
.trade-card-header svg {
    width: 16px;
    height: 16px;
    opacity: 0.9;
    flex-shrink: 0;
}
.trade-card-title {
    letter-spacing: 0.5px;
}

/* 卡片主体 */
.trade-card-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.trade-card-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    line-height: 1.5;
}
.trade-card-label {
    flex-shrink: 0;
    min-width: 56px;
    color: var(--soft-2, #8a7d71);
    font-weight: 600;
}
.trade-card-label::after {
    content: '：';
}
.trade-card-value {
    flex: 1;
    color: var(--ink, #211912);
    font-weight: 500;
    word-break: break-word;
}

/* 自己发送的卡片：强调边框 */
.trade-card.mine {
    border-color: rgba(49, 87, 67, 0.4);
    box-shadow: 0 6px 20px rgba(49, 87, 67, 0.2);
}

/* 失败状态卡片弱化 */
.chat-bubble.failed .trade-card {
    opacity: 0.7;
}

/* 会话列表中交易消息预览的小图标 */
.conv-item-msg::before {
    content: none;
}

/* ── 响应式 ── */
@media (max-width: 768px) {
    .chat-window {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
    }

    .chat-page {
        padding: 16px 12px 40px;
    }

    .chat-panel {
        height: 400px;
    }

    .trade-modal {
        width: 100%;
        max-width: 100%;
        max-height: 90vh;
        border-radius: 16px;
    }

    .chat-trade-btn {
        width: 38px;
        height: 38px;
    }
    .chat-trade-btn svg {
        width: 17px;
        height: 17px;
    }
}

/* ══════════════════════════════════════
   删除会话确认弹窗
   ══════════════════════════════════════ */
.chat-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 28, 28, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.chat-confirm-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.chat-confirm {
    width: 360px;
    max-width: calc(100vw - 40px);
    background: linear-gradient(180deg, #fffdf9 0%, #faf5ec 100%);
    border: 1px solid rgba(41, 28, 18, 0.12);
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(33, 25, 18, 0.25);
    padding: 24px 24px 20px;
    text-align: center;
    transform: translateY(16px) scale(0.97);
    transition: transform 0.25s cubic-bezier(0.32, 0.72, 0.24, 1);
}
.chat-confirm-overlay.open .chat-confirm {
    transform: translateY(0) scale(1);
}
.chat-confirm-icon {
    font-size: 34px;
    line-height: 1;
    margin-bottom: 12px;
}
.chat-confirm-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--ink, #211912);
    margin-bottom: 8px;
}
.chat-confirm-text {
    font-size: 14px;
    line-height: 1.7;
    color: var(--soft, #695d52);
    word-break: break-word;
}
.chat-confirm-text strong {
    color: var(--ink, #211912);
}
.chat-confirm-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}
.chat-confirm-cancel {
    padding: 9px 22px;
    border: 1.5px solid rgba(41, 28, 18, 0.16);
    background: transparent;
    color: var(--soft, #695d52);
    border-radius: 11px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}
.chat-confirm-cancel:hover {
    background: rgba(41, 28, 18, 0.05);
    color: var(--ink, #211912);
}
.chat-confirm-ok {
    padding: 9px 24px;
    border: none;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: #fff;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}
.chat-confirm-ok:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(231, 76, 60, 0.4);
}
.chat-confirm-ok:active {
    transform: translateY(0);
}
