/* ================= 全局重置 ================= */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { background-color: #1a1a1a; color: #fff; height: 100vh; width: 100vw; overflow: hidden; position: relative; }

/* 背景控制 */
#backgroundVideo { position: fixed; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.bg-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.4); z-index: -1; }

/* ================= 顶部设置按钮 ================= */
.top-settings-btn {
    position: fixed; top: 25px; right: 25px; width: 40px; height: 40px;
    border-radius: 50%; border: none; background: rgba(255, 255, 255, 0.1);
    color: #c9bfbf; cursor: pointer; z-index: 100;
    backdrop-filter: blur(10px); display: flex; align-items: center; justify-content: center;
}

/* ================= 侧边栏 ================= */
.custom-sidebar {
    position: fixed; top: 0; right: 0; width: 280px; height: 100vh;
    background: rgba(20, 20, 20, 0.95); z-index: 200; transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 60px 20px; border-left: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(20px);
}
.custom-sidebar.active { transform: translateX(0); }
.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); z-index: 150; display: none;
}
.sidebar-overlay.active { display: block; }
.sidebar-section { margin-bottom: 25px; }
.sidebar-section h3 { font-size: 12px; color: #888; text-transform: uppercase; margin-bottom: 10px; }
.sidebar-btn {
    width: 100%; padding: 12px; border-radius: 8px; border: none;
    background: rgba(255,255,255,0.08); color: #ddd; margin-bottom: 8px;
    text-align: left; cursor: pointer; display: flex; align-items: center; gap: 10px;
}
.close-side-btn {
    position: absolute; top: 15px; right: 15px; background: transparent; 
    border: none; color: #aaa; font-size: 1.2rem; cursor: pointer;
}
.setting-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: #ddd; }

/* ================= Avatar 容器 ================= */
#avatar-container {
    position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%);
    width: 300px; height: 300px; pointer-events: none; z-index: 1;
    display: flex; justify-content: center; align-items: center;
}

/* ================= 聊天气泡显示区 (新样式) ================= */
.chat-overlay-container {
    position: absolute; top: 70px; bottom: 180px; left: 50%; transform: translateX(-50%);
    width: 95%; max-width: 600px; overflow-y: auto; overflow-x: hidden;
    display: none; flex-direction: column; gap: 15px;
    z-index: 40; padding: 10px;
    scrollbar-width: none; -ms-overflow-style: none; /* 隐藏滚动条 */
}
.chat-overlay-container::-webkit-scrollbar { display: none; }

.message-wrapper {
    display: flex; align-items: flex-start; gap: 10px; max-width: 100%;
    animation: fadeIn 0.3s ease;
}
.message-wrapper.user { flex-direction: row-reverse; }

.message-wrapper .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.1); display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0; backdrop-filter: blur(5px);
}
.message-wrapper.user .avatar { background: #007aff; }
.message-wrapper.assistant .avatar { background: #ff9f0a; }

.message-content {
    background: rgba(30, 30, 30, 0.85); padding: 10px 14px; border-radius: 16px;
    color: #b1b1b1; font-size: 15px; line-height: 1.5; backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.05);
    max-width: 80%; word-wrap: break-word;
}
.message-wrapper.user .message-content {
    background: #5e6872; color: #fff; border-bottom-right-radius: 4px;
}
.message-wrapper.assistant .message-content {
    border-top-left-radius: 4px;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ================= 状态/字幕显示区 ================= */
/* 原本的 tts-display-area 调整位置，避免遮挡聊天 */
.tts-display-area {
    position: absolute; bottom: 200px; left: 50%; transform: translateX(-50%);
    width: 90%; text-align: center; font-size: 1.4rem; 
    color: rgba(121, 121, 121, 0.9); text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    z-index: 50; min-height: 30px; pointer-events: none;
}

/* ================= 底部交互条 ================= */
.bottom-bar {
    position: absolute; bottom: 40px; left: 50%;
    transform: translateX(-50%);
    display: flex; align-items: center; justify-content: center; gap: 30px; z-index: 20;
    width: 100%;
}

/* 键盘按钮 */
.kb-trigger {
    width: 50px; height: 50px; border-radius: 50%; border: none;
    background: rgba(255,255,255,0.1); color: #ccc; font-size: 20px;
    backdrop-filter: blur(5px); cursor: pointer;
}
.kb-trigger:hover { background: rgba(255,255,255,0.2); }

/* 核心麦克风容器 */
.mic-wrapper { position: relative; width: 80px; height: 80px; display: flex; justify-content: center; align-items: center; }

#voiceInputBtn {
    width: 76px; height: 76px; border-radius: 50%;
    border: none; background: rgba(255, 255, 255, 0.15);
    color: #fff; font-size: 30px; cursor: pointer;
    backdrop-filter: blur(15px); z-index: 2;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    outline: none; -webkit-tap-highlight-color: transparent;
}

/* 状态：连接中 */
#voiceInputBtn.connecting { background: #88847d; animation: pulse 1s infinite; }
/* 状态：通话中 */
#voiceInputBtn.talking { background: #e23a31; box-shadow: 0 0 20px rgba(255, 69, 58, 0.5); transform: scale(1.1); }

/* 波纹动画 */
.ripple {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.3);
    z-index: 1; opacity: 0; pointer-events: none;
}
.talking-mode .ripple { animation: ripple-anim 2s infinite; }

@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.6; } 100% { opacity: 1; } }
@keyframes ripple-anim { 
    0% { transform: scale(1); opacity: 0.5; border-color: rgba(255, 69, 58, 0.8); } 
    100% { transform: scale(2.2); opacity: 0; border-color: rgba(255, 69, 58, 0); } 
}

/* ================= 输入面板 (新版样式) ================= */
.input-panel {
    position: absolute; bottom: 128px; left: 50%; transform: translateX(-50%);
    width: 90%; max-width: 500px;
    background: rgba(30, 30, 30, 0.95);
    border-radius: 35px; padding: 10px 15px;
    display: none; align-items: center; gap: 10px;
    z-index: 60; backdrop-filter: blur(20px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
}
.input-panel.active { display: flex; animation: slideUp 0.3s ease; }

#messageInput { 
    flex: 1; background: none; border: none; color: #b4b4b4; 
    padding: 10px; font-size: 16px; outline: none; 
}
#sendBtn { 
    background: #4e4e4e; color: #fff; border: none; 
    width: 45px; height: 45px; border-radius: 50%; 
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#sendBtn:active { transform: scale(0.95); }

@keyframes slideUp { from { opacity: 0; transform: translate(-50%, 20px); } to { opacity: 1; transform: translate(-50%, 0); } }