:root {
  --bg: #0b1528;
  --panel: rgba(15, 23, 42, .78);
  --line: #1e293b;
  --line-2: #334155;
  --txt: #e2e8f0;
  --dim: #94a3b8;
  --dim-2: #64748b;
  --acc: #4facfe;
  --acc-2: #00f2fe;
  --ok: #10b981;
  --rec: #ef4444;
  --warn: #f59e0b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC',
               'Hiragino Sans GB', 'Microsoft YaHei', Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 16px 28px;
}

.app { width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 12px; }

/* ── 顶部 ─────────────────────────────────────── */
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--dim); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim-2); flex: none; }
.dot.on   { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.busy { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.dot.err  { background: var(--rec); box-shadow: 0 0 8px var(--rec); }
.pill {
  font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 20px; border: 1px solid var(--line-2);
  color: var(--dim); white-space: nowrap;
}

/* ── 场景 ─────────────────────────────────────── */
.scene-box {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.scene-box label { font-size: 11px; color: var(--dim-2); flex: none; }
.scene-box select {
  flex: 1; background: #0f172a; color: var(--txt);
  border: 1px solid var(--line-2); border-radius: 8px;
  padding: 7px 9px; font-size: 13px; outline: none;
}
.goals { margin-top: 8px; font-size: 11px; color: var(--dim-2); line-height: 1.7; }
.goals b { color: var(--acc); font-weight: 500; }

/* ── 头像 + 波形 ──────────────────────────────── */
.stage {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px 16px 18px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.avatar {
  width: 96px; height: 96px; border-radius: 50%;
  background: linear-gradient(135deg, var(--acc) 0%, var(--acc-2) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 42px; box-shadow: 0 0 26px rgba(79, 172, 254, .28);
  transition: box-shadow .25s;
}
.avatar.active { animation: pulse 1.5s infinite ease-in-out; }
@keyframes pulse {
  0%,100% { transform: scale(1);    box-shadow: 0 0 20px rgba(79,172,254,.30); }
  50%     { transform: scale(1.06); box-shadow: 0 0 40px rgba(79,172,254,.60); }
}
.coach-name { font-size: 16px; font-weight: 500; }
.status { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--acc); }

/* 波形（验收硬指标：说话时必须跳） */
.wave {
  width: 100%; height: 44px; display: flex; align-items: center;
  gap: 3px; justify-content: center;
}
.wave i {
  display: block; width: 3px; height: 3px; border-radius: 2px;
  background: var(--acc); opacity: .55; transition: height .06s linear;
}
.wave.hot i { background: var(--rec); opacity: .9; }

/* ── 字幕 ─────────────────────────────────────── */
.subs { display: flex; flex-direction: column; gap: 8px; min-height: 96px; }
.sub {
  background: rgba(255,255,255,.04); border-left: 2px solid var(--line-2);
  border-radius: 8px; padding: 9px 12px; font-size: 15px; line-height: 1.55;
  word-break: break-word;
}
.sub.user { border-left-color: var(--ok); color: #cbd5e1; }
.sub.ai   { border-left-color: var(--acc); }
.sub .who {
  display: block; font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--dim-2); margin-bottom: 3px;
}
.sub.warn { border-left-color: var(--warn); font-size: 12px; color: var(--warn); }
.sub.err  { border-left-color: var(--rec); font-size: 12px; color: #fca5a5; }
.caret { display: inline-block; width: 7px; background: var(--acc); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ── 底部控件 ─────────────────────────────────── */
.controls { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 4px; }
.mic {
  width: 78px; height: 78px; border-radius: 50%; border: none;
  background: var(--ok); color: #fff; font-size: 30px; cursor: pointer;
  box-shadow: 0 4px 20px rgba(16,185,129,.4); transition: all .18s;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.mic:disabled { background: var(--line-2); box-shadow: none; cursor: not-allowed; }
.mic.rec { background: var(--rec); box-shadow: 0 4px 20px rgba(239,68,68,.45); }
.mic.live { background: var(--acc); box-shadow: 0 0 0 0 rgba(79,172,254,.5); }
.mic.live::after { content: ''; }

.row { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.ghost {
  background: none; border: 1px solid var(--line-2); color: var(--dim-2);
  padding: 6px 13px; border-radius: 16px; font-size: 11px; cursor: pointer;
}
.ghost:hover { color: var(--rec); border-color: var(--rec); }
.ghost:disabled { opacity: .4; cursor: not-allowed; }

.speed { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--dim-2); }
.speed input { width: 130px; accent-color: var(--acc); }
.speed span { color: var(--acc); width: 34px; }

.hint { font-size: 11px; color: var(--dim-2); text-align: center; line-height: 1.6; }

/* 指标条 */
.metrics {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  font-size: 10px; color: var(--dim-2);
}
.metrics b { color: var(--dim); font-weight: 500; }

@media (prefers-color-scheme: light) {
  /* 本 App 固定深色（口语陪练场景多为夜间/室内），不做浅色反转 */
}

/* ══════════════════════════════════════════════════════════════
   FR-01-02 · AI 身份常驻标识
   要求：每个对话页可见、字号 ≥ 正文 80%、不得折叠、无关闭入口。
   本页正文为 15px，此处 12.5px（≈83%）满足下限。
   ══════════════════════════════════════════════════════════════ */
.ai-badge {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 12.5px; color: var(--dim);
  padding: 5px 10px;
  border: 1px solid rgba(79, 172, 254, .22);
  border-radius: 999px;
  background: rgba(79, 172, 254, .06);
  margin: 0 auto 8px;
  width: fit-content;
  max-width: 100%;
  user-select: none;
  /* 刻意不加 cursor:pointer、不加 hover 变色 —— 它不是一个可交互/可关闭的控件 */
}
.ai-badge .ai-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--acc); box-shadow: 0 0 6px var(--acc);
  flex: none;
}

/* 小按钮（进度入口） */
.mini {
  margin-left: auto;
  font: inherit; font-size: 12px;
  padding: 5px 11px;
  color: var(--acc);
  background: rgba(79, 172, 254, .1);
  border: 1px solid rgba(79, 172, 254, .3);
  border-radius: 999px;
  cursor: pointer;
}
.mini:active { transform: scale(.96); }

/* ══════════════════════════════════════════════════════════════
   首启门禁（FR-01-01 隐私说明 / FR-01-03 邀请码）
   ══════════════════════════════════════════════════════════════ */
/* ★★★ 这一条必须有（2026-09-26 真机实测踩坑）：
   HTML 的 hidden 属性只靠浏览器默认样式 [hidden]{display:none} 生效，
   而**任何 CSS 里给该元素写的 display 都会盖掉它**。本项目 .gate 恰好是
   `display: flex`，于是「隐藏门禁」静默失效 —— WS 连上了、AI 开场白也播了，
   用户却还看着门禁页、看不到麦克风按钮（因为门禁一直盖在最上层）。
   症状极具误导性：**功能全通，只有界面卡住**，且控制台无任何报错。
   !important 是为了防止以后新增的 display 再把它盖掉。 */
[hidden] { display: none !important; }

.gate {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 11, 22, .96);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 18px;
  overflow-y: auto;
}
.gate-card {
  width: 100%; max-width: 460px;
  background: #101c33;
  border: 1px solid var(--line-2);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
}
.gate-h { font-size: 17px; font-weight: 600; margin-bottom: 12px; }
.gate-body { font-size: 14px; line-height: 1.7; color: var(--txt); }
.gate-body p { margin: 0 0 10px; }
.gate-body ul { margin: 6px 0 12px; padding-left: 19px; }
.gate-body li { margin-bottom: 5px; color: var(--dim); }
.gate-body strong { color: #fff; }
.gate-warn {
  background: rgba(245, 158, 11, .09);
  border-left: 3px solid var(--warn);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 12px 0;
  font-size: 13px;
}
.gate-warn ul { margin: 6px 0 0; }
.gate-link {
  display: inline-block; color: var(--acc); text-decoration: none;
  font-size: 13.5px; margin-top: 4px;
}
.gate-actions { display: flex; gap: 10px; margin-top: 18px; }
.gate-btn {
  flex: 1;
  font: inherit; font-size: 15px; font-weight: 500;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: transparent;
  color: var(--txt);
  cursor: pointer;
}
.gate-btn.primary {
  border: none;
  background: linear-gradient(135deg, var(--acc), var(--acc-2));
  color: #05121f; font-weight: 600;
}
.gate-btn:active { transform: scale(.985); }
.gate-input {
  width: 100%;
  font: inherit; font-size: 18px; font-weight: 600;
  letter-spacing: .12em; text-align: center;
  padding: 13px 12px;
  margin-top: 8px;
  color: #fff;
  background: #0a1526;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  text-transform: uppercase;
}
.gate-input:focus { outline: none; border-color: var(--acc); box-shadow: 0 0 0 3px rgba(79,172,254,.15); }
.gate-msg { min-height: 19px; font-size: 13px; margin-top: 7px; color: var(--dim-2); }
.gate-msg.err { color: var(--rec); }
.gate-msg.ok { color: var(--ok); }

/* ══════════════════════════════════════════════════════════════
   进度面板（FR-07）
   ══════════════════════════════════════════════════════════════ */
.sheet {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(5, 11, 22, .72);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 460px;
  background: #101c33;
  border: 1px solid var(--line-2);
  border-bottom: none;
  border-radius: 18px 18px 0 0;
  padding: 16px 18px calc(22px + env(safe-area-inset-bottom));
  max-height: 84vh; overflow-y: auto;
  animation: sheetUp .22s ease-out;
}
@keyframes sheetUp { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-h {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 16px; font-weight: 600; margin-bottom: 14px;
}
.sheet-x {
  font: inherit; font-size: 16px; line-height: 1;
  background: none; border: none; color: var(--dim);
  cursor: pointer; padding: 4px 6px;
}

/* 进度指标网格 */
.pg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 16px; }
.pg-cell {
  background: #0a1526; border: 1px solid var(--line);
  border-radius: 11px; padding: 12px 8px; text-align: center;
}
.pg-num { font-size: 21px; font-weight: 700; color: var(--acc); line-height: 1.25; }
.pg-num small { font-size: 12px; font-weight: 500; color: var(--dim); margin-left: 1px; }
.pg-lab { font-size: 11.5px; color: var(--dim-2); margin-top: 3px; }

.pg-sec { font-size: 13px; color: var(--dim); margin: 15px 0 8px; }
.pg-today {
  background: #0a1526; border: 1px solid var(--line); border-radius: 11px;
  padding: 13px; font-size: 13.5px; color: var(--txt);
}
.pg-bar {
  height: 7px; border-radius: 999px; background: #16233d;
  overflow: hidden; margin-top: 9px;
}
.pg-bar i { display: block; height: 100%; border-radius: 999px;
            background: linear-gradient(90deg, var(--acc), var(--acc-2)); }
.pg-days { display: flex; gap: 5px; flex-wrap: wrap; }
.pg-day {
  width: 30px; text-align: center; font-size: 10px; color: var(--dim-2);
}
.pg-day b {
  display: block; height: 22px; border-radius: 5px;
  background: #16233d; margin-bottom: 3px;
}
.pg-day.on b { background: linear-gradient(180deg, var(--acc), #1f6fb2); }
.pg-note {
  font-size: 12.5px; color: var(--dim-2); line-height: 1.6;
  margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
