:root {
  /* 浅色主题（腾讯会议风格） */
  --bg: #f4f6f9;
  --bg-card: #ffffff;
  --bg-elevated: #f0f2f5;
  --text: #1f2937;
  --text-muted: #6b7280;
  --primary: #2e7bff;
  --primary-hover: #1f68e0;
  --primary-soft: #eaf2ff;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #10b981;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(31, 41, 55, .08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; }

/* ---------- 首页 ---------- */
#lobby {
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  background: linear-gradient(160deg, #f0f6ff 0%, var(--bg) 55%);
}

.lobby-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: var(--shadow);
}

.brand { text-align: center; margin-bottom: 32px; }
.brand-icon {
  width: 60px; height: 60px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--primary), #5b9bff);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(46, 123, 255, .28);
}
.brand-icon svg { width: 30px; height: 30px; color: #fff; }
.brand h1 { font-size: 26px; font-weight: 700; letter-spacing: 1px; color: #111827; }
.brand p { color: var(--text-muted); font-size: 14px; margin-top: 6px; }

.form-group { margin-bottom: 22px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 8px;
}
.form-group input {
  width: 100%; height: 46px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0 14px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(46, 123, 255, .12);
}
.form-group input::placeholder { color: #9ca3af; }
.form-group small { display: block; color: var(--text-muted); font-size: 12px; margin-top: 6px; }

.role-select { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.role-btn {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 18px 12px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .2s;
}
.role-btn:hover { border-color: var(--primary); }
.role-btn.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.role-icon { width: 32px; height: 32px; }
.role-icon svg { width: 100%; height: 100%; }
.role-text { text-align: center; }
.role-text strong { display: block; font-size: 14px; margin-bottom: 4px; color: var(--text); }
.role-btn.active .role-text strong { color: var(--primary); }
.role-text small { font-size: 11px; color: var(--text-muted); }

.btn {
  width: 100%; height: 48px;
  border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
  font-family: var(--font);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(46,123,255,.25); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: #cbd5e1; color: #fff; cursor: not-allowed; box-shadow: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-small { width: auto; height: 34px; padding: 0 16px; font-size: 13px; }

.lobby-hint {
  display: flex; align-items: center; gap: 8px;
  margin-top: 20px; padding: 12px;
  background: var(--primary-soft);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.5;
}
.lobby-hint svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--primary); }

/* ---------- 会议界面 ---------- */
#meeting { flex-direction: column; }

.meeting-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.room-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-elevated);
  padding: 6px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 500;
  color: var(--text);
}
.room-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--success);
}
.connection-status {
  flex: 1; text-align: center;
  font-size: 12px; color: var(--text-muted);
}
.connection-status.connected { color: var(--success); }
.connection-status.error { color: var(--danger); }

.stage {
  flex: 1;
  position: relative;
  background: #1a1d24;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  min-height: 0;
}
.stage video#remoteVideo {
  width: 100%; height: 100%;
  object-fit: contain;
  background: #1a1d24;
}

.placeholder {
  text-align: center;
  padding: 32px;
  color: #9ca3af;
}
.placeholder-icon {
  width: 64px; height: 64px; margin: 0 auto 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center;
}
.placeholder-icon svg { width: 32px; height: 32px; color: #cbd5e1; }
.placeholder h3 { color: #f3f4f6; font-size: 18px; margin-bottom: 8px; }
.placeholder p { font-size: 13px; line-height: 1.6; }

.host-preview {
  position: absolute;
  top: 12px; right: 12px;
  width: 200px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--primary);
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.host-preview video { width: 100%; display: block; background: #000; }
.preview-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.7);
  color: #fff;
  font-size: 11px; padding: 4px 8px;
}

.mic-indicator {
  position: absolute;
  bottom: 16px; left: 16px;
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.6);
  color: #fff;
  padding: 8px 12px; border-radius: 20px;
  font-size: 12px;
}
.mic-indicator svg { width: 16px; height: 16px; color: var(--success); }

.controls {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.ctrl-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 72px; padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  transition: background .2s, opacity .2s;
}
.ctrl-btn:hover { background: #e5e7eb; }
.ctrl-btn svg { width: 22px; height: 22px; }
.ctrl-btn.active { background: var(--primary); color: #fff; }
.ctrl-btn.muted { opacity: .55; }
.ctrl-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.ctrl-primary:hover { background: var(--primary-hover); }
.ctrl-primary.sharing { background: var(--danger); border-color: var(--danger); }

.peer-list {
  position: absolute;
  top: 70px; left: 16px;
  display: flex; flex-direction: column; gap: 6px;
  z-index: 10;
}
.peer-chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.6);
  color: #fff;
  padding: 6px 10px; border-radius: 16px;
  font-size: 11px;
}
.peer-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }

.hidden { display: none !important; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  bottom: 90px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(31, 41, 55, .92);
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 鉴权遮罩 ---------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #f4f7fb 0%, #e8eef6 100%);
}
.auth-gate.hidden { display: none; }
.auth-gate-inner { text-align: center; color: var(--text-muted); font-size: 14px; }
.auth-gate-inner .spinner {
  width: 38px; height: 38px; margin: 0 auto 14px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 内置浏览器提示 ---------- */
.browser-warning {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: rgba(15, 23, 42, .45);
}
.browser-warning-card {
  width: 100%; max-width: 340px; background: var(--bg-card);
  border-radius: 16px; padding: 26px 24px; box-shadow: var(--shadow); text-align: center;
}
.browser-warning-card h3 { font-size: 17px; margin-bottom: 12px; color: var(--text); }
.browser-warning-card p { font-size: 13px; line-height: 1.7; color: var(--text-muted); margin-bottom: 20px; }
.browser-warning-card .btn { width: 100%; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 600px) {
  .lobby-card { padding: 28px 20px; border-radius: 16px; }
  .role-select { grid-template-columns: 1fr; }
  .role-btn { flex-direction: row; justify-content: flex-start; padding: 14px; }
  .role-icon { width: 28px; height: 28px; }
  .role-text { text-align: left; }
  .host-preview { width: 120px; }
  .controls { gap: 8px; padding: 10px 8px; }
  .ctrl-btn { min-width: 64px; padding: 8px; }
}

/* ---------- 连接诊断面板 ---------- */
.diag-panel {
  position: fixed; right: 12px; bottom: 12px; z-index: 200;
  width: min(420px, calc(100vw - 24px)); max-height: 70vh;
  display: flex; flex-direction: column;
  background: #1e293b; color: #e2e8f0;
  border: 1px solid #334155; border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.35); overflow: hidden;
}
.diag-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: #0f172a; font-size: 14px;
}
.diag-head strong { flex: 1; }
.diag-btn {
  background: #334155; color: #e2e8f0; border: none; border-radius: 6px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.diag-btn:hover { background: #475569; }
.diag-status {
  padding: 8px 12px; font-size: 12px; color: #93c5fd;
  border-bottom: 1px solid #334155;
}
.diag-log {
  margin: 0; padding: 10px 12px; overflow: auto; flex: 1;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 10.5px; line-height: 1.6; white-space: pre-wrap;
  word-break: break-all; color: #cbd5e1;
}
