:root {
  --bg: #0a0d16;
  --bg-2: #101528;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-2: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef1f8;
  --text-dim: #9aa3bb;
  --text-mute: #646d85;
  --accent: #5b8cff;
  --accent-2: #7c5cff;
  --live: #2fd3a5;
  --warn: #ffb86b;
  --danger: #ff6b81;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body::before {
  content: "";
  position: fixed;
  inset: -20% -20% auto -20%;
  height: 70vh;
  background:
    radial-gradient(45% 55% at 20% 20%, rgba(91, 140, 255, 0.28), transparent 70%),
    radial-gradient(40% 50% at 85% 10%, rgba(124, 92, 255, 0.22), transparent 70%),
    radial-gradient(35% 45% at 50% 0%, rgba(47, 211, 165, 0.12), transparent 70%);
  filter: blur(10px);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: var(--safe-b);
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: 0.4px;
}

.brand .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(91, 140, 255, 0.9);
  animation: breathe 2.6s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.55; transform: scale(0.82); }
}

.brand-name {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.92);
}

.ghost-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s;
  font-family: inherit;
}

.ghost-btn:hover { background: var(--panel-2); color: var(--text); }

.me-avatar {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* ---------- 舞台 ---------- */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 4px 18px 0;
}

.room-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 18px;
}

.room-head h1 {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: 0.2px;
}

.room-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-mute);
  display: flex;
  gap: 6px;
  align-items: center;
}

.room-sub .sep { opacity: 0.5; }

.quality {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-dim);
  white-space: nowrap;
  transition: 0.35s;
}

.quality-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-mute);
  transition: 0.35s;
}

.quality[data-level="hq"] { color: #bcd0ff; border-color: rgba(91, 140, 255, 0.45); background: rgba(91, 140, 255, 0.12); }
.quality[data-level="hq"] .quality-dot { background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.quality[data-level="stable"] { color: #9ff0d4; border-color: rgba(47, 211, 165, 0.4); background: rgba(47, 211, 165, 0.1); }
.quality[data-level="stable"] .quality-dot { background: var(--live); box-shadow: 0 0 10px var(--live); }
.quality[data-level="low"] { color: #ffd7a8; border-color: rgba(255, 184, 107, 0.4); background: rgba(255, 184, 107, 0.1); }
.quality[data-level="low"] .quality-dot { background: var(--warn); box-shadow: 0 0 10px var(--warn); }

/* ---------- 麦位 ---------- */
.seats {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

/* 顶部主持位：居中、比普通麦位大一圈 */
.seat-host {
  display: flex;
  justify-content: center;
}

.seat-host .seat {
  width: 128px;
  padding: 10px 6px 9px;
}

.seat-host .avatar {
  width: 64px;
  height: 64px;
  font-size: 20px;
}

/* 下面 8 个麦位：每排 4 个，正好两排 */
.seat-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px 10px;
}

.seat-grid .seat {
  width: calc((100% - 30px) / 4);
  padding: 10px 4px 9px;
}

.seat-grid .avatar {
  width: 50px;
  height: 50px;
  font-size: 17px;
}

.seat {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 6px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  cursor: pointer;
  transition: transform 0.18s ease, background 0.25s, border-color 0.25s;
  user-select: none;
}

.seat:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.075); }
.seat:active { transform: scale(0.97); }

.seat[data-empty="true"] {
  border: 1px dashed rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.018);
}

.seat[data-locked="true"] {
  border-color: rgba(255, 184, 107, 0.28);
  background: rgba(255, 184, 107, 0.05);
}

.avatar {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  background: #2a3350;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: 0.25s;
}

.seat[data-empty="true"] .avatar {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-mute);
  font-size: 22px;
  font-weight: 300;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* 说话光环 */
.seat[data-speaking="true"] .avatar::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--live);
  animation: speak 1.15s ease-out infinite;
}

@keyframes speak {
  0% { transform: scale(0.92); opacity: 0.9; }
  70% { transform: scale(1.12); opacity: 0; }
  100% { transform: scale(1.12); opacity: 0; }
}

.seat[data-speaking="true"] .avatar {
  box-shadow: 0 0 0 2px rgba(47, 211, 165, 0.65), 0 0 26px rgba(47, 211, 165, 0.45);
}

.seat[data-self="true"] .avatar { box-shadow: 0 0 0 2px rgba(91, 140, 255, 0.85); }
.seat[data-self="true"][data-speaking="true"] .avatar { box-shadow: 0 0 0 2px rgba(47, 211, 165, 0.75), 0 0 26px rgba(47, 211, 165, 0.5); }

.seat-name {
  font-size: 12.5px;
  color: var(--text-dim);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat[data-empty="true"] .seat-name { color: var(--text-mute); }

.badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--text-dim);
}

.badge.crown { color: #ffd479; border-color: rgba(255, 212, 121, 0.35); background: rgba(255, 212, 121, 0.12); }
.badge.mute { color: var(--danger); border-color: rgba(255, 107, 129, 0.3); background: rgba(255, 107, 129, 0.12); }
.badge.lock { color: var(--warn); border-color: rgba(255, 184, 107, 0.3); background: rgba(255, 184, 107, 0.12); }

.seat-hint {
  position: absolute;
  bottom: -6px;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(10, 13, 22, 0.9);
  border: 1px solid var(--line);
  color: var(--text-mute);
}

/* ---------- 公屏 ---------- */
.feed-wrap {
  flex: 1;
  min-height: 90px;
  position: relative;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.012));
  border: 1px solid var(--line);
  overflow: hidden;
}

.feed-wrap::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 26px;
  background: linear-gradient(180deg, rgba(10, 13, 22, 0.75), transparent);
  pointer-events: none;
  z-index: 2;
}

.feed {
  height: 100%;
  overflow-y: auto;
  padding: 14px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.14) transparent;
}

.feed::-webkit-scrollbar { width: 4px; }
.feed::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 4px; }

.msg {
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  animation: msgIn 0.28s ease both;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.msg .who {
  color: #8fb0ff;
  font-weight: 500;
  margin-right: 6px;
}

.msg .body { color: rgba(238, 241, 248, 0.88); }

.msg.system {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-mute);
  padding: 2px 0;
}

.msg.system .body { color: var(--text-mute); }

/* ---------- 底部 ---------- */
.dock {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px calc(16px + var(--safe-b));
  background: linear-gradient(180deg, transparent, rgba(10, 13, 22, 0.9) 40%);
}

.mic-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 18px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid rgba(91, 140, 255, 0.4);
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.9), rgba(124, 92, 255, 0.9));
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.22s;
  box-shadow: 0 8px 24px -8px rgba(91, 140, 255, 0.75);
  font-family: inherit;
  white-space: nowrap;
}

.mic-btn:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -8px rgba(91, 140, 255, 0.9); }
.mic-btn:active { transform: scale(0.97); }

.mic-btn[data-state="on"] {
  border-color: rgba(47, 211, 165, 0.5);
  background: linear-gradient(135deg, rgba(47, 211, 165, 0.92), rgba(56, 189, 248, 0.88));
  box-shadow: 0 8px 24px -8px rgba(47, 211, 165, 0.8);
}

.mic-btn[data-state="muted"] {
  border-color: rgba(255, 107, 129, 0.45);
  background: linear-gradient(135deg, rgba(255, 107, 129, 0.9), rgba(200, 80, 120, 0.9));
  box-shadow: 0 8px 24px -8px rgba(255, 107, 129, 0.7);
}

.mic-btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.mic-icon { display: grid; place-items: center; }

.chat-form {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 6px 0 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  transition: 0.2s;
}

.chat-form:focus-within {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(91, 140, 255, 0.45);
}

.chat-form input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}

.chat-form input::placeholder { color: var(--text-mute); }

.send-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: none;
  background: rgba(91, 140, 255, 0.9);
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: 0.18s;
}

.send-btn:hover { background: rgba(91, 140, 255, 1); }

/* ---------- 杂项 ---------- */
.audio-sink { position: absolute; width: 0; height: 0; overflow: hidden; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translate(-50%, 12px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(20, 25, 40, 0.94);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: 0.28s ease;
  z-index: 50;
  max-width: 84vw;
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .avatar { width: 48px; height: 48px; font-size: 16px; }
  .seats { gap: 10px 8px; }
  .room-head h1 { font-size: 18px; }
  .mic-btn { padding: 0 14px; }
}

@media (min-height: 780px) and (min-width: 520px) {
  .app {
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.45);
  }
}

/* ---------- 麦位操作面板 ---------- */
.sheet-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.sheet-wrap.show { opacity: 1; }

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 5, 10, 0.6);
  backdrop-filter: blur(3px);
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 10px calc(10px + var(--safe-b));
  padding: 8px 8px 6px;
  border-radius: 22px;
  background: #151a2b;
  border: 1px solid var(--line);
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.5);
  transform: translateY(18px);
  transition: transform 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.sheet-wrap.show .sheet { transform: none; }

.sheet-title {
  padding: 12px 14px 10px;
  font-size: 12.5px;
  color: var(--text-mute);
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.sheet-item,
.sheet-cancel {
  display: block;
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.sheet-item:hover,
.sheet-cancel:hover { background: rgba(255, 255, 255, 0.06); }

.sheet-item.danger { color: var(--danger); }

.sheet-cancel {
  margin-top: 4px;
  color: var(--text-mute);
  border-top: 1px solid var(--line);
  border-radius: 0 0 16px 16px;
}

/* ---------- 传输模式标识 ---------- */
.mode-chip {
  margin-left: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: 0.3px;
  color: #9ff0d4;
  background: rgba(47, 211, 165, 0.1);
  border: 1px solid rgba(47, 211, 165, 0.3);
}

/* ---------- 非安全上下文提示 ---------- */
.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 9px 14px;
  font-size: 12.5px;
  color: #ffd7a8;
  background: rgba(255, 184, 107, 0.13);
  border-bottom: 1px solid rgba(255, 184, 107, 0.3);
}

.banner[hidden] { display: none; }

.banner a {
  color: #ffd7a8;
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (max-width: 380px) {
  .seat-grid .seat { padding: 8px 2px 7px; }
  .seat-grid .avatar { width: 44px; height: 44px; font-size: 15px; }
  .seat-host .seat { width: 112px; }
  .seat-host .avatar { width: 58px; height: 58px; }
}

/* ---------- 顶部工具栏 / 扬声器音量 ---------- */
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-dim);
  font-size: 12px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: 0.2s;
}

.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn[aria-expanded="true"] { border-color: rgba(91, 140, 255, 0.5); color: #bcd0ff; }

.vol-panel {
  position: absolute;
  top: 62px;
  right: 18px;
  z-index: 40;
  width: 268px;
  padding: 14px 16px 12px;
  border-radius: 16px;
  background: #151a2b;
  border: 1px solid var(--line);
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.5);
}

.vol-panel[hidden] { display: none; }

.vol-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.vol-row output {
  color: #bcd0ff;
  font-variant-numeric: tabular-nums;
}

.vol-panel input[type="range"] {
  width: 100%;
  height: 30px;
  accent-color: var(--accent);
  cursor: pointer;
}

.vol-mute {
  width: 100%;
  margin-top: 8px;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-dim);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
  transition: 0.18s;
}

.vol-mute:hover { background: rgba(255, 255, 255, 0.09); }
.vol-mute[aria-pressed="true"] {
  color: var(--danger);
  border-color: rgba(255, 107, 129, 0.4);
  background: rgba(255, 107, 129, 0.12);
}

/* ---------- 无障碍基础 ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible {
  outline: 2px solid #9fbcff;
  outline-offset: 3px;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid #9fbcff;
  outline-offset: 2px;
  border-radius: 10px;
}

.seat:focus-visible {
  outline: 2px solid #9fbcff;
  outline-offset: 3px;
  background: rgba(91, 140, 255, 0.12);
}

/* 提高次要文字的对比度，满足 4.5:1 */
:root {
  --text-dim: #aeb6c9;
  --text-mute: #8d95a9;
}

/* 系统开启"减少动态效果"时关掉所有动画 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- 操作面板里的个人音量 ---------- */
.sheet-vol {
  padding: 10px 12px 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}

.sheet-vol input[type="range"] {
  width: 100%;
  height: 30px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ---------- 锁房按钮（仅主持麦可见） ---------- */
.lock-btn[hidden] { display: none; }

.lock-btn[aria-pressed="true"] {
  color: #ffd479;
  border-color: rgba(255, 212, 121, 0.45);
  background: rgba(255, 212, 121, 0.12);
}
