/**
 * 微聊 IM - 主样式表
 * 微信风格UI: 绿色主题#07C160, 白色卡片, 灰色背景#EDEDED
 */

/* ==================== 基础重置 ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

:root {
    --primary: #07C160;
    --primary-dark: #06AD56;
    --primary-light: #E8F8EE;
    --bg: #EDEDED;
    --bg-white: #FFFFFF;
    --text: #191919;
    --text-secondary: #888888;
    --text-tertiary: #B2B2B2;
    --border: #E5E5E5;
    --danger: #FA5151;
    --warning: #FF9C19;
    --blue: #10AEFF;
    --tabbar-height: 50px;
    --navbar-height: 44px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* ==================== 通用组件 ==================== */

/* 头部导航栏 */
.navbar {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--navbar-height);
    padding-top: var(--safe-top);
    background: var(--bg-white);
    border-bottom: 0.5px solid var(--border);
    position: relative;
    z-index: 100;
    flex-shrink: 0;
}

.navbar-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
}

.navbar-left, .navbar-right {
    position: absolute;
    top: var(--safe-top);
    height: var(--navbar-height);
    display: flex;
    align-items: center;
}

.navbar-left {
    left: 0;
    padding-left: 12px;
}

.navbar-right {
    right: 0;
    padding-right: 12px;
}

.navbar-btn {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 4px;
    color: var(--primary);
    font-size: 16px;
    background: none;
    border: none;
    cursor: pointer;
}

.navbar-btn:active {
    opacity: 0.6;
}

.navbar-btn-text {
    font-size: 15px;
    color: var(--primary);
}

/* 底部Tab栏 */
.tabbar {
    display: flex;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--tabbar-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-white);
    border-top: 0.5px solid var(--border);
    z-index: 999;
}

.tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 10px;
    position: relative;
    cursor: pointer;
}

.tabbar-item.active {
    color: var(--primary);
}

.tabbar-item .icon {
    width: 26px;
    height: 26px;
}

.tabbar-badge {
    position: absolute;
    top: 4px;
    left: 50%;
    margin-left: 10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    border: 2px solid var(--bg-white);
}

.tabbar-dot {
    position: absolute;
    top: 8px;
    left: 50%;
    margin-left: 14px;
    width: 9px;
    height: 9px;
    background: var(--danger);
    border-radius: 50%;
    border: 1.5px solid var(--bg-white);
}

/* 页面容器 */
.page {
    display: none;
    flex-direction: column;
    height: 100%;
}

.page.active {
    display: flex;
}

.page-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* 卡片 */
.card {
    background: var(--bg-white);
    margin: 8px 0;
    border-top: 0.5px solid var(--border);
    border-bottom: 0.5px solid var(--border);
}

/* 头像 */
.avatar {
    width: 46px;
    height: 46px;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #f0f0f0;
    position: relative;
}

.avatar.no-avatar {
    background: var(--primary);
    color: white;
    font-size: 18px;
    font-weight: 500;
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: 500;
}

.avatar-sm { width: 36px; height: 36px; border-radius: 5px; }
.avatar-sm .avatar-text { font-size: 14px; }
.avatar-lg { width: 64px; height: 64px; border-radius: 8px; }
.avatar-lg .avatar-text { font-size: 24px; }
.avatar-xl { width: 80px; height: 80px; border-radius: 10px; }
.avatar-xl .avatar-text { font-size: 30px; }
.avatar-round { border-radius: 50%; }

/* 列表项 */
.list-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-white);
    cursor: pointer;
    position: relative;
    gap: 12px;
}

.list-item:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 68px;
    right: 0;
    bottom: 0;
    height: 0.5px;
    background: var(--border);
}

.list-item:active {
    background: #f5f5f5;
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-size: 16px;
    color: var(--text);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-extra {
    font-size: 13px;
    color: var(--text-tertiary);
}

.list-item-arrow .icon-arrow-right {
    width: 8px;
    height: 14px;
    margin-left: 4px;
}

/* 输入框 */
.input-group {
    margin: 12px 16px;
}

.input-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-field {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--bg-white);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.input-field:focus {
    border-color: var(--primary);
}

textarea.input-field {
    height: auto;
    min-height: 80px;
    padding: 10px 12px;
    resize: none;
    line-height: 1.5;
}

/* 按钮 */
.btn {
    display: block;
    width: 100%;
    height: 46px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
    text-align: center;
    line-height: 46px;
}

.btn:active {
    opacity: 0.8;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-secondary {
    background: #f0f0f0;
    color: var(--text);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-sm {
    width: auto;
    height: 32px;
    padding: 0 16px;
    font-size: 14px;
    line-height: 32px;
    border-radius: 6px;
}

.btn:disabled {
    opacity: 0.5;
}

/* Toast */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 9999;
    max-width: 80%;
    text-align: center;
    transition: opacity 0.3s;
    display: none;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9998;
}

.loading-spinner {
    background: rgba(0, 0, 0, 0.8);
    border-radius: 12px;
    padding: 24px 32px;
    text-align: center;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: white;
    font-size: 14px;
}

/* 确认对话框 */
.confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-dialog {
    background: white;
    border-radius: 12px;
    width: 80%;
    max-width: 300px;
    overflow: hidden;
}

.confirm-message {
    padding: 24px 20px;
    text-align: center;
    font-size: 16px;
    line-height: 1.5;
}

.confirm-buttons {
    display: flex;
    border-top: 0.5px solid var(--border);
}

.confirm-btn {
    flex: 1;
    height: 44px;
    border: none;
    background: white;
    font-size: 16px;
    cursor: pointer;
}

.confirm-btn:first-child {
    border-right: 0.5px solid var(--border);
    color: var(--text-secondary);
}

.confirm-btn.ok {
    color: var(--primary);
}

.confirm-btn:active {
    background: #f5f5f5;
}

/* ActionSheet */
.actionsheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.actionsheet-mask {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s;
}

.actionsheet-overlay.show .actionsheet-mask {
    background: rgba(0, 0, 0, 0.4);
}

.actionsheet {
    position: relative;
    background: #F7F7F7;
    border-radius: 12px 12px 0 0;
    padding-bottom: var(--safe-bottom);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.actionsheet-overlay.show .actionsheet {
    transform: translateY(0);
}

.actionsheet-overlay.closing .actionsheet {
    transform: translateY(100%);
}

.actionsheet-overlay.closing .actionsheet-mask {
    background: rgba(0, 0, 0, 0);
}

.actionsheet-item {
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    color: var(--text);
    background: white;
    cursor: pointer;
    border-bottom: 0.5px solid var(--border);
}

.actionsheet-item:active {
    background: #f5f5f5;
}

.actionsheet-item.danger {
    color: var(--danger);
}

.actionsheet-item.cancel {
    margin-top: 8px;
    border-bottom: none;
    font-weight: 500;
}

.actionsheet-divider {
    height: 8px;
}

/* ==================== 登录页 ==================== */
.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    background: var(--bg-white);
    padding: 0 32px;
    padding-top: calc(80px + var(--safe-top));
}

.login-logo {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.login-logo svg {
    width: 48px;
    height: 48px;
    fill: white;
}

.login-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.login-form {
    width: 100%;
    max-width: 320px;
}

.login-input-wrap {
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.login-input-wrap input {
    width: 100%;
    height: 48px;
    border: none;
    font-size: 17px;
    outline: none;
    background: transparent;
}

.login-input-wrap input::placeholder {
    color: var(--text-tertiary);
}

.login-tabs {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.login-tab {
    font-size: 17px;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
    padding-bottom: 4px;
}

.login-tab.active {
    color: var(--text);
    font-weight: 600;
}

.login-tab.active::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 24px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
}

.login-btn {
    margin-top: 24px;
}

.server-config {
    margin-top: 20px;
    text-align: center;
}

.server-config-btn {
    font-size: 13px;
    color: var(--text-tertiary);
    background: none;
    border: none;
    cursor: pointer;
}

.server-config-input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0 12px;
    font-size: 14px;
    margin-top: 8px;
    display: none;
}

.server-config-input.show {
    display: block;
}

/* ==================== 聊天列表页 ==================== */
.chat-list-page .page-content {
    background: var(--bg-white);
}

.chat-list-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    background: var(--bg-white);
    cursor: pointer;
    position: relative;
}

.chat-list-item:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 68px;
    right: 0;
    bottom: 0;
    height: 0.5px;
    background: var(--border);
}

.chat-list-item:active {
    background: #f5f5f5;
}

.chat-list-info {
    flex: 1;
    min-width: 0;
}

.chat-list-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-list-name {
    font-size: 16px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-list-time {
    font-size: 12px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.chat-list-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    gap: 8px;
}

.chat-list-msg {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.chat-list-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    flex-shrink: 0;
}

.chat-list-avatar-wrap {
    position: relative;
}

.chat-list-avatar-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    z-index: 1;
}

.chat-list-header-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.chat-list-header-actions .icon {
    width: 24px;
    height: 24px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-tertiary);
}

.empty-state .icon {
    width: 60px;
    height: 60px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 14px;
}

/* ==================== 聊天界面 ==================== */
.chat-page {
    display: none;
    flex-direction: column;
    height: 100%;
    background: var(--bg);
}

.chat-page.show {
    display: flex;
}

.chat-navbar {
    display: flex;
    align-items: center;
    height: var(--navbar-height);
    padding-top: var(--safe-top);
    background: var(--bg-white);
    border-bottom: 0.5px solid var(--border);
    position: relative;
    flex-shrink: 0;
}

.chat-back-btn {
    display: flex;
    align-items: center;
    height: 100%;
    padding-left: 12px;
    gap: 2px;
    background: none;
    border: none;
    color: var(--primary);
    font-size: 16px;
    cursor: pointer;
}

.chat-back-btn .icon {
    width: 24px;
    height: 24px;
}

.chat-navbar-title {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    padding-right: 60px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-navbar-right {
    padding-right: 12px;
}

.chat-navbar-right .icon {
    width: 24px;
    height: 24px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 消息时间分隔 */
.msg-time-divider {
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    align-self: center;
}

/* 消息气泡 */
.msg-row {
    display: flex;
    gap: 8px;
    max-width: 100%;
    align-items: flex-start;
}

.msg-row.self {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 5px;
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
}

.msg-avatar .avatar-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 15px;
    font-weight: 500;
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-content-wrap {
    max-width: 68%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.msg-row.self .msg-content-wrap {
    align-items: flex-end;
}

.msg-bubble {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
    max-width: 100%;
}

.msg-row.other .msg-bubble {
    background: var(--bg-white);
    border-top-left-radius: 0;
}

.msg-row.self .msg-bubble {
    background: #95EC69;
    border-top-right-radius: 0;
}

/* 气泡小三角 */
.msg-row.other .msg-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: -6px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 6px 6px 0;
    border-color: transparent var(--bg-white) transparent transparent;
}

.msg-row.self .msg-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    right: -6px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 6px 6px;
    border-color: transparent transparent transparent #95EC69;
}

/* 图片消息 */
.msg-image {
    max-width: 200px;
    max-height: 300px;
    border-radius: 4px;
    cursor: pointer;
    display: block;
}

/* 语音消息 */
.msg-voice {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 80px;
    cursor: pointer;
}

.msg-voice-duration {
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
}

.msg-voice-icon {
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23191919'%3E%3Cpath d='M12 15c1.66 0 2.99-1.34 2.99-3L15 6c0-1.66-1.34-3-3-3S9 4.34 9 6v6c0 1.66 1.34 3 3 3z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.msg-voice.playing .msg-voice-icon {
    animation: voicePulse 1s ease infinite;
}

@keyframes voicePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* 撤回消息 */
.msg-recall {
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 4px 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    align-self: center;
}

/* 阅后即焚标识 */
.msg-burn-tag {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 11px;
    color: var(--warning);
    margin-bottom: 4px;
}

.msg-burn-tag .icon {
    width: 12px;
    height: 12px;
}

/* 已读/发送状态 */
.msg-status {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.msg-row.self .msg-status {
    text-align: right;
}

/* 消息操作菜单触发 */
.msg-bubble.long-pressable {
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* 聊天底部输入栏 */
.chat-input-bar {
    flex-shrink: 0;
    background: #F7F7F7;
    border-top: 0.5px solid var(--border);
    padding: 8px 8px;
    padding-bottom: calc(8px + var(--safe-bottom));
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.chat-input-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
}

.chat-input-icon .icon {
    width: 28px;
    height: 28px;
}

.chat-input-text {
    flex: 1;
    min-height: 36px;
    max-height: 100px;
    border: 0.5px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 15px;
    background: var(--bg-white);
    outline: none;
    line-height: 1.4;
    resize: none;
    overflow-y: auto;
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
}

.chat-send-btn .icon {
    width: 20px;
    height: 20px;
}

/* 语音录制按钮 */
.chat-voice-btn {
    flex: 1;
    height: 36px;
    border: 0.5px solid var(--border);
    border-radius: 6px;
    background: var(--bg-white);
    font-size: 14px;
    color: var(--text);
    text-align: center;
    line-height: 36px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

.chat-voice-btn.recording {
    background: #cccccc;
}

/* 更多面板（图片/视频等） */
.chat-more-panel {
    display: none;
    padding: 12px 8px;
    background: #F7F7F7;
}

.chat-more-panel.show {
    display: flex;
    gap: 16px;
    overflow-x: auto;
}

.chat-more-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    width: 64px;
}

.chat-more-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: var(--bg-white);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-more-icon .icon {
    width: 28px;
    height: 28px;
}

.chat-more-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 阅后即焚开关 */
.chat-burn-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--primary-light);
    border-top: 0.5px solid var(--border);
    font-size: 13px;
    color: var(--primary);
}

.burn-switch {
    position: relative;
    width: 40px;
    height: 22px;
    background: #ddd;
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.3s;
}

.burn-switch.on {
    background: var(--primary);
}

.burn-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.burn-switch.on::after {
    transform: translateX(18px);
}

/* 录音提示 */
.recording-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
}

.recording-overlay.show {
    display: flex;
}

.recording-box {
    background: rgba(0, 0, 0, 0.8);
    border-radius: 12px;
    padding: 24px 32px;
    text-align: center;
    color: white;
}

.recording-mic {
    width: 60px;
    height: 60px;
    margin: 0 auto 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.recording-time {
    font-size: 18px;
    margin-bottom: 8px;
}

.recording-tip {
    font-size: 13px;
    opacity: 0.8;
}

.recording-cancel {
    color: var(--danger);
}

/* ==================== 通讯录页 ==================== */
.contacts-page .page-content {
    background: var(--bg-white);
}

.contacts-section-header {
    padding: 4px 16px;
    font-size: 13px;
    color: var(--text-secondary);
    background: #F7F7F7;
}

.contacts-quick-entry {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    background: var(--bg-white);
    cursor: pointer;
    position: relative;
}

.contacts-quick-entry:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 68px;
    right: 0;
    bottom: 0;
    height: 0.5px;
    background: var(--border);
}

.contacts-quick-entry:active {
    background: #f5f5f5;
}

.contacts-quick-icon {
    width: 46px;
    height: 46px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contacts-quick-icon .icon {
    width: 24px;
    height: 24px;
}

.contacts-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
}

/* 字母索引 */
.alphabet-index {
    position: fixed;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 50;
}

.alphabet-index-item {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 2px 4px;
    cursor: pointer;
    line-height: 1;
}

.alphabet-index-item.active {
    color: var(--primary);
    font-weight: bold;
}

/* 搜索栏 */
.search-bar {
    padding: 8px 12px;
    background: var(--bg-white);
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    background: #F0F0F0;
    border-radius: 8px;
    padding: 0 10px;
    height: 36px;
    gap: 6px;
}

.search-input-wrap .icon {
    width: 18px;
    height: 18px;
}

.search-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 14px;
    outline: none;
    height: 100%;
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

/* 搜索结果 */
.search-results {
    background: var(--bg-white);
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    cursor: pointer;
    position: relative;
}

.search-result-item:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 68px;
    right: 0;
    bottom: 0;
    height: 0.5px;
    background: var(--border);
}

.search-result-item:active {
    background: #f5f5f5;
}

/* 好友请求列表 */
.friend-request-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    background: var(--bg-white);
    position: relative;
}

.friend-request-item:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 68px;
    right: 0;
    bottom: 0;
    height: 0.5px;
    background: var(--border);
}

.friend-request-actions {
    display: flex;
    gap: 8px;
}

/* ==================== 朋友圈页 ==================== */
.moments-page .page-content {
    background: #F7F7F7;
}

.moments-header {
    position: relative;
    height: 280px;
    overflow: hidden;
}

.moments-cover {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #07C160 0%, #0A8C45 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.moments-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.moments-user {
    position: absolute;
    bottom: -28px;
    right: 16px;
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.moments-user-name {
    font-size: 17px;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    margin-bottom: 36px;
}

.moments-user-avatar {
    border: 3px solid white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.moment-card {
    background: var(--bg-white);
    margin-top: 40px;
    padding: 16px;
    border-bottom: 0.5px solid var(--border);
}

.moment-card:first-of-type {
    margin-top: 40px;
}

.moment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.moment-author {
    font-size: 15px;
    font-weight: 600;
    color: #576B95;
}

.moment-content {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text);
    margin-bottom: 8px;
    white-space: pre-wrap;
    word-break: break-word;
}

.moment-images {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.moment-image {
    width: calc((100% - 12px) / 3);
    aspect-ratio: 1;
    border-radius: 4px;
    object-fit: cover;
    cursor: pointer;
    background: #f0f0f0;
}

.moment-images.single .moment-image {
    width: auto;
    max-width: 180px;
    max-height: 240px;
    aspect-ratio: auto;
}

.moment-images.double .moment-image {
    width: calc((100% - 6px) / 2);
    aspect-ratio: 1;
}

.moment-images.quadruple .moment-image {
    width: calc((100% - 6px) / 2);
}

.moment-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.moment-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.moment-action-btn {
    background: #F2F2F2;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.moment-action-btn .icon {
    width: 16px;
    height: 16px;
}

.moment-interactions {
    background: #F7F7F7;
    border-radius: 4px;
    padding: 8px 12px;
    margin-top: 8px;
}

.moment-likes {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #576B95;
}

.moment-likes .icon {
    width: 14px;
    height: 14px;
    margin-right: 4px;
}

.moment-like-item {
    cursor: pointer;
}

.moment-like-divider {
    width: 0.5px;
    height: 12px;
    background: #ccc;
    margin: 0 2px;
}

.moment-comments {
    margin-top: 6px;
}

.moment-comment {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
}

.moment-comment-author {
    color: #576B95;
    cursor: pointer;
}

.moment-comment-divider {
    height: 0.5px;
    background: #E5E5E5;
    margin: 4px 0;
}

/* 发布朋友圈 */
.moment-publish-page {
    display: none;
    flex-direction: column;
    height: 100%;
    background: var(--bg-white);
}

.moment-publish-page.show {
    display: flex;
}

.publish-textarea {
    flex: 1;
    border: none;
    padding: 16px;
    font-size: 16px;
    line-height: 1.6;
    resize: none;
    outline: none;
    background: var(--bg-white);
    min-height: 120px;
}

.publish-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 16px;
}

.publish-image-item {
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.publish-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.publish-image-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 22px;
    height: 22px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    cursor: pointer;
}

.publish-add-image {
    width: 80px;
    height: 80px;
    border: 1.5px dashed #ccc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.publish-add-image .icon {
    width: 32px;
    height: 32px;
}

/* 评论区输入 */
.moment-comment-input-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #F7F7F7;
    border-top: 0.5px solid var(--border);
    padding: 8px 12px;
    padding-bottom: calc(8px + var(--safe-bottom));
    z-index: 200;
}

.moment-comment-input-bar.show {
    display: flex;
    gap: 8px;
    align-items: center;
}

.moment-comment-input {
    flex: 1;
    height: 36px;
    border: 0.5px solid var(--border);
    border-radius: 6px;
    padding: 0 10px;
    font-size: 14px;
    background: var(--bg-white);
    outline: none;
}

/* ==================== 个人中心页 ==================== */
.profile-page .page-content {
    background: var(--bg);
}

.profile-header {
    background: var(--bg-white);
    padding: 20px 16px;
    padding-top: calc(20px + var(--safe-top));
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 0.5px solid var(--border);
}

.profile-header-info {
    flex: 1;
}

.profile-name {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.profile-id {
    font-size: 13px;
    color: var(--text-secondary);
}

.profile-signature {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
}

.profile-section {
    background: var(--bg-white);
    margin-top: 8px;
}

.profile-section-item {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    gap: 12px;
    cursor: pointer;
    position: relative;
}

.profile-section-item:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 48px;
    right: 0;
    bottom: 0;
    height: 0.5px;
    background: var(--border);
}

.profile-section-item:active {
    background: #f5f5f5;
}

.profile-section-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-section-icon .icon {
    width: 22px;
    height: 22px;
}

.profile-section-label {
    flex: 1;
    font-size: 16px;
    color: var(--text);
}

.profile-section-value {
    font-size: 14px;
    color: var(--text-tertiary);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-logout {
    margin-top: 24px;
    text-align: center;
    padding: 14px;
    background: var(--bg-white);
    color: var(--danger);
    font-size: 16px;
    cursor: pointer;
    border-top: 0.5px solid var(--border);
    border-bottom: 0.5px solid var(--border);
}

.profile-logout:active {
    background: #f5f5f5;
}

/* 编辑资料页 */
.profile-edit-page {
    display: none;
    flex-direction: column;
    height: 100%;
    background: var(--bg);
}

.profile-edit-page.show {
    display: flex;
}

.profile-edit-avatar {
    display: flex;
    align-items: center;
    padding: 20px 16px;
    background: var(--bg-white);
       gap: 12px;
    margin-top: 8px;
    cursor: pointer;
}

.profile-edit-avatar-label {
    flex: 1;
    font-size: 16px;
}

.profile-edit-avatar-preview {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
}

.profile-edit-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-edit-field {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg-white);
    gap: 12px;
    border-top: 0.5px solid var(--border);
}

.profile-edit-field-label {
    font-size: 16px;
    width: 70px;
    flex-shrink: 0;
}

.profile-edit-field input {
    flex: 1;
    border: none;
    font-size: 16px;
    outline: none;
    background: transparent;
    text-align: right;
}

.profile-edit-field textarea {
    flex: 1;
    border: none;
    font-size: 16px;
    outline: none;
    background: transparent;
    resize: none;
    text-align: right;
    min-height: 24px;
    line-height: 1.5;
}

/* ==================== 通话界面 ==================== */
.call-page {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 8000;
    background: #1a1a1a;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
}

.call-page.show {
    display: flex;
}

.call-page.video {
    background: #000;
}

.call-remote-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.call-local-video {
    position: absolute;
    top: calc(80px + var(--safe-top));
    right: 16px;
    width: 100px;
    height: 150px;
    border-radius: 10px;
    object-fit: cover;
    z-index: 2;
    background: #333;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.call-page.voice .call-local-video {
    display: none;
}

.call-page.voice .call-remote-video {
    display: none;
}

.call-header {
    position: relative;
    z-index: 3;
    padding-top: calc(60px + var(--safe-top));
    text-align: center;
}

.call-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 16px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255, 255, 255, 0.2);
}

.call-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.call-avatar .avatar-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 40px;
    font-weight: 500;
}

.call-name {
    font-size: 24px;
    color: white;
    font-weight: 500;
    margin-bottom: 8px;
}

.call-status-text {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.6);
}

.call-duration {
    font-size: 15px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 4px;
}

.call-actions {
    position: relative;
    z-index: 3;
    padding-bottom: calc(60px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
}

.call-action-row {
    display: flex;
    gap: 40px;
}

.call-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.call-action-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: transform 0.2s;
}

.call-action-btn:active .call-action-circle {
    transform: scale(0.92);
}

.call-action-circle .icon {
    width: 28px;
    height: 28px;
}

.call-action-circle.active {
    background: white;
}

.call-action-circle.active .icon {
    filter: invert(1);
}

.call-action-circle.hangup {
    background: var(--danger);
}

.call-action-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
}

/* 来电界面 */
.call-incoming-actions {
    display: flex;
    gap: 80px;
    align-items: center;
}

.call-incoming-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.call-incoming-circle {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: callPulse 1.5s ease-in-out infinite;
}

.call-incoming-circle.accept {
    background: var(--primary);
}

.call-incoming-circle.reject {
    background: var(--danger);
}

.call-incoming-circle .icon {
    width: 32px;
    height: 32px;
}

@keyframes callPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ==================== 图片查看器 ==================== */
.image-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.image-viewer.show {
    display: flex;
}

.image-viewer img {
    max-width: 100%;
    max-height: 100%;
    transition: transform 0.3s;
    will-change: transform;
}

.image-viewer-close {
    position: absolute;
    top: calc(16px + var(--safe-top));
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1;
}

.image-viewer-close .icon {
    width: 24px;
    height: 24px;
}

/* ==================== WS状态指示 ==================== */
#ws-status {
    display: none;
    position: fixed;
    top: calc(var(--navbar-height) + var(--safe-top));
    left: 0;
    right: 0;
    height: 30px;
    background: #FA5151;
    color: white;
    font-size: 13px;
    align-items: center;
    justify-content: center;
    z-index: 500;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

/* ==================== 子页面(全屏覆盖) ==================== */
.sub-page {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    z-index: 500;
    flex-direction: column;
}

.sub-page.show {
    display: flex;
}

/* ==================== 通用动画 ==================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

/* ==================== 滚动条隐藏 ==================== */
::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* ==================== 用户详情页 ==================== */
.user-detail-page .page-content {
    background: var(--bg);
}

.user-detail-header {
    background: var(--bg-white);
    padding: 20px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 0.5px solid var(--border);
    margin-bottom: 8px;
}

.user-detail-info {
    flex: 1;
}

.user-detail-name {
    font-size: 20px;
    font-weight: 600;
}

.user-detail-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.user-detail-actions {
    padding: 20px;
}

/* ==================== 消息菜单 ==================== */
.msg-menu {
    position: fixed;
    background: rgba(0, 0, 0, 0.85);
    border-radius: 8px;
    padding: 4px 0;
    z-index: 9500;
    display: none;
    min-width: 120px;
    backdrop-filter: blur(10px);
}

.msg-menu.show {
    display: block;
}

.msg-menu-item {
    padding: 12px 20px;
    font-size: 14px;
    color: white;
    cursor: pointer;
    text-align: center;
    white-space: nowrap;
}

.msg-menu-item:active {
    background: rgba(255, 255, 255, 0.1);
}

.msg-menu-item:not(:last-child) {
    border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
}

.msg-menu-item.danger {
    color: #FF6B6B;
}

/* ==================== 空状态 ==================== */
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* 文件输入隐藏 */
.file-input {
    display: none;
}

/* 禁用文字选择(防止长按选中) */
.no-select {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* 允许输入框选择文字 */
input, textarea {
    -webkit-user-select: text;
    user-select: text;
}
