/* 語音停靠列、「通話」分頁、釘選小視窗、說話高亮、主持人管理 */
.voice-dock {
  position: absolute; z-index: 12; top: 6px; left: 6px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  max-width: calc(100% - 160px); pointer-events: none;
}
.voice-dock > * { pointer-events: auto; }
.voice-row, .voice-controls { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.voice-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 11px; border: 0; border-radius: 22px;
  background: rgba(0, 0, 0, .5); color: #fff; font-size: 14px; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.voice-btn .icon { width: 22px; height: 22px; }
.voice-btn .voice-icon { display: inline-flex; }
.voice-btn:disabled { opacity: .45; cursor: default; }
.voice-btn.on, .voice-btn[aria-pressed="true"] { background: var(--accent); }
.voice-btn.ptt { touch-action: none; }
.voice-btn.speaking { box-shadow: 0 0 0 3px var(--ok); }
.voice-btn.voice-warn { background: var(--danger); }
/* 加入通話：沒人在通話中時低調（與其他停靠列按鈕相同）；有人在通話中時強調色＋第二行人數 */
.voice-join.has-others { background: rgba(79, 140, 255, .9); }
.voice-join-text { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.15; text-align: center; }
.voice-join-count { font-size: 11px; opacity: .9; white-space: nowrap; }
.voice-join-count[hidden] { display: none; }
/* 提示泡泡（有人在通話中、還沒加入）：可關閉 */
.voice-hint {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
  font-size: 12px; line-height: 1.3; color: #fff; background: rgba(0, 0, 0, .7);
  padding: 2px 2px 2px 10px; border-radius: 12px;
}
.voice-hint[hidden] { display: none; }
/* 出現淡入、消失反向淡出（ui/anim.js） */
.voice-hint { animation: ui-fade-in .2s ease-out; }
.voice-hint.closing { animation: ui-fade-out .2s ease-in forwards; }
.voice-hint-close {
  position: relative; flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer;
}
.voice-hint-close .icon { width: 14px; height: 14px; }
@media (pointer: coarse) { .voice-hint-close::after { content: ''; position: absolute; inset: -10px; } }
.voice-status { font-size: 12px; color: #fff; background: rgba(0, 0, 0, .5); padding: 2px 8px; border-radius: 10px; }
.voice-note {
  font-size: 12px; color: #fff; background: rgba(229, 72, 77, .85);
  padding: 4px 10px; border-radius: 10px;
}
.voice-settings .voice-note { margin-bottom: 8px; }
.voice-audio { display: none; }

/* 設定抽屜 */
.voice-settings { display: flex; flex-direction: column; gap: 10px; }
.voice-settings select.input { width: 100%; min-height: var(--tap); }
.voice-toggle { display: flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.voice-toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
.voice-quality { margin: 0; font-size: 13px; }
.voice-steps { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 6px; }
.voice-crowded .btn-row { display: flex; gap: 8px; justify-content: flex-end; }

/* 成員清單 */
.member-voice { display: inline-flex; color: var(--fg-2); }
.member-voice .icon { width: 16px; height: 16px; }
.member-row.speaking { box-shadow: inset 0 0 0 2px var(--ok); border-radius: 10px; }
.member-row.speaking .member-voice { color: var(--ok); }

/* 釘選的浮動小視窗（影片：舞台容器內，全螢幕時仍可見；戰術板：戰術板窗格內） */
.vtiles { position: absolute; inset: 0; z-index: 11; pointer-events: none; }
.vtile {
  position: relative; overflow: hidden; background: #000; border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, .15);
}
.vtile.floating {
  position: absolute; pointer-events: auto; touch-action: none; cursor: grab;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .5);
}
.vtile.floating.dragging { cursor: grabbing; opacity: .9; }
.vtile.speaking { border-color: var(--ok); }
.vtile-video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.vtile-video[hidden] { display: none; }
.vtile.mirror .vtile-video { transform: scaleX(-1); }
.vtile-name {
  position: absolute; left: 6px; bottom: 4px; max-width: calc(100% - 30px);
  font-size: 12px; color: #fff; text-shadow: 0 1px 2px #000;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
.vtile-resize {
  display: none; position: absolute; right: 0; bottom: 0; width: 28px; height: 28px; cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(255, 255, 255, .7) 50%);
}
.vtile.floating .vtile-resize { display: block; }

/* 釘選的浮動小視窗：沒開鏡頭時顯示頭像；右上角 × 取消釘選 */
.vtile .ctile-avatar { position: absolute; inset: 0; }
.vtile-unpin {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer;
  transition: opacity .25s, visibility .25s;
}
.vtile-unpin .icon { width: 16px; height: 16px; }
.vtile-resize { transition: opacity .25s, visibility .25s; }
/* 觸控：按鈕熱區放大（視覺大小不變） */
@media (pointer: coarse) {
  .vtile-unpin::after { content: ''; position: absolute; inset: -8px; }
}
/* 戰術板窗格也是浮動層的定位容器 */
.tx-drawer { position: relative; }
.tx-drawer > .vtiles { z-index: 20; }
/* 閒置淡出：小視窗本身留著（是內容），只隱藏 × 與縮放把手 */
.room.ui-idle .vtile-unpin, .room.ui-idle .vtile-resize { visibility: hidden; opacity: 0; }

/* 「通話」分頁：每位通話成員一格（開鏡頭顯示畫面，否則頭像） */
.ctile-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.ctile-bar .btn .icon { width: 18px; height: 18px; margin-right: 4px; }
.ctile-bar [hidden] { display: none; }
.ctile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.ctile {
  position: relative; overflow: hidden; border-radius: 10px; background: #111;
  border: 2px solid rgba(255, 255, 255, .12); aspect-ratio: 4 / 3; outline: none;
}
.ctile:focus-visible { border-color: var(--accent); }
.ctile.speaking { border-color: var(--ok); }
.ctile-media { position: absolute; inset: 0; }
.ctile.mirror .vtile-video { transform: scaleX(-1); }
.ctile-avatar { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #1b1e26; }
.ctile-avatar[hidden] { display: none; }
.ctile-avatar span {
  display: flex; align-items: center; justify-content: center;
  width: min(44%, 56px); aspect-ratio: 1; border-radius: 50%;
  background: var(--c, #4f8cff); color: #fff; font-size: 22px; font-weight: 600; text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}
.ctile-foot {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 4px;
  padding: 14px 6px 4px; background: linear-gradient(transparent, rgba(0, 0, 0, .65));
  font-size: 12px; color: #fff; pointer-events: none;
}
.ctile-mic { display: inline-flex; flex: none; }
.ctile-mic .icon { width: 15px; height: 15px; }
.ctile-mic[data-on="false"] { color: #ff8a8d; }
.ctile-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; }
.ctile-state { flex: none; font-size: 11px; padding: 0 6px; border-radius: 8px; background: rgba(229, 72, 77, .85); }
.ctile-state[hidden] { display: none; }
/* 操作：滑鼠懸停（或鍵盤聚焦）顯示；觸控點一下淡入、幾秒後淡出。
   所有按鈕在同一層置中、放不下就換行；窄格子只顯示圖示，極窄時主持人按鈕收成「⋯」，任何尺寸都不超出格子 */
.ctile-actions {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 6px; overflow: hidden; background: rgba(0, 0, 0, .66);
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
.ctile.show-actions .ctile-actions, .ctile:focus-within .ctile-actions { opacity: 1; visibility: visible; }
@media (hover: hover) and (pointer: fine) {
  .ctile:hover .ctile-actions { opacity: 1; visibility: visible; }
}
/* 只有圖示時每列最多兩個（2×2），有文字時依寬度換行 */
.ctile-btns {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px;
  max-width: calc(2 * var(--ctile-btn) + 6px); --ctile-btn: 36px;
}
.ctile-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: var(--ctile-btn); height: var(--ctile-btn); padding: 0 9px; flex: none;
  border: 0; border-radius: calc(var(--ctile-btn) / 2); background: rgba(44, 48, 60, .94); color: #fff;
  font-size: 12px; cursor: pointer; touch-action: manipulation; white-space: nowrap;
}
.ctile-btn .icon { width: 16px; height: 16px; }
.ctile-btn:hover { background: rgba(74, 80, 96, .96); }
.ctile-btn[aria-pressed="true"] { background: var(--accent); }
.ctile-btn[hidden], .ctile-more { display: none; }
.ctile-btn-text { display: none; }
@media (pointer: coarse) { .ctile-btns { --ctile-btn: 44px; } }
.ctile { container: ctile / inline-size; }
/* 寬格子：顯示文字 */
@container ctile (min-width: 250px) {
  .ctile-btns { max-width: 100%; }
  .ctile-btn-text { display: inline; }
  .ctile-btn { padding: 0 11px; }
}
/* 極窄格子（觸控按鈕 44px 排不下兩列兩個）：主持人按鈕收成「⋯」 */
@container ctile (max-width: 139px) {
  .ctile-btn.ctile-mod { display: none; }
  .ctile-btn.ctile-more:not([hidden]) { display: inline-flex; }
}

/* 「通話」分頁的控制列：麥克風、鏡頭、靜音、語音設定、離開／加入（與舞台停靠列同步） */
.call-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.call-ctl {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 44px; height: 44px; padding: 0 11px; border: 1px solid var(--line); border-radius: 22px;
  background: var(--bg-3); color: var(--fg); font-size: 14px; cursor: pointer;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.call-ctl .icon { width: 20px; height: 20px; }
.call-ctl .voice-icon { display: inline-flex; }
.call-ctl:disabled { opacity: .45; cursor: default; }
.call-ctl.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.call-ctl.ptt { touch-action: none; }
.call-ctl.speaking { box-shadow: 0 0 0 3px var(--ok); }
.call-ctl[hidden], .call-ctl [hidden] { display: none; }
.call-leave { background: var(--danger); border-color: var(--danger); color: #fff; }
.call-join { background: var(--accent); border-color: var(--accent); color: #fff; }
/* 沒加入通話時的提示卡：人數＋「加入通話才聽得到…」＋加入按鈕 */
.call-hint {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg-3);
}
.call-hint[hidden] { display: none; }
.call-hint > .icon { flex: none; width: 22px; height: 22px; color: var(--accent); }
.call-hint-body { flex: 1; min-width: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--fg-2); }
.call-hint-count { font-size: 14px; color: var(--fg); }
.call-hint-count[hidden] { display: none; }
.call-hint .call-join { flex: none; }
.call-status { font-size: 13px; color: var(--fg-2); }
.call-note { flex-basis: 100%; margin: 0; font-size: 13px; color: #fff; background: rgba(229, 72, 77, .85); padding: 6px 10px; border-radius: 10px; }
.call-status[hidden], .call-note[hidden] { display: none; }
/* 靜音中：紅底＋「已靜音」文字，一眼看得出聽不到通話 */
.voice-btn.deaf-on, .call-ctl.deaf-on { background: var(--danger); border-color: var(--danger); color: #fff; }

/* 管理抽屜（主持人） */
.mod-sheet { display: flex; flex-direction: column; gap: 10px; }
.mod-sheet .hint { margin: 0; }
.mod-group { display: flex; gap: 8px; }
.mod-group .btn { flex: 1; }
.mod-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.mod-btn .icon { width: 18px; height: 18px; }
.mod-btn.on { border-color: var(--danger); color: var(--danger); }
.member-manage { flex: none; padding: 0 8px; }
.member-manage .icon { width: 18px; height: 18px; }
.member-subtitle { margin: 16px 6px 4px; font-size: 13px; font-weight: 600; color: var(--fg-2); }

/* 自動淡出（.room.ui-idle，各版面相同）：隱藏停靠列按鈕，但保留按住說話與「點此開啟聲音」 */
.voice-btn, .voice-status, .voice-note, .voice-hint { transition: opacity .25s, visibility .25s; }
.room.ui-idle .voice-dock .voice-btn:not(.ptt):not(.voice-warn):not(.deaf-on),
.room.ui-idle .voice-dock .voice-status, .room.ui-idle .voice-dock .voice-hint {
  visibility: hidden; opacity: 0;
}
/* 滑鼠裝置：淡出後不可點，但仍可用 Tab 聚焦 */
@media (hover: hover) and (pointer: fine) {
  .room.ui-idle .voice-dock .voice-btn:not(.ptt):not(.voice-warn):not(.deaf-on),
  .room.ui-idle .voice-dock .voice-hint { visibility: visible; pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) {
  .voice-btn, .voice-status, .voice-note, .voice-hint { transition: none; }
  .voice-hint, .voice-hint.closing { animation: none; }
}
