/* ==================== 全局变量与重置 ==================== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* 深色主题核心色板 */
  --bg-deep:      #0d0f11;
  --bg-surface:   #161a1e;
  --bg-elevated:  #1e2329;
  --bg-overlay:   #252b33;
  --bg-hover:     #2a323b;
  --bg-active:    #333d47;

  --border:       #2a3238;
  --border-light: #3a4550;

  --text:         #e8ecf0;
  --text-secondary:#a0aab4;
  --text-muted:   #65707d;

  --primary:      #07C160;
  --primary-hover:#06AE56;
  --primary-light:rgba(7,193,96,0.12);

  --danger:       #ef4444;
  --danger-hover: #dc2626;

  --radius:       10px;
  --radius-lg:    16px;
  --radius-sm:    6px;
  --sidebar-w:    320px;

  /* 立体阴影层 */
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.03) inset;
  --shadow-md:    0 4px 12px rgba(0,0,0,0.5), 0 1px 0 rgba(255,255,255,0.04) inset;
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.6), 0 1px 0 rgba(255,255,255,0.03) inset;
  --shadow-xl:    0 20px 60px rgba(0,0,0,0.7);
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: linear-gradient(170deg, #0f1318 0%, #141a20 50%, #0d1216 100%);
  color: var(--text);
}

/* ==================== 屏幕切换 ==================== */
.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; }

/* ==================== 登录页 ==================== */
#screen-login {
  align-items: center;
  justify-content: center;
  background: linear-gradient(150deg, #11161d 0%, #1a2330 40%, #0f1822 100%);
}

.login-container {
  background: linear-gradient(180deg, #1e252c 0%, #1a2028 100%);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-xl),
              0 1px 0 rgba(255,255,255,0.04) inset;
  border: 1px solid var(--border);
  text-align: center;
}

.login-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, #2d3a4a, #1e2d3d);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: #3b82f6;
  box-shadow: 0 4px 16px rgba(59,130,246,0.2),
              inset 0 1px 1px rgba(255,255,255,0.06);
}

.login-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 28px; }

.login-form { text-align: left; }

.input-group {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border-radius: var(--radius);
  padding: 0 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  transition: all 0.25s;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
}
.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7,193,96,0.12), inset 0 1px 3px rgba(0,0,0,0.3);
}
.input-group i {
  color: var(--text-muted);
  font-size: 16px;
  margin-right: 10px;
}
.input-group input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 14px 0;
  font-size: 15px;
  outline: none;
  color: var(--text);
  font-family: inherit;
}
.input-group input::placeholder { color: var(--text-muted); }

.btn-random {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bg-overlay);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.25s;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.btn-random:hover {
  background: var(--primary);
  color: #fff;
  transform: rotate(180deg);
}

.btn-block { width: 100%; }

.btn-primary {
  padding: 13px 24px;
  background: linear-gradient(180deg, #07C160 0%, #06AE56 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(7,193,96,0.25),
              inset 0 1px 0 rgba(255,255,255,0.08);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #06AE56 0%, #05944A 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(7,193,96,0.35);
}
.btn-primary:active { transform: scale(0.98); }

.login-hint {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ==================== 主界面布局 ==================== */
#screen-main {
  flex-direction: row;
  background: var(--bg-deep);
}

/* ==================== 侧边栏 ==================== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-deep) 100%);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  box-shadow: inset -1px 0 1px rgba(255,255,255,0.02);
}

.sidebar-header {
  display: flex;
  align-items: center;
  padding: 16px;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(59,130,246,0.3);
}

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 15px; font-weight: 600; color: var(--text); }
.user-status { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.user-status .text-success { color: var(--primary); }

.btn-icon {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text); }

/* 搜索 */
.sidebar-search {
  display: flex;
  align-items: center;
  padding: 4px 12px;
  margin: 10px 12px;
  background: var(--bg-deep);
  border-radius: var(--radius-sm);
  gap: 8px;
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}
.sidebar-search i { color: var(--text-muted); font-size: 13px; }
.sidebar-search input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 13px;
  outline: none;
  color: var(--text);
  font-family: inherit;
}
.sidebar-search input::placeholder { color: var(--text-muted); }

/* 标签切换 */
.sidebar-tabs {
  display: flex;
  padding: 0 12px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  padding: 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  font-family: inherit;
  font-weight: 500;
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text-secondary); }
.tab-btn.active {
  background: var(--bg-overlay);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* 联系人列表 */
.contact-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.list-content.hidden { display: none; }

.contact-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.contact-item:hover { background: var(--bg-hover); }
.contact-item.active {
  background: var(--bg-overlay);
  box-shadow: inset 3px 0 0 var(--primary);
}
.contact-item:active { background: var(--bg-active); }

.contact-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.contact-avatar.user {
  background: linear-gradient(135deg, #3b82f6, #2dd4bf);
}
.contact-avatar.group {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.contact-avatar i { font-size: 20px; }

.contact-info { flex: 1; min-width: 0; }
.contact-name { font-size: 14px; font-weight: 500; color: var(--text); }
.contact-preview {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-badge {
  font-size: 10px;
  background: var(--primary);
  color: #fff;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 500;
  flex-shrink: 0;
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(7,193,96,0.5);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 13px; }
.empty-state.hidden { display: none; }

/* ==================== 聊天区域 ==================== */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg-deep) 0%, #101418 100%);
  min-width: 0;
}

/* 空状态 */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}
.chat-empty-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
}
.chat-empty-icon i { font-size: 36px; color: var(--text-muted); }
.chat-empty h2 { font-size: 20px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.chat-empty p { font-size: 14px; color: var(--text-muted); margin-bottom: 24px; }

.welcome-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-width: 360px;
}
.feature-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-overlay);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.feature-item i { font-size: 16px; color: var(--primary); }

/* 聊天头 — 微信风格 */
.chat-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  background: #1a2028;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-header.hidden { display: none; }

.chat-target-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.chat-target-avatar {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  flex-shrink: 0;
}
.chat-target-avatar.user { background: linear-gradient(135deg, #3b82f6, #2dd4bf); }
.chat-target-avatar.group { background: linear-gradient(135deg, #6366f1, #8b5cf6); }

.chat-target-text { min-width: 0; }
.chat-target-name { font-size: 16px; font-weight: 600; color: var(--text); }
.chat-target-status { font-size: 11px; color: var(--text-muted); }

.chat-header-actions { display: flex; gap: 2px; }

/* ==================== 微信风格消息列表 ==================== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #0f1318;
}
.chat-messages.hidden { display: none; }

/* 日期分割线 */
.chat-date-separator {
  text-align: center;
  margin: 14px 0 8px;
  font-size: 11px;
  color: #475569;
  user-select: none;
}
.chat-date-separator span {
  background: rgba(30,41,59,0.5);
  padding: 2px 8px;
  border-radius: 3px;
}

.message-wrap { display: flex; gap: 8px; max-width: 72%; margin: 3px 0; }
.message-wrap.self { align-self: flex-end; flex-direction: row-reverse; }
.message-wrap.other { align-self: flex-start; }

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 2px;
}
.msg-avatar.me { background: linear-gradient(135deg, #3b82f6, #2dd4bf); }
.msg-avatar.other { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.msg-avatar.system {
  background: var(--bg-overlay);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  font-size: 10px;
  border-radius: 50%;
}

/* 消息内容包装 */
.msg-content-wrap {
  min-width: 0;
}
.msg-content-wrap.self { display: flex; flex-direction: column; align-items: flex-end; }
.msg-content-wrap.other { display: flex; flex-direction: column; align-items: flex-start; }

.message-bubble {
  padding: 9px 13px;
  border-radius: 4px 14px 14px 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  position: relative;
}
.message-wrap.self .message-bubble {
  background: #38673c;
  border-radius: 14px 4px 14px 14px;
  color: #e8f5e9;
}
.message-wrap.other .message-bubble {
  background: #1a232e;
  border-radius: 4px 14px 14px 14px;
  color: #e2e8f0;
}

.message-wrap.system {
  max-width: 100%;
  align-self: center;
}
.message-wrap.system .message-bubble {
  background: transparent;
  color: #64748b;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 4px;
}
.message-wrap.system .msg-avatar { display: none; }

.msg-time {
  font-size: 10px;
  color: #64748b;
  margin-top: 3px;
  padding: 0 2px;
}

/* 媒体消息 */
.msg-image {
  max-width: 240px;
  max-height: 240px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
}
.msg-video {
  max-width: 240px;
  max-height: 240px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
}
.msg-voice {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 0;
}
.msg-voice i { color: var(--primary); font-size: 18px; }
.msg-voice .voice-dur { font-size: 12px; color: var(--text-secondary); }

/* ==================== 微信风格输入栏 ==================== */
.chat-input-bar {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  gap: 6px;
  background: #1a2028;
  border-top: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}
.chat-input-bar.hidden { display: none; }

.input-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 18px;
  cursor: pointer;
  color: #64748b;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* 发送按钮高亮 */
.send-btn {
  color: #165DFF;
}
.send-btn:hover {
  background: rgba(22, 93, 255, 0.15);
  color: #4080FF;
}

/* ==================== 常用语快捷面板 ==================== */
.quick-phrases-panel {
  background: #0f1318;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  margin: 0 10px 4px;
  max-height: 200px;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}
.quick-phrase-item {
  padding: 10px 14px;
  font-size: 13px;
  color: #94a3b8;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  cursor: pointer;
  transition: background 0.15s;
}
.quick-phrase-item:last-child { border-bottom: none; }
.quick-phrase-item:hover {
  background: #1a232e;
  color: #fff;
}
.quick-phrase-item:active {
  background: #1e293b;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.input-btn:hover { background: rgba(255,255,255,0.05); color: #94a3b8; }
.input-btn:active { background: rgba(255,255,255,0.08); }

.ptt-small {
  background: linear-gradient(135deg, #07C160, #06AE56);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 6px;
}
.ptt-small:hover { color: #fff; background: linear-gradient(135deg, #06AE56, #05944A); }
.ptt-small:active, .ptt-small.pressed {
  background: linear-gradient(135deg, #05944A, #048040);
  transform: scale(0.95);
}

.text-input-wrap {
  flex: 1;
  min-width: 0;
}
.text-input-wrap input {
  width: 100%;
  border: none;
  background: #0f1419;
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  color: #e2e8f0;
  font-family: inherit;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.text-input-wrap input:focus {
  background: #111820;
  border-color: rgba(7,193,96,0.3);
}
.text-input-wrap input::placeholder { color: #475569; }

/* 录音栏 — 位于输入栏上方 */
.recording-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.recording-bar.hidden { display: none; }
.recording-indicator { display: flex; align-items: center; gap: 8px; }
.record-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: blink-dot 0.6s infinite;
  box-shadow: 0 0 8px rgba(239,68,68,0.5);
}
@keyframes blink-dot { 50% { opacity: 0.3; } }
#recording-time { font-size: 16px; font-weight: 600; color: var(--danger); }
.recording-hint { font-size: 13px; color: var(--text-muted); }

.hidden { display: none !important; }

/* ==================== 底部全员操作工具栏 ==================== */
.broadcast-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 900;
  display: flex;
  align-items: flex-end;
  justify-content: space-evenly;
  gap: 8px;
  padding: 8px 20px max(8px, env(safe-area-inset-bottom, 8px));
  background: linear-gradient(to top, rgba(18,22,28,0.98), rgba(22,28,34,0.9));
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}

.broadcast-btn {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
  flex-shrink: 0;
}

.broadcast-btn i { font-size: 22px; }

/* ====== 按钮 + 文字标签外壳 ====== */
.broadcast-btn-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.broadcast-btn-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
  line-height: 1;
}

/* ====== PTT 对讲（居中突出） ====== */
.broadcast-ptt-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.broadcast-ptt {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, #07C160, #06AE56);
  box-shadow:
    0 4px 20px rgba(7,193,96,0.5),
    0 0 0 6px rgba(7,193,96,0.08),
    inset 0 1px 0 rgba(255,255,255,0.1);
  margin-bottom: 4px;
}
.broadcast-ptt i { font-size: 28px; }
.broadcast-ptt:hover {
  box-shadow:
    0 6px 24px rgba(7,193,96,0.6),
    0 0 0 10px rgba(7,193,96,0.12),
    inset 0 1px 0 rgba(255,255,255,0.1);
  transform: scale(1.06);
}
.broadcast-ptt.pressed {
  background: linear-gradient(135deg, #05944A, #048040);
  box-shadow:
    0 4px 28px rgba(7,193,96,0.7),
    0 0 0 10px rgba(7,193,96,0.2),
    inset 0 1px 0 rgba(255,255,255,0.05);
  animation: pulse-ptt 0.8s infinite;
  transform: scale(1.04);
}

.broadcast-btn-label,
.broadcast-ptt-label {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
  user-select: none;
  line-height: 1;
}

/* ====== 音频/视频通话（两侧小圆） ====== */
.broadcast-audio {
  background: linear-gradient(135deg, #07C160, #06AE56);
  box-shadow:
    0 3px 14px rgba(7,193,96,0.4),
    inset 0 1px 0 rgba(255,255,255,0.06);
}
.broadcast-audio:hover {
  box-shadow: 0 4px 18px rgba(7,193,96,0.55);
  transform: scale(1.08);
}

.broadcast-video {
  background: linear-gradient(135deg, #07C160, #06AE56);
  box-shadow:
    0 3px 14px rgba(7,193,96,0.4),
    inset 0 1px 0 rgba(255,255,255,0.06);
}
.broadcast-video:hover {
  box-shadow: 0 4px 18px rgba(7,193,96,0.55);
  transform: scale(1.08);
}

@keyframes pulse-ptt {
  0%, 100% { box-shadow: 0 4px 28px rgba(7,193,96,0.7), 0 0 0 10px rgba(7,193,96,0.2); }
  50% { box-shadow: 0 4px 36px rgba(7,193,96,0.9), 0 0 0 16px rgba(7,193,96,0.3); }
}

/* 底部工具栏与页面的间距 — 仅工具栏可见时生效 */
#screen-main.has-toolbar { padding-bottom: 85px; }

/* 响应式：移动端工具栏调整 */
@media (max-width: 640px) {
  .broadcast-toolbar { gap: 16px; }
  .broadcast-btn { width: 50px; height: 50px; }
  .broadcast-btn i { font-size: 20px; }
  .broadcast-ptt { width: 66px; height: 66px; }
  .broadcast-ptt i { font-size: 26px; }
}

/* ==================== 正在说话提醒弹窗 ==================== */
.speaking-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1100;
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
  border-radius: 14px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  min-width: 240px;
  animation: toastSlideIn 0.3s ease-out;
  border: 1px solid var(--primary);
}
.speaking-toast.hidden { display: none; }

@keyframes toastSlideIn {
  from { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.speaking-toast-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  animation: avatar-pulse 1.5s ease-in-out infinite;
}

.speaking-toast-info { flex: 1; min-width: 0; }
.speaking-toast-name { font-size: 14px; font-weight: 600; color: var(--text); }
.speaking-toast-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--primary);
  margin-top: 2px;
}

.speaking-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: blink-dot 0.6s infinite;
}
.speaking-toast-timer {
  color: var(--text-muted);
  margin-left: 4px;
}

.speaking-toast-wave {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 24px;
  flex-shrink: 0;
}
.speaking-toast-wave span {
  width: 3px;
  background: var(--primary);
  border-radius: 2px;
  animation: toastWave 0.6s ease-in-out infinite;
}
.speaking-toast-wave span:nth-child(1) { height: 10px; }
.speaking-toast-wave span:nth-child(2) { height: 20px; animation-delay: 0.1s; }
.speaking-toast-wave span:nth-child(3) { height: 14px; animation-delay: 0.2s; }
.speaking-toast-wave span:nth-child(4) { height: 22px; animation-delay: 0.3s; }
.speaking-toast-wave span:nth-child(5) { height: 8px; animation-delay: 0.4s; }
@keyframes toastWave { 0%, 100% { height: 4px; } 50% { height: 24px; } }

/* ==================== 未读消息气泡 ==================== */
.unread-badge {
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(239,68,68,0.3);
}

/* ==================== 最小化按钮 ==================== */
.call-float-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.call-float-btn:hover {
  background: rgba(255,255,255,0.2);
  transform: scale(1.1);
}

/* ==================== 语音通话弹窗 ==================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.overlay.hidden { display: none; }

.call-screen {
  text-align: center;
  color: #fff;
  position: relative;
}

.call-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2dd4bf);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 44px;
  color: #fff;
  box-shadow: 0 4px 24px rgba(59,130,246,0.4);
}

.call-name { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
.call-status { font-size: 14px; color: #94a3b8; margin-bottom: 16px; }
.call-timer { font-size: 28px; font-weight: 300; letter-spacing: 4px; margin-bottom: 30px; }

.call-actions {
  display: flex;
  gap: 24px;
  justify-content: center;
}

.call-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 22px;
  transition: all 0.2s;
  color: #fff;
}
.call-btn span { font-size: 10px; margin-top: 2px; }
.call-btn.mute {
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.05);
}
.call-btn.mute.muted {
  background: var(--danger);
  box-shadow: 0 2px 10px rgba(239,68,68,0.4);
}
.call-btn.speaker {
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.05);
}
.call-btn.camera {
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.05);
}
.call-btn.camera.off {
  background: var(--danger);
  box-shadow: 0 2px 10px rgba(239,68,68,0.4);
}
.call-btn.switch-cam {
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.05);
}
.call-btn.hangup {
  background: var(--danger);
  width: 60px;
  height: 60px;
  box-shadow: 0 4px 16px rgba(239,68,68,0.5);
}

/* ==================== 浮动通话小窗 ==================== */
.call-float-window {
  position: fixed;
  z-index: 1050;
  width: 180px;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.08);
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.3s;
  overflow: hidden;
}
.call-float-window:active { cursor: grabbing; }
.call-float-window.dragging {
  box-shadow: 0 12px 40px rgba(0,0,0,0.7), 0 0 0 2px rgba(59,130,246,0.3);
  transition: none;
}
.call-float-window.snapping {
  transition: left 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              top 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.call-float-window.hidden { display: none; }

.float-win-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  pointer-events: none;
}
.float-win-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.float-win-info {
  flex: 1;
  min-width: 0;
}
.float-win-name {
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.float-win-timer {
  font-size: 11px;
  color: #64748b;
  font-weight: 300;
  letter-spacing: 0.5px;
}

.float-win-actions {
  display: flex;
  border-top: 1px solid rgba(255,255,255,0.06);
  pointer-events: auto;
}
.float-win-btn {
  flex: 1;
  height: 36px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.float-win-btn:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
.float-win-hangup:hover { color: #ef4444; }

/* 视频通话中浮动窗显示本地视频 */
.call-float-window.video .float-win-video {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
  background: #000;
}
.call-float-window .float-win-video { display: none; }

/* ==================== 来电提醒 ==================== */
.incoming-animation {
  position: relative;
  width: 100px;
  height: 100px;
  margin: 0 auto 24px;
}

.ripple {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  border: 2px solid rgba(59,130,246,0.3);
  animation: ripple-expand 1.5s ease-out infinite;
}
.ripple-1 { animation-delay: 0s; }
.ripple-2 { animation-delay: 0.5s; }
.ripple-3 { animation-delay: 1s; }

@keyframes ripple-expand {
  0% { transform: scale(0.6); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}

.incoming-avatar {
  animation: avatar-pulse 1.5s ease-in-out infinite;
}
@keyframes avatar-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.5); }
  50% { box-shadow: 0 0 0 20px rgba(59,130,246,0); }
}

.incoming-actions {
  display: flex;
  gap: 40px;
  justify-content: center;
  margin-top: 10px;
}

.call-btn.accept {
  background: var(--primary);
  width: 60px;
  height: 60px;
  font-size: 26px;
  box-shadow: 0 4px 16px rgba(7,193,96,0.4);
}
.call-btn.accept:hover { background: var(--primary-hover); }

/* ==================== 视频通话弹窗 ==================== */
.video-screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.video-full {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  color: #334155;
}

.video-pip {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 120px;
  height: 170px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.15);
  background: #111827;
  z-index: 2;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.video-call-name {
  position: absolute;
  top: 24px;
  left: 24px;
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.video-call-timer {
  position: absolute;
  top: 50px;
  left: 24px;
  color: #fff;
  font-size: 22px;
  font-weight: 300;
  letter-spacing: 3px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

.video-call-actions {
  position: absolute;
  bottom: 40px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 20px;
}

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
  :root { --sidebar-w: 280px; }

  .login-container { max-width: 340px; padding: 32px 24px; }
}

@media (max-width: 640px) {
  .sidebar { width: 100%; min-width: 100%; }
  #chat-area { display: none; }
  #chat-area.chat-open {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 10;
  }
  #chat-area.chat-open ~ .sidebar { display: none; }
  .video-pip { width: 80px; height: 110px; }

  .message-wrap { max-width: 85%; }
  .welcome-features { grid-template-columns: 1fr 1fr; }

  .broadcast-toolbar { gap: 16px; }
  .broadcast-btn { width: 50px; height: 50px; }
  .broadcast-btn i { font-size: 20px; }
  .broadcast-ptt { width: 66px; height: 66px; }
  .broadcast-ptt i { font-size: 26px; }
}

@media (min-width: 1400px) {
  :root { --sidebar-w: 360px; }
  .message-wrap { max-width: 65%; }
}
