/* 数学奇妙岛 · Math Wonder Island · scoped to .math-root
   Phase 1 skeleton only：讲义/AI/数据渲染尚未接入，这里只提供壳层与 loading 骨架的最小样式。 */

/**
 * 色板与字体变量。
 *
 * ⚠ 选择器里为什么还有 `.math-fab` / `.math-ai-mask`：
 * CSS 自定义属性靠 **DOM 继承**往下传，而小乌龟 fab 与 AI 弹层挂在 `/math` 的
 * layout 上、是 `{children}` 的**兄弟节点，在 `.math-root` 外面**——够不着这份色板。
 * 只写 `.math-root` 时，弹层里的 `background: var(--bg)` 取不到值、整条声明失效，
 * 于是**弹层整个是透明的**（踩过）。`color: var(--ink)`、`border-color: var(--line)` 同理。
 *
 * 看例题弹层没这个问题——它由 page.tsx 渲染，在 `.math-root` 里面。
 *
 * ⚠ 只把**变量**给浮层，不给 background / min-height 那几条：
 * 那是页面壳层的属性，浮层拿了会在页面后面多出一屏底色。
 */
.math-root,
.math-fab,
.math-ai-mask {
  --bg: #f9f5f0;
  --bg-2: #f4f0e9;
  --bg-3: #efeae2;
  --ink: #1f1915;
  --ink-2: #423c37;
  --ink-3: #76706c;
  --ink-4: #a8a3a0;
  --line: #d3cec8;
  --line-2: #e5e0da;
  --accent: #bf6e3e;
  --accent-strong: #a85a2e;
  --accent-soft: rgba(191, 110, 62, 0.12);
  --cool: #496973;
  --warn: #b54c3d;
  --safe: #537d5c;

  /* 蜂蜜橙：比 --accent 亮一档、暖一档，专给小学生的「去看例题」按钮用。
     站内其它产品没有这个色——数学奇妙岛面向小学生，主站那档深陶土橙对孩子偏重。
     按 docs/design-tokens.md「染字不染物」例外：独立静态样式 public/*.css
     自带局部色板、写字面值（essay-ai.css 同样自定义了 --pray-gold 等）。 */
  --honey: #e8a05c;
  --honey-strong: #dd8f45;
  --honey-rgb: 232, 160, 92;
  /* 按钮字色。软底（16% 蜂蜜橙叠 8% 卡片底 ≈ #f5e2ce）很浅，字必须够深：
     实测 #96450d 对比度 5.28:1，达 WCAG AA 的 4.5（面向小学生、视力发育中，不踩线）。
     ⚠ 别为了"更活泼"把它往浅里调——试过 #c47a33 只有 2.70:1、#b35c00 只有 3.75:1，都不达标。
     活泼靠**饱和度**、不靠亮度：压低明度 + 拉满饱和 = 浓蜂蜜而非发灰。 */
  --honey-ink: #96450d;

  --serif: 'Noto Serif SC', 'Songti SC', serif;
  --sans: 'Inter', 'PingFang SC', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
}

/* 页面壳层自身的观感。**不并进上面那条**：浮层只该拿变量，
   拿了 min-height / background 会在页面后面多出一屏底色。 */
.math-root {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* 浮层同样要字色与字体——它们在 .math-root 外面，继承不到上面那条。 */
.math-fab,
.math-ai-mask {
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* 同上：作用域要和基础色板那条**保持一致**，否则支持 oklch 的浏览器上
   页面走 oklch、浮层走 hex，两边差一档色。 */
@supports (color: oklch(0.5 0 0)) {
  .math-root,
  .math-fab,
  .math-ai-mask {
    --bg: oklch(0.972 0.008 80);
    --bg-2: oklch(0.955 0.01 80);
    --bg-3: oklch(0.94 0.012 80);
    --ink: oklch(0.22 0.012 60);
    --ink-2: oklch(0.36 0.012 60);
    --ink-3: oklch(0.55 0.01 60);
    --ink-4: oklch(0.72 0.008 60);
    --line: oklch(0.86 0.01 70);
    --line-2: oklch(0.91 0.008 70);
    --accent: oklch(0.62 0.12 50);
    --accent-soft: oklch(0.62 0.12 50 / 0.12);
    --cool: oklch(0.5 0.04 220);
    --warn: oklch(0.55 0.14 30);
    --safe: oklch(0.55 0.07 150);
  }
}

/* 浮层同样要这套重置：否则弹层里的 <p>/<textarea> 带着浏览器默认外边距，
   气泡间距会突然变宽。 */
.math-root *,
.math-fab *,
.math-ai-mask * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 同上：链接重置也压成零特异度，否则 `.math-pager-dot`、`.math-quiz-missing`
   这类纯类选择器（0,1,0）会被 `.math-root a`（0,1,1）盖掉字色。 */
:where(.math-root a, .math-fab a, .math-ai-mask a) {
  color: inherit;
  text-decoration: none;
}

/**
 * ⚠ 用 :where() 把重置压成**零特异度**，否则它会盖掉所有带类的按钮样式。
 *
 * 踩过：原本写 `.math-root button`（特异度 0,1,1），而组件类如 `.math-xref-btn`
 * 只有 (0,1,0) —— 重置反而赢，把底色/描边/字色全抹成 none/inherit。
 * `[看例N]` 从 <a> 改成 <button> 后立刻露馅（变成光秃秃的文字+箭头），
 * 而「提交答案」「需要提示吗」「交卷」等一直是 <button> 的，其实一直被抹着。
 *
 * `:where(...)` 内的选择器不贡献特异度，所以这条降为 (0,0,0)：
 * 裸 <button> 仍被重置，任何带类的按钮都能正常覆盖。
 */
:where(.math-root button, .math-fab button, .math-ai-mask button) {
  font: inherit;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
}

.math-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px 32px;
}

.math-placeholder-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  background: #fff;
}

.math-placeholder-card h1 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 12px;
}

.math-placeholder-card p {
  color: var(--ink-3);
  line-height: 1.6;
}

/* ============================================================
   讲义页：页头 + 段落切换 + 正文排版
   ============================================================ */

.math-container {
  max-width: 860px;
}

.math-lesson-header {
  margin-bottom: 28px;
}

.math-lesson-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 8px;
}

.math-lesson-title {
  font-family: var(--serif);
  font-size: clamp(26px, 3.4vw, 36px);
  font-weight: 500;
  line-height: 1.25;
  color: var(--ink);
}

.math-lesson-segname {
  margin-top: 8px;
  font-size: 15px;
  color: var(--ink-3);
}

/* 讲次列表（/math 落地页） */

.math-lesson-list {
  display: grid;
  gap: 14px;
  list-style: none;
}

.math-lesson-card > a {
  display: grid;
  gap: 6px;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.math-lesson-card > a:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(31, 25, 21, 0.06);
}

.math-lesson-card-no {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.math-lesson-card-title {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--ink);
}

.math-lesson-card-meta {
  font-size: 13px;
  color: var(--ink-3);
}

/* 段落切换器 */

.math-segnav {
  margin-bottom: 36px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-2);
}

.math-segnav-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
}

.math-segnav-item > a,
.math-segnav-item > span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  color: var(--ink-2);
  background: #fff;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.math-segnav-item > a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.math-segnav-item.is-current > a {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.math-segnav-item.is-locked > span {
  color: var(--ink-4);
  background: var(--bg-2);
  border-style: dashed;
  cursor: default;
}

.math-segnav-order {
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0.7;
}

.math-segnav-soon {
  font-size: 11px;
  opacity: 0.8;
}

.math-segnav-progress {
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-3);
}

/* 作答区占位（作答/判分/记录未接入时的显式占位，避免看起来像页面坏了） */

.math-answer-slot {
  margin-top: 28px;
  padding: 18px 20px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--bg-2);
}

.math-answer-slot-tag {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink-4);
  margin-bottom: 6px;
}

.math-answer-slot-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-3);
}

/* 按需提示（挤牙膏式） */

.math-hints {
  margin-top: 24px;
}

.math-hints-btn {
  padding: 10px 20px;
  border-radius: 16px;
  border: 1.5px dashed rgba(var(--honey-rgb), 0.5);
  background: rgba(var(--honey-rgb), 0.1);
  color: var(--honey-ink);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.12s ease;
}

.math-hints-btn:hover {
  background: rgba(var(--honey-rgb), 0.2);
}

.math-hints-list {
  list-style: none;
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.math-hints-list li {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  border-left: 3px solid rgba(var(--honey-rgb), 0.55);
  border-radius: 0 8px 8px 0;
  background: var(--bg-2);
}

.math-hints-step {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--honey-ink);
}

.math-hints-text {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink-2);
}

/* 提示正文走 MathMarkdown（要渲染 $…$ 公式），在列表项里收一收段落间距 */
.math-hints-text .math-md {
  font-size: 15px;
  line-height: 1.7;
}

.math-hints-text .math-md > :last-child {
  margin-bottom: 0;
}

.math-hints-done {
  font-size: 14px;
  color: var(--ink-3);
}

/* 作答区 */

.math-answer {
  margin-top: 28px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

/* 已提交：换成"锁定"观感——绿描边 + 灰输入框 + 明显徽标 */
.math-answer.is-submitted {
  border-color: rgba(83, 125, 92, 0.45);
  background: rgba(83, 125, 92, 0.05);
}

.math-answer-tag {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink-4);
  margin-bottom: 12px;
}

.math-answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.math-answer-head .math-answer-tag {
  margin-bottom: 0;
}

.math-answer-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--safe);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* 例题底部弹层：讲解页点「看例N」就地弹出，关掉回原地（不改变页面高度） */

.math-sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(31, 25, 21, 0.42);
  animation: math-sheet-fade 0.16s ease;
}

.math-sheet {
  width: min(100%, 720px);
  max-height: min(86vh, 900px);
  display: flex;
  flex-direction: column;
  border-radius: 20px 20px 0 0;
  background: var(--bg);
  box-shadow: 0 -8px 40px rgba(31, 25, 21, 0.22);
  animation: math-sheet-rise 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

/* 桌面端离底一点，不贴死屏幕边 */
@media (min-width: 900px) {
  .math-sheet-mask {
    align-items: center;
  }

  .math-sheet {
    border-radius: 18px;
    max-height: min(84vh, 860px);
  }
}

.math-sheet-head {
  position: relative;
  flex: 0 0 auto;
  padding: 14px 52px 12px 24px;
  border-bottom: 1px solid var(--line-2);
}

.math-sheet-grip {
  display: block;
  width: 44px;
  height: 4px;
  margin: 0 auto 10px;
  border-radius: 999px;
  background: var(--line);
}

@media (min-width: 900px) {
  .math-sheet-grip {
    display: none;
  }
}

.math-sheet-title {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  color: var(--ink);
}

.math-sheet-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-2);
  color: var(--ink-3);
  font-size: 22px;
  line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
}

.math-sheet-close:hover {
  background: var(--bg-3);
  color: var(--ink);
}

.math-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 24px 28px;
}

/* 末尾的大按钮：例题有一屏多高，看到底部时关闭得在手边 */
.math-sheet-back {
  display: block;
  width: 100%;
  margin-top: 24px;
  padding: 14px 20px;
  border-radius: 18px;
  background: var(--honey);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(var(--honey-rgb), 0.38);
  transition: background 0.12s ease;
}

.math-sheet-back:hover {
  background: var(--honey-strong);
}

@keyframes math-sheet-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes math-sheet-rise {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .math-sheet-mask,
  .math-sheet {
    animation: none;
  }
}


/* 顶栏登录弹层：复用 .math-sheet-* 骨架，内容比 AI 弹层短得多，不撑满高度 */
.math-login-sheet {
  height: auto;
  max-height: min(80vh, 560px);
}

.math-login-sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom, 0px));
}

/* 「其他登录方式」折叠区：微信降级为次要入口后放这里 */
.math-ai-login-more {
  margin-top: 6px;
}

.math-ai-login-more > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--ink-3);
  list-style: none;
  padding: 6px 0;
}

.math-ai-login-more > summary::-webkit-details-marker {
  display: none;
}

.math-ai-login-more > summary::before {
  content: "▸ ";
}

.math-ai-login-more[open] > summary::before {
  content: "▾ ";
}

.math-ai-login-more .math-ai-login-wechat {
  width: 100%;
  margin-top: 8px;
}

.math-ai-login-hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-3);
}

/* ── 数学自有极简顶栏 ──────────────────────────────────────────────────────
   不用站内的 SiteTopNav：那是高考志愿的门头（雨来高考 AI / 志愿教程 / 自我定位…），
   小学生每页顶着「高考」既看不懂也不该看。这里只留：回数学岛 + 当前讲次 + 登录态。 */

.math-topnav {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line-2);
  background: var(--bg);
}

.math-topnav-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.math-topnav-name {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

.math-topnav-lesson {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  color: var(--ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.math-topnav-auth {
  flex: 0 0 auto;
  margin-left: auto;
}

.math-topnav-user {
  font-size: 14px;
  color: var(--ink-3);
}

.math-topnav-login {
  display: inline-flex;
  padding: 7px 16px;
  border-radius: 14px;
  border: 1.5px solid rgba(var(--honey-rgb), 0.5);
  background: rgba(var(--honey-rgb), 0.12);
  color: var(--honey-ink);
  font-size: 14px;
  font-weight: 600;
}

.math-topnav-login:hover {
  background: rgba(var(--honey-rgb), 0.22);
}

@media (max-width: 480px) {
  .math-topnav {
    gap: 10px;
    padding: 10px 14px;
  }

  /* 手机上讲次名让位给品牌与登录，别把顶栏挤成两行 */
  .math-topnav-lesson {
    display: none;
  }
}

/* ── 小乌龟 AI ────────────────────────────────────────────────────────────
   浮动入口 + 问答弹层。弹层复用上面的 .math-sheet-* 骨架（同一套交互语言：
   底部弹起、Esc 关闭、右上角 ×），这里只加对话专有的部分。 */

.math-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  /**
   * ⚠ 必须高于看例题弹层的遮罩（.math-sheet-mask = 60），低于 AI 弹层（.math-ai-mask = 70）。
   *
   * 踩过：原本是 50，被例题弹层那层铺满全屏的遮罩（inset:0、z 60）盖住——
   * 小乌龟看得见（遮罩半透明）却**点不动**。当初只设计了「AI 弹层能叠在例题弹层之上」，
   * 却漏了「AI 还没打开时，唤起它的入口正被例题遮罩压着」：能叠加但打不开，等于没实现。
   * 而学生看例题时想问「这道例题怎么做」恰恰是最自然的提问时刻。
   *
   * 低于 70 是因为 AI 弹层打开后 fab 本就会隐藏（免得压住「发送」键），两者不冲突。
   */
  z-index: 65;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

/* 形制抄志愿的 AiFab（54 圆、米白底、柔影），配色换成数学的蜂蜜橙 */
.math-fab-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #fffefa;
  border: 1px solid rgba(var(--honey-rgb), 0.45);
  box-shadow: 0 8px 24px rgba(31, 25, 21, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.math-fab-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(var(--honey-rgb), 0.36);
}

/* quiz 未交卷：灰掉但不隐藏——学生前四段用惯了，突然消失会以为坏了 */
.math-fab-btn.is-locked {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.55;
  border-color: var(--line);
  box-shadow: none;
}

.math-fab-btn.is-locked:hover {
  transform: none;
  box-shadow: none;
}

.math-fab-locked-tip {
  max-width: 190px;
  padding: 7px 11px;
  border-radius: 12px;
  background: rgba(31, 25, 21, 0.82);
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  text-align: right;
}

/* 叠在看例题弹层（60）之上：两者可同时开，看例题卡住能立刻问 */
.math-ai-mask {
  z-index: 70;
}

.math-ai-sheet {
  height: min(70vh, 620px);
}

/* 手机上限 70vh 且贴底：题目上半部不被挡住，学生能边看题边问 */
@media (min-width: 900px) {
  .math-ai-sheet {
    height: min(72vh, 680px);
    width: min(100%, 620px);
  }
}

.math-ai-location {
  margin-top: 4px;
  font-size: 13px;
  color: var(--ink-3);
}

.math-ai-thread {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.math-ai-bubble {
  max-width: 86%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.75;
}

.math-ai-bubble.is-assistant {
  align-self: flex-start;
  background: var(--bg-2);
  color: var(--ink);
  border-bottom-left-radius: 6px;
}

.math-ai-bubble.is-user {
  align-self: flex-end;
  background: rgba(var(--honey-rgb), 0.18);
  color: var(--honey-ink);
  border-bottom-right-radius: 6px;
}

/* 失败提示既不是学生说的也不是 AI 说的，样式上要一眼区分开 */
.math-ai-bubble.is-error {
  align-self: flex-start;
  background: var(--bg-3);
  color: var(--ink-2);
  border: 1px dashed var(--line);
}

.math-ai-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.math-ai-typing {
  color: var(--ink-3);
}

/* 就地登录表单：长在「请登录」那条气泡里，学生不离开题目 */
.math-ai-login {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.math-ai-login-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.math-ai-login-note {
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.6;
}

.math-ai-login-row {
  display: flex;
  gap: 8px;
}

.math-ai-login-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  /* 同输入框：小于 16px 时 iOS Safari 会自动放大页面 */
  font: inherit;
  font-size: 16px;
}

.math-ai-login-input:focus {
  outline: none;
  border-color: var(--honey);
}

.math-ai-login-send {
  flex: 0 0 auto;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid rgba(var(--honey-rgb), 0.5);
  background: rgba(var(--honey-rgb), 0.14);
  color: var(--honey-ink);
  font-size: 14px;
  font-weight: 600;
}

.math-ai-login-send:disabled {
  border-color: var(--line);
  background: var(--bg-3);
  color: var(--ink-3);
  cursor: not-allowed;
}

.math-ai-login-submit {
  margin-top: 2px;
  padding: 12px 20px;
  border-radius: 14px;
  background: var(--honey);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

.math-ai-login-submit:hover:not(:disabled) {
  background: var(--honey-strong);
}

.math-ai-login-submit:disabled {
  background: var(--line);
  color: var(--ink-3);
  cursor: not-allowed;
}

.math-ai-login-wechat {
  padding: 10px 20px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.math-ai-login-wechat:hover {
  border-color: var(--honey);
  color: var(--honey-ink);
}

.math-ai-login-error {
  font-size: 13px;
  color: var(--warn);
}

.math-ai-login-dev {
  font-size: 12px;
  color: var(--ink-3);
}

.math-ai-compose {
  flex: 0 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line-2);
}

.math-ai-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--ink);
  /* 16px 起步：iOS Safari 对更小的字号会自动放大页面 */
  font: inherit;
  font-size: 16px;
  line-height: 1.6;
  resize: none;
}

.math-ai-input:focus {
  outline: none;
  border-color: var(--honey);
}

.math-ai-send {
  flex: 0 0 auto;
  padding: 12px 22px;
  border-radius: 16px;
  background: var(--honey);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  transition: background 0.12s ease;
}

.math-ai-send:hover:not(:disabled) {
  background: var(--honey-strong);
}

.math-ai-send:disabled {
  background: var(--line);
  color: var(--ink-3);
  cursor: not-allowed;
}

/* 测验：随时可直达交卷页 */
.math-answer-tosubmit {
  margin-top: 12px;
  text-align: center;
  font-size: 14px;
}

.math-answer-tosubmit a {
  color: var(--honey-ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* 题间导航：放答题区正下方（不让小学生去页面底部翻页圆点那里找） */

.math-answer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line-2);
}

.math-answer-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 22px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #fff;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.math-answer-nav-btn:hover {
  border-color: var(--honey);
  color: var(--honey-ink);
  background: rgba(var(--honey-rgb), 0.08);
}

/* 「下一题」是主方向，给实心蜂蜜橙 */
.math-answer-nav-btn.is-next {
  border-color: transparent;
  background: var(--honey);
  color: #fff;
  box-shadow: 0 3px 10px rgba(var(--honey-rgb), 0.34);
}

.math-answer-nav-btn.is-next:hover {
  background: var(--honey-strong);
  color: #fff;
}

.math-answer-nav-btn.is-disabled {
  opacity: 0.3;
  cursor: default;
  background: var(--bg-2);
}

@media (max-width: 480px) {
  .math-answer-nav-btn {
    padding: 10px 14px;
    font-size: 14px;
  }
}

/* 「下一步」：提交后才出现。用蜂蜜橙「该你动手」色系，
   与左侧绿色「已提交/这题过了」区分开——绿=完成，橙=下一步该点这里。 */
.math-answer-next {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 12px 26px;
  border-radius: 18px;
  background: var(--honey);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(var(--honey-rgb), 0.4);
  transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.math-answer-next:hover {
  background: var(--honey-strong);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(var(--honey-rgb), 0.48);
}

.math-answer-next:active {
  transform: translateY(0);
}

/* 提交引导：填完要点提交，小学生不会天然知道 */
.math-answer-guide {
  margin-top: 14px;
  font-size: 14px;
  color: var(--honey-ink);
}

.math-answer-input input:disabled {
  background: var(--bg-3);
  color: var(--ink-2);
  border-color: var(--line);
  border-style: dashed;
  font-weight: 600;
  cursor: not-allowed;
  opacity: 1;
  -webkit-text-fill-color: var(--ink-2);
}

.math-answer-fields {
  display: grid;
  gap: 12px;
}

.math-answer-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.math-answer-label {
  font-size: 15px;
  color: var(--ink-2);
}

.math-answer-input {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.math-answer-input input {
  width: 150px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  font-family: var(--sans);
  font-size: 16px;
  color: var(--ink);
}

.math-answer-input input:focus {
  outline: none;
  border-color: var(--honey);
  background: #fff;
}

.math-answer-input em,
.math-answer-value em {
  font-style: normal;
  font-size: 14px;
  color: var(--ink-3);
}

.math-answer-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

/* 提交是这一页的主操作，比跨段引用那种软按钮更重：实心蜂蜜橙 + 更大点击区，
   让小学生一眼看到"这里要点一下"。 */
.math-answer-submit {
  padding: 13px 30px;
  border-radius: 18px;
  border: none;
  background: var(--honey);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 3px 10px rgba(var(--honey-rgb), 0.4);
  transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.math-answer-submit:hover:not(:disabled) {
  background: var(--honey-strong);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(var(--honey-rgb), 0.48);
}

.math-answer-submit:active:not(:disabled) {
  transform: translateY(0);
}

.math-answer-submit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.math-answer-hint,
.math-answer-note {
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.7;
}

.math-answer-readback {
  list-style: none;
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.math-answer-readback li {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
}

.math-answer-value {
  font-size: 17px;
  font-weight: 600;
  color: var(--honey-ink);
}

/* 选择题：整行可点（小学生点击精度差，只让小圆点可点很难选中） */

.math-choices {
  display: grid;
  gap: 10px;
  list-style: none;
}

.math-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.math-choice:hover {
  border-color: rgba(var(--honey-rgb), 0.6);
  background: rgba(var(--honey-rgb), 0.06);
}

.math-choice input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.math-choice-id {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--line);
  border-radius: 50%;
  background: var(--bg-2);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-3);
}

.math-choice-text {
  font-size: 16px;
  color: var(--ink-2);
}

.math-choice.is-picked {
  border-color: var(--honey);
  background: rgba(var(--honey-rgb), 0.14);
}

.math-choice.is-picked .math-choice-id {
  border-color: var(--honey);
  background: var(--honey);
  color: #fff;
}

.math-choice.is-picked .math-choice-text {
  color: var(--honey-ink);
  font-weight: 600;
}

.math-choices.is-readonly .math-choice {
  cursor: default;
  opacity: 0.55;
}

.math-choices.is-readonly .math-choice.is-picked {
  opacity: 1;
}

/* 测验说明条：告诉学生这里不逐题交 */

.math-quiz-notice {
  margin-bottom: 22px;
  padding: 12px 18px;
  border-left: 3px solid var(--cool);
  border-radius: 0 8px 8px 0;
  background: rgba(73, 105, 115, 0.08);
}

.math-quiz-notice .math-md {
  font-size: 14px;
}

.math-quiz-notice .math-md > :last-child {
  margin-bottom: 0;
}

/* 交卷页 */

.math-quiz-submit {
  padding: 28px 24px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  text-align: center;
}

.math-quiz-missing {
  display: inline-block;
  margin: 0 4px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(var(--honey-rgb), 0.16);
  color: var(--honey-ink);
  font-weight: 600;
}

.math-quiz-submit-btn {
  margin-top: 18px;
  padding: 14px 36px;
  border: none;
  border-radius: 18px;
  background: var(--honey);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(var(--honey-rgb), 0.42);
  transition: background 0.12s ease, transform 0.12s ease;
}

.math-quiz-submit-btn:hover:not(:disabled) {
  background: var(--honey-strong);
  transform: translateY(-1px);
}

.math-quiz-submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 成绩 */

.math-quiz-score {
  margin-bottom: 24px;
  padding: 24px;
  border: 1px solid rgba(var(--honey-rgb), 0.35);
  border-radius: 12px;
  background: rgba(var(--honey-rgb), 0.1);
  text-align: center;
}

.math-quiz-score-num {
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--honey-ink);
}

.math-quiz-score-num span {
  font-size: 22px;
  color: var(--ink-3);
}

.math-quiz-score-note {
  margin-top: 8px;
  font-size: 15px;
  color: var(--ink-2);
}

.math-quiz-retry {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.math-quiz-retry-btn {
  padding: 11px 24px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: #fff;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-2);
  transition: border-color 0.12s ease, color 0.12s ease;
}

.math-quiz-retry-btn:hover {
  border-color: var(--honey);
  color: var(--honey-ink);
}

/* 逐题就地展开的参考答案（04 挑战练习） */

.math-item-solution {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid rgba(83, 125, 92, 0.35);
  border-radius: 10px;
  background: rgba(83, 125, 92, 0.05);
}

/* 不判分题：中性灰蓝，不用绿——绿在别处是「这题过了/对了」的语义 */
.math-item-solution.is-ungraded {
  border-color: rgba(73, 105, 115, 0.32);
  background: rgba(73, 105, 115, 0.06);
}

.math-item-solution-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-2);
}

.math-item-solution-title {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

.math-item-solution-neutral {
  flex: 0 0 auto;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(73, 105, 115, 0.14);
  color: var(--cool);
  font-size: 13px;
  font-weight: 600;
}

.math-item-solution-note {
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-3);
}

/* 自由文字输入（不判分题）：比数值框宽 */
.math-answer-field.is-text {
  align-items: flex-start;
  flex-direction: column;
  gap: 8px;
}

.math-answer-input.is-wide {
  width: 100%;
}

.math-answer-input.is-wide input {
  width: min(100%, 420px);
}

/* 统一复盘 */

.math-review,
.math-review-locked {
  margin-top: 8px;
}

.math-review-locked {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--bg-2);
  text-align: center;
}

.math-review-locked-title {
  font-family: var(--serif);
  font-size: 19px;
  color: var(--ink);
  margin-bottom: 8px;
}

.math-review-progress {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-4);
}

.math-review-note {
  font-size: 14px;
  color: var(--ink-3);
  line-height: 1.7;
}

.math-review-score {
  padding: 14px 18px;
  border-radius: 10px;
  background: rgba(var(--honey-rgb), 0.12);
  border: 1px solid rgba(var(--honey-rgb), 0.3);
  font-size: 16px;
  color: var(--ink-2);
  margin-bottom: 20px;
}

.math-review-score strong {
  font-size: 20px;
  color: var(--honey-ink);
}

.math-review-item {
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: #fff;
}

.math-review-item.is-correct {
  border-left: 4px solid var(--safe);
}

.math-review-item.is-wrong {
  border-left: 4px solid var(--honey);
}

.math-review-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-2);
}

.math-review-item-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.math-review-verdict {
  font-size: 14px;
  color: var(--ink-3);
}

.math-review-question .math-md {
  font-size: 15px;
}

.math-review-answers {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--bg-2);
}

.math-review-answers dt {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--ink-4);
  margin-bottom: 4px;
}

.math-review-answers dd {
  font-size: 16px;
  color: var(--ink-2);
}

.math-review-answer-chip {
  display: inline-block;
  margin-right: 12px;
}

.math-review-answers dd.is-correct-answer {
  font-weight: 600;
  color: var(--safe);
}

.math-review-solution {
  padding-top: 6px;
  border-top: 1px dashed var(--line-2);
}

.math-review-solution .math-md {
  font-size: 15px;
}

.math-review-solution .math-md h2 {
  font-size: 16px;
  margin: 14px 0 10px;
}

/* 跨段引用卡：手法卡末尾「去看例题」/「后面会用到」 */

.math-xref {
  display: flex;
  gap: 12px;
  margin-top: 28px;
  padding: 18px 20px;
  border-radius: 10px;
}

.math-xref-icon {
  flex: 0 0 auto;
  font-size: 20px;
  line-height: 1.4;
}

.math-xref-main {
  flex: 1 1 auto;
  min-width: 0;
}

.math-xref-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-2);
}

/* 能跳的：蜂蜜橙软底 + 软按钮。比深陶土橙轻快柔和，适合小学生 */
.math-xref-go {
  border: 1px solid rgba(var(--honey-rgb), 0.32);
  background: rgba(var(--honey-rgb), 0.08);
}

.math-xref-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.math-xref-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 16px;
  background: rgba(var(--honey-rgb), 0.16);
  border: 1.5px solid rgba(var(--honey-rgb), 0.45);
  color: var(--honey-ink);
  font-size: 15px;
  font-weight: 600;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.math-xref-btn:hover {
  background: rgba(var(--honey-rgb), 0.26);
  border-color: rgba(var(--honey-rgb), 0.6);
}

/* 跳不了的：中性底、无按钮、不做成链接样式，避免学生去点一个点不动的东西 */
.math-xref-later {
  align-items: center;
  border: 1px dashed var(--line);
  background: var(--bg-2);
}

.math-xref-later .math-xref-text {
  color: var(--ink-3);
}

/* 「下一步」引导：学完一招/一段，往前走的主按钮。
   刻意与 .math-xref-btn（软底描边、卡片里面）拉开——
   实心蜂蜜橙 + 卡片外独立一行，语义是「学完了，往前走」，不是「顺便看一眼」。 */
.math-nextstep {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

.math-nextstep-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: 20px;
  background: var(--honey);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(var(--honey-rgb), 0.42);
  transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}

.math-nextstep-btn:hover {
  background: var(--honey-strong);
  transform: translateY(-1px);
  box-shadow: 0 5px 18px rgba(var(--honey-rgb), 0.5);
}

.math-nextstep-btn:active {
  transform: translateY(0);
}

@media (max-width: 480px) {
  .math-nextstep {
    justify-content: stretch;
  }

  .math-nextstep-btn {
    justify-content: center;
    width: 100%;
  }
}

/* 段内翻页器 */

.math-pager {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--line-2);
}

.math-pager-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
}

.math-pager-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-3);
  transition: border-color 0.15s ease, color 0.15s ease;
}

.math-pager-dot:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.math-pager-dot.is-current {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.math-pager-arrows {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.math-pager-arrow {
  flex: 0 1 auto;
  max-width: 42%;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.math-pager-arrow:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.math-pager-arrow.is-disabled {
  opacity: 0.35;
  cursor: default;
}

.math-pager-count {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink-3);
}

/* ============================================================
   .math-md —— 讲义正文排版（作用域限定，勿污染全站）
   与 chatbot 的 .chat-md 分开：那套是按聊天气泡收敛过字号的，
   这里要的是正文阅读排版。
   ============================================================ */

.math-md {
  font-size: 16px;
  line-height: 1.8;
  color: var(--ink-2);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.math-md > :first-child {
  margin-top: 0;
}

.math-md p {
  margin: 0 0 1em;
}

.math-md h1,
.math-md h2,
.math-md h3,
.math-md h4 {
  font-family: var(--serif);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}

.math-md h1 {
  font-size: 27px;
  margin: 0 0 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line-2);
}

.math-md h2 {
  font-size: 22px;
  margin: 40px 0 16px;
}

.math-md h3 {
  font-size: 18px;
  margin: 30px 0 12px;
  padding-left: 11px;
  border-left: 3px solid var(--accent);
}

.math-md h4 {
  font-size: 16px;
  margin: 22px 0 10px;
}

.math-md strong {
  font-weight: 600;
  color: var(--ink);
}

.math-md em {
  font-style: italic;
}

.math-md ul,
.math-md ol {
  margin: 0 0 1em;
  padding-left: 1.5em;
}

.math-md li {
  margin-bottom: 0.4em;
}

.math-md li::marker {
  color: var(--accent);
}

/* 提示块：md 里大量使用 `> 🔑 / 📐 / 👉 / 💡 / ✅` 引导语 */
.math-md blockquote {
  margin: 0 0 1.2em;
  padding: 14px 18px;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
  background: var(--bg-2);
  color: var(--ink-2);
}

.math-md blockquote p:last-child {
  margin-bottom: 0;
}

.math-md hr {
  margin: 32px 0;
  border: 0;
  border-top: 1px solid var(--line-2);
}

/* 行内代码：md 里用来标节点/题型，如 `计算题` */
.math-md code {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-3);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.88em;
}

/* 表格 */
.math-md-tablewrap {
  margin: 0 0 1.4em;
  overflow-x: auto;
}

.math-md table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.math-md th,
.math-md td {
  padding: 10px 14px;
  border: 1px solid var(--line-2);
  text-align: left;
}

.math-md th {
  background: var(--bg-3);
  font-weight: 600;
  color: var(--ink);
}

.math-md tbody tr:nth-child(even) {
  background: var(--bg-2);
}

/* 插图：原书 PDF 截图，白底，给一层描边免得和页面糊在一起 */
.math-md-figure {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 20px auto;
  padding: 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: #fff;
}

/* KaTeX：块级公式居中留白，长公式可横向滚动而不撑破版心 */
.math-md .katex-display {
  margin: 1.1em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}

.math-md .katex {
  font-size: 1.04em;
}

@media (max-width: 640px) {
  .math-container {
    padding: 28px 18px;
  }

  .math-md {
    font-size: 15px;
  }

  .math-md h1 {
    font-size: 23px;
  }

  .math-md h2 {
    font-size: 20px;
  }
}

/* Loading skeleton — 结构照抄 essay-ai.css 的 product-loading 骨架 */

.math-root .product-loading-skeleton {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

.math-root .product-loading-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 72px;
  border-bottom: 1px solid var(--line-2);
  padding: 0 56px;
}

.math-root .product-loading-brand,
.math-root .product-loading-tabs span,
.math-root .product-loading-line,
.math-root .product-loading-actions span,
.math-root .product-loading-card-head,
.math-root .product-loading-card-grid span {
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(31, 25, 21, 0.08);
}

.math-root .product-loading-brand::after,
.math-root .product-loading-tabs span::after,
.math-root .product-loading-line::after,
.math-root .product-loading-actions span::after,
.math-root .product-loading-card-head::after,
.math-root .product-loading-card-grid span::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.48), transparent);
  animation: product-loading-shimmer 1.35s ease-in-out infinite;
}

.math-root .product-loading-brand {
  width: 188px;
  height: 24px;
}

.math-root .product-loading-tabs {
  display: flex;
  gap: 12px;
}

.math-root .product-loading-tabs span {
  width: 94px;
  height: 34px;
}

.math-root .product-loading-main {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: 48px;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
  padding: 96px 56px 140px;
}

.math-root .product-loading-copy {
  display: grid;
  gap: 18px;
}

.math-root .product-loading-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

.math-root .product-loading-copy h1 {
  font-family: var(--serif);
  font-size: clamp(34px, 4vw, 54px);
  font-weight: 500;
  line-height: 1.2;
  color: var(--ink);
}

.math-root .product-loading-line {
  width: 72%;
  height: 14px;
  border-radius: 999px;
}

.math-root .product-loading-line.is-wide {
  width: 92%;
}

.math-root .product-loading-actions {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.math-root .product-loading-actions span {
  width: 132px;
  height: 42px;
}

.math-root .product-loading-card {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
  padding: 26px;
  box-shadow: 0 24px 70px rgba(31, 25, 21, 0.08);
}

.math-root .product-loading-card-head {
  width: 46%;
  height: 22px;
  margin-bottom: 26px;
}

.math-root .product-loading-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.math-root .product-loading-card-grid span {
  height: 126px;
  border-radius: 8px;
}

@keyframes product-loading-shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* ─────────────────────────────────────────────────────────────
   家长注册（/math/enroll）
   ⚠ 这一屏给**家长**看，不是给学生看：字号偏保守、不用小乌龟的圆润语气，
   同意书正文行高放宽（家长要真读完，而不是划过去）。
   复用 .math-root 的调色板，不新造颜色。
   ───────────────────────────────────────────────────────────── */
.math-enroll {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 4px 48px;
}
.math-enroll-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}
.math-enroll-hint {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-2);
}
.math-enroll-note {
  font-size: 13px;
  color: var(--ink-3);
}
.math-enroll-matched {
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 15px;
  font-weight: 700;
}
.math-enroll-input {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 16px; /* ⚠ 16px 以下 iOS Safari 聚焦时会自动放大页面 */
}
.math-enroll-input:focus {
  outline: none;
  border-color: var(--accent);
}
.math-enroll-submit {
  padding: 12px 20px;
  border-radius: 14px;
  background: var(--honey);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}
.math-enroll-submit:hover:not(:disabled) {
  background: var(--honey-strong);
}
.math-enroll-submit:disabled {
  background: var(--line);
  color: var(--ink-3);
  cursor: not-allowed;
}
.math-enroll-back {
  align-self: center;
  padding: 6px;
  color: var(--ink-3);
  font-size: 14px;
  text-decoration: underline;
}
/* 同意书正文。⚠ 不加 max-height + overflow：滚动条会让家长以为「读到底了」，
   而实际还有半屏没看——知情同意不能被折叠起来。 */
.math-enroll-consent {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: var(--bg-2);
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.85;
}
.math-enroll-consent-title {
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}
.math-enroll-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  cursor: pointer;
}
.math-enroll-check input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex: none;
  accent-color: var(--accent);
}
.math-enroll-done {
  font-size: 20px;
  font-weight: 700;
  color: var(--safe);
}
.math-enroll-error {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(181, 76, 61, 0.1);
  color: var(--warn);
  font-size: 14px;
  line-height: 1.7;
}

/* ─────────────────────────────────────────────────────────────
   小乌龟登场 + 起名（/math 首次进入）
   ⚠ 这一屏给**学生**看：字号大、行距松、按钮手指点得到。
   与家长注册那一屏（.math-enroll-*）是两套语气，刻意不共用样式。
   ───────────────────────────────────────────────────────────── */
.math-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 460px;
  margin: 0 auto;
  padding: 32px 8px 48px;
  text-align: center;
}
.math-intro-turtle {
  font-size: 64px;
  line-height: 1;
}
.math-intro-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 16px;
  line-height: 1.8;
  color: var(--ink-2);
}
.math-intro-ask {
  margin-top: 8px;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
}
.math-intro-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.math-intro-suggestion {
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}
.math-intro-suggestion:hover {
  border-color: var(--honey);
  background: var(--accent-soft);
}
.math-intro-custom {
  display: flex;
  gap: 8px;
  width: 100%;
}
.math-intro-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 16px; /* ⚠ 低于 16px 时 iOS Safari 聚焦会放大整页 */
  text-align: center;
}
.math-intro-input:focus {
  outline: none;
  border-color: var(--honey);
}
.math-intro-submit {
  flex: none;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--honey);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}
.math-intro-submit:hover:not(:disabled) {
  background: var(--honey-strong);
}
.math-intro-submit:disabled {
  background: var(--line);
  color: var(--ink-3);
  cursor: not-allowed;
}
.math-intro-error {
  color: var(--warn);
  font-size: 15px;
}

/* ─────────────────────────────────────────────────────────────
   表情基线 / 每讲反馈（权威版 §六）
   ⚠ 一次一题、五档横排。表情要大——小学生是照着脸挑，不是照着字挑。
   ───────────────────────────────────────────────────────────── */
.math-mood {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 520px;
  margin: 0 auto;
  padding: 32px 8px 48px;
  text-align: center;
}
.math-mood-greeting {
  font-size: 16px;
  line-height: 1.8;
  color: var(--ink-2);
}
.math-mood-progress {
  color: var(--ink-3);
  font-size: 13px;
  letter-spacing: 0.08em;
}
.math-mood-prompt {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--ink);
}
.math-mood-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.math-mood-option {
  display: flex;
  flex: 1 1 84px;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 84px;
  padding: 14px 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}
.math-mood-option:hover:not(:disabled) {
  border-color: var(--honey);
  background: var(--accent-soft);
}
.math-mood-option:disabled {
  opacity: 0.5;
}
.math-mood-emoji {
  font-size: 32px;
  line-height: 1;
}
.math-mood-label {
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.4;
}
.math-mood-back {
  padding: 6px;
  color: var(--ink-3);
  font-size: 14px;
  text-decoration: underline;
}
.math-mood-error {
  color: var(--warn);
  font-size: 15px;
}

/* ─────────────────────────────────────────────────────────────
   问卷两段（权威版 §四 §五）
   与表情基线同一套骨架：一次一题、选项大、居中。
   ───────────────────────────────────────────────────────────── */
.math-survey {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 520px;
  margin: 0 auto;
  padding: 32px 8px 48px;
  text-align: center;
}
.math-survey-progress {
  color: var(--ink-3);
  font-size: 13px;
  letter-spacing: 0.08em;
}
.math-survey-prompt {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.6;
  color: var(--ink);
}
.math-survey-hint,
.math-survey-opening-sub {
  color: var(--ink-3);
  font-size: 14px;
  line-height: 1.7;
}
/* 第二段开场语：给学生看的「没有对错、会保密」。放大、留白，让它被读到。 */
.math-survey-opening {
  padding: 20px 16px;
  border-radius: 16px;
  background: var(--bg-2);
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.9;
}
/* 逐项评分时当前评的那一项 */
.math-survey-item {
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 19px;
  font-weight: 700;
}
.math-survey-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
}
.math-survey-option {
  position: relative;
  flex: 1 1 128px;
  min-width: 128px;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}
.math-survey-option:hover:not(:disabled) {
  border-color: var(--honey);
  background: var(--accent-soft);
}
.math-survey-option:disabled:not(.is-picked) {
  opacity: 0.5;
}
.math-survey-option.is-picked {
  border-color: var(--honey);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}
/* 排序题里已选课程右上角的名次 */
.math-survey-rank {
  position: absolute;
  top: 6px;
  right: 10px;
  color: var(--honey-strong);
  font-size: 13px;
  font-weight: 700;
}
.math-survey-next {
  padding: 12px 28px;
  border-radius: 14px;
  background: var(--honey);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}
.math-survey-next:hover {
  background: var(--honey-strong);
}
.math-survey-back {
  padding: 6px;
  color: var(--ink-3);
  font-size: 14px;
  text-decoration: underline;
}
.math-survey-error {
  color: var(--warn);
  font-size: 15px;
}

/* ─────────────────────────────────────────────────────────────
   首次进入的位置介绍 / 每讲 quiz 前的表情反馈
   两者都是整屏遮罩上的一张卡，层级见下方 .math-mood-gate/.math-tour 的注释。
   ───────────────────────────────────────────────────────────── */
/**
 * ⚠ 这两层必须**高于 fab（65）**，所以不能沿用 .math-sheet-mask 的 60。
 *
 * 踩过：第 6 步我在注释里写了「高于 fab（65）」，但实际用的是 .math-sheet-mask = 60，
 * 也就是 fab 反而浮在必答的表情反馈上面、学生能点开小乌龟——**写了一句没验证的断言**，
 * 和 #586 修的是同一类问题（那次是 fab 被例题遮罩盖住、点不动）。
 *
 * 为什么例题遮罩是 60 而这里要 75：看例题时 fab **应该**在上面
 *（学生要能边看例题边问小乌龟，那是 #586 特意修的）；而这两张卡一个是一次性介绍、
 * 一个是**必答**的测量，小乌龟浮在上面能被点开就没有意义。**用途不同，层级就该不同。**
 */
.math-mood-gate,
.math-tour {
  z-index: 75;
  /* .math-sheet-mask 是 align-items: flex-end（为底部弹层设计）。这两张是居中卡。 */
  align-items: center;
  padding: 16px;
}
.math-tour-card,
.math-mood-gate-card {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 24px 20px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--ink);
  text-align: center;
}
.math-tour-lead,
.math-mood-gate-lead {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}
.math-tour-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 20px 0 24px;
}
.math-tour-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border: 1px solid var(--line-2);
  border-radius: 14px;
  background: #fff;
  text-align: left;
}
.math-tour-icon {
  font-size: 28px;
  line-height: 1;
}
.math-tour-label {
  font-size: 17px;
  font-weight: 700;
}
.math-tour-ok {
  padding: 12px 32px;
  border-radius: 14px;
  background: var(--honey);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}
.math-tour-ok:hover {
  background: var(--honey-strong);
}
