/* chain.css —— 单题拆解闯关（2026-11-03）
 *
 * 【类名纪律】一律用 .ch- 前缀，但**必须逐个查 style.css 有没有同名**：
 * 这里踩过一次 —— `.ch-btn` 在 style.css 里是"章节历史"模块的按钮，
 * 它带 `:hover { background: var(--brand-soft); color: var(--brand) }`，
 * 于是拆解页的主按钮一悬停就变成淡蓝底蓝字（看着像白底白字），
 * 用户以为按钮坏了。现在拆解页的按钮叫 .chg-btn。
 *
 * 与 quiz.css 同源：配色走主样式变量（--brand / --panel / --ink / --muted / --border），
 * 深色主题自动跟随。题型外观直接复用 quiz.css 的 .qz-opt / .qz-chip / .qz-bucket / .qz-sort，
 * 这里只写"拆解"独有的骨架（进度点、关卡卡、倒计时、结果页）。
 *
 * 【刻意没有的东西】分数、评级、连击、生命值 —— 评价指标只有一个：
 * 过没过最后一关（2026-11-03 用户定）。多一个数字，学生就会开始刷分而不是想题。
 */

.ch-overlay {
  position: fixed; top: 0; left: 0; right: 0; height: var(--vh); box-sizing: border-box; z-index: 9650;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, .58);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
.ch-overlay[hidden] { display: none !important; }
body.ch-open { overflow: hidden; }

.ch-panel {
  position: relative;
  display: flex; flex-direction: column;
  width: min(720px, 100%);
  max-height: min(760px, calc(var(--vh) - 40px));
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .3);
  overflow: hidden;
}

/* ── 顶栏 ─────────────────────────────────────────────────────── */
.ch-head {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px 12px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--brand-soft), transparent 130%);
  flex: 0 0 auto;
}
.ch-head::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, #2f6df6, #7aa7ff 55%, #f5a623);
}
.ch-kicker {
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  color: #fff; background: var(--brand);
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.ch-sec {
  font-size: 13px; color: var(--muted); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ch-timer {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 15px; font-weight: 700; color: var(--brand);
  padding: 2px 10px; border-radius: 999px;
  background: var(--brand-soft);
  transition: color .2s ease, background .2s ease;
}
.ch-timer.urgent { color: #fff; background: #e5484d; }
.ch-close {
  width: 30px; height: 30px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1; color: var(--muted);
  background: transparent; border: 1px solid transparent; border-radius: 9px;
  cursor: pointer;
}
.ch-close:hover { background: var(--chat-bg, #f3f5f8); color: var(--ink); }

/* 「↻ 重新生成」（2026-11-21）：顶栏右侧、× 左边的**次级**按钮。
   顶栏本来就窄（390px 要同时放 kicker + 范围 + 倒计时 + ×），
   所以窄屏只留图标 —— 但按钮不能藏（触屏没有悬停），只是文案收起来。 */
.ch-regen {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 10px;
  font-size: 12px; font-weight: 600; line-height: 1;
  color: var(--brand); background: var(--brand-soft);
  border: 1px solid transparent; border-radius: 9px;
  cursor: pointer; white-space: nowrap;
  transition: background .18s ease, color .18s ease, opacity .18s ease;
}
.ch-regen:hover { background: var(--brand); color: #fff; }
.ch-regen:disabled { opacity: .45; cursor: default; }
.ch-regen:disabled:hover { background: var(--brand-soft); color: var(--brand); }
.ch-regen[hidden] { display: none !important; }
.ch-regen-i { font-size: 14px; line-height: 1; }
@media (max-width: 430px) {
  .ch-regen { padding: 0 8px; }
  .ch-regen-t { display: none; }
}

.ch-body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px;
}

/* ── 加载 / 错误 ──────────────────────────────────────────────── */
.ch-center { padding: 40px 10px; text-align: center; }
.ch-spin {
  width: 30px; height: 30px; margin: 0 auto 14px;
  border: 3px solid var(--brand-soft); border-top-color: var(--brand);
  border-radius: 50%; animation: ch-spin .9s linear infinite;
}
@keyframes ch-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ch-spin { animation-duration: 3s; } }
.ch-loading-t { font-size: 14px; font-weight: 600; }
.ch-loading-s { margin-top: 8px; font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.ch-err-t { font-size: 15px; font-weight: 700; color: #e5484d; }
.ch-err-s { margin: 8px 0 16px; font-size: 13px; color: var(--muted); line-height: 1.7; }

/* ── 开场 ─────────────────────────────────────────────────────── */
.ch-intro-q {
  font-size: 14px; line-height: 1.75; color: var(--ink);
  padding: 12px 14px; border-radius: 12px;
  background: var(--chat-bg, #f7f9fc); border: 1px solid var(--border);
}
.ch-intro-meta { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.ch-intro-meta b { color: var(--ink); }
.ch-ilist {
  margin-top: 12px; display: flex; flex-direction: column; gap: 6px;
}
.ch-iline { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.ch-iline b {
  width: 20px; height: 20px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff; background: var(--brand); border-radius: 7px;
}
.ch-iline span { color: var(--ink); }
.ch-note {
  margin-top: 14px; font-size: 12.5px; line-height: 1.7; color: var(--muted);
  padding-left: 10px; border-left: 2px solid var(--brand-soft);
}
.ch-warn {
  margin-top: 12px; padding: 10px 12px;
  font-size: 12.5px; line-height: 1.65;
  color: #7a4a00; background: #fff7e6;
  border: 1px solid #f0c987; border-radius: 10px;
}
html[data-theme="dark"] .ch-warn { color: #f5d9a6; background: rgba(245, 166, 35, .14); border-color: rgba(245, 166, 35, .4); }
/* 「AI 复核没走通」用红调而不是琥珀调（2026-11-13）：它和上面那条"标答可能有误"
   是两个不同的坏消息，同色会让人以为是同一件事说了两遍。 */
.ch-warn-sus { color: #8a3b3b; background: #fdf1f1; border-color: #f2c4c4; }
html[data-theme="dark"] .ch-warn-sus {
  color: #f0c9c9; background: rgba(229, 72, 77, .12); border-color: rgba(229, 72, 77, .38);
}

/* ── 进度点 ───────────────────────────────────────────────────── */
.ch-prog { display: flex; align-items: center; gap: 7px; margin-bottom: 12px; }
.ch-dot {
  width: 22px; height: 6px; border-radius: 999px;
  background: var(--border);
}
.ch-dot.cur { background: var(--brand-soft); box-shadow: inset 0 0 0 1.5px var(--brand); }
.ch-dot.done.ok { background: #18a058; }
.ch-dot.done.seen { background: #f5a623; }

/* ── 关卡卡 ───────────────────────────────────────────────────── */
.ch-card {
  padding: 14px 14px 12px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--panel);
}
.ch-q { font-size: 15px; line-height: 1.8; font-weight: 600; color: var(--ink); }
.ch-why {
  margin-top: 6px; font-size: 12px; line-height: 1.65; color: var(--muted);
}
.ch-ia { margin-top: 12px; }

/* 托盘的卡都分完了：标签已由 JS 换成「都分完了，提交吧」，这里只把颜色转绿
   （与知识闯关同一种暗示）。**只改颜色不改尺寸** —— 高度一变下面的筐会跳。 */
.ch-panel .qz-tray.qz-empty { border-style: solid; border-color: rgba(24, 160, 88, .45); }
.ch-panel .qz-tray.qz-empty .qz-blabel { color: #18a058; }

.ch-num { display: flex; align-items: center; gap: 8px; }
/* 数值题的 √ / π 快捷键：手机键盘打不出根号，不给按钮就等于"这题答不出来"
   （2026-11-03 用户报障：答案是 2−√3，输入框只收数字）。 */
.ch-kbd { display: flex; gap: 4px; flex: 0 0 auto; }
.ch-kb {
  width: 34px; height: 40px; padding: 0;
  font-size: 15px; font-weight: 600; color: var(--brand);
  background: var(--brand-soft); border: 1px solid rgba(47, 109, 246, .25);
  border-radius: 9px; cursor: pointer;
}
.ch-kb:hover { border-color: var(--brand); }
html[data-theme="dark"] .ch-kb { background: rgba(47, 109, 246, .2); }.ch-num input {
  flex: 1 1 auto; min-width: 0;
  padding: 11px 13px; font-size: 16px;
  color: var(--ink); background: var(--chat-bg, #f7f9fc);
  border: 1.5px solid var(--border); border-radius: 10px;
  outline: none;
}
.ch-num input:focus { border-color: var(--brand); }
.ch-unit { font-size: 13.5px; color: var(--muted); white-space: nowrap; }

/* ── 反馈 ─────────────────────────────────────────────────────── */
.ch-fb {
  margin-top: 12px; padding: 10px 12px;
  font-size: 13px; line-height: 1.7;
  border-radius: 10px; border: 1px solid var(--border);
}
.ch-fb.ok { color: #0d7a43; background: #eafaf0; border-color: #a9e2c2; }
.ch-fb.bad { color: #a3352b; background: #fdeeee; border-color: #f2bcbc; }
.ch-fb.reveal { color: #7a4a00; background: #fff7e6; border-color: #f0c987; }
html[data-theme="dark"] .ch-fb.ok { color: #9be8bd; background: rgba(24, 160, 88, .16); border-color: rgba(24, 160, 88, .4); }
html[data-theme="dark"] .ch-fb.bad { color: #f3b0ad; background: rgba(229, 72, 77, .16); border-color: rgba(229, 72, 77, .4); }
html[data-theme="dark"] .ch-fb.reveal { color: #f5d9a6; background: rgba(245, 166, 35, .14); border-color: rgba(245, 166, 35, .4); }
.ch-fb-x { margin-top: 4px; font-size: 12.5px; line-height: 1.75; opacity: .92; }
.ch-fb-s { margin-top: 6px; font-size: 11.5px; opacity: .8; }

/* ── 选项选中态 ──────────────────────────────────────────────────
 * 【为什么必须自己写】quiz.css 里的 .qz-opt 只有 .right / .wrong / .gone，
 * 没有「已选中但还没交」这一态 —— 因为知识闯关点一下就直接判分，不需要中间态。
 * 拆解关是"选好再确认"，缺这一条的直接后果是：学生选了看不出变化，
 * 以为点不动（2026-11-03 用户报障）。 */
.ch-panel .qz-opt.sel {
  border-color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, .16);
}
.ch-panel .qz-opt.sel .qz-opt-l { background: var(--brand); color: #fff; }
.ch-panel .qz-opt.sel .qz-opt-t { font-weight: 600; }
/* 多选：再点一次取消 —— 给个"可以反选"的暗示 */
.ch-panel .qz-opt.sel::after {
  content: "✓"; margin-left: 2px; color: var(--brand);
  font-size: 13px; font-weight: 700; line-height: 1;
  align-self: center;
}

/* ── 底部按钮 ─────────────────────────────────────────────────── */
.ch-foot { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.chg-btn {
  padding: 10px 18px; font-size: 13.5px; font-weight: 600;
  color: var(--ink); background: var(--chat-bg, #f3f5f8);
  border: 1px solid var(--border); border-radius: 11px;
  cursor: pointer;
}
/* hover 只给次要按钮换色。主按钮若也吃这条，文字会被染成品牌蓝 ——
   蓝底蓝字等于看不见（2026-11-03 用户截图报障）。 */
.chg-btn:not(.chg-btn-main):hover { border-color: var(--brand); color: var(--brand); }
.chg-btn-main { color: #fff; background: var(--brand); border-color: var(--brand); }
.chg-btn-main:hover:not([disabled]) { filter: brightness(1.06); }
.chg-btn[disabled] { cursor: default; }
/* 禁用态必须是**明确的灰**。原来用 opacity:.5 让蓝底半透明，
   鼠标一悬停看着就是"白底白字"—— 用户以为按钮坏了（2026-11-03 报障）。 */
.chg-btn-main[disabled] {
  background: var(--chat-bg, #eef1f5);
  color: #8b95a5; border-color: var(--border);
  filter: none;
}
html[data-theme="dark"] .chg-btn-main[disabled] {
  background: rgba(255, 255, 255, .06); color: rgba(255, 255, 255, .38);
}
.ch-tip { font-size: 12px; color: var(--muted); }

/* ── 结果页 ───────────────────────────────────────────────────── */
.ch-result { padding: 6px 2px; }
.ch-res-t { font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.ch-res-t.ok { color: #18a058; }
.ch-res-t.bad { color: #e5484d; }
.ch-res-s { margin-top: 6px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.ch-res-meta { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.ch-res-meta b { color: var(--ink); }
.ch-rlist {
  margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px;
}
.ch-rrow {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px 4px 5px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--chat-bg, #f7f9fc);
}
.ch-rrow i {
  width: 17px; height: 17px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-style: normal; color: #fff; background: #b4b2a9;
}
.ch-rrow.ok i { background: #18a058; }
.ch-rrow.seen i { background: #f5a623; }
.ch-rrow.fail i { background: #e5484d; }
.ch-rrow.fail { border-color: #f2bcbc; }
.ch-rrow.todo { opacity: .6; }
/* 复核有分歧的关（2026-11-13）：虚线边 + 小字「存疑」，一眼能和"你答错了"区分开 ——
   这一关是题/链本身可疑，不是他的问题。 */
.ch-rrow.sus { border-style: dashed; border-color: #e0b64a; }
.ch-sus { font-style: normal; font-size: 10.5px; line-height: 1; color: #b8811a; }
html[data-theme="dark"] .ch-sus { color: #f0c987; }
/* 「完整解析去题库看」的指路（2026-11-13）：原「看完整解析」折叠块已下线 ——
   服务端截断到 1800 字（多小问只到第 2 问）+ 面板纯文本渲染（图片只剩〔图片〕），
   与其给一份残的，不如指路。字号/颜色跟 .ch-res-meta 一档，不抢成功/失败的视线。 */
.ch-more {
  margin-top: 12px; font-size: 12.5px; line-height: 1.6;
  color: var(--muted); text-align: center;
}
.ch-res-btns { margin-top: 16px; display: flex; gap: 10px; }

@media (max-width: 560px) {
  .ch-overlay { padding: 0; }
  .ch-panel { width: 100%; max-height: var(--vh); height: 100%; border-radius: 0; border: 0; }
  .ch-body { padding: 12px; }
  .ch-q { font-size: 14px; }
  .ch-timer { font-size: 14px; }
}
