/* 科目一刷题 · 移动优先样式（iPhone Safari / 微信 WebView 优先） */

:root {
  --primary: #b74b10;
  --primary-dark: #953a09;
  --primary-bg: #fff0df;
  --success: #47785a;
  --success-bg: #edf5ec;
  --danger: #b34444;
  --danger-bg: #fbedeb;
  --bg: #fffaf0;
  --card: #fffefb;
  --line: #e7e0d1;
  --text: #292824;
  --text2: #737064;
  --radius: 20px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  touch-action: manipulation;
  word-break: break-word;
}

button { font-family: inherit; touch-action: manipulation; cursor: pointer; -webkit-user-select: none; user-select: none; }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.header-block {
  position: sticky; top: 0; z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding-top: var(--safe-top);
}
.topbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 8px;
  min-height: 52px;
}
.topbar-title {
  flex: 1; text-align: center;
  font-size: 17px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.icon-btn {
  width: 44px; height: 44px; flex: none;
  border: 0; background: none;
  font-size: 26px; line-height: 1; color: var(--text);
  border-radius: 10px; padding: 0;
}
.icon-btn:active { background: var(--bg); }
.icon-btn.fav-btn.on { color: #f5a623; }
.icon-btn-ph { width: 44px; flex: none; }

/* ---------- 进度条 ---------- */
.bar {
  height: 8px; border-radius: 4px; background: #e5e8ee; overflow: hidden; flex: 1;
}
.bar i { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width .25s; }
.bar.thin { height: 5px; }
.practice-sub {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px 10px;
  font-size: 14px; color: var(--text2);
  font-variant-numeric: tabular-nums;
}
.exam-sub {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px 10px;
  font-size: 14px; color: var(--text2);
  font-variant-numeric: tabular-nums;
}
.exam-timer { font-size: 15px; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.exam-timer b { font-size: 17px; }
.exam-timer.danger, .exam-timer.danger b { color: var(--danger); }

/* ---------- 按钮 ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 12px;
  min-height: 48px; padding: 0 18px;
  font-size: 17px; font-weight: 600;
}
.btn:disabled { opacity: .4; pointer-events: none; }
.btn-block { width: 100%; }
.btn.big { min-height: 54px; font-size: 18px; border-radius: 14px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); }
.btn-ghost { background: var(--primary-bg); color: var(--primary); }
.btn-outline { background: var(--card); border: 1.5px solid var(--line); color: var(--text); }
.btn-outline:active { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: var(--card); border: 1.5px solid var(--danger); color: var(--danger); }
.btn-exam { background: var(--primary-bg); color: var(--primary); border: 1.5px solid var(--primary); }

/* ---------- 首页 ---------- */
.home {
  max-width: 560px; margin: 0 auto;
  padding: 16px 16px calc(28px + var(--safe-bottom));
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; gap: 12px;
}
.stat-card {
  background: #346d80;
  color: #fff; border-radius: 18px; padding: 20px 18px;
  box-shadow: 0 6px 18px rgba(173, 84, 62, .25);
}
.stat-title { font-size: 15px; opacity: .92; }
.stat-main { font-size: 26px; font-weight: 800; margin: 6px 0 10px; font-variant-numeric: tabular-nums; }
.stat-card .bar { background: rgba(255, 255, 255, .28); }
.stat-card .bar i { background: #fff; }
.stat-sub { margin-top: 10px; font-size: 14px; opacity: .95; font-variant-numeric: tabular-nums; }

.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-btn {
  background: var(--card); border: 0; border-radius: var(--radius);
  padding: 15px 16px; text-align: left;
  display: flex; flex-direction: column; gap: 2px;
}
.menu-btn:active { background: #f0f1f4; }
.menu-btn b { font-size: 17px; }
.menu-btn span { font-size: 13px; color: var(--text2); }
.settings-entry {
  margin: 6px auto 0; background: none; border: 0;
  color: var(--text2); font-size: 14px; text-decoration: underline;
}

/* ---------- 题目页 ---------- */
.qpage {
  max-width: 640px; margin: 0 auto;
  padding: 14px 14px calc(92px + var(--safe-bottom));
}
.qcard { background: var(--card); border-radius: var(--radius); padding: 16px; }
.qmeta { margin-bottom: 8px; }
.qtype {
  display: inline-block; font-size: 13px; color: var(--primary);
  background: var(--primary-bg); padding: 2px 9px; border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.qtype.region { background: #e8f7ee; color: var(--success); }

/* 科目切换器 */
.subject-switch { display: flex; gap: 8px; }
.subject-switch button {
  flex: 1; height: 44px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--card);
  font-size: 16px; font-weight: 600; color: var(--text2);
}
.subject-switch button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.confirm-multi { margin-top: 12px; }
.fb-tips {
  margin-top: 8px; background: #fff8e6; border-radius: 8px;
  padding: 8px 10px; color: #8a6d1a; font-size: 15px;
}
.fb-easy {
  margin-top: 8px; background: #eef7f2; border-radius: 8px;
  padding: 8px 10px; color: #2c5f4a; font-size: 15px;
}
.qtext { font-size: 19px; font-weight: 600; line-height: 1.55; }
.qimgs { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.qimg-wrap { position: relative; border-radius: 10px; overflow: hidden; background: #f2f3f5; }
.qimg-wrap img { width: 100%; display: block; cursor: zoom-in; }
.img-fail { display: none; padding: 30px 12px; text-align: center; color: var(--text2); font-size: 15px; }
.qimg-wrap.img-failed .img-fail { display: block; }

.options { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.option {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  text-align: left; background: var(--card);
  border: 1.5px solid var(--line); border-radius: 12px;
  min-height: 52px; padding: 12px 14px;
  font-size: 17px; line-height: 1.5; color: var(--text);
}
.option:active { background: #f5f6f8; }
.option .letter { font-weight: 700; color: var(--text2); flex: none; }
.option .otext { flex: 1; }
.option.selected { border-color: var(--primary); background: var(--primary-bg); }
.option.correct { border-color: var(--success); background: var(--success-bg); }
.option.correct .letter { color: var(--success); }
.option.wrong { border-color: var(--danger); background: var(--danger-bg); }
.option.wrong .letter { color: var(--danger); }
.option.dim { opacity: .55; }
.mark { margin-left: auto; flex: none; font-size: 18px; font-weight: 800; padding-left: 6px; }
.mark.ok { color: var(--success); }
.mark.no { color: var(--danger); }
.mark.sel { color: var(--primary); font-size: 14px; }

.feedback { border-radius: 12px; padding: 14px; margin-top: 14px; font-size: 16px; }
.feedback.correct { background: var(--success-bg); border: 1px solid #bfe8d2; }
.feedback.wrong { background: var(--danger-bg); border: 1px solid #f3c1c3; }
.fb-title { font-weight: 700; font-size: 17px; }
.feedback.correct .fb-title { color: var(--success); }
.feedback.wrong .fb-title { color: var(--danger); }
.fb-answer { margin: 6px 0; }
.fb-explain { color: #333; }
.remove-wrong { margin-top: 14px; }

/* ---------- 底部操作栏 ---------- */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; gap: 10px;
  padding: 10px 14px calc(var(--safe-bottom) + 10px);
}
.bottombar .btn { flex: 1; }

/* ---------- 答题卡 ---------- */
.sheet-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--card); width: 100%; max-width: 640px;
  max-height: 80vh; max-height: 80dvh; overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 16px 14px calc(var(--safe-bottom) + 14px);
}
.sheet-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; font-size: 16px; }
.muted { color: var(--text2); font-size: 13px; }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; margin-bottom: 14px; }
.sheet-btn {
  min-height: 44px; border-radius: 8px;
  border: 1.5px solid var(--line); background: var(--card);
  font-size: 15px; font-variant-numeric: tabular-nums;
}
.sheet-btn.answered { background: var(--primary); border-color: var(--primary); color: #fff; }
.sheet-btn.current { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(173, 84, 62, .35); }

/* ---------- 考试结果 ---------- */
.result-page {
  max-width: 560px; margin: 0 auto;
  padding: 20px 16px calc(28px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 12px;
  min-height: 100vh; min-height: 100dvh; justify-content: center;
}
.result-card { background: var(--card); border-radius: 18px; padding: 28px 18px; text-align: center; border-top: 4px solid var(--success); }
.result-card.fail { border-top-color: var(--danger); }
.score { font-size: 58px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score span { font-size: 18px; color: var(--text2); margin-left: 4px; font-weight: 400; }
.pass-badge { margin: 8px 0 18px; font-weight: 700; font-size: 16px; }
.result-card.pass .pass-badge { color: var(--success); }
.result-card.fail .pass-badge { color: var(--danger); }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.result-grid b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.result-grid span { font-size: 13px; color: var(--text2); }

/* ---------- 设置 ---------- */
.settings-page {
  max-width: 560px; margin: 0 auto;
  padding: 14px 14px calc(28px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.card { background: var(--card); border-radius: var(--radius); padding: 4px 14px 10px; }
.card-title { font-size: 13px; color: var(--text2); padding: 12px 0 2px; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 0; border-bottom: 1px solid var(--line); font-size: 16px;
}
.set-row:last-child { border-bottom: 0; }
.set-info { font-size: 14px; color: var(--text2); padding: 8px 0; font-variant-numeric: tabular-nums; }
.card .btn { margin: 8px 0 4px; }

.switch { position: relative; display: inline-block; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch i {
  position: absolute; inset: 0; background: #d7dae0; border-radius: 15px;
  transition: background .2s; pointer-events: none;
}
.switch i::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px;
  background: #fff; border-radius: 50%; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.switch input:checked + i { background: var(--success); }
.switch input:checked + i::after { transform: translateX(20px); }

.json-area {
  width: 100%; min-height: 140px; max-height: 240px;
  font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  resize: vertical; background: #fafbfc; color: var(--text);
}

/* ---------- 弹窗 / 提示 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--card); width: 100%; max-width: 560px;
  border-radius: 16px 16px 0 0;
  padding: 18px 16px calc(var(--safe-bottom) + 16px);
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body { margin-top: 8px; font-size: 15px; color: #333; }
.modal-body b { font-variant-numeric: tabular-nums; }
.modal-btns { display: flex; gap: 10px; margin-top: 16px; }
.modal-btns .btn { flex: 1; min-height: 46px; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(20, 22, 26, .88); color: #fff;
  padding: 9px 16px; border-radius: 10px;
  font-size: 15px; z-index: 80; max-width: 86%;
  text-align: center;
}

/* ---------- 大图查看 ---------- */
.img-viewer {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0, 0, 0, .92);
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 20px) 10px calc(var(--safe-bottom) + 20px);
}
.img-viewer img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.viewer-close {
  position: absolute; top: calc(var(--safe-top) + 12px); right: 14px;
  background: rgba(255, 255, 255, .16); color: #fff;
  border: 0; border-radius: 20px; padding: 9px 16px; font-size: 15px;
}

/* ---------- 加载 / 空态 ---------- */
.loading, .load-error, .center-empty {
  min-height: 70vh; min-height: 70dvh;
  display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center;
  padding: 24px; text-align: center; color: var(--text2);
}

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--card); border-radius: 18px;
  padding: 28px 22px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .06);
}
.login-title { font-size: 22px; font-weight: 800; text-align: center; }
.login-sub { text-align: center; color: var(--text2); font-size: 14px; margin: -4px 0 6px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; color: var(--text2); }
.field input {
  height: 48px; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 0 14px; font-size: 16px; background: #fafbfc; color: var(--text);
  font-family: inherit;
}
.field input:focus { outline: none; border-color: var(--primary); background: #fff; }
.login-error { color: var(--danger); font-size: 14px; min-height: 20px; text-align: center; }

/* ---------- AI 法规答疑 ---------- */
.ai-fab {
  position: fixed; right: 14px; bottom: calc(var(--safe-bottom) + 92px);
  width: 52px; height: 52px; border-radius: 50%; border: 0;
  background: #b74b10;
  color: #fff; font-size: 16px; font-weight: 800; letter-spacing: 1px;
  z-index: 35;
  box-shadow: 0 4px 14px rgba(173, 84, 62, .4);
}
.ai-fab:active { transform: scale(.95); }
.ai-panel {
  background: var(--card); width: 100%; max-width: 640px;
  max-height: 80vh; max-height: 80dvh;
  border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  padding-bottom: calc(var(--safe-bottom) + 10px);
}
.ai-tabs { display: flex; gap: 6px; padding: 0 14px 8px; }
.ai-tab {
  flex: 1; height: 38px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--card);
  font-size: 14px; font-weight: 600; color: var(--text2);
}
.ai-tab.on { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); }
#ai-body-comments { display: flex; flex-direction: column; min-height: 0; }
.cm-list {
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 14px 8px; min-height: 180px; flex: 1;
}
.cm-count { font-size: 12px; color: var(--text2); padding: 2px 0 4px; font-variant-numeric: tabular-nums; }
.cm-item { background: #f7f8fa; border-radius: 12px; padding: 10px 12px; }
.cm-author { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text2); margin-bottom: 4px; flex-wrap: wrap; }
.cm-author b { color: var(--text); font-size: 13px; }
.cm-vip, .cm-jh { font-size: 11px; color: #b8860b; background: #fdf3d7; border-radius: 4px; padding: 1px 5px; }
.cm-loc { font-size: 11px; color: var(--text2); }
.cm-likes { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; }
.cm-content { font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.cm-time { margin-top: 4px; font-size: 11px; color: var(--text2); }
.cm-replies { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.cm-reply { font-size: 13px; color: #444; background: #fff; border-radius: 8px; padding: 6px 9px; line-height: 1.5; }
.cm-reply b { font-size: 12px; }
.cm-note { text-align: center; color: var(--text2); font-size: 13px; padding: 10px; }
.cm-error { background: var(--danger-bg); color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cm-more { margin-top: 4px; }
/* 网友讨论（解析后内嵌） */
.q-comments { margin-top: 14px; }
.cm-toggle {
  width: 100%; display: flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--line); background: var(--card);
  border-radius: 12px; padding: 11px 14px;
  font-size: 15px; font-weight: 600; color: var(--primary);
}
.cm-toggle:active { background: var(--primary-bg); }
.cm-caret { margin-left: auto; color: var(--text2); font-size: 12px; }
.q-comments.open .cm-toggle { border-color: var(--primary); }
.cm-body { margin-top: 10px; display: flex; flex-direction: column; gap: 10px; }
.q-comments:not(.open) .cm-body { display: none; }
.cm-list { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.cm-count { font-size: 12px; color: var(--text2); font-variant-numeric: tabular-nums; }
.cm-item { background: #f7f8fa; border-radius: 12px; padding: 10px 12px; }
.cm-author { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text2); margin-bottom: 4px; flex-wrap: wrap; }
.cm-author b { color: var(--text); font-size: 13px; }
.cm-vip, .cm-jh { font-size: 11px; color: #b8860b; background: #fdf3d7; border-radius: 4px; padding: 1px 5px; }
.cm-loc { font-size: 11px; color: var(--text2); }
.cm-likes { margin-left: auto; font-size: 12px; font-variant-numeric: tabular-nums; }
.cm-content { font-size: 15px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.cm-time { margin-top: 4px; font-size: 11px; color: var(--text2); }
.cm-replies { margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.cm-reply { font-size: 13px; color: #444; background: #fff; border-radius: 8px; padding: 6px 9px; line-height: 1.5; }
.cm-reply b { font-size: 12px; }
.cm-note { text-align: center; color: var(--text2); font-size: 13px; padding: 10px; }
.cm-error { background: var(--danger-bg); color: var(--danger); border-radius: 10px; padding: 10px 12px; font-size: 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ai-head { display: flex; align-items: center; gap: 8px; padding: 10px 8px 6px 14px; }
.ai-head b { font-size: 16px; }
.ai-head .muted { flex: 1; font-size: 12px; }
.ai-chat {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 14px 8px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 180px;
}
.ai-msg {
  max-width: 88%; padding: 10px 12px; border-radius: 12px;
  font-size: 15px; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
}
.ai-msg.user {
  align-self: flex-end; background: var(--primary); color: #fff;
  border-bottom-right-radius: 4px;
}
.ai-msg.bot {
  align-self: flex-start; background: #f2f4f8; color: var(--text);
  border-bottom-left-radius: 4px;
}
.ai-msg.bot.thinking { color: var(--text2); }

/* 弹窗顶部的本题信息（题干/选项/正确答案） */
.ai-qcontext {
  margin: 0 14px 8px;
  background: #f6f7fa; border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px; line-height: 1.55;
  max-height: 140px; overflow-y: auto;
}
.ai-qcontext .q { font-weight: 600; }
.ai-qcontext .opts { color: var(--text2); margin-top: 2px; }
.ai-qcontext .ans { color: var(--success); font-weight: 600; margin-top: 2px; }

/* 深度思考过程（可折叠） */
.ai-think-wrap { align-self: flex-start; max-width: 88%; }
.ai-think-label {
  display: block; border: 0; background: none; text-align: left;
  color: var(--text2); font-size: 12px; padding: 2px 0 4px;
}
.ai-think-text {
  display: block;
  background: #f6f7fa; color: var(--text2);
  font-size: 12px; line-height: 1.6;
  padding: 8px 10px; border-radius: 10px;
  max-height: 110px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}
.ai-think-wrap.closed .ai-think-text { display: none; }

/* 报错与重试 */
.ai-error {
  align-self: flex-start; max-width: 88%;
  background: var(--danger-bg); color: var(--danger);
  border-radius: 12px; padding: 10px 12px;
  font-size: 14px; line-height: 1.5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.ai-retry {
  border: 0; background: var(--danger); color: #fff;
  border-radius: 14px; padding: 6px 14px;
  font-size: 13px; font-weight: 600;
}
.ai-retry:active { opacity: .85; }
.ai-chips { display: flex; gap: 8px; padding: 4px 14px 8px; flex-wrap: wrap; }
.ai-chip {
  border: 1px solid var(--line); background: #fff; border-radius: 16px;
  padding: 7px 13px; font-size: 13px; color: var(--primary);
}
.ai-chip:active { background: var(--primary-bg); }
.ai-inputrow { display: flex; gap: 8px; padding: 4px 14px 0; }
.ai-inputrow input {
  flex: 1; height: 42px; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 0 12px; font-size: 16px; background: #fafbfc; color: var(--text);
  font-family: inherit;
}
.ai-inputrow input:focus { outline: none; border-color: var(--primary); background: #fff; }
.ai-inputrow .btn { min-height: 42px; padding: 0 16px; font-size: 15px; }
.ai-inputrow .btn:disabled { opacity: .5; }

/* ---------- 桌面端微调（非主要目标） ---------- */
@media (min-width: 700px) {
  .modal-mask, .sheet-mask { align-items: center; }
  .modal { border-radius: 16px; }
  .sheet, .ai-panel { border-radius: 16px; padding-bottom: 14px; }
}

/* ---------- 米菲陪伴主题：平涂色块、黑色轮廓与留白 ---------- */
body { background: var(--bg); }
button { transition: background .18s, transform .18s; }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible, input:focus-visible { outline: 3px solid #789880; outline-offset: 3px; }
.home { gap: 16px; padding-top: calc(24px + var(--safe-top)); }
.home-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.eyebrow { color: var(--text2); font-size: 12px; letter-spacing: 2px; }
h1, h2, p { margin-top: 0; }
.home-heading h1 { margin: 5px 0 0; font-size: 23px; letter-spacing: -.6px; }
.home-heading h1 span { color: #ba765b; }
.home-settings { border: 1px solid var(--line); background: #fff; border-radius: 50%; width: 44px; height: 44px; color: var(--text2); font-size: 23px; flex: none; }
.welcome-card { display: flex; align-items: center; justify-content: space-between; position: relative; padding: 23px 20px 19px; border-radius: 26px; background: #ffe6a4; border: 1.5px solid #292824; overflow: hidden; }
.welcome-tag { font-size: 11px; color: #886951; letter-spacing: 1px; }
.welcome-card h2 { font-size: 28px; line-height: 1.45; margin: 8px 0 10px; font-weight: 750; letter-spacing: 1px; }
.welcome-card p { font-size: 12px; margin-bottom: 0; color: #886951; }
.companion { width: 146px; flex: none; align-self: flex-end; margin: 0 -8px -8px -15px; }
.stat-card { border-radius: 22px; padding: 19px 20px; box-shadow: none; }
.stat-title { font-size: 12px; letter-spacing: .4px; }
.stat-main { display: flex; align-items: baseline; gap: 5px; font-size: 32px; margin: 5px 0 12px; line-height: 1.4; }
.stat-main span { font-size: 13px; font-weight: 400; opacity: .85; }
.stat-main small { margin-left: auto; font-weight: 400; font-size: 12px; }
.stat-sub { font-size: 12px; letter-spacing: .5px; }
.btn { border-radius: 15px; }
.home > .btn-primary { justify-content: space-between; padding: 0 22px; min-height: 58px; box-shadow: 0 3px 0 #292824; }
.home > .btn-primary span { font-size: 25px; font-weight: 400; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 6px; }
.section-heading h2 { font-size: 16px; margin: 0; }
.section-heading > span { font-size: 11px; color: var(--text2); }
.menu-grid { gap: 10px; }
.menu-btn { position: relative; min-height: 119px; border: 1px solid var(--line); padding: 14px 16px; gap: 4px; box-shadow: 0 3px 9px #604b3104; }
.menu-btn::after { content: '↗'; position: absolute; right: 16px; top: 16px; color: #b9a898; font-size: 17px; }
.menu-btn .menu-icon { font-size: 21px; font-style: normal; width: 32px; height: 32px; line-height: 32px; text-align: center; color: #98683a; background: #ffe1bd; border-radius: 11px; margin-bottom: 4px; }
.menu-btn:nth-child(2) .menu-icon { color: #5c7b65; background: #e2edf3; }
.menu-btn:nth-child(3) .menu-icon { color: #ad6652; background: #fbe3da; }
.menu-btn:nth-child(4) .menu-icon { color: #947343; background: #ffedac; }
.menu-btn b { font-size: 16px; }
.menu-btn span { font-size: 12px; }
.btn-exam { background: #fce6a3; border: 1.5px solid #292824; color: #292824; justify-content: space-between; padding: 0 18px; }
.exam-hint { font-size: 12px; font-weight: 400; }
.home-note { color: #8d7b6a; text-align: center; font-size: 12px; margin: 2px 0 -8px; }
.settings-entry { font-size: 12px; text-decoration: none; padding: 8px; min-height: 44px; }
.header-block { background: #fffaf3f5; }
.qcard { border: 1px solid var(--line); padding: 20px 18px; }
.qtext { font-size: 19px; line-height: 1.75; }
.qmeta { display: flex; flex-wrap: wrap; gap: 5px; }
.option { border-radius: 17px; min-height: 57px; }
.option .letter { color: #917a69; }
.streak-strip { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: #99774c; padding: 0 3px 13px; }
.streak-strip b { color: var(--primary); font-size: 16px; }
.streak-strip > span:last-child { font-size: 11px; }
.bottombar { background: #fffaf3f5; }
.result-page { min-height: calc(100dvh - 60px - var(--safe-top)); justify-content: flex-start; padding-top: 28px; }
.result-card, .result-card.fail { border: 1px solid var(--line); background: #fffefb; border-radius: 26px; }
.result-flower { font-size: 44px; line-height: 1.3; }
.result-title { font-size: 23px; margin: 12px 0 8px; }
.result-message { font-size: 13px; color: var(--text2); margin-bottom: 22px; }
.score { color: var(--primary); font-size: 64px; }
.result-card.pass .score { color: var(--success); }
.result-card.fail .pass-badge { color: #946f45; }
.result-grid { border-top: 1px dashed var(--line); padding-top: 20px; }
.result-grid b { font-size: 17px; }
.login-card { background: #fffefb; border: 1px solid var(--line); border-radius: 28px; }
.login-card .companion { width: 130px; align-self: center; margin: -10px 0 2px; }
.login-sub { font-size: 12px; }
.card { border: 1px solid var(--line); }
.card-title { color: #665448; font-size: 15px; font-weight: 650; }
.ai-inputrow input { min-width: 0; }
.ai-msg.bot, .ai-qcontext, .ai-think-text { background: #f7f1e9; }
/* 奖励层不阻挡答题；顶部短句自动消失，粒子限定生命周期。 */
.celebration { position: fixed; inset: 0; z-index: 75; pointer-events: none; }
.celebration > canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.celebration-banner { position: absolute; top: calc(var(--safe-top) + 18px); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 32px); border: 1px solid #edcf9d; border-radius: 18px; padding: 12px 20px; background: #fff9eaf5; color: #82572f; text-align: center; box-shadow: 0 8px 32px #7d4e2020; animation: celebration-arrive .3s ease-out; }
.celebration-banner strong { display: block; font-size: 17px; }
.celebration-copy span { display: block; font-size: 12px; margin-top: 3px; }
.celebration-level-5 .celebration-banner { background: #fff1daf5; border-color: #d9b279; }
@keyframes celebration-arrive { from { opacity: 0; translate: 0 -12px; } to { opacity: 1; translate: 0 0; } }
@media (max-width: 380px) {
  .home-heading h1 { font-size: 21px; }
  .welcome-card { padding: 20px 16px; }
  .welcome-card h2 { font-size: 26px; }
  .companion { width: 130px; }
  .welcome-card p { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

.stat-title, .stat-sub, .stat-main span { opacity: 1; }

.menu-btn { color: var(--text); }
.result-grid b { white-space: nowrap; }

/* 米菲绘本的平涂色块；橙色按钮用深色文字保证可读性。 */
.home > .btn-primary, .subject-switch button.on {
  background: #f47920; color: #242320; border: 1.5px solid #292824;
}
.home-heading h1 span { color: #c45311; }
.welcome-tag, .welcome-card p { color: #655328; }
.home-settings { border-color: #292824; color: #292824; }
.menu-btn { border-color: #c8c2b6; box-shadow: none; }
.menu-btn .menu-icon { color: #292824; }
.stat-card { border: 1.5px solid #292824; }
.celebration-banner { border-color: #292824; background: #fff4c9; color: #292824; }
.celebration-level-5 .celebration-banner { background: #ffe5a3; border-color: #292824; }

/* 分层位图米菲：画布负责肢体联动，DOM 保留键盘和触碰语义。 */
.miffy-scene {
  position: relative; display: block; width: 144px; height: 224px; flex: none;
  margin: 0; padding: 0; border: 0; background: none; color: var(--text);
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.miffy-scene:active:not(:disabled) { transform: none; }
.miffy-canvas { display: block; width: 100%; height: auto; aspect-ratio: 7 / 10; opacity: 0; }
.is-ready .miffy-canvas { opacity: 1; }
.miffy-fallback { position: absolute; top: 50%; left: 0; right: 0; font-size: 12px; text-align: center; color: var(--text2); }
.is-ready .miffy-fallback { display: none; }
.miffy-touch-hint { position: absolute; bottom: 0; left: -8px; right: -8px; font-size: 10px; color: #7e6742; text-align: center; white-space: nowrap; }
.miffy-speech { position: absolute; z-index: 2; left: 50%; top: -3px; transform: translateX(-50%); width: max-content; max-width: 174px; border-radius: 13px; padding: 6px 10px; font-size: 11px; line-height: 1.5; background: #fffdf7; border: 1px solid #e0c385; box-shadow: 0 3px 9px #715b1510; pointer-events: none; }
.miffy-speech:empty { display: none; }
.welcome-card { padding: 16px 18px 18px; overflow: visible; background: #fff0bf; border: 1px solid #efdb9b; }
.welcome-card > div { flex: 1; min-width: 0; }
.welcome-card h2 { font-size: 25px; letter-spacing: 0; }
.welcome-card p { max-width: 166px; line-height: 1.8; }
.welcome-card > .miffy-scene { margin: -7px -6px 0 0; }
.login-card > .miffy-scene { align-self: center; width: 126px; height: 192px; margin: -10px 0 8px; }
.celebration-banner { display: flex; align-items: center; gap: 6px; padding: 6px 14px 6px 3px; max-width: calc(100% - 28px); background: #fff8e8; border: 1px solid #e8c77a; }
.celebration-miffy { flex: none; width: 66px; }
.celebration-miffy .miffy-scene { width: 66px; height: 95px; }
.celebration-copy { text-align: left; min-width: 0; }
.celebration-copy strong { font-size: 16px; }
.celebration-copy span { font-size: 11px; }
.celebration-miffy .miffy-fallback { font-size: 9px; }
.result-miffy { display: flex; justify-content: center; margin: -16px 0 -12px; }
.result-miffy .miffy-scene { width: 95px; height: 135px; }
.result-miffy + .result-flower { font-size: 25px; }
@media (max-width: 380px) {
  .welcome-card { padding: 14px 16px 18px; }
  .welcome-card h2 { font-size: 24px; }
  .welcome-card .miffy-scene { width: 130px; height: 207px; }
}
