/* umrtc —— 视频会议系统样式（零依赖，响应式，12px 统一圆角） */
:root {
  --radius: 12px;
  --bg: #0f1419;
  --bg-2: #171e27;
  --panel: #1e2732;
  --panel-2: #26303d;
  --line: #2e3a49;
  --text: #e8edf3;
  --text-dim: #9aa7b6;
  --primary: #3b82f6;
  --primary-h: #2f6fe0;
  --danger: #ef4444;
  --danger-h: #dc2626;
  --ok: #22c55e;
  --warn: #f59e0b;
  font-size: 16px;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button, input, select { font-family: inherit; font-size: 1rem; }

/* ---------------- 通用控件 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, opacity .15s ease;
  user-select: none;
}
.btn:hover { background: var(--primary-h); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--panel-2); color: var(--text); }
.btn.ghost:hover { background: var(--line); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: var(--danger-h); }
.btn.block { width: 100%; }

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; color: var(--text-dim); font-size: .9rem; }
.input, select.input {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
  color: var(--text);
  outline: none;
}
.input:focus { border-color: var(--primary); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .75rem;
  background: var(--panel-2);
  color: var(--text-dim);
}
.badge.mesh { background: #1e3a5f; color: #7db8ff; }
.badge.sfu { background: #3a2a5f; color: #c29bff; }

/* ---------------- 大厅页 index ---------------- */
.lobby {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}
.lobby header { text-align: center; margin-bottom: 28px; }
.lobby header h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); }
.lobby header p { color: var(--text-dim); margin-top: 8px; }

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}
@media (min-width: 820px) {
  .lobby-grid { grid-template-columns: 1fr 1fr; }
}

.room-list { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-2);
}
.room-item .meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.room-item .meta .rn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-item .meta .ri { font-size: .8rem; color: var(--text-dim); }
.muted { color: var(--text-dim); font-size: .9rem; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1; min-height: 44px; border: 1px solid var(--line);
  background: var(--bg-2); color: var(--text-dim); border-radius: var(--radius); cursor: pointer;
}
.seg button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------------- 会议页 room ---------------- */
.meet {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}
.meet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.meet-top .title { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.meet-top .conn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; color: var(--text-dim);
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-dim); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--danger); }

.stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 12px;
}
.meet-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  max-width: min(560px, calc(100% - 32px));
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: .85rem;
  text-align: center;
  pointer-events: none;
}

/* 宫格布局 */
.grid {
  display: grid;
  gap: 10px;
  width: 100%;
  height: 100%;
  grid-auto-rows: 1fr;
}

/* 主讲人布局 */
.stage.spotlight .grid {
  grid-template-columns: 1fr !important;
  grid-template-rows: 1fr auto;
}
.stage.spotlight .filmstrip {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  height: 22vh;
  min-height: 120px;
}
.stage.spotlight .filmstrip .tile { width: 180px; flex: 0 0 auto; height: 100%; }
.filmstrip { display: none; }

.tile {
  position: relative;
  background: #000;
  border: 2px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 90px;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.tile.dragging {
  opacity: 0.65;
  z-index: 4;
  cursor: grabbing;
}
.tile video, .tile .avatar, .tile .name, .tile .status { touch-action: none; }
.tile.speaking { border-color: var(--ok); }
.tile.main { grid-column: 1 / -1; }
.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  display: block;
}
.tile.local video { transform: scaleX(-1); }
.tile .name {
  position: absolute; left: 8px; bottom: 8px;
  padding: 3px 8px; border-radius: 8px;
  background: rgba(0,0,0,.55); font-size: .8rem; max-width: 70%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile .status {
  position: absolute; right: 8px; top: 8px;
  display: flex; align-items: center; gap: 6px;
}
.tile .status .ic {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); font-size: 14px;
}
.tile .status .ic.off { background: rgba(239,68,68,.85); }
.tile .net {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 26px;
  padding: 5px 5px 4px;
  border-radius: 8px;
  background: rgba(0,0,0,.55);
}
.tile .net[data-tip]:not([data-tip=""]):hover::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 3;
  padding: 3px 6px;
  border-radius: 6px;
  background: rgba(0,0,0,.8);
  color: #fff;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
}
.tile .net i {
  display: block;
  width: 3px;
  border-radius: 1px;
  background: rgba(255,255,255,.28);
}
.tile .net i:nth-child(1) { height: 5px; }
.tile .net i:nth-child(2) { height: 9px; }
.tile .net i:nth-child(3) { height: 13px; }
.tile .net i:nth-child(4) { height: 17px; }
.tile .net.q4 i { background: var(--ok); }
.tile .net.q3 i:nth-child(-n+3) { background: #84cc16; }
.tile .net.q2 i:nth-child(-n+2) { background: #f59e0b; }
.tile .net.q1 i:nth-child(1) { background: #ef4444; }
.tile .avatar {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel);
}
.tile .avatar span {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 600;
}
.tile.video-off video { display: none; }

/* 控制条 */
.controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-2);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.ctrl {
  position: relative;
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
}
.ctrl .cbtn {
  width: 52px; height: 52px; border-radius: 50%;
  border: none; cursor: pointer;
  background: var(--panel-2); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; transition: background .15s, transform .08s;
}
.ctrl .cbtn:hover { background: var(--line); }
.ctrl .cbtn:active { transform: scale(.94); }
.ctrl .cbtn.active { background: var(--primary); color: #fff; }
.ctrl .cbtn.off { background: var(--danger); color: #fff; }
.ctrl .clabel { font-size: .7rem; color: var(--text-dim); }
.ctrl.hangup .cbtn { background: var(--danger); color: #fff; }

/* 设备选择下拉 */
.menu {
  position: absolute; bottom: 64px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px; min-width: 220px; display: none; z-index: 20;
  box-shadow: 0 8px 28px rgba(0,0,0,.4);
}
.menu.open { display: block; }
.menu .mi { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: .9rem; }
.menu .mi:hover { background: var(--panel-2); }
.menu .mi.sel { color: var(--primary); }
.menu .mt { padding: 6px 12px; font-size: .75rem; color: var(--text-dim); }

/* 提示 toast */
.toast-wrap {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 100; width: min(92vw, 420px);
}
.toast {
  background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--primary);
  border-radius: var(--radius); padding: 12px 14px; font-size: .9rem;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: slidein .2s ease;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes slidein { from { opacity: 0; transform: translateY(-8px);} to { opacity: 1; transform: none;} }

/* 加入前的预览遮罩 */
.join-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10,14,20,.94);
  display: flex; align-items: safe center; justify-content: center;
  padding: 16px; overflow: auto;
}
.join-box {
  width: min(94vw, 860px);
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "preview" "form" "watch" "guide";
  gap: 18px;
  align-items: start;
}
.join-preview { grid-area: preview; }
.join-guide { grid-area: guide; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.join-box > .card { grid-area: form; }
.join-watch { grid-area: watch; margin: 0; }
.join-watch[hidden] { display: none !important; }
@media (min-width: 720px) {
  .join-box {
    grid-template-columns: 1.15fr .85fr;
    grid-template-areas: "preview form" "guide watch";
  }
}
.join-guide .secure-hint { margin: 0; }
.join-preview { background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 16/9; position: relative; }
.join-preview video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; transform: scaleX(-1);
}
@media (min-width: 720px) {
  /* 画面高度跟右侧加入卡片走，不再按 16:9 高出一截。写在后面，避免被上面的 16:9 盖掉。 */
  .join-preview { aspect-ratio: auto; align-self: stretch; min-height: 0; }
  .join-watch { align-self: start; }
}
.preview-empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: #11161c;
  color: var(--text);
}
.preview-empty[hidden] { display: none !important; }
.preview-empty-ic { font-size: 1.6rem; line-height: 1; opacity: .85; }
.preview-empty strong { font-size: 1rem; font-weight: 600; }

.secure-hint {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--warn);
  background: rgba(245, 158, 11, .1);
  font-size: .85rem;
  line-height: 1.55;
}
.secure-hint strong { color: var(--warn); }
.secure-hint .lead { margin: 4px 0 0; color: var(--text); }
.secure-method {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(245, 158, 11, .28);
}
.secure-method-title { font-weight: 600; margin-bottom: 4px; }
.secure-method p { margin: 0; color: var(--text-dim); }
.secure-hint .mono {
  display: block;
  margin: 8px 0 0;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 8px;
  font-family: ui-monospace, Consolas, monospace;
  font-size: .75rem;
  word-break: break-all;
  user-select: all;
}
.secure-hint .hint-actions { display: flex; gap: 8px; margin-top: 8px; }
.secure-hint .hint-actions button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}
.watch-note {
  margin: -2px 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-2);
  font-size: .85rem;
  line-height: 1.55;
}
.watch-note strong { display: block; margin-bottom: 4px; }
.watch-note p { margin: 0; color: var(--text-dim); }
.seg button:disabled { opacity: .45; cursor: not-allowed; }
.lobby-secure {
  max-width: 720px;
  margin: 0 auto 18px;
}

.hidden { display: none !important; }

/* 统计面板 */
.stats-panel {
  position: absolute; right: 12px; top: 12px; z-index: 15;
  background: rgba(0,0,0,.6); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; font-size: .75rem; color: var(--text-dim); max-width: 260px; display: none;
}
.stats-panel.open { display: block; }
.stats-panel .sr { display: flex; justify-content: space-between; gap: 10px; }
