/* 字号统一由 --fs 驱动（默认 26px，A+/A− 以 0.25 档可调） */
:root { --fs: 26px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, sans-serif;
  background: #d9d9d9; display: flex; justify-content: center; align-items: center;
  color: #191919;
}
.app {
  width: 100%; max-width: 980px; height: 100vh;
  background: #ededed; display: flex; flex-direction: column; position: relative;
  box-shadow: 0 0 24px rgba(0,0,0,.12);
}

/* ---------- header ---------- */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #ededed; border-bottom: 1px solid #dcdcdc;
  flex: 0 0 auto; gap: 10px;
}
.h-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.h-avatar {
  width: 46px; height: 46px; border-radius: 8px; background: #ffb020; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px;
  flex: 0 0 auto;
}
.h-title { font-size: 21px; font-weight: 700; }
.h-sub { font-size: 15px; color: #8b8b8b; margin-top: 3px; }
.h-right { display: flex; gap: 8px; flex: 0 0 auto; }
.icon-btn {
  border: none; background: #fff; color: #666; min-width: 42px; height: 42px; padding: 0 10px;
  border-radius: 21px; font-size: 17px; cursor: pointer; line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,.1); font-weight: 600;
}
.icon-btn:hover { background: #f5f5f5; }
.icon-btn.off { background: #f1f3f5; color: #98a2b3; }
/* 自动刷新开关：开启时绿色，暂停时灰色 */
#btnAuto { min-width: 74px; font-variant-numeric: tabular-nums; background: #e7f8ee; color: #07994a; }
#btnAuto.off { background: #f1f3f5; color: #98a2b3; }
#btnAuto.off:hover { background: #e9ecef; }

/* ---------- chat ---------- */
.chat { flex: 1 1 auto; overflow-y: auto; padding: 18px 18px 8px; }
.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-thumb { background: #c8c8c8; border-radius: 4px; }

.row { display: flex; gap: 14px; margin-bottom: 22px; align-items: flex-start; }
.row.me { flex-direction: row-reverse; }
.avatar {
  width: calc(var(--fs) * 1.3); height: calc(var(--fs) * 1.3);
  border-radius: 8px; flex: 0 0 auto; color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: calc(var(--fs) * 0.6); user-select: none;
}
.bubble-wrap { max-width: 70%; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.row.me .bubble-wrap { align-items: flex-end; }
.name { font-size: calc(var(--fs) * 0.58); color: #8b8b8b; padding: 0 6px; }
.bubble {
  position: relative; padding: 12px 16px; border-radius: 8px; background: #fff;
  font-size: var(--fs); line-height: 1.5; word-wrap: break-word; white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,.06); max-width: 100%;
}
.row.me .bubble { background: #95ec69; }
.row.me.peer .bubble { background: #d6ecff; }   /* 其他学生/老师：靠右但蓝色气泡 */
.bubble .cn {
  font-size: calc(var(--fs) * 0.6); color: #7b7b7b; margin-top: 8px;
  border-top: 1px dashed #e6e6e6; padding-top: 8px;
}
.actions { display: flex; gap: 12px; align-items: center; padding: 0 6px; }
.spk {
  border: none; background: none; cursor: pointer; color: #5b8ff9;
  font-size: calc(var(--fs) * 0.58); display: inline-flex; align-items: center; gap: 4px; padding: 0;
}
.spk:hover { text-decoration: underline; }
.sys-line { text-align: center; font-size: calc(var(--fs) * 0.55); color: #9a9a9a; margin: 14px 0 20px; }
.sys-line span { background: #dcdcdc; color: #6b6b6b; padding: 5px 14px; border-radius: 14px; display: inline-block; }
.time { text-align: center; font-size: calc(var(--fs) * 0.5); color: #a8a8a8; margin: 4px 0 14px; }

/* typing */
.typing { display: flex; gap: 6px; padding: 6px 2px; }
.typing i { width: 10px; height: 10px; background: #b6b6b6; border-radius: 50%; animation: bl 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes bl { 0%,60%,100% { opacity: .3; transform: translateY(0);} 30% { opacity: 1; transform: translateY(-4px);} }

/* ---------- status ---------- */
.status { flex: 0 0 auto; font-size: calc(var(--fs) * 0.55); color: #8b8b8b; padding: 4px 20px 0; height: calc(var(--fs) * 0.8); }
.status.rec { color: #e03131; font-weight: 600; }

/* ---------- composer ---------- */
.composer {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px 10px; background: #f7f7f7; border-top: 1px solid #dcdcdc;
}
.composer input {
  flex: 1 1 auto; border: 1px solid #e0e0e0; background: #fff; border-radius: 8px;
  padding: 12px 14px; font-size: calc(var(--fs) * 0.85); outline: none; min-width: 0;
  font-family: inherit;
}
.composer input:focus { border-color: #b7d8a0; }
.send {
  border: none; background: #07c160; color: #fff; padding: 13px 24px; border-radius: 8px;
  font-size: calc(var(--fs) * 0.62); cursor: pointer; font-weight: 700; flex: 0 0 auto;
}
.send:disabled { background: #c6e6d2; cursor: not-allowed; }
.mic {
  width: calc(var(--fs) * 2.6); height: calc(var(--fs) * 2.6); flex: 0 0 auto;
  border-radius: 50%; border: none; cursor: pointer;
  background: #e7f8ee; color: #07994a; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.14); transition: all .15s;
}
.mic svg { width: calc(var(--fs) * 1.3); height: calc(var(--fs) * 1.3); }
.mic:hover { background: #d2f2e0; }
.mic.rec { background: #e03131; color: #fff; animation: pulse 1.1s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(224,49,49,.5);} 70% { box-shadow: 0 0 0 16px rgba(224,49,49,0);} 100% { box-shadow: 0 0 0 0 rgba(224,49,49,0);} }

.me-bar {
  flex: 0 0 auto; background: #f7f7f7; padding: 0 16px 10px;
  font-size: calc(var(--fs) * 0.55); color: #8b8b8b;
}
.me-bar b { color: #07c160; cursor: pointer; }

.audio-hint {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(0,0,0,.78); color: #fff; padding: 12px 22px; border-radius: 24px;
  font-size: 17px; z-index: 30; pointer-events: none; animation: fadeIn .3s;
}
.audio-hint.clickable { pointer-events: auto; cursor: pointer; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- modal ---------- */
.mask { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: none; z-index: 20; }
.mask.show { display: block; }
.modal {
  position: fixed; z-index: 21; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(820px, 92vw); max-height: 82vh; background: #fff; border-radius: 12px;
  display: none; flex-direction: column; overflow: hidden;
}
.modal.show { display: flex; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; background: #f7f7f7; border-bottom: 1px solid #eee; font-weight: 700; font-size: 18px; }
.modal-b { padding: 18px; overflow-y: auto; font-size: 17px; line-height: 1.75; }
.modal-b h4 { margin: 16px 0 8px; font-size: 16px; color: #e8590c; }
.modal-b p { margin: 0 0 10px; color: #333; }
.modal-b .seed { background: #fafafa; border-left: 4px solid #ddd; padding: 10px 12px; border-radius: 5px; color: #444; }

@media (max-width: 640px) {
  .bubble-wrap { max-width: 80%; }
  .h-title { font-size: 17px; }
  .h-sub { font-size: 12px; }
}

/* ---------- access code box ---------- */
.code-box { width: min(420px, 92vw); }
.code-err { color: #e03131; min-height: 20px; margin: 0 0 8px; font-size: 15px; }
.code-box input {
  width: 100%; padding: 12px 14px; font-size: 17px; border: 1px solid #ddd;
  border-radius: 8px; outline: none; font-family: inherit;
}
.code-box input:focus { border-color: #b7d8a0; }
.code-ok {
  margin-top: 12px; width: 100%; padding: 12px; border: none; border-radius: 8px;
  background: #07c160; color: #fff; font-size: 17px; font-weight: 700; cursor: pointer;
}
