/* =========================================================================
   数据传输 · 样式表
   设计原则：中性底色 + 单一品牌色（微信绿）+ 细描边 + 轻阴影；
   字号只用 11.5 / 12.5 / 13.5 / 15 / 20 五档；间距走 4px 网格。
   ========================================================================= */

:root {
  --brand: #07C160;
  --brand-600: #06AD56;
  --brand-700: #048C47;
  --brand-soft: #EAF8F0;
  --brand-line: #CDEBD9;

  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --surface-2: #F7F8FA;
  --surface-3: #EFF1F4;

  --line: #E8EAEE;
  --line-2: #DDE1E6;

  --t1: #171A1F;
  --t2: #5B6270;
  --t3: #98A0AC;
  --t4: #C4C9D2;

  --danger: #E5484D;
  --danger-soft: #FDF1F1;
  --danger-line: #F6CFCF;
  --warn: #A85B00;
  --warn-soft: #FFF9EE;
  --warn-line: #FBE4BF;
  --info: #1F6FEB;
  --info-soft: #EFF5FF;
  --info-line: #D6E4FB;

  --r-xl: 20px;
  --r-lg: 14px;
  --r-md: 11px;
  --r-sm: 8px;

  --sh1: 0 1px 2px rgba(16, 24, 40, .04);
  --sh2: 0 2px 8px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --sh3: 0 18px 48px -12px rgba(16, 24, 40, .18), 0 4px 12px rgba(16, 24, 40, .06);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--t1);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
/* 关键：整页纵向弹性，聊天区才能吃满剩余高度、输入框才会贴底 */
#hostView { display: flex; flex-direction: column; height: 100%; }

/* ===== 顶栏 ===== */
.topbar {
  flex-shrink: 0;
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 20px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-icon {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(140deg, #0ACB69 0%, var(--brand) 45%, var(--brand-700) 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px -2px rgba(7, 193, 96, .55);
}
.brand-icon svg { width: 16px; height: 16px; display: block; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.topbar-title { font-size: 14.5px; font-weight: 600; letter-spacing: .1px; line-height: 1.25; }
.topbar-sub { font-size: 11.5px; color: var(--t3); margin-top: 1px; letter-spacing: .1px; }
.topbar-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 10px; border: none; background: transparent;
  font-size: 15px; cursor: pointer; color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  transition: background .16s ease, color .16s ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--t1); }
.icon-btn:active { background: var(--line-2); }

/* ===== 侧栏里的通用卡片 ===== */
#roomCard, #p2pBanner, #guestGate, #waitBar {
  flex-shrink: 0;
  margin: 10px 20px 0;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh1);
  text-align: left;
}

/* ===== 房间卡片 ===== */
.room-card-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--t3);
}
.room-card-title::before {
  content: ''; width: 6px; height: 6px; border-radius: 2px;
  background: var(--brand); flex-shrink: 0;
}
#roomCode {
  display: block; margin-top: 8px; padding: 9px 10px;
  font-family: var(--mono); font-size: 17px; font-weight: 600;
  letter-spacing: 2px; color: var(--t1); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
  cursor: pointer; word-break: break-all; text-align: center;
  transition: background .15s ease, border-color .15s ease;
}
#roomCode:hover { background: var(--brand-soft); border-color: var(--brand-line); }
#roomCode:active { transform: scale(.995); }
.room-actions { display: flex; gap: 8px; margin-top: 8px; }
.room-actions .pill { flex: 1; min-width: 0; padding: 6px 0; text-align: center; }
/* 加入者只剩一颗「复制房间码」：不拉成整行宽条，按胶囊正常宽度居中 */
body:not(.is-room-owner) .room-actions { justify-content: center; }
body:not(.is-room-owner) .room-actions .pill { flex: 0 0 auto; padding: 6px 16px; }
/* 房间卡标题行右端的小问号：点开是「房间什么时候销毁」的说明 */
.room-q {
  margin-left: auto; flex-shrink: 0;
  width: 16px; height: 16px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-2); border-radius: 50%;
  background: var(--surface); color: var(--t3);
  font-family: inherit; font-size: 10.5px; font-weight: 600; line-height: 1;
  cursor: pointer; text-transform: none; letter-spacing: 0;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.room-q:hover { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-700); }
.room-q:active { transform: scale(.94); }

/* ===== 通道卡片：局域网 / 外网统一外观，只靠左侧圆点区分 ===== */
.p2p-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.p2p-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--t2);
}
.p2p-label::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); flex-shrink: 0;
}
/* 房间里的外网开关：一个 30×17 的小拨杆，靠文字说清它管什么 */
.p2p-sw {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: auto; padding: 0; border: 0; background: none;
  font-family: inherit; cursor: pointer;
}
.p2p-sw[disabled] { cursor: default; opacity: .55; }
.p2p-sw-t { font-size: 11px; color: var(--t3); transition: color .16s ease; }
.p2p-sw-track {
  width: 30px; height: 17px; border-radius: 999px; padding: 1px;
  background: #E3E7ED; border: 1px solid #D3D9E0;
  display: inline-flex; align-items: center;
  transition: background .16s ease, border-color .16s ease;
}
.p2p-sw-knob {
  width: 13px; height: 13px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18); display: block;
  transition: transform .18s cubic-bezier(.3, .9, .3, 1);
}
.p2p-sw.on .p2p-sw-track { background: var(--brand); border-color: var(--brand); }
.p2p-sw.on .p2p-sw-knob { transform: translateX(13px); }
.p2p-sw.on .p2p-sw-t { color: var(--t2); }
/* 关掉外网：卡片不撤，只把底色压淡、描边改虚线，读起来是「这块现在没在用」 */
#p2pBanner.off { background: var(--surface-2); border-style: dashed; box-shadow: none; }
#p2pBanner.off .p2p-label::before { background: var(--t4); }
.p2p-off { margin-top: 8px; font-size: 11.5px; line-height: 1.6; color: var(--t3); }
.side-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.pill {
  border: 1px solid var(--line-2); background: var(--surface); color: var(--t2);
  font-size: 12px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  text-decoration: none; font-family: inherit;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
  line-height: 1.5;
}
.pill:hover { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-700); }
.pill:active { transform: scale(.97); }
.pill.ghost { background: transparent; border-color: transparent; color: var(--t2); }
.pill.ghost:hover { background: var(--surface-2); border-color: var(--line); color: var(--t1); }
.pill.danger { color: var(--danger); border-color: var(--danger-line); background: var(--surface); }
.pill.danger:hover { background: var(--danger-soft); color: #C4292E; border-color: #EFB6B6; }
.pill:disabled { opacity: .45; cursor: not-allowed; }
#inviteHint { font-size: 11.5px; color: var(--t3); margin-top: 8px; line-height: 1.6; }

/* 每条通道各自的设备数与清单 */
.chan-state {
  margin-top: 10px; padding-top: 9px;
  border-top: 1px solid var(--line);
}
.chan-count {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 500; color: var(--t2);
}
.chan-count::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--t4); flex-shrink: 0;
}
.chan-list { display: none; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.chan-list.show { display: flex; }

/* 设备清单 / 等待条 / 房间号只给房主看 */
body:not(.is-room-owner) .chan-state,
body:not(.is-room-owner) .side-notice,
body:not(.is-room-owner) #waitBar,
body:not(.is-room-owner) #dissolveBtn { display: none !important; }

.side-notice {
  margin-top: 8px; padding: 7px 9px;
  font-size: 11.5px; line-height: 1.65; color: var(--warn);
  background: var(--warn-soft); border: 1px solid var(--warn-line);
  border-radius: var(--r-sm);
}

.member-row {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px;
  max-width: 100%; min-width: 0;
  font-size: 11px; color: var(--t2);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 9px;
}
.member-tag { padding: 1px 6px; border-radius: 4px; font-size: 10px; flex-shrink: 0; }
.member-tag.wan { background: var(--brand-soft); color: var(--brand-700); }
.member-tag.lan { background: var(--info-soft); color: var(--info); }
.member-tag.relay { background: var(--warn-soft); color: var(--warn); }
.member-name { font-weight: 600; color: var(--t1); flex-shrink: 0; }
/* IPv6 一长串没有空格、不可软换行，不放开 word-break 会把卡片撑破 */
.member-ip {
  font-family: var(--mono); color: var(--t3); min-width: 0;
  overflow-wrap: anywhere; word-break: break-all; text-align: left;
}

/* 二维码 */
#qrBox { padding: 10px 0 2px; }
#qrImg {
  display: inline-block; background: #fff; padding: 5px; border-radius: var(--r-sm);
  line-height: 0; border: 1px solid var(--line);
}
#qrImg canvas { width: 80px; height: 80px; }

/* ===== 地址框 ===== */
#p2pUrl {
  display: block; margin-top: 9px; padding: 8px 10px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); word-break: break-all; cursor: pointer;
  color: var(--t2); transition: background .15s ease, border-color .15s ease;
}
#p2pUrl:hover { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-700); }

/* ===== 等待对方加入 ===== */
#waitBar {
  display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border-color: var(--line);
}
#waitBar .w-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #E8A33D;
  flex-shrink: 0; margin-top: 6px;
  animation: waitPulse 1.6s ease-in-out infinite;
}
@keyframes waitPulse {
  0%, 100% { opacity: .35; transform: scale(.85); }
  50% { opacity: 1; transform: scale(1.1); }
}
/* 这张卡是引导而不是标签，所以标题比通道卡的标签更重 —— 它要回答
   「房间建好了，接下来做什么」，是四张卡里唯一需要被读到的一句 */
#waitBar .w-text { font-size: 12.5px; font-weight: 600; color: var(--t1); }
#waitBar .w-sub { font-size: 11.5px; color: var(--t3); line-height: 1.6; flex: 1 1 100%; padding-left: 15px; }

/* 没人可发时把输入区压暗，避免点了没反应 */
body.no-peer .input-bar { opacity: .55; }
body.no-peer .send-btn,
body.no-peer .folder-btn { cursor: not-allowed; }
body.no-peer #textInput { cursor: not-allowed; }

/* ===== 访客：连接状态卡 ===== */
.guest-room {
  margin-top: 8px; font-size: 12px; color: var(--t3);
  display: flex; align-items: center; gap: 6px;
}
#linkRoom {
  font-family: var(--mono); font-size: 13.5px; font-weight: 600;
  color: var(--t1); letter-spacing: 1.6px;
}
.self-ip { margin-top: 6px; font-size: 11.5px; color: var(--t3); line-height: 1.6; }
.self-ip b { font-family: var(--mono); font-weight: 500; color: var(--t2); overflow-wrap: anywhere; }
.guest-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
#guestStatus { display: none; font-size: 11.5px; color: var(--t2); margin-top: 8px; line-height: 1.6; }
#guestProg { display: none; height: 4px; background: var(--surface-3); border-radius: 2px; margin-top: 10px; overflow: hidden; }
#guestBar { height: 100%; width: 0; background: var(--brand); transition: width .2s ease; }
#guestProgText { font-size: 11.5px; color: var(--t3); margin-top: 6px; }
#guestTip, #wxTip {
  display: none; margin-top: 9px; padding: 9px 11px;
  border-radius: var(--r-sm); font-size: 11.5px; line-height: 1.7;
}
#guestTip { background: var(--warn-soft); border: 1px solid var(--warn-line); color: var(--warn); }
#wxTip { background: var(--info-soft); border: 1px solid var(--info-line); color: #1A4FB4; }

/* ===== 聊天区 ===== */
.chat-scroll {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 22px 20px 12px; overscroll-behavior: contain;
}
.chat-inner { max-width: 820px; margin: 0 auto; }
.chat-scroll::-webkit-scrollbar { width: 8px; }
.chat-scroll::-webkit-scrollbar-thumb { background: #D9DDE3; border-radius: 4px; border: 2px solid transparent; background-clip: content-box; }
.chat-scroll::-webkit-scrollbar-thumb:hover { background: #C2C8D1; background-clip: content-box; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 42vh; padding: 20px; text-align: center;
  color: var(--t3); font-size: 13px; line-height: 1.8;
}
.empty .e-icon {
  display: flex; align-items: center; justify-content: center;
  width: 60px; height: 60px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--line);
  font-size: 26px; margin-bottom: 16px; box-shadow: var(--sh1);
}
.empty .e-sub { display: block; font-size: 12px; color: var(--t4); margin-top: 3px; }

/* 键盘可达性 */
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
a:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
#textInput::placeholder { color: var(--t4); }

.msg-row { display: flex; margin-bottom: 18px; align-items: flex-start; gap: 10px; }
.msg-row.self { flex-direction: row-reverse; }
.msg-row.self .msg-side { display: flex; flex-direction: column; align-items: flex-end; }
.msg-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: #fff;
  background: #B9C2C9; user-select: none;
  margin-top: 2px;
}
.msg-avatar.anon { background: #CBD5DE; color: #5F7486; }
.msg-avatar.anon svg { display: block; }
.msg-avatar.anon.av-num {
  background: linear-gradient(140deg, #0ACB69, var(--brand-600));
  color: #fff; font-size: 14px; font-weight: 600; letter-spacing: .3px;
}
.msg-side { flex: 1; min-width: 0; }

.bubble {
  background: var(--surface);
  padding: 10px 14px;
  font-size: 14.5px; line-height: 1.6;
  word-break: break-word; white-space: pre-wrap;
  border-radius: var(--r-md) var(--r-md) var(--r-md) 4px;
  position: relative; display: inline-block; max-width: min(72ch, 100%);
  border: 1px solid var(--line);
  box-shadow: var(--sh1);
}
.bubble::before { display: none; }
.bubble.me {
  background: var(--brand); color: #fff; border-color: transparent;
  border-radius: var(--r-md) var(--r-md) 4px var(--r-md);
  box-shadow: 0 2px 8px -3px rgba(7, 193, 96, .5);
}
.msg-time { font-size: 11px; color: var(--t3); margin-top: 6px; letter-spacing: .1px; }

/* ===== 文件卡片（图片同样是文件，点卡片即下载）===== */
.file-card {
  display: flex; align-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 14px;
  width: 340px; max-width: 100%; text-decoration: none; color: inherit;
  position: relative; box-shadow: var(--sh1);
  /* 卡片本体不可点：只有右侧按钮能下载。所以不给 hover 抬起 / 手型光标，
     否则等于骗人去点——点了没反应比不能点更气人。 */
  cursor: default;
}
.file-card::before { display: none; }
/* 类型徽标：38×38 固定尺寸，只放类型字（MP4），水平垂直都居中。
   发送方式不再塞这里——38px 的方块塞两行字谁也看不清，它和大小、失效原因
   一样做成下方的小标签。颜色只承担一件事：绿=能用，灰=失效。 */
.file-icon {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand-700);
  border: 1px solid var(--brand-line);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-right: 11px;
}
.file-icon .ext {
  font-size: 11px; font-weight: 700;
  letter-spacing: .3px; line-height: 1;
}
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 12.5px; font-weight: 500; word-break: break-all; line-height: 1.38; }
/* 大小 / 方式 / 失效原因：三枚同规格标签（10.5px、17px 高、圆角 4px、左右 6px），
   横排、间距 5px，放不下就自然换行，绝不挤文件名。
   opacity 必须写死 1：旧的「6.5px 小字」时代这里有 .55 / 失效 .42 的透明度，
   留着会让其中一枚永远比另外两枚淡——这是实际踩到的坑。 */
.file-size {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 5px; margin-top: 5px;
}
.sztag,
.file-way,
.file-gone-tag {
  display: inline-block; font-size: 10.5px; font-weight: 500;
  line-height: 17px; padding: 0 6px; border-radius: 4px;
  margin-left: 0; vertical-align: 0; opacity: 1; letter-spacing: 0;
}
/* 状态一：正常 —— 大小与方式同一套品牌绿 */
.sztag,
.file-way {
  background: var(--brand-soft); color: var(--brand-700);
  border: 1px solid var(--brand-line);
}

/* 下载按钮：自己画的 SVG，所有设备长得一样（⬇ emoji 在 iOS / 安卓 / Windows 上
   分别是三种形状，还会被系统上色）。放在卡片右侧，点它和点卡片是同一个动作。 */
.file-dl {
  flex: 0 0 auto; width: 30px; height: 30px; margin-left: 10px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--brand-line); border-radius: 9px;
  background: var(--brand-soft); color: var(--brand-700);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.file-dl svg { display: block; }
.file-dl:hover { background: var(--brand); border-color: var(--brand); color: #fff; }
.file-dl:active { transform: scale(.93); }

/* 取消下载：只在真的在传（或排队等着）时出现，紧挨在下载按钮左边。
   这时候右边那个已经是「暂停」了，两个挨在一起，点错了也只是换个状态。 */
.file-stop {
  flex: 0 0 auto; width: 26px; height: 26px; margin-left: 8px; padding: 0;
  display: none; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface-2); color: var(--t3);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}
.file-stop svg { display: block; }
.file-card[data-dl="queued"] .file-stop,
.file-card[data-dl="running"] .file-stop,
.file-card[data-dl="paused"] .file-stop { display: flex; }
.file-stop:hover { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.file-stop:active { transform: scale(.93); }

/* 失效的文件：记录留着（知道谁在什么时候发过什么），但字节没了。
   整卡压灰、徽标连「直连 / 中转」小字一起褪色，右侧一个按钮都不放——
   按下去只会报「下载不到」，留着等于让人反复点。文件名、大小、类型、
   时间照常显示：灰只说明「这份下不了」，不是把这条记录擦掉。 */
.file-card.gone { background: var(--surface-2); border-color: var(--line); box-shadow: none; }
.file-card.gone .file-icon {
  background: var(--surface-3); border-color: var(--line); color: var(--t3);
}
/* 状态二：失效 —— 大小、方式、原因三枚一律换成同一套灰。
   必须在这里显式写 opacity:1：基础规格里那一条才压得住任何遗留的透明度，
   三枚但凡有一枚带 .5 透明，看起来就是「不一样的颜色」。 */
.file-card.gone .sztag,
.file-card.gone .file-way,
.file-card.gone .file-gone-tag {
  background: var(--surface-3); color: var(--t2);
  border: 1px solid var(--line); opacity: 1;
}
.file-card.gone .file-name { color: var(--t2); }
.file-card.gone .file-dl { display: none; }
/* 自己发的直连卡：宿主色保持纯白，其余与普通卡一致（徽标也统一绿） */
.file-card.mine-p2p { background: var(--surface); }


/* 文件卡片下方的下载进度条（访客端）。
   宽度和上面那张文件卡一致（340px）：窄一截会显得进度条是「另一个东西」，
   宽一截又会顶出气泡边界。窄屏统一 max-width 收住。 */
.pull-wrap { display: none; width: 340px; max-width: 100%; margin-top: 8px; }
.pull-bar { height: 4px; border-radius: 2px; overflow: hidden; background: var(--surface-3); }
/* 不要 transition：这条每 90ms 就刷新一次，补间动画只会让条在「暂停」之后
   还往前滑一段，看着像文件偷跑了一点。宽度一变就到位，暂停即停。 */
.pull-bar i { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--brand); transition: none; }
/* 暂停时进度条褪成灰：数字不再动，颜色也得跟着停，否则看不出是「停住了」还是「网慢」 */
.pull-wrap.paused .pull-bar i { background: var(--t4); }
/* 文字一行：进度文字占满左侧，不换行。按钮不在这里，挂在卡片右侧。 */
.pull-line { display: flex; align-items: center; margin-top: 6px; }
.pull-text { flex: 1; min-width: 0; font-size: 11px; color: var(--t3); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== 屏幕共享卡：一条卡片两种状态 ===== */
.screen-card {
  background: var(--surface); border-radius: var(--r-lg); padding: 0;
  width: min(400px, 100%); box-shadow: var(--sh2);
  border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.screen-card::before { display: none; }
.screen-card.ended { background: var(--surface-2); }
.screen-card.live { width: min(400px, 100%); }
.sc-video-wrap {
  position: relative; border-radius: calc(var(--r-lg) - 1px); overflow: hidden;
  background: #0D0F11; cursor: pointer;
}
.sc-video {
  display: block; width: 100%; aspect-ratio: 16 / 9; max-height: 44vh;
  background: #0D0F11; object-fit: cover;
}
.sc-badge {
  position: absolute; left: 10px; top: 10px; z-index: 2;
  display: flex; align-items: center; gap: 5px;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px);
  border-radius: 999px; padding: 3px 9px;
  font-size: 11px; color: #fff; pointer-events: none;
}
.sc-badge i { width: 6px; height: 6px; border-radius: 50%; background: #FF4D4F; animation: blink 1.4s infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.sc-dur {
  position: absolute; right: 10px; top: 10px; z-index: 2;
  background: rgba(0, 0, 0, .55); backdrop-filter: blur(6px);
  border-radius: 999px; padding: 3px 9px;
  font-size: 11px; color: #fff; font-variant-numeric: tabular-nums;
  pointer-events: none;
}
.sc-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, .62) 100%);
  color: #fff;
}
.sc-av {
  width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff;
  font-size: 11px; font-style: normal; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.sc-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.sc-fs {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  background: rgba(255, 255, 255, .16); pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.sc-stop {
  flex: none; height: 24px; padding: 0 11px; border: none; border-radius: 999px;
  background: #FF4D4F; color: #fff; font-size: 11.5px; cursor: pointer; font-family: inherit;
}
.sc-stop:hover { background: #E5484D; }
.sc-end-body {
  height: 156px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
}
.sc-end-title { font-size: 13.5px; font-weight: 600; color: var(--t2); }
.sc-end-tip {
  font-size: 11px; color: var(--t3); background: var(--surface-3);
  border-radius: 999px; padding: 3px 10px;
}
.sc-end-bar {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 8px 13px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--t3);
}
.sc-end-bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-lanhint {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: #CFD8DE; background: rgba(13, 15, 17, .82);
  pointer-events: none;
}
.sc-play {
  position: absolute; inset: 0; z-index: 4; border: none;
  background: rgba(0, 0, 0, .58); color: #fff; font-size: 13px;
  font-family: inherit; cursor: pointer; line-height: 1.6;
}

/* ===== 共享画面全屏观看层 ===== */
.scf {
  display: none; position: fixed; inset: 0; z-index: 400;
  background: #000; align-items: center; justify-content: center;
}
.scf.show { display: flex; }
.scf video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.scf-top {
  position: absolute; left: 0; right: 0; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, .68), rgba(0, 0, 0, 0));
  color: #fff;
}
.scf-dot { width: 7px; height: 7px; border-radius: 50%; background: #FF4D4F; animation: blink 1.4s infinite; flex: none; }
.scf-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.scf-dur { font-size: 13px; font-variant-numeric: tabular-nums; }
.scf-stop {
  flex: none; height: 28px; padding: 0 13px; border: none; border-radius: 999px;
  background: #FF4D4F; color: #fff; font-size: 12px; cursor: pointer; font-family: inherit;
}
.scf-close {
  flex: none; width: 30px; height: 30px; border: none; border-radius: 50%;
  background: rgba(255, 255, 255, .16); padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.scf-tip {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 2;
  background: rgba(0, 0, 0, .5); color: rgba(255, 255, 255, .72); font-size: 11px;
  border-radius: 999px; padding: 5px 13px; pointer-events: none; white-space: nowrap;
}
.scf-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3;
  border: none; background: rgba(0, 0, 0, .62); color: #fff; font-size: 13px;
  font-family: inherit; cursor: pointer; border-radius: 999px; padding: 10px 18px;
}
body.fs-locked { overflow: hidden; }

/* ===== 待发送文件 / 发送队列 =====
   和消息区的文件卡用同一套语言：扩展名徽标 + 文件名 + 次要信息，
   一眼能看出「这是什么文件」；右侧只留一个圆形小按钮，安静不抢戏。 */
/* ===== 发送方式：中转 / 直连 =====
   只在「有待发文件」时出现。平时没人关心文件怎么走，有文件在手边才需要选。
   中转=绿（和品牌色、房主存储是一套），直连=蓝（表示这条路不经过房主）。 */
.send-mode {
  display: none; flex-shrink: 0;
  background: var(--surface-2); border-top: 1px solid var(--line);
  padding: 9px 20px;
}
.send-mode.show { display: block; }
/* 两个面板背景相同，中间的描边只留最上面那道，别画出双线 */
.send-mode.show + .pending-area { border-top: none; }
.sm-row {
  display: flex; align-items: center; gap: 10px;
  max-width: 820px; margin: 0 auto;
}
.sm-seg {
  display: flex; gap: 2px; flex: 0 0 auto;
  padding: 2px; border-radius: 9px; background: var(--surface-3);
}
.sm-btn {
  border: none; background: none; font-family: inherit;
  font-size: 12px; line-height: 20px; color: var(--t2);
  padding: 4px 11px; border-radius: 7px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.sm-btn:hover { color: var(--t1); }
.sm-btn.on { background: var(--surface); color: var(--brand-700); font-weight: 500; box-shadow: var(--sh1); }
.sm-btn[data-mode="p2p"].on { color: var(--info); }
.sm-tip {
  flex: 1; min-width: 0;
  font-size: 11.5px; color: var(--t3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.pending-area {
  display: none; flex-shrink: 0;
  background: var(--surface-2); border-top: 1px solid var(--line);
  padding: 10px 20px 12px;
  /* 选十几个文件时别把聊天区吃光：超出就内部滚 */
  max-height: 34vh; overflow-y: auto; overscroll-behavior: contain;
}
.pending-area.show { display: block; }
.pq-head {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 820px; margin: 0 auto 8px;
  font-size: 12px; color: var(--t3);
}
.pq-head b { color: var(--t1); font-weight: 600; }
.pq-head button {
  border: none; background: none; color: var(--t3); font-size: 12px;
  font-family: inherit; cursor: pointer; padding: 3px 8px; border-radius: 6px;
  transition: background .15s ease, color .15s ease;
}
.pq-head button:hover { background: var(--surface-3); color: var(--t1); }

.pq-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 9px 10px 10px 11px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--sh1);
  margin: 0 auto 7px; max-width: 820px;
  overflow: hidden;
  transition: border-color .15s ease, background .15s ease;
}
.pq-item:last-child { margin-bottom: 0; }
.pq-item.sending { background: var(--brand-soft); border-color: var(--brand-line); }
/* 暂停：颜色退成中性，进度条留在原地不动 —— 让人一眼看出“是我按停的” */
.pq-item.paused { background: var(--surface-2); border-color: var(--line-2); }
.pq-item.paused .pq-bar { display: block; }
.pq-item.paused .pq-fill { background: var(--t4); }
.pq-item.paused .pq-state { color: var(--t2); }
.pq-item.done { background: var(--surface-2); box-shadow: none; }
.pq-item.done .pq-name { color: var(--t2); }
.pq-item.err { background: var(--danger-soft); border-color: var(--danger-line); }

/* 扩展名徽标：和消息里的 .file-icon 同一族，只是小一号 */
.pq-ico {
  flex-shrink: 0; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: .02em; line-height: 1;
  color: var(--brand-700); background: var(--brand-soft);
  border: 1px solid var(--brand-line); border-radius: var(--r-sm);
  overflow: hidden;
}
.pq-item.err .pq-ico { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-line); }

.pq-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pq-name {
  font-size: 13px; font-weight: 500; color: var(--t1); line-height: 1.45;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pq-state { font-size: 11.5px; color: var(--t3); line-height: 1.4; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.pq-state.ok { color: var(--brand-700); }
.pq-state.err { color: var(--danger); }

.pq-btn {
  flex-shrink: 0; width: 28px; height: 28px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent; border-radius: 50%;
  color: var(--t3); cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.pq-btn:hover { background: var(--surface-3); color: var(--t1); border-color: var(--line-2); }
.pq-item.err .pq-btn:first-of-type:hover { color: var(--brand-700); }

.pq-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--surface-3);
}
.pq-item:not(.sending):not(.paused):not(.err) .pq-bar { display: none; }
.pq-fill { height: 100%; width: 0; background: var(--brand); transition: width .18s linear; }
.pq-item.err .pq-fill { background: #E57373; }

/* ===== 输入区 ===== */
.input-bar {
  flex-shrink: 0; background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
}
.input-inner { max-width: 820px; margin: 0 auto; }
.input-row { display: flex; gap: 8px; align-items: flex-end; }
#textInput {
  flex: 1; border: 1px solid var(--line-2); background: var(--surface-2);
  border-radius: var(--r-md); padding: 10px 13px;
  font-size: 14.5px; font-family: inherit; resize: none; outline: none;
  line-height: 1.5; max-height: 132px; overflow-y: auto;
  scrollbar-width: none; -ms-overflow-style: none;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
#textInput::-webkit-scrollbar { width: 0; height: 0; display: none; }
#textInput:focus {
  border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, .1);
}
.send-btn {
  padding: 0 20px; height: 40px; border-radius: var(--r-md);
  background: var(--brand); color: #fff; border: none;
  font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer;
  transition: background .16s ease, transform .1s ease;
}
.send-btn:hover { background: var(--brand-600); }
.send-btn:active { transform: scale(.98); }
.send-btn:disabled { background: #BCE3CC; color: #F3FBF6; cursor: not-allowed; }
.send-btn:disabled:hover { background: #BCE3CC; }
.send-btn:disabled:active { transform: none; }
.folder-btn {
  width: 40px; height: 40px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 17px; cursor: pointer; color: var(--t2);
  display: flex; align-items: center; justify-content: center;
  transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.folder-btn:hover { background: var(--brand-soft); border-color: var(--brand-line); color: var(--brand-700); }
.folder-btn:disabled { opacity: .5; cursor: not-allowed; }
.folder-btn:disabled:hover { background: var(--surface-2); color: var(--t2); }

/* ===== 弹窗 / 提示 ===== */
.modal-mask {
  display: none; position: fixed; inset: 0; background: rgba(17, 20, 24, .42);
  backdrop-filter: blur(2px);
  z-index: 300; justify-content: center; align-items: center; padding: 20px;
}
.modal-mask.show { display: flex; animation: maskIn .18s ease; }
@keyframes maskIn { from { background: rgba(17, 20, 24, 0); } to { background: rgba(17, 20, 24, .42); } }
.modal {
  background: var(--surface); border-radius: var(--r-xl); padding: 24px;
  width: 100%; max-width: 420px; max-height: 78vh; overflow-y: auto;
  box-shadow: var(--sh3); border: 1px solid rgba(16, 24, 40, .04);
}
.modal-mask.show .modal { animation: modalIn .22s cubic-bezier(.2, .8, .3, 1); }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 14px; letter-spacing: .1px; }
.modal input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line-2);
  border-radius: var(--r-sm); font-size: 14px; font-family: inherit;
  margin-bottom: 12px; outline: none; background: var(--surface-2);
  transition: border-color .18s ease, background .18s ease;
}
.modal input:focus { border-color: var(--brand); background: var(--surface); }
/* flex-wrap：建房冲突弹窗有三个按钮，420px 的弹窗放不下，
   不换行会顶出内边距、最后一个按钮被裁掉一截 */
.modal-btns { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-btns button {
  padding: 9px 18px; border-radius: var(--r-sm); border: none;
  font-size: 13.5px; font-family: inherit; cursor: pointer;
  transition: background .15s ease, filter .15s ease;
}
.modal-btns button:hover { filter: brightness(.97); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); filter: none; }
.btn-primary:disabled { background: #BCE3CC; color: rgba(255, 255, 255, .9); cursor: not-allowed; }
.btn-plain { background: var(--surface-3); color: var(--t1); }
.btn-plain:hover { background: var(--line-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #C4292E; filter: none; }
.btn-danger:disabled { background: var(--danger-line); color: #fff; cursor: not-allowed; }
.modal-tip { font-size: 12.5px; line-height: 1.8; color: var(--t2); margin: -4px 0 4px; }

/* 「二选一」弹窗不要排一排按钮：420px 的弹窗里三个按钮必然折行，
   最后一个被挤到第二行右边，看着像布局坏了。改成纵向选项卡 + 弱化的退出。 */
.modal-lead { margin: 4px 0 0; font-size: 12.5px; line-height: 1.8; color: var(--t2); }
.modal-lead b { color: var(--t1); font-weight: 600; letter-spacing: .3px; }
/* 状态行：比正文再小一档、颜色更淡，读起来像「补充说明」而不是又一段话 */
.modal-state { margin: 6px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--t3); }

.opt-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.opt {
  display: block; width: 100%; text-align: left; padding: 11px 14px;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  background: var(--surface); font-family: inherit; cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.opt:hover { border-color: var(--t4); background: var(--surface-2); }
.opt-t { display: block; font-size: 13.5px; font-weight: 600; color: var(--t1); }
.opt-s { display: block; margin-top: 2px; font-size: 11.5px; line-height: 1.55; color: var(--t3); }
.opt.primary { background: var(--brand); border-color: var(--brand); }
.opt.primary .opt-t { color: #fff; }
.opt.primary .opt-s { color: rgba(255, 255, 255, .84); }
.opt.primary:hover { background: var(--brand-600); border-color: var(--brand-600); }

/* 退出项：不占视觉重量，但必须是完整宽度的一行，手机上也好点 */
.modal-cancel {
  display: block; width: 100%; margin-top: 8px; padding: 9px 0;
  background: none; border: none; color: var(--t3);
  font-size: 12.5px; font-family: inherit; cursor: pointer;
}
.modal-cancel:hover { color: var(--t2); }

/* 接管提示里的「安心一句话」：浅底 + 一道竖线，和普通说明区分开。
   这不是警告，是让人确认记录还在 */
.modal-note {
  margin: 10px 0 0; padding: 9px 12px;
  background: var(--brand-soft); border-left: 3px solid var(--brand);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 12px; line-height: 1.7; color: #2C6B49;
}

.toast {
  position: fixed; top: 24px; left: 50%; transform: translate(-50%, -8px);
  background: rgba(23, 26, 31, .92); color: #fff;
  padding: 10px 18px; border-radius: 999px;
  font-size: 13px; opacity: 0; transition: opacity .2s ease, transform .2s ease;
  z-index: 999; pointer-events: none; max-width: 86vw; text-align: center;
  box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .4);
  backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== 入口页 ===== */
#gateView {
  position: fixed; inset: 0; z-index: 200; display: flex;
  /* 进出房间都要有过渡，所以不能再用 display 切换（display 无法过渡）。
     改成常驻 flex + visibility/opacity：隐藏时不接收任何指针事件。 */
  visibility: hidden; opacity: 0; pointer-events: none;
  transition: opacity .24s ease, visibility 0s linear .24s;
  background:
    radial-gradient(820px 420px at 50% -8%, #DBF6E7 0%, rgba(219, 246, 231, 0) 68%),
    radial-gradient(680px 360px at 92% 104%, #E6EEFC 0%, rgba(230, 238, 252, 0) 62%),
    #F4F6F8;
  /* 刘海 / 圆角屏 / 手势条：四边都让出安全区，卡片不会贴到挖孔下面 */
  padding:
    max(20px, env(safe-area-inset-top, 0px))
    max(20px, env(safe-area-inset-right, 0px))
    max(20px, env(safe-area-inset-bottom, 0px))
    max(20px, env(safe-area-inset-left, 0px));
  overflow-y: auto; overscroll-behavior: contain;
  /* 用 flex-start 而不是 center：卡片比视口高时（横屏手机），
     center 会把顶部推到看不见的地方，滚动也滚不到。居中交给 .gate-card 的 margin:auto */
  align-items: flex-start; justify-content: center;
}
#gateView.show {
  visibility: visible; opacity: 1; pointer-events: auto;
  transition: opacity .24s ease, visibility 0s;
}
/* 进房间：从入口页整块淡出后，房间界面淡入 */
#hostView { animation: hostIn .3s ease both; }
@keyframes hostIn { from { opacity: 0; transform: scale(.995); } to { opacity: 1; transform: none; } }
/* 刷新恢复（邀请链接 / 房主刷新 / 访客回连）：房间信息还没到手之前，
   房间壳先别露出来——顶栏是空的、侧栏是空的、聊天区还写着「还没有消息」，
   这些假空态比什么都不显示更容易让人误会。此时只留 body 底色。
   JS 一旦确定「进房」或「回入口页」就摘掉这个 class，两条路都会解除。 */
body.booting #hostView { visibility: hidden; animation: none; }
@media (prefers-reduced-motion: reduce) {
  #gateView, #gateView.show, #hostView { transition: none; animation: none; }
}
/* 间距刻度统一取 4 的倍数：26 / 16 / 10 / 13 / 10，
   自上而下逐段收窄，视觉重心落在「创建房间」那颗按钮上。
   入场动画改到子元素上做逐级上浮，卡片本身不再整体位移（见文件末尾）。 */
.gate-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: var(--r-xl); padding: 26px 26px 18px;
  border: 1px solid rgba(16, 24, 40, .05);
  box-shadow: 0 24px 64px -20px rgba(16, 24, 40, .22), 0 2px 6px rgba(16, 24, 40, .04);
  /* 空间够时自动居中；空间不够时自动归零，卡片从顶部开始、可滚动 */
  margin: auto;
  position: relative;      /* 子视图的左上角返回图标以它为定位基准 */
}
/* 子视图的返回：左上角一个小图标，不占正文高度。
   只要不在第一屏（gateChoices）就出现；局域网设备只能加入房间，用 .no-back 全藏掉。 */
.gate-back-ico {
  display: none;
  position: absolute; left: 10px; top: 10px; z-index: 3;
  width: 34px; height: 34px; border-radius: 10px;
  align-items: center; justify-content: center;
  border: 0; background: none; color: var(--t2);
  cursor: pointer;
  transition: background .16s ease, color .16s ease, transform .12s ease;
}
#gateView:not([data-view="gateChoices"]) .gate-back-ico { display: flex; }
#gateView.no-back .gate-back-ico { display: none; }
.gate-back-ico:hover { background: var(--surface-2); color: var(--t1); }
.gate-back-ico:active { transform: scale(.93); }
.gate-back-ico:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.gate-logo {
  width: 44px; height: 44px; border-radius: 14px; margin: 0 auto 12px;
  background: linear-gradient(140deg, #0ACB69 0%, var(--brand) 45%, var(--brand-700) 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px -8px rgba(7, 193, 96, .6);
}
.gate-logo svg { width: 22px; height: 22px; }
.gate-title { text-align: center; font-size: 19px; font-weight: 600; letter-spacing: .3px; }
.gate-sub { text-align: center; font-size: 12px; color: var(--t3); margin-top: 5px; line-height: 1.65; }

/* 内容区：三块视图（选择 / 输入房间码 / 下载程序）叠在同一格里 ——
   用 grid 同格叠放，格子高度天然等于最高那块，窗口怎么变都不用重新量。
   隐藏用 visibility 而不是 display：隐藏的那块仍然参与撑高，
   这样切屏、点按钮、冒提示都不会让卡片长高变矮。 */
.gate-body { margin-top: 16px; }
.gate-views { display: grid; }
.gate-view { grid-area: 1 / 1; align-self: center; visibility: hidden; }
.gate-view.on { visibility: visible; }

.gate-list { display: flex; flex-direction: column; gap: 8px; }
.gate-btn {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 12px 14px; border-radius: var(--r-lg);
  border: 1px solid var(--line-2); background: var(--surface);
  cursor: pointer; font-family: inherit;
  transition: border-color .16s ease, background .16s ease, box-shadow .2s ease,
              transform .18s cubic-bezier(.22, .9, .28, 1);
}
/* 悬停抬起 1px + 落影：按钮"可点"这件事靠位移说，比换底色更直觉 */
.gate-btn:hover {
  border-color: var(--brand-line); background: var(--brand-soft);
  transform: translateY(-1px);
  box-shadow: 0 10px 20px -14px rgba(16, 24, 40, .45);
}
.gate-btn:active { transform: translateY(0) scale(.99); box-shadow: none; transition-duration: .07s; }
.gate-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.gate-btn:disabled { opacity: .6; cursor: default; transform: none; box-shadow: none; }
/* 正在创建时只是不能点，不该整块发灰：进度文字要看得清 */
.gate-btn.busy:disabled { opacity: 1; }
.gate-btn.primary {
  background: linear-gradient(140deg, #0ACB69 0%, var(--brand) 50%, #06A852 100%);
  border-color: transparent;
  box-shadow: 0 8px 20px -8px rgba(7, 193, 96, .65);
}
.gate-btn.primary:hover {
  background: linear-gradient(140deg, #12D473 0%, #07C860 50%, #06AC55 100%);
  box-shadow: 0 14px 26px -12px rgba(7, 193, 96, .62);
}
.gate-ico {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  background: var(--brand-soft); color: var(--brand-700); font-size: 16px;
  border: 1px solid var(--brand-line);
  display: flex; align-items: center; justify-content: center;
  transition: transform .2s cubic-bezier(.34, 1.3, .64, 1);
}
.gate-btn:hover .gate-ico { transform: scale(1.07); }
.gate-btn.primary .gate-ico { background: rgba(255, 255, 255, .18); color: #fff; border-color: rgba(255, 255, 255, .22); }
.gate-txt { display: flex; flex-direction: column; min-width: 0; }
.gate-txt b { font-size: 14px; font-weight: 600; letter-spacing: .1px; line-height: 19px; }
/* 行高写死 16px：忙碌时这行要换成进度文字，两行同高按钮才不会变高 */
.gate-txt i { font-style: normal; font-size: 11px; color: var(--t3); margin-top: 1px; line-height: 15px; }
.gate-btn.primary .gate-txt b { color: #fff; }
.gate-btn.primary .gate-txt i { color: rgba(255, 255, 255, .85); }

/* 探活进行中：同一颗按钮换成「取消」。绿底白字的「取消」容易被当成「确认」，
   所以退回次要操作的观感（白底绿字 + 描边）——但保留 hover 的手感，
   让人一眼看出它还能点，而不是又卡住了一个灰按钮 */
.gate-btn.primary.cancel {
  background: var(--surface);
  border: 1px solid var(--brand-line);
  box-shadow: none;
}
.gate-btn.primary.cancel .gate-txt b { color: var(--brand-700); }
.gate-btn.primary.cancel:hover {
  background: var(--brand-soft);
  box-shadow: 0 10px 20px -14px rgba(16, 24, 40, .45);
}

/* 创建房间：等本机程序回应时把 ＋ 换成转圈，进度画在副标题位置 */
.gate-btn.busy { pointer-events: none; cursor: default; }
.gate-btn.busy .gate-ico { position: relative; color: transparent; font-size: 0; }
/* 图标改成 SVG 之后，转圈那层靠 color:transparent 藏不住了，显式收起来 */
.gate-btn.busy .gate-ico > svg { display: none; }
.gate-btn.busy .gate-ico::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 15px; height: 15px; margin: -8.5px 0 0 -8.5px;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
  border-radius: 50%; animation: gateSpin .7s linear infinite;
}
@keyframes gateSpin { to { transform: rotate(360deg); } }
.gate-btn.busy .gate-txt > i { display: none; }
/* 进度只占副标题那一行、进度条压在按钮底边（绝对定位）：
   按钮高度不因为「开始创建」而变，卡片也就不会跟着长高 */
.gate-prog { display: none; margin-top: 1px; }
.gate-btn.busy .gate-prog { display: block; }
.gate-prog-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 15px; }
.gate-prog-line > span {
  display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; min-width: 0;
  font-size: 10.5px; line-height: 16px; color: rgba(255, 255, 255, .92);
  white-space: nowrap; overflow: hidden;
}
.gate-prog-line > b {
  flex-shrink: 0; margin-left: auto; font-size: 10.5px; font-weight: 600; color: #fff;
  font-variant-numeric: tabular-nums;
}
.gp-done { color: #fff; }
.gp-now { color: #fff; font-weight: 600; }
.gp-wait { color: rgba(255, 255, 255, .55); }
.gp-sep { color: rgba(255, 255, 255, .4); }
.gate-prog-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: block; height: 3px;
  background: rgba(255, 255, 255, .22); overflow: hidden;
}
.gate-prog-fill { display: block; height: 100%; width: 0; background: #fff; transition: width .22s ease; }

#gateRoom {
  width: 100%; padding: 14px; font-size: 19px; text-align: center;
  letter-spacing: 4px; text-transform: uppercase;
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  outline: none; font-family: var(--mono); background: var(--surface-2);
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
#gateRoom::placeholder { letter-spacing: normal; text-transform: none; font-size: 15px; }
/* 空着的时候别用字距：房间码是 10 位，空输入框带 4px 字距会让占位文字散开 */
#gateRoom:placeholder-shown { letter-spacing: 0; font-size: 15px; }
#gateRoom:focus {
  border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, .1);
}
.gate-row { display: flex; gap: 9px; margin-top: 12px; }
.gate-row .gate-btn { justify-content: center; padding: 13px; }
.gate-row .gate-alt {
  flex: 0 0 92px; padding: 13px; border-radius: var(--r-md);
  border: 1px solid var(--line-2); background: var(--surface);
  color: var(--t2); font-size: 14px; font-family: inherit; cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.gate-row .gate-alt:hover { background: var(--surface-2); border-color: var(--line-2); color: var(--t1); }

/* 提示和底部那一栏叠在同一格里：谁高用谁。隐藏用 visibility，
   隐藏的那块照样撑格子，所以出提示、清提示卡片高度一分都不动 */
#gateMsg {
  grid-area: 1 / 1; visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px;
  padding: 6px 10px; border-radius: var(--r-md);
  font-size: 11.5px; line-height: 1.5; text-align: center;
  overflow-wrap: anywhere;      /* 长房间码 / 错误类型也别撑破卡片 */
}
/* 第二行：分段耗时诊断。等宽数字，秒数跳动时那一行不会左右抖 */
#gateMsg .gm-sub {
  font-size: 10px; line-height: 1.4; opacity: .72;
  font-variant-numeric: tabular-nums;
}
#gateMsg.err { visibility: visible; background: var(--danger-soft); color: #C4292E; }
/* 房间结束 / 被请出：不是错误，但要比过程提示醒目 */
#gateMsg.warn { visibility: visible; background: var(--warn-soft); color: var(--warn); }
#gateMsg.info { visibility: visible; background: transparent; color: var(--t3); }


/* 免责声明：复选框一行 */
.gate-disc { margin-top: 13px; }
.agree-check {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 11.5px; color: var(--t3); cursor: pointer; user-select: none; position: relative;
  line-height: 1.6;
}
.agree-check input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
/* 圆角方框 + 细勾：勾的笔画收细、重心上提一点，才不会显得往下坠 */
.gd-box {
  flex: none; width: 15px; height: 15px; border-radius: 4px;
  border: 1.5px solid var(--line-2); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .18s ease, border-color .18s ease;
}
.gd-box::after {
  content: ''; width: 7px; height: 3.5px; margin-top: -1.5px;
  border-left: 1.7px solid #fff; border-bottom: 1.7px solid #fff;
  transform: rotate(-45deg); opacity: 0; transition: opacity .15s ease;
}
.agree-check input:checked + .gd-box { background: var(--brand); border-color: var(--brand); }
.agree-check input:checked + .gd-box::after { opacity: 1; }
.agree-check input:focus-visible + .gd-box { box-shadow: 0 0 0 3px rgba(7, 193, 96, .18); }
.gd-link { color: var(--brand-700); cursor: pointer; text-decoration: none; }
.gd-link:hover { text-decoration: underline; }

/* 底部一栏：只剩一个极小的仓库入口。
   行高固定 34px（跟一条提示等高），所以出提示时卡片不长高 */
.gate-foot-wrap { display: grid; grid-auto-rows: minmax(34px, auto); margin-top: 10px; }
.gate-foot {
  grid-area: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; color: var(--t3);
  border-top: 1px solid var(--line);
}
/* 出提示时整栏让位给 #gateMsg：只切 visibility，格子高度不变 */
.gate-foot.hide { visibility: hidden; }
/* 帮助弹窗底部左侧的页面版本：只用于对版，压到最淡，不抢按钮 */
.gf-ver {
  margin-right: auto; align-self: center;
  font-size: 10.5px; color: var(--t3);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}


/* 免责声明独立页 */
.disc-page { position: fixed; inset: 0; z-index: 320; background: var(--bg); display: none; flex-direction: column; }
.disc-page.show { display: flex; }
.dp-head {
  flex: none; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; height: 56px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.dp-back {
  flex: none; padding: 6px 14px; border: 1px solid var(--line-2);
  border-radius: 999px; background: var(--surface); font-size: 13px;
  color: var(--t2); font-family: inherit; cursor: pointer;
}
.dp-back:hover { background: var(--surface-2); color: var(--t1); }
.dp-title { flex: 1; text-align: center; font-size: 15px; font-weight: 600; }
.dp-spacer { flex: none; width: 64px; }
.dp-body {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 24px 20px 40px; max-width: 640px; margin: 0 auto; width: 100%;
  box-sizing: border-box; font-size: 13px; line-height: 2; color: var(--t2);
}
.dp-body p { margin: 0 0 14px; text-align: justify; }
.dp-body b { color: var(--t1); }

/* ===== 拖拽投放 ===== */
#dropMask {
  position: fixed; inset: 0; z-index: 120; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(7, 193, 96, .06);
  border: 2px dashed var(--brand); border-radius: var(--r-xl);
}
#dropMask.show { display: flex; }
.drop-card { text-align: center; pointer-events: none; }
.drop-ico { font-size: 40px; }
.drop-t { font-size: 15px; font-weight: 600; color: var(--brand-700); margin-top: 8px; }
.drop-s { font-size: 12px; color: var(--t2); margin-top: 5px; }

/* ===== 网络与中继设置 ===== */
.modal.wide { max-width: 560px; }
.ice-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 12px; }
.ice-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); font-size: 12.5px;
}
.ice-row .why {
  flex-shrink: 0; font-size: 10px; padding: 1px 7px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-700);
}
.ice-row .why.def { background: var(--surface-3); color: var(--t2); }
.ice-url {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--mono); color: var(--t2); font-size: 12px;
}
.ice-row button { border: none; background: none; color: var(--danger); cursor: pointer; font-size: 13px; }
.ice-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ice-add select, .ice-add input {
  margin: 0; padding: 9px 11px; border: 1px solid var(--line-2);
  border-radius: var(--r-sm); font-size: 12.5px; font-family: inherit;
  outline: none; background: var(--surface-2); min-width: 0;
}
.ice-add select { flex: 0 0 84px; }
.ice-add #iceUrl { flex: 1 1 220px; }
.ice-add #iceUser, .ice-add #icePass { flex: 1 1 140px; }
.ice-add input:focus, .ice-add select:focus { border-color: var(--brand); background: var(--surface); }
.ice-add .btn-primary {
  flex: 0 0 auto; margin-left: auto; padding: 8px 18px;
  border: none; border-radius: var(--r-sm); font-size: 13px;
  font-family: inherit; cursor: pointer;
}
.ice-tip { font-size: 11.5px; line-height: 1.7; color: var(--t3); margin-top: 10px; }
/* 信令服务器：跟 TURN 是两件事，中间加一条分隔线，免得被当成同一组配置 */
.ice-sep {
  margin: 16px 0 8px; padding-top: 12px; border-top: 1px dashed var(--line-2);
  font-size: 11.5px; font-weight: 600; color: var(--t2); line-height: 1.6;
}
.ice-add #sigHost { flex: 1 1 200px; }
.ice-add #sigPort { flex: 0 0 70px; }
.ice-add #sigPath { flex: 0 0 70px; }
.ice-add #sigKey  { flex: 0 0 110px; }

/* ===== 帮助 ===== */
.faq { display: flex; flex-direction: column; gap: 6px; max-height: 54vh; overflow: auto; }
.faq details { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 13px; }
.faq summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--t1); }
.faq p { font-size: 12.5px; line-height: 1.85; color: var(--t2); margin-top: 8px; }
.faq code { font-family: var(--mono); background: var(--surface-3); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

/* ===== 连接信息侧栏 =====
   窄屏：纵向堆叠、卡片全宽（手机就该上下排，不该逼人左右滑）；
   宽屏：固定到右侧竖排，聊天区独享中间。 */
.side-info { flex-shrink: 0; display: flex; flex-direction: column; }
.side-info > #p2pBanner,
.side-info > #guestGate, .side-info > #waitBar { text-align: left; }

@media (max-width: 1099px) {
  /* 窄屏：纵向排、卡片占满整行。
     手机是上下滚的设备，横向滑动藏内容是反直觉的——看不见的那几张
     等于不存在。全部铺开、上下排，一眼看全。
     卡片多的时候侧栏内部纵向滚，不把聊天区顶掉。 */
  .side-info {
    flex-direction: column; align-items: stretch; gap: 8px;
    padding: 10px 12px 0;
    max-height: 46vh; overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .side-info::-webkit-scrollbar { display: none; }
  .side-info > * {
    flex: 0 0 auto; margin: 0 !important;
    width: 100% !important; max-width: none;
  }
}

/* 宽屏：右侧固定信息栏 */
@media (min-width: 1100px) {
  .side-info {
    position: fixed; top: 56px; right: 16px; width: 252px;
    padding: 14px 0 0; gap: 10px;
    max-height: calc(100vh - 56px); overflow-y: auto;
    z-index: 6;
    scrollbar-width: thin; scrollbar-color: #D3D9E0 transparent;
  }
  .side-info::-webkit-scrollbar { width: 4px; }
  .side-info::-webkit-scrollbar-thumb { background: #D3D9E0; border-radius: 2px; }
  .side-info > * { margin: 0 !important; }
  .side-info .p2p-line { gap: 6px; }
  .side-info .side-actions .pill { flex: 1; min-width: 0; padding: 5px 0; text-align: center; }
  .side-info #roomCode { font-size: 15.5px; letter-spacing: 1.4px; padding: 7px 8px; }
  .side-info #p2pUrl { font-size: 11.5px; padding: 6px 8px; }
  .side-info #qrImg canvas { width: 84px; height: 84px; }
  #waitBar { flex-direction: column; align-items: flex-start; gap: 5px; }
  /* 聊天区让出右侧栏宽度 */
  .chat-scroll { padding-right: 284px; }
  .input-bar { padding-right: 284px; }
  .pending-area { padding-right: 284px; }
}

/* ===== 二维码浮层：盖在卡片上，卡片尺寸不变 ===== */
#p2pBanner { position: relative; }
#p2pBanner .qr-float {
  position: absolute; inset: 0; z-index: 3; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 10px; text-align: center;
  background: var(--surface); border-radius: calc(var(--r-lg) - 1px);
}
#p2pBanner .qr-back { margin: 0; padding: 4px 26px; white-space: nowrap; flex-shrink: 0; }

/* ===== 窄屏适配 ===== */
@media (max-width: 640px) {
  .topbar { height: 52px; padding: 0 14px; }
  .topbar-sub { display: none; }

  /* 手机屏高有限，房间信息必须压扁：三张卡加起来要能在一屏内看完，
     否则只能内部滚动，而"卡片被切断一半"是最难看的形态。 */
  .side-info { padding: 8px 10px 0; gap: 7px; max-height: 50vh; }
  .pending-area { padding: 9px 10px 10px; max-height: 36vh; }
  .pq-item { padding: 8px 8px 9px 9px; }
  .pq-ico { width: 32px; height: 32px; font-size: 9.5px; }
  .pq-name { font-size: 12.5px; }
  .side-info > * { width: 100% !important; }
  #roomCard, #p2pBanner, #guestGate, #roomStat { padding: 10px 11px; }
  #waitBar { padding: 10px 11px; }

  /* 「房间」两个字在这里是废话：10 位房间号摆在那儿，谁都认得。
     但「网页直连」这个徽标要留着 —— 手机上它是唯一的房间类型提示，
     跟着标题一起藏掉，用户就看不出这是个什么房间了。 */
  .room-card-title { display: flex; }
  .room-card-title .rct-t { display: none; }
  .room-card-title::before { display: none; }
  .room-card-title .room-badge { margin-left: 0; }
  #roomCode { font-size: 16.5px; letter-spacing: 1.5px; padding: 6px 10px; }
  .room-actions { margin-top: 6px; gap: 6px; }
  .room-actions .pill { padding: 5px 0; font-size: 12px; }

  /* 通道卡：标签 + 地址 + 按钮，每一行都收紧一档 */
  .p2p-label { font-size: 12.5px; }
  #p2pUrl { font-size: 11.5px; padding: 5px 8px; letter-spacing: 0; }
  .side-actions { margin-top: 6px; gap: 6px; }
  .side-actions .pill { padding: 4px 11px; font-size: 11.5px; }
  .chan-count { font-size: 11.5px; }
  #guestGate .guest-room { font-size: 12.5px; }
  /* 通道卡片默认收起：手机上屏幕太贵。房间号始终可见（别人要靠它加入），
     地址、复制/二维码按钮、成员清单这些「偶尔看一眼」的，点标题行再铺开。
     收起的卡片仍然显示连接台数，一眼知道有没有人在线。 */
  #p2pBanner .p2p-line { cursor: pointer; -webkit-user-select: none; user-select: none; }
  #p2pBanner .p2p-line::after {
    content: ''; margin-left: auto; flex-shrink: 0; width: 7px; height: 7px;
    border-right: 1.6px solid var(--t4); border-bottom: 1.6px solid var(--t4);
    transform: rotate(45deg) translate(-2px, -2px);
    transition: transform .2s ease;
  }
  #p2pBanner.open .p2p-line::after {
    transform: rotate(-135deg) translate(-2px, -2px);
  }
  #p2pBanner:not(.open) #p2pUrl,
  #p2pBanner:not(.open) .side-actions,
  #p2pBanner:not(.open) #inviteHint,
  #p2pBanner:not(.open) .chan-list { display: none !important; }

  /* 等待条在手机上只留一句话，副标题那种「把房间码发给别人…」是给宽屏看的 */
  #waitBar { flex-direction: row; align-items: center; gap: 7px; }
  #waitBar .w-sub { display: none; }
  #guestGate .self-ip { font-size: 12px; }
  .screen-card, .screen-card.live { width: 100%; }
  .sc-video { max-height: 42vh; }
  .chat-scroll { padding: 16px 12px 8px; }
  .input-bar { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .file-card { width: 100%; }
  /* 卡片一改成满宽，下载条也必须跟着满宽，否则进度条比卡片短一截 */
  .pull-wrap { width: 100%; }
  .empty { padding: 48px 16px; min-height: 34vh; }
  .gate-card { padding: 24px 18px 16px; border-radius: var(--r-lg); }
  .gate-title { font-size: 18.5px; }
  .modal { padding: 20px; border-radius: var(--r-lg); }
  .bubble { max-width: 100%; }
}

/* ===== v2：房间卡 ===== */
.room-badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  border-radius: 999px; background: #e8f7ee; color: #0a8f4a;
  font-size: 10px; font-weight: 600; vertical-align: middle;
}
/* 人数：跟着房间号走的一行小字。用 --t3 而不是更淡的 --t4 ——
   「在线 2 / 6 人」是要被读到的信息，不是装饰。 */
.room-sub { margin-top: 6px; font-size: 11.5px; color: var(--t3); line-height: 1.5; }
.room-sub.full { color: var(--warn); font-weight: 600; }

/* 房间卡里的销毁倒计时：和房间码绑在一起，一眼能看到房间还能活多久。
   剩不到 5 分钟由 renderRoomStat() 加 .warn 换成告警色。 */
.room-idle {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; padding: 6px 9px;
  font-size: 11.5px; color: var(--t2);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm);
  transition: color .2s ease, background .2s ease, border-color .2s ease;
}
.room-idle::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--brand); flex-shrink: 0;
}
.room-idle b {
  font-family: var(--mono); font-weight: 600; color: var(--t1);
  letter-spacing: .02em;
}
.room-idle.warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.room-idle.warn::before { background: var(--warn); }
.room-idle.warn b { color: var(--warn); }

/* ===== 存储 / 上传限制卡 =====
   云房主：已用 / 总量、单文件上限、进度条（总量 = 可用空间 × 80%）；
   加入者：同一份数字的只读版，由房主经 QUOTA 帧同步；
   局域网房间：没有配额，只显示后端给的单文件上限。 */
#roomStat {
  flex-shrink: 0;
  margin: 10px 20px 0;
  padding: 12px 14px;
  background: #f5fcf8;
  border: 1px solid #cfeadd;
  border-radius: var(--r-lg);
}
.st-h {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: #0a8f4a;
}
.st-h::before {
  content: ''; width: 6px; height: 6px; border-radius: 2px;
  background: #07C160; flex-shrink: 0;
}
/* 侧栏宽屏只有 252px，两项并排会挤成「已用 0 B / 8.0 GB 单文件上限 819.2 MB」
   一整串读不断句，所以默认竖排；窄屏侧栏是全宽的，再改回并排省一行高度。 */
.st-grid {
  display: flex; flex-direction: column; gap: 3px;
  margin-top: 8px; font-size: 11.5px; color: var(--t2);
}
@media (max-width: 1099px) {
  .st-grid { flex-direction: row; flex-wrap: wrap; gap: 4px 10px; }
}
.st-grid b { color: var(--t1); font-weight: 600; }
/* 探测不到配额：卡片底色转红，说明文字就在进度条下面 */
#roomStat.no-quota {
  background: var(--danger-soft);
  border-color: var(--danger-line);
}
#roomStat.no-quota .st-h { color: #C4292E; }
#roomStat.no-quota .st-h::before { background: var(--danger); }
#roomStat.no-quota .mini-bar i { background: var(--danger); }
.st-warn {
  margin-top: 8px; padding: 6px 8px; border-radius: var(--r-sm);
  background: #fff; border: 1px solid var(--danger-line);
  font-size: 10.5px; line-height: 1.5; color: var(--danger);
}
/* 文件按钮被禁用的外观：不是 disabled（refreshReady 会把它改回来），只做视觉提示。
   真正的拦截在 addFiles()，点了会弹一句为什么不能传。 */
.folder-btn.blocked {
  opacity: .45; color: var(--t3); cursor: not-allowed;
}
.folder-btn.blocked:hover { background: var(--surface-2); border-color: var(--line); color: var(--t3); }
.mini-bar {
  height: 4px; margin-top: 9px; border-radius: 999px;
  background: #dcefe4; overflow: hidden;
}
.mini-bar i {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: #07C160; transition: width .3s ease;
}
.st-foot { margin-top: 8px; font-size: 10.5px; color: var(--t3); line-height: 1.5; }
/* 清理入口：只在房主页面上出现（加入者看不到，也没有权限）。
   做成有底色的轻按钮，不用下划线——下划线像正文里的链接，和旁边的小字说明混在一起。 */
.st-clean {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 10px; padding: 5px 10px; border: 1px solid var(--brand-line);
  border-radius: var(--r-sm); background: var(--brand-soft);
  font: inherit; font-size: 11px; line-height: 1.2; color: var(--brand-700);
  cursor: pointer; text-decoration: none;
  transition: background .15s ease, border-color .15s ease;
}
.st-clean:hover { background: #DFF4E8; border-color: #B7E2C9; }
.st-clean:active { background: #D5EFE1; }

/* ===== 清理文件弹窗 =====
   房主勾选聊天里的文件卡片，删掉后立即释放房间空间。
   列表用固定最大高度 + 内部滚动：文件多时弹窗不会顶出屏幕。 */
.clean-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; font-size: 12px; color: var(--t2);
}
.clean-all { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.clean-all input { width: 14px; height: 14px; accent-color: var(--brand); }
.clean-sum { font-size: 11.5px; color: var(--t3); }
.clean-list {
  margin-top: 8px; max-height: 46vh; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface);
}
.clean-row {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-top: 1px solid var(--line);
  font-size: 12px; color: var(--t1); cursor: pointer;
}
.clean-row:first-child { border-top: 0; }
.clean-row:hover { background: var(--surface-2); }
.clean-row input { width: 14px; height: 14px; accent-color: var(--brand); flex-shrink: 0; }
.clean-row .cn {
  flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.clean-row .cs { flex-shrink: 0; font-size: 11px; color: var(--t3); }
.clean-empty {
  padding: 22px 12px; text-align: center;
  font-size: 12px; color: var(--t3);
}
.clean-filters { display: flex; gap: 6px; margin-top: 12px; }
.clean-filters select {
  flex: 1; min-width: 0; height: 30px; padding: 0 7px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface); color: var(--t1); font: inherit; font-size: 11.5px;
  cursor: pointer;
}

/* ===== v2：入口页视图切换的过渡 =====
   三块视图本来就同格叠放、靠 visibility 切换，卡片长宽不变（D-04）。
   退出沿用「淡出 + 位移」，进入用 keyframes 从反向滑入：
   前进（选择 → 输入房号 / 下载）从右侧进、旧页向左退；后退反过来。
   方向由 gateView() 写在 .gate-views 的 data-nav 上。 */
.gate-view {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .22s ease, transform .22s ease, visibility 0s linear .22s;
}
.gate-view.on {
  opacity: 1;
  transform: none;
  transition: opacity .22s ease, transform .22s ease, visibility 0s;
}
.gate-views[data-nav="fwd"] .gate-view:not(.on) { transform: translateX(-12px); }
.gate-views[data-nav="back"] .gate-view:not(.on) { transform: translateX(12px); }
.gate-views[data-nav="fwd"] .gate-view.on { animation: gateInFwd .26s cubic-bezier(.22, .9, .28, 1) both; }
.gate-views[data-nav="back"] .gate-view.on { animation: gateInBack .26s cubic-bezier(.22, .9, .28, 1) both; }
@keyframes gateInFwd { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes gateInBack { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }

/* ===== 卡片入场：子元素逐级上浮（位移 + 淡入），卡片本身不动 =====
   逐级的 40~60ms 差让视线自然落到「创建房间」那颗按钮上，
   比整卡一次性淡入更有方向感，也不会造成布局跳动。 */
@keyframes gateUp { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: none; } }
@keyframes logoPop {
  from { opacity: 0; transform: scale(.82); }
  60%  { opacity: 1; }
  to   { opacity: 1; transform: none; }
}
#gateView.show .gate-card > * { animation: gateUp .38s cubic-bezier(.22, .9, .28, 1) both; }
#gateView.show .gate-card > .gate-logo { animation: logoPop .46s cubic-bezier(.34, 1.35, .64, 1) both; }
#gateView.show .gate-card > .gate-title { animation-delay: .06s; }
#gateView.show .gate-card > .gate-sub { animation-delay: .09s; }
#gateView.show .gate-card > .gate-body { animation-delay: .12s; }
#gateView.show .gate-card > .gate-disc { animation-delay: .19s; }
#gateView.show .gate-card > .gate-foot-wrap { animation-delay: .22s; }

@media (prefers-reduced-motion: reduce) {
  .gate-view, .gate-view.on { transition: none; transform: none; animation: none; }
  .gate-views[data-nav] .gate-view.on,
  #gateView.show .gate-card > * { animation: none; }
  .gate-btn, .gate-ico { transition: none; }
}

/* ===== v2：文件卡下载的暂停 / 继续 =====
   三个图标叠在同一个按钮里，靠卡片上的 data-dl 决定显示哪一个：
   空闲与完成显示下载箭头，下载中显示暂停，暂停后显示继续。 */
.file-dl svg { display: none; }
.file-card:not([data-dl]) .file-dl svg:first-child,
.file-card[data-dl="idle"] .file-dl svg:first-child,
.file-card[data-dl="done"] .file-dl svg:first-child { display: block; }
.file-card[data-dl="queued"] .file-dl .dl-ico-pause { display: block; }
.file-card[data-dl="running"] .file-dl .dl-ico-pause { display: block; }
.file-card[data-dl="paused"] .file-dl .dl-ico-play { display: block; }
/* 下载完不加任何"已完成"的灰态：图标还是那枚下载箭头、还是那个颜色。
   压灰等于告诉用户「这按钮废了」，可它明明还能点（再点就是重新下一遍）。 */

/* 进度条贴在卡片底边，绝对定位 —— 高度不占布局，卡片尺寸一点不变 */
.dl-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  display: none; overflow: hidden;
  background: rgba(7, 193, 96, .16);
  border-radius: 0 0 var(--r-md) var(--r-md);
}
.file-card[data-dl="running"] .dl-bar,
.file-card[data-dl="paused"] .dl-bar { display: block; }
.dl-bar i {
  display: block; height: 100%; width: 0;
  background: var(--brand);
  transition: width .22s linear;
}
.file-card[data-dl="paused"] .dl-bar i { background: var(--t4); }

/* ===== 入口页响应式：宽度 / 高度 / 触屏 三条轴分别处理 =====
   卡片本身最大 400px（一行 20 字上下最舒服的阅读宽度），
   所以宽屏不需要放大，只需要在窄屏和矮屏上逐档收紧。 */

/* 触屏：hover 抬起在手指点完会「粘住」，变成一直悬空的样子，直接关掉位移与落影 */
@media (hover: none) {
  .gate-btn:hover { transform: none; box-shadow: none; }
  .gate-btn:hover .gate-ico { transform: none; }
  .gate-btn.primary:hover { box-shadow: 0 8px 20px -8px rgba(7, 193, 96, .65); }
}

/* 窄屏（≤400）：左右内边距收一档，把宽度还给内容 */
@media (max-width: 400px) {
  .gate-card { padding: 22px 16px 14px; }
  .gate-btn { padding: 12px 12px; gap: 9px; }
  .agree-check { font-size: 11px; gap: 5px; }
}

/* 超窄（≤340，iPhone SE / 小屏安卓）：字号与图标再收半步，避免声明行折两行 */
@media (max-width: 340px) {
  #gateView { padding-left: 12px; padding-right: 12px; }
  .gate-card { padding: 18px 12px 12px; border-radius: 16px; }
  .gate-title { font-size: 17px; }
  .gate-sub { font-size: 11px; }
  .gate-ico { width: 28px; height: 28px; border-radius: 9px; }
  .gate-ico svg { width: 15px; height: 15px; }
  .gate-txt b { font-size: 13.5px; }
  .gate-txt i { font-size: 10.5px; }
  .ls-txt b { font-size: 12px; }
  .ls-txt i { font-size: 10px; }
  .agree-check { font-size: 10.5px; }
}

/* 矮屏（≤700 高：横屏手机、半屏窗口）：压扁纵向节奏，争取一屏看完 */
@media (max-height: 700px) {
  #gateView { padding-top: 14px; padding-bottom: 14px; }
  /* 只动上下，左右交给宽度断点：320 宽的小屏要的是两种收法同时生效 */
  .gate-card { padding-top: 18px; padding-bottom: 12px; }
  .gate-logo { width: 38px; height: 38px; border-radius: 12px; margin-bottom: 8px; }
  .gate-logo svg { width: 19px; height: 19px; }
  .gate-title { font-size: 17.5px; }
  .gate-sub { margin-top: 3px; font-size: 11.5px; }
  .gate-body { margin-top: 12px; }
  .gate-btn { padding: 10px 12px; }
  .gate-txt i { font-size: 10.5px; }
  .gate-disc { margin-top: 10px; }
  .gate-foot-wrap { margin-top: 8px; }
  .gate-foot { padding-top: 7px; font-size: 10px; }
}

/* 极矮（≤480 高，横屏手机）：标题区让位给操作区，logo 与副标题收起 */
@media (max-height: 480px) {
  .gate-logo, .gate-sub { display: none; }
  .gate-card { padding-top: 14px; padding-bottom: 10px; }
  .gate-title { font-size: 16.5px; margin-bottom: 2px; }
  .gate-body { margin-top: 10px; }
  .gate-foot { display: none; }
}
