/* 消息页面样式 */
.chat-main {
    display: flex;
    height: calc(100vh - 60px);
    max-width: 1440px;
    margin: 0 auto;
    padding: 16px;
    gap: 16px;
    width: 100%;
    box-sizing: border-box;
}

/* 左侧边栏 */
.chat-sidebar {
    width: 320px;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.6);
    box-shadow: 0 2px 12px rgba(100,110,140,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 8px;
    gap: 4px;
}
.sidebar-tab {
    flex: 1;
    padding: 8px;
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: #8e8e93;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.sidebar-tab.active {
    background: rgba(0,122,255,0.1);
    color: #007aff;
}

/* 我的ID码 */
.my-code-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(0,122,255,0.05);
    margin: 10px;
    border-radius: 12px;
}
.my-code-label { font-size: 12px; color: #8e8e93; }
.my-code-value {
    font-size: 18px;
    font-weight: 800;
    color: #007aff;
    letter-spacing: 2px;
    flex: 1;
}
.copy-code-btn {
    background: rgba(0,122,255,0.1);
    border: none;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    color: #007aff;
    cursor: pointer;
    font-weight: 600;
}@media (hover: hover) {

.copy-code-btn:hover { background: rgba(0,122,255,0.2); }
}

/* 添加好友 */
.add-friend-box {
    display: flex;
    gap: 8px;
    padding: 0 10px 10px;
}
.add-friend-box input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 10px;
    font-size: 13px;
    outline: none;
    background: rgba(255,255,255,0.8);
}
.add-friend-box input:focus { border-color: #007aff; }

/* 好友请求 */
.friend-requests {
    margin: 0 10px 10px;
    background: rgba(255,149,0,0.08);
    border-radius: 12px;
    padding: 10px;
}
.requests-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 600;
    color: #ff9500;
    margin-bottom: 8px;
}
.request-count {
    background: #ff9500;
    color: #fff;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
}
.request-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,149,0,0.1);
}
.request-item:last-child { border-bottom: none; }
.request-name { font-size: 13px; font-weight: 600; color: #333; }
.request-actions { display: flex; gap: 6px; }
.request-actions button {
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 12px;
    border: none;
    cursor: pointer;
    font-weight: 600;
}
.btn-accept { background: #34c759; color: #fff; }
.btn-reject { background: rgba(0,0,0,0.1); color: #666; }

/* 侧边栏内容区 */
.sidebar-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 4px 8px 8px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.friend-list, .conv-list {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}
.sidebar-empty {
    text-align: center;
    color: #8e8e93;
    font-size: 13px;
    padding: 40px 16px;
}

/* 会话列表 */
.conv-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 2px;
}@media (hover: hover) {

.conv-item:hover { background: rgba(0,122,255,0.06); }
}
.conv-item.active { background: rgba(0,122,255,0.12); }
.conv-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: #ddd;
    flex-shrink: 0;
}
.conv-info { flex: 1; min-width: 0; }
.conv-name {
    font-size: 14px;
    font-weight: 600;
    color: #1c1c1e;
    margin-bottom: 2px;
}
.conv-last {
    font-size: 12px;
    color: #8e8e93;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.conv-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.conv-time { font-size: 11px; color: #c7c7cc; }
.conv-unread {
    background: #ff3b30;
    color: #fff;
    font-size: 11px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    font-weight: 700;
}

/* 好友列表 */
.friend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 2px;
}@media (hover: hover) {

.friend-item:hover { background: rgba(0,122,255,0.06); }
}
.friend-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: #ddd;
    flex-shrink: 0;
}
.friend-name { font-size: 14px; font-weight: 600; color: #1c1c1e; flex: 1; }
.friend-code { font-size: 11px; color: #c7c7cc; }

/* 右侧聊天窗口 */
.chat-window {
    flex: 1;
    min-width: 0;
    min-height: 0;
    background: rgba(255,255,255,0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.6);
    box-shadow: 0 2px 12px rgba(100,110,140,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-placeholder {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #8e8e93;
}
.placeholder-icon {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    background: rgba(0,122,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 28px;
}
.placeholder-icon svg {
    width: 32px;
    height: 32px;
    stroke: #007aff;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.chat-placeholder p {
    font-size: 14px;
    color: #aeaeb2;
    margin: 0;
}

.chat-active {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    flex: 1;
}
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.chat-header-actions {
    display: flex;
    gap: 8px;
}
.chat-friend-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    background: #ddd;
}
#chatFriendName { font-size: 16px; font-weight: 700; color: #1c1c1e; }

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
/* 消息项保持自然高度，不被flex压缩，超出才能滚动 */
.chat-messages > * { flex-shrink: 0; }
.msg-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-all;
    animation: msgIn 0.2s ease;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.msg-mine {
    align-self: flex-end;
    background: linear-gradient(135deg, #007aff, #5856d6);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.msg-other {
    align-self: flex-start;
    background: rgba(255,255,255,0.9);
    color: #1c1c1e;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.msg-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

/* ===== 群聊消息 - 微信风格 ===== */
.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
    animation: msgIn 0.2s ease;
}
.chat-message.mine {
    flex-direction: row !important;
    justify-content: flex-end !important;
}
.chat-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    flex-shrink: 0;
    object-fit: cover;
}
.chat-bubble {
    max-width: 70%;
    padding: 9px 13px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-all;
    position: relative;
    background: #fff;
    color: #1c1c1e;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.chat-message.mine .chat-bubble {
    background: #95EC69;
    color: #1c1c1e;
    border-bottom-right-radius: 3px;
}
.chat-message:not(.mine) .chat-bubble {
    border-bottom-left-radius: 3px;
}
/* 气泡尖角 */
.chat-bubble::before {
    content: '';
    position: absolute;
    top: 12px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
}
.chat-message.mine .chat-bubble::before {
    right: -10px;
    border-left-color: #95EC69;
    border-right: none;
}
.chat-message:not(.mine) .chat-bubble::before {
    left: -10px;
    border-right-color: #fff;
    border-left: none;
}
.chat-msg-image {
    max-width: 200px;
    max-height: 250px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
}
.chat-message.mine .chat-msg-image {
    border-bottom-right-radius: 3px;
}
.chat-message:not(.mine) .chat-msg-image {
    border-bottom-left-radius: 3px;
}

/* 图片分享消息卡片 */
.msg-bubble.msg-image-card {
    padding: 6px;
    max-width: 180px;
    width: 180px;
    border-radius: 14px;
    box-sizing: border-box;
    cursor: pointer;
}
.msg-image-card .img-card-thumb {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    background: #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: center;
}
.msg-image-card .img-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.msg-image-card .img-card-name {
    font-size: 12px;
    margin-top: 6px;
    padding: 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.msg-image-card .img-card-loading {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0.6;
    background: #e8e8e8;
    border-radius: 10px;
}
.msg-mine.msg-image-card .img-card-name { color: #fff; }
.msg-mine.msg-image-card .img-card-loading { color: #fff; }
.msg-other.msg-image-card .img-card-name { color: #1c1c1e; }

/* 左滑删除（手机端） */
.msg-swipe {
    position: relative;
    max-width: 70%;
    overflow: hidden;
    border-radius: 16px;
    width: fit-content;
}
.msg-swipe.msg-mine { align-self: flex-end; }
.msg-swipe.msg-other { align-self: flex-start; }
.msg-swipe .msg-bubble {
    transition: transform 0.25s ease;
    position: relative;
    z-index: 2;
    max-width: none;
    margin: 0;
}
.msg-swipe.swiped .msg-bubble {
    transform: translateX(-70px);
}
.msg-swipe .swipe-delete {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 70px;
    background: #ff3b30;
    color: #fff;
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}
.msg-swipe.swiped .swipe-delete {
    opacity: 1;
}

/* 会话/好友项左滑 */
.conv-swipe, .friend-swipe {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    margin-bottom: 2px;
}
.conv-swipe .conv-item, .friend-swipe .friend-item {
    transition: transform 0.25s ease;
    position: relative;
    z-index: 2;
    background: transparent;
}
.conv-swipe.swiped .conv-item,
.friend-swipe.swiped .friend-item {
    transform: translateX(-80px);
}
.conv-swipe .swipe-delete, .friend-swipe .swipe-delete {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 80px;
    background: #ff9500;
    color: #fff;
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid rgba(0,0,0,0.06);
    position: relative;
    align-items: center;
}
.chat-input-area input {
    flex: 1;
    padding: 11px 16px;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 14px;
    font-size: 14px;
    outline: none;
    background: rgba(255,255,255,0.9);
}
.chat-input-area input:focus { border-color: #007aff; }

/* 表情按钮和面板 */
.emoji-btn {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    border: 1px solid rgba(0,0,0,0.1);
    background: rgba(255,255,255,0.9);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}@media (hover: hover) {

.emoji-btn:hover { background: rgba(0,122,255,0.1); transform: scale(1.05); }
}
.emoji-btn.active { background: rgba(0,122,255,0.15); border-color: #007aff; }

.emoji-panel {
    position: absolute;
    bottom: 70px;
    left: 20px;
    width: 320px;
    max-height: 240px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.8);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    padding: 12px;
    z-index: 100;
    overflow-y: auto;
    animation: emojiIn 0.15s ease;
}
@keyframes emojiIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}
.emoji-item {
    font-size: 22px;
    padding: 6px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s;
    line-height: 1;
}@media (hover: hover) {

.emoji-item:hover { background: rgba(0,122,255,0.1); transform: scale(1.2); }
}

/* 消息右键菜单 */
.msg-context-menu {
    position: fixed;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    padding: 6px;
    z-index: 1000;
    min-width: 120px;
    animation: ctxIn 0.12s ease;
}
@keyframes ctxIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
.ctx-item {
    padding: 10px 16px;
    font-size: 14px;
    color: #ff3b30;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.15s;
}@media (hover: hover) {

.ctx-item:hover { background: rgba(255,59,48,0.1); }
}

/* 撤回确认弹窗 */
.recall-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.2s ease;
}
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.recall-modal-box {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 18px;
    padding: 24px;
    width: 280px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0,0,0,0.2);
    animation: modalPop 0.25s ease;
}
@keyframes modalPop {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.recall-modal-title {
    font-size: 17px;
    font-weight: 700;
    color: #1c1c1e;
    margin-bottom: 10px;
}
.recall-modal-text {
    font-size: 14px;
    color: #8e8e93;
    line-height: 1.6;
    margin-bottom: 20px;
}
.recall-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.recall-modal-actions .btn-primary {
    background: #ff3b30;
    border-color: #ff3b30;
}

/* 手机端：微信式全屏切换，页面不滚动，只有列表/聊天记录滚动 */
@media (max-width: 768px) {
    .chat-main {
        flex-direction: column;
        padding: 8px;
        gap: 8px;
        flex: 1;
        min-height: 0;
        height: auto;
        overflow: hidden;
    }
    .chat-sidebar {
        width: 100%;
        max-height: none;
        flex: 1;
        min-height: 0;
        border-radius: 12px;
    }
    .sidebar-content {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .chat-window {
        min-height: 0;
        flex: 1;
        display: none;
        border-radius: 12px;
    }
    /* 手机端进入聊天视图：全屏聊天窗口 */
    .chat-main.chat-view-active .chat-sidebar {
        display: none;
    }
    .chat-main.chat-view-active .chat-window {
        display: flex;
        flex: 1;
        min-height: 0;
    }
    .back-btn {
        display: inline-flex !important;
    }
    .msg-bubble { max-width: 85%; }
    /* 手机端聊天输入框自适配宽度 */
    .chat-input-area {
        padding: 10px 12px;
        gap: 8px;
        width: 100%;
        box-sizing: border-box;
        flex-shrink: 0;
    }
    .chat-input-area input {
        flex: 1;
        min-width: 0;
        width: 100%;
        padding: 10px 14px;
        font-size: 14px;
        box-sizing: border-box;
    }
    .chat-input-area .emoji-btn {
        width: 38px;
        height: 38px;
        flex-shrink: 0;
    }
    .chat-input-area #sendBtn {
        flex-shrink: 0;
        padding: 10px 16px;
        font-size: 14px;
        min-width: 0;
        white-space: nowrap;
    }
    .chat-messages {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .chat-header {
        flex-shrink: 0;
        padding: 12px 14px;
    }
    .chat-active {
        flex: 1;
        min-height: 0;
    }
}

/* ===== 黑色主题适配 ===== */
body[data-theme="dark"] .chat-sidebar {
    background: rgba(28,28,30,0.85);
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
body[data-theme="dark"] .chat-window {
    background: rgba(28,28,30,0.85);
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
body[data-theme="dark"] .sidebar-tabs { border-bottom-color: rgba(255,255,255,0.08); }
body[data-theme="dark"] .sidebar-tab { color: #8e8e93; }
body[data-theme="dark"] .sidebar-tab.active { background: rgba(10,132,255,0.2); color: #0a84ff; }
body[data-theme="dark"] .my-code-box { background: rgba(10,132,255,0.1); }
body[data-theme="dark"] .my-code-label { color: #8e8e93; }
body[data-theme="dark"] .my-code-value { color: #0a84ff; }
body[data-theme="dark"] .copy-code-btn { background: rgba(10,132,255,0.15); color: #0a84ff; }@media (hover: hover) {

body[data-theme="dark"] .copy-code-btn:hover { background: rgba(10,132,255,0.25); }
}
body[data-theme="dark"] .add-friend-box input {
    background: rgba(44,44,46,0.9); color: #fff; border-color: rgba(255,255,255,0.12);
}
body[data-theme="dark"] .add-friend-box input:focus { border-color: #0a84ff; }
body[data-theme="dark"] .add-friend-box input::placeholder { color: rgba(255,255,255,0.3); }
body[data-theme="dark"] .friend-requests { background: rgba(255,149,0,0.1); }
body[data-theme="dark"] .request-name { color: #fff; }
body[data-theme="dark"] .btn-reject { background: rgba(255,255,255,0.1); color: #c7c7cc; }@media (hover: hover) {

body[data-theme="dark"] .conv-item:hover { background: rgba(10,132,255,0.12); }
}
body[data-theme="dark"] .conv-item.active { background: rgba(10,132,255,0.2); }
body[data-theme="dark"] .conv-name { color: #fff; }
body[data-theme="dark"] .conv-last { color: #8e8e93; }
body[data-theme="dark"] .conv-time { color: #636366; }@media (hover: hover) {

body[data-theme="dark"] .friend-item:hover { background: rgba(10,132,255,0.12); }
}
body[data-theme="dark"] .friend-name { color: #fff; }
body[data-theme="dark"] .friend-code { color: #636366; }
body[data-theme="dark"] .conv-avatar,
body[data-theme="dark"] .friend-avatar,
body[data-theme="dark"] .chat-avatar { background: #3a3a3c; }
body[data-theme="dark"] .chat-header { border-bottom-color: rgba(255,255,255,0.08); }
body[data-theme="dark"] #chatFriendName { color: #fff; }
body[data-theme="dark"] .chat-placeholder { color: #636366; }
body[data-theme="dark"] .placeholder-icon { background: rgba(10,132,255,0.12); }
body[data-theme="dark"] .placeholder-icon svg { stroke: #0a84ff; }
body[data-theme="dark"] .chat-placeholder p { color: #636366; }
body[data-theme="dark"] .msg-other {
    background: rgba(44,44,46,0.95); color: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
body[data-theme="dark"] .msg-other.msg-image-card .img-card-name { color: #fff; }
body[data-theme="dark"] .img-card-thumb,
body[data-theme="dark"] .img-card-loading { background: #3a3a3c; }
body[data-theme="dark"] .chat-input-area { border-top-color: rgba(255,255,255,0.08); }
body[data-theme="dark"] .chat-input-area input {
    background: rgba(44,44,46,0.9); color: #fff; border-color: rgba(255,255,255,0.12);
}
body[data-theme="dark"] .chat-input-area input:focus { border-color: #0a84ff; }
body[data-theme="dark"] .chat-input-area input::placeholder { color: rgba(255,255,255,0.3); }
body[data-theme="dark"] .emoji-btn {
    background: rgba(44,44,46,0.9); border-color: rgba(255,255,255,0.12);
}
body[data-theme="dark"] .sidebar-empty { color: #636366; }
body[data-theme="dark"] .recall-modal { background: rgba(28,28,30,0.95); border-color: rgba(255,255,255,0.1); }
body[data-theme="dark"] .recall-modal-title { color: #fff; }
body[data-theme="dark"] .recall-modal-text { color: #8e8e93; }

/* 聊天图片消息 */
.msg-chat-image {
    max-width: 220px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    display: block;
}
.msg-chat-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
}
.msg-mine .msg-chat-image { margin-left: auto; }
.msg-other .msg-chat-image { margin-right: auto; }

/* 聊天图片查看器 */
.chat-image-viewer {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.chat-image-viewer img {
    max-width: 95vw;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
}

/* ===== 彩虹动画主题 ===== */
body[data-theme="rainbow"] .chat-sidebar {
    background: rgba(255,255,255,0.75);
    border-color: rgba(255,255,255,0.6);
    box-shadow: 0 2px 12px rgba(255,107,157,0.1);
}
body[data-theme="rainbow"] .chat-window {
    background: rgba(255,255,255,0.75);
    border-color: rgba(255,255,255,0.6);
    box-shadow: 0 2px 12px rgba(255,107,157,0.1);
}
body[data-theme="rainbow"] .sidebar-tab { color: #636366; }
body[data-theme="rainbow"] .sidebar-tab.active { background: rgba(255,107,157,0.15); color: #ff6b9d; }
body[data-theme="rainbow"] .conv-name,
body[data-theme="rainbow"] .friend-name,
body[data-theme="rainbow"] #chatFriendName { color: #1c1c1e; }
body[data-theme="rainbow"] .msg-other { background: rgba(255,255,255,0.95); color: #1c1c1e; }
body[data-theme="rainbow"] .add-friend-box input,
body[data-theme="rainbow"] .chat-input-area input {
    background: rgba(255,255,255,0.9); color: #1c1c1e; border-color: rgba(255,107,157,0.2);
}
body[data-theme="rainbow"] .emoji-btn { background: rgba(255,255,255,0.9); border-color: rgba(255,107,157,0.2); }


/* ===== v43 好友页重构：双端无顶部汇象栏、高度自适应、触控与交互统一 ===== */

/* 侧栏顶部：返回相册 + 标题 */
.sidebar-topline {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 2px;
    flex-shrink: 0;
}
.back-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 6px 12px 6px 7px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.92) 0%,
        rgba(255, 255, 255, 0.66) 50%,
        rgba(247, 249, 252, 0.78) 100%);
    color: #14161a;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(16, 18, 24, 0.06);
    transition: color 0.18s ease, background 0.18s ease;
}
.back-home-btn svg { width: 15px; height: 15px; }@media (hover: hover) {

.back-home-btn:hover { color: #007aff; }
}
.back-home-btn:active { transform: scale(0.97); }
.sidebar-title {
    margin-left: auto;
    font-size: 12px;
    color: #aeaeb2;
    letter-spacing: 1px;
}

/* 去掉顶栏后按动态视口铺满：100vh 兜底 → dvh → JS 同步的实际可视高度 */
.chat-main {
    height: 100vh;
    height: 100dvh;
    height: var(--app-h, 100dvh);
    padding: 14px;
    gap: 14px;
}

/* 桌面端：侧栏更舒展，列表项留白加大 */
@media (min-width: 769px) {
    .chat-sidebar { width: 340px; }
    .chat-header { padding: 16px 22px; }
    .conv-item, .friend-item { padding: 11px 12px; }
    .conv-list, .friend-list, .group-list { padding: 4px 8px 10px; }
}

/* 移动端：触控尺寸、安全区、列表密度 */
@media (max-width: 768px) {
    .chat-main {
        padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
        gap: 8px;
    }
    .sidebar-topline { padding: 8px 10px 0; }
    .back-home-btn { padding: 8px 14px 8px 9px; font-size: 13px; }
    .sidebar-tab { min-height: 42px; padding: 10px; }
    .conv-item, .friend-item { padding: 12px 10px; }
    .conv-item:hover, .friend-item:hover { background: transparent; }
    .conv-item:active, .friend-item:active { background: rgba(0, 122, 255, 0.08); }
    .chat-header { gap: 8px; }
    .chat-header-actions { gap: 6px; }
    .chat-header-actions .btn-ghost { padding: 8px 11px; font-size: 13px; }
    .chat-input-area { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    .sidebar-content { padding-bottom: 6px; }
    .sidebar-empty { padding: 26px 16px; }
}

/* 深色主题 */
body[data-theme="dark"] .back-home-btn {
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.14) 0%,
        rgba(255, 255, 255, 0.07) 52%,
        rgba(255, 255, 255, 0.10) 100%);
    border-color: rgba(255, 255, 255, 0.18);
    color: #f2f3f6;
}
body[data-theme="dark"] .sidebar-title { color: rgba(255, 255, 255, 0.35); }

/* 手机端聊天头部：返回与名字一行、操作按钮换到第二行，避免挤压换行 */
@media (max-width: 768px) {
    .chat-header {
        flex-wrap: wrap;
        row-gap: 8px;
        padding: 10px 12px;
    }
    .back-btn {
        order: 0;
        flex-shrink: 0;
        white-space: nowrap;
        padding: 7px 10px !important;
        font-size: 13px !important;
    }
    .chat-friend-info {
        order: 1;
        flex: 1 1 auto;
        min-width: 0;
    }
    #chatFriendName {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .chat-header-actions {
        order: 2;
        width: 100%;
        justify-content: flex-end;
        gap: 8px;
    }
    .chat-header-actions .btn-ghost {
        white-space: nowrap;
        padding: 8px 14px !important;
    }
}
/* 手机端顶部安全区（刘海屏） */
@media (max-width: 768px) {
    .chat-main { padding-top: calc(8px + env(safe-area-inset-top)); }
}

/* 键盘弹起：聊天页整体固定为可视高度（top 对齐），输入区紧贴键盘上沿。
   不用 bottom 定位——iOS 键盘弹起不改布局视口高度，bottom:0 会被键盘盖住。 */
html.kb-open .chat-main {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--app-h, 100dvh);
    padding-bottom: 6px;
    z-index: 1;
}
html.kb-open body,
html.kb-open .chat-main { overflow: hidden; }

/* ============================================================
   黑色主题：文字可读性（会话时间、好友编码、空态、输入提示）
   原来的 #636366 在深底上只有约 2.9:1，统一提到系统灰 #8e8e93
   ============================================================ */
body[data-theme="dark"] .conv-time,
body[data-theme="dark"] .friend-code,
body[data-theme="dark"] .chat-placeholder,
body[data-theme="dark"] .chat-placeholder p,
body[data-theme="dark"] .sidebar-empty {
    color: #8e8e93;
}
body[data-theme="dark"] .add-friend-box input::placeholder,
body[data-theme="dark"] .chat-input-area input::placeholder {
    color: rgba(255,255,255,0.45);
}
body[data-theme="dark"] .sidebar-title {
    color: rgba(255,255,255,0.5);
}
