DialogueChatView.vue 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859
  1. <template>
  2. <div class="dialogue-chat-view">
  3. <!-- ── HEADER ── -->
  4. <div class="chat-header">
  5. <div class="header-left">
  6. <div
  7. class="ai-avatar"
  8. :class="{ breathing: state === 'idle' || state === 'ai_thinking' }"
  9. >{{ aiAvatar }}</div>
  10. <span class="ai-name">{{ aiName }}</span>
  11. <span v-if="state === 'idle' && showIdleHint" class="idle-hint fade-in">
  12. 在等你的回答...
  13. </span>
  14. <span
  15. v-else-if="state !== 'idle' && state !== 'ai_thinking'"
  16. class="online-dot"
  17. title="在线"
  18. />
  19. </div>
  20. <div class="header-right">
  21. <span class="round-indicator">{{ currentRound }} / {{ totalRounds }} 轮</span>
  22. <span v-if="engine.countdownSeconds.value != null" class="total-time">
  23. {{ formatSeconds(engine.countdownSeconds.value) }}
  24. </span>
  25. <button class="icon-btn" title="更多操作" @click="showExitConfirm = true">
  26. <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  27. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  28. <circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />
  29. </svg>
  30. </button>
  31. </div>
  32. </div>
  33. <!-- 麦克风权限引导 -->
  34. <div v-if="recorder.permissionState.value === 'denied'" class="permission-banner">
  35. <span class="permission-icon">🎤</span>
  36. <span>麦克风权限已被拒绝,请在浏览器设置中开启后刷新页面</span>
  37. </div>
  38. <!-- ── CHAT AREA ── -->
  39. <div ref="chatContainerRef" class="chat-area">
  40. <template v-for="message in engine.messages.value" :key="message.id">
  41. <!-- AI 消息 -->
  42. <div v-if="message.role === 'ai'" class="msg-row msg-ai fade-in">
  43. <div class="avatar-sm">{{ aiAvatar }}</div>
  44. <div class="msg-col">
  45. <!-- 音频条 -->
  46. <div v-if="message.content || message.status === 'done'" class="voice-bar voice-ai">
  47. <button
  48. class="play-btn play-ai"
  49. :class="{ 'play-btn-error': player.errorId.value === message.id }"
  50. @click="togglePlay(message.id)"
  51. >
  52. <svg
  53. v-if="player.loadingId.value === message.id"
  54. class="play-spinner"
  55. width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  56. stroke-width="2" stroke-linecap="round"
  57. >
  58. <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  59. </svg>
  60. <svg
  61. v-else-if="player.playingId.value === message.id"
  62. width="12" height="12" viewBox="0 0 24 24" fill="currentColor"
  63. >
  64. <rect x="6" y="4" width="4" height="16" /><rect x="14" y="4" width="4" height="16" />
  65. </svg>
  66. <svg
  67. v-else-if="player.errorId.value === message.id"
  68. width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  69. stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  70. >
  71. <path d="M12 9v4" />
  72. <path d="M12 17h.01" />
  73. <path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" />
  74. </svg>
  75. <svg
  76. v-else
  77. width="12" height="12" viewBox="0 0 24 24" fill="currentColor"
  78. >
  79. <polygon points="5 3 19 12 5 21 5 3" />
  80. </svg>
  81. </button>
  82. <div class="wave-bar-group">
  83. <div
  84. v-for="i in 14"
  85. :key="i"
  86. class="wave-bar wave-ai"
  87. :style="{ height: `${Math.abs(Math.sin(i * 0.7)) * 8 + 3}px` }"
  88. />
  89. </div>
  90. <span
  91. v-if="player.errorId.value === message.id"
  92. class="play-error-hint"
  93. >点击重试</span>
  94. <span
  95. v-else
  96. class="voice-duration voice-duration-ai"
  97. >0:04</span>
  98. </div>
  99. <!-- 英文文本 -->
  100. <div v-if="showEnglishText && message.content" class="bubble bubble-ai">
  101. {{ message.content }}
  102. </div>
  103. <!-- 流式加载中 -->
  104. <div v-if="message.status === 'loading' && !message.content" class="typing-bubble">
  105. <span class="typing-dot" style="animation-delay: 0ms" />
  106. <span class="typing-dot" style="animation-delay: 150ms" />
  107. <span class="typing-dot" style="animation-delay: 300ms" />
  108. </div>
  109. <!-- AI 错误 -->
  110. <div v-if="message.status === 'error'" class="error-card">
  111. <span class="error-text">{{ message.error || '生成失败' }}</span>
  112. <button
  113. v-if="hasRetryButton(message)"
  114. class="retry-btn"
  115. :disabled="engine.greetingInflight.value"
  116. @click="handleRetry(message)"
  117. >{{ retryButtonLabel(message) }}</button>
  118. </div>
  119. </div>
  120. </div>
  121. <!-- 学生消息 -->
  122. <div v-else class="msg-row msg-student fade-in">
  123. <!-- 音频条(橙色) -->
  124. <div v-if="message.content || message.status !== 'loading'" class="voice-bar voice-student">
  125. <span
  126. v-if="player.errorId.value === message.id"
  127. class="play-error-hint play-error-hint-student"
  128. >点击重试</span>
  129. <span
  130. v-else
  131. class="voice-duration voice-duration-student"
  132. >0:04</span>
  133. <div class="wave-bar-group">
  134. <div
  135. v-for="i in 14"
  136. :key="i"
  137. class="wave-bar wave-student"
  138. :style="{ height: `${Math.abs(Math.sin(i * 0.7)) * 8 + 3}px` }"
  139. />
  140. </div>
  141. <button
  142. class="play-btn play-student"
  143. :class="{ 'play-btn-error': player.errorId.value === message.id }"
  144. @click="togglePlay(message.id)"
  145. >
  146. <svg
  147. v-if="player.loadingId.value === message.id"
  148. class="play-spinner"
  149. width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  150. stroke-width="2" stroke-linecap="round"
  151. >
  152. <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  153. </svg>
  154. <svg
  155. v-else-if="player.playingId.value === message.id"
  156. width="12" height="12" viewBox="0 0 24 24" fill="currentColor"
  157. >
  158. <rect x="6" y="4" width="4" height="16" /><rect x="14" y="4" width="4" height="16" />
  159. </svg>
  160. <svg
  161. v-else-if="player.errorId.value === message.id"
  162. width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  163. stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  164. >
  165. <path d="M12 9v4" />
  166. <path d="M12 17h.01" />
  167. <path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" />
  168. </svg>
  169. <svg
  170. v-else
  171. width="12" height="12" viewBox="0 0 24 24" fill="currentColor"
  172. >
  173. <polygon points="5 3 19 12 5 21 5 3" />
  174. </svg>
  175. </button>
  176. </div>
  177. <!-- 英文识别文本(带高亮) -->
  178. <div v-if="showEnglishText && message.content" class="bubble bubble-student">
  179. <template v-if="message.evaluation?.wordAnalysis">
  180. <template v-for="(word, idx) in message.content.split(' ')" :key="idx">
  181. <span
  182. v-if="getWordAnalysis(message, word)?.status === 'improvable'"
  183. class="improvable-word"
  184. @click="openPhonemeDetail(getWordAnalysis(message, word)!)"
  185. >{{ word }}</span>
  186. <span v-else>{{ word }}</span>
  187. {{ ' ' }}
  188. </template>
  189. </template>
  190. <template v-else>{{ message.content }}</template>
  191. </div>
  192. <!-- 学生错误 -->
  193. <div v-if="message.status === 'error'" class="error-card">
  194. <span class="error-text">{{ message.error || '发送失败' }}</span>
  195. <button
  196. v-if="hasRetryButton(message)"
  197. class="retry-btn"
  198. @click="handleRetry(message)"
  199. >{{ retryButtonLabel(message) }}</button>
  200. <button
  201. v-if="hasRerecordButton(message)"
  202. class="rerecord-btn"
  203. @click="handleRerecord(message)"
  204. >重录</button>
  205. </div>
  206. <!-- L1 评分卡 -->
  207. <div v-if="message.evaluation" class="eval-card">
  208. <div class="eval-l1">
  209. <div class="dim-row">
  210. <span class="dim-label">准确</span>
  211. <DimBadge :level="message.evaluation.dimensions.accuracy" />
  212. <span class="dim-sep">|</span>
  213. <span class="dim-label">流畅</span>
  214. <DimBadge :level="message.evaluation.dimensions.fluency" />
  215. <span class="dim-sep">|</span>
  216. <span class="dim-label">完整</span>
  217. <DimBadge :level="message.evaluation.dimensions.completeness" />
  218. <span class="dim-sep">|</span>
  219. <span class="dim-label">节奏</span>
  220. <DimBadge :level="message.evaluation.dimensions.rhythm" />
  221. </div>
  222. <div class="sugg-row">
  223. <p class="sugg-text">
  224. <span class="sugg-icon">💡</span>
  225. <span class="truncate">{{ message.evaluation.suggestion }}</span>
  226. </p>
  227. <button class="detail-toggle" @click="toggleExpand(message.id)">
  228. {{ expandedMessageId === message.id ? '收起' : '详情' }}
  229. <svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  230. stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
  231. :class="{ 'chev-up': expandedMessageId === message.id }">
  232. <polyline points="6 9 12 15 18 9" />
  233. </svg>
  234. </button>
  235. </div>
  236. </div>
  237. <div v-if="expandedMessageId === message.id" class="eval-l2 fade-in">
  238. <div v-if="message.evaluation.betterExpression" class="better-exp">
  239. <p class="detail-label"><span>✨</span> Better expression:</p>
  240. <p class="detail-content">{{ message.evaluation.betterExpression }}</p>
  241. </div>
  242. <div v-if="message.evaluation.suggestedWords?.length" class="suggested-words">
  243. <p class="detail-label"><span>🎯</span> Try these words:</p>
  244. <div class="word-tags">
  245. <span v-for="(w, i) in message.evaluation.suggestedWords" :key="i" class="word-tag">{{ w }}</span>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. </template>
  252. <!-- AI 思考(STT 或 ai_thinking 且无占位消息时展示) -->
  253. <div
  254. v-if="(state === 'stt' || state === 'ai_thinking') && !hasLoadingPlaceholder"
  255. class="msg-row msg-ai fade-in"
  256. >
  257. <div class="avatar-sm">{{ aiAvatar }}</div>
  258. <div class="typing-bubble">
  259. <span class="typing-dot" style="animation-delay: 0ms" />
  260. <span class="typing-dot" style="animation-delay: 150ms" />
  261. <span class="typing-dot" style="animation-delay: 300ms" />
  262. </div>
  263. </div>
  264. </div>
  265. <!-- 沉默提示浮层 -->
  266. <div v-if="state === 'recording' && silenceHintText" class="silence-hint-wrap">
  267. <div class="silence-hint fade-in">
  268. <span class="silence-icon">💡</span>
  269. <p class="silence-text">{{ silenceHintText }}</p>
  270. <button class="silence-close" @click="silenceHintText = ''">
  271. <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  272. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  273. <line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
  274. </svg>
  275. </button>
  276. </div>
  277. </div>
  278. <!-- ── CONTROL ZONE ── -->
  279. <div class="control-zone">
  280. <!-- 进度条(仅录音时可见) -->
  281. <div class="progress-wrap">
  282. <div
  283. class="progress-track"
  284. :style="{ background: state === 'recording' ? '#f3f4f6' : 'transparent' }"
  285. >
  286. <div
  287. class="progress-fill"
  288. :class="{ 'near-limit': isNearLimit }"
  289. :style="{
  290. width: state === 'recording' ? `${progressPct}%` : '0%',
  291. opacity: state === 'recording' ? 1 : 0,
  292. }"
  293. />
  294. </div>
  295. </div>
  296. <!-- 状态叠放区 -->
  297. <div class="state-stack">
  298. <!-- idle -->
  299. <div
  300. class="state-layer state-idle"
  301. :style="stateStyle('idle')"
  302. >
  303. <button class="hint-btn" @click="openTaskHint">
  304. <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  305. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  306. <path d="M9 18h6" /><path d="M10 22h4" />
  307. <path d="M15.09 14c.18-.98.65-1.74 1.41-2.5A4.65 4.65 0 0 0 18 8 6 6 0 0 0 6 8c0 1 .23 2.23 1.5 3.5A4.61 4.61 0 0 1 8.91 14" />
  308. </svg>
  309. 提示
  310. </button>
  311. <button
  312. class="mic-btn"
  313. :disabled="!engine.canRecord.value"
  314. @click="handleStartRecording"
  315. >
  316. <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  317. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  318. <path d="M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z" />
  319. <path d="M19 10v2a7 7 0 0 1-14 0v-2" />
  320. <line x1="12" y1="19" x2="12" y2="23" />
  321. <line x1="8" y1="23" x2="16" y2="23" />
  322. </svg>
  323. 开始录音
  324. </button>
  325. </div>
  326. <!-- starting -->
  327. <div class="state-layer state-starting" :style="stateStyle('starting')">
  328. <div class="record-capsule">
  329. <button class="cancel-btn" @click="handleCancelStarting">
  330. <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  331. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  332. <line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
  333. </svg>
  334. 取消
  335. </button>
  336. <div class="record-meter">
  337. <svg class="spinner" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  338. stroke-width="2" stroke-linecap="round">
  339. <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  340. </svg>
  341. <span class="record-time">准备录音中...</span>
  342. </div>
  343. <button class="finish-btn" disabled>
  344. <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  345. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  346. <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
  347. <polyline points="22 4 12 14.01 9 11.01" />
  348. </svg>
  349. 完成
  350. </button>
  351. </div>
  352. </div>
  353. <!-- recording -->
  354. <div class="state-layer state-recording" :style="stateStyle('recording')">
  355. <div class="record-capsule">
  356. <button class="cancel-btn" @click="handleCancelRecording">
  357. <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  358. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  359. <line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
  360. </svg>
  361. 取消
  362. </button>
  363. <div class="record-meter">
  364. <div class="animated-wave">
  365. <div
  366. v-for="i in 7"
  367. :key="i"
  368. class="aw-bar"
  369. :class="{ 'near-limit': isNearLimit }"
  370. :style="{
  371. height: `${Math.abs(Math.sin(i * 0.9)) * 9 + 3}px`,
  372. animationDelay: `${(i - 1) * 0.1}s`,
  373. }"
  374. />
  375. </div>
  376. <span class="record-time" :class="{ 'near-limit': isNearLimit }">
  377. {{ formatSeconds(recorder.recordingDuration.value) }}
  378. </span>
  379. <span class="record-time-max">/ {{ formatSeconds(MAX_RECORDING_SECONDS) }}</span>
  380. </div>
  381. <button class="finish-btn" @click="handleFinishRecording">
  382. <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  383. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  384. <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
  385. <polyline points="22 4 12 14.01 9 11.01" />
  386. </svg>
  387. 完成
  388. </button>
  389. </div>
  390. </div>
  391. <!-- stt -->
  392. <div class="state-layer state-center" :style="stateStyle('stt')">
  393. <svg class="spinner" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  394. stroke-width="2" stroke-linecap="round">
  395. <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  396. </svg>
  397. <span class="center-text">正在识别语音...</span>
  398. </div>
  399. <!-- ai_thinking -->
  400. <div class="state-layer state-center" :style="stateStyle('ai_thinking')">
  401. <div class="mini-avatar">{{ aiAvatar }}</div>
  402. <span class="center-text">{{ aiName }} 正在回复...</span>
  403. </div>
  404. <!-- error -->
  405. <div class="state-layer state-error" :style="stateStyle('error')">
  406. <div class="error-info">
  407. <span class="warn-icon">⚠️</span>
  408. <span class="warn-text">{{ lastErrorText }}</span>
  409. </div>
  410. <button
  411. v-if="lastErroredMessage && hasRetryButton(lastErroredMessage)"
  412. class="retry-pill"
  413. @click="handleRetry(lastErroredMessage)"
  414. >{{ retryButtonLabel(lastErroredMessage) }}</button>
  415. </div>
  416. <!-- finalizing -->
  417. <div class="state-layer state-center" :style="stateStyle('finalizing')">
  418. <svg class="spinner" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  419. stroke-width="2" stroke-linecap="round">
  420. <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  421. </svg>
  422. <span class="center-text">正在生成你的本次对话报告...</span>
  423. </div>
  424. </div>
  425. </div>
  426. <!-- ─────── OVERLAYS ─────── -->
  427. <!-- 任务提示弹窗 -->
  428. <TaskHintModal
  429. :visible="showHintModal"
  430. :loading="taskHintLoading"
  431. :error="taskHintError"
  432. :hint="taskHint"
  433. :ai-name="aiName"
  434. @close="showHintModal = false"
  435. @retry="loadTaskHint"
  436. />
  437. <!-- 音素详情弹窗 -->
  438. <div v-if="phonemeDetail" class="modal-mask" @click.self="phonemeDetail = null">
  439. <div class="modal phoneme-modal scale-in">
  440. <div class="modal-head">
  441. <div>
  442. <h3 class="phoneme-word">{{ phonemeDetail.word }}</h3>
  443. <p class="phoneme-sub">发音详情</p>
  444. </div>
  445. <button class="close-btn" @click="phonemeDetail = null">
  446. <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  447. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  448. <line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
  449. </svg>
  450. </button>
  451. </div>
  452. <div class="phoneme-body">
  453. <div class="pho-card pho-user">
  454. <div>
  455. <p class="pho-label">你的发音</p>
  456. <p class="pho-value">{{ phonemeDetail.userPronunciation }}</p>
  457. </div>
  458. <button class="pho-play pho-play-user">
  459. <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3" /></svg>
  460. </button>
  461. </div>
  462. <div class="pho-card pho-standard">
  463. <div>
  464. <p class="pho-label">标准发音</p>
  465. <p class="pho-value pho-value-green">{{ phonemeDetail.standardPronunciation }}</p>
  466. </div>
  467. <button class="pho-play pho-play-standard">
  468. <svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><polygon points="5 3 19 12 5 21 5 3" /></svg>
  469. </button>
  470. </div>
  471. <div v-if="phonemeDetail.tip" class="pho-card pho-tip">
  472. <p class="pho-label">小提示</p>
  473. <p class="pho-tip-text">{{ phonemeDetail.tip }}</p>
  474. </div>
  475. <button class="pho-practice-btn" @click="practiceThisWord">
  476. 针对这个词重练一次
  477. </button>
  478. </div>
  479. </div>
  480. </div>
  481. <!-- 退出/重开确认弹窗 -->
  482. <div v-if="showExitConfirm" class="modal-mask" @click.self="showExitConfirm = false">
  483. <div class="modal exit-modal scale-in">
  484. <div class="modal-head">
  485. <h3 class="modal-title">选择操作</h3>
  486. <button class="close-btn" @click="showExitConfirm = false">
  487. <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
  488. stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
  489. <line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />
  490. </svg>
  491. </button>
  492. </div>
  493. <p class="exit-hint">请选择你的操作:</p>
  494. <div class="exit-actions">
  495. <button class="exit-secondary" @click="showExitConfirm = false">继续练习</button>
  496. <button class="exit-secondary" @click="handleRestart">重新开始</button>
  497. <button class="exit-primary" @click="handleExitConfirm">结束并查看报告</button>
  498. </div>
  499. </div>
  500. </div>
  501. <!-- 徽章弹窗 -->
  502. <div v-if="showBadge" class="badge-popup scale-in">
  503. <div class="badge-card">
  504. <span class="badge-icon">{{ showBadge.icon }}</span>
  505. <div>
  506. <p class="badge-name">{{ showBadge.name }}</p>
  507. <p class="badge-desc">{{ showBadge.description }}</p>
  508. </div>
  509. </div>
  510. </div>
  511. </div>
  512. </template>
  513. <script lang="ts" setup>
  514. import { ref, computed, watch, onMounted, onUnmounted, nextTick, h, defineComponent } from 'vue'
  515. import type { PropType } from 'vue'
  516. import type { PreviewChatMessage, BadgeAchievement, DialogueReport, SessionStartInfo, TaskHint } from '@/types/englishSpeaking'
  517. import { useDialogueEngine } from '../composables/useDialogueEngine'
  518. import { useAudioRecorder } from '../composables/useAudioRecorder'
  519. import { useAudioPlayer } from '../composables/useAudioPlayer'
  520. import TaskHintModal from './TaskHintModal.vue'
  521. import { createDialogueApi } from '../services/llmService'
  522. // ─────────────────────────────────────────────
  523. // Props / Emits
  524. // ─────────────────────────────────────────────
  525. interface Props {
  526. topic?: string
  527. keywords?: string[]
  528. aiName?: string
  529. aiAvatar?: string
  530. totalRounds?: number
  531. showEnglishText?: boolean
  532. showChineseText?: boolean
  533. sessionInfo?: SessionStartInfo | null
  534. }
  535. const props = withDefaults(defineProps<Props>(), {
  536. topic: '我最喜欢的动物',
  537. keywords: () => ['animal', 'zoo', 'cute', 'favorite'],
  538. aiName: 'Tom',
  539. aiAvatar: '😊',
  540. totalRounds: 3,
  541. showEnglishText: true,
  542. showChineseText: false,
  543. sessionInfo: null,
  544. })
  545. const emit = defineEmits<{
  546. complete: [report: DialogueReport | null]
  547. restart: []
  548. }>()
  549. // ─────────────────────────────────────────────
  550. // Config
  551. // ─────────────────────────────────────────────
  552. const MAX_RECORDING_SECONDS = 60
  553. const SILENCE_HINTS = [
  554. 'You could say: "I really like pandas because they are so cute!"',
  555. 'Try: "My favorite animal is the elephant. It\'s very smart."',
  556. 'You could say: "I went to the zoo last weekend with my family."',
  557. ]
  558. const BADGE_CONFIG: Record<string, BadgeAchievement> = {
  559. smooth_talker: { id: 'smooth_talker', name: '流畅达人', nameEn: 'Smooth Talker', icon: '💬', description: '连续3句流畅度优秀' },
  560. pronunciation_pro: { id: 'pronunciation_pro', name: '发音专家', nameEn: 'Pronunciation Pro', icon: '🎯', description: '连续5句发音准确' },
  561. perfect_round: { id: 'perfect_round', name: '完美一轮', nameEn: 'Perfect Round', icon: '⭐', description: '单轮四维度全优' },
  562. }
  563. // ─────────────────────────────────────────────
  564. // Composables
  565. // ─────────────────────────────────────────────
  566. const engine = useDialogueEngine()
  567. const recorder = useAudioRecorder()
  568. const player = useAudioPlayer()
  569. // ─────────────────────────────────────────────
  570. // Local UI State
  571. // ─────────────────────────────────────────────
  572. const chatContainerRef = ref<HTMLDivElement>()
  573. const expandedMessageId = ref<string | null>(null)
  574. const showHintModal = ref(false)
  575. const taskHint = ref<TaskHint | null>(null)
  576. const taskHintLoading = ref(false)
  577. const taskHintError = ref<string | null>(null)
  578. const taskHintApi = createDialogueApi()
  579. const showExitConfirm = ref(false)
  580. const phonemeDetail = ref<{
  581. word: string
  582. userPronunciation?: string
  583. standardPronunciation?: string
  584. tip?: string
  585. } | null>(null)
  586. const silenceHintText = ref('')
  587. const showIdleHint = ref(false)
  588. let idleHintTimer: ReturnType<typeof setTimeout> | null = null
  589. const isStarting = ref(false)
  590. const reportFetchInflight = ref(false)
  591. let startAbortController: AbortController | null = null
  592. // 徽章
  593. const showBadge = ref<BadgeAchievement | null>(null)
  594. const consecutiveFluent = ref(0)
  595. const consecutiveAccurate = ref(0)
  596. let badgeTimer: ReturnType<typeof setTimeout> | null = null
  597. // ─────────────────────────────────────────────
  598. // Derived State
  599. // ─────────────────────────────────────────────
  600. const currentRound = computed(() => engine.currentRound.value)
  601. // 状态机:starting → recording → stt → ai_thinking → idle / error / finalizing / done
  602. const state = computed<
  603. 'idle' | 'starting' | 'recording' | 'stt' | 'ai_thinking' | 'finalizing' | 'error' | 'done'
  604. >(() => {
  605. if (isStarting.value) return 'starting'
  606. if (recorder.isRecording.value) return 'recording'
  607. if (engine.isComplete.value) return reportFetchInflight.value ? 'finalizing' : 'done'
  608. const msgs = engine.messages.value
  609. const last = msgs[msgs.length - 1]
  610. if (last?.status === 'error') return 'error'
  611. // 学生消息 loading 且无 content → 正在 STT
  612. if (last?.role === 'student' && last.status === 'loading' && !last.content) return 'stt'
  613. if (engine.isProcessing.value) return 'ai_thinking'
  614. return 'idle'
  615. })
  616. // stt/ai_thinking 时,若最后一条已是 loading 的 AI 占位消息,列表里已有 typing-bubble,就不再在末尾叠一个
  617. const hasLoadingPlaceholder = computed(() => {
  618. const msgs = engine.messages.value
  619. const last = msgs[msgs.length - 1]
  620. return last?.status === 'loading' && last.role === 'ai' && !last.content
  621. })
  622. const progressPct = computed(() => Math.min((recorder.recordingDuration.value / MAX_RECORDING_SECONDS) * 100, 100))
  623. const isNearLimit = computed(() => recorder.recordingDuration.value >= MAX_RECORDING_SECONDS * 0.8)
  624. const lastErrorText = computed(() => {
  625. const msgs = engine.messages.value
  626. const last = msgs[msgs.length - 1]
  627. return last?.error || '请求异常,请稍后再试'
  628. })
  629. // ─────────────────────────────────────────────
  630. // Sub-Component: DimBadge
  631. // ─────────────────────────────────────────────
  632. const DimBadge = defineComponent({
  633. props: { level: { type: String as PropType<'excellent' | 'good' | 'improve'>, required: true } },
  634. setup(p) {
  635. return () => {
  636. if (p.level === 'excellent') return h('span', { class: 'dim-badge dim-excellent' }, '✓✓')
  637. if (p.level === 'good') return h('span', { class: 'dim-badge dim-good' }, '✓')
  638. return h('span', { class: 'dim-badge dim-improve' }, '△')
  639. }
  640. },
  641. })
  642. // ─────────────────────────────────────────────
  643. // Helpers
  644. // ─────────────────────────────────────────────
  645. function formatSeconds(s: number): string {
  646. const m = Math.floor(s / 60)
  647. const sec = s % 60
  648. return `${m}:${sec.toString().padStart(2, '0')}`
  649. }
  650. function getWordAnalysis(message: PreviewChatMessage, word: string) {
  651. const clean = word.replace(/[.,!?]/g, '')
  652. return message.evaluation?.wordAnalysis?.find(w => w.word === clean)
  653. }
  654. function stateStyle(target: string) {
  655. const active = state.value === target
  656. return {
  657. opacity: active ? 1 : 0,
  658. pointerEvents: active ? 'auto' : 'none',
  659. transition: 'opacity 0.18s ease-out',
  660. } as const
  661. }
  662. // ─────────────────────────────────────────────
  663. // Actions
  664. // ─────────────────────────────────────────────
  665. // 当前流式会话控制器(开始录音时打开 WebSocket,结束时收尾)
  666. let streamCtl: ReturnType<typeof engine.beginStudentStream> = null
  667. async function handleStartRecording() {
  668. if (!engine.canRecord.value || recorder.isRecording.value || isStarting.value) return
  669. player.stop()
  670. isStarting.value = true
  671. startAbortController = new AbortController()
  672. try {
  673. await recorder.startRecording(startAbortController.signal)
  674. // Mic acquired — open the WS now (no placeholders pushed yet).
  675. streamCtl = engine.beginStudentStream({
  676. sampleRate: recorder.sampleRate.value,
  677. bits: 16,
  678. channels: 1,
  679. })
  680. if (streamCtl) {
  681. recorder.onChunk.value = streamCtl.pushChunk
  682. }
  683. } catch (err: any) {
  684. if (err.name === 'AbortError') {
  685. // User cancelled during getUserMedia. State naturally returns to idle.
  686. } else {
  687. console.error('Failed to start recording:', err)
  688. }
  689. } finally {
  690. isStarting.value = false
  691. startAbortController = null
  692. }
  693. }
  694. function handleCancelStarting() {
  695. startAbortController?.abort()
  696. // recorder.startRecording will reject with AbortError; no further cleanup needed.
  697. }
  698. function handleCancelRecording() {
  699. // 停止录音 + 中止流式会话(丢弃本次录音)
  700. recorder.onChunk.value = null
  701. if (streamCtl) {
  702. streamCtl.abort() // close WS; nothing on the message list to clean
  703. streamCtl = null
  704. }
  705. if (recorder.isRecording.value) {
  706. recorder.stopRecording().catch(() => {})
  707. }
  708. recorder.cleanup()
  709. }
  710. async function handleFinishRecording() {
  711. if (!recorder.isRecording.value) return
  712. const ctl = streamCtl
  713. streamCtl = null
  714. try {
  715. const blob = await recorder.stopRecording()
  716. recorder.onChunk.value = null
  717. if (ctl) {
  718. ctl.commit(blob) // pushes placeholders, attaches blob, sends 'stop'
  719. } else {
  720. // Fallback: direct HTTP path
  721. await engine.sendStudentMessage(blob, crypto.randomUUID())
  722. }
  723. } catch (err) {
  724. console.error('Recording/send failed:', err)
  725. }
  726. }
  727. function hasRetryButton(m: PreviewChatMessage): boolean {
  728. return m.recovery === 'retry' || m.recovery === 'restart'
  729. }
  730. function hasRerecordButton(m: PreviewChatMessage): boolean {
  731. return m.role === 'student' && (m.recovery === 'retry' || m.recovery === 'rerecord')
  732. }
  733. function retryButtonLabel(m: PreviewChatMessage): string {
  734. if (m.recovery === 'restart') return '返回重开'
  735. return '重试'
  736. }
  737. async function handleRetry(m: PreviewChatMessage) {
  738. if (m.recovery === 'restart') {
  739. emit('restart')
  740. return
  741. }
  742. if (m.role === 'student') {
  743. await engine.retryMessage(m.id)
  744. } else {
  745. // greeting case: first AI message with no prior student
  746. const idx = engine.messages.value.indexOf(m)
  747. const isGreeting = !engine.messages.value
  748. .slice(0, idx)
  749. .some(x => x.role === 'student')
  750. if (isGreeting) {
  751. await engine.retryGreeting()
  752. } else {
  753. await engine.regenerateAiMessage(m.id)
  754. }
  755. }
  756. }
  757. function handleRerecord(m: PreviewChatMessage) {
  758. engine.discardCurrentTurn(m.id)
  759. }
  760. const lastErroredMessage = computed<PreviewChatMessage | null>(() => {
  761. const msgs = engine.messages.value
  762. for (let i = msgs.length - 1; i >= 0; i--) {
  763. if (msgs[i].status === 'error') return msgs[i]
  764. }
  765. return null
  766. })
  767. function toggleExpand(id: string) {
  768. expandedMessageId.value = expandedMessageId.value === id ? null : id
  769. }
  770. function openTaskHint() {
  771. showHintModal.value = true
  772. if (!taskHint.value && !taskHintLoading.value) {
  773. loadTaskHint()
  774. }
  775. }
  776. async function loadTaskHint() {
  777. if (!props.sessionInfo?.sessionId) {
  778. taskHintError.value = '当前会话未准备好,请稍后重试'
  779. return
  780. }
  781. taskHintLoading.value = true
  782. taskHintError.value = null
  783. try {
  784. taskHint.value = await taskHintApi.generateTaskHint(props.sessionInfo.sessionId)
  785. } catch {
  786. taskHintError.value = '生成任务提示失败,请重试'
  787. } finally {
  788. taskHintLoading.value = false
  789. }
  790. }
  791. function togglePlay(id: string) {
  792. // Same id is currently playing or loading → stop.
  793. if (player.playingId.value === id || player.loadingId.value === id) {
  794. player.stop()
  795. return
  796. }
  797. const msg = engine.messages.value.find(m => m.id === id)
  798. if (!msg) return
  799. if (msg.role === 'student' && msg.audioBlob) {
  800. player.play(id, { kind: 'blob', blob: msg.audioBlob })
  801. }
  802. else if (msg.role === 'ai' && msg.content) {
  803. player.play(id, { kind: 'tts', text: msg.content })
  804. }
  805. }
  806. function openPhonemeDetail(wa: NonNullable<NonNullable<PreviewChatMessage['evaluation']>['wordAnalysis']>[0]) {
  807. phonemeDetail.value = {
  808. word: wa.word,
  809. userPronunciation: wa.userPronunciation,
  810. standardPronunciation: wa.standardPronunciation,
  811. tip: wa.tip,
  812. }
  813. }
  814. function practiceThisWord() {
  815. phonemeDetail.value = null
  816. handleStartRecording()
  817. }
  818. async function handleExitConfirm() {
  819. showExitConfirm.value = false
  820. emit('complete', await fetchReportSafe())
  821. }
  822. async function fetchReportSafe(): Promise<DialogueReport | null> {
  823. reportFetchInflight.value = true
  824. try {
  825. await engine.completeSession()
  826. return await engine.getReport()
  827. } catch (err) {
  828. console.warn('[speaking] getReport failed:', err)
  829. return null
  830. } finally {
  831. reportFetchInflight.value = false
  832. }
  833. }
  834. function handleRestart() {
  835. showExitConfirm.value = false
  836. engine.abort()
  837. player.stop()
  838. emit('restart')
  839. }
  840. // ─────────────────────────────────────────────
  841. // Badge detection
  842. // ─────────────────────────────────────────────
  843. function triggerBadge(id: string) {
  844. const badge = BADGE_CONFIG[id]
  845. if (!badge) return
  846. showBadge.value = badge
  847. if (badgeTimer) clearTimeout(badgeTimer)
  848. badgeTimer = setTimeout(() => { showBadge.value = null }, 2800)
  849. }
  850. function checkBadges(ev: NonNullable<PreviewChatMessage['evaluation']>) {
  851. const d = ev.dimensions
  852. if (d.fluency === 'excellent') {
  853. consecutiveFluent.value += 1
  854. if (consecutiveFluent.value === 3) triggerBadge('smooth_talker')
  855. } else {
  856. consecutiveFluent.value = 0
  857. }
  858. if (d.accuracy === 'excellent') {
  859. consecutiveAccurate.value += 1
  860. if (consecutiveAccurate.value === 5) triggerBadge('pronunciation_pro')
  861. } else {
  862. consecutiveAccurate.value = 0
  863. }
  864. if (d.accuracy === 'excellent' && d.fluency === 'excellent' && d.completeness === 'excellent' && d.rhythm === 'excellent') {
  865. setTimeout(() => triggerBadge('perfect_round'), 400)
  866. }
  867. }
  868. // ─────────────────────────────────────────────
  869. // Watchers
  870. // ─────────────────────────────────────────────
  871. // 自动滚动到底部
  872. watch(
  873. () => engine.messages.value.map(m => m.content + m.status).join('|'),
  874. () => {
  875. nextTick(() => {
  876. if (chatContainerRef.value) {
  877. chatContainerRef.value.scrollTop = chatContainerRef.value.scrollHeight
  878. }
  879. })
  880. },
  881. )
  882. // 自动播放:AI 消息流式 done 后,合成并播一次。
  883. // 用 Set 去重防止 watcher 因为不相关重渲染重复触发。
  884. const autoPlayedIds = new Set<string>()
  885. const seededHistoricalMessageIds = new Set<string>()
  886. watch(
  887. () => engine.messages.value.map(m => `${m.id}:${m.status}`).join('|'),
  888. () => {
  889. for (const m of engine.messages.value) {
  890. if (
  891. m.role === 'ai' &&
  892. m.status === 'done' &&
  893. m.content &&
  894. !seededHistoricalMessageIds.has(m.id) &&
  895. !autoPlayedIds.has(m.id)
  896. ) {
  897. autoPlayedIds.add(m.id)
  898. player.play(m.id, { kind: 'tts', text: m.content })
  899. }
  900. }
  901. },
  902. )
  903. // AI 消息 done 后,延迟 600ms 显示 "在等你的回答..."
  904. watch(
  905. () => {
  906. const msgs = engine.messages.value
  907. const last = msgs[msgs.length - 1]
  908. return last?.role === 'ai' && last.status === 'done' ? last.id : null
  909. },
  910. (val) => {
  911. if (idleHintTimer) clearTimeout(idleHintTimer)
  912. if (val) {
  913. showIdleHint.value = false
  914. idleHintTimer = setTimeout(() => { showIdleHint.value = true }, 600)
  915. } else {
  916. showIdleHint.value = false
  917. }
  918. },
  919. )
  920. // 学生消息产生 evaluation 时,检查徽章 + 清理沉默提示
  921. watch(
  922. () => engine.messages.value.filter(m => m.role === 'student' && m.evaluation).length,
  923. () => {
  924. const done = engine.messages.value.filter(m => m.role === 'student' && m.evaluation)
  925. const last = done[done.length - 1]
  926. if (last?.evaluation) checkBadges(last.evaluation)
  927. },
  928. )
  929. // 对话完成 → 通知父组件
  930. watch(
  931. () => engine.isComplete.value,
  932. async (complete) => {
  933. if (complete) emit('complete', await fetchReportSafe())
  934. },
  935. )
  936. // 沉默检测 → 随机提示
  937. watch(
  938. () => recorder.silenceDetected.value,
  939. (silent) => {
  940. if (silent && recorder.isRecording.value) {
  941. silenceHintText.value = SILENCE_HINTS[Math.floor(Math.random() * SILENCE_HINTS.length)]
  942. } else {
  943. silenceHintText.value = ''
  944. }
  945. },
  946. )
  947. // 录音时长达到上限,自动完成
  948. watch(
  949. () => recorder.recordingDuration.value,
  950. (v) => {
  951. if (v >= MAX_RECORDING_SECONDS && recorder.isRecording.value) {
  952. handleFinishRecording()
  953. }
  954. },
  955. )
  956. // ─────────────────────────────────────────────
  957. // Lifecycle
  958. // ─────────────────────────────────────────────
  959. onMounted(() => {
  960. if (props.sessionInfo) {
  961. const hasHistory = !!props.sessionInfo.messages?.length
  962. seededHistoricalMessageIds.clear()
  963. for (const message of props.sessionInfo.messages ?? []) {
  964. seededHistoricalMessageIds.add(message.id)
  965. }
  966. engine.attachSession({
  967. sessionId: props.sessionInfo.sessionId,
  968. expiresAt: props.sessionInfo.expiresAt,
  969. totalRounds: props.totalRounds,
  970. currentRound: props.sessionInfo.currentRound,
  971. messages: props.sessionInfo.messages,
  972. })
  973. if (!hasHistory) engine.generateGreeting()
  974. } else {
  975. console.warn('[DialogueChatView] mounted without sessionInfo; chat is inert. Parent must createSession before mounting.')
  976. }
  977. // 无 sessionInfo 时聊天区保持空(父组件应当先创建 session 再挂载本组件)
  978. })
  979. onUnmounted(() => {
  980. if (idleHintTimer) clearTimeout(idleHintTimer)
  981. if (badgeTimer) clearTimeout(badgeTimer)
  982. })
  983. </script>
  984. <style lang="scss" scoped>
  985. // ─────────────────────────────────────────────
  986. // Root
  987. // ─────────────────────────────────────────────
  988. .dialogue-chat-view {
  989. width: 100%;
  990. height: 100%;
  991. display: flex;
  992. flex-direction: column;
  993. position: relative;
  994. user-select: none;
  995. background: #fff;
  996. font-size: 12px;
  997. }
  998. // ─────────────────────────────────────────────
  999. // Header
  1000. // ─────────────────────────────────────────────
  1001. .chat-header {
  1002. display: flex;
  1003. align-items: center;
  1004. justify-content: space-between;
  1005. padding: 8px 12px;
  1006. border-bottom: 1px solid #f3f4f6;
  1007. background: #fff;
  1008. flex-shrink: 0;
  1009. }
  1010. .header-left {
  1011. display: flex;
  1012. align-items: center;
  1013. gap: 8px;
  1014. min-width: 0;
  1015. }
  1016. .ai-avatar {
  1017. width: 24px; height: 24px;
  1018. border-radius: 50%;
  1019. background: #fff7ed;
  1020. border: 1px solid #fed7aa;
  1021. display: flex; align-items: center; justify-content: center;
  1022. font-size: 12px;
  1023. flex-shrink: 0;
  1024. &.breathing { animation: breathing 2.4s ease-in-out infinite; }
  1025. }
  1026. .ai-name { font-size: 12px; font-weight: 600; color: #1f2937; }
  1027. .idle-hint { font-size: 11px; color: #9ca3af; }
  1028. .online-dot {
  1029. width: 6px; height: 6px;
  1030. background: #10b981;
  1031. border-radius: 50%;
  1032. }
  1033. .header-right {
  1034. display: flex;
  1035. align-items: center;
  1036. gap: 12px;
  1037. }
  1038. .round-indicator { font-size: 11px; font-weight: 500; color: #f97316; }
  1039. .total-time { font-size: 11px; font-weight: 500; color: #6b7280; font-variant-numeric: tabular-nums; }
  1040. .icon-btn {
  1041. padding: 6px;
  1042. border: none; background: transparent;
  1043. color: #9ca3af;
  1044. border-radius: 6px;
  1045. display: flex; align-items: center; justify-content: center;
  1046. cursor: pointer;
  1047. transition: background 0.15s, color 0.15s;
  1048. &:hover { background: #f3f4f6; color: #4b5563; }
  1049. }
  1050. // ─────────────────────────────────────────────
  1051. // Permission banner
  1052. // ─────────────────────────────────────────────
  1053. .permission-banner {
  1054. display: flex;
  1055. align-items: center;
  1056. gap: 8px;
  1057. padding: 8px 12px;
  1058. background: #fef3c7;
  1059. border-bottom: 1px solid #fde68a;
  1060. font-size: 11px;
  1061. color: #92400e;
  1062. flex-shrink: 0;
  1063. }
  1064. .permission-icon { font-size: 14px; }
  1065. // ─────────────────────────────────────────────
  1066. // Chat area
  1067. // ─────────────────────────────────────────────
  1068. .chat-area {
  1069. flex: 1;
  1070. overflow-y: auto;
  1071. padding: 12px;
  1072. display: flex;
  1073. flex-direction: column;
  1074. gap: 12px;
  1075. background: #f7f8fa;
  1076. min-height: 0;
  1077. }
  1078. .msg-row {
  1079. display: flex;
  1080. align-items: flex-end;
  1081. gap: 8px;
  1082. }
  1083. .msg-ai { justify-content: flex-start; }
  1084. .msg-student {
  1085. flex-direction: column;
  1086. align-items: flex-end;
  1087. gap: 4px;
  1088. }
  1089. .msg-col {
  1090. max-width: 78%;
  1091. display: flex;
  1092. flex-direction: column;
  1093. gap: 4px;
  1094. }
  1095. .avatar-sm {
  1096. width: 28px; height: 28px;
  1097. border-radius: 50%;
  1098. background: #fff7ed;
  1099. border: 1px solid #fed7aa;
  1100. display: flex; align-items: center; justify-content: center;
  1101. font-size: 14px;
  1102. flex-shrink: 0;
  1103. margin-bottom: 2px;
  1104. }
  1105. // 语音条
  1106. .voice-bar {
  1107. display: flex;
  1108. align-items: center;
  1109. gap: 8px;
  1110. padding: 8px 12px;
  1111. width: clamp(140px, 44%, 210px);
  1112. }
  1113. .voice-ai {
  1114. background: #fff;
  1115. border: 1px solid #f3f4f6;
  1116. border-radius: 16px;
  1117. border-top-left-radius: 4px;
  1118. box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  1119. }
  1120. .voice-student {
  1121. background: #f97316;
  1122. border-radius: 16px;
  1123. border-top-right-radius: 4px;
  1124. }
  1125. .play-btn {
  1126. width: 24px; height: 24px;
  1127. border-radius: 50%;
  1128. border: none;
  1129. display: flex; align-items: center; justify-content: center;
  1130. flex-shrink: 0;
  1131. cursor: pointer;
  1132. transition: background 0.2s;
  1133. }
  1134. .play-ai {
  1135. background: rgba(249,115,22,0.1);
  1136. color: #f97316;
  1137. &:hover { background: rgba(249,115,22,0.2); }
  1138. }
  1139. .play-student {
  1140. background: rgba(255,255,255,0.2);
  1141. color: #fff;
  1142. &:hover { background: rgba(255,255,255,0.3); }
  1143. }
  1144. .play-btn-error {
  1145. background: #fef2f2 !important;
  1146. color: #dc2626 !important;
  1147. border: 1px solid #fecaca;
  1148. &:hover { background: #fee2e2 !important; }
  1149. }
  1150. .play-spinner {
  1151. animation: spin 1s linear infinite;
  1152. }
  1153. .play-error-hint {
  1154. font-size: 10px;
  1155. color: #dc2626;
  1156. font-weight: 500;
  1157. flex-shrink: 0;
  1158. white-space: nowrap;
  1159. }
  1160. .play-error-hint-student {
  1161. color: #fff;
  1162. }
  1163. .wave-bar-group {
  1164. flex: 1;
  1165. display: flex;
  1166. align-items: center;
  1167. gap: 1px;
  1168. }
  1169. .wave-bar {
  1170. width: 2px;
  1171. border-radius: 999px;
  1172. flex-shrink: 0;
  1173. }
  1174. .wave-ai { background: rgba(249,115,22,0.4); }
  1175. .wave-student { background: rgba(255,255,255,0.5); }
  1176. .voice-duration { font-size: 10px; flex-shrink: 0; }
  1177. .voice-duration-ai { color: #9ca3af; }
  1178. .voice-duration-student { color: rgba(255,255,255,0.7); }
  1179. // 气泡
  1180. .bubble {
  1181. padding: 8px 12px;
  1182. border-radius: 12px;
  1183. font-size: 12px;
  1184. line-height: 1.55;
  1185. max-width: 100%;
  1186. }
  1187. .bubble-ai {
  1188. background: #fff;
  1189. border: 1px solid #f3f4f6;
  1190. border-top-left-radius: 4px;
  1191. color: #374151;
  1192. box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  1193. }
  1194. .bubble-student {
  1195. background: #fff7ed;
  1196. border: 1px solid #fed7aa;
  1197. border-top-right-radius: 4px;
  1198. color: #374151;
  1199. max-width: 78%;
  1200. padding: 6px 12px;
  1201. }
  1202. .improvable-word {
  1203. color: #d97706;
  1204. text-decoration: underline wavy #fbbf24;
  1205. cursor: pointer;
  1206. padding: 0 2px;
  1207. border-radius: 2px;
  1208. transition: background 0.2s;
  1209. &:hover { background: #fef3c7; }
  1210. }
  1211. // typing 指示器
  1212. .typing-bubble {
  1213. display: inline-flex;
  1214. align-items: center;
  1215. gap: 4px;
  1216. padding: 10px 14px;
  1217. background: #fff;
  1218. border: 1px solid #f3f4f6;
  1219. border-radius: 16px;
  1220. border-top-left-radius: 4px;
  1221. box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  1222. }
  1223. .typing-dot {
  1224. width: 6px; height: 6px;
  1225. background: rgba(249,115,22,0.7);
  1226. border-radius: 50%;
  1227. animation: typing-bounce 1s ease-in-out infinite;
  1228. }
  1229. @keyframes typing-bounce {
  1230. 0%, 100% { transform: translateY(0); opacity: 0.5; }
  1231. 50% { transform: translateY(-3px); opacity: 1; }
  1232. }
  1233. // 错误卡
  1234. .error-card {
  1235. margin-top: 4px;
  1236. padding: 6px 10px;
  1237. background: #fef2f2;
  1238. border: 1px solid #fecaca;
  1239. border-radius: 10px;
  1240. display: inline-flex;
  1241. align-items: center;
  1242. gap: 8px;
  1243. }
  1244. .error-text { font-size: 11px; color: #dc2626; }
  1245. .retry-btn {
  1246. padding: 3px 10px;
  1247. background: #fff;
  1248. border: 1px solid #fecaca;
  1249. border-radius: 999px;
  1250. font-size: 11px;
  1251. color: #dc2626;
  1252. cursor: pointer;
  1253. &:hover { background: #fef2f2; border-color: #f87171; }
  1254. }
  1255. .rerecord-btn {
  1256. padding: 3px 10px;
  1257. background: transparent;
  1258. border: 1px solid #d1d5db;
  1259. border-radius: 999px;
  1260. font-size: 11px;
  1261. color: #6b7280;
  1262. cursor: pointer;
  1263. margin-left: 4px;
  1264. &:hover { background: #f9fafb; border-color: #9ca3af; color: #374151; }
  1265. }
  1266. // 评分卡
  1267. .eval-card {
  1268. background: #fff;
  1269. border: 1px solid #f3f4f6;
  1270. border-radius: 12px;
  1271. box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  1272. overflow: hidden;
  1273. width: clamp(260px, 88%, 420px);
  1274. text-align: left;
  1275. margin-top: 2px;
  1276. }
  1277. .eval-l1 { padding: 8px 12px; }
  1278. .dim-row {
  1279. display: flex;
  1280. align-items: center;
  1281. gap: 6px;
  1282. font-size: 10px;
  1283. color: #6b7280;
  1284. flex-wrap: wrap;
  1285. }
  1286. .dim-label { color: #6b7280; }
  1287. .dim-sep { color: #e5e7eb; margin: 0 2px; }
  1288. .dim-badge {
  1289. font-size: 10px;
  1290. font-weight: 600;
  1291. padding: 1px 4px;
  1292. border-radius: 3px;
  1293. }
  1294. .dim-excellent { color: #059669; background: #ecfdf5; }
  1295. .dim-good { color: #10b981; background: #ecfdf5; }
  1296. .dim-improve { color: #f59e0b; background: #fffbeb; }
  1297. .sugg-row {
  1298. display: flex;
  1299. align-items: center;
  1300. justify-content: space-between;
  1301. gap: 8px;
  1302. margin-top: 6px;
  1303. }
  1304. .sugg-text {
  1305. flex: 1;
  1306. min-width: 0;
  1307. font-size: 10px;
  1308. color: #6b7280;
  1309. display: flex;
  1310. align-items: center;
  1311. gap: 4px;
  1312. margin: 0;
  1313. }
  1314. .sugg-icon { color: #f59e0b; flex-shrink: 0; }
  1315. .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  1316. .detail-toggle {
  1317. font-size: 10px;
  1318. color: #f97316;
  1319. background: transparent;
  1320. border: none;
  1321. cursor: pointer;
  1322. display: flex;
  1323. align-items: center;
  1324. gap: 2px;
  1325. flex-shrink: 0;
  1326. &:hover { color: #ea580c; }
  1327. svg { transition: transform 0.2s; }
  1328. .chev-up { transform: rotate(180deg); }
  1329. }
  1330. .eval-l2 {
  1331. padding: 10px 12px;
  1332. border-top: 1px solid #f9fafb;
  1333. background: #fafbfc;
  1334. display: flex;
  1335. flex-direction: column;
  1336. gap: 10px;
  1337. }
  1338. .detail-label {
  1339. font-size: 10px;
  1340. color: #9ca3af;
  1341. margin: 0 0 4px;
  1342. display: flex;
  1343. align-items: center;
  1344. gap: 4px;
  1345. }
  1346. .detail-content {
  1347. font-size: 12px;
  1348. color: #374151;
  1349. background: #fff;
  1350. padding: 6px 10px;
  1351. border: 1px solid #f3f4f6;
  1352. border-radius: 8px;
  1353. margin: 0;
  1354. line-height: 1.5;
  1355. }
  1356. .word-tags { display: flex; flex-wrap: wrap; gap: 4px; }
  1357. .word-tag {
  1358. padding: 2px 8px;
  1359. background: #fff7ed;
  1360. color: #ea580c;
  1361. font-size: 10px;
  1362. border-radius: 999px;
  1363. border: 1px solid #fed7aa;
  1364. }
  1365. // ─────────────────────────────────────────────
  1366. // Silence hint
  1367. // ─────────────────────────────────────────────
  1368. .silence-hint-wrap {
  1369. position: absolute;
  1370. bottom: 76px;
  1371. left: 0; right: 0;
  1372. display: flex;
  1373. justify-content: center;
  1374. z-index: 10;
  1375. padding: 0 16px;
  1376. pointer-events: none;
  1377. }
  1378. .silence-hint {
  1379. background: rgba(255,255,255,0.95);
  1380. backdrop-filter: blur(6px);
  1381. border: 1px solid #fed7aa;
  1382. border-radius: 14px;
  1383. box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  1384. padding: 10px 14px;
  1385. display: flex;
  1386. align-items: flex-start;
  1387. gap: 10px;
  1388. max-width: 320px;
  1389. width: 100%;
  1390. pointer-events: auto;
  1391. }
  1392. .silence-icon { color: #fb923c; font-size: 14px; flex-shrink: 0; margin-top: 2px; }
  1393. .silence-text { font-size: 12px; color: #4b5563; margin: 0; line-height: 1.5; flex: 1; }
  1394. .silence-close {
  1395. background: transparent; border: none;
  1396. color: #d1d5db;
  1397. cursor: pointer;
  1398. padding: 2px;
  1399. flex-shrink: 0;
  1400. &:hover { color: #6b7280; }
  1401. }
  1402. // ─────────────────────────────────────────────
  1403. // Control zone
  1404. // ─────────────────────────────────────────────
  1405. .control-zone {
  1406. flex-shrink: 0;
  1407. border-top: 1px solid #f3f4f6;
  1408. background: #fff;
  1409. padding: 10px 16px 12px;
  1410. }
  1411. .progress-wrap {
  1412. max-width: 384px;
  1413. margin: 0 auto 8px;
  1414. }
  1415. .progress-track {
  1416. height: 1px;
  1417. border-radius: 999px;
  1418. overflow: hidden;
  1419. }
  1420. .progress-fill {
  1421. height: 100%;
  1422. background: #fb923c;
  1423. transition: width 1s linear, background-color 0.4s ease, opacity 0.2s ease;
  1424. &.near-limit { background: #f87171; }
  1425. }
  1426. .state-stack {
  1427. position: relative;
  1428. height: 36px;
  1429. max-width: 384px;
  1430. margin: 0 auto;
  1431. }
  1432. .state-layer {
  1433. position: absolute;
  1434. inset: 0;
  1435. display: flex;
  1436. align-items: center;
  1437. }
  1438. .state-idle {
  1439. justify-content: center;
  1440. gap: 12px;
  1441. }
  1442. .state-center { justify-content: center; gap: 8px; }
  1443. .state-error {
  1444. justify-content: space-between;
  1445. gap: 12px;
  1446. }
  1447. // idle buttons
  1448. .hint-btn {
  1449. display: inline-flex;
  1450. align-items: center;
  1451. gap: 5px;
  1452. padding: 5px 14px;
  1453. border-radius: 999px;
  1454. background: #f9fafb;
  1455. border: 1px solid #e5e7eb;
  1456. color: #6b7280;
  1457. font-size: 11px;
  1458. font-weight: 500;
  1459. cursor: pointer;
  1460. transition: background 0.2s, border-color 0.2s, color 0.2s;
  1461. &:hover {
  1462. background: #fff7ed;
  1463. border-color: #fed7aa;
  1464. color: #f97316;
  1465. }
  1466. }
  1467. .mic-btn {
  1468. display: inline-flex;
  1469. align-items: center;
  1470. gap: 8px;
  1471. padding: 7px 24px;
  1472. border-radius: 999px;
  1473. background: #f97316;
  1474. border: none;
  1475. color: #fff;
  1476. font-size: 13px;
  1477. font-weight: 500;
  1478. cursor: pointer;
  1479. box-shadow: 0 4px 10px rgba(249,115,22,0.25);
  1480. transition: background 0.2s, transform 0.15s;
  1481. &:hover { background: #ea580c; }
  1482. &:active { transform: scale(0.96); }
  1483. &:disabled { opacity: 0.5; cursor: not-allowed; background: #d1d5db; box-shadow: none; }
  1484. }
  1485. // recording capsule
  1486. .record-capsule {
  1487. width: 100%;
  1488. display: flex;
  1489. align-items: center;
  1490. gap: 8px;
  1491. padding: 5px 10px;
  1492. border-radius: 999px;
  1493. background: #f9fafb;
  1494. border: 1px solid #f3f4f6;
  1495. }
  1496. .cancel-btn, .finish-btn {
  1497. display: inline-flex;
  1498. align-items: center;
  1499. gap: 4px;
  1500. padding: 4px 10px;
  1501. border-radius: 999px;
  1502. font-size: 11px;
  1503. font-weight: 500;
  1504. cursor: pointer;
  1505. flex-shrink: 0;
  1506. transition: background 0.2s, border-color 0.2s, color 0.2s;
  1507. }
  1508. .cancel-btn {
  1509. background: #fff;
  1510. border: 1px solid #e5e7eb;
  1511. color: #6b7280;
  1512. &:hover { background: #fef2f2; border-color: #fecaca; color: #ef4444; }
  1513. }
  1514. .finish-btn {
  1515. background: #f97316;
  1516. border: none;
  1517. color: #fff;
  1518. &:hover { background: #ea580c; }
  1519. }
  1520. .record-meter {
  1521. flex: 1;
  1522. display: flex;
  1523. align-items: center;
  1524. justify-content: center;
  1525. gap: 6px;
  1526. }
  1527. .animated-wave { display: flex; align-items: center; gap: 1px; }
  1528. .aw-bar {
  1529. width: 2px;
  1530. border-radius: 999px;
  1531. background: #f97316;
  1532. animation: aw-pulse 1.2s ease-in-out infinite;
  1533. &.near-limit { background: #ef4444; }
  1534. }
  1535. @keyframes aw-pulse {
  1536. 0%, 100% { opacity: 0.55; }
  1537. 50% { opacity: 1; }
  1538. }
  1539. .record-time {
  1540. font-size: 12px;
  1541. font-family: monospace;
  1542. font-weight: 600;
  1543. color: #1f2937;
  1544. font-variant-numeric: tabular-nums;
  1545. &.near-limit { color: #ef4444; }
  1546. }
  1547. .record-time-max { font-size: 10px; color: #d1d5db; }
  1548. // stt / thinking
  1549. .spinner {
  1550. color: #fb923c;
  1551. animation: spin 1s linear infinite;
  1552. }
  1553. @keyframes spin {
  1554. to { transform: rotate(360deg); }
  1555. }
  1556. .mini-avatar {
  1557. width: 16px; height: 16px;
  1558. border-radius: 50%;
  1559. background: #fff7ed;
  1560. display: flex; align-items: center; justify-content: center;
  1561. font-size: 10px;
  1562. }
  1563. .center-text { font-size: 12px; color: #9ca3af; }
  1564. // error
  1565. .error-info { display: flex; align-items: center; gap: 6px; }
  1566. .warn-icon { color: #f59e0b; font-size: 12px; }
  1567. .warn-text { font-size: 12px; color: #4b5563; }
  1568. .retry-pill {
  1569. padding: 5px 14px;
  1570. border-radius: 999px;
  1571. background: #f97316;
  1572. color: #fff;
  1573. border: none;
  1574. font-size: 12px;
  1575. font-weight: 500;
  1576. cursor: pointer;
  1577. &:hover { background: #ea580c; }
  1578. }
  1579. // ─────────────────────────────────────────────
  1580. // Modals
  1581. // ─────────────────────────────────────────────
  1582. .modal-mask {
  1583. position: fixed;
  1584. inset: 0;
  1585. background: rgba(0,0,0,0.3);
  1586. backdrop-filter: blur(2px);
  1587. display: flex;
  1588. align-items: center;
  1589. justify-content: center;
  1590. z-index: 50;
  1591. padding: 16px;
  1592. }
  1593. .modal {
  1594. background: #fff;
  1595. border-radius: 16px;
  1596. width: 100%;
  1597. max-height: 80vh;
  1598. overflow-y: auto;
  1599. box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  1600. }
  1601. .phoneme-modal { max-width: 320px; }
  1602. .exit-modal { max-width: 320px; padding: 20px; }
  1603. .modal-head {
  1604. display: flex;
  1605. align-items: center;
  1606. justify-content: space-between;
  1607. margin-bottom: 12px;
  1608. }
  1609. .modal-title {
  1610. font-size: 14px;
  1611. font-weight: 600;
  1612. color: #111827;
  1613. display: flex;
  1614. align-items: center;
  1615. gap: 6px;
  1616. margin: 0;
  1617. }
  1618. .close-btn {
  1619. width: 26px; height: 26px;
  1620. background: #f3f4f6;
  1621. border: none;
  1622. border-radius: 8px;
  1623. color: #6b7280;
  1624. cursor: pointer;
  1625. display: flex; align-items: center; justify-content: center;
  1626. &:hover { background: #e5e7eb; }
  1627. }
  1628. // 音素
  1629. .phoneme-word { text-align: left; font-size: 16px; font-weight: 700; color: #111827; margin: 0; }
  1630. .phoneme-sub { font-size: 11px; color: #9ca3af; margin: 2px 0 0; }
  1631. .phoneme-body {
  1632. padding: 0 20px 20px;
  1633. display: flex;
  1634. flex-direction: column;
  1635. gap: 10px;
  1636. }
  1637. .modal-head + .phoneme-body { padding-top: 0; }
  1638. .phoneme-modal .modal-head { padding: 20px 20px 12px; margin-bottom: 0; }
  1639. .pho-card {
  1640. border-radius: 12px;
  1641. padding: 12px;
  1642. display: flex;
  1643. align-items: center;
  1644. justify-content: space-between;
  1645. gap: 12px;
  1646. }
  1647. .pho-user { background: #fffbeb; border: 1px solid #fde68a; }
  1648. .pho-standard { background: #ecfdf5; border: 1px solid #bbf7d0; }
  1649. .pho-tip { background: #eff6ff; border: 1px solid #bfdbfe; display: block; }
  1650. .pho-label { font-size: 10px; font-weight: 500; margin: 0 0 2px; }
  1651. .pho-user .pho-label { color: #d97706; }
  1652. .pho-standard .pho-label { color: #059669; }
  1653. .pho-tip .pho-label { color: #2563eb; }
  1654. .pho-value { font-size: 14px; font-family: monospace; color: #b45309; margin: 0; }
  1655. .pho-value-green { color: #15803d; }
  1656. .pho-tip-text { font-size: 12px; color: #1d4ed8; margin: 0; line-height: 1.5; }
  1657. .pho-play {
  1658. width: 30px; height: 30px;
  1659. border-radius: 8px;
  1660. border: 1px solid;
  1661. display: flex; align-items: center; justify-content: center;
  1662. cursor: pointer;
  1663. }
  1664. .pho-play-user { background: #fef3c7; border-color: #fde68a; color: #d97706; &:hover { background: #fde68a; } }
  1665. .pho-play-standard { background: #d1fae5; border-color: #bbf7d0; color: #059669; &:hover { background: #bbf7d0; } }
  1666. .pho-practice-btn {
  1667. width: 100%;
  1668. padding: 9px;
  1669. border-radius: 12px;
  1670. background: #f97316;
  1671. color: #fff;
  1672. border: none;
  1673. font-size: 12px;
  1674. font-weight: 500;
  1675. cursor: pointer;
  1676. &:hover { background: #ea580c; }
  1677. }
  1678. // 退出弹窗
  1679. .exit-hint { font-size: 11px; color: #9ca3af; margin: 0 0 14px; }
  1680. .exit-actions { display: flex; flex-direction: column; gap: 10px; }
  1681. .exit-secondary {
  1682. padding: 9px 0;
  1683. border-radius: 12px;
  1684. background: transparent;
  1685. border: 1px solid #e5e7eb;
  1686. color: #4b5563;
  1687. font-size: 12px;
  1688. font-weight: 500;
  1689. cursor: pointer;
  1690. &:hover { background: #f9fafb; }
  1691. }
  1692. .exit-primary {
  1693. padding: 9px 0;
  1694. border-radius: 12px;
  1695. background: #f97316;
  1696. border: none;
  1697. color: #fff;
  1698. font-size: 12px;
  1699. font-weight: 500;
  1700. cursor: pointer;
  1701. &:hover { background: #ea580c; }
  1702. }
  1703. // 徽章
  1704. .badge-popup {
  1705. position: fixed;
  1706. top: 64px;
  1707. right: 16px;
  1708. z-index: 60;
  1709. }
  1710. .badge-card {
  1711. display: flex;
  1712. align-items: center;
  1713. gap: 12px;
  1714. padding: 10px 16px;
  1715. background: linear-gradient(to right, #f97316, #f59e0b);
  1716. border-radius: 16px;
  1717. box-shadow: 0 8px 24px rgba(249,115,22,0.3);
  1718. }
  1719. .badge-icon { font-size: 24px; }
  1720. .badge-name { font-size: 12px; font-weight: 600; color: #fff; margin: 0; }
  1721. .badge-desc { font-size: 10px; color: rgba(255,255,255,0.8); margin: 2px 0 0; }
  1722. // ─────────────────────────────────────────────
  1723. // Animations
  1724. // ─────────────────────────────────────────────
  1725. @keyframes breathing {
  1726. 0%, 100% { transform: scale(1); }
  1727. 50% { transform: scale(1.06); box-shadow: 0 0 0 3px rgba(249,115,22,0.12); }
  1728. }
  1729. @keyframes fade-in-frames {
  1730. from { opacity: 0; transform: translateY(4px); }
  1731. to { opacity: 1; transform: translateY(0); }
  1732. }
  1733. .fade-in { animation: fade-in-frames 0.22s ease-out; }
  1734. @keyframes scale-in-frames {
  1735. from { opacity: 0; transform: scale(0.96); }
  1736. to { opacity: 1; transform: scale(1); }
  1737. }
  1738. .scale-in { animation: scale-in-frames 0.22s ease-out; }
  1739. </style>