/* ============================================================
   行测双人对战 · 主题样式
   ============================================================
   第八阶段 UI 要求逐条落实：

   1. 低饱和度、护眼配色
      浅色模式：米白 #F5F5F0 系（不用纯白 #FFF）
      深色模式：深灰蓝 #1E1E2E 系（不用纯黑 #000）
   2. 强调色用柔和蓝绿 / 暖橙，避免刺眼的高饱和红黄
   3. 系统默认无衬线字体，字号足够大，行距宽松
   4. 动效平滑，不闪烁、不突然跳变
   5. 答题反馈用柔和绿 / 红，不用荧光色
   6. 移动端适配：响应式、视口、触摸优化
   ============================================================ */

/* ---------------- 浅色模式（默认） ---------------- */
:root {
  /* 背景层：米白，不用纯白 */
  --bg:            #F5F5F0;
  --bg-elevated:   #FBFBF7;
  --bg-sunken:     #EDEDE6;
  --surface:       #FFFFFF;
  --surface-hover: #F7F7F2;

  /* 文字：不用纯黑，降低对比疲劳 */
  --text:          #2E2E38;
  --text-secondary:#5A5A68;
  --text-muted:    #8A8A96;
  --text-inverse:  #FBFBF7;

  /* 边框：柔和 */
  --border:        #E2E2D8;
  --border-strong: #CFCFC4;

  /* 强调色：柔和蓝绿（主）+ 暖橙（辅） */
  --accent:        #4A9D8E;
  --accent-soft:   #E3F0ED;
  --accent-hover:  #3F8B7E;
  --accent-warm:   #D99058;
  --accent-warm-soft: #F7EBE0;

  /* 答题反馈：柔和绿 / 红，绝不荧光 */
  --correct:       #5B9E6B;
  --correct-soft:  #E6F1E8;
  --wrong:         #C4736B;
  --wrong-soft:    #F6E8E6;
  --pending:       #B8A15E;
  --pending-soft:  #F5F0E0;

  /* 状态色（用于徽标） */
  --badge-frequent-bg: #F7EBE0;
  --badge-frequent-fg: #A96A3C;
  --badge-key-bg:      #F6E8E6;
  --badge-key-fg:      #A8524A;

  /* 阴影：轻柔 */
  --shadow-sm: 0 1px 2px rgba(46,46,56,.05);
  --shadow:    0 2px 8px rgba(46,46,56,.07);
  --shadow-lg: 0 8px 24px rgba(46,46,56,.10);

  /* 圆角与间距 */
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  /* 字体：系统默认无衬线 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
          "Noto Sans CJK SC", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  /* 字号：偏大，行距宽松 */
  --fs-xs: 13px;
  --fs-sm: 15px;
  --fs-base: 17px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-2xl: 30px;
  --lh-tight: 1.4;
  --lh: 1.75;
  --lh-loose: 1.9;

  /* 动效：平滑，无闪烁 */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur-fast: 140ms;
  --dur: 220ms;
  --dur-slow: 380ms;

  /* 布局 */
  --maxw: 960px;
  --header-h: 60px;
}

/* ---------------- 深色模式 ---------------- */
/* 深灰蓝底，不用纯黑；对比度略降，夜间不刺眼 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #1E1E2E;
    --bg-elevated:   #252536;
    --bg-sunken:     #191926;
    --surface:       #282840;
    --surface-hover: #2F2F4A;

    --text:          #E4E4EC;
    --text-secondary:#B4B4C4;
    --text-muted:    #8A8A9E;
    --text-inverse:  #1E1E2E;

    --border:        #35354E;
    --border-strong: #45455F;

    --accent:        #6FBFAE;
    --accent-soft:   #23423C;
    --accent-hover:  #82CDBD;
    --accent-warm:   #E0A470;
    --accent-warm-soft: #3D2F22;

    --correct:       #7BB98A;
    --correct-soft:  #23392A;
    --wrong:         #D68E85;
    --wrong-soft:    #3B2624;
    --pending:       #CBB677;
    --pending-soft:  #38321F;

    --badge-frequent-bg: #3D2F22;
    --badge-frequent-fg: #E0A470;
    --badge-key-bg:      #3B2624;
    --badge-key-fg:      #D68E85;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.25);
    --shadow:    0 2px 10px rgba(0,0,0,.30);
    --shadow-lg: 0 8px 28px rgba(0,0,0,.40);
  }
}

/* 手动切换深色（覆盖系统设置） */
:root[data-theme="dark"] {
  --bg:            #1E1E2E;
  --bg-elevated:   #252536;
  --bg-sunken:     #191926;
  --surface:       #282840;
  --surface-hover: #2F2F4A;
  --text:          #E4E4EC;
  --text-secondary:#B4B4C4;
  --text-muted:    #8A8A9E;
  --text-inverse:  #1E1E2E;
  --border:        #35354E;
  --border-strong: #45455F;
  --accent:        #6FBFAE;
  --accent-soft:   #23423C;
  --accent-hover:  #82CDBD;
  --accent-warm:   #E0A470;
  --accent-warm-soft: #3D2F22;
  --correct:       #7BB98A;
  --correct-soft:  #23392A;
  --wrong:         #D68E85;
  --wrong-soft:    #3B2624;
  --pending:       #CBB677;
  --pending-soft:  #38321F;
  --badge-frequent-bg: #3D2F22;
  --badge-frequent-fg: #E0A470;
  --badge-key-bg:      #3B2624;
  --badge-key-fg:      #D68E85;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.25);
  --shadow:    0 2px 10px rgba(0,0,0,.30);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.40);
}

/* ---------------- 基础重置 ---------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  /* 触摸优化：禁止双击缩放导致的延迟 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  /* 主题切换平滑过渡，不闪烁 */
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 尊重用户的"减少动效"偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

h1, h2, h3, h4 {
  margin: 0 0 .6em;
  line-height: var(--lh-tight);
  font-weight: 650;
  color: var(--text);
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

p { margin: 0 0 1em; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--accent-hover); }

img {
  max-width: 100%;
  height: auto;
  /* 注意：这里**不能**默认 opacity:0。
     早期版本靠"加载成功后加 .loaded 类"才显示，
     结果只要 load 事件没触发（弱网、缓存、浏览器差异），
     图片就永久隐身，页面只剩空白 —— 题目图全靠图片的
     图形推理题会整题空白。
     现在改为：默认可见，仅在标记了 .img-pending 时才淡入。 */
}
img.img-pending {
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease);
}
img.img-pending.loaded { opacity: 1; }

/* 题目图片：白底卡片，方便看图表 */
.q-image {
  display: block;
  margin: 12px auto;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 100%;
}
.q-image.inline {
  display: inline-block;
  margin: 0 2px;
  padding: 1px 3px;
  vertical-align: middle;
  max-height: 2.6em;
}

/* ---------------- 布局 ---------------- */
.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.header .brand {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--text);
  white-space: nowrap;
}
.header .brand .dot { color: var(--accent); }
.header .spacer { flex: 1; }

.main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.footer {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  border-top: 1px solid var(--border);
}

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card.tight { padding: 14px; }
.card.center { text-align: center; }
.card-title {
  font-size: var(--fs-lg);
  font-weight: 650;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  min-height: 46px;          /* 触摸友好 */
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1.2;
  color: var(--text-inverse);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  /* 触摸优化 */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background-color var(--dur) var(--ease),
              transform var(--dur-fast) var(--ease),
              box-shadow var(--dur) var(--ease),
              opacity var(--dur) var(--ease);
}
.btn:hover:not(:disabled) { background: var(--accent-hover); box-shadow: var(--shadow); }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.995); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn.secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn.warm { background: var(--accent-warm); }
.btn.warm:hover:not(:disabled) { background: var(--accent-warm); filter: brightness(1.05); }

.btn.ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  font-weight: 500;
}
.btn.ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }

.btn.small { padding: 8px 14px; min-height: 38px; font-size: var(--fs-sm); }
.btn.block { width: 100%; }
.btn.lg { padding: 15px 28px; min-height: 54px; font-size: var(--fs-lg); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row.end { justify-content: flex-end; }

/* ---------------- 表单 ---------------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input {
  width: 100%;
  padding: 13px 15px;
  min-height: 48px;
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  /* 触摸优化 */
  touch-action: manipulation;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-muted); }

/* 房间码输入框：等宽、大字、字距宽 */
.input.code {
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  letter-spacing: .3em;
  text-align: center;
  text-transform: uppercase;
  font-weight: 700;
}

.hint { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 6px; line-height: 1.6; }

/* ---------------- 房间码展示 ---------------- */
.room-code {
  font-family: var(--font-mono);
  font-size: 42px;
  font-weight: 800;
  letter-spacing: .22em;
  color: var(--accent);
  padding: 18px 10px;
  background: var(--accent-soft);
  border-radius: var(--radius);
  text-align: center;
  user-select: all;            /* 方便分享时复制 */
  word-break: break-all;
  transition: background-color var(--dur) var(--ease);
}

/* ---------------- 徽标 / 标签 ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: var(--fs-xs);
  font-weight: 600;
  border-radius: var(--radius-pill);
  background: var(--bg-sunken);
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.correct { background: var(--correct-soft); color: var(--correct); }
.badge.wrong { background: var(--wrong-soft); color: var(--wrong); }
.badge.pending { background: var(--pending-soft); color: var(--pending); }
.badge.frequent { background: var(--badge-frequent-bg); color: var(--badge-frequent-fg); }
.badge.key { background: var(--badge-key-bg); color: var(--badge-key-fg); }

.tag {
  display: inline-block;
  padding: 2px 9px;
  font-size: var(--fs-xs);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ---------------- 题号导航（模块内自选题） ---------------- */
.qnav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.qnav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;             /* 触摸友好 */
  font-size: var(--fs-base);
  font-weight: 650;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background-color var(--dur-fast) var(--ease),
              border-color var(--dur-fast) var(--ease),
              color var(--dur-fast) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.qnav-item:hover { background: var(--surface-hover); transform: translateY(-1px); }
.qnav-item:active { transform: translateY(0); }
.qnav-item.current {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.qnav-item.correct {
  border-color: var(--correct);
  background: var(--correct-soft);
  color: var(--correct);
}
.qnav-item.wrong {
  border-color: var(--wrong);
  background: var(--wrong-soft);
  color: var(--wrong);
}
/* 已答/未答/对错状态标记：小圆点 */
.qnav-item .mark {
  position: absolute;
  margin-top: -26px;
  margin-left: 26px;
  font-size: 11px;
}

/* 未答题提醒：点「下一题」时闪烁两下，把注意力引到没做的题号上 */
@keyframes flashRemind {
  0%, 100% { box-shadow: 0 0 0 0 rgba(214, 122, 62, 0); }
  50% { box-shadow: 0 0 0 4px rgba(214, 122, 62, 0.55); background: var(--warn-soft, #fdf1e6); }
}
.qnav-item.flash-remind {
  animation: flashRemind 0.55s ease-in-out 2;
  border-color: var(--warn, #d67a3e);
}

/* ---------------- 对局视图：内部滚动区 ---------------- */
/* 题目区自己滚动，切题时只需把它的 scrollTop 归零。
   彻底避开"短题目文档不够高、window 滚不动"的问题。 */
/* ⚠ 对局视图**不再固定任何区块**（用户最终决定）。
   曾经用 flex + 内部滚动容器解决"短题目 window 滚不动"，
   但代价是手机上题目区被挤到只剩 ~1cm，
   而且滚动时题号上的对错符号会留在固定坐标、不跟着走。
   现在恢复整页滚动：切题后滚到**题目卡片顶部**（不是题号行，
   避免把上方的材料顶出视口）。短题目滚不到位的问题已在
   CSS 层用 #question-card 的 scroll-margin-top + 下方留白解决。 */
.q-scroll {
  display: block;
  padding-bottom: 8px;
}

/* ---------------- 题目 ---------------- */
/* 题号行：切题后滚动到这里，并吸附在顶部，读长材料时也不会丢失题号 */
.q-head {
  /* ⚠ 刻意**不**用 position:sticky。
     真实故障：全局顶栏 .header 是 sticky top:0，
     题号行原来也是 sticky top:0 —— 两者叠在一起，
     题号行被 60px 高的顶栏完全盖住；
     而 JS 把"题号行滚到 top=12"当作成功，日志看着正常，实际看不见。
     改为普通流式布局后，滚动目标是"题目卡片顶部"，
     题号行自然出现在顶栏下方，不再有遮挡。 */
  padding: 6px 2px;
  margin: 0 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* 无 sticky 支持或用户偏好减少动效时，保证仍能正确停位 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* 作答闸门：题目/图片就绪前，选项不可点（视觉上置灰并给出提示）。
   防止"图还没加载出来就已经算我答完了"的误点。 */
#question-card.options-pending #q-options {
  opacity: 0.45;
  pointer-events: none;
  filter: grayscale(0.35);
}
#question-card.options-pending #q-options::after {
  content: '图片载入中，稍候即可作答…';
  display: block;
  margin-top: 8px;
  font-size: var(--fs-sm, 13px);
  color: var(--text-muted, #9a9a9a);
}

/* 题目卡片：切题滚动到它时，顶部留出全局顶栏的高度，
   避免被 sticky 的 .header 遮住（这正是之前"看不到题干"的原因）。 */
#question-card {
  scroll-margin-top: calc(var(--header-h) + 12px);
}

.stem {
  font-size: var(--fs-lg);
  line-height: var(--lh-loose);   /* 行距宽松，长题干好读 */
  margin-bottom: 18px;
  color: var(--text);
}
.material {
  padding: 14px 16px;
  margin-bottom: 18px;
  background: var(--bg-sunken);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  line-height: var(--lh-loose);
  color: var(--text-secondary);
  max-height: 320px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  min-height: 52px;              /* 触摸友好 */
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg-elevated);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background-color var(--dur) var(--ease),
              border-color var(--dur) var(--ease),
              transform var(--dur-fast) var(--ease);
}
.option:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.option:active { transform: scale(.995); }
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option.correct { border-color: var(--correct); background: var(--correct-soft); }
.option.wrong { border-color: var(--wrong); background: var(--wrong-soft); }
.option.disabled { cursor: default; opacity: .92; }
.option .label {
  flex: 0 0 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  background: var(--bg-sunken);
  border-radius: 50%;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.option.selected .label { background: var(--accent); color: var(--text-inverse); }
.option.correct .label { background: var(--correct); color: #fff; }
.option.wrong .label { background: var(--wrong); color: #fff; }
.option .text { flex: 1; }

/* ---------------- 反馈 ---------------- */
.feedback {
  margin-top: 14px;
  padding: 13px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 9px;
  animation: fadeSlide var(--dur-slow) var(--ease);
}
.feedback.correct { background: var(--correct-soft); color: var(--correct); }
.feedback.wrong { background: var(--wrong-soft); color: var(--wrong); }
.feedback.info { background: var(--accent-soft); color: var(--accent); }

/* 平滑出现，不闪烁 */
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------------- 计时器 ---------------- */
.timer {
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  transition: color var(--dur) var(--ease);
}
.timer.urgent { color: var(--accent-warm); }

/* ---------------- 对手进度条 ---------------- */
.progress-bar {
  height: 8px;
  background: var(--bg-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 6px;
}
.progress-bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  /* 进度变化平滑，不跳变 */
  transition: width var(--dur-slow) var(--ease);
}
.progress-bar.warm > i { background: var(--accent-warm); }
.progress-bar.correct > i { background: var(--correct); }
.progress-bar.wrong > i { background: var(--wrong); }

.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}
.player-row + .player-row { border-top: 1px solid var(--border); }
.player-row .who { flex: 0 0 auto; font-weight: 650; }
.player-row .stats { margin-left: auto; font-size: var(--fs-sm); color: var(--text-secondary); }
.player-row .bar-wrap { flex: 1; min-width: 90px; }

/* ---------------- 错题诊断：占比条形图 ---------------- */
.ratio-list { display: flex; flex-direction: column; gap: 12px; }
.ratio-item { }
.ratio-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 5px;
}
.ratio-label { font-weight: 600; font-size: var(--fs-sm); }
.ratio-value {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.ratio-track {
  height: 12px;
  background: var(--bg-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.ratio-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transition: width var(--dur-slow) var(--ease);
}
.ratio-fill.frequent { background: var(--accent-warm); }
.ratio-fill.key { background: var(--wrong); }

/* ---------------- 结果页 ---------------- */
.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.score-cell {
  padding: 14px 10px;
  text-align: center;
  background: var(--bg-sunken);
  border-radius: var(--radius);
  transition: background-color var(--dur) var(--ease);
}
.score-cell .num {
  font-size: var(--fs-2xl);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.score-cell .lbl { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 3px; }
.score-cell.correct .num { color: var(--correct); }
.score-cell.wrong .num { color: var(--wrong); }
.score-cell.accent .num { color: var(--accent); }

.winner-banner {
  padding: 20px;
  text-align: center;
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  animation: fadeSlide var(--dur-slow) var(--ease);
}
.winner-banner .title { font-size: var(--fs-xl); font-weight: 750; color: var(--accent); }
.winner-banner .sub { color: var(--text-secondary); margin-top: 6px; font-size: var(--fs-sm); }

/* ---------------- 解析卡片 ---------------- */
.analysis {
  padding: 16px;
  background: var(--bg-sunken);
  border-radius: var(--radius);
  line-height: var(--lh-loose);
  font-size: var(--fs-base);
  animation: fadeIn var(--dur-slow) var(--ease);
}
.analysis h4 { font-size: var(--fs-base); color: var(--accent); margin: 14px 0 6px; }
.analysis h4:first-child { margin-top: 0; }
.analysis p { margin: 0 0 .8em; }
.analysis code {
  font-family: var(--font-mono);
  font-size: .92em;
  padding: 1px 5px;
  background: var(--bg-elevated);
  border-radius: 4px;
}
.analysis strong { color: var(--text); font-weight: 700; }

.feedback-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
  align-items: center;
}
.btn.learned { background: var(--correct); }
.btn.not-understood { background: var(--accent-warm); }

/* 「说清我卡在哪一步」勾选框：勾上后才出现填写框，
   让考生把堵点直接告诉 AI，讲解会专门针对这一点。 */
.confusion-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm, 13px);
  color: var(--text-soft, #6b6b6b);
  cursor: pointer;
  user-select: none;
}
.confusion-toggle input { width: 16px; height: 16px; cursor: pointer; }
.confusion-box { margin-top: 10px; }
.confusion-box .input { width: 100%; }
/* 输入框与"提交疑问"按钮同行，玩家一眼就能看到怎么提交 */
.confusion-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.confusion-row .input { flex: 1; min-width: 0; }
.confusion-row .btn { flex: 0 0 auto; white-space: nowrap; }

/* 诊断报告里的题号容器：展开时用 flex 排布（默认折叠走 .hidden 类） */
.ratio-chips { display: flex; }
.ratio-chips.hidden { display: none; }

/* ---------------- 加载 / 提示 ---------------- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
}

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: calc(100% - 32px);
  max-width: 420px;
}
.toast {
  padding: 12px 18px;
  background: var(--text);
  color: var(--bg);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: fadeSlide var(--dur) var(--ease);
  max-width: 100%;
  text-align: center;
}
.toast.error { background: var(--wrong); color: #fff; }
.toast.success { background: var(--correct); color: #fff; }
.toast.info { background: var(--accent); color: #fff; }

/* ---------------- 弹窗 ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(20, 20, 30, .45);
  backdrop-filter: blur(3px);
  animation: fadeIn var(--dur) var(--ease);
}
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-lg);
  animation: fadeSlide var(--dur-slow) var(--ease);
}

/* ---------------- 对局状态条 ---------------- */
.game-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
  position: sticky;
  top: var(--header-h);
  z-index: 40;
}
.game-bar .meta { display: flex; flex-direction: column; gap: 2px; }
.game-bar .meta .k { font-size: var(--fs-xs); color: var(--text-muted); }
.game-bar .meta .v { font-weight: 700; font-size: var(--fs-sm); }

/* ---------------- 连接状态条 ---------------- */
/* 断线/重连时的轻量提示，固定在顶部，不用弹窗刷屏、不闪烁 */
.conn-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 300;
  display: none;
  padding: 7px 14px;
  text-align: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.conn-bar.warn { background: var(--pending-soft); color: var(--pending); }
.conn-bar.info { background: var(--accent-soft); color: var(--accent); }
.conn-bar.error { background: var(--wrong-soft); color: var(--wrong); }

/* ---------------- 工具类 ---------------- */
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--text-muted); }
.secondary-text { color: var(--text-secondary); }
.small { font-size: var(--fs-sm); }
.xsmall { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none !important; }
.center { text-align: center; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------------- 移动端适配 ---------------- */
@media (max-width: 640px) {
  :root {
    --fs-base: 16px;
    --fs-lg: 19px;
    --fs-xl: 22px;
    --fs-2xl: 26px;
    --maxw: 100%;
    --header-h: 56px;
  }
  .main { padding: 14px 12px 64px; }
  .card { padding: 16px; border-radius: var(--radius); }
  .room-code { font-size: 32px; letter-spacing: .16em; padding: 14px 6px; }
  .input.code { font-size: var(--fs-xl); letter-spacing: .22em; }
  .stem { font-size: var(--fs-base); }
  .btn-row { flex-direction: column; }
  .btn-row .btn { width: 100%; }
  .btn-row.end { flex-direction: row; justify-content: flex-end; }
  .btn-row.end .btn { width: auto; }
  .qnav { grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
  .qnav-item { min-height: 42px; font-size: var(--fs-sm); }
  .header .brand { font-size: var(--fs-base); }
  .material { max-height: 240px; font-size: var(--fs-xs); }
  .score-grid { grid-template-columns: repeat(2, 1fr); }
}

/* 横屏手机：压缩纵向空间 */
@media (max-height: 480px) and (orientation: landscape) {
  .material { max-height: 140px; }
  .room-code { font-size: 26px; padding: 10px; }
}

/* 打印：错题集可以直接打印出来复习 */
@media print {
  .header, .footer, .btn, .game-bar, .toast-wrap, .modal-backdrop { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
}

/* 反复追问时折叠起来的"上一次讲解" */
.prev-analysis { margin-top: 10px; padding-top: 6px; border-top: 1px dashed var(--border); }
/* 原生 <details> 折叠：每层独立展开，互不影响 */
.prev-analysis-toggle {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 2px;
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.prev-analysis-toggle::-webkit-details-marker { display: none; }
.prev-analysis-toggle::before { content: '▸ '; }
.prev-analysis[open] > .prev-analysis-toggle::before { content: '▾ '; }
.prev-analysis-toggle:hover { color: var(--accent); }
.prev-analysis-body {
  margin-top: 8px;
  padding: 10px 12px;
  border-left: 3px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  opacity: .9;
}
/* ---------------- P1-1 玩家自选 emoji ---------------- */
.emoji-picker { display: block; }
.emoji-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.emoji-choice {
  font-size: 22px;
  line-height: 1;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease);
  /* 触摸友好 */
  -webkit-tap-highlight-color: transparent;
}
.emoji-choice:active { transform: scale(0.92); }
.emoji-choice.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
/* ---------------- P1-4 我的错题本 ---------------- */
.stat-row { display: flex; gap: 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .k { font-size: var(--fs-sm); color: var(--text-secondary); }
.stat .v { font-size: var(--fs-xl); font-weight: 700; }

.hist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.hist-row:last-child { border-bottom: 0; }
.hist-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hist-room { font-weight: 600; letter-spacing: 1px; }
.hist-actions { flex: 0 0 auto; }

.nb-tax-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.nb-tax-row:last-child { border-bottom: 0; }
.nb-tax-name { flex: 1 1 auto; min-width: 0; font-weight: 500; }

/* ---------------- P1-1 emoji 两行选择器 ---------------- */
.emoji-row { margin-top: 8px; }
.emoji-row-label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-bottom: 4px;
}
/* ---------------- 错题本：单题型题号 ---------------- */
.nb-qchips { display: flex; flex-wrap: wrap; gap: 8px; }
.nb-qchip {
  min-width: 58px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: var(--fs-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nb-qchip:active { transform: scale(0.96); }
.nb-qchip:hover { border-color: var(--accent); color: var(--accent); }
/* ---------------- 错题本：模块 → 题型 双层折叠 ---------------- */
.nb-module { margin-bottom: 10px; }
.nb-module-sum {
  cursor: pointer; font-weight: 700; padding: 8px 4px;
  list-style: none; user-select: none;
}
.nb-module-sum::-webkit-details-marker { display: none; }
.nb-module-sum::before { content: '▸ '; }
.nb-module[open] > .nb-module-sum::before { content: '▾ '; }

.nb-group {
  margin: 4px 0 8px 14px; padding-left: 10px;
  border-left: 2px solid var(--border);
}
.nb-group-sum {
  cursor: pointer; font-size: var(--fs-sm); color: var(--text-secondary);
  padding: 4px 0; list-style: none; user-select: none;
}
.nb-group-sum::-webkit-details-marker { display: none; }
.nb-group-sum::before { content: '▸ '; }
.nb-group[open] > .nb-group-sum::before { content: '▾ '; }

/* 题号按钮：⭐ 用**微型角标**，绝不撑大按钮 */
.nb-qchip {
  position: relative;
  min-width: 40px; height: 40px; padding: 0 4px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elevated); color: var(--text);
  font-size: var(--fs-sm); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nb-qchip:active { transform: scale(0.94); }
.nb-qchip:hover { border-color: var(--accent); color: var(--accent); }
.nb-qchip-no { line-height: 40px; }
.nb-qchip-star {
  position: absolute; top: -6px; right: -4px;
  font-size: 10px; line-height: 1; color: #f5a623;
  text-shadow: 0 0 2px #fff; pointer-events: none;
}
.nb-stars-big { font-size: 18px; color: #f5a623; letter-spacing: 2px; }
/* ---------------- 错题本目录（与错题集按钮同卡片） ---------------- */
.nb-tree-slot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.nb-hist { margin-top: 12px; }
.nb-hist-sum {
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  padding: 6px 0;
  list-style: none;
  user-select: none;
  text-align: center;
}
.nb-hist-sum::-webkit-details-marker { display: none; }
.nb-hist-sum::after { content: ' ▾'; }
.nb-hist[open] > .nb-hist-sum::after { content: ' ▴'; }
/* ---------------- 题目报错对话框 ---------------- */
.rq-list { display: flex; flex-direction: column; gap: 8px; }
.rq-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.rq-row:has(input:checked) { border-color: var(--accent); background: var(--bg-elevated); }
.rq-label { font-weight: 600; font-size: var(--fs-sm); }
/* ============================================================
   P1-3 批注画板
   ============================================================ */
/* 画板宿主：需要 relative 定位作为 canvas 的参照 */
.anno-host { position: relative; }
.anno-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 6;
  border-radius: inherit;
  /* ⚠ 默认关闭：pointer-events:none 让所有点击照常落到选项上 —— 这是防误触的关键 */
  pointer-events: none;
  touch-action: auto;
}
/* 开启批注后才接收指针事件 */
.anno-canvas.anno-on {
  pointer-events: auto;
  touch-action: none;   /* 画的时候不让页面跟着滚 */
  cursor: crosshair;
}
/* 批注中：明确提示选项不可点，避免"点了没反应"的困惑 */
.options.anno-blocked { opacity: .75; }

.anno-bar-box { margin: 8px 0; }
.anno-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}
.anno-hint {
  font-size: var(--fs-sm);
  color: var(--accent);
  font-weight: 600;
}
.anno-color {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
}

/* 材料图片可点击放大 */
.material-zoomable { cursor: zoom-in; }

/* 全屏图片查看器 */
.iv-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, .88);
  display: flex;
  flex-direction: column;
}
.iv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  color: #fff;
}
.iv-title { font-size: var(--fs-sm); opacity: .85; }
.iv-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}
.iv-img {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}
/* 放大查看器：图片容器（批注画板挂在这里，随 transform 一起缩放） */
.iv-imgwrap { position: relative; display: inline-block; line-height: 0; }
.iv-imgwrap .iv-img { display: block; }
.iv-toast {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: var(--fs-sm);
  pointer-events: none;
  z-index: 5;
}
/* #7 输入框为空时的**非阻塞**提示：红色边框闪一下（不弹阻塞式错误） */
.input-error {
  border-color: var(--wrong) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--wrong) 22%, transparent);
  animation: inputShake .18s ease-in-out 2;
}
@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* #4 批注时临时展开可滑动材料：让整段内容可见，画板才能覆盖全高 */
.material.anno-expand {
  max-height: none !important;
  overflow: visible !important;
}

/* #2 未完成对局提示（并入「输入房间码加入」卡片） */
.resume-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.resume-inline-text { font-size: var(--fs-sm); font-weight: 600; }

/* 对局模式 / 模块选择（首页） */
.mode-row { display: flex; gap: 8px; flex-wrap: wrap; }
.mode-chip, .module-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--fs-sm);
  user-select: none;
}
.mode-chip:has(input:checked), .module-chip:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  font-weight: 600;
}
.mode-chip input, .module-chip input { margin: 0; }
.module-pick { display: flex; flex-wrap: wrap; gap: 8px; }


/* 首页"对局设置"两页 tab（仿错题集的两页切换） */
.setup-tabs {
  display: flex;
  gap: 6px;
  margin: 12px 0 10px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.setup-tab {
  flex: 1 1 0;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.setup-tab.active {
  background: var(--bg-card, #fff);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.setup-page { text-align: left; }

/* UI：题型紧跟题号；做题标记 🐷 */
.q-subtype-inline {
  margin-left: 8px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12px;
}
.q-subtype-inline:empty { display: none; }
.q-current-pig {
  font-size: 15px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.15));
}

/* 顶栏批注工具条（用户要求：工具栏放到最顶端） */
.anno-tools {
  position: sticky;
  top: 0;
  z-index: 60;
  padding: 6px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.anno-tools .anno-bar { border: none; background: transparent; padding: 0; }
.anno-width {
  min-width: 30px;
  padding: 4px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  /* ⚠ 必须显式继承主题文字色：否则深色模式下按钮文字仍是浏览器默认黑字，
     在深色底上看不见（线上反馈：细/中/粗 在夜间模式不显示成白字）。 */
  color: var(--text);
  font-size: var(--fs-sm);
  font-family: inherit;
  cursor: pointer;
}

/* 批注工具条里的按钮同样继承主题色 */
.anno-bar .btn,
.anno-bar .btn.ghost {
  color: var(--text);
}
.anno-bar .btn.small:not(.ghost) {
  color: #fff;
}
/* 深色模式下"完成"按钮保持高对比 */
html[data-theme="dark"] .anno-bar .btn.small:not(.ghost) {
  color: #0C1220;
}

.anno-width.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  font-weight: 700;
}
.anno-toast {
  position: fixed;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0,0,0,.78);
  color: #fff;
  font-size: var(--fs-sm);
  z-index: 400;
  pointer-events: none;
}

/* 题干行右侧图标组：🐷 / ⚠️ 靠拢，不做均匀分布 */
.q-head-icons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* 顶栏动作区：图标靠右、彼此贴近（用户反馈：之前像"车头摆件"均匀散开） */
.header .btn.ghost.small {
  padding: 4px 7px;
  margin-left: 2px;
}
.header { gap: 4px; }

/* 图片加载失败：整块可点（用户反馈：只点红字太不方便） */
.img-retry {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 96px;
  padding: 14px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  cursor: pointer;
  user-select: none;
}
.img-retry:active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.img-retry .t { font-weight: 600; }
.img-retry .s { font-size: 12px; opacity: .8; }


/* 顶栏动作区：靠拢右对齐、仅图标（用户反馈：之前均匀散开像车头摆件） */
.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}
.header-actions .btn {
  padding: 4px 8px;
  min-width: 0;
  line-height: 1.2;
}


/* 题号胶囊右上角的 🐷：「正在做这道题」 */
.qnav-item { position: relative; }
.qnav-pig {
  position: absolute;
  top: -7px;
  right: -6px;
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.18));
}


/* ============================================================
   深色模式下的图片衬底
   ------------------------------------------------------------
   公式图 / 数据表格图大多是**透明背景 PNG**：
   深色主题下黑字压在深底上几乎看不见，放大后更是"一片黑"。
   这里统一给它们配一张浅色"纸"，黑白内容都清晰可辨。
   ============================================================ */
html[data-theme="dark"] .stem img,
html[data-theme="dark"] .material img,
html[data-theme="dark"] .options img,
html[data-theme="dark"] .analysis img,
html[data-theme="dark"] #q-feedback img,
html[data-theme="dark"] .iv-imgwrap {
  background: #FFFFFF;
  padding: 4px;
  border-radius: 6px;
  /* 轻微描边，避免白底与深色背景边界糊在一起 */
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .18);
}

/* 放大查看器：深色模式下也给图片本身加白底（否则透明处是黑洞） */
html[data-theme="dark"] .iv-img {
  background: #FFFFFF;
  padding: 6px;
  border-radius: 6px;
}


/* 整卡单画板：画布铺满卡片，圆角裁剪避免溢出圆角外 */
.anno-host { position: relative; }
.anno-host > .anno-canvas { border-radius: inherit; }


/* ============================================================
   本局全部题目：题号网格（结算后复盘用）
   红框＝答错，绿边＝答对，灰＝未作答
   ============================================================ */
.allq-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.allq-chip {
  width: 42px;
  min-height: 40px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}
.allq-chip.correct {
  border-color: var(--right, #18A058);
  color: var(--right, #18A058);
}
.allq-chip.wrong {
  border-color: var(--wrong, #E5484D);
  color: var(--wrong, #E5484D);
  background: color-mix(in srgb, var(--wrong, #E5484D) 8%, transparent);
}
.allq-chip.unanswered {
  border-style: dashed;
  color: var(--text-muted);
}

/* 错题复习：本题用时（写在「答对了」右边） */
.nb-elapsed {
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}

/* 右上角实时计时：与「未作答/答对/答错」拉开间距（用户反馈：太近） */
.nb-live-timer {
  margin-right: 10px;
  font-variant-numeric: tabular-nums;   /* 数字等宽，跳动时不抖 */
  color: var(--text-muted);
}
/* 「答对了 + 用时」整体靠左 */
.nb-result-left {
  display: inline-flex;
  align-items: center;
}

/* 历史对局：模块类型标签 */
.hist-module {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

/* 做题时 🚩 标记按钮（激活=已标记） */
.q-flag-btn { opacity: .45; }
.q-flag-btn.active { opacity: 1; filter: drop-shadow(0 0 4px rgba(255,120,80,.55)); }

/* 错题集：跨设备同步区块 */
.nb-sync-card {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.nb-sync-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.nb-sync-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text);
}
.nb-sync-input {
  flex: 1;
  min-width: 160px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* 题型列表：各项之间用细线分隔（与历史对局区一致） */
.ratio-item + .ratio-item {
  border-top: 1px dashed var(--border);
  padding-top: 12px;
  margin-top: 12px;
}

/* 快速解法：整行、带 💡、自动换行，不与右侧按钮挤在一起 */
.quick-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  word-break: break-word;
}
.quick-line .quick-icon { flex: 0 0 auto; }

/* 涂鸦模式：右侧透明滚动带
   ------------------------------------------------------------
   用户反馈：带抓手时，自制抓手固定不动、浏览器自带抓手游走，
   两个一起看着冲突，滑动时还会"跳"。
   所以这里做成**完全透明**、无抓手、无边框 —— 相当于把浏览器
   自带的滚动条"加宽"了 34px，视觉上没有任何多余元素。
   ---------------------------------------------------------- */
.anno-scroll-rail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 34px;
  z-index: 90;
  display: none;
  background: transparent;
  border: 0;
  touch-action: none;   /* 交给 JS 滚动，避免与原生滚动叠加跳动 */
}
