/* ============================================
 * 未来通讯 - 移动端优化版 CSS（含昵称样式）
 * ============================================ */

/* CSS变量定义 - 支持三种主题 */
:root {
    --safe-top: env(safe-area-inset-top);
    --safe-bottom: env(safe-area-inset-bottom);
    --safe-left: env(safe-area-inset-left);
    --safe-right: env(safe-area-inset-right);
    
    /* 默认炫酷版（赛博朋克） */
    --bg-body: #020204;
    --bg-primary: rgba(10, 10, 18, 0.98);
    --bg-content: rgba(0, 0, 0, 0.3);
    --text-main: #e0f7ff;
    --text-sub: #8b92a8;
    --accent-1: #00f3ff;
    --accent-2: #ff00ff;
    --accent-3: #ff003c;
    --accent-4: #00ff9d;
    --border: rgba(0, 243, 255, 0.2);
    --card: rgba(0, 243, 255, 0.05);
    --shadow: 0 0 20px rgba(0, 243, 255, 0.2);
    --grid-opacity: 0.03;
    --radius: 12px;
    
    /* 移动端适配变量 */
    --touch-target: 44px;
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 16px;
    --spacing-lg: 20px;
}

/* 简约版主题 */
[data-theme="simple"] {
    --bg-body: #f2f3f7;
    --bg-primary: #ffffff;
    --bg-content: #f2f3f7;
    --text-main: #1a1a1a;
    --text-sub: #666666;
    --accent-1: #007aff;
    --accent-2: #5856d6;
    --accent-3: #ff3b30;
    --accent-4: #34c759;
    --border: #e5e5ea;
    --card: #ffffff;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --grid-opacity: 0;
    --radius: 10px;
}

/* 暗夜简约版 */
[data-theme="dark"] {
    --bg-body: #000000;
    --bg-primary: #1c1c1e;
    --bg-content: #2c2c2e;
    --text-main: #ffffff;
    --text-sub: #8e8e93;
    --accent-1: #0a84ff;
    --accent-2: #5e5ce6;
    --accent-3: #ff453a;
    --accent-4: #30d158;
    --border: #38383a;
    --card: #2c2c2e;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    --grid-opacity: 0;
    --radius: 10px;
}

/* ============================================
 * 基础样式重置 - 移动端优化
 * ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

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

html {
    /* 移动端字体基准 */
    font-size: 16px;
    /* 防止 iOS 字体大小调整 */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* 平滑滚动 */
    scroll-behavior: smooth;
    /* 防止横向滚动 */
    overflow-x: hidden;
}

html, body {
    height: 100%;
    height: 100dvh; /* 使用动态视口高度 */
    width: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    position: fixed; /* 防止移动端浏览器弹性滚动 */
    touch-action: none; /* 控制触摸行为 */
}

/* 背景网格（仅炫酷版显示） */
.cyber-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(0, 243, 255, var(--grid-opacity)) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 243, 255, var(--grid-opacity)) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

/* ============================================
 * 登录页样式 - 移动端优化
 * ============================================ */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-body);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--safe-top) var(--spacing-md) var(--spacing-md);
    overflow-y: auto;
    /* 移动端弹性滚动 */
    -webkit-overflow-scrolling: touch;
    /* 适配底部安全区 */
    padding-bottom: calc(var(--spacing-md) + var(--safe-bottom));
}

.brand-box {
    text-align: center;
    margin: 20px 0 32px;
    /* 小屏幕减少间距 */
    margin-top: clamp(20px, 10vh, 60px);
}

.brand-logo {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}

[data-theme="default"] .brand-logo {
    transform: rotate(45deg);
    border-radius: 16px;
    border: 2px solid var(--accent-1);
    animation: breathe 3s infinite;
}

@keyframes breathe {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 243, 255, 0.4); }
    50% { box-shadow: 0 0 30px rgba(0, 243, 255, 0.6); }
}

.brand-logo svg {
    width: 36px;
    height: 36px;
    fill: white;
}

[data-theme="default"] .brand-logo svg {
    transform: rotate(-45deg);
}

.brand-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-1);
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.brand-slogan {
    font-size: 13px;
    color: var(--text-sub);
    opacity: 0.8;
}

.form-box {
    width: 100%;
    max-width: 340px;
    padding: 0 var(--spacing-sm);
    /* 移动端动画 */
    animation: slideUp 0.4s ease-out;
}

.input-wrap {
    margin-bottom: var(--spacing-md);
}

.input-label {
    display: block;
    font-size: 14px;
    color: var(--text-sub);
    margin-bottom: 6px;
    font-weight: 500;
    padding-left: 4px;
}

.input-field {
    width: 100%;
    height: 48px; /* 移动端最小触摸高度 */
    min-height: 48px;
    padding: 0 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-main);
    font-size: 16px; /* 防止 iOS 缩放 */
    outline: none;
    transition: all 0.3s;
    /* 移动端优化 */
    -webkit-appearance: none;
    appearance: none;
}

.input-field:focus {
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
    transform: translateY(-1px);
}

[data-theme="default"] .input-field:focus {
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
}

/* 移动端按钮样式优化 */
.btn {
    width: 100%;
    min-height: 48px; /* 最小触摸目标 48px */
    height: 48px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    /* 移除移动端点击高亮 */
    -webkit-tap-highlight-color: transparent;
    /* 防止文字被选中 */
    -webkit-user-select: none;
    user-select: none;
}

/* 移动端活跃的点击状态 */
.btn:active {
    transform: scale(0.96);
    opacity: 0.9;
}

.btn-primary {
    background: var(--accent-1);
    color: white;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.3);
}

[data-theme="default"] .btn-primary {
    background: transparent;
    border: 1.5px solid var(--accent-1);
    color: var(--accent-1);
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.2);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-sub);
    margin-top: 12px;
}

/* ============================================
 * 主应用布局 - 移动端全屏适配
 * ============================================ */
#app {
    display: none;
    flex-direction: column;
    height: 100%;
    height: 100dvh; /* 动态视口高度 */
    width: 100%;
    position: relative;
    z-index: 1;
    background: var(--bg-primary);
    /* 防止内容溢出 */
    overflow: hidden;
    /* 移动端优化 */
    touch-action: pan-y;
}

/* 页面基础 - 移动端全屏 */
.page {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: var(--bg-primary);
    animation: fadeIn 0.25s ease-out;
    /* 硬件加速 */
    transform: translate3d(0, 0, 0);
    will-change: transform, opacity;
}

.page.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate3d(0, 10px, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* 导航栏 - 移动端高度优化 */
.navbar {
    height: 52px; /* 稍微降低移动端高度 */
    min-height: 52px;
    padding: 0 var(--spacing-sm);
    padding-top: var(--safe-top);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    /* 防止导航栏被压缩 */
    flex-shrink: 0;
}

.nav-title {
    font-size: 17px; /* iOS 标准导航栏字体 */
    font-weight: 600;
    /* 居中显示，留出返回按钮空间 */
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

[data-theme="default"] .nav-title {
    color: var(--accent-1);
    text-shadow: 0 0 10px rgba(0, 243, 255, 0.3);
}

.nav-back {
    min-width: 36px;
    min-height: 36px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-main);
    cursor: pointer;
    /* 移动端点击优化 */
    -webkit-tap-highlight-color: transparent;
    padding: 0;
    z-index: 10;
}

.nav-back svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* 内容区 - 移动端滚动优化 */
.content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* iOS 弹性滚动 */
    overscroll-behavior: contain; /* 防止滚动传播 */
    padding: var(--spacing-sm);
    background: var(--bg-content);
    /* 硬件加速 */
    transform: translate3d(0, 0, 0);
}

/* ============================================
 * 聊天列表组件 - 移动端优化
 * ============================================ */
.chat-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    /* 移动端点击区域优化 */
    min-height: 72px;
    position: relative;
    /* 硬件加速 */
    transform: translate3d(0, 0, 0);
}

[data-theme="default"] .chat-item {
    border-left: 3px solid var(--accent-1);
}

.chat-item.public {
    border-left-color: var(--accent-2);
}

[data-theme="default"] .chat-item.public {
    background: linear-gradient(90deg, rgba(255,0,255,0.05), transparent);
}

/* 移动端点击反馈 */
.chat-item:active {
    opacity: 0.7;
    transform: scale(0.98);
    transition: transform 0.1s;
}

.chat-avatar {
    width: 48px;
    height: 48px;
    min-width: 48px; /* 防止被压缩 */
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
    margin-right: 12px;
    flex-shrink: 0;
    box-shadow: var(--shadow);
    overflow: hidden;
    /* 防止图片拖拽 */
    -webkit-user-drag: none;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* 防止图片拖拽 */
    pointer-events: none;
    -webkit-user-drag: none;
}

.chat-avatar.public {
    background: linear-gradient(135deg, var(--accent-2), var(--accent-3));
}

.chat-info {
    flex: 1;
    min-width: 0; /* 允许文本截断 */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

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

.chat-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.chat-time {
    font-size: 11px;
    color: var(--text-sub);
    flex-shrink: 0;
    margin-left: 4px;
}

.chat-preview {
    font-size: 13px;
    color: var(--text-sub);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1.4;
}

.unread-badge {
    background: var(--accent-3);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    font-weight: 600;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(255, 0, 60, 0.3);
}

/* ============================================
 * 底部导航栏 - 移动端安全区适配
 * ============================================ */
.tabbar {
    height: 56px; /* 标准移动端底部导航高度 */
    min-height: 56px;
    padding-bottom: var(--safe-bottom);
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    display: flex;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    /* 防止 iOS 底部手势条误判 */
    padding-bottom: max(var(--safe-bottom), 8px);
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-sub);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    /* 移动端点击优化 */
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.tab-item:active {
    opacity: 0.6;
}

.tab-item.active {
    color: var(--accent-1);
}

.tab-item svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    transition: transform 0.2s;
}

.tab-item:active svg {
    transform: scale(0.9);
}

.tab-item span {
    font-size: 10px;
    font-weight: 500;
}

.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 20px;
    height: 2px;
    background: var(--accent-1);
    border-radius: 2px;
    /* 炫酷版发光效果 */
    box-shadow: 0 0 8px currentColor;
}

/* ============================================
 * 用户卡片 - 移动端优化
 * ============================================ */
.user-card {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    /* 移动端点击区域 */
    min-height: 64px;
}

.user-info {
    flex: 1;
    margin-left: 12px;
    min-width: 0;
    overflow: hidden;
}

.user-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-id {
    font-size: 12px;
    color: var(--text-sub);
    opacity: 0.8;
}

.user-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 6px;
    flex-shrink: 0;
}

.user-status.online {
    background: var(--accent-4);
    box-shadow: 0 0 0 2px var(--card);
}

.user-status.offline {
    background: var(--text-sub);
    opacity: 0.5;
}

.btn-small {
    padding: 6px 14px;
    min-height: 32px;
    background: var(--accent-1);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    /* 移动端点击优化 */
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
}

[data-theme="default"] .btn-small {
    background: transparent;
    border: 1px solid var(--accent-1);
    color: var(--accent-1);
}

.btn-small:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* ============================================
 * 个人中心 - 移动端优化
 * ============================================ */
.profile-header {
    text-align: center;
    padding: 32px var(--spacing-md);
    /* 减少顶部padding，适配小屏幕 */
    padding-top: max(20px, 4vh);
}

.avatar-xl {
    width: 80px;
    height: 80px;
    min-width: 80px;
    min-height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 32px;
    font-weight: 700;
    color: white;
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
    /* 防止拖拽 */
    -webkit-user-drag: none;
}

.avatar-xl img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.avatar-xl .upload-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

/* 移动端始终显示上传提示，或点击显示 */
@media (hover: none) {
    .avatar-xl .upload-overlay {
        opacity: 1;
        height: 24px;
        font-size: 10px;
    }
}

.avatar-xl:active .upload-overlay,
.avatar-xl:hover .upload-overlay {
    opacity: 1;
}

.profile-name {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    padding: 0 var(--spacing-sm);
    word-break: break-all;
}

.profile-id {
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 10px;
    opacity: 0.8;
}

.admin-badge {
    display: inline-block;
    padding: 4px 12px;
    background: linear-gradient(90deg, var(--accent-3), var(--accent-2));
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(255, 0, 60, 0.3);
}

.menu-list {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin: 0 var(--spacing-sm) 16px;
    overflow: hidden;
    /* 移动端微妙的阴影 */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.menu-item {
    padding: 14px var(--spacing-md);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    /* 最小点击高度 */
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:active {
    background: rgba(128,128,128,0.15);
}

.menu-left {
    font-size: 15px;
    font-weight: 500;
}

.menu-right {
    font-size: 14px;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 主题选择面板 - 移动端横向滚动 */
.theme-panel {
    padding: var(--spacing-sm);
    background: rgba(0,0,0,0.2);
    border-top: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.theme-options {
    display: flex;
    gap: 10px;
    /* 确保可以滚动 */
    min-width: min-content;
    padding-bottom: 4px;
}

.theme-btn {
    flex: 0 0 auto;
    width: 100px;
    padding: 12px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    background: var(--card);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.theme-btn.active {
    border-color: var(--accent-1);
    background: rgba(0, 122, 255, 0.1);
    transform: scale(0.98);
}

[data-theme="default"] .theme-btn.active {
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.2);
}

.theme-btn:active {
    transform: scale(0.95);
}

.theme-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    margin: 0 auto 6px;
}

.theme-icon.cyber {
    background: linear-gradient(135deg, #00f3ff, #ff00ff);
    box-shadow: 0 0 10px rgba(0, 243, 255, 0.5);
}

.theme-icon.simple {
    background: linear-gradient(135deg, #f2f3f7, #ffffff);
    border: 1px solid #e5e5ea;
}

.theme-icon.dark {
    background: linear-gradient(135deg, #1c1c1e, #2c2c2e);
    border: 1px solid #38383a;
}

.theme-title {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 2px;
}

.theme-desc {
    font-size: 10px;
    color: var(--text-sub);
    opacity: 0.8;
}

.btn-danger {
    width: calc(100% - 32px);
    min-height: 48px;
    height: 48px;
    background: var(--accent-3);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    margin: 8px 16px 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 4px 12px rgba(255, 0, 60, 0.2);
}

[data-theme="default"] .btn-danger {
    background: transparent;
    border: 1px solid var(--accent-3);
    color: var(--accent-3);
    box-shadow: 0 0 20px rgba(255, 0, 60, 0.2);
}

.btn-danger:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* ============================================
 * 聊天消息样式 - 含昵称显示（关键修改部分）
 * ============================================ */

/* 消息列表容器 */
.msg-list {
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: 8px; /* 减小间距，因为昵称会占用额外空间 */
    /* 确保底部留出输入框空间 */
    padding-bottom: 80px;
}

/* 消息行 - 基础布局 */
.msg-row {
    display: flex;
    animation: slideUp 0.3s ease-out;
    max-width: 85%;
    position: relative;
    align-items: flex-start; /* 关键：顶部对齐，适配昵称 */
}

.msg-row.self {
    justify-content: flex-end;
    align-self: flex-end;
    margin-left: auto;
}

.msg-row.other {
    justify-content: flex-start;
    align-self: flex-start;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translate3d(0, 10px, 0);
    }
    to { 
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* 头像样式 */
.msg-avatar {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
    margin-right: 8px;
    flex-shrink: 0;
    overflow: hidden;
    -webkit-user-drag: none;
}

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

/* 自己消息的头像（通常隐藏或用自己头像） */
.msg-row.self .msg-avatar {
    display: none; /* 简洁起见，自己的消息不显示头像，只在对方消息显示 */
}

/* 【关键】消息内容区域 - 包含昵称和气泡 */
.msg-content {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    min-width: 0; /* 允许flex子项收缩 */
}

/* 【关键】发送者昵称样式 */
.msg-sender-name {
    font-size: 11px;
    color: var(--text-sub);
    margin-bottom: 3px;
    padding-left: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    opacity: 0.85;
    line-height: 1.2;
    font-weight: 500;
}

/* 自己的消息昵称靠右对齐 */
.msg-row.self .msg-sender-name {
    text-align: right;
    padding-left: 0;
    padding-right: 4px;
    align-self: flex-end;
}

/* 对方的消息昵称靠左对齐 */
.msg-row.other .msg-sender-name {
    text-align: left;
    align-self: flex-start;
}

/* 消息气泡 */
.msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    position: relative;
    /* 移动端更好的文本渲染 */
    -webkit-font-smoothing: antialiased;
}

/* 自己消息的气泡（靠右） */
.msg-row.self .msg-bubble {
    background: var(--accent-1);
    color: white;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

[data-theme="default"] .msg-row.self .msg-bubble {
    background: rgba(0, 243, 255, 0.2);
    color: var(--text-main);
    border: 1px solid rgba(0, 243, 255, 0.3);
    backdrop-filter: blur(10px);
}

/* 对方消息的气泡（靠左） */
.msg-row.other .msg-bubble {
    background: var(--card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

/* 系统消息（中间显示，例如"对方正在输入..."） */
.msg-row.system {
    align-self: center;
    max-width: 90%;
    margin: 4px 0;
}

.msg-row.system .msg-bubble {
    background: rgba(0,0,0,0.3);
    color: var(--text-sub);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 12px;
    border: none;
    text-align: center;
}

/* 时间分隔线 */
.msg-divider {
    text-align: center;
    margin: 12px 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msg-divider::before {
    content: '';
    position: absolute;
    left: 20px;
    right: 20px;
    height: 1px;
    background: var(--border);
    opacity: 0.5;
}

.msg-divider span {
    background: var(--bg-content);
    padding: 0 12px;
    font-size: 11px;
    color: var(--text-sub);
    position: relative;
    z-index: 1;
}

/* 消息元信息（时间和已读状态） */
.msg-meta {
    font-size: 10px;
    color: var(--text-sub);
    margin-top: 3px;
    opacity: 0.7;
    display: flex;
    align-items: center;
    gap: 4px;
}

.msg-row.self .msg-meta {
    justify-content: flex-end;
    padding-right: 4px;
}

.msg-row.other .msg-meta {
    justify-content: flex-start;
    padding-left: 4px;
}

/* 消息状态图标 */
.msg-status {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
}

.msg-status.sent::after { 
    content: '✓'; 
    opacity: 0.6; 
}

.msg-status.delivered::after { 
    content: '✓✓'; 
    opacity: 0.6; 
}

.msg-status.read::after { 
    content: '✓✓'; 
    color: var(--accent-4); 
    opacity: 1;
    font-weight: bold;
}

/* 媒体消息样式 */
.msg-media {
    max-width: 220px;
    max-height: 280px;
    border-radius: 12px;
    overflow: hidden;
    -webkit-user-drag: none;
    background: var(--bg-body);
    cursor: pointer;
}

.msg-media img {
    width: 100%;
    height: auto;
    max-height: 260px;
    object-fit: cover;
    display: block;
    -webkit-user-drag: none;
}

.msg-media video {
    width: 100%;
    max-height: 240px;
    display: block;
    border-radius: 12px;
}

/* ============================================
 * 新版语音消息样式 - 点击播放 + 波形动画 + 未读标记
 * ============================================ */

/* 语音消息容器 - 整个区域可点击 */
.voice-message {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.2s;
    max-width: 260px;
    -webkit-tap-highlight-color: transparent;
}

.voice-message:active {
    transform: scale(0.95);
}

/* 语音气泡 */
.voice-bubble {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 18px;
    background: rgba(0, 243, 255, 0.1);
    border: 1px solid rgba(0, 243, 255, 0.3);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    min-width: 110px;
    max-width: 240px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

/* 自己发送的语音（靠右，反色） */
.msg-row.self .voice-bubble {
    background: rgba(0, 200, 255, 0.15);
    border-color: rgba(0, 243, 255, 0.4);
    flex-direction: row-reverse;
}

/* 时长文字 */
.voice-duration {
    font-family: 'Orbitron', sans-serif;
    font-size: 12px;
    color: var(--accent-1, #00f3ff);
    font-weight: 700;
    min-width: 28px;
    text-align: center;
    text-shadow: 0 0 5px rgba(0, 243, 255, 0.5);
    letter-spacing: 1px;
    transition: all 0.3s;
}

/* 波形动画容器 */
.waveform {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
    width: 50px;
    justify-content: center;
    flex-shrink: 0;
}

.waveform span {
    display: block;
    width: 3px;
    background: var(--accent-1, #00f3ff);
    border-radius: 2px;
    opacity: 0.3;
    transition: all 0.3s;
    height: 30%;
    box-shadow: 0 0 4px rgba(0, 243, 255, 0.3);
}

/* 播放状态：只有.playing类时才动画 */
.voice-message.playing .waveform span {
    animation: voiceWave 0.6s ease-in-out infinite;
    opacity: 1;
    background: #00ff9d;
    box-shadow: 0 0 8px #00ff9d;
}

/* 播放状态：气泡高亮发光 */
.voice-message.playing .voice-bubble {
    background: rgba(0, 243, 255, 0.25);
    border-color: #00f3ff;
    box-shadow: 0 0 25px rgba(0, 243, 255, 0.5), inset 0 0 15px rgba(0, 243, 255, 0.1);
    animation: voicePulse 1.5s infinite;
}

/* 状态图标（麦克风） */
.voice-status-icon {
    width: 20px;
    height: 20px;
    fill: var(--accent-1, #00f3ff);
    opacity: 0.7;
    transition: all 0.3s;
    flex-shrink: 0;
}

.voice-message.playing .voice-status-icon {
    opacity: 1;
    fill: #00ff9d;
    filter: drop-shadow(0 0 5px #00ff9d);
    animation: micPulse 1s infinite;
}

/* 波形动画关键帧 */
@keyframes voiceWave {
    0%, 100% { height: 20%; }
    50% { height: 100%; }
}

/* 错落动画延迟 - 创建波浪效果 */
.voice-message.playing .waveform span:nth-child(1) { animation-delay: 0s; }
.voice-message.playing .waveform span:nth-child(2) { animation-delay: 0.1s; }
.voice-message.playing .waveform span:nth-child(3) { animation-delay: 0.05s; }
.voice-message.playing .waveform span:nth-child(4) { animation-delay: 0.15s; }
.voice-message.playing .waveform span:nth-child(5) { animation-delay: 0.08s; }

/* 气泡脉冲动画 */
@keyframes voicePulse {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 243, 255, 0.4); }
    50% { box-shadow: 0 0 35px rgba(0, 243, 255, 0.7); }
}

/* 麦克风脉冲 */
@keyframes micPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* 未读标记红点 */
.voice-message.unread::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ff003c;
    border-radius: 50%;
    box-shadow: 0 0 12px #ff003c, 0 0 20px #ff003c;
    top: 50%;
    right: -15px;
    transform: translateY(-50%);
    animation: unreadPulse 2s infinite;
    z-index: 10;
}

/* 自己发送的（右侧）红点在左边 */
.msg-row.self .voice-message.unread::after {
    right: auto;
    left: -15px;
}

/* 未读红点脉冲动画 */
@keyframes unreadPulse {
    0%, 100% { opacity: 1; transform: translateY(-50%) scale(1); }
    50% { opacity: 0.8; transform: translateY(-50%) scale(1.2); }
}

/* 已读状态（播放后红点消失） */
.voice-message.read::after {
    display: none;
}

/* ============================================
 * 旧版语音样式已删除（原.msg-audio相关）
 * ============================================ */

/* ============================================
 * 输入框 - 移动端键盘适配
 * ============================================ */
.input-bar {
    padding: 8px 12px;
    padding-bottom: calc(8px + var(--safe-bottom));
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    /* 固定在底部 */
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 150px;
}

.msg-input {
    flex: 1;
    min-height: 40px;
    max-height: 100px;
    height: auto;
    padding: 10px 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-main);
    font-size: 16px; /* 关键：防止 iOS 缩放 */
    outline: none;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
    resize: none;
    overflow-y: auto;
    font-family: inherit;
}

.msg-input:focus {
    border-color: var(--accent-1);
}

/* 输入操作按钮 */
.input-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

.input-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-sub);
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.input-btn:active {
    transform: scale(0.9);
    background: var(--accent-1);
    color: white;
    border-color: var(--accent-1);
}

.input-btn svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* 发送按钮 */
.btn-send {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: var(--accent-1);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.3);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s;
}

.btn-send:active {
    transform: scale(0.9);
}

.btn-send svg {
    width: 18px;
    height: 18px;
    fill: white;
    margin-left: 2px;
}

/* ============================================
 * 搜索模态框 - 移动端全屏优化
 * ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    z-index: 2000;
    flex-direction: column;
    transform: translate3d(0, 0, 0);
}

.modal.active {
    display: flex;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    padding: 12px 16px;
    padding-top: calc(12px + var(--safe-top));
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--bg-primary);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    height: 38px;
    min-height: 38px;
    padding: 0 12px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 16px;
    -webkit-appearance: none;
    appearance: none;
}

.search-input:focus {
    border-color: var(--accent-1);
    outline: none;
}

/* ============================================
 * Toast提示 - 移动端优化
 * ============================================ */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 3000;
    transition: transform 0.2s;
    border: 1px solid var(--accent-1);
    max-width: 80%;
    text-align: center;
    line-height: 1.4;
    backdrop-filter: blur(10px);
}

.toast.show {
    transform: translate(-50%, -50%) scale(1);
}

/* ============================================
 * 图片预览 - 移动端手势支持
 * ============================================ */
.image-preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.95);
    z-index: 4000;
    align-items: center;
    justify-content: center;
    touch-action: pan-y pinch-zoom;
}

.image-preview-modal.active {
    display: flex;
}

.image-preview-modal img {
    max-width: 95%;
    max-height: 85%;
    object-fit: contain;
    -webkit-user-drag: none;
    pointer-events: none;
}

.image-preview-close {
    position: absolute;
    top: max(16px, var(--safe-top));
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    -webkit-tap-highlight-color: transparent;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.image-preview-close:active {
    background: rgba(255,255,255,0.3);
    transform: scale(0.95);
}

/* ============================================
 * 文件消息样式（补充）
 * ============================================ */
.msg-file {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
    max-width: 260px;
    padding: 4px 2px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.file-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.file-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.file-size {
    font-size: 11px;
    opacity: 0.6;
}

/* ============================================
 * 工具类
 * ============================================ */
.hidden {
    display: none !important;
}

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

/* 加载动画 */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px var(--spacing-md);
    color: var(--text-sub);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    fill: var(--border);
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
    line-height: 1.5;
}

/* 滚动条 */
::-webkit-scrollbar {
    width: 3px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ============================================
 * 响应式适配
 * ============================================ */

/* 小屏幕设备优化 (iPhone SE等) */
@media (max-width: 375px) {
    .chat-name {
        font-size: 14px;
    }
    
    .chat-preview {
        font-size: 12px;
    }
    
    .chat-avatar {
        width: 44px;
        height: 44px;
        min-width: 44px;
    }
    
    .msg-bubble {
        font-size: 14px;
        padding: 8px 12px;
    }
    
    .msg-sender-name {
        font-size: 10px;
    }
    
    .input-btn {
        width: 36px;
        height: 36px;
    }
    
    .btn-send {
        width: 36px;
        height: 36px;
    }
    
    .voice-bubble {
        min-width: 100px;
        padding: 8px 12px;
    }
    
    .voice-duration {
        font-size: 11px;
    }
    
    .waveform {
        width: 40px;
        height: 20px;
    }
}

/* 横屏优化 */
@media (orientation: landscape) and (max-height: 500px) {
    .profile-header {
        padding: 20px var(--spacing-md);
    }
    
    .avatar-xl {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
    
    .tabbar {
        height: 48px;
    }
    
    .tab-item svg {
        width: 22px;
        height: 22px;
    }
}

/* 平板横屏适配 */
@media (min-width: 768px) and (orientation: landscape) {
    .form-box {
        max-width: 400px;
    }
    
    .chat-item {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }
    
    .msg-row {
        max-width: 70%;
    }
}

/* 安全区域兜底（老版本iOS兼容） */
@supports not (padding-top: env(safe-area-inset-top)) {
    .navbar {
        padding-top: 20px;
    }
    
    .tabbar {
        padding-bottom: 8px;
    }
}
/* ============================================
 * 语音消息颜色修复 - 蓝色气泡内对比度优化
 * ============================================ */

/* 自己发送的语音消息（在蓝色消息气泡内） */
.msg-row.self .voice-bubble {
    background: rgba(255, 255, 255, 0.2); /* 改为半透明白色，与蓝色背景形成对比 */
    border: 1.5px solid rgba(255, 255, 255, 0.6); /* 白色半透明边框 */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15), inset 0 0 10px rgba(255, 255, 255, 0.1); /* 双层阴影增加层次 */
    backdrop-filter: blur(10px);
}

/* 自己语音消息的图标和文字改为白色，更清晰 */
.msg-row.self .voice-status-icon {
    fill: #ffffff !important; /* 白色图标 */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2)); /* 轻微阴影增加立体 */
    opacity: 0.95;
}

.msg-row.self .voice-duration {
    color: #ffffff !important; /* 白色文字 */
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); /* 文字阴影防止看不清 */
    font-weight: 700;
}

/* 自己语音消息的波形条改为白色 */
.msg-row.self .waveform span {
    background: rgba(255, 255, 255, 0.8) !important; /* 白色半透明波形 */
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
}

/* 播放状态下保持绿色高亮（但加深对比） */
.msg-row.self .voice-message.playing .voice-bubble {
    background: rgba(255, 255, 255, 0.35); /* 播放时背景更亮 */
    border-color: rgba(0, 255, 157, 0.8); /* 绿色发光边框 */
    box-shadow: 0 0 20px rgba(0, 255, 157, 0.3), inset 0 0 15px rgba(0, 255, 157, 0.1);
}

.msg-row.self .voice-message.playing .voice-status-icon {
    fill: #00ff9d !important; /* 播放状态图标变绿 */
    filter: drop-shadow(0 0 5px #00ff9d);
}

.msg-row.self .voice-message.playing .voice-duration {
    color: #00ff9d !important; /* 播放状态时长变绿 */
    text-shadow: 0 0 8px rgba(0, 255, 157, 0.5);
}

.msg-row.self .voice-message.playing .waveform span {
    background: #00ff9d !important; /* 播放状态波形变绿 */
    box-shadow: 0 0 8px #00ff9d;
}

/* 未读红点位置调整（蓝色气泡内） */
.msg-row.self .voice-message.unread::after {
    background: #ffffff; /* 未读点改为白色（在蓝色背景上更显眼） */
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
    left: -12px;
    right: auto;
}

/* ============================================
 * 移动端适配修复 - 语音消息和聊天界面优化
 * ============================================ */

/* 基础消息行优化 - 防止溢出 */
.msg-row {
    max-width: 88%; /* 稍微减小，留出边距 */
    margin-bottom: 4px;
}

/* 语音消息移动端优化 */
@media (max-width: 480px) {
    /* 语音消息容器宽度限制 */
    .voice-message {
        max-width: 220px; /* 限制最大宽度 */
        min-width: 100px; /* 最小宽度保证可点击 */
    }
    
    /* 语音气泡内边距缩小 */
    .voice-bubble {
        padding: 8px 12px;
        min-width: 90px;
        gap: 6px; /* 减小间距 */
    }
    
    /* 波形宽度减小 */
    .waveform {
        width: 40px; /* 从50px减小 */
        height: 20px; /* 从24px减小 */
        gap: 2px; /* 条间距减小 */
    }
    
    .waveform span {
        width: 2.5px; /* 细一点 */
    }
    
    /* 字号减小 */
    .voice-duration {
        font-size: 11px;
        min-width: 24px;
    }
    
    .voice-status-icon {
        width: 16px;
        height: 16px;
    }
    
    /* 昵称字号减小，防止换行 */
    .msg-sender-name {
        font-size: 10px;
        max-width: 120px;
        margin-bottom: 2px;
    }
    
    /* 消息气泡内边距调整 */
    .msg-bubble {
        padding: 8px 12px;
        font-size: 14px;
        max-width: 100%; /* 确保不溢出 */
    }
    
    /* 消息内容区域最大宽度限制 */
    .msg-content {
        max-width: calc(100vw - 80px); /* 减去头像和边距 */
    }
    
    /* 自己消息的右侧留白 */
    .msg-row.self {
        padding-right: 8px;
        margin-left: auto;
        max-width: 88%;
    }
    
    /* 对方消息的左侧留白 */
    .msg-row.other {
        padding-left: 4px;
        max-width: 88%;
    }
    
    /* 头像缩小一点 */
    .msg-avatar {
        width: 32px;
        height: 32px;
        min-width: 32px;
        margin-right: 6px;
        font-size: 12px;
    }
    
    /* 未读红点位置调整 */
    .voice-message.unread::after {
        width: 8px;
        height: 8px;
        right: -12px;
        box-shadow: 0 0 6px currentColor;
    }
    
    .msg-row.self .voice-message.unread::after {
        left: -12px;
    }
    
    /* 元信息字号 */
    .msg-meta {
        font-size: 9px;
        margin-top: 2px;
    }
}

/* 超小屏幕适配（iPhone SE/小屏安卓） */
@media (max-width: 375px) {
    .voice-message {
        max-width: 200px;
    }
    
    .voice-bubble {
        padding: 6px 10px;
        min-width: 80px;
        gap: 4px;
    }
    
    .waveform {
        width: 35px;
        height: 18px;
        gap: 2px;
    }
    
    .voice-duration {
        font-size: 10px;
        min-width: 22px;
    }
    
    .msg-content {
        max-width: calc(100vw - 70px);
    }
    
    .msg-bubble {
        padding: 6px 10px;
        font-size: 13px;
    }
}

/* 横屏模式优化（手机横过来） */
@media (max-height: 500px) and (orientation: landscape) {
    .voice-message {
        max-width: 200px;
    }
    
    .msg-content {
        max-width: calc(100vw - 100px);
    }
}

/* 修复消息列表底部被输入框遮挡 */
.msg-list {
    padding-bottom: 100px; /* 确保底部留出足够空间 */
    width: 100%;
    box-sizing: border-box;
}

/* 输入框安全区域 */
.input-bar {
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 8px));
    min-height: 52px;
}

/* 确保媒体消息不溢出 */
.msg-media {
    max-width: 200px; /* 移动端限制媒体宽度 */
    max-height: 240px;
}

@media (min-width: 768px) {
    .msg-media {
        max-width: 280px; /* 平板可以大一点 */
        max-height: 320px;
    }
}

/* ============================================
 * 手机端显示不完全 - 终极修复方案
 * ============================================ */

/* 强制所有元素不溢出 */
* {
    max-width: 100vw;
    box-sizing: border-box;
}

/* 根元素强制约束 */
html, body {
    width: 100vw !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    position: relative;
}

/* 应用容器强制适配 */
#app, .page, .content {
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
}

/* 消息列表强制约束 */
.msg-list {
    width: 100% !important;
    max-width: 100vw !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
    box-sizing: border-box !important;
}

/* 消息行强制约束 - 防止溢出 */
.msg-row {
    max-width: calc(100vw - 16px) !important;
    width: auto !important;
    display: flex !important;
    flex-wrap: nowrap !important;
}

.msg-row.self {
    margin-left: auto !important;
    max-width: calc(100vw - 50px) !important; /* 留出左侧空间 */
}

.msg-row.other {
    margin-right: auto !important;
    max-width: calc(100vw - 50px) !important; /* 留出头像空间 */
}

/* 消息内容区域强制约束 */
.msg-content {
    max-width: calc(100vw - 60px) !important;
    min-width: 0 !important;
    flex: 1 !important;
    overflow: hidden !important;
}

/* 消息气泡强制约束 */
.msg-bubble {
    max-width: 100% !important;
    word-break: break-word !important;
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    display: inline-block !important;
    box-sizing: border-box !important;
}

/* 语音消息移动端强制适配 */
@media (max-width: 480px) {
    .voice-message {
        max-width: 180px !important; /* 进一步减小最大宽度 */
        min-width: 80px !important;
    }
    
    .voice-bubble {
        max-width: 180px !important;
        padding: 6px 10px !important;
        gap: 4px !important;
    }
    
    .waveform {
        width: 32px !important; /* 波形更窄 */
        height: 18px !important;
    }
    
    .voice-status-icon {
        width: 14px !important;
        height: 14px !important;
    }
    
    .voice-duration {
        font-size: 10px !important;
        min-width: 20px !important;
    }
}

/* 超小屏幕极致适配 */
@media (max-width: 375px) {
    .msg-row.self,
    .msg-row.other {
        max-width: calc(100vw - 40px) !important;
    }
    
    .voice-message {
        max-width: 160px !important;
    }
    
    .voice-bubble {
        max-width: 160px !important;
        padding: 5px 8px !important;
    }
}

/* 输入框区域强制适配 */
.input-bar {
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
    padding-left: 8px !important;
    padding-right: 8px !important;
}

.msg-input {
    max-width: calc(100vw - 200px) !important; /* 减去按钮宽度 */
    min-width: 50px !important;
}

/* 媒体消息强制约束 */
.msg-media {
    max-width: 100% !important;
    width: auto !important;
}

.msg-media img,
.msg-media video {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
}

/* 文件消息强制约束 */
.msg-file {
    max-width: 100% !important;
    min-width: 0 !important;
}

/* 聊天列表项强制约束 */
.chat-item {
    width: 100% !important;
    max-width: 100vw !important;
    box-sizing: border-box !important;
}

.chat-info {
    min-width: 0 !important;
    width: auto !important;
    flex: 1 !important;
}

/* 防止长文本溢出 */
.chat-name, .chat-preview, 
.msg-sender-name, 
.file-name {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 100% !important;
}

/* 底部导航栏强制约束 */
.tabbar {
    width: 100% !important;
    max-width: 100vw !important;
}

/* 安全区域预留（针对刘海屏） */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .msg-list {
        padding-bottom: calc(100px + env(safe-area-inset-bottom)) !important;
    }
    
    .input-bar {
        padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    }
    
    .tabbar {
        padding-bottom: env(safe-area-inset-bottom) !important;
    }
    
    /* ============================================
 * 消息红点提醒系统样式
 * ============================================ */

/* Tab图标包装器 - 用于定位红点 */
.tab-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 底部导航栏红点 */
.nav-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: linear-gradient(135deg, #ff003c, #ff0055);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(255, 0, 60, 0.4);
    border: 2px solid var(--bg-primary, #020204);
    z-index: 10;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    letter-spacing: -0.5px;
}

/* 99+ 特殊处理 */
.nav-badge.large {
    font-size: 10px;
    padding: 0 4px;
    min-width: 28px;
}

/* 聊天列表项红点 - 在右侧 */
.chat-badge {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: linear-gradient(135deg, #ff003c, #ff0055);
    color: white;
    font-size: 12px;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(255, 0, 60, 0.3);
    z-index: 5;
}

.chat-badge.large {
    font-size: 10px;
    min-width: 32px;
}

/* 消息预览区域留出红点空间 */
.chat-preview {
    padding-right: 30px; /* 给红点留位置 */
    position: relative;
}

/* 公共频道特殊标记 */
.chat-item.public .chat-badge {
    background: linear-gradient(135deg, #ff00ff, #ff00aa);
}

/* 移动端适配 */
@media (max-width: 375px) {
    .nav-badge {
        min-width: 16px;
        height: 16px;
        font-size: 10px;
        top: -4px;
        right: -6px;
    }
    
    .chat-badge {
        min-width: 18px;
        height: 18px;
        font-size: 11px;
    }
}

/* 隐藏状态 */
.hidden {
    display: none !important;
}

/* ============================================
 * 消息提醒设置样式
 * ============================================ */

/* 开关按钮样式 */
.toggle-switch {
    width: 50px;
    height: 28px;
    background: var(--border);
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s;
    -webkit-tap-highlight-color: transparent;
}

.toggle-switch.active {
    background: var(--accent-1);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch.active::after {
    left: 24px;
}

/* 设置项状态文字 */
.setting-status {
    font-size: 13px;
    color: var(--text-sub);
    display: flex;
    align-items: center;
    gap: 6px;
}

.setting-status.enabled {
    color: var(--accent-4);
}

.setting-status.muted {
    color: var(--accent-3);
}

/* 提醒选项面板 */
.notify-options {
    padding: 10px 16px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid var(--border);
}

.notify-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.notify-option:last-child {
    border-bottom: none;
}

.notify-option-left {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.notify-option-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.notify-option.selected .notify-option-icon {
    background: var(--accent-1);
    color: white;
}

/* 系统提示权限按钮 */
.permission-hint {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: #ffc107;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    margin: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.permission-hint button {
    background: #ffc107;
    color: #000;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}