/* ============================================================
   金豆 · 微信风格样式
   配色：微信绿 #07C160 / 挂断红 #FA5151 / 底色 #EDEDED
   ============================================================ */

:root {
  --green: #07C160;
  --green-press: #06AD56;
  --red: #FA5151;
  --bg: #EDEDED;
  --card: #FFFFFF;
  --text: #191919;
  --sub: #888888;
  --line: #E5E5E5;
  --call-bg: #0E0E0E;
  --radius: 12px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

.hidden { display: none !important; }

/* ============================================================
   加入页
   ============================================================ */

.page-join { overflow-y: auto; background: var(--bg); }

.nav-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: 48px;
  padding-top: var(--safe-t);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.nav-title { font-size: 17px; font-weight: 600; letter-spacing: .5px; }

.join-wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 20px calc(32px + var(--safe-b));
}

.join-logo {
  width: 72px;
  height: 72px;
  margin: 8px auto 14px;
  border-radius: 20px;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(7, 193, 96, .28);
}

.join-slogan { text-align: center; color: var(--sub); font-size: 13px; margin: 0 0 24px; }

.join-card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
}

.field {
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 0 16px;
}
.field + .field { border-top: 1px solid var(--line); }
.field-label { width: 76px; color: var(--text); font-size: 16px; flex: none; }
.field-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  font-size: 16px;
  background: transparent;
  color: var(--text);
  padding: 16px 0;
}
.field-input::placeholder { color: #b8b8b8; }
.field-input.room { font-size: 20px; letter-spacing: 3px; font-weight: 600; }

.join-hint {
  color: var(--sub);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 14px 4px 22px;
  text-align: center;
}

.btn-primary {
  display: block;
  width: 100%;
  height: 48px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-size: 17px;
  font-weight: 500;
  transition: background .15s, transform .1s;
}
.btn-primary:active { background: var(--green-press); transform: scale(.99); }
.btn-primary:disabled { background: #c8c9cc; cursor: not-allowed; }

.btn-text {
  display: block;
  width: 100%;
  margin-top: 16px;
  color: #576B95;
  font-size: 14px;
  padding: 8px;
}

.join-recent { margin-top: 26px; }
.join-recent-title { color: var(--sub); font-size: 12.5px; margin: 0 4px 8px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  width: 100%;
  text-align: left;
}
.recent-item:active { background: #f2f2f2; }
.recent-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 600;
}
.recent-main { flex: 1; min-width: 0; }
.recent-room { font-size: 16px; font-weight: 500; letter-spacing: 1px; }
.recent-sub { font-size: 12px; color: var(--sub); margin-top: 3px; }

.join-footer { text-align: center; color: #b2b2b2; font-size: 11.5px; margin-top: 28px; line-height: 1.8; }

.warn-box {
  background: #FFF9E6;
  border: 1px solid #FFE58F;
  color: #8B6D00;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 16px;
}

/* ============================================================
   通话页
   ============================================================ */

.page-call { background: var(--call-bg); color: #fff; }

.stage { position: fixed; inset: 0; background: var(--call-bg); overflow: hidden; }

.main-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

video { display: block; background: transparent; }

.main-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.main-video.mirror { transform: scaleX(-1); }

.main-avatar-box {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: radial-gradient(circle at 50% 42%, #2a2a2a 0%, #141414 70%);
}
.main-avatar-box .avatar { box-shadow: 0 8px 26px rgba(0, 0, 0, .5); }
.main-avatar-name { font-size: 17px; color: #d8d8d8; }

.avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  flex: none;
  user-select: none;
}

.waiting-box {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #9a9a9a;
  text-align: center;
  padding: 0 32px;
}
.waiting-room { font-size: 30px; letter-spacing: 6px; color: #fff; font-weight: 600; }
.waiting-tip { font-size: 13.5px; line-height: 1.7; }

/* ---------- 顶栏 ---------- */

.topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  padding: calc(var(--safe-t) + 10px) 14px 26px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .55), rgba(0, 0, 0, 0));
  pointer-events: none;
  font-size: 12.5px;
  color: rgba(255, 255, 255, .92);
}
.topbar > * { pointer-events: auto; }
.top-meta { display: flex; align-items: center; gap: 8px; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }
.top-room { font-weight: 600; letter-spacing: 1px; }
.top-dot { opacity: .5; }
.top-spacer { flex: 1; }

.netbars { display: inline-flex; align-items: flex-end; gap: 1.5px; height: 11px; }
.netbars i { display: block; width: 3px; background: rgba(255, 255, 255, .28); border-radius: 1px; }
.netbars i:nth-child(1) { height: 3px; }
.netbars i:nth-child(2) { height: 5.5px; }
.netbars i:nth-child(3) { height: 8px; }
.netbars i:nth-child(4) { height: 11px; }
.netbars i.on { background: #fff; }
.netbars.bad i.on { background: #FFD666; }

.top-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  backdrop-filter: blur(6px);
}
.top-btn svg { width: 17px; height: 17px; }

.banner {
  position: absolute;
  top: calc(var(--safe-t) + 54px);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 21;
  background: rgba(250, 157, 59, .94);
  color: #fff;
  font-size: 12.5px;
  padding: 6px 14px;
  border-radius: 14px;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  max-width: 86vw;
  text-align: center;
}
.banner.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 主屏标签 ---------- */

.main-label {
  position: absolute;
  left: 14px;
  bottom: 132px;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 14px;
  background: rgba(0, 0, 0, .42);
  color: #fff;
  font-size: 12.5px;
  backdrop-filter: blur(6px);
  max-width: 62vw;
  pointer-events: none;
}
.main-label .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main-label svg { width: 13px; height: 13px; opacity: .9; flex: none; }
.main-label .tag-main { color: #FFD666; font-size: 11px; }

/* ---------- 副屏（可拖动小窗） ---------- */

.tiles { position: absolute; inset: 0; z-index: 18; pointer-events: none; }

.tile {
  position: absolute;
  width: var(--tile-w, 132px);
  aspect-ratio: 4 / 3;
  border-radius: 9px;
  overflow: hidden;
  background: #1c1c1c;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .45);
  border: 1px solid rgba(255, 255, 255, .16);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  transition: box-shadow .16s, transform .16s;
  will-change: left, top, transform;
}
.tile.no-anim { transition: none; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile video.mirror { transform: scaleX(-1); }
.tile.is-dragging { transition: none; z-index: 40; box-shadow: 0 10px 26px rgba(0, 0, 0, .6); transform: scale(1.06); }

.tile-off {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #333 0%, #1b1b1b 72%);
}
.tile-off .avatar { font-size: 20px; }

.tile-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 8px 6px 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, .62), rgba(0, 0, 0, 0));
  pointer-events: none;
}
.tile-bar .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-bar svg { width: 10px; height: 10px; flex: none; opacity: .95; }

.tile-badge {
  position: absolute;
  top: 5px; right: 5px;
  background: rgba(0, 0, 0, .5);
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 9.5px;
  color: #FFD666;
}

.tile.is-offline video { filter: grayscale(1) brightness(.45); }
.tile.is-offline::after {
  content: '连接中…';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  color: #fff;
  background: rgba(0, 0, 0, .45);
}
.tile.is-main { outline: 2px solid var(--green); outline-offset: -2px; }

/* ---------- 底部控制栏 ---------- */

.controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  padding: 30px 12px calc(var(--safe-b) + 18px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: linear-gradient(to top, rgba(0, 0, 0, .62), rgba(0, 0, 0, 0));
}

.ctrl {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  backdrop-filter: blur(10px);
  transition: background .16s, transform .12s, color .16s;
  flex: none;
}
.ctrl:active { transform: scale(.92); }
.ctrl-icon { display: flex; width: 26px; height: 26px; }
.ctrl-icon svg { width: 100%; height: 100%; }
.ctrl.is-off { background: #fff; color: #191919; }
.ctrl-danger { background: var(--red); color: #fff; }
.ctrl-danger:active { background: #e84848; }

.ctrl-label {
  position: absolute;
  margin-top: 78px;
  font-size: 10.5px;
  color: rgba(255, 255, 255, .72);
  white-space: nowrap;
}

/* ---------- 麦克风静音小图标 ---------- */

.mic-off-icon { color: #FF7B7B; }

/* ============================================================
   加入前准备面板
   ============================================================ */

.prep {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #0E0E0E;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 24px) 24px calc(var(--safe-b) + 24px);
  gap: 26px;
}
.prep-preview {
  width: min(74vw, 340px);
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  overflow: hidden;
  background: #1b1b1b;
  position: relative;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .55);
}
.prep-preview video { width: 100%; height: 100%; object-fit: cover; }
.prep-preview video.mirror { transform: scaleX(-1); }
.prep-off {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #333 0%, #1a1a1a 72%);
}
.prep-room { text-align: center; }
.prep-room-id { font-size: 26px; letter-spacing: 5px; font-weight: 600; color: #fff; }
.prep-room-tip { font-size: 12.5px; color: #8f8f8f; margin-top: 8px; line-height: 1.6; }
.prep-side { display: flex; flex-direction: column; align-items: center; gap: 24px; width: 100%; max-width: 340px; }
.prep-side .warn-box { background: rgba(250, 157, 59, .16); border-color: rgba(250, 157, 59, .5); color: #FFC078; width: 100%; }
.prep-toggles { display: flex; gap: 34px; }
.prep-toggle { display: flex; flex-direction: column; align-items: center; gap: 9px; }
.prep-toggle .ctrl { width: 62px; height: 62px; }
.prep-toggle span { font-size: 11.5px; color: #9c9c9c; }
.prep-actions { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; }
.prep-actions .btn-text { color: #8a8a8a; margin-top: 0; }

/* ============================================================
   Toast / 遮罩 / 弹层
   ============================================================ */

.toast {
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -10px) scale(.96);
  z-index: 200;
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 14px;
  line-height: 1.5;
  padding: 11px 18px;
  border-radius: 9px;
  max-width: 78vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
  backdrop-filter: blur(3px);
}
.overlay.show { opacity: 1; pointer-events: auto; }
.overlay-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.overlay-text {
  color: #fff;
  font-size: 14px;
  text-align: center;
  padding: 0 26px;
  line-height: 1.7;
  /* 连接诊断信息是多行的（地址 / 状态 / 重试次数），必须让 \n 真正换行 */
  white-space: pre-line;
  word-break: break-word;
}

.spinner {
  width: 32px; height: 32px;
  border: 2.5px solid rgba(255, 255, 255, .25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(0, 0, 0, .42);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity .2s;
}
.sheet-mask.show { opacity: 1; }
.sheet {
  width: 100%;
  max-height: 78vh;
  overflow-y: auto;
  background: var(--card);
  color: var(--text);
  border-radius: 14px 14px 0 0;
  padding-bottom: var(--safe-b);
  transform: translateY(16px);
  transition: transform .22s;
}
.sheet-mask.show .sheet { transform: translateY(0); }
.sheet-head {
  position: sticky; top: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 15px 48px 13px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.sheet-title { font-size: 15.5px; font-weight: 600; }
.sheet-close {
  position: absolute; right: 10px; top: 9px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--sub);
}
.sheet-close svg { width: 17px; height: 17px; }
.sheet-body { padding: 4px 0 14px; }
.sheet-section { padding: 14px 18px 6px; font-size: 12.5px; color: var(--sub); }
.sheet-info { padding: 4px 18px 10px; font-size: 13px; color: var(--sub); line-height: 1.65; }
.sheet-item {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; min-height: 50px; padding: 0 18px;
  font-size: 16px; text-align: left;
  border-bottom: 1px solid var(--line);
}
.sheet-item:active { background: #f4f4f4; }
.sheet-item-value { color: var(--sub); font-size: 14px; margin-left: 12px; text-align: right; }

/* ============================================================
   响应式：横屏 / 桌面
   ============================================================ */

@media (min-width: 700px) {
  .tile { --tile-w: 168px; }
  .controls { gap: 26px; }
  .ctrl { width: 62px; height: 62px; }
  .ctrl-icon { width: 28px; height: 28px; }
  .main-label { bottom: 150px; left: 22px; font-size: 13.5px; }
  .prep { flex-direction: row; gap: 46px; }
  .prep-preview { width: 380px; aspect-ratio: 4 / 3; }
  .prep-actions { width: 280px; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .prep-preview { width: 190px; aspect-ratio: 4 / 3; }
  .controls { padding-top: 16px; padding-bottom: calc(var(--safe-b) + 10px); gap: 16px; }
  .ctrl { width: 46px; height: 46px; }
  .ctrl-icon { width: 21px; height: 21px; }
  .main-label { bottom: 76px; }
}

@media (max-width: 360px) {
  .controls { gap: 12px; }
  .ctrl { width: 50px; height: 50px; }
  .ctrl-icon { width: 22px; height: 22px; }
  .prep-toggles { gap: 24px; }
}
