/* ============================================================
 * theme.css —— 家庭学习工具统一主题
 * ------------------------------------------------------------
 * 设计基调：温暖橙 + 清新青绿点缀，学习感而非工具感
 *   - 触控友好：按钮/输入框最小高度 48px（>= 44px 触摸区）
 *   - 平板优先：768px 以上为主布局，窄屏自动降级为单列
 *   - 配色全部走 CSS 变量，后续调色只需改 :root
 * 命名约定：组件类用 .block、状态类用 .is-xxx、元素类用 .block-part
 * ============================================================ */

/* ------------------------------------------------------------
 * 1. 设计变量
 * ------------------------------------------------------------ */
:root {
  /* 主色：温暖橙 */
  --brand-50: #fff7ed;
  --brand-100: #ffedd5;
  --brand-200: #fed7aa;
  --brand-300: #fdba74;
  --brand-400: #fb923c;
  --brand-500: #f97316;
  --brand-600: #ea580c;
  --brand-700: #c2410c;

  /* 辅助色：清新青绿 */
  --accent-50: #f0fdfa;
  --accent-100: #ccfbf1;
  --accent-500: #14b8a6;
  --accent-600: #0d9488;

  /* 语义色 */
  --success-50: #f0fdf4;
  --success-200: #bbf7d0;
  --success-600: #16a34a;
  --success-700: #15803d;

  --danger-50: #fff1f2;
  --danger-200: #fecdd3;
  --danger-600: #e11d48;
  --danger-700: #be123c;

  --warn-50: #fffbeb;
  --warn-100: #fef3c7;
  --warn-600: #d97706;
  --warn-700: #b45309;
  --warn-800: #92400e;

  --info-50: #eff6ff;
  --info-200: #bfdbfe;
  --info-600: #2563eb;
  --info-700: #1d4ed8;

  /* 中性色（暖灰） */
  --ink-900: #292524;
  --ink-800: #3f3a36;
  --ink-700: #57534e;
  --ink-500: #78716c;
  --ink-400: #a8a29e;
  --ink-300: #d6d3d1;
  --ink-200: #e7e5e4;
  --ink-100: #f5f3f1;

  /* 表面与背景 */
  --page-bg: #fdf8f3;
  --page-bg-grad: linear-gradient(180deg, #fffaf4 0%, #fdf6ef 100%);
  --surface: #ffffff;
  --surface-soft: #fdfaf7;
  --line: #efe7df;
  --line-strong: #e0d5cb;

  /* 圆角 */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(120, 86, 50, 0.06), 0 1px 4px rgba(120, 86, 50, 0.05);
  --shadow: 0 4px 16px rgba(120, 86, 50, 0.08);
  --shadow-lg: 0 14px 36px rgba(120, 86, 50, 0.14);
  --shadow-brand: 0 8px 20px rgba(234, 88, 12, 0.26);

  /* 间距 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 44px;
  --space-8: 60px;

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  /* 公式字体栈（预留：接入 KaTeX 后生效，未接入时回退到系统数学字体） */
  --font-math: "KaTeX_Main", "KaTeX_Math", "Cambria Math", "Latin Modern Math",
    "Times New Roman", serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* 层级 */
  --z-auth: 99;
  --z-toast: 990;
  --z-modal: 1000;
  --z-loading: 1010;
  --z-cropper: 2000;

  /* F10：响应式断点（文档 / JS 参考值）。
     注意：CSS 自定义属性不能用于 @media 条件 —— 媒体查询在样式表解析期
     求值，而变量在元素上解析，写 @media (max-width: var(--bp-md)) 无效。
     故各 @media 仍使用字面量，但数值统一与此处对齐：sm=640 / md=768 / lg=1024。 */
  --bp-sm: 640px;
  --bp-md: 768px;
  --bp-lg: 1024px;
}

/* ------------------------------------------------------------
 * 2. 基础重置
 * ------------------------------------------------------------ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-900);
  background: var(--page-bg);
  background-image: var(--page-bg-grad);
  background-attachment: fixed;
  min-height: 100vh;
  /* iPad standalone 模式下 100vh 会把内容压到浏览器 UI 底下，dvh 才是可视高度 */
  min-height: 100dvh;
  /* 连续点击卡片时不要出现蓝色高亮块 */
  -webkit-tap-highlight-color: transparent;
  /* Prompt 24（iPad 防误触）：允许纵向滑动，但阻断双指缩放 / 双击缩放
     （iOS 13+ 支持 touch-action；双保险见 common.js 的 gesturestart 守卫） */
  touch-action: pan-y;
  /* 禁掉 iOS 的橡皮筋回弹，避免画板 / 弹层被整页带着晃 */
  overscroll-behavior: none;
  overflow-x: hidden;
}

/* Prompt 24：可点元素不参与双击缩放。已放开 viewport 缩放限制，
   双击缩放拦截改由 touch-action 处理，详见 common.js 手势守卫 */
button,
a,
input,
select,
textarea,
label,
[role="button"] {
  touch-action: manipulation;
}

/* 画板 / 裁剪器等手势区：手势完全交给 JS（touch-action 由各组件自声明 none），
   同时禁掉长按呼出菜单 / 选中 */
.hw-canvas,
.ic-stage {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  color: var(--brand-600);
  text-decoration: none;
}

a:hover {
  color: var(--brand-700);
}

/* ------------------------------------------------------------
 * 3. 布局
 * ------------------------------------------------------------ */
/* 工具类：显隐切换（配合 JS 的 classList.toggle 使用） */
.is-hidden {
  display: none !important;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  /* Prompt 24：black-translucent 状态栏悬浮在内容上，
     PWA standalone 模式必须用 safe-area 让出刘海 / 状态栏，普通浏览器 env=0 不受影响 */
  padding: calc(var(--space-5) + env(safe-area-inset-top, 0px))
    max(var(--space-4), env(safe-area-inset-right, 0px))
    calc(var(--space-7) + env(safe-area-inset-bottom, 0px))
    max(var(--space-4), env(safe-area-inset-left, 0px));
}

.page.is-narrow {
  max-width: 820px;
}

.page-head {
  margin-bottom: var(--space-5);
}

.page-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.page-sub {
  margin-top: var(--space-1);
  font-size: 14px;
  color: var(--ink-500);
}

.stack > * + * {
  margin-top: var(--space-4);
}

.stack-sm > * + * {
  margin-top: var(--space-2);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.row-wrap {
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--ink-500);
  margin-bottom: var(--space-3);
}

.back-link:hover {
  color: var(--brand-600);
}

/* ------------------------------------------------------------
 * 4. 卡片
 * ------------------------------------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.card + .card {
  margin-top: var(--space-4);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: 17px;
  font-weight: 700;
}

.card-hint {
  font-size: 13px;
  color: var(--ink-500);
}

.card-flat {
  box-shadow: none;
  background: var(--surface-soft);
}

/* ------------------------------------------------------------
 * 5. 按钮（触控区 >= 48px）
 * ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--ink-800);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease,
    border-color 0.18s ease, opacity 0.18s ease;
  user-select: none;
}

.btn:active {
  transform: scale(0.975);
}

.btn:focus-visible {
  outline: 3px solid var(--brand-200);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-600) 100%);
  color: #fff;
  box-shadow: var(--shadow-brand);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--brand-600) 0%, var(--brand-700) 100%);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink-700);
  border-color: var(--line-strong);
}

.btn-secondary:hover {
  border-color: var(--brand-300);
  color: var(--brand-700);
  background: var(--brand-50);
}

.btn-danger {
  background: var(--danger-600);
  color: #fff;
  border-color: var(--danger-600);
  /* F12：默认即实心红 + 加粗，触屏无 hover 也与 secondary 明显可辨 */
  font-weight: 700;
}

.btn-danger:hover {
  background: var(--danger-700);
  color: #fff;
  border-color: var(--danger-700);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-500) 0%, var(--accent-600) 100%);
  color: #fff;
  box-shadow: 0 8px 20px rgba(13, 148, 136, 0.24);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-500);
  padding: 0 var(--space-3);
}

.btn-ghost:hover {
  color: var(--brand-600);
  background: var(--brand-50);
}

.btn-lg {
  min-height: 60px;
  font-size: 19px;
  padding: 0 var(--space-6);
}

.btn-sm {
  min-height: 40px;
  font-size: 14px;
  padding: 0 var(--space-4);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn[disabled],
.btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-row {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.btn-row > .btn {
  flex: 1;
  min-width: 150px;
}

/* 轻微脉冲：强调「记入错题本」这类主行动 */
.btn-pulse {
  animation: btnPulse 2.4s ease-in-out infinite;
}

@keyframes btnPulse {
  0%,
  100% {
    box-shadow: var(--shadow-brand);
  }
  50% {
    box-shadow: 0 10px 26px rgba(234, 88, 12, 0.42);
  }
}

/* ------------------------------------------------------------
 * 6. 徽标 / 标签
 * ------------------------------------------------------------ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 700;
  background: var(--ink-100);
  color: var(--ink-700);
  white-space: nowrap;
}

.badge-brand {
  background: var(--brand-100);
  color: var(--brand-700);
}

.badge-accent {
  background: var(--accent-100);
  color: var(--accent-600);
}

.badge-success {
  background: var(--success-50);
  color: var(--success-700);
}

.badge-danger {
  background: var(--danger-50);
  color: var(--danger-700);
}

.badge-warn {
  background: var(--warn-100);
  color: var(--warn-800);
}

.badge-info {
  background: var(--info-50);
  color: var(--info-700);
}

/* 入口卡片上的角标 */
.badge-float {
  position: absolute;
  top: -10px;
  right: -10px;
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.35);
}

/* ------------------------------------------------------------
 * 7. 进度条
 * 动态宽度通过 CSS 变量 --progress 传入（唯一允许的内联样式）
 * ------------------------------------------------------------ */
.progress-bar {
  position: relative;
  width: 100%;
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--brand-100);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: var(--progress, 0%);
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--brand-400), var(--brand-600));
  /* Prompt 12 二、7：统一进度条动画时长为 300ms */
  transition: width 0.3s ease-out;
}

.progress-bar.is-thin {
  height: 8px;
}

.progress-bar.is-tall {
  height: 16px;
}

/* 进度数值文字（放在进度条右侧） */
.progress-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.progress-meta .progress-bar {
  flex: 1;
}

.progress-count {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-700);
  white-space: nowrap;
}

/* ------------------------------------------------------------
 * 8. 步骤条
 * ------------------------------------------------------------ */
.steps {
  display: flex;
  align-items: flex-start;
  list-style: none;
  padding: var(--space-2) 0;
}

.step {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

/* 连接线 */
.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 19px;
  left: calc(50% + 26px);
  right: calc(-50% + 26px);
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--ink-200);
}

.step.is-done:not(:last-child)::after {
  background: var(--success-200);
}

.step-dot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--ink-200);
  color: var(--ink-500);
  font-size: 16px;
  font-weight: 700;
  transition: all 0.25s ease;
}

.step-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-500);
  transition: color 0.25s ease;
}

.step.is-active .step-dot {
  border-color: var(--brand-500);
  background: var(--brand-500);
  color: #fff;
  box-shadow: 0 0 0 6px var(--brand-100);
}

.step.is-active .step-label {
  color: var(--brand-700);
}

.step.is-done .step-dot {
  border-color: var(--success-600);
  background: var(--success-600);
  color: #fff;
}

.step.is-done .step-label {
  color: var(--success-700);
}

/* 步骤条下方的细进度条（由 ui.renderProgressBar 生成） */
.step-progress .progress-bar {
  height: 8px;
}

/* ------------------------------------------------------------
 * 9. 表单
 * ------------------------------------------------------------ */
.field {
  margin-bottom: var(--space-4);
}

.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink-800);
}

.field-required {
  color: var(--danger-600);
}

.field-hint {
  margin-top: 5px;
  font-size: 12.5px;
  color: var(--ink-500);
}

.field-error {
  display: none;
  margin-top: 5px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger-600);
}

.field.is-error .field-error {
  display: block;
}

.field.is-error .input,
.field.is-error .textarea,
.field.is-error .select {
  border-color: var(--danger-600);
  background: var(--danger-50);
}

.input,
.textarea,
.select {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 16px;
  line-height: 1.5;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.65;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 4px var(--brand-100);
}

.input[readonly] {
  background: var(--warn-50);
  border-color: var(--brand-200);
  color: var(--warn-800);
  font-weight: 600;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-500);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

/* 选项列表（每项一个输入框 + 字母标记） */
.option-list {
  display: grid;
  gap: var(--space-2);
}

.option-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.option-letter {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--brand-50);
  border: 1.5px solid var(--brand-200);
  color: var(--brand-700);
  font-weight: 700;
  font-size: 16px;
}

.option-item .input {
  flex: 1;
}

/* ------------------------------------------------------------
 * 10. 提示条 / 提示块
 * ------------------------------------------------------------ */
.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.6;
  background: var(--info-50);
  color: var(--info-700);
  border: 1px solid var(--info-200);
}

.notice-info {
  background: var(--info-50);
  color: var(--info-700);
  border-color: var(--info-200);
}

.notice-warn {
  background: var(--warn-50);
  color: var(--warn-800);
  border-color: var(--warn-100);
}

.notice-danger {
  background: var(--danger-50);
  color: var(--danger-700);
  border-color: var(--danger-200);
}

.notice-success {
  background: var(--success-50);
  color: var(--success-700);
  border-color: var(--success-200);
}

.notice-brand {
  background: var(--brand-50);
  color: var(--brand-700);
  border-color: var(--brand-200);
}

.notice-icon {
  flex: none;
  font-size: 16px;
  line-height: 1.5;
}

/* 图形题提示（options 全空 + has_figure=true 时显示，替代选项区） */
.figure-hint {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--accent-50);
  border: 1.5px dashed var(--accent-500);
  color: var(--accent-600);
  font-size: 14.5px;
  font-weight: 600;
}

.figure-hint-icon {
  font-size: 26px;
  line-height: 1;
}

/* ------------------------------------------------------------
 * 11. 图片缩略图 / 预览
 * ------------------------------------------------------------ */
.thumb {
  display: inline-block;
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid var(--line-strong);
  background: var(--ink-100);
  cursor: zoom-in;
}

.thumb img {
  display: block;
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
}

.thumb::after {
  content: "点击放大";
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgba(41, 37, 36, 0.66);
  color: #fff;
  font-size: 11.5px;
}

/* 全屏看图 */
.image-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(28, 25, 23, 0.9);
}

.image-modal.is-visible {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.image-modal img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius-sm);
}

.image-modal-close {
  position: absolute;
  top: 18px;
  right: 20px;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

/* ------------------------------------------------------------
 * 12. 拍照区
 * ------------------------------------------------------------ */
.capture {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 240px;
  padding: var(--space-6) var(--space-4);
  border: 2.5px dashed var(--brand-300);
  border-radius: var(--radius-lg);
  background: var(--brand-50);
  color: var(--brand-700);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.12s ease;
}

.capture:hover {
  border-color: var(--brand-500);
  background: var(--brand-100);
}

.capture:active {
  transform: scale(0.99);
}

.capture-icon {
  font-size: 54px;
  line-height: 1;
}

.capture-title {
  font-size: 20px;
  font-weight: 700;
}

.capture-sub {
  font-size: 13.5px;
  color: var(--ink-500);
  font-weight: 400;
}

/* 摄像头/相册输入框保持可聚焦但视觉隐藏 */
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.preview-meta {
  font-size: 13px;
  color: var(--ink-500);
}

/* ------------------------------------------------------------
 * 13. AI 判断区
 * ------------------------------------------------------------ */
.ai-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--brand-50);
  border: 1.5px solid var(--brand-200);
}

.ai-panel-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-700);
}

/* 分段选择控件 */
.segmented {
  display: inline-flex;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
}

.segmented button {
  min-height: 42px;
  padding: 0 var(--space-4);
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-500);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
  white-space: nowrap;
}

.segmented button.is-active {
  background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.segmented button.is-active[data-value="right"] {
  background: linear-gradient(135deg, var(--accent-500), var(--accent-600));
}

/* ------------------------------------------------------------
 * 14. 鼓励语气泡
 * ------------------------------------------------------------ */
.encouragement {
  position: fixed;
  top: 18px;
  left: 50%;
  z-index: var(--z-toast);
  transform: translate(-50%, -160%);
  padding: 14px 30px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  color: #fff;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transition: transform 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.3s ease;
  max-width: min(86vw, 520px);
  text-align: center;
}

.encouragement.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ------------------------------------------------------------
 * 15. Toast（右下角）
 * ------------------------------------------------------------ */
.toast-wrap {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: min(86vw, 420px);
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-left: 5px solid var(--ink-400);
  box-shadow: var(--shadow-lg);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-800);
  opacity: 0;
  transform: translateX(28px);
  transition: opacity 0.26s ease, transform 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  pointer-events: auto;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast-icon {
  flex: none;
  font-size: 17px;
  line-height: 1;
}

.toast-text {
  word-break: break-word;
}

.toast-success {
  border-left-color: var(--success-600);
}

.toast-success .toast-icon {
  color: var(--success-600);
}

.toast-error {
  border-left-color: var(--danger-600);
}

.toast-error .toast-icon {
  color: var(--danger-600);
}

.toast-info {
  border-left-color: var(--info-600);
}

.toast-info .toast-icon {
  color: var(--info-600);
}

/* ------------------------------------------------------------
 * 16. 全屏加载
 * ------------------------------------------------------------ */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-loading);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(41, 37, 36, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.22s ease, visibility 0.22s ease;
}

.loading-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-7);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
  max-width: min(86vw, 420px);
}

.loading-spinner {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 5px solid var(--brand-100);
  border-top-color: var(--brand-500);
  animation: spin 0.9s linear infinite;
}

.loading-spinner.is-sm {
  width: 22px;
  height: 22px;
  border-width: 3px;
}

.loading-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-800);
}

.loading-sub {
  font-size: 13px;
  color: var(--ink-500);
  font-weight: 400;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* 行内加载（按钮或状态条里的迷你转圈） */
.inline-loading {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 14px;
  color: var(--brand-700);
  font-weight: 600;
}

/* ------------------------------------------------------------
 * 17. 确认对话框
 * ------------------------------------------------------------ */
.dialog-mask {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(41, 37, 36, 0.45);
  animation: fadeIn 0.18s ease;
}

.dialog {
  width: 100%;
  max-width: 460px;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: dialogIn 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.dialog-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: var(--space-2);
}

.dialog-message {
  font-size: 15px;
  color: var(--ink-700);
  line-height: 1.65;
  white-space: pre-line;
}

.dialog-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.dialog-actions > .btn {
  flex: 1;
}

@keyframes dialogIn {
  from {
    transform: translateY(16px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ------------------------------------------------------------
 * 18. 孩子端首页
 * ------------------------------------------------------------ */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-600) 62%, #f59e0b 100%);
  color: #fff;
  box-shadow: var(--shadow-brand);
}

.hero-greet {
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.hero-date {
  margin-top: 4px;
  font-size: 14.5px;
  color: rgba(255, 255, 255, 0.9);
}

.hero-emoji {
  font-size: 52px;
  line-height: 1;
}

.entry-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.entry-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  min-height: 152px;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--ink-900);
  cursor: pointer;
  text-align: left;
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.entry-card:hover {
  transform: translateY(-3px);
  border-color: var(--brand-300);
  box-shadow: var(--shadow);
  color: var(--ink-900);
}

.entry-card:active {
  transform: translateY(-1px) scale(0.995);
}

.entry-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: var(--radius);
  font-size: 30px;
  background: var(--brand-50);
}

.entry-card[data-tone="accent"] .entry-icon {
  background: var(--accent-50);
}

.entry-card[data-tone="info"] .entry-icon {
  background: var(--info-50);
}

.entry-card[data-tone="warn"] .entry-icon {
  background: var(--warn-50);
}

.entry-name {
  font-size: 20px;
  font-weight: 700;
}

.entry-desc {
  font-size: 13.5px;
  color: var(--ink-500);
  font-weight: 400;
}

.entry-card[data-pending="1"] .entry-name::after {
  content: "即将上线";
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--ink-100);
  color: var(--ink-500);
  font-size: 11.5px;
  font-weight: 700;
  vertical-align: middle;
}

.page-foot {
  margin-top: var(--space-6);
  text-align: center;
  font-size: 14px;
  color: var(--ink-500);
}

.page-foot strong {
  color: var(--brand-600);
}

/* ------------------------------------------------------------
 * 19. 入库成功页
 * ------------------------------------------------------------ */
.success-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-7) var(--space-5);
  text-align: center;
}

.check-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 32%, #fbbf24 0%, var(--brand-500) 48%, var(--brand-700) 100%);
  box-shadow: 0 16px 34px rgba(234, 88, 12, 0.3);
  animation: popIn 0.46s cubic-bezier(0.2, 0.9, 0.3, 1.35) both;
}

.check-circle svg {
  width: 74px;
  height: 74px;
}

.check-ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.42);
  stroke-width: 2.5;
}

.check-tick {
  fill: none;
  stroke: #fff;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 46;
  stroke-dashoffset: 46;
  animation: drawTick 0.42s ease-out 0.28s forwards;
}

@keyframes drawTick {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes popIn {
  0% {
    transform: scale(0.35);
    opacity: 0;
  }
  62% {
    transform: scale(1.08);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}

.success-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--brand-700);
}

.success-text {
  font-size: 15.5px;
  color: var(--ink-700);
  max-width: 460px;
}

.success-next {
  font-size: 14px;
  color: var(--ink-500);
  margin-top: var(--space-2);
}

/* ------------------------------------------------------------
 * 20. 口令输入条（由 common.js 生成，样式集中在此，避免内联样式）
 * ------------------------------------------------------------ */
.auth-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-auth);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: 10px var(--space-4);
  background: var(--warn-50);
  color: var(--warn-800);
  font-size: 13px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.auth-bar-label {
  font-weight: 600;
}

.auth-bar-input {
  width: 200px;
  min-height: 38px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-strong);
  font-size: 13px;
}

.auth-bar-btn {
  min-height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: var(--radius-xs);
  background: var(--warn-600);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.auth-bar-btn:hover {
  background: var(--warn-700);
}

.auth-tip {
  color: var(--brand-700);
  font-weight: 600;
}

/* ------------------------------------------------------------
 * 21. 平板适配
 * ------------------------------------------------------------ */
@media (min-width: 640px) {
  .entry-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 639px) {
  .field-row {
    grid-template-columns: 1fr;
  }

  .page {
    padding: var(--space-4) var(--space-3) var(--space-6);
  }

  .hero-greet {
    font-size: 22px;
  }

  .hero-emoji {
    font-size: 40px;
  }

  .toast-wrap {
    right: var(--space-3);
    left: var(--space-3);
    bottom: var(--space-3);
    align-items: stretch;
  }

  .toast {
    max-width: none;
  }
}

@media (min-width: 1024px) {
  .page {
    padding-top: var(--space-6);
  }
}

/* 尊重系统的「减少动效」偏好 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------
 * 整卷扫描页（scan-paper.html，Prompt 8 新增）
 * ------------------------------------------------------------ */

/* 题目卡片列表：平板单列，卡片间距 16px */
.paper-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.paper-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.paper-card.is-checked {
  border-color: var(--brand-300);
  box-shadow: var(--shadow);
}

/* 题号非数字：整卡标红（默认不勾选） */
.paper-card.is-danger {
  border-color: var(--danger-200);
  background: var(--danger-50);
}

/* 已成功入库的卡片：淡化显示 */
.paper-card.is-done {
  border-color: var(--success-200);
  opacity: 0.72;
}

.paper-card-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
}

.paper-check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  min-height: 44px; /* 平板触摸区 */
  cursor: pointer;
  user-select: none;
}

.paper-check-input {
  width: 26px;
  height: 26px;
  margin: 0;
  accent-color: var(--brand-500);
  cursor: pointer;
}

.paper-check-text {
  font-size: 14px;
  color: var(--ink-700);
}

.paper-card-icon {
  flex: none;
  font-size: 20px;
  line-height: 1.2;
  margin-top: 2px;
}

.paper-card-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.paper-card-title {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.paper-card-number {
  font-weight: 800;
  font-size: 16px;
  color: var(--ink-900);
  flex: none;
}

.paper-card-number.is-bad {
  color: var(--danger-600);
}

/* 长题干收起时截断省略，展开后完整显示 */
.paper-card-snippet {
  color: var(--ink-700);
  font-size: 15px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.paper-card.is-open .paper-card-snippet {
  display: block;
  -webkit-line-clamp: unset;
}

.paper-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* 展开编辑区：300ms 缓动展开，超高内滚动 */
.paper-card-detail {
  max-height: 0;
  overflow: hidden;
  border-top: 1px solid transparent;
  transition: max-height 0.3s ease, border-color 0.3s ease;
}

.paper-card.is-open .paper-card-detail {
  max-height: 72vh;
  overflow-y: auto;
  border-top-color: var(--line);
}

.paper-card-detail-inner {
  padding: var(--space-4);
}

/* 固定底部操作栏 */
.paper-actionbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(120, 86, 50, 0.08);
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom));
}

.paper-actionbar-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* 有底栏的页面留出底部空间，内容不被遮住 */
.page-has-actionbar {
  padding-bottom: 132px;
}

/* ============================================================
 * F11：长录入页主 CTA 固定底栏（无需移动 DOM）
 * ------------------------------------------------------------
 * 给流内主按钮加 .cta-fixed 即可：position:fixed 钉在视口底部。
 * 按钮仍留在原面板/表单内 —— 祖先 display:none 时 fixed 元素同样不渲染，
 * 因此多步骤页（拍照 → 确认）的互斥显隐、按钮 disabled、type=submit
 * 表单提交、id 事件绑定全部保持原样，不破坏既有逻辑。
 * ============================================================ */
.cta-fixed {
  position: fixed !important;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 991;                 /* 高于 pbottom-nav(90) / kbottom-nav(--z-toast:990) */
  width: 100%;
  max-width: none;
  margin: 0 !important;
  border-radius: 0 !important;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)) !important;
  box-shadow: 0 -4px 16px rgba(120, 86, 50, 0.14) !important;
}
/* 与底部标签栏共存：主 CTA 抬到标签栏之上，标签栏仍在最底可见 */
body.has-kbottom .cta-fixed { bottom: 62px; }
/* scan-paper 等既有 .paper-actionbar 同样避免被 kbottom 导航盖住 */
body.has-kbottom .paper-actionbar {
  bottom: 62px;
  z-index: 991;
}
@media (max-width: 768px) {
  body.parent .cta-fixed {
    bottom: calc(var(--p-bottom-nav-h, 56px) + env(safe-area-inset-bottom, 0px));
  }
}
/* 预留空间需覆盖「主 CTA 条 + 标签栏」两层，避免内容被遮 */
body.has-kbottom .page-has-actionbar { padding-bottom: 196px; }
@media (max-width: 768px) {
  body.parent .page-has-actionbar { padding-bottom: 196px; }
}

/* 入库进度（底栏内） */
.paper-action-progress {
  flex: 1;
  min-width: 0;
}

.paper-action-text {
  font-size: 14px;
  color: var(--ink-700);
  margin-bottom: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 入库报告：失败列表 */
.report-fail-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: var(--space-4) 0;
  text-align: left;
}

.report-fail-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--danger-50);
  border: 1px solid var(--danger-200);
  border-radius: var(--radius-sm);
}

.report-fail-main {
  flex: 1;
  min-width: 0;
}

.report-fail-title {
  font-weight: 700;
  font-size: 14px;
  color: var(--danger-700);
  margin-bottom: 2px;
}

.report-fail-reason {
  font-size: 13px;
  color: var(--ink-700);
}

/* ------------------------------------------------------------
 * 重练页（review.html / review-do.html / parent/variant.html，Prompt 9 新增）
 * ------------------------------------------------------------ */

/* 今日重练：进度区 */
.review-progress-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
}

.review-progress-emoji {
  font-size: 40px;
  line-height: 1;
  margin-bottom: var(--space-2);
}

.review-progress-text {
  font-weight: 800;
  font-size: 18px;
  color: var(--ink-900);
  margin-bottom: var(--space-3);
}

/* Prompt 60b-2P：每日限流排队提示（小字，位于进度条下方） */
.review-queue-hint {
  margin: calc(var(--space-2) * -1) 0 var(--space-3);
  font-size: 12px;
  color: var(--ink-500, #6b7280);
}

/* 任务列表（按科目分组） */
.review-group-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 800;
  font-size: 15px;
  color: var(--ink-700);
  margin: var(--space-5) 0 var(--space-3);
}

.review-group-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.review-task {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  cursor: pointer;
  min-height: 44px; /* 平板触摸区 */
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  font: inherit;
  color: inherit;
}

.review-task:hover {
  border-color: var(--brand-300);
  box-shadow: var(--shadow);
}

.review-task:active {
  transform: scale(0.99);
}

.review-task.is-done {
  opacity: 0.68;
}

.review-task-main {
  flex: 1;
  min-width: 0;
}

.review-task-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.review-task-index {
  font-weight: 800;
  color: var(--ink-900);
  flex: none;
}

.review-task-snippet {
  color: var(--ink-700);
  font-size: 14px;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.review-task-side {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-1);
}

.review-task-overdue {
  color: var(--warn-600, #d97706);
  font-weight: 700;
  font-size: 13px;
}

.review-task-arrow {
  color: var(--ink-500, #9ca3af);
  font-size: 18px;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--ink-700);
}

.empty-state-icon {
  font-size: 52px;
  line-height: 1;
  margin-bottom: var(--space-3);
}

.empty-state-text {
  font-size: 16px;
  font-weight: 700;
}

/* 作答区 */
.answer-reveal {
  background: var(--brand-50, #fff7ed);
  border: 2px solid var(--brand-200, #fed7aa);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-top: var(--space-4);
}

.answer-reveal-title {
  font-weight: 800;
  font-size: 14px;
  color: var(--brand-700, #c2410c);
  margin-bottom: var(--space-2);
}

.answer-reveal-text {
  font-size: 16px;
  color: var(--ink-900);
  line-height: 1.6;
  word-break: break-word;
}

.self-grade-row {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* 打勾 / 撒花动画 */
.anim-check {
  width: 84px;
  height: 84px;
  margin: 0 auto var(--space-3);
  animation: anim-pop 0.45s ease;
}

@keyframes anim-pop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.confetti-box {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 90;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  opacity: 0.9;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0% { transform: translateY(-10vh) rotate(0deg); }
  100% { transform: translateY(105vh) rotate(540deg); }
}

/* 结果面板（答对 / 答错 / 掌握） */
.result-panel {
  text-align: center;
  padding: var(--space-6) var(--space-4);
}

.result-emoji {
  font-size: 56px;
  line-height: 1;
  margin-bottom: var(--space-3);
  animation: anim-pop 0.45s ease;
}

.result-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink-900);
  margin-bottom: var(--space-2);
}

.result-sub {
  color: var(--ink-700);
  margin-bottom: var(--space-5);
}

/* 变式题逐题卡片 */
.variant-item {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.variant-item.is-active {
  border-color: var(--brand-400, #fb923c);
  box-shadow: var(--shadow);
}

.variant-item.is-past {
  opacity: 0.75;
}

.variant-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--brand-50, #fff7ed);
  color: var(--brand-700, #c2410c);
  margin-bottom: var(--space-2);
}

/* 家长确认页（375px 起步） */
.parent-variant-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.parent-variant-origin {
  font-size: 14px;
  color: var(--ink-700);
  line-height: 1.5;
  padding-bottom: var(--space-3);
  border-bottom: 1px dashed var(--line);
  margin-bottom: var(--space-3);
}

.parent-variant-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.parent-variant-actions .btn {
  flex: 1;
}

/* ============================================================
 * Prompt 10：笔记模块 + match-picker 手动匹配组件
 * ============================================================ */

/* ---------- 笔记列表 ---------- */
.note-filter-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.note-filter-row .btn {
  flex-shrink: 0;
  min-height: 48px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.search-icon {
  position: absolute;
  left: 14px;
  font-size: 15px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 48px;
  padding: 0 40px 0 40px;
  border: 2px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  font-size: 15px;
  color: var(--ink-900);
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--brand-400);
}

.search-clear {
  position: absolute;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--ink-200);
  color: var(--ink-700);
  font-size: 13px;
  cursor: pointer;
}

.notice-action {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--brand-600);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
  min-height: 44px;
}

/* 笔记卡片 */
.note-card {
  position: relative;
  display: flex;
  gap: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--space-3);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.note-card:active {
  transform: scale(0.99);
}

.note-thumb {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.note-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.note-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.note-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.note-summary {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-800);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-meta {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  font-size: 12px;
  color: var(--ink-500);
}

/* 搜索关键词高亮 */
.note-hl {
  background: var(--warn-100);
  color: var(--warn-800);
  border-radius: 3px;
  padding: 0 2px;
}

/* 匹配标签 */
.note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.note-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  font-size: 13px;
  color: var(--ink-800);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

button.note-tag:hover,
.note-tag:active {
  background: var(--brand-50);
  border-color: var(--brand-200);
}

.note-tag.is-static {
  cursor: default;
}

.note-tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* 学科区分：数学=蓝，英语=橙，历史=紫（V1-58-A 第三色） */
.dot-math {
  background: var(--info-600);
}

.dot-en {
  background: var(--brand-500);
}

/* V1-58-A：历史第三色 —— 紫，与蓝/橙明显区分 */
.dot-hist {
  background: #7c3aed;
}

/* V1-58-A：科目表未就绪 / 科目名不在表内时的中性兜底色（不猜学科） */
.dot-generic {
  background: var(--ink-400);
}

/* unmatched 橙色提示 */
.note-unmatched-hint {
  align-self: flex-start;
  border: 1px dashed var(--warn-600);
  border-radius: var(--radius-pill);
  background: var(--warn-50);
  color: var(--warn-800);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  min-height: 44px;
  cursor: pointer;
}

/* ··· 菜单 */
.note-more {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--ink-100);
  color: var(--ink-700);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
}

.more-menu {
  position: fixed;
  z-index: 90;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.more-menu-item {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: 15px;
  color: var(--ink-800);
  cursor: pointer;
}

.more-menu-item:hover,
.more-menu-item:active {
  background: var(--surface-soft);
}

.more-menu-item.is-danger {
  color: var(--danger-600);
  font-weight: 700;
}

/* Prompt 21：孩子端笔记详情顶部操作栏（编辑题型 / 删除） */
.detail-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.detail-toolbar .btn {
  min-height: 48px;
}

/* 浮动上传按钮 */
.fab {
  position: fixed;
  right: 24px;
  bottom: 32px;
  z-index: 60;
  width: 64px;
  height: 64px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-400), var(--brand-600));
  color: #fff;
  font-size: 32px;
  line-height: 1;
  box-shadow: 0 6px 20px rgba(249, 115, 22, 0.4);
  cursor: pointer;
  transition: transform 0.15s;
}

.fab:hover {
  transform: scale(1.06);
}

.fab:active {
  transform: scale(0.96);
}

/* 上传进度 */
.upload-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

/* 详情页文本 */
.note-detail-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-800);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 警示型提示文字 */
.card-hint.is-warn {
  color: var(--warn-700);
  font-weight: 700;
}

/* 警示按钮（手动添加知识点） */
.btn-warn {
  background: linear-gradient(135deg, var(--warn-600), var(--warn-700));
  color: #fff;
  border: none;
}

.btn-warn:hover {
  filter: brightness(1.05);
}

/* ---------- match-picker 手动匹配组件 ---------- */
.mp-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(41, 37, 36, 0.45);
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.mp-mask.is-visible {
  opacity: 1;
}

.mp-panel {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 820px;
  margin: 24px auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: translateY(12px);
  transition: transform 0.2s;
}

.mp-mask.is-visible .mp-panel {
  transform: translateY(0);
}

.mp-head {
  padding: var(--space-4);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.mp-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--ink-900);
}

.mp-search {
  position: relative;
  display: flex;
  align-items: center;
}

.mp-search-icon {
  position: absolute;
  left: 14px;
  font-size: 14px;
  pointer-events: none;
}

.mp-search-input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px 0 40px;
  border: 2px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface-soft);
  font-size: 15px;
  outline: none;
}

.mp-search-input:focus {
  border-color: var(--brand-400);
}

.mp-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* 左栏：层级树 */
.mp-tree {
  flex: 1.6;
  min-width: 0;
  overflow-y: auto;
  padding: var(--space-2) var(--space-3) var(--space-4);
  -webkit-overflow-scrolling: touch;
}

.mp-subject {
  font-size: 13px;
  font-weight: 800;
  color: var(--brand-600);
  padding: var(--space-3) 4px var(--space-1);
}

.mp-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  overflow: hidden;
  background: var(--surface-soft);
}

.mp-section.is-collapsed .mp-collapse {
  /* 高度由 JS 控制 */
}

.mp-section.is-hidden {
  display: none;
}

.mp-node {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 0 12px;
  border: none;
  background: none;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-900);
  text-align: left;
  cursor: pointer;
}

.mp-node-top {
  background: var(--surface);
  font-size: 16px;
}

.mp-node.is-open {
  color: var(--brand-600);
}

.mp-node-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mp-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-500);
  background: var(--ink-100);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
}

.mp-caret {
  font-size: 12px;
  color: var(--ink-500);
  width: 14px;
}

/* 折叠容器（200ms max-height 过渡） */
.mp-collapse {
  overflow: hidden;
  transition: max-height 0.2s ease;
  max-height: 0;
}

.mp-collapse-inner {
  padding: 0 6px 8px 20px;
}

/* 题型行 */
.mp-type-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 8px;
  border: none;
  border-radius: var(--radius-xs);
  background: none;
  font-size: 14px;
  color: var(--ink-800);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}

.mp-type-row:hover {
  background: var(--brand-50);
}

.mp-type-row.is-selected {
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 700;
}

.mp-type-row.is-hidden {
  display: none;
}

.mp-check {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: 2px solid var(--line-strong);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #fff;
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
}

.mp-check.is-checked {
  background: var(--brand-500);
  border-color: var(--brand-500);
}

.mp-type-name {
  min-width: 0;
}

.mp-hl {
  background: var(--warn-100);
  color: var(--warn-800);
  border-radius: 3px;
  padding: 0 1px;
}

.mp-empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--ink-500);
  font-size: 14px;
}

/* 右栏：已选列表 */
.mp-side {
  flex: 1;
  min-width: 200px;
  border-left: 1px solid var(--line);
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
}

.mp-side-title {
  padding: var(--space-3) var(--space-4);
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-900);
  border-bottom: 1px solid var(--line);
}

.mp-side-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2);
}

.mp-side-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  border: 1px solid var(--line);
  margin-bottom: var(--space-2);
}

.mp-side-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--ink-800);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mp-side-remove {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--ink-100);
  color: var(--ink-500);
  font-size: 12px;
  cursor: pointer;
}

.mp-side-remove:hover {
  background: var(--danger-50);
  color: var(--danger-600);
}

.mp-side-empty {
  padding: var(--space-4);
  text-align: center;
  color: var(--ink-500);
  font-size: 13px;
}

/* 底栏 */
.mp-foot {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

/* 超出多选上限时的就地提示：默认不占位，触发时独占一行 */
.mp-limit-hint {
  display: none;
  flex: 0 0 100%;
  order: -1;
  font-size: 13px;
  line-height: 1.5;
  color: var(--danger-700);
}

.mp-limit-hint.is-show {
  display: block;
}

.mp-foot .btn {
  flex: 1;
  min-height: 48px;
}

/* 窄屏：右栏改为底部横排，避免两栏挤压 */
@media (max-width: 768px) {
  .mp-body {
    flex-direction: column;
  }

  .mp-side {
    min-width: 0;
    max-height: 180px;
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .mp-side-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-content: flex-start;
  }

  .mp-side-item {
    margin-bottom: 0;
  }
}

/* ============================================================
 * Prompt 10.5：重点题模块
 * ============================================================ */

/* 选项列表 */
.key-options {
  margin: 0;
  padding-left: 22px;
  font-size: 15px;
  line-height: 1.8;
  color: var(--ink-800);
}

.key-options li::marker {
  color: var(--brand-500);
  font-weight: 700;
}

/* a 标签形式的题型标签（详情页可点击跳转筛选） */
a.note-tag {
  text-decoration: none;
}

/* ------------------------------------------------------------
 * 知识图谱（kid/graph.html，Prompt 11.5）
 * ------------------------------------------------------------ */
.kg-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

/* 图谱页所有交互元素保持 ≥44px 触摸区（覆盖 .segmented 42px / .btn-sm 40px） */
.kg-toolbar .segmented button,
.kg-info-actions .btn {
  min-height: 44px;
}

.kg-scope-hint {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-500);
}

.kg-chart-card {
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.kg-chart {
  width: 100%;
  max-width: 600px;
}

.kg-loading {
  padding: 44px 16px;
  text-align: center;
  color: var(--ink-500);
  font-size: 14px;
}

.kg-info-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.kg-node-name {
  font-size: 20px;
  font-weight: 700;
}

.kg-stats {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 15px;
  color: var(--ink-700);
}

.kg-stats strong {
  font-size: 18px;
  color: var(--brand-600);
  font-variant-numeric: tabular-nums;
}

.kg-cheer {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 15px;
  font-weight: 600;
}

.kg-info-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.kg-mistake-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kg-mistake-item {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: var(--surface-soft);
}

.kg-mistake-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.kg-mistake-no {
  font-weight: 700;
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}

.kg-mistake-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-900);
  word-break: break-word;
}

.kg-mistake-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-500);
}

/* 孩子端 6 个入口：平板及以上 3 列 × 2 行（风险 7） */
@media (min-width: 768px) {
  .entry-grid-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Prompt 37 Bug 1：孩子端 7 个入口（新增「我的练习」）——平板及以上 4 列（4+3 两行） */
@media (min-width: 768px) {
  .entry-grid-7 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* V1-58-A：孩子端 10 个入口（新增「历史讲评」后共 10 张卡）
   ——平板及以上 3 列，前 9 张排成 3×3 方阵；
     末张「历史讲评」用 .entry-card-wide 横跨整行，既避免 4+4+1 的孤儿行，
     又把讲评入口做成一个醒目的宽卡。 */
@media (min-width: 768px) {
  .entry-grid-10 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* V1-58-A：宽卡（横跨整行）——平板及以上生效；窄屏本来就是 1 列，无需处理 */
@media (min-width: 768px) {
  .entry-grid-10 .entry-card-wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 639px) {
  .kg-node-name {
    font-size: 18px;
  }
}

/* ============================================================
 * 26. 难度等级徽标 + 挑战题（Prompt 11.6b）
 * ------------------------------------------------------------
 * 等级颜色（全项目统一，前端由 common.js 的 renderDifficultyBadge 生成）：
 *   L1 灰 / L2 蓝 / L3 橙 / L4 紫 / L5 红
 * 挑战题视觉：金色边框 + 星光图标（孩子端今日重练列表 / 作答页一致）
 * ============================================================ */
.diff-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  white-space: nowrap;
}

.diff-l1 {
  background: #f1f3f5;
  border-color: #ced4da;
  color: #495057;
}

.diff-l2 {
  background: #e7f5ff;
  border-color: #a5d8ff;
  color: #1971c2;
}

.diff-l3 {
  background: #fff4e6;
  border-color: #ffc078;
  color: #d9480f;
}

.diff-l4 {
  background: #f3f0ff;
  border-color: #d0bfff;
  color: #7048e8;
}

.diff-l5 {
  background: #fff0f0;
  border-color: #ffa8a8;
  color: #c92a2a;
}

/* 挑战题徽标 */
.badge-challenge {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #a16207;
  box-shadow: inset 0 0 0 1px #fbbf24;
}

/* 挑战题卡片：金色边框（孩子端今日重练列表） */
.review-task.is-challenge {
  border: 2px solid #fbbf24;
  background: linear-gradient(180deg, #fffdf5, #ffffff);
  box-shadow: 0 6px 18px rgba(251, 191, 36, 0.18);
}

.review-task.is-challenge .review-task-index {
  color: #a16207;
}

/* 作答页顶部的挑战题信息条 */
.challenge-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 2px solid #fbbf24;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #fffdf5, #fff7e6);
}

.challenge-banner-text {
  font-size: 15px;
  font-weight: 700;
  color: #a16207;
}

/* 难度徽标挂到题干上方时的容器 */
.question-level-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* 变式题「针对薄弱点」提示（Prompt 49）：小字浅色，紧贴题干上方，说明这道题为什么出 */
.variant-target {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0 0 8px;
  padding: 6px 10px;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.5;
  color: #64748b;
}

.variant-target-emoji {
  font-size: 14px;
  line-height: 1;
}

.variant-target-label {
  font-weight: 600;
  color: #475569;
}

/* 挑战题过渡页（变式题全对后：挑战更难的题目？） */
.challenge-transition {
  padding: 22px 18px;
  border: 2px solid #fbbf24;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, #fffdf5, #fef3c7);
  text-align: center;
}

.challenge-transition-emoji {
  font-size: 40px;
  line-height: 1.2;
}

.challenge-transition-title {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 800;
  color: #92400e;
}

.challenge-transition-sub {
  margin-top: 6px;
  font-size: 14px;
  color: var(--ink-700);
}

.challenge-transition-level {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 12px 0 4px;
}

.challenge-transition-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.challenge-transition-loading {
  margin-top: 14px;
  font-size: 14px;
  color: var(--ink-500);
}

/* 挑战题答对：升级提示 + 光环 */
.level-upgrade {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, #fef3c7, #fcd34d);
  color: #92400e;
  font-weight: 800;
  font-size: 14px;
  animation: level-pop 600ms ease-out;
}

@keyframes level-pop {
  0% {
    transform: scale(0.7);
    opacity: 0;
  }
  60% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---------- 错题详情页 ---------- */
.md-head-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.md-section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-700);
  margin-bottom: 8px;
}

.md-variant-item {
  padding: 12px 14px;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  margin-bottom: 10px;
}

.md-variant-item.is-challenge {
  border-color: #fbbf24;
  background: #fffdf5;
}

.md-variant-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.md-variant-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-900);
  word-break: break-word;
}

.md-variant-answer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--ink-200);
  font-size: 14px;
  color: var(--ink-700);
}

.md-answer-text {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-900);
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 639px) {
  .challenge-transition-title {
    font-size: 18px;
  }
}

/* ------------------------------------------------------------
 * 27. 笔记文档上传（Prompt 14b-1 修正版：一份文档 = 一条笔记）
 * ------------------------------------------------------------
 * 家长端 upload.html 与孩子端 note-upload.html 共用的 nd-* 组件样式，
 * 配色走 CSS 变量，两端各自的主色由页面级样式覆盖。
 * ------------------------------------------------------------ */
.nd {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.nd-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.nd-file-name {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-900);
  word-break: break-all;
}

.nd-file-meta {
  font-size: 13px;
  color: var(--ink-500);
}

.nd-hint {
  font-size: 13px;
  color: var(--ink-500);
  line-height: 1.6;
}

.nd-btnrow {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* 解析中 */
.nd-parsing .progress-bar {
  margin-bottom: 6px;
}

/* 确认页：原文档信息 + 内容 */
.nd-field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
}

.nd-content {
  width: 100%;
  min-height: 140px;
  padding: 10px 12px;
  border: 1px solid var(--ink-200);
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-900);
  background: #ffffff;
  resize: vertical;
  box-sizing: border-box;
}

.nd-content:focus {
  outline: none;
  border-color: var(--brand-400);
}

/* AI 题型提示（三态：有建议 / 为空 / 已修改） */
.nd-type-hint {
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
}

.nd-type-hint.is-ai {
  color: var(--info-600);
}

.nd-type-hint.is-empty {
  color: var(--ink-500);
}

.nd-type-hint.is-modified {
  color: var(--warn-700);
}

/* 题型标签（带 ✕ 移除） */
.nd-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nd-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-50);
  color: var(--accent-600);
  font-size: 12px;
}

.nd-tag-remove {
  border: none;
  background: none;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  color: inherit;
  cursor: pointer;
  opacity: 0.7;
}

.nd-tag-remove:hover {
  opacity: 1;
}

/* 页面原图（扫描型 PDF） */
.nd-pages {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.nd-source-link {
  border: none;
  background: none;
  padding: 0;
  font-size: 13px;
  color: var(--info-600);
  cursor: pointer;
  text-decoration: underline;
}

/* 学科下拉 */
.nd-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 220px;
}

.nd-subject {
  width: 100%;
}

/* 完成步骤 */
.nd-done {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
}

.nd-done-text {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-900);
}

.nd-done .nd-btnrow {
  justify-content: center;
}

/* ============================================================
 * 28. 知识点通关详情面板（Prompt 15c）
 * ------------------------------------------------------------
 * 5 条难度进度条 + 状态徽标，孩子端 graph.html 信息卡与
 * 家长端 graph.html 右侧面板共用（两端都加载 theme.css）。
 * 进度条颜色：绿（100%）/ 橙（>0%）/ 灰（0%）
 * ============================================================ */

.km-mastery {
  margin: 10px 0;
  border: 1px solid #e4e9f1;
  border-radius: 12px;
  padding: 12px;
  background: #fbfcfe;
}

.km-mastery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.km-pass-level {
  font-size: 12.5px;
  color: #55647c;
  font-weight: 600;
}

.km-levels {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.km-level-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.km-level-name {
  flex: none;
  width: 64px;
  font-size: 12.5px;
  color: #2c3446;
  font-weight: 600;
  white-space: nowrap;
}

.km-bar {
  flex: 1;
  min-width: 60px;
  height: 10px;
  border-radius: 999px;
  background: #edf0f5;
  overflow: hidden;
}

.km-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.km-bar-fill.is-full {
  background: #51cf66;
}

.km-bar-fill.is-partial {
  background: #ffa94d;
}

.km-bar-fill.is-empty {
  background: transparent;
}

.km-level-pct {
  flex: none;
  width: 40px;
  text-align: right;
  font-size: 12px;
  color: #55647c;
  font-variant-numeric: tabular-nums;
}

.km-level-badge {
  flex: none;
  font-size: 11px;
  border-radius: 6px;
  padding: 1px 6px;
  white-space: nowrap;
}

.km-level-badge.is-pass {
  background: #e5f6ec;
  color: #1f7a43;
}

.km-level-badge.is-partial {
  background: #fdf3e0;
  color: #8a6d1f;
}

.km-level-badge.is-empty {
  background: #f1f3f6;
  color: #8695ab;
}

.km-mastery-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed #e4e9f1;
  font-size: 12.5px;
  color: #55647c;
}

.km-mastery-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ============================================================
 * 29. AI 分步骤解析共享组件 steps-viewer（Prompt 15d）
 * ------------------------------------------------------------
 * 所有页面（孩子端 / 家长端 / 弹层）统一使用 renderStepsViewer，
 * 样式集中在这一节，页面不再各自实现。
 * ============================================================ */
.sv-root {
  border: 1px solid var(--ink-200);
  border-radius: 12px;
  background: var(--brand-50);
  overflow: hidden;
}

.sv-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
  min-height: 44px;
}

.sv-head:hover {
  background: var(--brand-100);
}

.sv-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-800);
}

.sv-hint {
  font-size: 12px;
  color: var(--ink-500);
  flex: 1;
}

.sv-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sv-toggle {
  font-size: 12.5px;
  color: var(--brand-600);
  white-space: nowrap;
}

.sv-copy {
  border: 1px solid var(--brand-200);
  background: #fff;
  color: var(--brand-600);
  font-size: 12px;
  border-radius: 8px;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.sv-copy:hover {
  background: var(--brand-100);
}

.sv-copy.is-hidden {
  display: none;
}

.sv-body {
  max-height: 720px;
  opacity: 1;
  transition: max-height 0.2s ease, opacity 0.2s ease;
}

.sv-root.is-collapsed .sv-body {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

.sv-body-inner {
  padding: 4px 14px 12px;
  max-height: 340px;
  overflow-y: auto;
}

.sv-root.is-collapsed .sv-body-inner {
  overflow: hidden;
}

/* 步骤有序列表：圆圈序号 + 步骤文本 + 细分割线 */
.sv-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sv-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 9px 0;
}

.sv-item + .sv-item {
  border-top: 1px solid var(--ink-200);
}

.sv-no {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--brand-300);
  color: var(--brand-600);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.sv-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink-800);
  word-break: break-word; /* 交互细节 4：长步骤换行 */
  white-space: pre-wrap;
  font-family: inherit;
}

/* 单段解析降级（题库 explanation 等） */
.sv-fallback {
  margin: 6px 0 2px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink-700);
  white-space: pre-wrap;
  word-break: break-word;
}

/* analyzing：骨架屏 */
.sv-status-text {
  font-size: 13px;
  color: var(--ink-500);
  margin: 4px 0 8px;
}

.sv-status-text.is-active {
  color: var(--brand-600);
  font-weight: 600;
}

.sv-skeleton {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sv-skel-bar {
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #efe9e4 25%, #f7f3ef 50%, #efe9e4 75%);
  background-size: 200% 100%;
  animation: sv-skel-shimmer 1.2s infinite;
}

.sv-skel-bar.is-short {
  width: 60%;
}

@keyframes sv-skel-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* failed：错误 + 重试 */
.sv-failed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 2px 0 4px;
}

.sv-error-text {
  font-size: 13.5px;
  color: var(--danger-700);
  word-break: break-word;
}

.sv-action-btn {
  align-self: flex-start;
}

/* 空状态：暂无解析 + 生成按钮 */
.sv-empty {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.sv-empty-text {
  font-size: 13.5px;
  color: var(--ink-500);
}

/* 图谱弹层错题条目的解析按钮行（孩子端） */
.kg-mistake-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.kg-mistake-steps {
  margin-top: 8px;
}

.kg-mistake-steps.is-hidden {
  display: none;
}

/* 组件容器（field 内 / 结果面板卡内） */
.sv-field {
  width: 100%;
}

.sv-field.sv-field + .sv-field {
  margin-top: 8px;
}

/* 重练答错结果页：标准答案卡（Prompt 15d 二、3） */
.wrong-answer-card {
  margin-top: 12px;
  border: 1px solid var(--success-200);
  background: var(--success-50);
}

.wrong-answer-card .field-label {
  color: var(--success-700);
}

/* ============================================================
   第 30 节 · Prompt 15f：笔记关联知识图谱（孩子端）
   ============================================================ */

/* ---- 错题 / 笔记 tab ---- */
.kg-tabs {
  display: flex;
  gap: 6px;
  margin: 14px 0 4px;
  border-bottom: 2px solid var(--line);
}

.kg-tab {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-500);
  padding: 7px 14px;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s ease, background 0.15s ease;
}

.kg-tab:hover {
  color: var(--brand-600);
  background: var(--brand-50);
}

.kg-tab.is-active {
  color: var(--brand-600);
  border-bottom-color: var(--brand-500);
  background: none;
}

.kg-tab-num {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--ink-100);
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.kg-tab.is-active .kg-tab-num {
  background: var(--brand-100);
  color: var(--brand-700);
}

/* ---- 笔记列表 ---- */
.kg-note-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.kg-note-skeleton {
  padding: 4px 0;
}

.kg-note-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.kg-note-card:hover {
  border-color: var(--brand-300);
  box-shadow: 0 6px 18px rgba(249, 115, 22, 0.12);
  transform: translateY(-1px);
}

.kg-note-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.kg-note-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.kg-note-time {
  flex: none;
  font-size: 12px;
  color: var(--ink-500);
}

.kg-note-excerpt {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-700);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kg-note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kg-note-tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--info-50);
  color: var(--info-700);
  border: 1px solid var(--info-200);
}

.kg-note-tag.is-more {
  background: var(--ink-100);
  color: var(--ink-500);
  border-color: var(--line);
}

.kg-note-tag.is-empty {
  background: var(--ink-100);
  color: var(--ink-500);
  border-color: var(--line);
}

.kg-note-actions {
  display: flex;
  justify-content: flex-end;
}

.kg-note-more {
  align-self: center;
  margin-top: 2px;
}

.kg-note-empty {
  text-align: center;
  padding: 22px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--ink-500);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.kg-note-empty-icon {
  font-size: 26px;
}

/* ---- 笔记详情页：反向关联知识点 ---- */
.note-related-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-related-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 8px 12px;
}

.note-related-path {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-800);
}

.note-related-row .btn {
  flex: none;
}

/* ============================================================
 * 通关后快速复习（Prompt 15e）—— 孩子端
 * ------------------------------------------------------------
 * · .badge-mastery          复习徽标（青绿，与挑战题金色 / 变式题蓝色区分）
 * · .review-task.is-mastery  今日重练列表里复习题的卡片强调
 * · .mastery-banner          作答页顶部「快速复习 · 第 N/M 题」信息条
 * ============================================================ */
.badge-mastery {
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
  color: #0f766e;
  box-shadow: inset 0 0 0 1px #5eead4;
}

/* 复习题任务卡：青绿左边框，和挑战题（金）/ 变式题（蓝）一眼可分 */
.review-task.is-mastery {
  border-left: 4px solid var(--accent-500);
  background: linear-gradient(180deg, #f6fffd, #ffffff);
}

.review-task.is-mastery .review-task-index {
  color: var(--accent-600);
}

.review-task-mastery-seq {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent-600);
}

/* ============================================================
 * 我的练习两组视图（Prompt 41）—— 孩子端
 * ------------------------------------------------------------
 * · .practice-task-meta  卡片底部元信息行（创建于/计划/逾期 · 弱化灰字）
 * 复用既有 .review-task / .review-group-title / .badge / .empty-state，
 * 快速复习卡片沿用 .is-mastery 青绿左边框，整卷卡片用默认橙系。
 * ============================================================ */
.practice-task-meta {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-500);
}

/* 作答页顶部信息条：整体进度 + 当前档位 */
.mastery-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 2px solid var(--accent-500);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #f0fdfa, #ffffff);
}

.mastery-banner-text {
  font-weight: 700;
  color: var(--accent-600);
}

.mastery-banner-progress {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
}

.mastery-banner-hint {
  width: 100%;
  font-size: 13px;
  color: var(--ink-500);
}

/* 复习完成后的结果提示（作答页底部） */
.mastery-result-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  margin-top: 14px;
  border: 1px solid var(--accent-100);
  border-radius: var(--radius-lg);
  background: var(--accent-50);
}

.mastery-result-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-600);
}

.mastery-result-text {
  font-size: 14px;
  color: var(--ink-700);
}

/* ============================================================
 * 题型标签共用组件（Prompt 16a 二）
 * ------------------------------------------------------------
 * markup 由 /js/type-tags.js 生成，家长端 upload.html 与孩子端
 * scan-single.html 共用同一套类名。家长端 parent.css 里已有一份
 * 桌面版定义（parent.css 在 theme.css 之后加载，会覆盖本文件），
 * 这里是孩子端（平板）版本：触控区放大到 44px。
 * ============================================================ */
.uptags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.uptag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 6px 8px 6px 14px;
  border-radius: var(--radius-pill, 999px);
  background: var(--brand-50);
  color: var(--brand-600);
  font-size: 15px;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--brand-100);
}

.uptag-empty {
  padding: 6px 14px;
  background: #f4f2f0;
  color: var(--ink-500);
  font-weight: 500;
  box-shadow: inset 0 0 0 1px #e7e3df;
}

/* 标签内的移除按钮：44px 触控区，视觉上只是一枚小 × */
.uptag-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -6px -4px -6px 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--brand-600);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.uptag-x:hover,
.uptag-x:active {
  background: var(--brand-100);
  color: var(--brand-600);
}

/* ============================================================
 * KaTeX 公式排版（Prompt 16a 一）—— 屏上
 * ------------------------------------------------------------
 * · .katex-display 是 $$…$$ 渲染出的独立公式块：超宽时允许横向滚动，
 *   而不是被卡片裁掉；打印态由 print.css 覆盖（那里禁用滚动、改用缩字号）。
 * · 只微调字号，不改 KaTeX 自身的字体与间距，避免视觉错乱（风险 5）。
 * ============================================================ */
.katex {
  font-size: 1.05em;
}

.katex-display {
  max-width: 100%;
  margin: 0.5em 0;
  padding: 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.katex-display::-webkit-scrollbar {
  height: 6px;
}

.katex-display::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: var(--brand-100);
}

/* 公式整体不参与剪裁：KaTeX 的上下标用负边距定位 */
.katex .vlist-t,
.katex .vlist-r,
.katex .vlist {
  overflow: visible;
}

/* 渲染失败时 KaTeX 会用 errorColor(#cc0000) 输出原文，给个浅底更醒目 */
.katex-error {
  background: #fff1f0;
  border-radius: 4px;
  padding: 0 2px;
}

/* ============================================================
 * Prompt 16d：LaTeX 摘要 CSS 截断工具类
 * 原则：后端/前端返回并渲染完整题干，视觉截断交给 CSS，
 * 避免字符串截断把 $...$ 切成不配对的半个公式。
 * ============================================================ */
/* 单行截断 —— 表格列、紧凑列表 */
.latex-clamp-1 {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  min-width: 0; /* flex 容器内允许收缩 */
}
/* 双行截断 —— 卡片式列表 */
.latex-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
  word-break: break-word;
}
/* 三行截断 */
.latex-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 100%;
  word-break: break-word;
}
/* KaTeX 渲染后的内联元素保持 inline，不破坏父容器截断 */
.latex-clamp-1 .katex,
.latex-clamp-2 .katex,
.latex-clamp-3 .katex {
  display: inline;
  max-width: none;
}

/* ============================================================
 * Prompt 44：题干折叠（孩子端做题页 review-do.html）
 *   默认渲染完整题干 + .latex-clamp-3 视觉截断；
 *   超过阈值才显示「展开全文 / 收起」按钮（主色高亮，孩子能一眼看见）。
 *   换行用 pre-line 保留（不注入 <br>，避免把 $…$ 拆进两个文本节点导致 KaTeX 不渲染）。
 * ============================================================ */
.qtext-body {
  white-space: pre-line;
}
.qtext-toggle-row {
  margin-top: 10px;
  text-align: right;
}
.qtext-toggle {
  font-weight: 700;
}

/* ============================================================
 * Prompt 18：知识图谱题型 tab + 关联模块（孩子端 kg-*）
 * ============================================================ */
.kg-related {
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px dashed var(--brand-300);
  border-radius: 12px;
  background: var(--brand-50);
  font-size: 13.5px;
  line-height: 1.9;
}

.kg-related-label {
  font-weight: 700;
  color: var(--brand-700);
  margin-right: 4px;
}

.kg-related-item {
  display: inline-block;
  margin: 0 4px 0 0;
  color: var(--brand-600);
  text-decoration: underline;
}

.kg-type-list {
  margin-top: 10px;
}

.kg-type-item {
  padding: 10px 12px;
  border: 1px solid var(--ink-200, #e5e7eb);
  border-radius: 12px;
  margin-bottom: 8px;
  background: #fff;
}

.kg-type-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  cursor: pointer;
  min-height: 44px;
}

.kg-type-name {
  font-weight: 700;
  font-size: 14.5px;
}

.kg-type-hot {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #fff1f0;
  color: #d6453d;
  border: 1px solid #ffc9c2;
}

.kg-type-hot.is-press {
  background: var(--brand-50);
  color: var(--brand-700);
  border-color: var(--brand-200);
}

.kg-type-meta {
  margin-left: auto;
  font-size: 12.5px;
  color: #6b7280;
}

.kg-type-rel {
  margin-top: 6px;
  font-size: 12.5px;
  line-height: 1.7;
  color: #6b7280;
}

.kg-type-rel-label {
  color: var(--ink-700, #374151);
  font-weight: 600;
}

.kg-type-rel-path {
  color: var(--brand-600);
}

.kg-type-detail {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--ink-200, #e5e7eb);
}

.kg-type-detail.is-hidden {
  display: none;
}

/* ============================================================
 * 关联推荐面板（Prompt 22）
 * ------------------------------------------------------------
 * 结构：
 *   .related-section
 *     .related-header  > .related-title + .btn-rebuild
 *     .related-host    > .related-list > a.related-card
 *                        .related-more / .related-empty / .related-error
 *                        .related-updating / .related-skeleton
 * compact 变体 = 孩子端（.related-list.is-compact），只显示题干 + AI 理由
 * 家长端配色由 parent.css 覆盖为蓝灰
 * ============================================================ */

.related-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.related-header .related-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink-900);
}

/* 区块标题右侧的小按钮（图标 + 文字） */
.btn-rebuild {
  flex: 0 0 auto;
  white-space: nowrap;
}

.btn-rebuild.is-hidden {
  display: none;
}

.related-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* ------------------------------------------------------------
 * 卡片（笔记 / 错题共用外壳）
 * ------------------------------------------------------------ */
.related-card {
  display: flex;
  gap: var(--space-3);
  align-items: stretch;
  min-height: 64px;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.related-card:hover {
  border-color: var(--brand-300);
  box-shadow: var(--shadow-sm);
}

.related-card:active {
  transform: translateY(1px);
}

.related-thumb {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-xs);
  background: var(--brand-50);
}

.related-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.related-thumb-ph {
  font-size: 22px;
  line-height: 1;
}

.related-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.related-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--ink-900);
  word-break: break-word;
}

.related-card-excerpt {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-500);
  word-break: break-word;
}

/* AI 理由：灰色小字 */
.related-card-reason {
  font-size: 12px;
  line-height: 1.55;
  color: var(--ink-500);
  word-break: break-word;
}

.related-card-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

/* 错题卡：题号 / 难度 / 题干摘要 */
.related-qno {
  font-weight: 800;
  color: var(--brand-600);
}

.related-qtext {
  font-weight: 600;
}
/* Prompt 44：题干改为完整文本 + 两行 CSS 截断。
   题干独占一行（flex-basis 100%）→ 让 -webkit-line-clamp 拿到稳定的可用宽度，
   避免和题号/难度徽标挤在同一行时因 min-width:auto 撑出横向滚动条。 */
.related-qtext.latex-clamp-2 {
  flex: 1 1 100%;
  min-width: 0;
}

.related-difficulty {
  flex: 0 0 auto;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-500);
  background: var(--ink-100);
}

.related-difficulty.is-key {
  color: var(--brand-700);
  background: var(--brand-100);
}

/* ------------------------------------------------------------
 * 来源徽标 + 相关度
 * ------------------------------------------------------------ */
.related-source,
.related-score {
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 18px;
}

.related-source.is-ai {
  color: var(--ink-500);
  background: var(--ink-100);
}

.related-source.is-shared {
  color: var(--warn-700);
  background: var(--warn-50);
  border: 1px solid var(--warn-100);
}

.related-score.is-high {
  color: var(--success-700);
  background: var(--success-50);
}

.related-score.is-mid {
  color: var(--warn-700);
  background: var(--warn-50);
}

.related-score.is-low {
  color: var(--ink-500);
  background: var(--ink-100);
}

/* ------------------------------------------------------------
 * compact（孩子端）：更简洁，只留题干 + AI 理由
 * ------------------------------------------------------------ */
.related-list.is-compact .related-card {
  min-height: 0;
  padding: 10px 12px;
  background: var(--surface-soft);
  border-color: var(--brand-100);
}

.related-list.is-compact .related-card-title {
  font-size: 13.5px;
  font-weight: 600;
}

.related-list.is-compact .related-card-reason {
  font-size: 12px;
  color: var(--ink-500);
}

/* ------------------------------------------------------------
 * compact 专属：「重点题」小徽标（Prompt 22 补丁）
 * 只出现在孩子端紧凑模式（家长端走 .related-difficulty.is-key，文案「重点题」）
 * 小号 / 暖色 / 无边框
 * ------------------------------------------------------------ */
.related-list.is-compact .related-key-tag {
  flex: 0 0 auto;
  padding: 2px 6px;
  border: 0;
  border-radius: 4px;
  background: #fff3e0;
  color: #e65100;
  font-size: 11px;
  font-weight: 700;
  line-height: 16px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

/* ------------------------------------------------------------
 * 查看更多 / 空状态 / 失败 / 更新中 / 骨架屏
 * ------------------------------------------------------------ */
.related-more {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.related-hint {
  font-size: 12.5px;
  color: var(--ink-500);
}

.related-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  font-size: 13px;
  color: var(--ink-500);
}

.related-empty-icon {
  font-size: 16px;
  line-height: 1;
}

.related-error {
  display: flex;
  width: 100%;
  min-height: 48px;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  border: 1px dashed var(--danger-200);
  border-radius: var(--radius-sm);
  background: var(--danger-50);
  font-size: 13px;
  font-weight: 600;
  color: var(--danger-700);
  text-align: left;
  cursor: pointer;
}

.related-error-icon {
  font-size: 15px;
  line-height: 1;
}

.related-updating {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;
  border-radius: var(--radius-sm);
  background: var(--brand-50);
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-700);
}

.related-updating-icon {
  font-size: 15px;
  line-height: 1;
  animation: related-pulse 1.1s ease-in-out infinite;
}

@keyframes related-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.related-skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.related-skel-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.related-skel-thumb {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xs);
  background: var(--ink-100);
}

.related-skel-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.related-skel-bar {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--ink-100) 0%, var(--ink-200) 50%, var(--ink-100) 100%);
  background-size: 200% 100%;
  animation: related-shimmer 1.3s linear infinite;
}

.related-skel-bar.is-short {
  width: 55%;
}

@keyframes related-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ------------------------------------------------------------
 * match-picker：已选计数行（Prompt 22）
 * 注意：树节点的小计数徽标用的是 .mp-count，这里用 .mp-sel-count
 * ------------------------------------------------------------ */
.mp-sel-count {
  padding: 9px var(--space-4);
  border-bottom: 1px dashed var(--line);
  background: var(--surface);
  font-size: 13px;
  color: var(--ink-500);
}

.mp-sel-count-num {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-900);
}

.mp-sel-count.is-limit {
  background: var(--danger-50);
  color: var(--danger-700);
}

.mp-sel-count.is-limit .mp-sel-count-num {
  color: var(--danger-700);
}

.mp-sel-count-warn {
  margin-left: 4px;
  font-weight: 800;
}

/* ------------------------------------------------------------
 * 移动端（375px）：缩略图收窄、头部允许换行
 * ------------------------------------------------------------ */
@media (max-width: 768px) {
  .related-header {
    flex-wrap: wrap;
  }

  .related-card {
    gap: 10px;
    padding: 10px;
  }

  .related-thumb,
  .related-skel-thumb {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
  }
}

/* ============================================================
 * Prompt 23：作答方式切换 + 手写画板 + AI 判定面板 + 判定统计
 * ============================================================ */

/* ------------------------------------------------------------
 * 作答方式 tab（键盘输入 / 手写作答）
 * ------------------------------------------------------------ */
.answer-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.answer-tab {
  flex: 1 1 0;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink-500);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.answer-tab:hover {
  border-color: var(--brand-300);
}

.answer-tab.is-active {
  background: var(--brand-50);
  border-color: var(--brand-400);
  color: var(--brand-700);
}

.answer-tab[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.answer-pane.is-hidden {
  display: none;
}

/* ------------------------------------------------------------
 * P25：拍照作答
 * ------------------------------------------------------------ */
.photo-answer-box {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
}

.photo-answer-empty {
  padding: 24px;
  text-align: center;
  color: var(--ink-500);
}

.photo-answer-emoji {
  margin-bottom: 6px;
  font-size: 34px;
  line-height: 1;
}

.photo-answer-tip {
  font-size: 14px;
}

.photo-answer-preview {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: #fff;
}

.photo-answer-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.photo-answer-actions .btn {
  flex: 1 1 0;
  min-height: 48px;
}

/* 作答回显（AI 判定面板 / 拍照与手写作答） */
.ai-verdict-answer-img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
}

/* ------------------------------------------------------------
 * 数学草稿纸画板（P26）
 * ------------------------------------------------------------
 * 结构：.hw-pad > .hw-toolbar（两行，sticky）+ .hw-viewport（裁剪锅）
 *      .hw-viewport > canvas.hw-canvas（2000×2000 世界坐标，CSS transform 平移缩放）
 *                     canvas.hw-overlay（视口大小的预览层，只画虚线，pointer-events:none）
 * 要点：工具栏走「上方独立一行」而不是浮在画布上 —— 一滴墨都不会被按钮挡住；
 *      但它 sticky 在视口顶部，滚动时不脱离视野。
 * ------------------------------------------------------------ */
.hw-pad {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hw-toolbar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
}

.hw-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hw-row-style {
  gap: 6px;
  padding-top: 2px;
  border-top: 1px dashed var(--line);
}

.hw-group-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-500);
  letter-spacing: 0.02em;
}

.hw-gap {
  margin-left: 6px;
}

/* 工具按钮：图标 + 小字，触摸区 ≥ 44px */
.hw-tool {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 54px;
  min-height: 44px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-700);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.hw-tool-cap {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-500);
}

.hw-tool.is-active {
  background: var(--brand-50);
  border-color: var(--brand-400);
  box-shadow: inset 0 0 0 1px var(--brand-200);
}

.hw-tool.is-active .hw-tool-cap {
  color: var(--brand-700);
}

.hw-tool:active {
  transform: scale(0.96);
}

/* 图标按钮（视口 / 操作） */
.hw-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink-700);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.hw-icon-btn:active:not([disabled]) {
  background: var(--brand-50);
  border-color: var(--brand-300);
}

.hw-icon-btn[disabled] {
  opacity: 0.38;
  cursor: not-allowed;
}

.hw-zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.hw-zoom-label {
  min-width: 44px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-500);
  font-variant-numeric: tabular-nums;
}

.hw-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 颜色 / 粗细 */
.hw-swatch,
.hw-width {
  min-height: 34px;
  min-width: 44px;
  padding: 2px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-500);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.hw-swatch::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--hw-swatch, var(--ink-500));
  vertical-align: middle;
}

.hw-swatch.is-active,
.hw-width.is-active {
  border-color: var(--brand-400);
  background: var(--brand-50);
  color: var(--brand-700);
}

/* 视口：只做裁剪，画布在其中平移缩放 */
.hw-viewport {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: #fff;
  touch-action: none; /* P27：手势全交给 JS（touch + mouse），浏览器不得抢去滚动/缩放 */
  overscroll-behavior: contain;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.hw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  background: #fff;
  cursor: crosshair;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transform-origin: 0 0;
  will-change: transform;
}

/* 预览层：永远盖在画布上，但不接收事件 */
.hw-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  touch-action: none;
}

.hw-viewport.is-pan,
.hw-viewport.is-pan .hw-canvas {
  cursor: grab;
}

.hw-viewport.is-pan:active,
.hw-viewport.is-pan:active .hw-canvas {
  cursor: grabbing;
}

.hw-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - 32px);
  text-align: center;
  color: var(--ink-500);
  font-size: 13px;
  line-height: 1.7;
  pointer-events: none;
}

.hw-hint-sub {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--ink-300);
}

.hw-hint.is-hidden {
  display: none;
}

/* ------------------------------------------------------------
 * AI 判定结果面板
 * ------------------------------------------------------------ */
.ai-verdict {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 800;
}

.ai-verdict.is-correct {
  background: var(--success-50);
  color: var(--success-700);
  border: 1px solid var(--success-200);
}

.ai-verdict.is-wrong {
  background: var(--danger-50);
  color: var(--danger-700);
  border: 1px solid var(--danger-200);
}

.ai-verdict-sub {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-500);
}

.ai-confirm-card .card-title {
  margin-bottom: 10px;
}

.ai-confirm-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-confirm-row .btn {
  flex: 1 1 45%;
  min-height: 52px;
}

/* AI 判定耗时（孩子端不做展示，测试/联调用 data 属性承载） */
.ai-judge-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-300);
}

@media (max-width: 768px) {
  /* 窄屏：工具按钮只留图标，把宽度让给画布（文字标签仍给屏幕阅读器） */
  .hw-tool {
    min-width: 44px;
    padding: 4px 6px;
  }

  .hw-tool-cap {
    display: none;
  }

  .hw-zoom {
    margin-left: 0;
  }

  .ai-confirm-row .btn {
    flex: 1 1 100%;
  }
}

/* ------------------------------------------------------------
 * 家长端：AI 判定统计卡
 * ------------------------------------------------------------ */
.pjudge-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

.pjudge-metric {
  flex: 1 1 140px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}

.pjudge-metric-label {
  font-size: 12.5px;
  color: var(--ink-500);
  font-weight: 700;
}

.pjudge-metric-value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink-700);
}

.pjudge-metric-value.is-good {
  color: var(--success-700);
}

.pjudge-metric-value.is-warn {
  color: var(--warn-700);
}

.pjudge-meter {
  height: 8px;
  margin-top: 10px;
  border-radius: var(--radius-pill);
  background: var(--ink-100);
  overflow: hidden;
}

.pjudge-meter-fill {
  height: 100%;
  width: var(--meter, 0%);
  background: var(--brand-500);
  transition: width 0.4s ease;
}

.pjudge-type-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}

.pjudge-type-row:last-child {
  border-bottom: 0;
}

.pjudge-type-name {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--ink-500);
}

.pjudge-type-bar {
  flex: 1 1 auto;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--ink-100);
  overflow: hidden;
}

.pjudge-type-bar > span {
  display: block;
  height: 100%;
  width: var(--meter, 0%);
  background: var(--brand-400);
}

.pjudge-type-rate {
  flex: 0 0 auto;
  font-weight: 700;
  color: var(--ink-500);
}

.pjudge-empty {
  padding: 12px;
  text-align: center;
  color: var(--ink-500);
  font-size: 13px;
}

/* ============================================================
 * Prompt 46：作答分析（步骤级诊断）共享样式
 * ------------------------------------------------------------
 * 组件：/js/answer-analysis.js（renderAnswerAnalysis）
 * 页面：孩子端/家长端错题详情、家长端批改页、家长端上传确认页
 * 语义色：出错步骤=红、正确步骤=绿、部分正确=橙（与孩子端既有配色一致）
 * ============================================================ */
.aa-root {
  margin: 12px 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.aa-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  user-select: none;
}

.aa-head:focus-visible {
  outline: 2px solid var(--brand-400);
  outline-offset: -2px;
}

.aa-title {
  font-weight: 700;
  color: var(--ink-900);
}

.aa-hint {
  font-size: 12px;
  color: var(--ink-500);
}

.aa-toggle {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-600);
  white-space: nowrap;
}

.aa-body {
  padding: 12px;
}

.aa-root.is-collapsed .aa-body {
  display: none;
}

.aa-block + .aa-block {
  margin-top: 14px;
}

.aa-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-700);
}

.aa-label-icon {
  font-size: 14px;
}

/* —— 出错步骤 —— */
.aa-step-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--danger-700);
}

.aa-step-text {
  font-size: 15px;
}

.aa-step-detail {
  margin-top: 6px;
  padding: 8px 10px;
  border-left: 3px solid var(--danger-600);
  border-radius: var(--radius-xs);
  background: var(--danger-50);
  color: var(--ink-800);
  white-space: pre-line;
}

/* —— 出错原因 —— */
.aa-reason-text {
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  background: var(--info-50);
  color: var(--ink-800);
  white-space: pre-line;
}

/* —— 薄弱点标签（只展示，不点击） —— */
.aa-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.aa-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--warn-50);
  border: 1px solid var(--warn-100);
  color: var(--warn-800);
  font-size: 13px;
  font-weight: 600;
}

/* —— 逐步骤分析 —— */
.aa-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.aa-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
}

.aa-item:last-child {
  border-bottom: none;
}

.aa-no {
  flex: 0 0 auto;
  color: var(--ink-500);
  font-size: 14px;
}

.aa-status {
  flex: 0 0 16px;
  text-align: center;
  font-weight: 700;
  line-height: 1.5;
}

.aa-item-body {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink-800);
  white-space: pre-line;
  word-break: break-word;
}

.aa-note {
  flex: 0 0 100%;
  margin-left: 38px;
  white-space: normal;
  word-break: break-word;
  color: var(--danger-600);
  font-size: 12px;
}

.aa-item.is-correct .aa-status { color: var(--success-600); }
.aa-item.is-partial .aa-status { color: var(--warn-600); }
.aa-item.is-unknown .aa-status { color: var(--ink-500); }
.aa-item.is-wrong .aa-status { color: var(--danger-600); }
.aa-item.is-wrong .aa-item-body { color: var(--danger-700); font-weight: 600; }
.aa-item.is-partial .aa-item-body { color: var(--warn-700); }

/* 公式渲染后不被截断（与既有 latex-clamp 口径一致） */
.aa-root .katex { display: inline; max-width: none; }

/* ============================================================
 * Prompt 46：latex-field 基座样式（孩子端）
 * ------------------------------------------------------------
 * 背景：.latex-field 的样式原先只写在 parent.css（用 --p-* 变量），
 *      而孩子端 note-upload.html 只加载 theme.css → 笔记内容的
 *      latex-field 会完全无样式。这里用 theme 变量补一份基座。
 * 优先级：家长端同时加载 theme.css + parent.css，后者在后 → 家长端
 *        仍用 parent.css 的蓝色调版本，行为不变。
 * ============================================================ */
.latex-field {
  width: 100%;
  box-sizing: border-box;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink-900);
}

.latex-field-preview {
  display: flex;
  align-items: flex-start;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  cursor: text;
  transition: border-color .15s ease, background .15s ease;
}

.latex-field-preview:hover {
  border-color: var(--brand-400);
  background: #fff;
}

.latex-field-preview:focus-visible {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .15);
}

.latex-field-content {
  flex: 1;
  min-width: 0;
  line-height: 1.7;
  word-break: break-word;
  white-space: pre-wrap;
}

.latex-field-content.is-empty {
  color: var(--ink-500);
}

.latex-field-hint {
  flex: 0 0 auto;
  align-self: center;
  margin-left: 8px;
  font-size: 12px;
  color: var(--ink-500);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .15s ease;
}

.latex-field-preview:hover .latex-field-hint,
.latex-field-preview:focus-visible .latex-field-hint {
  opacity: 1;
}

.latex-field-edit {
  padding: 8px 8px 0;
  border: 1px solid var(--brand-500);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, .12);
}

.latex-field-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  min-height: 40px;
  padding: 6px 6px 8px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink-900);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.7;
  resize: none;
}

textarea.latex-field-input {
  min-height: 76px;
  max-height: 360px;
  overflow-y: auto;
}

.latex-field-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 4px 2px 8px;
}

.latex-field-edit-hint {
  margin-right: auto;
  font-size: 12px;
  color: var(--ink-500);
}

.latex-field-done {
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--brand-500);
  border-radius: 8px;
  background: var(--brand-500);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.latex-field-done:hover {
  filter: brightness(1.06);
}

/* Prompt 46：笔记文档确认页的 latex-field 容器（note-doc-upload.js） */
.nd-content-host {
  width: 100%;
}

.nd-content-host .latex-field-preview {
  min-height: 140px;
}

@media (max-width: 480px) {
  .latex-field-hint,
  .latex-field-edit-hint {
    display: none;
  }

  .latex-field-preview {
    padding: 9px 10px;
  }
}

/* ============================================================
 * Prompt 49（薄弱点图谱 · 阶段 1）：孩子端「待加强」
 * ------------------------------------------------------------
 * 措辞：孩子端一律用「待加强 / 还能再稳一点」，不出现「薄弱」二字（关键决策 3）。
 * 颜色档位（使用频率越高越暖）：>=3 红 / 2 橙 / 1 黄 / 0 灰。
 * 触控区：所有可点行 >= 48px。
 * ============================================================ */

/* ---- 首页「我的薄弱点」卡片 ---- */
.wk-card {
  margin-top: var(--space-5);
}

.wk-more {
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-600);
  text-decoration: none;
  white-space: nowrap;
}

.wk-more:hover {
  text-decoration: underline;
}

.wk-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.wk-hint {
  padding: var(--space-2) 0;
  font-size: 14px;
  color: var(--ink-500);
}

.wk-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 48px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.wk-row:hover {
  border-color: var(--brand-200);
  background: var(--brand-50);
}

.wk-name {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
}

.wk-count {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-600);
}

/* ------------------------------------------------------------
 * Prompt 60b-2o：弱点通关进度
 * 首页卡片用窄条（.wk-bar），列表页用整行细条（.wk-item-bar）
 * ------------------------------------------------------------ */
.wk-bar {
  flex-shrink: 0;
  width: 56px;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.wk-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand-500, #f97316);
  transition: width 0.25s ease;
}

.wk-bar-fill.is-full {
  background: var(--success-600);
}

.wk-item-bar {
  height: 5px;
  margin: 0 16px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.07);
  overflow: hidden;
}

.wk-item-bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand-500, #f97316);
  transition: width 0.25s ease;
}

.wk-item-bar-fill.is-full {
  background: var(--success-600);
}

/* ---- 列表页 ---- */
.wk-page-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.wk-item {
  padding: 0;
  overflow: hidden;
}

.wk-item-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 56px;
  padding: var(--space-3) var(--space-4);
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.wk-item-head:hover {
  background: var(--brand-50);
}

.wk-dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink-300);
}

.wk-dot-red {
  background: #e11d48;
}
.wk-dot-orange {
  background: #ea580c;
}
.wk-dot-yellow {
  background: #d97706;
}
.wk-dot-gray {
  background: var(--ink-300);
}

.wk-item-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.5;
  word-break: break-word;
}

.wk-item-count {
  flex-shrink: 0;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--brand-100);
  color: var(--brand-700);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.wk-item-arrow {
  flex-shrink: 0;
  color: var(--ink-500);
  font-size: 20px;
  line-height: 1;
  transition: transform 0.18s ease;
}

.wk-item.is-open .wk-item-arrow {
  transform: rotate(90deg);
}

.wk-item-body {
  display: none;
  padding: 0 var(--space-4) var(--space-3);
  border-top: 1px dashed var(--line);
}

.wk-item.is-open .wk-item-body {
  display: block;
}

.wk-body-hint {
  padding: var(--space-3) 0;
  font-size: 14px;
  color: var(--ink-500);
}

.wk-mistake {
  display: block;
  padding: var(--space-3) var(--space-3);
  margin-top: var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: inherit;
  text-decoration: none;
}

.wk-mistake:hover {
  border-color: var(--brand-200);
  background: var(--brand-50);
}

.wk-mistake-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.wk-mistake-no {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-600);
}

.wk-mistake-meta {
  font-size: 12px;
  color: var(--ink-500);
}

.wk-mistake-text {
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-800);
}

/* ============================================================
 * Prompt 25：错题详情「最近一次重练回顾」
 * ------------------------------------------------------------
 * 页面：kid/mistake-detail.html、parent/mistake-detail.html 共用
 * 结构：标题（来源徽标）+ 元信息 + 作答（图/文）+ 三方判定 + 最终结论
 * 依赖：theme.css 的 --surface-soft / --line / --radius-sm 等变量，
 *       家长端加载 parent.css 后语义色仍沿用（success/danger/warn）
 * ============================================================ */
.lpr-field {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  border: 1.5px solid var(--line);
}

.lpr-meta {
  margin: 2px 0 10px;
  font-size: 12px;
  color: var(--ink-500);
}

/* 作答图片沿用 .thumb（自带「点击放大」蒙层 + 缩放绑定） */
.lpr-thumb {
  margin-bottom: 10px;
}

.lpr-answer {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  border: 1px solid var(--line);
}

.lpr-answer-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-500);
  margin-bottom: 4px;
}

/* 三方判定：桌面横排三等分，窄屏自动折成一列 */
.lpr-judges {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 620px) {
  .lpr-judges {
    grid-template-columns: minmax(0, 1fr);
  }
}

.lpr-judge {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  border: 1px solid var(--line);
}

.lpr-judge-who {
  font-size: 12px;
  color: var(--ink-500);
  white-space: nowrap;
}

.lpr-judge-val {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
}

.lpr-right {
  color: var(--success-600);
}

.lpr-wrong {
  color: var(--danger-600);
}

.lpr-none {
  color: var(--ink-500);
}

/* 最终结论：整块横幅，一眼看结论 */
.lpr-final {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.6;
}

.lpr-final-right {
  background: var(--success-50);
  color: var(--success-700);
  border: 1px solid var(--success-200);
}

.lpr-final-wrong {
  background: var(--warn-50);
  color: var(--warn-800);
  border: 1px solid var(--warn-100);
}

.lpr-final-pending {
  background: var(--info-50);
  color: var(--info-700);
  border: 1px solid var(--info-200);
}

/* ============================================================
 * P29：强制作答过程校验（need_steps）
 *   .need-steps-tip    作答区上方的橙色提示（常驻）
 *   .need-steps-banner 被打回后追加的提示条
 *   .ns-modal-*        打回弹窗（零依赖，纯 CSS 遮罩 + 卡片）
 * ============================================================ */

.need-steps-tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 0 10px;
  padding: 9px 12px;
  background: var(--brand-50);
  border: 1px solid var(--brand-200);
  border-left: 4px solid var(--brand-500);
  border-radius: var(--radius-xs);
  color: var(--brand-700);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}

.need-steps-tip-icon {
  flex: 0 0 auto;
  line-height: 1.4;
}

.need-steps-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0 0 10px;
  padding: 9px 12px;
  background: var(--danger-50);
  border: 1px solid var(--danger-200);
  border-left: 4px solid var(--danger-600);
  border-radius: var(--radius-xs);
  color: var(--danger-700);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.55;
}

/* ---- 打回弹窗 ---- */
.ns-modal-mask {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(41, 37, 36, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: ns-fade-in 0.16s ease-out;
}

.ns-modal {
  width: 100%;
  max-width: 420px;
  padding: 22px 20px 18px;
  background: var(--surface);
  border-radius: var(--radius-md, 14px);
  box-shadow: 0 18px 48px rgba(41, 37, 36, 0.28);
  text-align: center;
  animation: ns-pop-in 0.18s ease-out;
}

.ns-modal-emoji {
  font-size: 34px;
  line-height: 1.1;
  margin-bottom: 6px;
}

.ns-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-900);
  margin-bottom: 8px;
}

.ns-modal-body {
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink-700);
  text-align: left;
}

.ns-modal-example {
  margin: 12px 0 16px;
  padding: 9px 12px;
  background: var(--brand-50);
  border-radius: var(--radius-xs);
  color: var(--brand-700);
  font-size: 13px;
  line-height: 1.6;
  text-align: left;
}

@keyframes ns-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ns-pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 触屏设备：按钮保持 ≥44px 可点区域（P24 触控铁律） */
.ns-modal .btn-block {
  min-height: 48px;
  font-size: 16px;
}

/* ==== V1-32 孩子端批改结果 ==== */
.kg-batch { display: block; color: inherit; text-decoration: none; cursor: pointer; }
.kg-batch-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.kg-batch-code { font-size: 15px; font-weight: 700; letter-spacing: 0.3px; }
.kg-batch-date, .kg-batch-note { font-size: 12.5px; color: var(--ink-500); }
.kg-batch-stat { margin-top: 4px; font-size: 14px; font-weight: 600; }
.kg-batch-go, .kg-more { display: inline-block; margin-top: 10px; font-size: 13px; color: var(--brand-600); }
.kg-filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.kg-q { margin-bottom: 12px; }
.kg-q-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.kg-q-no { font-weight: 700; }
.kg-badge-soft { background: var(--ink-100); color: var(--ink-500); }
.kg-q-text { margin: 0 0 4px; font-size: 15px; line-height: 1.6; word-break: break-word; }
.kg-expand { margin: 6px 0 2px; }
.kg-field { margin-top: 10px; }
.kg-label { display: block; font-size: 12px; color: var(--ink-500); margin-bottom: 2px; }
.kg-val { font-size: 14.5px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.kg-val.is-empty { color: var(--ink-500); }
.kg-val-sub { font-size: 13.5px; color: var(--ink-700); }
.kg-thumb { margin-top: 4px; }
.kg-wk { display: flex; flex-wrap: wrap; gap: 6px; }
.kg-wk-tag { font-size: 12px; padding: 2px 8px; border-radius: var(--radius-pill); background: var(--ink-100); color: var(--ink-700); }
.kg-steps { margin-top: 12px; }
.kg-steps summary { cursor: pointer; font-size: 13px; color: var(--ink-700); }
.kg-steps ol { margin: 6px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.7; }

/* ============================================================
 * F9：孩子端全局底部导航（common.js 自动注入，心智与家长端一致）
 * ============================================================ */
.kbottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-toast);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(120, 86, 50, 0.06);
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom, 0px));
}
.kbottom-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 52px;
  padding: 6px 2px;
  font-size: 11px;
  line-height: 1.1;
  color: var(--ink-500);
  text-decoration: none;
}
.kbottom-link.is-active { color: var(--brand-600); }
.kbottom-icon { font-size: 20px; line-height: 1; }
.kbottom-label { white-space: nowrap; }
body.has-kbottom { padding-bottom: 62px; }

/* F17：导航渲染失败时的最低兜底（脚本异常也不致困死子页） */
.nav-fallback {
  position: sticky; top: 0; z-index: var(--z-toast);
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.nav-fallback a {
  font-size: 13px; color: var(--brand-600); text-decoration: none;
  padding: 4px 8px; border-radius: 8px;
}
.nav-fallback a:hover { background: var(--brand-50); }

/* ============================================================
 * F5：历史加载 / 空态类名 → theme 标准视觉别名表（CSS 层收敛）
 * ------------------------------------------------------------
 * 旧代码散落私有类名，观感不一。这里在 CSS 层把它们统一到
 * .empty-state / .loading-* 的语义色与留白，页面 HTML class 无需改动：
 *   p-empty / ptodo-empty / tempty  → 空态：居中、var(--ink-700)
 *   p-loading / tloading / wk-hint  → 加载·说明：居中、var(--ink-500)
 * 新代码请直接复用 .empty-state 与 UI.showLoading()/UI.hideLoading()。
 * 注：parent 页由 parent.css（后加载）落地上述值，teacher 页由页内
 *     <style> 落地；此处作为单一主题的口径声明，避免各端再次分叉。
 * ============================================================ */
