/* ============ 主题变量 ============ */
:root {
  --bg: #0f1220;
  --bg-2: #161a2e;
  --panel: #1d2237;
  --panel-2: #232a45;
  --border: #2e3658;
  --text: #eef1ff;
  --text-dim: #9aa3c0;
  --bar: rgba(22, 26, 46, 0.8);
  --accent: #5b8cff;
  --accent-2: #7c5cff;
  --danger: #ff5b6a;
  --success: #34d399;
  --warn: #ffb454;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --grad: linear-gradient(135deg, #5b8cff, #7c5cff);
}

/* 亮色主题 */
:root[data-theme="light"] {
  --bg: #eef1f8;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #e9edf7;
  --border: #d5dbe9;
  --text: #1c2340;
  --text-dim: #6b7290;
  --bar: rgba(255, 255, 255, 0.85);
  --shadow: 0 8px 24px rgba(30, 40, 80, 0.12);
}
:root[data-theme="light"] body {
  background: linear-gradient(180deg, #f6f8ff 0%, #e9edf7 100%);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(124, 92, 255, 0.25), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(91, 140, 255, 0.2), transparent 60%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ============ 顶栏 ============ */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bar);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 26px; }
.brand h1 { font-size: 1.15rem; font-weight: 600; letter-spacing: 0.5px; }
.meta { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.pill {
  font-size: 0.82rem;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill span { color: var(--text); font-weight: 500; }
.pill.timer span { color: var(--success); font-variant-numeric: tabular-nums; }

.icon-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  width: 38px; height: 38px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--panel-2); }
.icon-btn:active { transform: scale(0.95); }

/* ============ 主区域 ============ */
.layout {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 16px;
  min-height: 0;
}

/* 视频区 */
.video-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.videos {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-content: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 4px;
  min-height: 0;
}
.video-placeholder {
  width: 100%;
  height: 100%;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-dim);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}
.video-placeholder .ph-icon { font-size: 44px; opacity: 0.7; }
.video-placeholder p { font-size: 0.9rem; }

.video-tile {
  position: relative;
  width: calc(50% - 6px);
  max-width: 460px;
  min-width: 220px;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 2px solid var(--border);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.video-tile video { width: 100%; height: 100%; object-fit: cover; }
.video-tile .label {
  position: absolute;
  left: 8px; bottom: 8px;
  font-size: 0.75rem;
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  color: #fff;
}
.video-tile .label.me { background: var(--grad); }
.video-tile .voice-badge {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 0.85rem;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.15s;
}
/* 活跃说话者：绿色发光边框 */
.video-tile.speaking {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.45), var(--shadow);
}
.video-tile.speaking .voice-badge { opacity: 1; }

/* 房间操作 */
.room-bar { display: flex; flex-direction: column; gap: 10px; }
.room-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.room-controls input {
  flex: 1;
  min-width: 150px;
  padding: 11px 14px;
  font-size: 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
}
.room-controls input:focus { border-color: var(--accent); }
.in-room-chip {
  font-size: 0.9rem;
  padding: 10px 14px;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: var(--success);
  border-radius: 10px;
}
.room-list { display: flex; gap: 8px; flex-wrap: wrap; }
.room-list .room-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.2s, border-color 0.2s;
}
.room-list .room-btn:hover { background: var(--panel-2); border-color: var(--accent); }
.room-list .room-empty { color: var(--text-dim); font-size: 0.85rem; }

/* ============ 右侧栏 ============ */
.sidebar {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px;
}
.panel h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge {
  background: var(--grad);
  color: #fff;
  font-size: 0.7rem;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
}

.members { flex: 0 0 auto; max-height: 40%; }
.members ul { list-style: none; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--panel-2);
  border-radius: 10px;
  font-size: 0.88rem;
}
.member .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--grad);
  display: grid; place-items: center;
  font-size: 0.8rem; color: #fff; font-weight: 600;
  flex-shrink: 0;
}
.member .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .you {
  font-size: 0.7rem;
  color: var(--accent);
  background: rgba(91, 140, 255, 0.15);
  padding: 2px 8px;
  border-radius: 999px;
}
.member .hand { font-size: 0.95rem; animation: wave 0.6s ease-in-out infinite; }
@keyframes wave { 0%,100% { transform: rotate(0deg); } 50% { transform: rotate(18deg); } }
.member-empty { color: var(--text-dim); font-size: 0.85rem; text-align: center; padding: 12px 0; }

/* 聊天 */
.chat { flex: 1; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  margin-bottom: 10px;
}
.msg { max-width: 85%; display: flex; flex-direction: column; gap: 2px; }
.msg .bubble {
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--panel-2);
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
}
.msg .meta-line { font-size: 0.7rem; color: var(--text-dim); padding: 0 4px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.mine .bubble { background: var(--grad); color: #fff; }
.msg.system { align-self: center; max-width: 100%; }
.msg.system .bubble {
  background: transparent;
  color: var(--text-dim);
  font-size: 0.78rem;
  text-align: center;
  padding: 2px 8px;
}

/* 表情面板 */
.emoji-panel {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
}
.emoji-panel button {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s, transform 0.1s;
}
.emoji-panel button:hover { background: var(--panel); }
.emoji-panel button:active { transform: scale(1.2); }

.chat-form { display: flex; gap: 8px; }
.chat-form input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font-size: 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}
.chat-form input:focus { border-color: var(--accent); }
.chat-form .emoji-btn {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 12px;
  flex-shrink: 0;
}
.chat-form .emoji-btn:hover { background: var(--panel); }
.chat-form button[type="submit"] {
  background: var(--grad);
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.1s, box-shadow 0.2s;
}
.chat-form button[type="submit"]:hover { opacity: 0.9; box-shadow: 0 4px 14px rgba(91, 140, 255, 0.45); }
.chat-form button[type="submit"]:active { transform: scale(0.96); }
.chat-form button[type="submit"]:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* ============ 底部控制栏 ============ */
.controlbar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 20px;
  background: var(--bar);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
.ctrl-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, border-color 0.2s;
  min-width: 72px;
}
.ctrl-btn .ico { font-size: 20px; }
.ctrl-btn .txt { font-size: 0.72rem; color: var(--text-dim); }
.ctrl-btn:hover { background: var(--panel-2); }
.ctrl-btn:active { transform: scale(0.96); }
.ctrl-btn.on { background: var(--grad); border-color: transparent; }
.ctrl-btn.on .txt { color: #fff; }
.ctrl-btn.danger:hover { background: rgba(255, 91, 106, 0.15); border-color: var(--danger); }
.ctrl-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ============ 按钮通用 ============ */
button { font-family: inherit; }
.primary {
  background: var(--grad);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.primary:hover { opacity: 0.9; }
#createRoomBtn {
  background: var(--grad);
  color: #fff;
  border: none;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
#createRoomBtn:hover { opacity: 0.9; }

/* ============ 设置/加入弹窗 ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal-box {
  width: 100%;
  max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h3 { font-size: 1.05rem; }
.field-group { margin-bottom: 14px; }
.field-label { font-size: 0.82rem; color: var(--text-dim); display: block; margin-bottom: 8px; }
.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset-btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, border-color 0.2s;
}
.preset-btn:hover { background: var(--panel-2); }
.preset-btn.active { background: var(--grad); border-color: transparent; }
.field { display: block; margin-bottom: 12px; }
.field > span { font-size: 0.82rem; color: var(--text-dim); display: block; margin-bottom: 6px; }
.field input[type="text"],
.field input[type="password"],
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
  font-size: 0.9rem;
}
.field input:focus,
.field select:focus { border-color: var(--accent); }
.field.checkbox { display: flex; align-items: center; gap: 10px; }
.field.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.field.checkbox span { display: inline; margin: 0; font-size: 0.9rem; color: var(--text); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button {
  flex: 1;
  padding: 11px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
}
.modal-actions button.primary { background: var(--grad); border: none; color: #fff; }

/* ============ 提示条 ============ */
#toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
  max-width: 80vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ 文件传输区域 ============ */
.file-transfer-area {
  position: fixed;
  right: 20px;
  bottom: 100px;
  width: 380px;
  max-height: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  z-index: 150;
}

.file-transfer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: var(--radius) var(--radius) 0 0;
}

.file-transfer-header h3 {
  font-size: 0.9rem;
  margin: 0;
  color: var(--text);
}

.file-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: background 0.2s;
}

.file-item:hover {
  background: var(--panel-2);
}

.file-icon {
  font-size: 24px;
  flex-shrink: 0;
}

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

.file-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.file-progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}

.file-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

.file-actions {
  display: flex;
  gap: 6px;
}

.file-action-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
}

.file-action-btn:hover {
  background: var(--panel-2);
}

.file-action-btn.primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
}

.empty-files {
  text-align: center;
  padding: 30px 20px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ============ 消息操作和样式 ============ */
.msg-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.msg:hover .msg-actions {
  opacity: 1;
}

.action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.2s;
}

.action-btn:hover {
  background: var(--panel-2);
}

.reply-context, .forward-context {
  margin: 4px 0;
  padding: 6px 10px;
  background: var(--panel-2);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 0.85rem;
}

.reply-label, .forward-label {
  font-weight: 600;
  color: var(--accent);
  display: block;
  margin-bottom: 2px;
}

.reply-text, .forward-text {
  color: var(--text-dim);
  font-style: italic;
}

.bubble.edited {
  position: relative;
}

.bubble.edited::after {
  content: " (已编辑)";
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-left: 4px;
}

.bubble.forwarded {
  border-left: 3px solid var(--warn);
}

/* ============ WhatsApp分享样式 ============ */
.whatsapp-share {
  background: linear-gradient(135deg, #25D366, #128C7E);
  border-radius: 8px;
  padding: 12px;
  margin: 8px 0;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.share-header {
  color: #fff;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.share-content {
  background: rgba(255, 255, 255, 0.1);
  padding: 8px;
  border-radius: 6px;
  color: #fff;
  margin-bottom: 10px;
}

.whatsapp-chat-btn {
  background: #fff;
  color: #25D366;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  width: 100%;
}

.whatsapp-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ============ 管理员状态样式 ============ */
.admin-active {
  background: linear-gradient(135deg, #FFD700, #FFA500) !important;
  color: #000 !important;
  font-weight: 600;
}

.msg.whatsapp {
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.1), rgba(18, 140, 126, 0.1));
  border-left: 3px solid #25D366;
}

/* ============ 图片消息样式 ============ */
.msg.image {
  max-width: 80%;
}

.msg.image .bubble {
  padding: 0;
  background: transparent;
  border: none;
}

.image-container {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  max-width: 100%;
}

.image-container img {
  max-width: 100%;
  max-height: 400px;
  display: block;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 0.2s;
}

.image-container img:hover {
  transform: scale(1.02);
}

.image-info {
  padding: 8px 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.image-action-btn {
  background: var(--accent);
  border: none;
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: background 0.2s;
}

.image-action-btn:hover {
  background: var(--accent-2);
}

.image-loading {
  padding: 20px;
  text-align: center;
  color: var(--text-dim);
}

.image-error {
  padding: 20px;
  text-align: center;
  color: var(--danger);
  background: var(--panel);
  border-radius: var(--radius);
}

/* 图片预览模态框 */
.image-preview-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.image-preview-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.image-preview-content {
  max-width: 90%;
  max-height: 90%;
  position: relative;
}

.image-preview-content img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.image-preview-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.2rem;
  transition: background 0.2s;
}

.image-preview-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ============ AI 字幕样式 ============ */
.subtitle-overlay {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  max-width: 80%;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.subtitle-overlay.hidden {
  display: none;
}

.subtitle-overlay.active {
  display: block;
}

.subtitle-box {
  background: rgba(0, 0, 0, 0.7);
  padding: 12px 16px;
  border-radius: 8px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.subtitle-original,
.subtitle-translated {
  color: #fff;
  font-size: 16px;
  line-height: 1.4;
  text-align: center;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
  max-height: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subtitle-original {
  margin-bottom: 8px;
  font-weight: 500;
}

.subtitle-original.interim {
  color: rgba(255, 255, 255, 0.7);
  font-style: italic;
}

.subtitle-translated {
  color: #ffd700;
  font-size: 14px;
  font-style: italic;
}

.subtitle-original.show,
.subtitle-translated.show {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.subtitle-original:not(.show),
.subtitle-translated:not(.show) {
  opacity: 0;
  transform: translateY(10px);
}

/* 字幕加载状态 */
.subtitle-loading {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(91, 140, 255, 0.1);
  border: 1px solid rgba(91, 140, 255, 0.3);
  animation: pulse 1.5s infinite;
}

.subtitle-loading.hidden {
  display: none;
}

.subtitle-loading.show {
  display: block;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* 字幕错误提示 */
.subtitle-error {
  font-size: 0.85rem;
  color: #ff6b6b;
  text-align: center;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  margin-bottom: 8px;
}

.subtitle-error.hidden {
  display: none;
}

.subtitle-error.show {
  display: block;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 翻译错误样式 */
.subtitle-translated.translation-error {
  color: #ff6b6b;
  font-style: italic;
}

/* 字幕位置顶部变体 */
.subtitle-overlay.position-top {
  bottom: auto;
  top: 20px;
}

/* 深色主题适配 */
[data-theme="dark"] .subtitle-box {
  background: rgba(0, 0, 0, 0.8);
}

/* 浅色主题适配 */
[data-theme="light"] .subtitle-box {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .subtitle-original,
[data-theme="light"] .subtitle-translated {
  color: #000;
  text-shadow: none;
}

[data-theme="light"] .subtitle-translated {
  color: #0066cc;
}

/* ============ 字幕消息样式 ============ */
.msg.subtitle .bubble {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  border-left: 3px solid #667eea;
}

.msg.subtitle.mine .bubble {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.2), rgba(118, 75, 162, 0.2));
  border-left-color: #764ba2;
}

.bubble.subtitle .subtitle-original {
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

.bubble.subtitle .subtitle-translated {
  font-style: italic;
  color: var(--accent);
  margin-bottom: 6px;
  font-size: 0.95em;
}

.bubble.subtitle .subtitle-lang {
  font-size: 0.75em;
  color: var(--text-dim);
  opacity: 0.7;
  margin-top: 4px;
}

/* ============ 字幕历史查看模态框 ============ */
.modal-large {
  max-width: 900px;
  width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-large .modal-box {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.subtitle-history-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background: var(--panel);
  border-radius: 8px;
  margin-bottom: 16px;
}

.search-bar {
  display: flex;
  gap: 8px;
}

.search-bar input {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 6px;
  outline: none;
}

.search-bar input:focus {
  border-color: var(--accent);
}

.filter-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-controls select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.export-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.export-controls button {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.export-controls button:hover {
  background: var(--panel-2);
  border-color: var(--accent);
}

.export-controls button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.subtitle-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg-2);
  border-radius: 8px;
  margin-bottom: 12px;
}

.subtitle-history-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.subtitle-history-item:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.subtitle-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.subtitle-history-time {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.subtitle-history-speaker {
  font-weight: 600;
  color: var(--accent);
}

.subtitle-history-content {
  margin-bottom: 8px;
}

.subtitle-history-original {
  font-size: 0.95rem;
  margin-bottom: 6px;
  line-height: 1.4;
}

.subtitle-history-translated {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-style: italic;
  line-height: 1.3;
}

.subtitle-history-langs {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.lang-badge {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent);
  color: white;
}

.subtitle-history-stats {
  display: flex;
  gap: 16px;
  padding: 8px 12px;
  background: var(--panel);
  border-radius: 6px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.subtitle-history-stats strong {
  color: var(--text);
}

/* 搜索高亮 */
.highlight {
  background: var(--warn);
  color: var(--bg);
  padding: 2px 4px;
  border-radius: 3px;
}

/* 空状态 */
.subtitle-history-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}

.subtitle-history-empty .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ============ 响应式 ============ */
@media (max-width: 860px) {
  body { overflow: auto; height: auto; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; }
  .members { max-height: 220px; }
  .chat { min-height: 260px; }
  .video-tile { width: 100%; max-width: 100%; }
  .meta { display: none; }
  .controlbar { gap: 8px; }
  .ctrl-btn { min-width: 60px; padding: 8px 10px; }
  .room-controls input { min-width: 100%; }
}

/* ============ 文件进度文本 / 图片占位 / 已编辑标记 ============ */
.file-progress-text {
  font-size: 0.7rem;
  color: var(--text-dim);
  vertical-align: middle;
}

.image-expired {
  padding: 18px 24px;
  background: var(--panel-2);
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 0.8rem;
  text-align: center;
}

.edited-tag {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ============ 管理面板 ============ */
.danger-btn {
  background: var(--danger);
  border: none;
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.danger-btn:hover {
  opacity: 0.85;
}

.admin-logs-list {
  margin-top: 10px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-2);
  padding: 6px;
}

.admin-log-item {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
}

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

.admin-log-time {
  color: var(--text-dim);
  white-space: nowrap;
}

.admin-log-action {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

.admin-log-detail {
  color: var(--text-dim);
  word-break: break-all;
}

.admin-log-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 0.8rem;
}
