:root {
    --bg-dark: #1e1e2f;
    --bg-card: #27293d;
    --text-main: #ffffff;
    --text-muted: #8888a0;
    --primary-pink: #e14eca;
    --primary-cyan: #00f2fe;
    --danger: #fd5d93;
    --border-color: #3b3d54;
}

[v-cloak] { display: none; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; } /* 移除 iOS 点击高亮 */

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    background: var(--bg-dark); 
    color: var(--text-main); 
    height: 100vh; /* 兼容老版本浏览器 */
    height: 100dvh; /* 动态高度，完美适配移动端浏览器的地址栏和工具栏 */
    overflow: hidden; 
    /* 防止移动端橡皮筋回弹效果影响体验 */
    position: fixed;
    width: 100%;
}

/* Auth Overlay */
.auth-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(30,30,47,0.9); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.auth-box { background: var(--bg-card); padding: 30px; border-radius: 12px; width: 90%; max-width: 350px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.auth-box input { width: 100%; padding: 12px; margin: 10px 0; border-radius: 6px; border: 1px solid var(--border-color); background: var(--bg-dark); color: white; outline: none; }
.auth-box input:focus { border-color: var(--primary-pink); }
.switch-mode { margin-top: 15px; color: var(--primary-cyan); cursor: pointer; font-size: 0.9em; }

/* Buttons */
.btn { background: var(--primary-pink); color: white; border: none; padding: 10px 20px; border-radius: 6px; cursor: pointer; font-weight: bold; width: 100%; transition: 0.2s; }
.btn:hover { background: #ba38a3; }
.btn-small { padding: 5px 10px; border-radius: 4px; font-size: 0.85em; border: none; cursor: pointer; background: var(--primary-cyan); color: #000; font-weight: bold; }
.btn-danger { background: var(--danger); color: white; }

/* Chat Layout */
.chat-container { 
    display: flex; 
    flex-direction: column; 
    height: 100vh; /* 兼容老版本 */
    height: 100dvh; /* 动态高度，防止内容被系统工具栏挤出去 */
    max-width: 1000px; 
    margin: 0 auto; 
    background: var(--bg-card); 
    box-shadow: 0 0 20px rgba(0,0,0,0.3); 
}

.chat-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    /* 核心适配：上边距加上安全区域高度（刘海屏），左右20px，下边距15px */
    padding: calc(15px + env(safe-area-inset-top)) 20px 15px; 
    border-bottom: 1px solid var(--border-color); 
    background: var(--bg-dark); 
}
.online-status { display: flex; align-items: center; font-weight: bold; color: var(--primary-cyan); }
.dot { width: 10px; height: 10px; background: #00f2fe; border-radius: 50%; margin-right: 8px; box-shadow: 0 0 8px #00f2fe; animation: pulse 2s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.4; } 100% { opacity: 1; } }
select { background: var(--bg-card); color: white; border: 1px solid var(--border-color); padding: 5px; border-radius: 4px; outline: none; margin-right: 10px; }

/* Messages Area */
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; scroll-behavior: smooth; -webkit-overflow-scrolling: touch; }
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
.message { display: flex; margin-bottom: 20px; animation: slideIn 0.3s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.msg-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-cyan); color: #000; display: flex; justify-content: center; align-items: center; font-weight: bold; font-size: 1.2em; flex-shrink: 0; }
.msg-content-wrapper { max-width: 70%; margin: 0 15px; }
.msg-username { font-size: 0.85em; color: var(--text-muted); margin-bottom: 5px; }
.time { font-size: 0.8em; margin-left: 10px; opacity: 0.7; }
.msg-bubble { background: var(--bg-dark); padding: 12px 16px; border-radius: 12px; border: 1px solid var(--border-color); word-wrap: break-word; line-height: 1.5; position: relative; }
.img-bubble { padding: 5px; background: transparent; border: none; }
.img-bubble img { max-width: 100%; border-radius: 8px; cursor: pointer; border: 1px solid var(--border-color); }

/* ================= 语音消息样式升级 ================= */
.voice-bubble { 
    background: var(--bg-dark); 
    cursor: pointer; 
    color: var(--primary-cyan); 
    font-weight: bold; 
    display: flex; 
    align-items: center;
    gap: 10px;
    min-width: 100px;
    user-select: none;
    transition: all 0.2s ease;
}

.voice-bubble:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* 播放中状态：增加发光效果 */
.voice-bubble.is-playing {
    border-color: var(--primary-cyan);
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
}

.message.self .voice-bubble {
    color: #fff;
}

.message.self .voice-bubble.is-playing {
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

/* 播放波纹动画 */
.voice-playing-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 16px;
    width: 20px;
}

.voice-playing-bars span {
    display: block;
    width: 3px;
    background-color: currentColor;
    border-radius: 1px;
    animation: voice-play-wave 0.8s infinite alternate;
}

.voice-playing-bars span:nth-child(1) { animation-delay: 0.0s; height: 4px; }
.voice-playing-bars span:nth-child(2) { animation-delay: 0.2s; height: 8px; }
.voice-playing-bars span:nth-child(3) { animation-delay: 0.4s; height: 6px; }

@keyframes voice-play-wave {
    0% { height: 4px; }
    100% { height: 16px; }
}

.voice-icon-static {
    font-size: 1.1em;
}

/* ======================================================= */

/* Self Message Alignment */
.message.self { flex-direction: row-reverse; }
.message.self .msg-avatar { background: var(--primary-pink); color: white; }
.message.self .msg-content-wrapper { display: flex; flex-direction: column; align-items: flex-end; }
.message.self .msg-bubble { background: #3c1e36; border-color: var(--primary-pink); color: white; }

/* Input Area */
.chat-input { 
    display: flex; 
    background: var(--bg-dark); 
    border-top: 1px solid var(--border-color); 
    align-items: center; 
    gap: 10px; 
    /* 核心适配：上、右15px，下边距加上安全区域高度（手势条），左15px */
    padding: 15px 15px calc(15px + env(safe-area-inset-bottom)) 15px; 
} 
.chat-input.disabled { opacity: 0.5; pointer-events: none; }
.input-actions { display: flex; gap: 10px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-card); border: 1px solid var(--border-color); color: white; display: flex; justify-content: center; align-items: center; cursor: pointer; font-size: 1.2em; transition: 0.2s; -webkit-user-select: none; }
.icon-btn:hover { background: var(--border-color); }

/* 录制中动画 */
.voice-btn.recording { 
    background: var(--danger); 
    border-color: var(--danger); 
    animation: recordingPulse 1s infinite; 
    transform: scale(1.2);
}

@keyframes recordingPulse {
    0% { box-shadow: 0 0 0 0 rgba(253, 93, 147, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(253, 93, 147, 0); }
    100% { box-shadow: 0 0 0 0 rgba(253, 93, 147, 0); }
}

.chat-input input[type="text"] { flex: 1; background: var(--bg-card); border: 1px solid var(--border-color); color: white; padding: 12px 15px; border-radius: 20px; outline: none; font-size: 16px; } /* 16px 字体防止 iOS 自动放大页面 */
.chat-input input[type="text"]:focus { border-color: var(--primary-cyan); }
.send-btn { width: auto; border-radius: 20px; padding: 10px 25px; }

/* 预览图适配 */
.preview-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); display: flex; align-items: center;
    justify-content: center; z-index: 2000; cursor: zoom-out;
}
.preview-overlay img { max-width: 95%; max-height: 95%; object-fit: contain; }