/* ========== 全局重置 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; font-size: 14px; color: #333; background: #f5f7fa; overflow-x: hidden; overscroll-behavior: none; }
input, button, select, textarea { font-family: inherit; font-size: 14px; outline: none; border: none; }
button { cursor: pointer; background: none; }
a { text-decoration: none; color: inherit; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; max-width: 480px; margin: 0 auto; background: #f5f7fa; position: relative; }

/* ========== 导航栏 ========== */
.navbar { display: flex; align-items: center; height: 50px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; padding: 0 12px; flex-shrink: 0; position: relative; z-index: 100; }
.navbar-left, .navbar-right { width: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.navbar-title { flex: 1; text-align: center; font-size: 17px; font-weight: 600; }

/* ========== 主内容区 ========== */
.main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative; overscroll-behavior: none; }
.page { min-height: 100%; padding-bottom: 20px; }

/* ========== 登录页 ========== */
.page-login { display: flex; flex-direction: column; align-items: center; padding: 40px 24px; background: linear-gradient(180deg, #667eea 0%, #764ba2 40%, #f5f7fa 40%); }
.login-logo { text-align: center; margin-bottom: 30px; color: #fff; }
.logo-icon { font-size: 56px; margin-bottom: 12px; }
.login-logo h1 { font-size: 26px; margin-bottom: 8px; }
.login-logo p { font-size: 13px; opacity: 0.85; }
.login-form { width: 100%; background: #fff; border-radius: 16px; padding: 24px 20px; box-shadow: 0 8px 30px rgba(0,0,0,0.08); }
.tab-group { display: flex; margin-bottom: 20px; background: #f0f2f5; border-radius: 8px; padding: 4px; }
.tab { flex: 1; text-align: center; padding: 10px 0; border-radius: 6px; font-size: 15px; color: #999; cursor: pointer; transition: all 0.3s; }
.tab.active { background: #fff; color: #667eea; font-weight: 600; box-shadow: 0 2px 8px rgba(102,126,234,0.15); }
.form-group { margin-bottom: 14px; }
.form-group input, .form-group select { width: 100%; height: 46px; padding: 0 14px; border: 1px solid #e8e8e8; border-radius: 10px; font-size: 15px; background: #fafafa; transition: border-color 0.3s; }
.form-group input:focus, .form-group select:focus { border-color: #667eea; background: #fff; }
.form-label { display: block; font-size: 13px; color: #888; margin-bottom: 6px; }
.btn-primary { width: 100%; height: 48px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; border-radius: 10px; font-size: 16px; font-weight: 600; margin-top: 8px; transition: opacity 0.3s; }
.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; }
.login-tip { margin-top: 24px; font-size: 12px; color: #999; }

/* ========== 首页（与小程序 pages/home 布局一致） ========== */
.page-home { padding: 16px; }
.user-card { display: flex; align-items: center; background: #fff; border-radius: 20px; padding: 16px; margin-bottom: 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.user-avatar { width: 50px; height: 50px; border-radius: 50%; background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 600; margin-right: 12px; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.user-meta { font-size: 12px; color: #999; }
.user-points { font-size: 12px; color: #8a7bd8; background: #f0eefc; border-radius: 999px; padding: 4px 12px; margin-right: 6px; flex-shrink: 0; cursor: pointer; }
.user-settings { font-size: 20px; padding: 4px; flex-shrink: 0; cursor: pointer; }
.user-logout { font-size: 12px; color: #999; margin-left: 8px; flex-shrink: 0; cursor: pointer; padding: 4px; }

/* 功能入口宫格 */
.entry-grid { display: flex; gap: 12px; margin-bottom: 14px; }
.entry-item { flex: 1; background: #fff; border-radius: 20px; padding: 18px 10px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); text-align: center; cursor: pointer; transition: transform 0.15s; }
.entry-item:active { transform: scale(0.97); }
.entry-icon { width: 56px; height: 56px; border-radius: 14px; font-size: 28px; display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; }
.entry-name { font-size: 15px; font-weight: 600; }
.entry-desc { font-size: 11px; color: #999; margin-top: 4px; }

/* 教学模式：横排三卡片，选中高亮 */
.mode-card { background: #fff; border-radius: 20px; padding: 14px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); margin-bottom: 16px; }
.mode-title { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.mode-list { display: flex; gap: 8px; }
.mode-item { flex: 1; background: #f6f7fb; border: 2px solid transparent; border-radius: 12px; padding: 12px 6px; text-align: center; cursor: pointer; transition: all 0.15s; }
.mode-item.active { background: #f0f4ff; border-color: #667eea; }
.mode-name { font-size: 14px; font-weight: 600; color: #333; }
.mode-item.active .mode-name { color: #667eea; }
.mode-desc { font-size: 11px; color: #999; margin-top: 4px; line-height: 1.4; }
.mode-tip { font-size: 11px; color: #aaa; margin-top: 10px; }

/* 区块标题 */
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.section-title { font-size: 16px; font-weight: 600; }
.section-more { font-size: 12px; color: #667eea; cursor: pointer; padding: 4px; }

/* 广告位 */
.ad-banner { margin: 14px 0 4px; border-radius: 20px; overflow: hidden; background: #f7f7fb; box-shadow: 0 2px 12px rgba(102,126,234,0.12); }
.ad-img { width: 100%; display: block; border-radius: 20px; }
.ad-text { padding: 14px 16px; font-size: 13px; color: #5b6472; text-align: center; line-height: 1.5; }

/* 会话列表（对齐小程序：题目文字 + 图片缩略图，学段学科/教学模式标签 + 时间） */
.session-list { display: flex; flex-direction: column; gap: 10px; }
.session-item { background: #fff; border-radius: 12px; padding: 14px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.03); }
.session-item:active { background: #f9f9f9; }
.session-question { display: flex; align-items: center; gap: 12px; }
.session-question-img { width: 68px; height: 68px; border-radius: 10px; background: #f5f7fa; object-fit: cover; flex-shrink: 0; border: none; }
.session-text { font-size: 14px; line-height: 1.6; color: #333; flex: 1; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-all; }
.session-meta { display: flex; align-items: center; margin-top: 8px; gap: 8px; font-size: 11px; color: #aaa; }
.tag { font-size: 11px; color: #667eea; background: #eef4ff; border-radius: 8px; padding: 2px 8px; }
.tag.mode { color: #764ba2; background: #f5eefb; }
.time { margin-left: auto; font-size: 11px; color: #aaa; }

.empty-tip { text-align: center; color: #ccc; font-size: 14px; padding: 40px 0; }

/* ========== 拍照页 ========== */
.page-camera { padding: 0; background: #000; position: relative; display: flex; flex-direction: column; height: 100%; }
.camera-container { position: relative; width: 100%; flex: 1; min-height: 0; overflow: hidden; }
#cameraVideo { width: 100%; height: 100%; object-fit: cover; }
.camera-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.scan-frame { position: relative; width: 80%; height: 60%; border: 2px solid rgba(255,255,255,0.3); border-radius: 12px; }
.scan-corner { position: absolute; width: 24px; height: 24px; border-color: #667eea; border-style: solid; }
.scan-corner.tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-radius: 8px 0 0 0; }
.scan-corner.tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-radius: 0 8px 0 0; }
.scan-corner.bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-radius: 0 0 0 8px; }
.scan-corner.br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-radius: 0 0 8px 0; }
.scan-line { position: absolute; left: 10%; right: 10%; height: 2px; background: linear-gradient(90deg, transparent, #667eea, transparent); animation: scan 2s linear infinite; }
@keyframes scan { 0% { top: 10%; } 50% { top: 85%; } 100% { top: 10%; } }
.camera-tip { margin-top: 20px; color: #fff; font-size: 14px; text-shadow: 0 1px 4px rgba(0,0,0,0.5); }

.camera-controls { display: flex; align-items: center; justify-content: space-around; padding: 16px 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); background: #000; flex-shrink: 0; }

/* 裁剪识题界面 */
.crop-stage { position: fixed; top: 50px; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; background: #000; z-index: 900; display: flex; flex-direction: column; }
.crop-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; color: #fff; font-size: 16px; }
.crop-title { font-weight: 600; }
.btn-crop-auto { padding: 8px 16px; border-radius: 18px; background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; font-size: 13px; font-weight: 600; }
.crop-container { flex: 1; position: relative; overflow: hidden; min-height: 0; }
#cropImage { position: absolute; user-select: none; -webkit-user-select: none; }
.crop-box { position: absolute; border: 2px solid #667eea; box-shadow: 0 0 0 9999px rgba(0,0,0,0.4); touch-action: none; }
.crop-handle { position: absolute; width: 24px; height: 24px; border: 3px solid #fff; background: #667eea; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.crop-handle.tl { top: -2px; left: -2px; cursor: nwse-resize; }
.crop-handle.tr { top: -2px; right: -2px; cursor: nesw-resize; }
.crop-handle.bl { bottom: -2px; left: -2px; cursor: nesw-resize; }
.crop-handle.br { bottom: -2px; right: -2px; cursor: nwse-resize; }
.crop-tip { text-align: center; color: rgba(255,255,255,0.7); font-size: 12px; padding: 8px 16px; }
.crop-controls { display: flex; gap: 12px; padding: 14px 16px 24px; }
.crop-controls .btn-primary, .crop-controls .btn-secondary { flex: 1; height: 46px; margin-top: 0; }
.btn-camera-switch, .btn-album { width: 48px; height: 48px; border-radius: 50%; background: rgba(255,255,255,0.15); color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center; }
.btn-capture { width: 72px; height: 72px; border-radius: 50%; background: #fff; padding: 5px; }
.capture-inner { width: 100%; height: 100%; border-radius: 50%; background: #fff; border: 3px solid #667eea; }

.ocr-result { position: absolute; bottom: 0; left: 0; right: 0; background: #fff; border-radius: 20px 20px 0 0; padding: 20px; max-height: 72%; overflow-y: auto; }
.ocr-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; color: #333; }
.ocr-image-box { margin-bottom: 12px; text-align: center; }
.ocr-image { max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid #e8e8e8; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.ocr-figure-tip { font-size: 13px; line-height: 1.6; background: #fff7e6; color: #b8860b; border: 1px solid #ffe7ba; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.ocr-figure-tip.warn { background: #fff1f0; color: #d4380d; border-color: #ffccc7; }
.ocr-text { font-size: 14px; line-height: 1.7; color: #555; max-height: 150px; overflow-y: auto; background: #f9f9f9; padding: 12px; border-radius: 8px; margin-bottom: 14px; white-space: pre-wrap; }
.ocr-supplement-row { margin-bottom: 14px; }
.ocr-supplement-row .form-label { margin-bottom: 6px; font-size: 13px; color: #b8860b; }
.ocr-supplement { width: 100%; font-size: 14px; line-height: 1.6; color: #555; background: #fffdf5; padding: 10px 12px; border: 1px solid #ffe7ba; border-radius: 8px; resize: vertical; box-sizing: border-box; font-family: inherit; }
.ocr-supplement:focus { outline: none; border-color: #b8860b; }
.ocr-actions { display: flex; gap: 12px; }
.ocr-subject-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.ocr-subject-row .form-label { margin-bottom: 0; white-space: nowrap; }
.ocr-subject-row select { flex: 1; height: 40px; padding: 0 10px; border: 1px solid #e8e8e8; border-radius: 8px; font-size: 14px; background: #fafafa; }
.btn-secondary { flex: 1; height: 44px; border: 1px solid #e8e8e8; border-radius: 10px; font-size: 15px; color: #666; }

/* ========== 对话页 ========== */
.page-chat { display: flex; flex-direction: column; height: calc(100vh - 50px); max-height: calc(100vh - 50px); padding: 0; overflow: hidden; overscroll-behavior: contain; }
.chat-question { background: #fff; padding: 12px 16px; font-size: 14px; color: #555; line-height: 1.6; border-bottom: 1px solid #f0f0f0; flex-shrink: 0; z-index: 30; box-shadow: 0 2px 8px rgba(0,0,0,0.06); transition: padding 0.2s; }
.chat-question.frozen { padding: 10px 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.12); }
.chat-question-image-box { text-align: center; margin-top: 10px; }
.chat-question-image { max-width: 100%; max-height: 240px; border-radius: 10px; border: 1px solid #e8e8e8; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.chat-question-text { word-break: break-word; white-space: pre-wrap; }
.chat-question .chat-question-image-label { display: block; margin-top: 6px; font-size: 12px; color: #999; text-align: center; }
.chat-mode-badge { display: inline-block; margin: 8px 16px 0; padding: 4px 12px; border-radius: 12px; font-size: 12px; background: #f0f5ff; color: #667eea; align-self: flex-start; flex-shrink: 0; }
.chat-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.msg-row { display: flex; margin-bottom: 14px; }
.msg-row.user { justify-content: flex-end; }
.msg-bubble { max-width: 75%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.6; word-break: break-word; white-space: pre-wrap; }
.msg-row.ai .msg-bubble { background: #fff; color: #333; border-bottom-left-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.msg-row.user .msg-bubble { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; border-bottom-right-radius: 4px; }
.typing-cursor { display: inline-block; animation: blink 0.8s infinite; color: #999; font-weight: normal; }
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

/* ========== KaTeX 公式渲染适配（数学/物理/化学）========== */
/* 独立公式过长时可横向滚动，避免撑破气泡或容器 */
.msg-bubble .katex-display,
.chat-question .katex-display,
.ocr-text .katex-display,
.exercise-question .katex-display,
.exercise-result .katex-display { margin: 6px 0; overflow-x: auto; overflow-y: hidden; max-width: 100%; }
/* 行内公式随中文正常换行，略微放大提升可读性 */
.msg-bubble .katex, .ocr-text .katex, .chat-question .katex, .exercise-question .katex { font-size: 1.08em; }
/* AI 回复行内 Markdown 样式：斜体 / 行内代码 / 删除线 */
.msg-bubble em { font-style: italic; }
.msg-bubble del { text-decoration: line-through; color: #999; }
.msg-bubble code { font-family: Consolas, Menlo, monospace; background: #f0f0f0; padding: 1px 6px; border-radius: 4px; font-size: 0.92em; }
.msg-avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; margin: 0 8px; }
.msg-row.ai .msg-avatar { background: #f0f5ff; }
.msg-row.user .msg-avatar { background: #fff1f0; }
/* AI 回复重播按钮 */
.btn-replay-ai { width: 30px; height: 30px; border-radius: 50%; background: #f0f5ff; color: #667eea; font-size: 15px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-left: 4px; align-self: flex-end; transition: background 0.2s, transform 0.1s; }
.btn-replay-ai:active { background: #d6e4ff; transform: scale(0.92); }
.msg-typing { display: flex; gap: 4px; padding: 12px 16px; }
.msg-typing span { width: 8px; height: 8px; border-radius: 50%; background: #ccc; animation: typing 1.4s infinite; }
.msg-typing span:nth-child(2) { animation-delay: 0.2s; }
.msg-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-6px); opacity: 1; } }

.chat-input-bar { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: #fdfdfe; border-top: 1px solid #ececf2; box-shadow: 0 -4px 12px rgba(102,126,234,0.06); flex-shrink: 0; }
.btn-voice, .btn-speech, .btn-clear { width: 32px; height: 32px; border-radius: 50%; background: #f5f7fa; font-size: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.btn-clear:hover { background: #ffe5e5; color: #e74c3c; }
.chat-actions-col { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; justify-content: flex-end; }
.btn-voice.recording { background: #ff4d4f; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1); } }

/* 输入行：左侧输入框高度 = 右侧三按钮列高度 */
.input-row { display: flex; align-items: stretch; gap: 6px; }
.chat-input-area { flex: 1; min-height: 84px; max-height: 140px; padding: 9px 12px; background: #f7f8fa; border: 1px solid transparent; border-radius: 10px; font-size: 14px; line-height: 1.5; overflow-y: auto; -webkit-overflow-scrolling: touch; transition: border-color 0.2s; word-break: break-word; white-space: pre-wrap; -webkit-user-select: text; user-select: text; box-sizing: border-box; }
.chat-input-area:focus { border-color: #a8b4f5; background: #fff; outline: none; }
.chat-input-area:empty::before { content: attr(data-placeholder); color: #999; pointer-events: none; }
.chat-input-area .katex { font-size: 1.05em; }
.chat-input-area .katex-display { margin: 4px 0; overflow-x: auto; overflow-y: hidden; max-width: 100%; }

/* 右侧竖列：公式 / 手写 / 清除 */
.input-side { display: flex; flex-direction: column; justify-content: space-between; flex-shrink: 0; }
.side-btn { width: 48px; height: 26px; border-radius: 7px; background: linear-gradient(135deg, #f3f5ff, #e9edff); border: 1px solid #e2e6ff; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; cursor: pointer; }
.side-btn:active { background: #dfe4ff; }
.side-icon { font-size: 11px; color: #5a6ee0; }
.side-label { font-size: 9px; color: #5a6ee0; margin-top: 1px; }

/* 发送行：巩固练习（左） + 发送（右） */
.send-row { display: flex; align-items: center; justify-content: space-between; margin-top: 7px; }
.ex-link { font-size: 12px; color: #667eea; background: #eef0ff; border: 1px solid #e2e6ff; border-radius: 999px; padding: 6px 13px; cursor: pointer; }
.ex-link:active { background: #dfe4ff; }
.send-btn { width: 110px; height: 42px; line-height: 42px; padding: 0; margin: 0; background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; font-size: 15px; font-weight: 600; letter-spacing: 3px; border-radius: 10px; box-shadow: 0 3px 8px rgba(102,126,234,0.28); flex-shrink: 0; white-space: nowrap; }
.send-btn:disabled { opacity: 0.5; }

.voice-recording { position: absolute; bottom: 130px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,0.75); color: #fff; padding: 12px 24px; border-radius: 30px; display: flex; align-items: center; gap: 10px; font-size: 14px; z-index: 50; }
.recording-pulse { width: 12px; height: 12px; border-radius: 50%; background: #ff4d4f; animation: pulse 1s infinite; }

/* ========== 输入模式切换 ========== */
.input-mode-switch { display: flex; justify-content: center; align-items: center; gap: 0; padding: 6px 12px 0; background: #fff; border-top: 1px solid #f0f0f0; flex-shrink: 0; }
.input-mode-switch .mode-tab { padding: 6px 24px; font-size: 13px; color: #999; cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.2s; }
.input-mode-switch .mode-tab.active { color: #667eea; border-bottom-color: #667eea; font-weight: 600; }
.input-mode-switch .formula-toggle { margin-left: 6px; margin-right: 0; }

/* ========== 公式工具栏 ========== */
.formula-toggle { margin-left: auto; padding: 4px 12px; font-size: 12px; color: #667eea; cursor: pointer; border: 1px solid #d6e4ff; border-radius: 14px; background: #f0f5ff; transition: all 0.2s; user-select: none; -webkit-user-select: none; }
.formula-toggle.active { background: #667eea; color: #fff; border-color: #667eea; }
.formula-palette-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.formula-palette { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; background: #f9fafc; border-top: 1px solid #f0f0f0; border-bottom: 1px solid #f0f0f0; max-height: 120px; overflow-y: auto; flex-shrink: 0; }
.formula-palette .fp-item { padding: 5px 10px; font-size: 13px; background: #fff; border: 1px solid #e8e8e8; border-radius: 8px; cursor: pointer; white-space: nowrap; transition: all 0.15s; user-select: none; -webkit-user-select: none; }
.formula-palette .fp-item:active { background: #667eea; color: #fff; border-color: #667eea; transform: scale(0.95); }
.formula-palette .fp-item.fp-wrap { background: #f0f5ff; color: #667eea; border-color: #d6e4ff; font-weight: 600; }

/* 消息复制按钮 */
.btn-copy-msg { width: 30px; height: 30px; border-radius: 50%; background: #f0f5ff; color: #667eea; font-size: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-left: 4px; align-self: flex-end; transition: background 0.2s, transform 0.1s; }
.btn-copy-msg:active { background: #d6e4ff; transform: scale(0.92); }
.msg-row.user .btn-copy-msg { background: rgba(255,255,255,0.2); color: #fff; margin-left: 0; margin-right: 4px; }

/* ========== 语音输入栏 ========== */
.chat-voice-bar { display: flex; align-items: center; padding: 10px 12px; background: #fff; border-top: 1px solid #f0f0f0; gap: 10px; flex-shrink: 0; }
.btn-record { flex: 1; height: 44px; background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; border-radius: 22px; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.btn-record.recording { background: linear-gradient(135deg, #ff4d4f, #ff7875); animation: pulse 0.8s infinite; }
.btn-record .record-icon { font-size: 18px; }

/* ========== AI语音播放条 ========== */
.ai-audio-bar { display: flex; align-items: center; padding: 8px 12px; background: #f0f5ff; border-top: 1px solid #d6e4ff; gap: 10px; flex-shrink: 0; }
.btn-audio-play { width: 32px; height: 32px; border-radius: 50%; background: #667eea; color: #fff; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.audio-progress { flex: 1; height: 4px; background: #d6e4ff; border-radius: 2px; overflow: hidden; }
.audio-progress-fill { height: 100%; background: #667eea; border-radius: 2px; width: 0%; transition: width 0.1s linear; }
.audio-time { font-size: 12px; color: #666; flex-shrink: 0; min-width: 36px; text-align: right; }

/* ========== 习题页 ========== */
.page-exercise { padding: 16px; }
.exercise-card { background: #fff; border-radius: 14px; padding: 16px; margin-bottom: 14px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.exercise-num { display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center; background: #667eea; color: #fff; border-radius: 50%; font-size: 13px; margin-right: 8px; }
.exercise-question { font-size: 15px; line-height: 1.7; color: #333; margin: 10px 0; }
.exercise-answer-input { width: 100%; min-height: 80px; padding: 10px 12px; border: 1px solid #e8e8e8; border-radius: 10px; font-size: 14px; resize: vertical; margin-bottom: 10px; background: #fafafa; }
.exercise-result { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-top: 8px; }
.exercise-result.correct { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f; }
.exercise-result.wrong { background: #fff1f0; color: #f5222d; border: 1px solid #ffa39e; }
.exercise-result .answer { margin-top: 6px; color: #666; }

/* ========== 加载遮罩 ========== */
.loading-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 9999; }
.loading-spinner { width: 44px; height: 44px; border: 4px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: #fff; margin-top: 14px; font-size: 14px; }

/* ========== Toast ========== */
.toast { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,0.75); color: #fff; padding: 12px 24px; border-radius: 8px; font-size: 14px; z-index: 10000; max-width: 80%; text-align: center; }

/* ========== 文字输入题目按钮 ========== */
.btn-text-input { width: 100%; height: 48px; margin-top: 16px; background: #fff; border: 2px dashed #667eea; border-radius: 12px; color: #667eea; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.2s, transform 0.1s; }
.btn-text-input:active { background: #f0f5ff; transform: scale(0.98); }

/* ========== 通用弹窗 ========== */
.modal-mask { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 5000; padding: 20px; }
.modal-content { background: #fff; border-radius: 16px; padding: 24px 20px; width: 100%; max-width: 360px; max-height: 80vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,0.15); }
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; text-align: center; }
.modal-actions { display: flex; gap: 12px; margin-top: 8px; }
.modal-actions .btn-secondary, .modal-actions .btn-primary { flex: 1; height: 46px; margin-top: 0; }
.modal-content .form-group select { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #e8e8e8; border-radius: 8px; font-size: 14px; background: #fafafa; }
.text-question-input { width: 100%; min-height: 120px; padding: 10px 12px; border: 1px solid #e8e8e8; border-radius: 10px; font-size: 14px; line-height: 1.6; resize: vertical; background: #fafafa; transition: border-color 0.3s; }
.text-question-input:focus { border-color: #667eea; background: #fff; }
.text-question-input[contenteditable="true"] { min-height: 120px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; }
.text-question-input[contenteditable="true"]:empty:before { content: attr(data-placeholder); color: #999; pointer-events: none; }
.text-question-input[contenteditable="true"] .katex { font-size: 1.1em; }
.hw-result-preview { min-height: 44px; padding: 10px 12px; background: #fffdf5; border: 1px solid #ffe7ba; border-radius: 8px; margin-bottom: 8px; font-size: 18px; line-height: 1.8; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.hw-result-preview:empty { display: none; }
.hw-result-preview .katex { font-size: 1.15em; }

/* ========== 手写板 ========== */
.hw-toggle { margin-left: 8px; }
.handwrite-modal { max-width: 680px; }
.hw-toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.hw-tool { width: 40px; height: 40px; border-radius: 10px; border: 1px solid #e8e8e8; background: #fafafa; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background 0.2s, border-color 0.2s; }
.hw-tool:hover { background: #f0f5ff; border-color: #667eea; }
.hw-tool.active { background: #667eea; border-color: #667eea; }
.hw-tool-hint { margin-left: auto; font-size: 13px; color: #999; }
.hw-canvas { width: 100%; height: auto; background: #fff; border: 2px dashed #e8e8e8; border-radius: 12px; touch-action: none; cursor: crosshair; display: block; }
.hw-result { margin-top: 12px; background: #f9f9f9; border: 1px solid #e8e8e8; border-radius: 10px; padding: 10px 12px; }
.hw-result-label { font-size: 13px; color: #667eea; font-weight: 600; margin-bottom: 6px; }
.hw-result-text { width: 100%; min-height: 64px; padding: 8px 10px; border: 1px solid #e8e8e8; border-radius: 8px; font-size: 14px; line-height: 1.5; resize: vertical; background: #fff; box-sizing: border-box; }
.hw-result-tip { margin-top: 6px; font-size: 13px; color: #b8860b; line-height: 1.5; }

/* ========== AI 示意图（SVG） ========== */
.ai-svg-figure { margin: 8px 0; padding: 8px; background: #fff; border: 1px solid #e8e8e8; border-radius: 8px; overflow-x: auto; text-align: center; }
.ai-svg-figure svg { max-width: 100%; height: auto; display: block; margin: 0 auto; }
.ai-svg-fallback { color: #999; font-size: 12px; padding: 16px 8px; }

/* ========== 错题本 ========== */
.page-wrong { padding: 16px; }
.wrong-head { margin-bottom: 14px; }
.wrong-title { font-size: 16px; font-weight: 600; }
.wrong-tip { font-size: 12px; color: #999; margin-top: 4px; }
.wrong-list { display: flex; flex-direction: column; gap: 12px; }
.wrong-item { background: #fff; border-radius: 14px; padding: 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.wrong-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.wrong-time { font-size: 11px; color: #aaa; }
.wrong-q { font-size: 14px; line-height: 1.6; color: #333; font-weight: 600; margin-bottom: 10px; white-space: pre-wrap; word-break: break-word; }
.wrong-a-title { font-size: 13px; color: #667eea; font-weight: 600; margin-bottom: 6px; }
.wrong-a { font-size: 13px; line-height: 1.7; color: #555; white-space: pre-wrap; word-break: break-word; background: #f8f9fd; border-radius: 10px; padding: 10px 12px; }
.wrong-actions { display: flex; gap: 10px; margin-top: 12px; }
.wrong-btn { flex: 1; height: 38px; border-radius: 10px; font-size: 13px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.wrong-btn.del { border: 1px solid #ffd6d6; color: #e74c3c; background: #fff5f5; }
.wrong-btn.exp { border: 1px solid #d6e4ff; color: #667eea; background: #f0f5ff; }
.wrong-empty { text-align: center; color: #ccc; font-size: 14px; padding: 40px 0; }
.load-more { width: 100%; height: 40px; margin-top: 12px; border: 1px solid #e8e8e8; border-radius: 10px; font-size: 13px; color: #667eea; background: #fff; cursor: pointer; }
.load-more:active { background: #f5f7fa; }

/* ========== 学习报告 ========== */
.page-report { padding: 16px; }
.rp-head-card { margin-bottom: 14px; }
.rp-title { font-size: 17px; font-weight: 600; }
.rp-sub { font-size: 12px; color: #999; margin-top: 4px; }
.rp-stats { display: flex; gap: 12px; margin-bottom: 14px; }
.rp-stat { flex: 1; background: #fff; border-radius: 14px; padding: 16px 8px; text-align: center; box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.rp-num { font-size: 22px; font-weight: 700; color: #667eea; }
.rp-label { font-size: 12px; color: #999; margin-top: 4px; }
.rp-card { background: #fff; border-radius: 14px; padding: 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); margin-bottom: 14px; }
.rp-card-title { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.rp-bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding: 0 4px; }
.rp-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rp-bar { width: 100%; max-width: 36px; background: linear-gradient(180deg, #667eea, #764ba2); border-radius: 6px 6px 2px 2px; min-height: 3px; transition: height 0.5s; }
.rp-bar-label { font-size: 10px; color: #999; white-space: nowrap; }
.rp-bar-val { font-size: 10px; color: #667eea; font-weight: 600; }
.rp-subjects { display: flex; flex-direction: column; gap: 10px; }
.rp-subj { display: flex; align-items: center; gap: 10px; }
.rp-subj-name { width: 44px; font-size: 13px; color: #555; flex-shrink: 0; }
.rp-subj-bar { flex: 1; height: 8px; background: #f0f2f5; border-radius: 4px; overflow: hidden; }
.rp-subj-fill { height: 100%; background: linear-gradient(90deg, #667eea, #764ba2); border-radius: 4px; }
.rp-subj-cnt { width: 44px; font-size: 12px; color: #999; text-align: right; flex-shrink: 0; }
.rp-tip { font-size: 12px; color: #aaa; text-align: center; margin-top: 8px; }
.rp-empty { font-size: 13px; color: #ccc; text-align: center; padding: 16px 0; }

/* ========== 会员中心 ========== */
.page-vip { padding: 16px; }
.vip-card { background: #fff; border-radius: 20px; padding: 24px 20px; text-align: center; box-shadow: 0 2px 12px rgba(0,0,0,0.04); border: 2px solid transparent; margin-bottom: 16px; }
.vip-card.active { background: linear-gradient(135deg, #667eea, #764ba2); border-color: #667eea; }
.vip-card.active .vip-badge, .vip-card.active .vip-days { color: #fff; }
.vip-badge { font-size: 18px; font-weight: 700; }
.vip-days { font-size: 13px; color: #999; margin-top: 8px; }
.vip-section { background: #fff; border-radius: 14px; padding: 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); margin-bottom: 14px; }
.vip-section-title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.vip-item { font-size: 13px; color: #555; padding: 5px 0; }
.vip-tip { font-size: 12px; color: #999; margin-bottom: 8px; }
.vip-input-row { display: flex; gap: 10px; }
.vip-input { flex: 1; height: 44px; padding: 0 14px; border: 1px solid #e8e8e8; border-radius: 10px; font-size: 14px; background: #fafafa; }
.vip-input:focus { border-color: #667eea; background: #fff; }
.vip-btn { width: 88px; height: 44px; background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.vip-btn:disabled { opacity: 0.5; }
.vip-kf { margin-top: 4px; height: 46px; background: #fff; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #667eea; box-shadow: 0 2px 12px rgba(0,0,0,0.04); cursor: pointer; }

/* ========== 积分页 ========== */
.page-points { padding: 16px; }
.pts-header { background: linear-gradient(135deg, #667eea, #764ba2); border-radius: 20px; padding: 24px 20px; color: #fff; margin-bottom: 14px; }
.pts-label { font-size: 13px; opacity: 0.85; }
.pts-num { font-size: 36px; font-weight: 700; margin-top: 4px; }
.pts-rules { font-size: 12px; opacity: 0.85; margin-top: 10px; }
.ad-video-bar { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 14px; padding: 14px 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); margin-bottom: 14px; cursor: pointer; }
.ad-video-icon { font-size: 28px; }
.ad-video-main { flex: 1; }
.ad-video-title { font-size: 14px; font-weight: 600; }
.ad-video-desc { font-size: 11px; color: #999; margin-top: 3px; }
.ad-video-btn { font-size: 13px; color: #667eea; background: #eef0ff; border-radius: 999px; padding: 6px 14px; }
.pts-list { display: flex; flex-direction: column; gap: 10px; }
.pts-item { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 14px; padding: 14px 16px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.pts-icon { font-size: 24px; }
.pts-main { flex: 1; min-width: 0; }
.pts-remark { font-size: 14px; color: #333; }
.pts-time { font-size: 11px; color: #aaa; margin-top: 3px; }
.pts-change { font-size: 15px; font-weight: 700; }
.pts-change.plus { color: #52c41a; }
.pts-change.minus { color: #e74c3c; }
.pts-empty { text-align: center; color: #ccc; font-size: 14px; padding: 40px 0; }

/* ========== 设置页 ========== */
.page-settings { padding: 16px; }
.card { background: #fff; border-radius: 14px; box-shadow: 0 2px 12px rgba(0,0,0,0.04); }
.group-card { margin-bottom: 14px; overflow: hidden; }
.group-item { display: flex; align-items: center; justify-content: space-between; padding: 15px 16px; border-bottom: 1px solid #f5f5f5; }
.group-item:last-child { border-bottom: none; }
.group-label { font-size: 14px; color: #333; }
.group-value { font-size: 14px; color: #667eea; border: none; background: none; cursor: pointer; }
.group-value.link { cursor: pointer; }
select.group-value { appearance: none; -webkit-appearance: none; padding: 4px 20px 4px 4px; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23667eea'/%3E%3C/svg%3E") no-repeat right center; }
select.group-value:focus { outline: none; }
.btn-logout { width: 100%; height: 46px; margin-top: 6px; border: 1px solid #ffd6d6; border-radius: 14px; font-size: 14px; color: #e74c3c; background: #fff; cursor: pointer; }
.set-version { text-align: center; font-size: 12px; color: #bbb; margin-top: 14px; }

/* 学习记录列表底部提示 */
.list-tip { text-align: center; font-size: 12px; color: #aaa; padding: 14px 0 24px; }
