/* ============ 基础 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #1D6FE0;
  --primary-dark: #1558B8;
  --primary-light: #EBF3FE;
  --danger: #E24B4A;
  --success: #22A06B;
  --text-1: #1A1A1A;
  --text-2: #555;
  --text-3: #999;
  --bg-1: #F5F7FA;
  --bg-2: #FFFFFF;
  --border: #E2E6EC;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text-1);
  background: var(--bg-1);
  height: 100vh;
  /* 移动端地址栏会吃掉 100vh; JS 写入的 --vh 是真实可视高度(兼容不支持 dvh 的老内核) */
  height: calc(var(--vh, 1vh) * 100);
  height: 100dvh;
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ============ 落地页 ============ */
.landing-page {
  display: flex;
  flex-direction: column; /* 纵向排列: 内容居中 + 备案页脚固定在底部 (避免 flex 默认行方向使页脚跑到右侧) */
  min-height: 100vh;
  min-height: 100dvh; /* 移动端动态地址栏适配 */
  background: linear-gradient(160deg, #F0F6FF 0%, #F5F7FA 60%, #EEF2F7 100%);
  overflow-y: auto;
}

.landing-container {
  /* margin:auto 居中: 内容超出视口时外边距收缩为0, 顶部内容可滚动到达
     (不能用 align-items:center, 那会把溢出部分裁到顶部之外且无法滚动回来) */
  margin: auto;
  width: 480px;
  max-width: 94vw;
  padding: 20px 0 40px;
}

.logo-area { text-align: center; margin-bottom: 32px; }

.logo-area h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
}

.tagline {
  color: var(--text-2);
  font-size: 14px;
  margin-top: 8px;
}

.join-card {
  background: var(--bg-2);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.form-group { margin-bottom: 22px; }

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.form-group .hint { font-weight: 400; font-size: 12px; color: var(--text-3); }

.form-group input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus { border-color: var(--primary); }

.room-input-row { display: flex; gap: 10px; }
.room-input-row input { flex: 1; letter-spacing: 2px; }

.btn-secondary {
  padding: 0 16px;
  height: 46px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1.5px solid var(--primary-light);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s;
}
.btn-secondary:hover { background: #D9E9FD; }

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

.lang-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  padding: 10px 6px;
  background: var(--bg-1);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  transition: all 0.15s;
}

.lang-btn:hover { border-color: var(--primary); }

.lang-btn.selected {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.lang-flag { font-size: 15px; }

/* ===== 语言折叠区 + 搜索 (首页) ===== */
.lang-more-toggle {
  width: 100%;
  margin-top: 10px;
  padding: 9px;
  background: transparent;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.lang-more-toggle:hover { border-color: var(--primary); color: var(--primary); }

.lang-extra { margin-top: 10px; }

.lang-search {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-1);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-1);
  margin-bottom: 8px;
  box-sizing: border-box;
}
.lang-search:focus { outline: none; border-color: var(--primary); }

/* 仅字幕语言徽标 */
.lang-badge {
  display: inline-block;
  padding: 1px 5px;
  background: #FFF4E0;
  color: #B8860B;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.lang-btn .lang-badge { flex-shrink: 0; }

.lang-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  padding: 14px 0;
}

/* ===== 会议页自定义语言选择器 ===== */
.lang-picker { position: relative; }

.lang-picker-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: #2C3340;
  color: #DDE3ED;
  border: 1px solid #3D4554;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  max-width: 170px;
}
.lang-picker-btn:hover { border-color: #55607A; }
.lang-picker-btn span#langPickerLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lang-picker-caret { color: #9AA5B5; font-size: 11px; }

.lang-picker-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 280px;
  max-width: calc(100vw - 24px);
  background: #232936;
  border: 1px solid #3D4554;
  border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  padding: 8px;
  z-index: 200;
}

.lang-picker-panel .lang-search {
  background: #2C3340;
  border-color: #3D4554;
  color: #DDE3ED;
}

.lang-picker-list {
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.picker-group-title {
  font-size: 11px;
  color: #7C88A0;
  padding: 8px 6px 4px;
  border-bottom: 1px solid #2E3542;
  margin-bottom: 2px;
}

.picker-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  background: transparent;
  border: none;
  color: #C6CEDC;
  font-size: 13px;
  padding: 8px 8px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
}
.picker-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-item:hover { background: #2E3748; }
.picker-item.selected { background: #2C4A7A; color: #fff; }
.picker-item .lang-badge { background: #4A3F28; color: #E8C36A; }

.picker-empty {
  text-align: center;
  color: #7C88A0;
  font-size: 13px;
  padding: 16px 0;
}

/* ===== 管理后台热词编辑 ===== */
.admin-hotword-tip {
  font-size: 12px;
  color: var(--text-3);
  margin: 0 0 8px;
}
.admin-hotword-area {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13px;
  background: var(--bg-1);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-1);
  resize: vertical;
}
.admin-hotword-area:focus { outline: none; border-color: var(--primary); }
.admin-hotword-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.admin-hotword-status { font-size: 12px; color: var(--text-3); }

.btn-primary {
  width: 100%;
  height: 50px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  transition: background 0.2s;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(0.98); }

/* 进入会议按钮紧跟会议号下方, 与表单节奏对齐 */
.btn-join { margin-bottom: 22px; }

.powered-by {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-top: 16px;
}

/* ============ 邀请入会弹窗 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 20, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.show { display: flex; }

.modal-card {
  background: var(--bg-2);
  border-radius: 16px;
  width: min(92vw, 340px);
  padding: 20px 22px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-title { font-size: 17px; font-weight: 700; }

.modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg-1);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 14px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--border); }

.qrcode-box {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  min-height: 204px;
  color: var(--text-3);
  font-size: 13px;
}
.qrcode-box img { display: block; }

.invite-hint {
  text-align: center;
  font-size: 13px;
  color: var(--text-2);
  margin: 10px 0 14px;
}

.invite-link-row { display: flex; gap: 8px; }

.invite-link-row input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--bg-1);
  outline: none;
}

.invite-link-row .btn-secondary {
  height: 40px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
  white-space: nowrap;
}

.invite-tip {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 12px;
  text-align: center;
}

/* ============ 会议页 ============ */
/* 整页锁定视口高度并禁止整页滚动: 人多时只让成员区内部滚动,
   底部控制栏永远固定在可视区最下方, 不会被卡片盖住 */
.meeting-page {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #1B1F27;
  overflow: hidden;
}

/* 顶栏 */
.top-bar {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: #232833;
  color: #DDE3ED;
  flex-shrink: 0;
}

.top-left { display: flex; align-items: center; gap: 12px; }
.app-name { font-weight: 700; font-size: 15px; }
.room-badge {
  background: rgba(255,255,255,0.1);
  padding: 3px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-family: monospace;
  letter-spacing: 1px;
}
.top-center { font-family: monospace; font-size: 14px; color: #9AA5B5; }

/* 音频状态指示灯: 灰=未就绪, 橙=被浏览器挂起(点一下即可), 绿=正常拾音, 红=失败 */
.audio-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #9AA5B5;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  border-radius: 6px;
  padding: 3px 8px;
}
.audio-status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7A8494;
  flex-shrink: 0;
}
.audio-status.ok { color: #9AE6C0; }
.audio-status.ok::before { background: #22A06B; }
.audio-status.warn { color: #FFC46B; }
.audio-status.warn::before { background: #E2A03B; }
.audio-status.err { color: #FF9B9A; }
.audio-status.err::before { background: #E24B4A; }

.lang-select {
  background: #2C3340;
  color: #DDE3ED;
  border: 1px solid #3D4554;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  outline: none;
}

/* 主区域 */
.meeting-main {
  flex: 1;
  display: flex;
  min-height: 0;
  padding: 12px;
  gap: 12px;
  overflow: hidden; /* 成员卡片溢出时不得画到控制栏上面 */
}

/* 成员区: 人数多时纵向滚动; 列数按人数自适应 (JS 写入 data-count) */
.video-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;      /* 溢出时从顶部开始, 保证第一条可滚动到 */
  overscroll-behavior: contain;
  padding-right: 2px;
}

/* 1~2 人时内容不会溢出, 居中更美观 */
.video-grid[data-count="1"],
.video-grid[data-count="2"] { align-content: center; }

/* 按人数固定列数: 避免 auto-fit 在窄屏上把单人卡片拉成整行、多人挤成一列 */
.video-grid[data-count="1"] { grid-template-columns: 1fr; }
.video-grid[data-count="2"],
.video-grid[data-count="3"],
.video-grid[data-count="4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.video-grid[data-count="5"],
.video-grid[data-count="6"],
.video-grid[data-count="7"],
.video-grid[data-count="8"],
.video-grid[data-count="9"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* 视频模式: 卡片改竖版 (9:16 竖屏)
   手机竖持时摄像头输出本就是竖向画面, 竖卡片与之一致, 不会像横卡片那样把上下大幅裁掉。
   关键: 必须【宽度主导】—— width:100% + aspect-ratio 反推高度。
   此前用 height:100% + width:auto, 高度撑满整行后按 9:16 反推出的宽度在窄屏上
   远超列宽, 卡片横向溢出被裁切 —— 这就是"多人同时开视频时界面错乱"的根因。 */
.video-grid.has-video {
  grid-auto-rows: auto;
  align-content: center;
  align-content: safe center; /* 溢出时自动降级为 start, 保证第一张卡片仍可滚动到 */
}

.video-grid.has-video .video-tile {
  width: 100%;
  max-width: 320px;   /* 大屏时单卡不无限拉宽; 窄屏由列宽自然约束 */
  height: auto;
  aspect-ratio: 9 / 16;
  min-width: 0;
  min-height: 150px;  /* 老内核不认 aspect-ratio 时的兜底高度 */
  padding: 0;
  justify-self: center;
}

.video-tile {
  position: relative;
  background: #2A303C;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 176px; /* 低于此值卡片内容(头像/声波/名字)会挤在一起 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px;
  transition: box-shadow 0.2s;
}

/* 创建者(付费方)徽章 */
.tile-host {
  font-size: 10px;
  color: #FFC46B;
  border: 1px solid rgba(255, 196, 107, 0.45);
  border-radius: 4px;
  padding: 1px 4px;
  line-height: 1.3;
  white-space: nowrap;
}

/* 视频画面: 默认隐藏 —— 入会即纯语音形态, 只有真正拿到媒体流的卡片才显示出来 */
.tile-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #1B1F27;
  display: none;
}

.video-tile.has-video .tile-video { display: block; }

/* 有画面时收起头像与声波柱, 避免元素堆叠遮挡 */
.video-tile.has-video .video-off-avatar,
.video-tile.has-video .tile-wave { display: none; }

/* 本地自视图: 仅前置摄像头镜像(照镜子习惯);
   后置摄像头必须保持真实方向, 否则拍到的文字/场景会左右颠倒。远端画面永不镜像。 */
.video-tile.local.cam-front.has-video .tile-video { transform: scaleX(-1); }

.video-tile.speaking {
  box-shadow: 0 0 0 5px rgba(34, 160, 107, 0.22), 0 0 30px rgba(34, 160, 107, 0.55);
}

.tile-name {
  position: absolute;
  left: 10px;
  top: 10px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  backdrop-filter: blur(4px);
}

/* 点对点连接状态: 只在 attempting/failed 时出现, 建立成功后自动消失 */
.tile-link {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: #E6EAF2;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  backdrop-filter: blur(4px);
}

.tile-link.error { background: rgba(201, 58, 57, 0.9); color: #fff; }

.tile-lang {
  background: rgba(29,111,224,0.85);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}

.tile-speaking {
  position: absolute;
  inset: 0;
  border: 4px solid var(--success);
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.video-tile.speaking .tile-speaking {
  opacity: 1;
  animation: speaking-ring 1.3s ease-in-out infinite;
}

@keyframes speaking-ring {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* 声波跳动柱: 说话时显示 */
.tile-wave {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 22px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.tile-wave i {
  width: 5px;
  height: 6px;
  border-radius: 3px;
  background: var(--success);
}

.video-tile.speaking .tile-wave { opacity: 1; }

.video-tile.speaking .tile-wave i { animation: wave-bounce 0.9s ease-in-out infinite; }
.video-tile.speaking .tile-wave i:nth-child(1) { animation-delay: 0s; }
.video-tile.speaking .tile-wave i:nth-child(2) { animation-delay: 0.15s; }
.video-tile.speaking .tile-wave i:nth-child(3) { animation-delay: 0.3s; }
.video-tile.speaking .tile-wave i:nth-child(4) { animation-delay: 0.1s; }
.video-tile.speaking .tile-wave i:nth-child(5) { animation-delay: 0.25s; }

@keyframes wave-bounce {
  0%, 100% { height: 6px; }
  50% { height: 22px; }
}

/* "正在说话"徽标 */
.tile-speaking-badge {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--success);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 999px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  box-shadow: 0 2px 10px rgba(34, 160, 107, 0.45);
}

.video-tile.speaking .tile-speaking-badge { opacity: 1; }

.video-off-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3D4554, #2E3542);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 600;
  border: 3px solid #4A5364;
  transition: border-color 0.2s, transform 0.2s;
}

.video-tile.speaking .video-off-avatar {
  border-color: var(--success);
  transform: scale(1.06);
}

/* 字幕面板 */
.subtitle-panel {
  width: 320px;
  background: #232833;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.subtitle-panel.collapsed { display: none; }

.subtitle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid #323A48;
}

.subtitle-title { font-size: 13px; color: #9AA5B5; font-weight: 600; }

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12px;
}

.subtitle-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.subtitle-empty {
  color: #5A6474;
  font-size: 13px;
  text-align: center;
  margin-top: 40px;
}

.subtitle-item {
  padding: 10px 12px;
  background: #2A303C;
  border-radius: 10px;
}

.subtitle-item .speaker {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 4px;
}

.subtitle-item .source-text {
  font-size: 12px;
  color: #7A8494;
  margin-bottom: 4px;
  font-style: italic;
}

.subtitle-item .translated-text {
  font-size: 14px;
  color: #E5EAF2;
  line-height: 1.5;
}

.subtitle-item.me .translated-text { color: #9AE6C0; }

/* 控制栏: 常驻最底部。提升层级并带不透明背景 ——
   任何溢出内容(成员卡片/字幕)都不可能盖住它 */
.control-bar {
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #232833;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #9AA5B5;
  font-size: 13px;
  min-width: 160px;
}

.controls-center { display: flex; align-items: center; gap: 14px; transform: translateX(-56px); }

/* 文字型控制按钮 (字幕/邀请/离会): 宽度自适应文字 */
.ctrl-btn.ctrl-text { width: auto; min-width: 48px; padding: 0 16px; }
.ctrl-btn.ctrl-text .ctrl-label { font-size: 14px; font-weight: 500; white-space: nowrap; }

.participant-count { display: flex; align-items: center; gap: 5px; }

.ctrl-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #333B49;
  border: none;
  color: #DDE3ED;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.ctrl-btn:hover { background: #3D4554; }

.ctrl-btn.off { background: #E24B4A; color: #fff; animation: mute-pulse 0.35s ease; }
.ctrl-btn.off:hover { background: #C93A39; color: #fff; }
.ctrl-btn.off .icon-on { display: none; }
.ctrl-btn.off .icon-off { display: block; }

.ctrl-btn:not(.off) .icon-off { display: none; }

/* 视频按钮: "off" 是未开启的默认态, 用中性灰而非告警红(红色留给麦克风静音这类异常);
   开启时才用强调色, 表示正在发送画面 */
#btnVideo.off { background: #333B49; color: #DDE3ED; animation: none; }
#btnVideo.off:hover { background: #3D4554; color: #fff; }
#btnVideo:not(.off) { background: rgba(29, 111, 224, 0.22); color: #6EA8FF; }
#btnVideo:not(.off):hover { background: rgba(29, 111, 224, 0.32); color: #9CC3FF; }
/* 等待摄像头授权期间禁用点击并给出忙碌观感 */
#btnVideo.busy { opacity: 0.55; cursor: progress; }

/* 底部控制栏留出 iPhone 手势区/底部工具栏高度, 按键不会被系统条压住 */
.control-bar { padding-bottom: max(0px, env(safe-area-inset-bottom)); }

@keyframes mute-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.btn-hangup { background: var(--danger) !important; }

/* 窄屏适配: 控制栏换行, 按钮组居中独占一行 —— 新增第六个按钮(视频)后
   不至于把整排挤在一行里溢出或互相压叠 */
@media (max-width: 768px) {
  .control-bar {
    height: auto;
    min-height: 62px;
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .controls-left, .controls-right { min-width: 0; font-size: 12px; }
  .controls-center {
    order: -1;
    width: 100%;
    justify-content: center;
    gap: 10px;
    transform: none; /* 取消桌面端为了视觉居中做的偏移 */
  }
  /* 顶栏: 收起品牌名给会议号和状态灯让位, 避免窄屏挤成两行 */
  .top-bar { padding: 0 10px; min-height: 48px; gap: 8px; }
  .app-name { display: none; }
  .audio-status { font-size: 11px; padding: 2px 6px; }

  .ctrl-btn { width: 44px; height: 44px; }
  .ctrl-btn.ctrl-text { min-width: 44px; padding: 0 12px; }

  /* 窄屏: 主区改为纵向 —— 成员卡片在上(内部滚动), 字幕在下一栏,
     三者互不遮挡, 底部控制栏始终可见 */
  .meeting-main { flex-direction: column; padding: 8px; gap: 8px; }
  .video-tile { min-height: 92px; padding: 10px; gap: 8px; }
  .video-grid { gap: 8px; }

  /* 手机上多人时最多两列, 人特别多才三列: 保证单卡还能看清头像与名字 */
  .video-grid[data-count="3"],
  .video-grid[data-count="4"],
  .video-grid[data-count="5"],
  .video-grid[data-count="6"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .video-grid[data-count="7"],
  .video-grid[data-count="8"],
  .video-grid[data-count="9"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* 视频模式是竖卡片, 手机上最多两列 —— 再多会被挤成看不清的细条 */
  .video-grid.has-video[data-count="2"],
  .video-grid.has-video[data-count="3"],
  .video-grid.has-video[data-count="4"],
  .video-grid.has-video[data-count="5"],
  .video-grid.has-video[data-count="6"],
  .video-grid.has-video[data-count="7"],
  .video-grid.has-video[data-count="8"],
  .video-grid.has-video[data-count="9"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 窄屏: 完全由列宽决定, 绝不允许按高度反推宽度(会横向溢出被裁) */
  .video-grid.has-video .video-tile { min-width: 0; max-width: 100%; min-height: 120px; }

  /* 字幕区由右侧栏改为底部一栏: 限高, 保证上方成员卡片与下方控制栏都有空间 */
  .subtitle-panel { width: auto; height: 30%; min-height: 104px; max-height: 200px; flex-shrink: 0; }
  .subtitle-empty { margin-top: 16px; }
}

/* 大屏多视频时限制单卡最大宽度, 避免两人会议时画面被拉伸得过大 */
.video-grid.has-video { max-width: 1400px; margin: 0 auto; width: 100%; }
.btn-hangup:hover { background: #C93A39 !important; }

.lang-indicator {
  color: #9AA5B5;
  font-size: 12px;
}

/* 滚动条 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #3D4554; border-radius: 3px; }

/* Toast */
.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20,24,32,0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* 连接状态指示 */
.conn-status {
  position: fixed;
  top: 62px;
  right: 14px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  z-index: 99;
  background: rgba(35,40,51,0.95);
  color: #E24B4A;
}
.conn-status.ok { color: var(--success); }

/* ============ 会员/游客状态栏 (落地页) ============ */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 22px;
  border-radius: 10px;
  background: var(--primary-light);
  font-size: 13px;
  color: var(--text-2);
}
.user-bar-info b { color: var(--primary); }
.user-bar-actions { display: flex; gap: 8px; }

.btn-mini {
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 6px;
}
.btn-mini:hover { border-color: var(--primary); color: var(--primary); }
.btn-mini.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-mini.primary:hover { background: var(--primary-dark); }

.admin-link { color: var(--text-3); text-decoration: none; }
.admin-link:hover { color: var(--primary); }

/* ============ 登录/注册弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 32, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-mask[hidden] { display: none; }

.auth-modal {
  width: 360px;
  max-width: 92vw;
  background: var(--bg-2);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.auth-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg-1); border-radius: 8px; padding: 4px; }
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-2);
}
.auth-tab.active { background: var(--bg-2); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.auth-modal .form-group { margin-bottom: 16px; }

.auth-tip { font-size: 12px; color: var(--text-3); margin-bottom: 12px; }

/* 登录弹窗: 忘记密码入口 */
.auth-forgot-row { display: flex; justify-content: center; margin-top: 10px; }
.auth-forgot-row .btn-link { font-size: 13px; color: var(--text-3); }
.auth-forgot-row .btn-link:hover { color: var(--primary); }

/* 个人中心 */
.profile-tab-title {
  flex: 1; text-align: center; font-size: 15px; font-weight: 600; color: var(--text-1);
  background: var(--bg-2); padding: 8px 0; box-shadow: var(--shadow);
}
.profile-info {
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
}
.profile-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 0; font-size: 14px; color: var(--text-1);
}
.profile-row + .profile-row { border-top: 1px dashed rgba(29,111,224,0.25); }
.profile-label { color: var(--text-2); }
.auth-error {
  background: #FDECEC;
  color: var(--danger);
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.auth-submit { width: 100%; }
.btn-link {
  display: block;
  width: 100%;
  margin-top: 12px;
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 13px;
  padding: 8px 0;
  text-decoration: none;
  text-align: center;
}
.btn-link:hover { color: var(--primary); }

/* ============ 管理后台 ============ */
.admin-page { overflow: auto; }

/* hidden 属性兜底: display:flex 会覆盖 hidden 的 UA display:none,
   缺此规则时登录成功后登录卡片不消失, 表现为"点登录没反应" */
.admin-login[hidden] { display: none; }
.admin-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #F0F6FF 0%, #F5F7FA 60%, #EEF2F7 100%);
}
.admin-login-card {
  width: 380px;
  max-width: 92vw;
  background: var(--bg-2);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
  text-align: center;
}
.admin-login-card h2 { font-size: 20px; margin-bottom: 6px; }
.admin-login-sub { font-size: 13px; color: var(--text-3); margin-bottom: 24px; }
.admin-login-card .form-group { text-align: left; }
.admin-login-card .btn-primary { width: 100%; }
.admin-back { margin-top: 8px; }

.admin-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.admin-title { font-size: 17px; font-weight: 700; }
.admin-header-actions { display: flex; gap: 8px; }

.admin-body { max-width: 1200px; margin: 0 auto; padding: 24px 16px 60px; }

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat-card .stat-value { font-size: 22px; font-weight: 700; color: var(--primary); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card .stat-label { font-size: 12px; color: var(--text-3); margin-top: 6px; }

.admin-section { background: var(--bg-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 24px; }
.admin-section h3 { font-size: 15px; margin-bottom: 14px; }
.admin-table-wrap { overflow-x: auto; }

.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.admin-table th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-3);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
}
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .empty-tip { text-align: center; color: var(--text-3); padding: 28px 0; }
.admin-table .text-danger { color: var(--danger); font-weight: 600; }
.bill-status.free { color: var(--text-3); }
.bill-status.unpaid { color: var(--danger); font-weight: 600; }
.bill-status.paid { color: var(--success); font-weight: 600; }

/* ============ 余额充值 ============ */
.profile-tab-title { font-weight: 700; font-size: 15px; }
.text-balance { font-weight: 600; color: var(--primary); }
.recharge-amounts { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 14px; }
.recharge-amt-btn {
  flex: 1 1 calc(50% - 10px);
  min-width: 90px;
  padding: 12px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-1);
  font-size: 15px;
  cursor: pointer;
  transition: all .15s;
}
.recharge-amt-btn:hover { border-color: var(--primary); }
.recharge-amt-btn.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.recharge-custom input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  box-sizing: border-box;
}

/* ============ 站点页脚备案 ============ */
.site-footer {
  text-align: center;
  padding: 16px 12px;
  font-size: 12px;
  color: var(--text-3);
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  line-height: 1.8;
}
.site-footer .beian-link { color: var(--text-3); text-decoration: none; margin: 0 4px; }
.site-footer .beian-link:hover { color: var(--primary); }
