/* 小旺会议 - 样式 */
:root {
  --bg: #0e1116;
  --bg2: #141922;
  --card: #171d27;
  --card2: #1d2531;
  --line: #29313d;
  --txt: #e8edf4;
  --muted: #8d99ab;
  --primary: #3f7cff;
  --primary2: #2a63e0;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body { min-height: 100vh; min-height: 100dvh; }

a { color: var(--primary); text-decoration: none; }
code { background: #222b38; padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* ---------- 通用布局 ---------- */
.page-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: radial-gradient(1200px 600px at 50% -10%, #1b2743 0%, var(--bg) 60%);
}

.card {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.install-card, .join-card { max-width: 480px; }
.login-card { max-width: 380px; }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .3px;
  margin-bottom: 18px;
}
.brand small {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 2px;
}
.logo-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: linear-gradient(135deg, #4f8cff, #7b5cff);
  box-shadow: 0 0 0 4px rgba(63, 124, 255, .15);
}

.join-title { font-size: 22px; margin: 4px 0 6px; text-align: center; }
.h2 { font-size: 16px; margin: 0 0 14px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.center-text { text-align: center; padding: 8px; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.center { justify-content: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 13px; }
.field > span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 6px;
}
input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(63, 124, 255, .16);
}
input::placeholder { color: #5d6878; }

.adv {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, .02);
}
.adv summary { cursor: pointer; font-size: 13px; color: var(--muted); outline: none; }
.adv > .field:first-of-type { margin-top: 12px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card2);
  color: var(--txt);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform .06s, background .15s, border-color .15s;
  text-align: center;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn.primary {
  background: linear-gradient(180deg, var(--primary), var(--primary2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn.danger { background: rgba(239, 68, 68, .14); border-color: rgba(239, 68, 68, .5); color: #ff9b9b; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.tiny { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .6; cursor: default; }

/* ---------- 提示 ---------- */
.alert {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert.ok { background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .35); color: #86efac; }
.alert.bad { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .35); color: #fca5a5; }
.alert.warn { background: rgba(245, 158, 11, .1); border-color: rgba(245, 158, 11, .32); color: #fcd34d; }

/* ---------- 后台 ---------- */
.admin-body { padding-bottom: 40px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(14, 17, 22, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { margin: 0; font-size: 16px; }
.topbar-right { display: flex; gap: 8px; }

.wrap { max-width: 980px; margin: 0 auto; padding: 18px 16px; }
.wrap .card { max-width: none; margin-bottom: 18px; }

.create-form .grid2 { align-items: start; }

.meeting-list { display: flex; flex-direction: column; gap: 12px; }
.meeting-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg2);
  padding: 14px;
}
.meeting-item.is-ended { opacity: .72; }
.mi-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mi-name { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.mi-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mi-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.mi-actions form { margin: 0; }

.tag {
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 20px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.tag-live { background: rgba(34, 197, 94, .14); border-color: rgba(34, 197, 94, .4); color: #86efac; }
.tag-blue { background: rgba(63, 124, 255, .14); border-color: rgba(63, 124, 255, .4); color: #9dbcff; }
.tag-gray { background: rgba(141, 153, 171, .12); border-color: rgba(141, 153, 171, .3); color: var(--muted); }

.mi-links { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 12px; }
.linkrow { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; flex-wrap: wrap; }
.linkrow .lbl { width: 74px; flex: none; font-size: 12.5px; color: var(--muted); }
.copyinput {
  flex: 1 1 220px;
  min-width: 0;
  background: #0f141c;
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: none;
}
.copyinput.pw { flex: 0 1 130px; color: #ffd479; letter-spacing: 1px; }
.miniinput {
  width: 120px;
  background: #0f141c;
  border: 1px solid var(--line);
  color: var(--txt);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
}
.inline-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.hint { margin: 6px 0 0; }
.foot-note { margin: 22px 0 0; opacity: .75; }

/* ---------- 会议界面 ---------- */
.room-body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #0a0d12;
}

.room-top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: rgba(14, 17, 22, .95);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.rt-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rt-name {
  font-size: 14.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, .16);
  animation: pulse 2s infinite;
  flex: none;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
.rt-right { display: flex; align-items: center; gap: 8px; flex: none; }
.rt-count { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.rt-role {
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(63, 124, 255, .16);
  border: 1px solid rgba(63, 124, 255, .4);
  color: #9dbcff;
}

.room-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.warn-strip {
  flex: none;
  background: rgba(245, 158, 11, .14);
  border: 1px solid rgba(245, 158, 11, .35);
  color: #fcd34d;
  font-size: 12.5px;
  padding: 7px 10px;
  border-radius: 9px;
  margin-bottom: 8px;
}

.video-grid {
  display: grid;
  gap: 10px;
  flex: 1 1 auto;
  min-height: 0;
  align-content: stretch;
  grid-template-columns: 1fr;
  grid-auto-rows: minmax(0, 1fr);
  transition: grid-template-columns .2s;
}
/* 1 人：占满 */
.video-grid[data-count="1"] { grid-template-columns: 1fr; grid-template-rows: 1fr; }
/* 2 人：竖屏上下排，横屏/大屏左右排 */
.video-grid[data-count="2"] { grid-template-columns: 1fr; grid-template-rows: repeat(2, minmax(0, 1fr)); }
@media (min-width: 700px), (orientation: landscape) and (min-height: 380px) {
  .video-grid[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: 1fr; }
}
/* 3 人：手机上竖排三等分；平板/横屏走 2+1 */
.video-grid[data-count="3"] { grid-template-columns: 1fr; grid-template-rows: repeat(3, minmax(0, 1fr)); }
@media (min-width: 700px), (orientation: landscape) and (min-height: 380px) {
  .video-grid[data-count="3"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
  .video-grid[data-count="3"] .tile:nth-child(3) { grid-column: 1 / -1; }
}

.tile {
  position: relative;
  background: #12161d;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0a0d12;
  transform: translateZ(0);
}
.self-tile video { transform: scaleX(-1); }
.tile-bar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .72));
  font-size: 12px;
}
.tile-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-badge { color: #fcd34d; font-size: 11.5px; white-space: nowrap; }
.tile-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  background: #12161d;
  text-align: center;
  padding: 12px;
}
.tile.connected .tile-empty { display: none; }

.spinner {
  width: 26px; height: 26px;
  border: 3px solid rgba(255, 255, 255, .12);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.waiting {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  pointer-events: none;
}
.waiting-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  background: rgba(23, 29, 39, .9);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  text-align: center;
  font-size: 13px;
}
.waiting-inner p { margin: 0; }

.ctrl-bar {
  flex: none;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 4px;
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  background: rgba(14, 17, 22, .98);
  border-top: 1px solid var(--line);
  overflow: hidden;
}
.ctrl {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 4px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--txt);
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}
.ctrl:active { background: rgba(255, 255, 255, .06); }
.ctrl .ico { font-size: 19px; line-height: 1.1; }
.ctrl .ctl-txt {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.ctrl.off { background: rgba(239, 68, 68, .14); border-color: rgba(239, 68, 68, .4); }
.ctrl.off .ctl-txt { color: #ff9b9b; }
.ctrl.danger .ico { color: #ff8f8f; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 8, 12, .82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  text-align: center;
  box-shadow: var(--shadow);
}
.overlay-card h2 { margin: 0 0 8px; font-size: 18px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 10px);
  background: rgba(28, 35, 46, .97);
  border: 1px solid var(--line);
  color: var(--txt);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 70;
  max-width: 86vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.tap-fix {
  position: fixed;
  left: 50%;
  bottom: calc(110px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 65;
}

@media (max-width: 520px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .card { padding: 18px; border-radius: 12px; }
  .mi-actions { width: 100%; }
  .linkrow .lbl { width: 100%; }
  .copyinput { flex: 1 1 100%; }
  .ctrl { min-width: 0; }
  .ctrl .ctl-txt { font-size: 10px; }
}

/* ---------- 友好提示页（会议被删/已结束） ---------- */
.msg-card { text-align: center; max-width: 440px; }
.msg-ico { font-size: 42px; line-height: 1; margin: 4px 0 12px; opacity: .9; }
.msg-card .alert { text-align: left; }

/* ========== 多尺寸屏幕适配 ========== */
/* 平板：卡片居中不撑满，按钮更好点 */
@media (min-width: 760px) {
  body { font-size: 15.5px; }
  .page-center { padding: 32px; }
  .card { padding: 26px; }
  .join-card, .install-card { max-width: 520px; }
  .ctrl { min-width: 78px; }
  .ctrl .ico { font-size: 21px; }
  .ctrl .ctl-txt { font-size: 12px; }
  .room-top { padding-top: calc(10px + env(safe-area-inset-top)); padding-bottom: 10px; }
  .rt-name { font-size: 15.5px; }
}

/* 电脑大屏 */
@media (min-width: 1200px) {
  .wrap { max-width: 1100px; }
  .room-stage { padding: 16px; }
  .video-grid { gap: 14px; }
}

/* 窄屏手机（iPhone SE / 安卓小屏 320-375） */
@media (max-width: 375px) {
  body { font-size: 14.5px; }
  .ctrl .ctl-txt { font-size: 9.5px; }
  .ctrl .ico { font-size: 17px; }
  .card { padding: 16px; }
  .brand { font-size: 17px; margin-bottom: 14px; }
  .join-title { font-size: 19px; }
  .btn { padding: 10px 12px; font-size: 13.5px; }
  .ctrl { min-width: 0; padding: 5px 3px; }
  .ctrl .ico { font-size: 18px; }
  .ctrl .ctl-txt { font-size: 10px; }
  .ctrl-bar { gap: 4px; padding-left: 6px; padding-right: 6px; }
  .tile-bar { padding: 6px 8px; font-size: 11px; }
  .copyinput { font-size: 12px; }
  .linkrow .lbl { font-size: 12px; }
}

/* 超窄屏（320 及以下） */
@media (max-width: 330px) {
  .ctrl .ctl-txt { display: none; }
  .ctrl { min-width: 0; }
  .ctrl .ico { font-size: 20px; }
  .grow-none { display: none; }
}

/* 手机横屏 / 矮屏幕：压缩留白，把空间全留给画面 */
@media (max-height: 520px) and (orientation: landscape) {
  .room-top { padding: 6px 12px; }
  .room-stage { padding: 6px; }
  .video-grid { gap: 6px; }
  .ctrl-bar { padding: 4px 8px calc(4px + env(safe-area-inset-bottom)); }
  .ctrl .ctl-txt { font-size: 9.5px; }
  .ctrl { padding: 3px 6px; min-width: 50px; }
  .waiting { bottom: 6px; }
  .waiting-inner { padding: 6px 14px; font-size: 12px; }
  .page-center { padding: 10px 12px; }
  .card { padding: 14px 16px; }
  .brand { margin-bottom: 10px; font-size: 16px; }
  .join-title { font-size: 18px; margin: 2px 0 4px; }
  .field { margin-bottom: 9px; }
}

/* 极矮屏（折叠屏展开/小窗）：进一步压缩 */
@media (max-height: 400px) {
  .ctrl .ctl-txt { display: none; }
  .ctrl { min-width: 42px; padding: 4px; }
  .room-top { padding: 4px 10px; }
  .waiting-inner p.muted { display: none; }
}

/* 刘海 / 灵动岛 / 底部手势条 */
@supports (padding: env(safe-area-inset-bottom)) {
  .ctrl-bar { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .room-top { padding-top: calc(8px + env(safe-area-inset-top)); }
}

/* 深色模式下也保持一致（避免系统强制反色） */
@media (prefers-color-scheme: light) {
  :root { color-scheme: dark; }
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 底部设置面板 ---------- */
.sheet { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-end; justify-content: center; }
.sheet-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.sheet-body {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--card);
  border-top: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  animation: sheetUp .18s ease-out;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .4);
}
@keyframes sheetUp { from { transform: translateY(18px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet-bar { width: 42px; height: 4px; border-radius: 3px; background: #3a4350; margin: 2px auto 12px; }
.sheet-title { font-size: 15px; margin: 0 0 10px; font-weight: 600; }
.sheet-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.sheet-row:last-of-type { border-bottom: 0; }
.sheet-label { font-size: 14px; margin-bottom: 3px; }
.chips { display: flex; gap: 6px; }
.chip {
  background: var(--card2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}
.chip.active { background: rgba(63, 124, 255, .16); border-color: rgba(63, 124, 255, .55); color: #9dbcff; }

@media (min-width: 760px) {
  .sheet { align-items: center; }
  .sheet-body { border-radius: 16px; border: 1px solid var(--line); max-width: 480px; }
}
@media (max-height: 480px) {
  .sheet-body { padding: 8px 14px calc(10px + env(safe-area-inset-bottom)); }
  .sheet-row { padding: 8px 0; }
}

/* ---------- 进会前设备检测 ---------- */
.pretest { margin: 4px 0 14px; }
.prebox {
  margin-top: 10px;
  background: #0f141c;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.prebox video {
  display: block;
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  background: #000;
  transform: scaleX(-1);
}
.prebox .prestate { padding: 8px 10px; font-size: 12.5px; color: var(--muted); }

/* ---------- 自检页 ---------- */
.diag-list { display: flex; flex-direction: column; gap: 8px; }
.diag-row {
  display: grid;
  grid-template-columns: 150px 70px 1fr;
  gap: 8px;
  align-items: baseline;
  padding: 8px 10px;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 13.5px;
}
.diag-name { font-weight: 500; }
.diag-val.ok { color: #86efac; }
.diag-val.bad { color: #fca5a5; }
.diag-detail { word-break: break-all; }
.diag-steps { margin: 0; padding-left: 20px; font-size: 13.5px; color: var(--muted); }
.diag-steps li { margin-bottom: 8px; }
@media (max-width: 620px) {
  .diag-row { grid-template-columns: 1fr auto; }
  .diag-detail { grid-column: 1 / -1; }
}
