/* ===========================================================================
 * ChatRoom · 网页端样式
 * ---------------------------------------------------------------------------
 * 极简：入口一个框，房内两个按钮。没有多余的东西。
 *
 * ⚠ 三条老内核铁律（Chrome 55 / vivo X9 自带浏览器）：
 *   ① 不写 `inset`（除非四条边都另写一遍）—— 不认识就整条丢弃，
 *      定位和尺寸一起没 → 元素跑到文档流末尾、视口之外 →
 *      「点了没反应」。这个坑在 roomtalk 上真机实测过。
 *   ② `clamp()` / `max()` / `min()` / `env()` 前面**必须**有一条纯单位兜底。
 *   ③ `display:grid` 的居中在 57 之前不默认开启 → 关键居中用 flex。
 * =========================================================================== */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #14171a;
  --muted: #697586;
  --line: #e3e6ea;
  --accent: #2f6df6;
  --accent-ink: #ffffff;
  --danger: #e24b4a;
  --ok: #12a150;
  --radius: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #e8eaed;
    --muted: #98a2b3;
    --line: #262b36;
    --accent: #4a83ff;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
.hide { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ══════════════ 入口页 ══════════════ */

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

.gate-inner {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.logo {
  margin: 0;
  font-size: 24px;
  font-size: clamp(24px, 7vw, 30px);
  font-weight: 700;
  letter-spacing: -.01em;
}

.tagline {
  margin: 8px 0 26px;
  color: var(--muted);
  font-size: 13px;
  font-size: clamp(13px, 3.6vw, 14px);
  line-height: 1.7;
}

.pass {
  display: block;
  width: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 17px;          /* 16px 以下 iOS 会自动放大页面 */
  text-align: center;
  letter-spacing: .06em;
  -webkit-appearance: none;
  appearance: none;
}
.pass:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, .16);
}
.pass::placeholder { color: var(--muted); letter-spacing: normal; }

.btn-enter {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 15px 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.btn-enter:disabled { opacity: .6; }
.btn-enter:active { filter: brightness(.94); }

.err {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-size: clamp(13px, 3.5vw, 14px);
}

.linkish {
  margin-top: 20px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  font-size: clamp(13px, 3.5vw, 14px);
  text-decoration: underline;
  cursor: pointer;
}

/* ══════════════ 房内 ══════════════ */

.room {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 18px 22px;
  /* ⚠ 用 padding-bottom 而不是 margin —— 老 WebView 的 margin 折叠行为不一致 */
  padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
}

.room-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 12px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}

.count {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.timer {
  font-size: 13px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
}

.speaking {
  padding: 18px 26px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .04em;
}

.room-bottom {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding-top: 18px;
}

/* 麦克风：够大够好按（手机上 16px 的图标根本点不中）。 */
.mic {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.mic:active { filter: brightness(.94); }
.mic.off {
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
}

.leave {
  padding: 15px 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.leave:active { filter: brightness(.94); }

/* ══════════════ 首页下载悬浮图标 ══════════════ */

.dl-fab {
  position: fixed;
  /* ⚠ 不写 inset：Chrome 55 不认识 → 整条声明丢弃。四条边分开写。 */
  right: 16px;
  bottom: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 6px 18px rgba(47, 109, 246, .36);
  text-decoration: none;
  z-index: 70;
}
.dl-fab:active { filter: brightness(.94); }

/* ══════════════ 开始会话 / 等待房主 ══════════════ */

.room-session {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 4px;
  min-height: 0;
}

.start-session {
  padding: 11px 28px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.start-session:active { filter: brightness(.94); }

.wait-host {
  color: var(--muted);
  font-size: 13px;
  font-size: clamp(13px, 3.5vw, 14px);
}

/* 语音锁闭时麦克风按钮置灰、不可点。 */
.mic.locked { opacity: .5; }
.mic:disabled { opacity: .5; cursor: default; }

.timeout-end {
  display: block;
  width: 100%;
  margin-top: 12px;
}

/* ══════════════ 留言弹层 ══════════════ */

.modal {
  position: fixed;
  /* ⚠⚠ 必须四条边分开写，`inset` 只是省事的等价写法，**不能只有 inset**：
     Chrome 55 不认识 inset，整条声明丢弃 → 弹层没有定位也没有尺寸，
     被排到文档流末尾（视口之外）→ 用户点「留言」**看着像完全没反应**
     （roomtalk 2026-10-24 真机实测定位到这条）。 */
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  inset: 0;
  z-index: 60;
  display: flex;
  /* safe center 是 Chrome 93+ 的写法，老浏览器整条丢弃 → align-items 回到
     默认的 stretch，卡片被拉成整屏高。兜底用 flex-start。 */
  align-items: flex-start;
  align-items: safe center;
  justify-content: center;
  padding: 14px;
  padding: clamp(14px, 4vw, 24px);
  background: rgba(10, 14, 22, .58);
  overflow-y: auto;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  padding: 20px 18px 18px;
  padding: clamp(20px, 5.4vw, 26px) clamp(18px, 5vw, 24px) clamp(18px, 5vw, 22px);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(8, 12, 24, .28);
  text-align: center;
}

.modal-x {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
}
.modal-x:hover { background: var(--bg); color: var(--text); }

.modal-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-size: clamp(17px, 4.6vw, 19px);
  font-weight: 700;
}

.note-window {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-size: clamp(13px, 3.5vw, 14px);
}

.note-text {
  display: block;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.6;
  resize: vertical;
  -webkit-appearance: none;
  appearance: none;
}
.note-text:focus {
  outline: none;
  border-color: var(--accent);
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.note-rec {
  flex: 0 0 auto;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.note-rec.recording {
  border-color: var(--danger);
  color: var(--danger);
}

.rec-state {
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}

.audio-wrap {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.audio-wrap audio { width: 100%; }

.note-qr {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.note-qr-lead {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-size: clamp(13px, 3.5vw, 14px);
}
.note-qr img {
  display: block;
  margin: 0 auto;
  width: 132px;
  height: 132px;
  border-radius: 8px;
  background: #fff;
}

/* ══════════════ 提示 ══════════════ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: 86vw;
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(20, 23, 26, .92);
  color: #fff;
  font-size: 13px;
  font-size: clamp(13px, 3.5vw, 14px);
  text-align: center;
  z-index: 80;
}
