/* ==========================================================================
   app.css — Web 客户端样式（无框架、无构建）
   深色为默认；所有尺寸用 clamp/1fr，手机与桌面共用一套布局。
   ========================================================================== */

:root {
  --bg: #0b0f14;
  --panel: #131a22;
  --panel-2: #18212c;
  --line: #243040;
  --text: #e8eef6;
  --muted: #8fa3b8;
  --accent: #35d0a5;
  --accent-ink: #04231b;
  --danger: #ff6b6b;
  --warn: #ffc857;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 600px at 20% -10%, #16222e 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
/* ⚠️ 必须显式处理 hidden 属性：`.drawer{display:flex}` 这类作者样式会盖掉浏览器的
   [hidden]{display:none}，表现为「抽屉/主持人按钮默认就显示」。 */
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); letter-spacing: .08em; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ───────────── 屏幕容器 ───────────── */
.screen { min-height: 100%; display: flex; flex-direction: column; }

/* ───────────── 首屏 ───────────── */
.home { padding: clamp(20px, 5vw, 56px); gap: 28px; justify-content: center; align-items: center; }
.home-top {
  width: min(980px, 100%); display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(160deg, #2ee0ab, #1a9c94); color: #05221c;
  font-weight: 800; letter-spacing: .02em; box-shadow: var(--shadow);
}
.brand h1 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: .01em; }
.brand p { margin: 2px 0 0; font-size: 12.5px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted);
}
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(255, 200, 87, .12); }
.pill.ok i { background: var(--accent); box-shadow: 0 0 0 3px rgba(53, 208, 165, .14); }
.pill.bad i { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 107, 107, .14); }

.home-cards {
  width: min(980px, 100%); display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
@media (max-width: 760px) { .home-cards { grid-template-columns: 1fr; } }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(18px, 3vw, 26px); display: flex; flex-direction: column; gap: 14px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 2px; font-size: 16px; font-weight: 600; }
.card label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
@media (max-width: 420px) { .row2 { grid-template-columns: 1fr; } }

input[type="text"], input:not([type]), input[type="password"] {
  width: 100%; padding: 11px 12px; border-radius: 10px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(53, 208, 165, .12); }
input::placeholder { color: #5d7288; }

.check { flex-direction: row !important; align-items: center; gap: 8px !important; color: var(--text) !important; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
  padding: 12px 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-weight: 600; transition: transform .08s, filter .15s, background .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: var(--panel-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.hint { margin: 0; font-size: 12px; color: #6b8098; }
.home-foot { width: min(980px, 100%); font-size: 12px; text-align: center; }

/* ───────────── 等候区 ───────────── */
.wait { align-items: center; justify-content: center; padding: 24px; }
.wait-box { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.wait-box h2 { margin: 6px 0 0; font-size: 18px; font-weight: 600; }
.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .12); border-top-color: var(--accent);
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ───────────── 会议中 ───────────── */
.meet { height: 100vh; height: 100dvh; overflow: hidden; }
.meet-top {
  height: 52px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; gap: 12px; border-bottom: 1px solid var(--line); background: rgba(11, 15, 20, .7);
  backdrop-filter: blur(8px);
}
.meet-id { display: flex; align-items: center; gap: 6px; }
.meet-id .mono { font-size: 13px; color: var(--text); }
.meet-status { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.meet-status .sep { opacity: .4; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }

.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: transparent; border: 1px solid transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); border-color: var(--line); }

.stage { position: relative; flex: 1; min-height: 0; }
.grid {
  height: 100%; padding: 14px 14px 86px; display: grid; gap: 12px; overflow-y: auto;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  align-content: start;
}
.tile {
  position: relative; border-radius: 12px; overflow: hidden; background: #0e151d;
  border: 1px solid var(--line); aspect-ratio: 16 / 9;
}
.tile video.main { width: 100%; height: 100%; object-fit: cover; background: #0a1017; display: block; }
video.mirror { transform: scaleX(-1); }

/* 右上角摄像头小窗：仅在对方（或自己）共享屏幕时出现 */
.tile .pip {
  position: absolute; right: 8px; top: 8px; width: 26%; max-width: 220px;
  aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; z-index: 2;
  border: 1px solid rgba(255, 255, 255, .22); background: #000;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .45);
}
.tile.sharing::before {
  content: '共享中'; position: absolute; right: 8px; bottom: 8px; z-index: 2;
  padding: 3px 8px; border-radius: 8px; font-size: 12px;
  background: rgba(53, 208, 165, .18); color: var(--accent);
  border: 1px solid rgba(53, 208, 165, .35);
}
.tile .tag {
  position: absolute; left: 8px; bottom: 8px; display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border-radius: 8px; background: rgba(6, 10, 14, .66); font-size: 12px;
  backdrop-filter: blur(4px);
}
.tile .tag svg { width: 14px; height: 14px; }
.tile .hand {
  position: absolute; left: 8px; top: 8px; padding: 3px 8px; border-radius: 8px;
  background: rgba(255, 200, 87, .16); color: var(--warn); font-size: 12px;
}
.tile.off::after {
  content: attr(data-name); position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 13px; background: #0c131a;
}

/* 链路状态角标：把 WebRTC 的真实状态摆出来，
   用户才能区分「对方没开摄像头」和「网络打不通」 */
.tile .conn {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3;
  padding: 6px 12px; border-radius: 999px; font-size: 12px;
  background: rgba(6, 10, 14, .8); color: var(--warn);
  border: 1px solid rgba(255, 200, 87, .35);
}
.tile .conn.bad { color: var(--danger); border-color: rgba(255, 107, 107, .4); }

/* 格子里的说明文字（媒体获取失败的原因） */
.tile .tile-note {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3;
  max-width: 84%; text-align: center; font-size: 12px; line-height: 1.6;
  color: var(--danger); background: rgba(6, 10, 14, .82);
  border: 1px solid rgba(255, 107, 107, .3); border-radius: 10px; padding: 8px 12px;
}

/* 自动播放被拦：点一下就能播，而不是永远黑屏 */
.tap-play {
  position: absolute; inset: 0; z-index: 5; display: grid; place-items: center;
  background: rgba(4, 8, 12, .55); color: var(--text); font-size: 14px; cursor: pointer;
}
.muted-note {
  position: absolute; right: 8px; top: 8px; z-index: 5; padding: 3px 8px;
  border-radius: 8px; font-size: 12px; cursor: pointer;
  background: rgba(6, 10, 14, .72); color: var(--warn); border: 1px solid rgba(255, 200, 87, .35);
}

/* 全局链路告警：只在媒体确实建连失败时出现 */
.conn-hint {
  margin: 0 12px 8px; padding: 8px 12px; border-radius: 10px; font-size: 13px;
  color: #ffd7d7; background: rgba(255, 107, 107, .12);
  border: 1px solid rgba(255, 107, 107, .3);
}

/* 诊断面板 */
.diag {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  background: rgba(3, 6, 10, .72); padding: 16px;
}
.diag-box {
  width: min(680px, 96vw); max-height: 86vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.diag-box header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.diag-body { padding: 10px 14px; overflow: auto; font-size: 12.5px; }
.diag-body h4 {
  margin: 12px 0 6px; font-size: 12px; color: var(--accent);
  letter-spacing: .04em; text-transform: uppercase;
}
.diag-row {
  display: flex; gap: 12px; justify-content: space-between; padding: 3px 0;
  border-bottom: 1px dashed rgba(36, 48, 64, .7);
}
.diag-row span { color: var(--muted); flex: 0 0 auto; }
.diag-row b { font-weight: 500; text-align: right; word-break: break-all; font-family: var(--mono); }
.diag-box footer {
  padding: 10px 14px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 12px;
}

/* 双击放大：整格提到全屏层，主画面改为 contain（屏幕内容不被裁切） */
.zoom-x {
  position: absolute; right: 10px; top: 10px; z-index: 6; width: 34px; height: 34px;
  border-radius: 10px; display: grid; place-items: center; cursor: pointer;
  background: rgba(10, 14, 20, .72); border: 1px solid var(--line); color: var(--text);
}
.zoom-x:hover { background: rgba(10, 14, 20, .95); }
.tile.zoom {
  position: fixed; inset: 0; z-index: 80; border-radius: 0; border: none;
  aspect-ratio: auto; background: #000;
}
.tile.zoom video.main { object-fit: contain; }
.tile.zoom .pip { right: 62px; top: 16px; width: min(26vw, 380px); max-width: none; }
.tile.zoom .tag { left: 16px; bottom: 16px; }
.tile.zoom .hand { left: 16px; top: 16px; }
.tile.zoom.sharing::before { right: 16px; bottom: 16px; }
body.has-zoom { overflow: hidden; }

/* 抽屉 */
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(340px, 100%);
  background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column;
  z-index: 5; box-shadow: var(--shadow);
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 12px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 10px; border-radius: 8px; border: 1px solid transparent; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.tab.on { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }

.chat-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 92%; }
.msg .who { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.msg .bubble { background: var(--panel-2); border: 1px solid var(--line); padding: 8px 11px; border-radius: 10px; word-break: break-word; }
.msg.me { align-self: flex-end; }
.msg.me .bubble { background: rgba(53, 208, 165, .14); border-color: rgba(53, 208, 165, .35); }
.msg.sys { align-self: center; color: var(--muted); font-size: 12px; }
.chat-send { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-send input { flex: 1; }

.people { padding: 10px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.person { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); }
.person .nm { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.person .nm b { font-weight: 550; }
.person .badge { font-size: 11px; color: var(--accent); border: 1px solid rgba(53, 208, 165, .4); padding: 1px 6px; border-radius: 6px; }
.person .mini { display: flex; gap: 6px; color: var(--muted); }
.person .mini svg { width: 15px; height: 15px; }
.person.pending { opacity: .8; }
.person .acts { display: flex; gap: 6px; }
.person .acts button { font-size: 12px; padding: 4px 8px; border-radius: 7px; border: 1px solid var(--line); background: transparent; color: var(--text); cursor: pointer; }
.person .acts button.ok { border-color: rgba(53, 208, 165, .5); color: var(--accent); }

/* 工具栏 */
.bar {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 8px; border-radius: 16px;
  background: rgba(19, 26, 34, .92); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(8px); max-width: calc(100% - 20px); overflow-x: auto;
}
.ctl {
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 62px;
  padding: 7px 8px; border-radius: 11px; border: 1px solid transparent; background: transparent;
  color: var(--text); font: inherit; font-size: 11px; cursor: pointer; white-space: nowrap;
}
.ctl:hover { background: var(--panel-2); border-color: var(--line); }
.ctl.on { background: rgba(53, 208, 165, .16); border-color: rgba(53, 208, 165, .38); color: var(--accent); }
.ctl.danger { color: var(--danger); }
.ctl.danger:hover { background: rgba(255, 107, 107, .12); border-color: rgba(255, 107, 107, .35); }

/* Toast */
.toasts { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; }
.toast {
  padding: 9px 14px; border-radius: 10px; background: rgba(19, 26, 34, .96);
  border: 1px solid var(--line); font-size: 13px; box-shadow: var(--shadow); animation: pop .18s ease-out;
}
.toast.err { border-color: rgba(255, 107, 107, .45); color: #ffd5d5; }
.toast.ok { border-color: rgba(53, 208, 165, .45); color: #c9ffee; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 720px) {
  .bar { gap: 2px; padding: 6px; bottom: max(10px, env(safe-area-inset-bottom)); }
  .ctl { min-width: 54px; font-size: 10px; padding: 6px; }
  .ctl span { display: none; }
  .ctl svg { width: 22px; height: 22px; }
  .grid { padding: 10px 10px 76px; gap: 8px; }
  .meet-top { height: 48px; }
}
