:root {
  --accent: #6c5ce7;
  --accent-soft: rgba(108, 92, 231, 0.18);
  --bg: #17181d;
  --bg2: #1f2128;
  --bg3: #282b34;
  --text: #e8eaf0;
  --text-dim: #8b90a0;
  --danger: #e05252;
  --warn: #e0a852;
  --ok: #3ecf8e;
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  overflow: hidden;
}
.mono { font-family: Consolas, monospace; color: var(--accent); }

/* 主题化滚动条 */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.16) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 6px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* 图片右键菜单 */
#imgMenu {
  position: fixed;
  z-index: 130;
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 5px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  min-width: 128px;
}
#imgMenu button {
  background: none;
  color: var(--text);
  text-align: left;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  transition: background .12s;
}
#imgMenu button:hover { background: var(--accent); color: #fff; }
button { font-family: inherit; cursor: pointer; border: none; }
[hidden] { display: none !important; }

/* ---------- 首页 / 加入弹层 ---------- */
#home, #joinOverlay {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero, .card {
  text-align: center;
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 20px;
  padding: 48px 56px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 420px;
}
.logo { font-size: 44px; color: var(--accent); }
.logo svg { width: 46px; height: 46px; display: block; }
.home-col { display: flex; flex-direction: column; gap: 16px; max-width: 420px; width: 100%; }
.home-col .hero { max-width: none; }
#myRoomsBox {
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  padding: 16px 18px;
}
#myRoomsBox h3 { font-size: 12px; color: var(--text-dim); letter-spacing: 1px; margin-bottom: 8px; }
.room-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .12s;
}
.room-row:hover { background: var(--bg3); }
.room-row .r-name { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-row .r-id { font-size: 11px; color: var(--text-dim); font-family: Consolas, monospace; }
.room-row .r-del {
  background: none; color: var(--text-dim); border-radius: 7px;
  width: 24px; height: 24px; font-size: 12px; flex: none;
}
.room-row .r-del:hover { background: var(--danger); color: #fff; }
.hero h1, .card h2 { font-weight: 600; }
.hero p, .hint { color: var(--text-dim); font-size: 13px; line-height: 1.6; }

.primary {
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 10px 24px;
  font-size: 15px;
  transition: filter .15s, transform .1s;
}
.primary:hover { filter: brightness(1.12); }
.primary:active { transform: scale(0.97); }
.primary.big { padding: 13px 40px; font-size: 16px; width: 100%; }

.hero input[type="text"],
.card input[type="text"] {
  width: 100%;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  text-align: center;
  transition: border-color .15s;
}
.hero input[type="text"]:focus,
.card input[type="text"]:focus { border-color: var(--accent); }
#sbSlugInput {
  background: var(--bg3); border: 1px solid var(--accent); border-radius: 10px;
  color: var(--text); padding: 9px 14px; font-size: 13px; outline: none; width: 100%;
}

/* ---------- 房间 ---------- */
#room { height: 100%; display: flex; flex-direction: column; }

header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  font-size: 14px;
  color: var(--text-dim);
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
header .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.room-name { color: var(--text); font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-id { font-size: 11px; opacity: 0.7; }
.mini-ico {
  background: none; color: var(--text-dim);
  width: 26px; height: 26px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.mini-ico:hover { background: var(--bg3); color: var(--text); }
.mini-ico svg { width: 13px; height: 13px; }
#roomNameInput {
  background: var(--bg3); border: 1px solid var(--accent); border-radius: 8px;
  color: var(--text); padding: 4px 10px; font-size: 13px; outline: none; width: 180px;
}
.ghost {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg3);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 14px;
  font-size: 13px;
  transition: background .15s;
}
.ghost:hover { background: var(--accent); }
.ghost svg { width: 15px; height: 15px; }

main { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 20px; }

/* 屏幕分享区 */
#screens {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
}
#screens:empty { display: none; }
.screen-tile {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  aspect-ratio: 16 / 9;           /* 默认比例，JS 会按实际画面实时更新 */
  max-height: calc(100vh - 330px); /* 永不超出可视区 */
  min-height: 140px;
  margin: 0 auto;
}
.screen-tile video { width: 100%; height: 100%; object-fit: contain; display: block; }
.screen-tile .label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
}

/* 成员区 */
#people {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  align-content: center;
  flex: 1;
}
.person {
  position: relative;
  width: 150px;
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 20px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 600;
  border: 3px solid transparent;
  transition: border-color .1s, box-shadow .1s;
}
.person.speaking .avatar { border-color: var(--ok); box-shadow: 0 0 12px rgba(62,207,142,0.5); }
.person .pname {
  font-size: 13px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 5px;
}
.person .muted-ico { color: var(--danger); display: none; }
.person.is-muted .muted-ico { display: inline-flex; }
.muted-ico svg { width: 13px; height: 13px; }

/* 聊天记录浮窗 */
#logWin {
  position: fixed;
  z-index: 70;
  width: 320px;
  height: 420px;
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  box-shadow: 0 14px 44px rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#logWin.collapsed { height: auto !important; }
#logWin.collapsed .lw-body,
#logWin.collapsed .lw-resize { display: none; }
.lw-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 12px;
  background: var(--bg3);
  cursor: move;
  user-select: none;
  flex: none;
  touch-action: none;
}
.lw-title { flex: 1; font-size: 13px; font-weight: 600; }
.lw-btn {
  background: none;
  color: var(--text-dim);
  width: 27px; height: 27px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex: none;
  transition: background .12s, color .12s;
}
.lw-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.lw-btn.active { background: var(--accent); color: #fff; }
/* 气泡模式开关：圆形气泡，开启高亮 */
#lwCaption { border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.18); }
#lwCaption.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 0 10px rgba(108,92,231,0.6); }
.lw-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
}
.lw-resize {
  position: absolute;
  right: 0; bottom: 0;
  width: 18px; height: 18px;
  cursor: nwse-resize;
  touch-action: none;
}
.lw-resize::after {
  content: '';
  position: absolute;
  right: 4px; bottom: 4px;
  width: 8px; height: 8px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  opacity: 0.5;
}

/* 聊天记录 */
#transcriptList {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 2px;
}
#transcriptList:empty::before {
  content: '还没有记录。开启字幕后，说的话会自动记在这里。';
  color: var(--text-dim);
  font-size: 13px;
  margin: auto;
  text-align: center;
}
/* 聊天列表：消息气泡样式（自己靠右主题色，别人靠左灰色） */
.log-row { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; max-width: 100%; }
.log-row.me { align-items: flex-end; }
.log-row .log-meta { font-size: 10px; color: var(--text-dim); display: flex; gap: 6px; padding: 0 4px; }
.log-row .log-name { color: var(--accent); font-weight: 600; }
.log-row.me .log-name { color: var(--text-dim); }
.log-bubble {
  max-width: 82%;
  background: var(--bg3);
  border-radius: 12px;
  border-top-left-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  color: var(--chat-text, var(--text)); /* 聊天窗自定义文字颜色（仅此窗口） */
}
.log-row.me .log-bubble {
  background: var(--chat-bubble, var(--accent)); /* 聊天窗自定义气泡颜色（仅此窗口） */
  color: var(--chat-text, #fff);
  border-radius: 12px;
  border-top-right-radius: 4px;
}
.log-bubble .log-img { max-width: 150px; max-height: 150px; border-radius: 8px; cursor: zoom-in; display: block; }
.log-bubble .log-img:not(:first-child) { margin-top: 5px; }

/* 聊天设置面板（颜色 / 导出 / 清空） */
#chatCfg {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 12px;
}
.cc-row { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text); }
.cc-row span { flex: 1; }
.cc-row input[type="color"] {
  width: 36px; height: 24px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  background: none;
  padding: 0;
  cursor: pointer;
}
.cc-btns { display: flex; gap: 8px; }
.cc-btns button { flex: 1; padding: 7px 10px; font-size: 12px; }

/* 聊天输入区：默认收起，悬停/聚焦浮现 */
.lw-inputwrap { flex: none; }
.lw-inhint {
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lw-inhint span {
  width: 44px; height: 4px;
  border-radius: 2px;
  background: rgba(255,255,255,0.14);
  transition: background .15s;
}
.lw-inputwrap:hover .lw-inhint span { background: var(--accent); }
.lw-input {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex: none;
  max-height: 0;
  opacity: 0;
  transform: translateY(10px);
  overflow: hidden;
  transition: max-height .25s ease, opacity .2s ease, transform .25s ease;
}
.lw-inputwrap:hover .lw-input,
.lw-inputwrap:focus-within .lw-input {
  max-height: 130px;
  opacity: 1;
  transform: none;
  overflow: visible;
}
.lw-ibtn {
  background: var(--bg3);
  color: var(--text);
  border-radius: 9px;
  width: 34px; height: 34px;
  flex: none;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.lw-ibtn:hover { background: #333744; }
.lw-ibtn.send { background: var(--accent); color: #fff; }
.lw-ibtn.send:hover { filter: brightness(1.12); }
.lw-input textarea {
  flex: 1;
  resize: none;
  max-height: 90px;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
}
.lw-input textarea:focus { border-color: var(--accent); }

#chatImgPreview {
  position: relative;
  align-self: flex-start;
}
#chatImgPreview img { max-width: 90px; max-height: 90px; border-radius: 8px; display: block; }
#chatImgPreview .cip-x, #chatImgPreview .cip-star {
  position: absolute; top: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  font-size: 11px; display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,0.2);
}
#chatImgPreview .cip-x { right: -6px; background: var(--danger); color: #fff; }
#chatImgPreview .cip-star { right: 18px; background: var(--bg3); color: var(--warn); }

#stickerTray {
  position: absolute;          /* 浮在聊天内容之上，不挤压列表 */
  left: 10px; right: 10px; bottom: 56px;
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 168px; overflow-y: auto;
  padding: 10px;
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  box-shadow: 0 -8px 26px rgba(0,0,0,0.45);
  z-index: 6;
}
#stickerTray:empty::before { content: '还没有表情。粘贴图片后点 ★ 收藏。'; color: var(--text-dim); font-size: 12px; }
#stickerTray .stk { position: relative; }
#stickerTray .stk img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; cursor: pointer; }
#stickerTray .stk .stk-del {
  position: absolute; top: -5px; right: -5px;
  width: 17px; height: 17px; border-radius: 50%;
  background: var(--danger); color: #fff; font-size: 10px;
  display: none; align-items: center; justify-content: center;
}
#stickerTray .stk:hover .stk-del { display: flex; }

/* 头像上方气泡栈：文字气泡在上、图片/表情气泡在下，各自独立计时 */
#people { overflow: visible; }
.person { overflow: visible; }
.bubble-stack {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  z-index: 20;
  pointer-events: none;
}
.sbubble {
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 7px 11px;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
  max-width: 260px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  transition: opacity .4s;
  word-break: break-all;
}
.sbubble.b-text { box-sizing: border-box; min-width: 148px; } /* 至少和头像卡片同宽 */
.sbubble.b-media { padding: 4px; pointer-events: auto; }
.sbubble.b-media img { max-width: 200px; max-height: 200px; border-radius: 8px; display: block; cursor: zoom-in; }
.sbubble.fading { opacity: 0; }

/* 图片查看器（窗口内看大图） */
#imgViewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  cursor: zoom-out;
  padding: 24px;
}
#imgViewer img { max-width: 96vw; max-height: 92vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }

/* 顶栏/输入按钮里的 SVG 单色图标 */
.lw-btn svg, .lw-ibtn svg { width: 16px; height: 16px; }

/* 连接状态点（右上角） */
.person .pstatus {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: none;
}
.person[data-conn="new"] .pstatus,
.person[data-conn="connecting"] .pstatus {
  display: block;
  background: var(--warn);
  animation: pulse 1s infinite;
}
.person[data-conn="failed"] .pstatus,
.person[data-conn="disconnected"] .pstatus {
  display: block;
  background: var(--danger);
}
@keyframes pulse { 50% { opacity: 0.3; } }

/* 常驻音量条 */
#audioBar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 26px;
  padding: 8px 16px 2px;
  flex-wrap: wrap;
}
.ab-item { display: flex; align-items: center; gap: 8px; }
.ab-ico { cursor: help; color: var(--text-dim); display: inline-flex; }
.ab-ico svg { width: 15px; height: 15px; }
.ab-item input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 120px; height: 4px; border-radius: 2px;
  background: var(--bg3); outline: none;
}
.ab-item input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid #fff2; cursor: pointer;
}
.ab-item .ab-val { font-size: 11px; color: var(--text-dim); width: 38px; font-variant-numeric: tabular-nums; }
.ab-item.ab-off { opacity: 0.35; }
.ab-item.ab-off input { cursor: default; }

/* 底部控制栏 */
footer {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
}
.ctrl {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--bg3);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
}
.ctrl:hover { background: #333744; }
.ctrl:active { transform: scale(0.94); }
.ctrl svg { width: 22px; height: 22px; }
.ctrl.active { background: var(--accent); color: #fff; }
.ctrl.danger { color: var(--danger); }
.ctrl.danger:hover { background: var(--danger); color: #fff; }

#btnMic .off { display: none; }
#btnMic.mic-off { background: var(--danger); color: #fff; }
#btnMic.mic-off .on { display: none; }
#btnMic.mic-off .off { display: block; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: 0 24px 70px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 600;
}
.modal-x {
  background: none;
  color: var(--text-dim);
  font-size: 15px;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  transition: background .15s, color .15s;
}
.modal-x:hover { background: var(--bg3); color: var(--text); }

.modal section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: rgba(255,255,255,0.025);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
}
.modal h3 { font-size: 12px; font-weight: 600; color: var(--text-dim); letter-spacing: 1px; }

.modal select {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
}

.slider-row label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
}
.slider-val { color: var(--text-dim); font-variant-numeric: tabular-nums; }

.slider-wrap { position: relative; padding-bottom: 7px; }
.slider-wrap input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 3px;
  background: var(--bg3);
  outline: none;
}
.slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff2;
  cursor: pointer;
  transition: transform .1s;
}
.slider-wrap input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }

/* 声音电平条（滑条下方绿色反应条） */
.level-fill {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 0%;
  border-radius: 2px;
  background: var(--ok);
  transition: width .06s linear;
  pointer-events: none;
}

.ghost2 {
  background: var(--bg3);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13px;
  transition: background .15s;
  text-align: center;
}
.ghost2:hover { background: var(--accent); }
.ghost2.active { background: var(--accent); }

/* 每人音量行 */
.vrow { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.vrow .vname {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.vrow .vname .slider-val { color: var(--text-dim); }
.vrow-empty { color: var(--text-dim); font-size: 13px; text-align: center; padding: 6px 0; }

/* 网络检测结果 */
.net-result { font-size: 13px; line-height: 1.9; color: var(--text); white-space: pre-line; }
.net-result:empty { display: none; }

/* pills（分享设置） */
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  background: var(--bg3);
  color: var(--text);
  border-radius: 9px;
  padding: 7px 13px;
  font-size: 13px;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.pill:hover { border-color: var(--accent); }
.pill.sel { background: var(--accent); color: #fff; }

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.check-row input { accent-color: var(--accent); width: 15px; height: 15px; }

/* 远端分享：未观看=收起条 / 观看中悬停出双音量控制 */
.screen-tile.not-watching {
  aspect-ratio: auto !important;
  height: 92px;
  min-height: 92px;
  background: var(--bg2);
  border: 1px dashed rgba(255,255,255,0.18);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  transition: border-color .15s;
}
.screen-tile.not-watching:hover { border-color: var(--accent); }
/* 实时缩略图：视频继续播（静音），小窗显示 */
.screen-tile.not-watching video {
  width: 128px;
  height: 72px;
  flex: none;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
}
.screen-tile.not-watching .label { display: none; }
.share-invite {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 13px;
  color: var(--text);
  min-width: 0;
}
.share-invite span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remote-share:not(.not-watching) .share-invite { display: none; }
.enter-btn {
  background: var(--accent);
  color: #fff;
  border-radius: 9px;
  padding: 7px 16px;
  font-size: 12px;
  transition: filter .15s;
}
.enter-btn:hover { filter: brightness(1.12); }
.watch-ctrl {
  position: absolute;
  right: 10px;
  top: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
  opacity: 0;
  transition: opacity .15s;
  z-index: 6;
}
.remote-share:hover .watch-ctrl,
.watch-ctrl:has(.wc-toggle.open) { opacity: 1; }
.not-watching .watch-ctrl { display: none; }
.wc-toggle {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(0,0,0,0.68);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background .12s;
}
.wc-toggle svg { width: 17px; height: 17px; }
.wc-toggle:hover { background: var(--accent); }
.wc-toggle.open { background: var(--accent); border-color: var(--accent); }
.wc-panel {
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: rgba(0,0,0,0.68);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px 12px;
}
.wc-mute {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  flex: none;
  transition: background .12s, color .12s;
}
.wc-mute svg { width: 14px; height: 14px; }
.wc-mute .off { display: none; }
.wc-mute.muted { background: var(--danger); }
.wc-mute.muted .on { display: none; }
.wc-mute.muted .off { display: block; }
.wc-mute:hover { background: var(--accent); }
.wc-mute.muted:hover { background: var(--danger); filter: brightness(1.15); }
.wc-row { display: flex; align-items: center; gap: 7px; font-size: 11px; color: #ddd; }
.wc-row .wc-v { width: 34px; flex: none; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.wc-row input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 96px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.25); outline: none;
}
.wc-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}
.leave-btn {
  background: rgba(255,255,255,0.12);
  color: #ff8484;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  transition: background .12s;
}
.leave-btn:hover { background: var(--danger); color: #fff; }

/* 分享中控制条（悬停本地画面出现，Discord 式） */
.share-ctrl {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 6px;
  opacity: 0;
  transition: opacity .15s;
  z-index: 5;
}
.screen-tile:hover .share-ctrl { opacity: 1; }
.share-ctrl button {
  background: transparent;
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
  transition: background .12s;
}
.share-ctrl button:hover { background: var(--accent); }
.share-ctrl button:disabled { opacity: 0.45; cursor: default; }
.share-ctrl button:disabled:hover { background: transparent; }
.share-ctrl button.stop { color: #ff8484; }
.share-ctrl button.stop:hover { background: var(--danger); color: #fff; }

.share-pop {
  position: absolute;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  background: rgba(20,21,26,0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 6;
  min-width: 230px;
}
.share-pop h3 { font-size: 11px; color: var(--text-dim); letter-spacing: 1px; }
.share-pop .pill { padding: 5px 11px; font-size: 12px; }

/* 一起看：本地播放控制条 */
.media-ctrl {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  opacity: 0;
  transition: opacity .15s;
  z-index: 5;
}
.screen-tile:hover .media-ctrl { opacity: 1; }
.media-ctrl button {
  background: none; color: #fff; border-radius: 8px;
  padding: 4px 8px; font-size: 14px; flex: none;
  transition: background .12s;
}
.media-ctrl button:hover { background: var(--accent); }
.media-ctrl .m-time { font-size: 11px; color: #ddd; font-variant-numeric: tabular-nums; flex: none; }
.media-ctrl input[type="range"] {
  -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 2px; background: rgba(255,255,255,0.25); outline: none;
}
.media-ctrl input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); cursor: pointer;
}
.media-ctrl .m-seek { flex: 1; }
.media-ctrl .m-vol { width: 64px; flex: none; }
.media-audio-poster {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  color: var(--text-dim); font-size: 13px;
}
.media-audio-poster .m-icon { font-size: 46px; }

/* 区域框选 */
.crop-select {
  position: absolute;
  inset: 0;
  z-index: 7;
  cursor: crosshair;
  background: rgba(0,0,0,0.35);
  touch-action: none;
}
.crop-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}
.crop-rect {
  position: absolute;
  border: 2px dashed var(--accent);
  background: rgba(108,92,231,0.15);
  pointer-events: none;
}
.region-outline {
  position: absolute;
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
  pointer-events: none;
  z-index: 4;
}

/* 网络警示徽标 */
.netwarn { color: var(--warn); cursor: help; }

/* 房间侧栏 */
#sidebarMask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 60;
}
#sidebar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 272px;
  background: var(--bg2);
  border-right: 1px solid rgba(255,255,255,0.08);
  box-shadow: 12px 0 40px rgba(0,0,0,0.4);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: sb-in .18s ease-out;
}
@keyframes sb-in { from { transform: translateX(-30px); opacity: 0; } }
.sb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  padding: 0 4px;
}
/* 侧栏顶部账号块（固定，不随房间列表滚动） */
#sbAcct {
  flex: none;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 4px 4px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sba-row { display: flex; align-items: center; gap: 10px; }
.sba-ava {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex: none;
}
.sba-info { flex: 1; min-width: 0; }
.sba-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sba-sub { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.sba-out {
  flex: none; background: var(--bg3); color: var(--text-dim);
  border-radius: 8px; padding: 6px 10px; font-size: 12px;
  transition: background .12s, color .12s;
}
.sba-out:hover { background: var(--danger); color: #fff; }
.sba-login {
  background: var(--accent); color: #fff;
  border-radius: 10px; padding: 9px 12px; font-size: 13px;
  transition: filter .15s;
}
.sba-login:hover { filter: brightness(1.12); }

#sbList { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.sb-room {
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  transition: background .12s;
}
.sb-room:hover { background: var(--bg3); }
.sb-room.cur { background: var(--accent-soft); }
.sb-room .sr-top { display: flex; align-items: center; gap: 8px; }
.sb-room .sr-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-room.cur .sr-name { color: var(--accent); font-weight: 600; }
.sb-room .sr-id { font-size: 10px; color: var(--text-dim); font-family: Consolas, monospace; }
.sb-room .sr-users {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.5;
}
.sb-room .sr-users .u-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }
.sb-room .sr-users.empty .u-dot { background: var(--text-dim); opacity: 0.4; }

/* 新版本提示条 */
#updateBar {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--accent);
  color: #fff;
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 13px;
  box-shadow: 0 8px 30px rgba(108,92,231,0.45);
  z-index: 90;
}
#updateBar button {
  background: rgba(255,255,255,0.22);
  color: #fff;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  transition: background .15s;
}
#updateBar button:hover { background: rgba(255,255,255,0.35); }

/* toast & tooltip */
#toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  z-index: 99;
}
#tooltip {
  position: fixed;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

/* ---------- 账号登录 ---------- */
/* 密码打码：不用 type=password（它会触发系统安全键盘，锁死第三方输入法），
   用 text + 字符遮罩，视觉一样是圆点，键盘自由 */
.pw-mask { -webkit-text-security: disc; text-security: disc; }
.acct-row { display: flex; align-items: center; justify-content: center; gap: 6px; }
.acct-sep { color: var(--text-dim); opacity: 0.5; font-size: 12px; }
.acct-state { font-size: 12px; color: var(--text-dim); }
.acct-state b { color: var(--accent); font-weight: 600; }
.login-modal { width: 340px; gap: 12px; }
.login-modal input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 11px 14px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
}
.login-modal input:focus { border-color: var(--accent); }
.login-btns { display: flex; gap: 8px; }
.login-btns button { flex: 1; }
#loginCard input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  text-align: center;
  transition: border-color .15s;
}
#loginCard input:focus { border-color: var(--accent); }
.ghost2.wide { width: 100%; }
.hint .linklike { font-size: inherit; padding: 0; }

/* ---------- 手机端聊天悬浮球 ---------- */
#chatFab {
  position: fixed;
  z-index: 71;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(108,92,231,0.5);
  touch-action: none;
  user-select: none;
  cursor: pointer;
}
#chatFab svg { width: 24px; height: 24px; pointer-events: none; }
.fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
#fabMenu {
  position: fixed;
  z-index: 72;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  padding: 8px;
  box-shadow: 0 10px 34px rgba(0,0,0,0.5);
}
#fabMenu button {
  background: var(--bg3);
  color: var(--text);
  border-radius: 10px;
  padding: 11px 20px;
  font-size: 13px;
  transition: background .1s;
}
#fabMenu button.sel,
#fabMenu button:active { background: var(--accent); color: #fff; }
#fabMenu button.on { border: 1px solid var(--accent); }

/* ---------- 多设备同步 ---------- */
.linklike {
  background: none;
  color: var(--text-dim);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 2px 6px;
}
.linklike:hover { color: var(--accent); }
#syncBox { display: flex; flex-direction: column; align-items: center; gap: 10px; }
#syncQr svg { background: #fff; border-radius: 10px; display: block; }
.sync-code { font-size: 26px; letter-spacing: 6px; font-weight: 700; }
.dev-badge {
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 6px;
  padding: 2px 7px;
}
.person.same-acct { border-color: var(--accent-soft); }

/* ---------- 手机版 ---------- */
@media (max-width: 640px) {
  html, body { height: 100dvh; }

  /* 首页 / 加入页 */
  #home, #joinOverlay { padding: 14px; }
  .hero, .card { padding: 30px 22px; width: 100%; }
  .home-col { max-width: 100%; }

  /* iOS 刘海/状态栏安全区：不加的话左右上角按钮被盖住，要拖一下才能点 */
  header { padding: calc(8px + env(safe-area-inset-top)) 10px 8px; gap: 6px; flex-wrap: wrap; }
  #home, #joinOverlay { padding-top: calc(14px + env(safe-area-inset-top)); }

  /* 底部常驻音量条并入设置（设置里有同款滑条，双向同步；屏幕分享手机也用不到） */
  #audioBar { display: none; }
  .room-name { max-width: 130px; }
  .ghost { padding: 7px 10px; font-size: 0; gap: 0; }
  .ghost svg { width: 17px; height: 17px; }

  main { padding: 10px; gap: 12px; }
  #screens { grid-template-columns: 1fr; gap: 10px; }
  .screen-tile { max-height: 42vh; min-height: 100px; }

  .person { width: 116px; padding: 14px 8px 10px; gap: 7px; }
  .avatar { width: 50px; height: 50px; font-size: 21px; }
  .sbubble { max-width: 190px; }
  .sbubble.b-text { min-width: 116px; }
  .sbubble.b-media img { max-width: 150px; max-height: 150px; }

  /* 音量条 / 控制栏：适配窄屏+安全区 */
  #audioBar { gap: 10px; padding: 6px 8px 0; }
  .ab-item input[type="range"] { width: 78px; }
  footer { gap: 9px; padding: 10px 8px calc(10px + env(safe-area-inset-bottom)); }
  .ctrl { width: 46px; height: 46px; border-radius: 14px; }
  .ctrl svg { width: 20px; height: 20px; }

  /* 聊天窗：底部抽屉，全宽，位置尺寸由 CSS 接管（JS 已跳过拖拽/定位） */
  #logWin {
    left: 0 !important; right: 0 !important;
    top: auto !important; bottom: 0 !important;
    width: 100% !important;
    height: min(72dvh, 560px) !important;
    border-radius: 16px 16px 0 0;
    border-left: none; border-right: none; border-bottom: none;
  }
  #logWin.collapsed { height: auto !important; }
  .lw-head { cursor: default; padding: 10px 10px 10px 14px; }
  .lw-btn { width: 32px; height: 32px; }
  .lw-resize { display: none; }
  .lw-ibtn { width: 40px; height: 40px; }
  .lw-input textarea { font-size: 16px; } /* iOS 聚焦不放大页面 */
  #stickerTray .stk img { width: 60px; height: 60px; }
  #stickerTray .stk .stk-del { display: flex; } /* 触屏没有 hover，删除钮常显 */

  /* 弹窗全屏化 + 整体压缩（原尺寸对手机太大） */
  .modal {
    width: 100vw; max-width: 100vw;
    height: 100dvh; max-height: 100dvh;
    border-radius: 0;
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
    gap: 10px;
  }
  .modal-head { font-size: 14px; }
  .modal section { padding: 10px 11px; gap: 8px; }
  .modal h3 { font-size: 11px; letter-spacing: 0.5px; }
  .modal select, .ghost2, .pill, .check-row, .slider-row label, .vrow .vname { font-size: 12px; }
  .ghost2 { padding: 8px 10px; }
  .modal .hint { font-size: 11px; line-height: 1.6; }
  #syncQr svg { max-width: 180px; height: auto; }
  .sync-code { font-size: 20px; letter-spacing: 4px; }
  .login-modal { padding-top: calc(40px + env(safe-area-inset-top)); }
  #sidebar { width: 82vw; padding-top: calc(16px + env(safe-area-inset-top)); }

  #toast { bottom: 130px; max-width: 92vw; width: max-content; text-align: center; }
  #updateBar { width: max-content; max-width: 94vw; }

  /* 触屏没有 hover：观看控制常显（紧凑版） */
  .remote-share .watch-ctrl { opacity: 1; padding: 8px 10px; gap: 5px; }
  .wc-row input[type="range"] { width: 74px; }

  /* 触屏没有 hover：输入框常显，隐藏提示条 */
  .lw-inhint { display: none; }
  .lw-input { max-height: 130px; opacity: 1; transform: none; overflow: visible; }
}
